home *** CD-ROM | disk | FTP | other *** search
- ;
- ; Z3LIB Module Name: Z3PCL
- ; Author: Richard Conn
- ; Z3LIB Version Number: 1.3
- ; Module Version Number: 1.1
- ;
- public putcl
-
- ext getcl1,getcl2
-
- ;
- ; Macros
- ;
- putrg macro
- push bc
- push de
- push hl
- endm
-
- getrg macro
- pop hl
- pop de
- pop bc
- endm
-
- ;
- ; Z3PCL stores a command line in the ZCPR3 command line buffer.
- ; This command line is pted to by HL. On return, A=0 and Zero Flag Set
- ; if command line overflow is possible (no change to command line).
- ;
- putcl:
- putrg ;save registers
- ex de,hl ;DE pts to new line
- call getcl1 ;is command line available?
- jp nz,pcl1
- ;
- ; Error Return
- ;
- nocl:
- getrg ;restore registers
- xor a ;ret Z
- ret
- ;
- ; Process Command Line
- ;
- pcl1:
- ld b,a ;char count in B
- ex de,hl ;HL pts to new line
- push hl ;save ptr to new line
- pcl2:
- ld a,(hl) ;go to end of line
- or a ;at end?
- jp z,pcl3
- inc hl ;pt to next
- dec b ;count down
- jp nz,pcl2
- pop hl ;clear stack
- jp nocl ;command line too long
- ;
- ; At End of New Command Line (ptr on stack)
- ; Ptr to first char of new command line on stack
- ; HL pts to ending 0 of new command line
- ; B = number of chars remaining before overflow of Z3 command line
- ;
- pcl3:
- ex de,hl ;DE pts to last byte
- push de ;save ptr to last byte in case of error
- call getcl2 ;pt to tail of command line buffer
- ld a,(hl) ;get first char of tail
- cp ';' ;continuation?
- jp z,pcl4
- or a ;done?
- jp z,pcl4
- ld a,';' ;set continuation char
- ld (de),a
- inc de
- dec b ;count down
- jp z,pcl5 ;overflow
- ;
- ; Copy tail onto end of new command line
- ;
- pcl4:
- ld a,(hl) ;get next char
- ld (de),a ;store it
- inc hl ;pt to next
- inc de
- or a ;done?
- jp z,pcl6
- dec b ;count down
- jp nz,pcl4
- ;
- ; Command Line too Long
- ;
- pcl5:
- pop hl ;get ptr to end of old line
- ld (hl),0 ;store ending 0
- pop af ;clear stack
- jp nocl
- ;
- ; New Command Line OK
- ;
- pcl6:
- pop af ;clear stack
- call getcl1 ;get ptr to buffer
- ld de,4 ;pt to first char in buffer
- ex de,hl
- add hl,de
- ex de,hl
- ld (hl),e ;store address
- inc hl
- ld (hl),d ;DE pts to first char of buffer
- pop hl ;HL pts to first char of new line
- ;
- ; Copy New Command Line into Buffer
- ;
- pcl7:
- ld a,(hl) ;copy
- ld (de),a
- inc hl
- inc de
- or a ;EOL?
- jp nz,pcl7
- ;
- ; Exit with OK Code
- ;
- getrg ;restore regs
- xor a ;set NZ
- dec a
- ret
-
- end