; PROGRAM: PAUSE [derived from SAK (Strike Any Key) by Richard Conn] ; AUTHOR: Jay Sage ; VERSION: 1.1 ; DATE: 14 September 1987 ; * * * IMPORTANT NOTE * * * ; ; This program is copyrighted 1986 by NAOG/ZSIG. It may be copied and modified ; freely for personal use but may not be sold or distributed for a fee. ; Modified versions must be submitted to and approved by NAOG/ZSIG before they ; may be distributed. See the file ZSIGPOL1.DOC on Z-Nodes for the ZSIG policy ; on signing out and modifying programs. ;============================================================================= ; ; R E V I S I O N H I S T O R Y ; ;============================================================================= vers equ 11 ; Fixed bug in message display configuration control. ; The FLAGMSG code was never implemented, and the ; configuration setting at the beginning of the code ; was ignored. Jay Sage, 09/14/87 ;vers equ 10 ; New program called PAUSE derived from SAK. New ; features include F option to set or rest the ; program error flag instead of aborting command line ; or ZEX. Thus PAUSE can be like "IF INPUT" except that a ; a default answer of TRUE is given after pause time ; elapses. ; Jay Sage 14 November 1986 ;SAK version 22 ; Changed to allow the BIOS to return from ; CONIN: with the zero flag set. CONDIN: ; subroutine in SYSLIB assumes, incorrectly, ; that this flag will always be non-zero. ; Joe Wright 21 September 1985 ; Program updated by Ken Davidson ; PAUSE is used for the following purposes: ; 1) to wait for user interaction before continuing ; and to allow the user to abort a multiple ; command line, abort ZEX, or set/clear the ; program error flag; and/or ; 2) to command the user's attention by ringing the ; bell at his console. ; ; The PAUSE command line is: ; PAUSE text or PAUSE /o... text ; ; PAUSE is invoked with the following options: ; A -- DO NOT Allow the User to Abort MCL ; B -- Ring Bell ; F -- Set/Reset Program Error Flag (No Abort) ; Pnnnn -- Pause nnnn seconds and continue if no ; response by that time ; Z -- Allow the User to Abort ZEX ; ; The line of prompting text can contain special characters for ; allowing the generation of lowercase output and control characters. ; In the default version '^' preceding a character causes that ; character to be converted to a control character. The sequence ; '%>' causes all subsequent output to be converted to lowercase. The ; sequence '%<' causes uppercase output to resume. Any other character ; after '%' is displayed as is ('%^' will give a caret). Here is an ; example of the use of these features: ; ; A0>PAUSE P%>ROGRAM PAUSED^M^J^I%RESS A KEY TO RESUME: ; Program paused ; Press a key to resume: _ ; ; The most useful control characters are ^M (carriage return), ; ^J (linefeed), and ^I (tab). Since the 'text' begins with the ; first nonblank character, putting in '% ' allows one to include ; leading blank space. ;============================================================================= ; ; C O N F I G U R A T I O N E Q U A T E S ; ;============================================================================= false equ 0 true equ not false no equ false yes equ true upcase equ yes ; Default to upper case string output casech equ '%' ; Lead-in char for case change control contch equ '^' ; Lead-in char for control-char output lcase equ '>' ; Shift to lower case code ucase equ '<' ; Shift to upper case code fmsgs equ yes ; Yes to show error flag set/clear messages z3env aset 0fe00h tbuff equ 80h cr equ 0dh lf equ 0ah tab equ 09h bel equ 'G'-'@' ctrlc equ 'C'-'@' ; External (Z3LIB and SYSLIB) References ext z3init,wait1s,getcl1,qprint,qcrlf ext strtzex,stopzex,putzex,getznc,getzrun ext pstr,print,cst,cin,eval10,cout,sksp ext puter2 ; External ZCPR3 Environment Descriptor jp start db 'Z3ENV' ; This is a ZCPR3 Utility db 1 ; External Environment Descriptor z3eadr: dw z3env db 'CONFIG>' flagmsg: db fmsgs start: ld hl,(z3eadr) ; Point to ZCPR3 environment ; Start of Program -- Initialize ZCPR3 Environment ; NOTE THAT THIS PROGRAM DOES NOT CREATE A LOCAL STACK; IT RELIES ; ON THE SYSTEM STACK! call z3init ; Initialize the ZCPR3 environment ; Init Options and Parse and Interpret Command Line xor a ; Preset all flags to zero ld hl,flags ld b,nflags flaginit: ld (hl),0 inc hl djnz flaginit dec a ; Options turned ON ld (abortf),a ; ..abort ld hl,tbuff+1 ; Point to command line tail call sksp ; Skip over spaces ld a,(hl) ; Get first character cp '/' ; Option? jp nz,optdone inc hl ; Skip option lead-in char opt: ld a,(hl) ; Get option letter or a ; Done? jp z,optdone inc hl ; Point to next option cp ' ' ; Process text? jp z,optdone cp 'A' ; Abort? jp z,optabort cp 'B' ; Bell? jp z,optbell cp 'P' ; Pause? jp z,optpause cp 'Z' ; ZEX abort? jp z,optzex cp 'F' ; Error flag? jp z,opteflag ; Unrecognized options produce help screen call print db cr,lf,tab,tab db 'PAUSE Version ',[vers/10]+'0','.',[vers mod 10]+'0' db ' [(c)1986 ZSIG]' db cr,lf,lf,'SYNTAX: "ASK text" or "ASK /o... text"',cr,lf,lf db 'Options:' db tab, 'A -- DO NOT Allow Abort',cr,lf db tab,tab,'B -- Ring Bell',cr,lf db tab,tab,'F -- Set/Reset Program Error Flag (no abort)',cr,lf db tab,tab,'Pnnnn -- Pause nnnn secs',cr,lf db tab,tab,'Z -- Allow to Abort ZEX',cr,lf,lf db 'Special text characters:',cr,lf db tab,contch,'x' db tab,'convert character ''x'' to control character',cr,lf db tab,casech,lcase db tab,'begin lowercase output',cr,lf db tab,casech,ucase db tab,'begin uppercase output',cr,lf db tab,casech,'x' db tab,'output ''x'' directly (e.g., ',casech,casech, db ' or ',casech,contch,')',cr,lf db 0 ret ; Process A option (Abort MCL) optabort: xor a ; Turn off abort ld (abortf),a jp opt ; Process B option (Ring Bell) optbell: ld a,0ffh ; Turn on bell ld (bell),a jp opt ; Process Pnnnn option (Pause nnnn seconds) optpause: call eval10 ; Convert argument to decimal value in DE ex de,hl ; Put value into HL ld (delay),hl ex de,hl ; HL pts to next char jp opt ; Process Z option (Allow ZEX abort) optzex: ld a,0ffh ; Allow abort ld (stopz),a jp opt ; Process F option (Program Error Flag Set/Reset) opteflag: ld a,0ffh ; Enable program error flag set/reset option ld (eflag),a jp opt ; Continue Command Processing optdone: ld a,(hl) ; Any message? or a jp z,optdn1 ld (mpflag),a ; Set message printed flag call prtmsg ; Display message in command tail optdn1: call stopzex ; Suspend ZEX processing ld hl,(delay) ; Get delay count in HL ; Main Delay Loop askloop: ; Ring Bell if Option Selected ld a,(bell) ; Get flag or a ; Set zero flag call nz,bout ; Ring bell and delay ; Get character if one is available ; call condin ; Optionally get character ; jp nz,gotchar ; Process character ; This change in case the BIOS CONIN: returns with zero flag set. call cst jr nz,nochar getchar: call cin jp gotchar nochar: ; Loop if No Delay ld a,h ; Check for no delay or l jp z,askloop ; Delay and test for input call wait1s ; Delay 1 sec dec hl ; Count down ld a,h ; Done? or l jp nz,askloop ; Process Input Character ; If no input and timout instead, A=0 for continuation character gotchar: cp ctrlc ; Abort? jp z,abort resume: ld a,(mpflag) ; Message printed? or a ; 0=no call nz,qcrlf ; New line if yes ld a,(eflag) ; See if program error flag is to be reset or a jr z,resume1 ; If not, jump past this xor a ; Reset A call puter2 ; Store value in program error flag ld a,(flagmsg) ; See if message is to be printed or a jr z,resume0 call qprint db cr,'Program Error Flag Cleared ...',0 resume0: jp strtzex ; Resume ZEX processing resume1: ld a,(flagmsg) ; See if message is to be printed or a jr z,resume0 call qprint db cr,'Resuming ...',0 jr resume0 ; Resume ZEX processing ; Abort Multiple Command Line if there is one abort: ld a,(eflag) ; See if program error flag is to be set or a jr z,abort0 ; If not, skip ld a,0ffh ; Set the program error flag call puter2 ld a,(mpflag) ; Message printed? or a ; 0=no call nz,qcrlf ; New line if yes ld a,(flagmsg) ; See if message is to be printed or a jr z,resume0 call qprint db cr,'Program Error Flag Set ...',0 jr resume0 ; Resume with 'start zex' routine abort0: ld a,(abortf) ; Abort allowed? or a ; 0=no jp z,resume call getcl1 ; Get address of command line buffer ld a,h ; Any buffer? or l jp z,abort1 ld e,(hl) ; Get address of next char inc hl ld d,(hl) ex de,hl ; HL pts to next char ld (hl),0 ; Set no further command abort1: ld a,(mpflag) ; Message printed? or a ; 0=no call nz,qcrlf ; New line if yes call qprint db cr,lf,'Aborting ...',0 call getzrun ; Is ZEX running? ret z ; Done if not call strtzex ; Resume ZEX processing ld a,(stopz) ; Stop ZEX? or a ; 0=no ret z ; Resume processing call getznc ; Get next ZEX char ld (hl),0ffh ; Store abort ZEX code ret ;----------------------------------------------------------------------------- ; Ring Bell and Delay Briefly bout: ld a,bel ; Ring bell call cout push hl ; Save HL ld hl,(delay) ; Do not delay if pause already invoked ld a,h ; Zero delay? or l jp nz,bout1 ; Skip delay call wait1s ; Delay bout1: pop hl ret ;----------------------------------------------------------------------------- ; Output string with lowercase and control-character conversion prtmsg: ; Set up default output case xor a ; Lower case flag setting if upcase ; If upper case default dec a ; ..change to nonzero endif ld (casefl),a ; Store flag value ; Loop to echo chars prtmsg1: call getnext ; Get next character (aborts if none) cp contch ; Control-character lead-in? jr nz,prtmsg2 ; If not, jump call getnext ; If so, get next character and 1fh ; Convert to control character jr z,prtmsg1 ; If null, skip it jr prtmsg4 ; Else echo it prtmsg2: cp casech ; Case shift prefix? jr nz,prtmsg4 ; No, normal echo call getnext ; Get next character cp ucase ; Up-shift character? jr z,prtmsg3 ; Store non-zero value in case flag cp lcase ; Lower-case character? jr nz,prtmsg4 ; No, echo the character as is xor a ; Else, clear case flag prtmsg3: ld (casefl),a jr prtmsg1 ; On to next character prtmsg4: call charout ; Send char in correct case jr prtmsg1 ; Output char to printer or console charout: ld c,a ; Save character in C cp 'A' ; If less than 'a' jr c,charout1 ; ..leave as is cp 'Z'+1 ; If greater than 'z' jr nc,charout1 ; ..leave as is add a,20h ; Else convert to lower case charout1: ld d,a ; Save lower case version in d ld a,(casefl) ; Test case flag or a ld a,c ; Get ready to display upper case character jr nz,charout2 ; If upper case selected, go on as is ld a,d ; Else substitute lower case version charout2: jp cout ; Display the character ; Read a character from the command line; terminate routine if end of ; line reached. getnext: ld a,(hl) ; Get character inc hl ; Point to next one or a ; Check for end of string ret nz ; If not end, return pop hl ; Else, clean up stack ret ; And exit from routine ; Data Buffers dseg flags: casefl: ds 1 ; Upper/lower case output flag abortf: ds 1 ; Abort flag bell: ds 1 ; Bell flag delay: ds 2 ; Delay constant mpflag: ds 1 ; Message printed flag stopz: ds 1 ; Stop ZEX flag eflag: ds 1 ; Error flag set/reset flag nflags equ $ - flags end