home *** CD-ROM | disk | FTP | other *** search
- ;
- ; Z3LIB Module Name: Z3APPCL
- ; Author: Richard Conn
- ; Z3LIB Version Number: 1.3
- ; Module Version Number: 1.1
- ;
- public appcl
-
- ext getcl1,getcl2
-
- ;
- ; Macros
- ;
- putrg macro
- push bc
- push de
- push hl
- endm
-
- getrg macro
- pop hl
- pop de
- pop bc
- endm
-
- ;
- ; APPCL 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).
- ;
- appcl:
- putrg ;save registers
- push hl ;save ptr to new line
- call getcl1 ;is command line available?
- jp nz,pcl0
- ;
- ; Error Return
- ;
- nocl:
- pop hl ;get ptr to new line
- getrg ;restore registers
- xor a ;ret Z
- ret
- ;
- ; Pack old command line
- ;
- pcl0:
- ld b,a ;count of chars in B
- push hl
- call getcl2 ;get address of new first command
- ld (oldcmd),hl ;save position
- pop hl
- 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
- ld hl,(oldcmd) ;get address of first char of remaining CL
- ;
- ; Copy Old Command Line into Front of Buffer
- ;
- pcl1:
- ld a,(hl) ;copy
- ld (de),a
- inc hl
- inc de
- dec b ;count down
- or a ;EOL?
- jp nz,pcl1
- inc b ;B = number of bytes left in buffer
- pop hl ;HL = address of first char of new command line
- ;
- ; HL pts to first char of new command line
- ; DE pts to after ending 0 of old command line
- ; B = number of chars remaining before overflow of Z3 command line
- ;
- push de ;save ptr on stack
- pcl2:
- ld a,(hl) ;get next char
- ld (de),a ;put next char
- dec b ;count down remaining chars
- jp z,nocl ;overflow if reached zero
- inc hl ;pt to next
- inc de
- or a ;EOL?
- jp nz,pcl2
- pop hl ;get ptr to first char of new line
- dec hl ;pt to ending 0 of old line
- ld (hl),';' ;store semicolon separator
- getrg
- or 0ffh ;no error
- ret
-
- ;
- ; Data
- ;
- oldcmd: ds 2 ;pointer to old command line in CL buffer
-
- end