home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
SLIB2.LBR
/
SLPSTR.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
2KB
|
100 lines
;
; SYSLIB Module Name: SLPSTR
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public lpstr
;
; LPSTR --
; PRINT STRING PTED TO BY HL ON LST:
; AFFECT ONLY HL -- WHEN DONE, HL PTS TO BYTE AFTER STRING
;
EXT CLOUT
EXT LOUT
LPSTR:
PUSH DE ; SAVE REGS
PUSH BC
PUSH AF ; SAVE REG A AND FLAGS
LD C,0 ; SET POSITION COUNT
PSL: LD A,(HL) ; GET BYTE
INC HL ; PT TO NEXT
OR A ; 0=DONE
JP Z,PSD
CP TAB ; EXPAND <TAB>
JP Z,PST
;
; PRINT CHAR
;
INC C ; INCR POSITION
CALL CLOUT ; PRINT IT ON LST:
CP CR ; CHECK FOR <CR>
JP Z,PCR
CP LF ; CHECK FOR <LF>
JP Z,PLF
CP BEL ; CHECK FOR <BEL>
JP Z,PLF
CP BS ; CHECK FOR <BS>
JP Z,PBS
JP PSL
;
; <CR> -- RESET POSITION COUNT
;
PCR: LD C,0 ; RESET
JP PSL
;
; <LF>, <BEL>, <NULL> -- CURSOR DIDN'T ADVANCE
;
PLF: DEC C ; BACK UP COUNT BY 1
JP PSL
;
; <BS> -- CURSOR WENT BACKWARD, MAYBE
;
PBS: LD A,C ; CHECK FOR ZERO
OR A
JP Z,PSL
DEC C ; BACK UP COUNT BY 2
DEC C
JP PSL
;
; EXPAND <TAB>
;
PST: LD A,C ; GET COUNT
AND 7 ; MASK FOR SUB FROM 8
LD B,A ; STORE TEMPORARILY
LD A,8 ; SUBTRACT FROM 8 FOR <SP> COUNT
SUB B
LD B,A ; COUNT IN B
ADD A,C ; ADD TO POSITION COUNT
LD C,A
LD A,' ' ; PRINT <SP>
PSTL: CALL LOUT
DEC B ; COUNT DOWN
JP NZ,PSTL
JP PSL
;
; PSTR DONE
;
PSD: POP AF ; RESTORE REG A AND FLAGS
POP BC ; RESTORE REGS
POP DE
RET
;
; ASCII SPECIAL CHARACTER EQUATES
;
NULL EQU 0 ; NULL
BEL EQU 7 ; BELL
BS EQU 8 ; BACKSPACE
TAB EQU 9 ; TAB
LF EQU 10 ; LINE FEED
CR EQU 13 ; CARRIAGE RETURN
CTRLR EQU 'R'-40H ; CTRL-R
CTRLU EQU 'U'-40H ; CTRL-U
CTRLX EQU 'X'-40H ; CTRL-X
DEL EQU 7FH ; DELETE CHAR
END