home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-13 | 20.0 KB | 1,153 lines |
- ; PROGRAM: DEBUGRCP.ASM
- ; AUTHOR: RICHARD CONN
- ; VERSION: 1.0
- ; DATE: 30 JUNE 84
- ; PREVIOUS VERSIONS: NONE
- ;
- ;++++
- ; Version 1.1 - Rob Friefeld 2 Oct 87
- ; - Added two new commands:
- ; 'F' Fill Memory, syntax: start address, end address, byte value
- ; 'M' Move Memory, syntax: start address, end address, destination addr
- ; - This RCP (with CLS and H) requires 2367 bytes. Using HARDVID.LIB,
- ; about 500 bytes are saved.
- ; - Would someone like to add Go and Breakpoint commands??
- ;
- ; Version 1.0A - rdf 9/87
- ; - Intended for large RCP (takes over 2k)
- ; - Included hex calculator routine from MU3
- ; - Made minor changes to achieve compatibility with Z33RCP modules
- ; - Expanded command synomyms:
- ; "+" "=" "." <cr> advance one block
- ; "-" "," back one block
- ; - Put in some relative jumps and djnz's.
- ; "De-modularized" stndout/stndend and tinit/dinit to save a few bytes.
-
- false equ 0
- true equ -1
-
- hardvid equ false ; Use hard-coded or TCAP/VLIB routines
- ; Either TCAPVID.LIB or HARDVID.LIB
- ;++++
- ; DEBUGRCP is a resident debug command package for ZCPR3.3
- ;
- eolch equ 0 ; End of line char
- sepch equ ',' ; Separator char
- erow equ 6 ; First row of editor display
- ecol equ 4 ; First col of editor display
- ecolc equ ecol+16*3+8 ; First col of editor char display
- ecurs equ '>' ; Editor cursor
- prrow equ 22 ; Prompt row
- prcol equ 10 ; Prompt column
- prcoli equ prcol+15 ; Prompt input col
- errow equ 23 ; Error message row
- ercol equ 15 ; Error message column
-
-
- ;
- ; DEFINE FREE SPACE
- ;
- mu:
- call retsave ; Save cpr return address
-
- ld hl,tbuff ; Determine address
- ld (hl),126 ; 126 chars input allowed
- ld (buffer),hl ; Set ptr
- ;
- ; SET UP ARROW KEYS
- ;
- ld hl,z3env ; Pt to environment descriptor
- ld de,80h+10h ; Pt to arrow key info
- add hl,de
- ld de,edcurt ; Pt to cursor table
- ld bc,404h ; 4 arrow keys
- arrow:
- ldi ; (Decrements c)
- inc de ; Point to next entry
- inc de
- djnz arrow
- ;
- ; Initialize Terminal
- ;
- call tinit
- ;
- ; Check for Command Line Parameter
- ;
- ld hl,fcb+1 ; Pt to first char
- ld a,(hl) ; Get char
- cp ' ' ; No param?
- jr nz,pcheck
- ld hl,tpa ; Pt to tpa
- jr mu3
- ;
- ; We have a parameter
- ;
- pcheck:
- call hexin ; Convert to binary
- ex de,hl ; Hl=value
-
- ;
- ; Run MU3
- ; HL contains starting address
- ;
- mu3:
- ld (block),hl ; Save ptr to block
- ;
- ; REFRESH EDIT SCREEN
- ;
- edit0:
- call vcls ; New screen
- call at
- db 2,35 ; Row 2, col 35
- call vprint ; Banner
- db 'MU 1.1 RC','P'+80h
- ;
- ; REENTER MU3 WITH PTRS RESET
- ;
- mu3r:
- xor a ; A=0
- ld (eindex),a ; Set index to 0 (first element)
- mu3nr: call edplot ; Plot buffer data
- ;
- ; INPUT EDITOR COMMAND
- ;
- editcmd:
- call prmsg ; Position at prompt message
- db 'MU Command','?'+80h
- call prinp ; Position at prompt input
- db 0
- call cin ; Get char
- call caps ; Capitalize
- ld b,a ; Command in b
- ld hl,edcurt ; Process cursor commands first
- call cmd ; Process command
- ld hl,ecmdtbl ; Editor command table
- call cmd ; Process command
- ;
- ;INPUT ERROR
- ;
- what:
- call vprint ; Error message
- db bel+80h
- jr editcmd
-
- ;
- ; Position at Prompt Message and Print it
- ;
- prmsg:
- call at ; Position
- db prrow,prcol
- jp vprint ; Print it
- ;
- ; Position at Prompt Input and Print Prompt
- ;
- prinp:
- call at ; Position
- db prrow,prcoli
- jp vprint ; Print it
- ;
- ;Command Table Search and Execute
- ;
- cmd:
- ld a,(hl) ; Check for end of table
- or a
- ret z ; Command not found
- cp b ; Match?
- jr z,cmdrun
- inc hl ; Skip to next entry in table
- inc hl
- inc hl
- jr cmd
- ;
- ;RUN COMMAND
- ;
- cmdrun:
- inc hl ; Pt to low address
- ld e,(hl)
- inc hl ; Pt to high address
- ld d,(hl)
- ex de,hl
- pop af ; Clear stack
- jp (hl) ; Run routine
- ;
- ;PLOT BUFFER DATA
- ;
- edplot:
- ld h,erow-1 ; Set row
- ld l,ecol ; Set column
- call gotoxy ; Position cursor
- call vprint
- db dim
- db ' 0 1 2 3 4 5 6 7 8 9 A B C D E F'
- db bright,0
- inc h ; Next row
- call gotoxy ; Position cursor
- ex de,hl ; Position in de
- ld hl,(block) ; Pt to data
- ld b,8 ; 8 lines
- ;
- ;Print Next Line on Screen
- ;
- edit00:
- call stndout ; Go dim
- ld a,h ; Output address
- call pa2hc
- ld a,l
- call pa2hc
- call vprint
- db ':',bright,' '+80h
- ld c,16 ; 16 elements
- edit01:
- ld a,(hl) ; Get byte
- call pa2hc ; Print as hex
- call dspace ; Print 1 space
- inc hl ; Pt to next
- dec c ; Count down
- jr nz,edit01
- ex de,hl ; Position again
- inc h ; Next row
- call gotoxy
- ex de,hl
- djnz edit00
- ld h,erow ; Reset row
- ld l,ecolc ; Reset col
- call gotoxy ; Position cursor
- ex de,hl ; Position in de
- ld hl,(block) ; Pt to data
- ld b,8 ; 8 lines
- edit02:
- call bar ; Print bar
- ld c,16 ; 16 elements
- edit03:
- ld a,(hl) ; Get byte
- and 7fh ; Mask msb
- cp 7fh ; Don't print 7fh
- jr z,edit7f
- cp ' ' ; Space or more?
- jr nc,edit04
- edit7f:
- ld a,'.' ; Print dot
- edit04:
- call conout ; Print byte
- inc hl ; Pt to next
- dec c ; Count down
- jr nz,edit03
- call bar ; Print ending bar
- ex de,hl ; Position again
- inc h ; Next row
- call gotoxy
- ex de,hl
- dec b ; Count down
- jr nz,edit02
- jp edcur ; Position cursor
-
- ;
- ;EDITOR COMMAND TABLE
- ;
- ecmdtbl:
- db 'C'-'@' ; ^c = exit mu3
- dw edcc
- db 'R'-'@' ; ^r = refresh
- dw edit0
- db 'E'-'@' ; ^e=up
- dw edup
- db 'X'-'@' ; ^x=down
- dw eddown
- db 'D'-'@' ; ^d=right
- dw edright
- db 'S'-'@' ; ^s=left
- dw edleft
- db ' ' ; Nop
- dw editcmd
- db cr ; Advance a block
- dw editplus
- db '+' ; Advance
- dw editplus
- db '='
- dw editplus
- db '.'
- dw editplus
- db '-' ; Backup
- dw editminus
- db ','
- dw editminus
- db 'A' ; Address
- dw editadr
- db 'C' ; Command line
- dw editcl
- db 'H' ; Hex calc
- dw editcalc
- db 'N' ; Change numbers
- dw edithex
- db 'T' ; Change text
- dw editalp
- db 'F' ; Fill memory
- dw editfill
- db 'M' ; Move memory
- dw editmove
- db 0 ; End of table
- ;
- ; ARROW KEY DEFINITONS FROM TCAP
- ;
- edcurt:
- db 0 ; 0 indicates no arrow keys
- dw edup
- db 0
- dw eddown
- db 0
- dw edright
- db 0
- dw edleft
- db 0 ; End of table
-
- ;
- ; Get input line, check for blank and abort
- ;
- getline:
- call rdbuf ; Input text
- call edprcl ; Clear prompt line
- call sksp ; Skip to non-space
- ld a,(hl) ; Any input?
- or a ; 0=no
- ret nz
- pop af ; Lift stack
- jp editcmd
- ;
- ;Fill memory
- ;
- editfill:
- call edercl
- call prinp
- db dim,'Fill [Start, End, Value] ',bright,0
- call getline ; Input numbers
-
- call hexin ; Get the three numbers
- call sksp
- push de ; Save on stack
- call hexin
- call sksp
- push de ; Save on stack
- call hexin
- push de ; Save on stack
-
- pop bc ; BC = byte
- pop hl ; HL = end
- pop de ; DE = start
- xor a
- sbc hl,de ; HL = end - start
- jp c,what ; Error: end before start
- ex de,hl ; HL = start, DE = size of block
-
- editf1: ld (hl),c ; Do the fill
- inc hl
- ld a,d
- or e
- jp z,edita2 ; Replot on exit
- dec de
- jr editf1
-
- ;
- ; Move memory
- ;
- editmove:
- call edercl
- call prinp
- db dim,'Move [Start, End, Dest] ',bright,0
- call getline
-
- call hexin ; Get the three numbers
- call sksp
- push de
- call hexin
- call sksp
- push de
- call hexin ; DE = dest
- pop hl ; HL = end
- pop bc ; BC = start
-
- xor a ; Compute block length
- sbc hl,bc
- jp c,what ; Error: end before start
- push hl ; Swap HL,BC
- push bc
- pop hl ; HL = start
- pop bc ; BC = block size
-
- push hl ; Head move or tail move?
- xor a
- sbc hl,de ; Start - dest
- pop hl
- jr c,editm1 ; Tail move
-
- inc bc ; Head move, BC = # bytes to move
- ldir
- jp edita2
-
- editm1:
- add hl,bc ; Add length to start
- ex de,hl
- add hl,bc ; Add length to dest
- ex de,hl
- inc bc ; # bytes
- lddr ; Tail move
- jp edita2
-
-
- ;
- ;Enter Command Line
- ;
- editcl:
- call edercl
- call vprint ; Prompt input
- db cr,lf,'Command Line?',' '+80h
- call rdbuf ; Input text
- call putcl ; Store command line
- call crlf ; New line
- jp exit
- ;
- ; STORE COMMAND LINE
- ;
- putcl:
- ex de,hl ; Ptr to new line in de
- call getcl1 ; Get command line data
- ld b,a ; Char count in b
- ex de,hl ; Hl pts to new line
- push hl ; Save ptr to next line
- pcl1:
- ld a,(hl) ; Go to end of line
- or a ; At end?
- jr z,pcl2
- inc hl ; Pt to next
- djnz pcl1
- pop hl ; Clear stack
- ret ; Command line too long - abort
- ;
- ; AT END OF NEW COMMAND LINE
- ; 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 COMMAND LINE OVERFLOW
- ;
- pcl2:
- ex de,hl ; De pts to last byte
- push de ; Save ptr in case of error
- call getcl2 ; Pt to tail of command line buffer
- ld a,(hl) ; Get first char of tail
- cp ';' ; Continuation?
- jr z,pcl3
- or a ; Done?
- jr z,pcl3
- ld a,';' ; Set continuation char
- ld (de),a
- inc de
- dec b ; Count down
- jr z,pcl4 ; Overflow
- ;
- ; COPY TAIL ONTO END OF NEW COMMAND LINE
- ;
- pcl3:
- ld a,(hl) ; Get next char
- ld (de),a ; Store it
- inc hl ; Pt to next
- inc de
- or a ; Done?
- jr z,pcl5
- dec b ; Count down
- jr nz,pcl3
- ;
- ; COMMAND LINE TOO LONG
- ;
- pcl4:
- pop hl ; Get ptr to end of old line
- ld (hl),0 ; Store ending 0
- pop af ; Clear stack
- ret
- ;
- ; NEW COMMAND LINE OK
- ;
- pcl5:
- 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
- pop hl ; Hl pts to first char of new line
- ;
- ; COPY COMMAND LINE INTO BUFFER
- ;
- pcl6:
- ld a,(hl) ; Copy
- ld (de),a
- inc hl
- inc de
- or a ; Done?
- jr nz,pcl6
- ret
- ;
- ; GETCL1
- ;
- getcl1:
- ld hl,(z3env+18h) ; Get address of command line buffer
- push hl ; Save it
- inc hl ; Get size in a
- inc hl
- ld a,(hl)
- pop hl
- ret
- ;
- ; GETCL2
- ;
- getcl2:
- ld hl,(z3env+18h) ; Get address of command line buffer
- ld a,(hl) ; Get address of next char
- inc hl
- ld h,(hl)
- ld l,a ; Hl pts to next char
- ld a,(hl) ; Get it
- ret
-
-
- ;
- ; Get ASCII or HEX chars
- ;
- ahinput:
- call rdbuf ; Input text without prompt
- call edprcl ; Clear prompt line
- ld a,(eindex) ; Pt to position
- ex de,hl
- ld hl,(block) ; Compute offset
- ex de,hl
- add a,e
- ld e,a
- ld a,d
- adc 0
- ld d,a ; De pts to byte, hl pts to text
- ret
-
- ;Enter ASCII Chars
- ;
- editalp:
- call edercl
- call prinp ; Prompt input
- db dim,'Enter Text',bright
- db cr,lf,' -->',' '+80h
- call ahinput
- edita1:
- ld a,(hl) ; Get char
- cp eolch ; Eol?
- jr z,edita2 ; Refresh screen
- call getahv ; Get ascii or <hex> value
- ld (de),a ; Update byte
- inc hl ; Pt to next input char
- inc e ; Pt to next buffer byte
- jr nz,edita1
- edita2:
- jp mu3nr ; Done-refresh screen
-
- ;
- ;Enter Numbers
- ;
- edithex:
- call edercl
- call prinp ; Prompt input
- db dim,'Enter Hex Numbers',bright
- db cr,lf,' -->',' '+80h
- call ahinput
- edith1:
- ld a,(hl) ; Get hex digit
- cp eolch ; Eol?
- jr z,edita2 ; Refresh screen
- cp ' ' ; Skip spaces
- jr nz,edith2
- inc hl ; Skip space
- jr edith1
- edith2:
- push de ; Save ptr
- call hexin ; Get value and position hl
- ld a,e ; In a
- pop de ; Get ptr
- ld (de),a ; Put byte
- inc e ; Advance to next byte
- jr nz,edith1
- jr edita2 ; Done-refresh
-
- ;
- ;Calculate Sum and Differences
- ;
- editcalc:
- call edercl ; Clear error line
- call prinp ; Prompt input
- db dim,'Enter Two Hex Numbers - ',bright,0
- call getline
- call hexin ; Evaluate first number
- call sksp ; Skip to 2nd number
- push de ; Save first number
- call hexin ; Evaluate 2nd number
- pop hl ; Get first number
- call ermsg ; Print error message
- db 0
- call phl4hc ; Print first number
- call vprint
- db dim,' and',bright,' '+80h
- ex de,hl
- call phl4hc ; Print 2nd number
- ex de,hl
- call vprint
- db ' ',dim,'Sum =',bright,' '+80h
- push hl
- add hl,de
- call numout
- pop hl
- call vprint
- db ' ',dim,'Diff =',bright,' '+80h
- ld a,l ; Hl=hl-de
- sub e
- ld l,a
- ld a,h
- sbc a,d
- ld h,a
- call numout
- jp editcmd
- ;
- ;Output number in HL in Hex and Decimal
- ;
- numout:
- call phl4hc ; Hex
- call vprint
- db ' ','('+80h
- call phlfdc ; Decimal floating
- ld a,')' ; Close paren
- jp conout
-
- ;
- ; Position at Error Message and Print It
- ;
- ermsg:
- call at ; Position
- db errow,ercol
- jp vprint ; Print it
-
- edercl:
- call at
- db errow,ercol
- jp vereol
- ;
- ;CLEAR PROMPT LINE
- ;
- edprcl:
- call prinp ; Prompt line
- db 0
- ld b,40 ; 40 positions
- call vereol ; Clear to eol or 40 chars
- call at ; User input
- db errow,1
- ld b,79 ; 79 positions
- jp vereol
- ;
- ;Input Address
- ;
- editadr:
- call vprint
- db 'Address?',' '+80h
- call rdbuf ; Input text
- call sksp ; Skip to non-space
- ld a,(hl) ; Any input?
- or a ; 0=no
- jp z,editcmd
- call hexin ; Convert from hex
- ex de,hl ; Hl = address
- ld (block),hl
- jp edit0 ; Reenter
- ;
- ;Advance to Next Block
- ;
- editplus:
- ld de,128 ; 128 bytes
- editp1: ld hl,(block) ; To next block
- add hl,de
- ld (block),hl
- jp mu3r
- ;
- ;Backup to Last Block
- ;
- editminus:
- ld de,-128 ; 128 bytes
- jr editp1
- ;
- ;Exit MU3
- ;
- edcc:
- call dinit ; Deinit term
- call crlf ; New line
- jp exit
- ;
- ;EDIT MOVE: UP
- ;
- edup:
- call edccur ; Clear cursor
- ld a,(eindex) ; Backup index by 16
- sub 16
- ;
- ;Common EDIT MOVE Routine - on input, A=new index
- ;
- edmove:
- and 7fh ; Mod 128
- ld (eindex),a
- call edcur ; Set cursor
- jp editcmd
- ;
- ;EDIT MOVE: DOWN
- ;
- eddown:
- call edccur ; Clear cursor
- ld a,(eindex) ; Increment index by 16
- add 16
- jr edmove ; Common routine
- ;
- ;EDIT MOVE: RIGHT
- ;
- edright:
- call edccur ; Clear cursor
- ld a,(eindex) ; Increment index by 1
- inc a
- jr edmove ; Common routine
- ;
- ;EDIT MOVE: LEFT
- ;
- edleft:
- call edccur ; Clear cursor
- ld a,(eindex) ; Decrement index by 1
- dec a
- jr edmove ; Common routine
- ;
- ;EDIT SUBROUTINE: EDCUR
- ; Position Editor Cursor at EINDEX
- ;EDIT SUBROUTINE: EDCCUR
- ; Clear Editor Cursor at EINDEX
- ;
- edcur:
- push hl ; Save hl
- ld c,ecurs ; Cursor char
- call edsetcur
- call at ; Update data
- db 3,74
- ld a,(eindex) ; Pt to byte at cursor
- ld hl,(block)
- add a,l
- ld l,a
- ld a,h
- adc 0
- ld h,a ; Hl pts to byte at cursor
- ld a,(hl) ; Get byte
- call pa2hc ; Print as hex
- call dspace
- ld a,(hl) ; Get byte
- pop hl ; Restore hl
- and 7fh ; Mask
- cp 7fh ; 7fh as dot
- jr z,edc7f
- cp ' ' ; Output char or dot
- jp nc,conout
- edc7f:
- ld a,'.' ; Dot
- jp conout
- edccur:
- ld c,' ' ; Clear cursor
- edsetcur:
- call edrow ; Compute row
- and 0fh ; Compute col mod 16
- ld b,a ; Result in b
- add a,a ; *2
- add a,b ; *3
- add ecol+6 ; Add in col
- dec a ; Subtract 1
- ld l,a ; Col position set
- call gotoxy ; Position cursor
- ld a,c ; Output char
- jp conout
- ;
- ;Compute Row from EINDEX
- ;
- edrow:
- ld a,(eindex) ; Get index
- ld b,a ; Save in b
- rrca ; Divide by 16
- rrca
- rrca
- rrca
- and 0fh ; Mask for lsb only
- add erow ; Compute row
- ld h,a ; Row set
- ld a,b ; Get index
- ret
-
- ;
- ;PRINT A SPACE
- ;
- dspace:
- ld a,' '
- jp conout
- ;
- ;PRINT AN BARISK IN REV VIDEO
- ;
- bar:
- call vprint
- db dim,'|',bright,0
- ret
- ;
- ;Get value from input buffer
- ;
- getahv:
- ld a,(hl) ; Get next char
- cp '<' ; Hex escape?
- ret nz ; No, return
- ;"<<" means one "<"
- inc hl
- ld a,(hl)
- cp '<'
- ret z
- ;Got hex
- push de
- call hexin ; Get value
- cp '>' ; Proper delim?
- ld a,e ; Get value
- pop de
- ret z
- ;
- ;ERROR CONDITION IN SUBROUTINE - CLEAR STACK AND FLAG ERROR
- ;
- serr:
- pop af ; Clear stack
- jp what ; Error
- ;
- ;Input Number from Command Line -- Assume it to be Hex
- ; Number returned in DE
- ;
- hexin:
- ld de,0 ; Init value
- ld a,(hl)
- cp '#' ; Decimal?
- jr z,hdin ; Make decimal
- ;
- hinlp:
- ld a,(hl) ; Get char
- call caps ; Capitalize
- cp cr ; Eol?
- ret z
- cp eolch ; Eol?
- ret z
- cp sepch
- ret z
- cp ' ' ; Space?
- ret z
- cp '-' ; 'thru'?
- ret z
- cp '>'
- ret z
- inc hl ; Pt to next char
- cp '0' ; Range?
- jr c,serr
- cp '9'+1 ; Range?
- jr c,hinnum
- cp 'A' ; Range?
- jr c,serr
- cp 'F'+1 ; Range?
- jr nc,serr
- sub 7 ; Adjust from a-f to 10-15
- ;
- hinnum:
- sub '0' ; Convert from ascii to binary
- ex de,hl
- add hl,hl ; Mult previous value by 16
- add hl,hl
- add hl,hl
- add hl,hl
- add a,l ; Add in new digit
- ld l,a
- ex de,hl
- jr hinlp
- ;
- hdin:
- inc hl ; Skip '#'
- ;
- ;Input Number in Command Line as Decimal
- ; Number is returned in DE
- ;
- decin:
- ld de,0
- ld a,(hl) ; Get 1st char
- cp '#' ; Hex?
- jr nz,dinlp
- inc hl ; Pt to digit
- jr hinlp ; Do hex processing
- ;
- dinlp:
- ld a,(hl) ; Get digit
- call caps ; Capitalize
- cp '0' ; Range?
- ret c
- cp '9'+1 ; Range?
- ret nc
- sub '0' ; Convert to binary
- inc hl ; Pt to next
- push hl
- ld h,d
- ld l,e
- add hl,hl ; X2
- add hl,hl ; X4
- add hl,de ; X5
- add hl,hl ; X10
- add a,l ; Add in digit
- ld l,a
- ld a,h
- adc 0
- ld h,a
- ex de,hl ; Result in de
- pop hl
- jr dinlp
- ;
- ; READ LINE FROM USER INTO INPUT LINE BUFFER
- ;
- rdbuf:
- ld hl,(buffer) ; Pt to buffer
- ex de,hl ; Set de as ptr to buffer
- ld c,10 ; Bdos readln
- push de ; Save ptr
- call bdos
- pop hl ; Pt to char count
- inc hl
- ld e,(hl) ; Get char count
- ld d,0
- inc hl ; Pt to first char
- push hl ; Save ptr
- add hl,de ; Pt to after last char
- ld (hl),0 ; Store ending 0
- pop hl ; Pt to first char
- ret
-
- ;
- ; Erase to EOL
- ; If fct not supported, send out B spaces and B backspaces
- ;
- vereol:
- call ereol ; Try erase
- ret nz
-
- if [not hardvid]
- push bc ; Save b
- ld a,' ' ; Send spaces
- call vereol1
- pop bc ; Get b
- ld a,bs ; Send backspaces
- vereol1:
- call conout ; Send char in a
- djnz vereol1
- ret
- endif ; not hardvid
-
- ;
- ; Clear Screen
- ; If fct not supported, write 24 CRLFs
- ;
- vcls:
- if clson
- jp cls
- else
- call cls ; Try clear
- ret nz
- if [not hardvid]
- push bc ; Save b
- ld b,24 ; Count
- vcls1:
- call crlf
- djnz vcls1
- pop bc
- ret
- endif ; not hardvid
- endif ; Clson
- ;
- ; LIBRARY ROUTINES
- ;
-
- cin:
- push hl
- push de
- push bc
- ld c,1
- call bdos
- and 7fh
- push af
- ld a,bs ; Overwrite
- call conout
- pop af
- pop bc
- pop de
- pop hl
- ret
-
- ;
- ; Capitalize char in A
- ;
- caps:
- and 7fh
- cp 'a' ; Range?
- ret c
- cp 'z'+1
- ret nc
- and 5fh ; Mask to caps
- ret
-
-
-
-
- ;
- ; Print A as 2 Hex Chars
- ;
- pa2hc:
- push af
- push bc
- ld b,a ; Value in b
- rlca
- rlca
- rlca
- rlca
- call pa2hc1
- ld a,b ; Get value
- call pa2hc1
- pop bc
- pop af
- ret
- pa2hc1:
- and 0fh
- add '0' ; To ascii
- cp '9'+1
- jr c,pa2hc2
- add 7 ; To letter
- pa2hc2:
- jp conout
-
- ;
- ; Skip Spaces
- ;
- sksp:
- ld a,(hl) ; Skip to non-space
- cp ' '
- ret nz
- inc hl
- jr sksp
-
- phl4hc:
- push hl
- push af
- ld a,h
- call pa2hc
- ld a,l
- call pa2hc
- pop af
- pop hl
- ret
-
- phlfdc:
- push hl
- push de
- push bc
- push af
- call hldc1
- pop af
- pop bc
- pop de
- pop hl
- ret
- ; Routine to convert HL to decimal number and display it
-
- hldc1: ld b,0 ; B holds leading zero suppression flag
- ld de,10000
- call hldc2
- ld de,1000
- call hldc2
- ld de,100
- call hldc2
- ld de,10
- call hldc2
- ld a,l
- add a,'0'
- jp conout
-
- hldc2: ld c,'0'-1 ; Count number of divisions by de
- hldc3: inc c
- xor a
- sbc hl,de
- jr nc,hldc3 ; Keep subtracting until negative
- add hl,de ; Then add one back
-
- ld a,c
- cp '1'
- jr nc,hldc4 ; > 0, turn off leading 0 flag and print
- ld a,b ; Check flag at b
- or a
- ld a,c ; Put character back in c
- jr nz,hldc5 ; If b not 0, this '0' is not leading
- ret ; Else skip
- hldc4: ld b,0ffh ; Turn the leading 0 flag off
- hldc5:
- jp conout ; Print the number
-
- vprint:
- ex (sp),hl
- call vprint1
- ex (sp),hl
- ret
- ;
- ; Print String (terminated in 0) pted to by HL
- ;
- vprint1:
- ld a,(hl) ; Done?
- inc hl ; Pt to next
- or a ; 0 terminator
- ret z
- cp dim ; Standout?
- jr z,vprint1d
- cp bright ; Standend?
- jr z,vprint1b
- call conout ; Print char
- or a
- ret m ; Msb set
- jr vprint1
- vprint1d:
- call stndout ; Dim
- jr vprint1
- vprint1b:
- call stndend ; Bright
- jr vprint1
-
-
- ;
- ; CRT ROUTINES
- ;
- if hardvid
- include hardvid.lib
- else
- include tcapvid.lib
- endif ; hardvid
-
- ;
- ;EDITOR BUFFERS
- ;
- block:
- ds 2 ; Address of current block
- buffer:
- ds 2 ; Ptr to free space
- eindex:
- ds 1 ; Index entry
-
-
- ; END DEBUG.LIB
- :
- ds 2 ; Address of current block
- buffer:
- ds 2 ; Ptr to free space
- eindex:
- ds