home *** CD-ROM | disk | FTP | other *** search
- Z3ENV DEFL 0FE00H
- FCB EQU 5CH
- BDOS EQU 5
- PRTSTR EQU 9
- CR EQU 0DH
- LF EQU 0AH
- BEL EQU 07H
-
- EXTRN Z3INIT,GETIOP,GETCL2
- EXTRN GETEFCB,GETQUIET
- EXTRN CLRCL,IFEND,INSTR
-
- START: JP BEGIN
- DB 'Z3ENV',3 ; Tool ID, allow high ORG
- Z3EADR:
- DW Z3ENV ; Z33/BGii will poke this anyway
- DW START ; Linker will calculate this
- BEGIN: LD HL,(Z3EADR)
- CALL Z3INIT ; Educate Z3LIB
- LD HL,HLPMSG ; Convenient source
- LD DE,STRING ; Target buffer
- LD BC,STREND-STRING; String length
- LDIR ; For re-entrance, move 'em out
- EX DE,HL
- LD (HL),B ; B's got a NULL, plant it
- LD D,B ; Use to zero out D register
- CALL GETIOP ; Get IOP start
- LD E,12H ; DE = 0012H
- JR NZ,CHKOPT ; No IOP, use BIOS jump entry
- LD A,(HL)
- OR A
- JR NZ,CHKOPT
- DOBIOS: LD HL,(1) ; HL = BIOS cold boot jump addr.
- LD E,09H ; DE = 0009H
- CHKOPT: ADD HL,DE
- LD A,(FCB+2) ; Check for user options
- CP '/' ; Help query?
- JR Z,HELP
- CP 'N' ; Force CON: output on?
- JR Z,CONON
- CP 'F' ; Force CON: output off?
- JR Z,FRCOFF
- LD A,(HL) ; Get jump address contents
- CP 0C9H ; Is it already a RET?
- JR Z,CONON ; Then patch it back to a JP
- CP 0C3H ; JP is only acceptable byte
- JR Z,CONOFF ; OK, let 'er rip
- CALL GETIOP ; Re-test for IOP, use BIOS?
- JR NZ,DOBIOS ; No IOP means damaged BIOS
- LD DE,BIOSER ; So point to msg and go home
- JR DOMSG
- CONOFF:
- EX DE,HL ; Otherwise stash address in DE
- CALL GETCL2 ; Are there pending commands?
- EX DE,HL ; Swap back registers
- JR Z,NOCMD ; Barf if no further commands
- PUSH HL ; Otherwise stash addr. on stack
- CALL GETEFCB ; Get Z3 External FCB address
- JR Z,NOEFCB ; No EFCB, use name "CONCTRL"
- LD B,8 ; Down-counter in B
- EX DE,HL ; EFCB start (drive code) in DE
- LD HL,STRING-1 ; One byte below buffer into HL
-
- LOOP: INC HL ; Bump buffer pointer
- INC DE ; Bump EFCB pointer
- LD A,(DE) ; Get character from EFCB
- AND 7FH ; Mask out any attribits
- CP ' ' ; Done?
- JR Z,DONE ; Done if Z, (HL) at terminator
- LD (HL),A ; Otherwise, character to buffer
- DJNZ LOOP ; Loop if not finished
- INC HL ; Bump to terminator position
-
- DONE: LD (HL),0 ; Poke a NULL terminator
-
- NOEFCB:
- CALL GETCL2 ; Pending command is start
- LD DE,STRING ; String to compare
- CALL INSTR ; Search
- POP HL ; Get back CONOUT jump addr
- JR NZ,UNBAL ; Search failed, bitch 'n barf
-
- FRCOFF: CALL WAITIT ; Tell user to wait
- LD (HL),0C9H ; Patch the jump to a RET
- RET ; Return to Z, CONOUT disabled
-
- CONON: LD (HL),0C3H ; Poke (HL) to a JP
- RET ; Return to Z, CONOUT enabled
-
- HELP: LD DE,HLPMSG ; Point to message
- XOR A ; Force output
- JR DOMSG ; Exit via BDOS
-
- UNBAL: CALL IFEND ; Decrement IF level
- JR NZ,UNBAL ; Until none active
- CALL CLRCL ; Discard rest of command line
- LD DE,UNBAMG ; Point to message
- JR MSG ; (Conditional) bitch 'n barf
-
- NOCMD: LD DE,NCOMMG ; Point to message
- JR MSG ; etc.
-
- WAITIT:
- PUSH HL ; Save IOP CONOUT jump pointer
- LD DE,WAITMG ; Point to message
- CALL MSG ; Conditionally print it
- POP HL ; Restore pointer
- RET ; Return to caller
-
- MSG: CALL CONON ; Make sure we're not muzzled
- CALL GETQUIET ; Does Z3 want us stifled?
- DOMSG: LD C,PRTSTR ; BDOS's Print string function #
- JP Z,BDOS ; Exit via BDOS if loud
- RET ; Just return to Z if quiet
-
-
- ; MESSAGES
-
- UNBAMG:
- DB BEL,'Unbalanced CONCTRL invocation, aborting.',CR,LF,'$'
-
- NCOMMG:
- DB BEL,'No pending commands, CONCTRL aborting.',CR,LF,'$'
-
- WAITMG: DB 'Stand by.....$'
-
- BIOSER: DB BEL,'WARNING: BROKEN BIOS!$'
-
- HLPMSG:
- DB 'CONCTRL, Version 1.0',CR,LF
- DB 'Syntax:',CR,LF
- DB ' CONCTRL OFF (turns off the CON: device output)',CR,LF
- DB ' CONCTRL ON (turns on the CON: device output)',CR,LF
- DB 'CONCTRL with no tail toggles the CON: output state.',CR,LF
- DB 'This mode is for balanced command lines only, such as:',CR,LF
- DB ' CONCTRL;cmd1;cmd2;cmd3;CONCTRL (cmd?=silent commands)',CR,LF
- DB '$'
-
-
- ; DATA (initialized, bytes defined for reference only)
-
- DSEG
-
- STRING: DB 'CONCTRL'
- STREND: DS 4 ; Enough extra for 12345678 & 0
-
- END