extrn .skipblks, .nextch ; ; Parse any options from text line de^ into storage hl^. Advance ; de to 1st non-blank character, and to option string delimiter ; if a valid option string found. bc is a pointer to an option ; definition string, in the form: ; bc^ char Required "header" char for an option string ; bc+1^ count Number of options available ; bc+2^ char A char that may appear in the option string ; .... etc. (for count chars) ; (The storage at bc^ is an image, and is never altered). ; ; At exit, if a valid option string is found, hl^ contains a copy ; of the definition string, with all chars found in the input ; string ZEROED. i.e. a zero value means option set. Options ; returns with a = 0ffh, and the NZ flag set in this case. ; ; If no valid option string is found, or some characters are not ; present in the image (or present more than once), hl^ contains ; an unmodified copy of the definition string, and options returns ; a = 0, with the Z flag set. ; ; All candidate characters are upshifted before testing. Thus an ; option definition string containing lower case characters can never ; be matched. Similarly, if the definition string contains 0 bytes, ; these are pre-matched locations. This allows configuration of ; valid input options in the image string for installation purposes. ; ; An option string (not the definition string) consists of a trigger ; character, followed by a series of characters. If any string char ; acter is not present in the option template, the whole string is not ; an option string, and input conditions are restored. If all chars ; are present in the template, those positions are zeroed, and the ; input parser is advanced to the terminal blank (or control char). ; ; If a valid option list is found, 0ffh and nz is returned, ; otherwise 0 and z flag signal no valid option parsed. In any ; case all initial blanks in the input string have been skipped. ; a,f,d,e .options:: call odeflt; set default options call .skipblks rz; end of line, no options push h push b cmp m inx h jnz o9; not an option, back up push d; save for possible abort o1: call .nextch jz o4; terminated option string push h; save option array for rescan mov b,m; count of options inx h o2: cmp m; This flag? jnz o3; not an option, back up mvi m,0; set flag pop h jmp o1; and check next o3: inx h dcr b jnz o2; and test next option pop h jmp o8; not valid option, restore ptr o4: inx sp inx sp; purge saved input pointer pop b pop h ori 0ffh; signal an option found (NZ) ret; advanced past option field ; ; Some option invalid - not option field. Restore defaults o8: pop d; restore input pointer o9: pop b pop h; and reset options to default ; " " ; Set all options to default in hl^, source bc^. A := 0, Z flag ; a,f odeflt: ldax b mov m,a; the 'trigger' char push h push d push b inx b inx h ldax b mov d,a inr d od1: ldax b mov m,a inx b inx h dcr d jnz od1 pop b pop d pop h xra a; set z flag, return 0 ret