.z80 aseg org 0100h ;; entry OPENF,MAKEF,GETSTR,NSECT,NXTBYT,CLRFCB,SAVBLK,GETBLK,DSCAN,CMPHD,CMPBH ;; entry CONCHR,LSTCHR,CNCHRS,CNCRLF,LSCRLF,AUXCHR ;; entry COMCHK,GETSCB,GETBYT,BUFBYT ;; entry LENSTR,GETADR,UPCHR,BINDEC,SUXHD,ADDCHR,NULSTR,BYTADR,GETCNT,SAVCNT,FCBADR ;; entry MLT128,INCBC,INCHL l0000 equ 00h l0004 equ 04h l0008 equ 08h l000a equ 0ah l000c equ 0ch l0012 equ 12h BDOS equ 0005h DMA equ 0080h .conout equ 2 .auxout equ 4 .lstout equ 5 .condir equ 6 .open equ 15 .close equ 16 .srcfrs equ 17 .srcnxt equ 18 .delete equ 19 .rdseq equ 20 .wrseq equ 21 .make equ 22 .setdma equ 26 .scb equ 49 .nam equ 8 .ext equ 3 reclng equ 128 bel equ 07h bs equ 08h tab equ 09h lf equ 0ah cr equ 0dh eof equ 1ah esc equ 1bh eot equ '$' NOMSB equ 01111111b LOMASK equ 00001111b HIMASK equ 11110000b _COUNT equ 2 _BUFF equ 7 ; Offset to disk buffer ; ; Open file ; ENTRY Reg DE holds FCB ; Reg HL holds input parameter block ; Reg BC points to input buffer ; Accu holds sector count ; EXIT Accu holds zero on error ; In case of error reg DE holds error message ; OPENF: push bc push de push hl ld (NSECT),a ; Set sector count call CLRFCB ; Clear FCB ld c,.open call BDOS ; Open file inc a ; Set zero flag on error pop hl ld bc,0 call SAVCNT ; Init byte count pop de pop bc ld a,(NSECT) ; Get sector count call SAVBLK ; Store data to parameter block ret nz ; File found, ok ld de,l0123 ; Return error message ret ; l0123: db bel,cr,lf db 'Error: Input file not found' db cr,lf,eot ; ; Read byte from file ; ENTRY Reg DE points to string ; Reg HL holds input parameter block ; EXIT Accu holds zero on end of file ; GETSTR: ex de,hl call NULSTR ; Init string l0148: ex de,hl push de call l0168 ld c,a ld a,e or a jp z,l0165 ld a,c cp eof jp z,l0165 cp cr ld a,c pop de ret z ex de,hl call ADDCHR ; Add character to string jp l0148 l0165: pop de xor a ret ; ; ; l0168: call GETBYT and NOMSB cp lf ret z cp cr ret z cp tab ret z cp eof ret z cp ' ' jp c,l0168 ret ; ; Read byte from file ; ENTRY Reg HL holds input parameter block ; EXIT Accu holds byte ; GETBYT: push bc push hl call BYTADR ; Load buffer address call GETBLK ; Load data from parameter block ld (NSECT),a ; Set sector count ld a,b or c call z,l01a4 ld a,b or c ld e,a jp z,l019e ld hl,(NXTBYT) ; Get byte pointer ld a,(hl) inc hl ld (NXTBYT),hl dec bc l019e: pop hl call SAVCNT ; Store byte count pop bc ret ; ; ; l01a4: push hl ld a,(NSECT) ; Get sector count ld (l01da),a ld bc,0 ; Init record length l01ae: push hl push bc push de ex de,hl ld c,.setdma call BDOS ; Set disk buffer pop de ld c,.rdseq push de call BDOS ; Read record from file pop de or a pop bc pop hl jp nz,l01d5 call INCHL ; Add record length to reg HL call INCBC ; Add record length to reg BC ld a,(l01da) dec a ; Count down sector count ld (l01da),a jp nz,l01ae ; Not yet the end l01d5: pop hl ld (NXTBYT),hl ; Store byte pointer ret ; l01da: db 0 ; ; Create file ; ENTRY Reg DE holds FCB ; Reg HL holds output parameter block ; Reg BC points to output buffer ; Accu holds sector count ; EXIT Accu holds zero on error ; Reg DE holds error message ; MAKEF: push bc push de push hl ld (NSECT),a ; Set sector count push de ld c,.delete call BDOS ; Delete existing file pop de call CLRFCB ; Clear FCB ld c,.make call BDOS ; Create file inc a ; Get result pop hl pop de pop bc push af ; Save result ld a,(NSECT) ; Get sector count call SAVBLK ; Store data to parameter block push bc ld e,c ld d,b ex de,hl ld (NXTBYT),hl ; Store byte pointer ex de,hl call MLT128 ; Map sector count to record length call SAVCNT ; Store byte count pop bc pop af ; Get back result ld de,l020f ret ; l020f: db bel,cr,lf db 'Error: No directory space for new file' db cr,lf,eot ; ; Add string to file ; ENTRY Reg HL points to output parameter block ; Reg DE points to string ; Accu holds ??? flag ; EXIT ??? ; l023b: BUFSTR:: push af push bc ex de,hl call LENSTR ; Get length of string or a ; Test any character jp z,l025c ; Nope ld c,1 l0247: push af call l0693 ex de,hl push de call BUFBYT ; Put byte to file or a pop de jp z,l0266 ex de,hl inc c pop af dec a jp nz,l0247 l025c: ex de,hl pop bc pop af or a ld a,cr call nz,BUFBYT ; Put byte to file ret l0266: pop bc pop bc pop bc ret ; ; Put byte to file ; ENTRY Reg HL points to output parameter block ; Accu holds byte ; EXIT Accu holds ??? ; BUFBYT: push bc push hl push af call BYTADR ; Load buffer address call GETBLK ; Load data from parameter block ld (NSECT),a ; Set sector count pop af push hl ld hl,(NXTBYT) ; Get byte pointer ld (hl),a inc hl ld (NXTBYT),hl dec bc ld a,b or c ld a,0ffh pop hl call z,l028f pop hl call SAVCNT ; Store byte count pop bc ret ; ; ; l028f: push hl push hl push bc ld a,(NSECT) ; Get sector count call MLT128 ; Map sector count to record length ld l,c ; Get length ld h,b ld (l02f0),hl ; Save for top length pop bc pop hl l029f: push hl push bc push de ex de,hl ld c,.setdma call BDOS ; Set disk buffer pop de push de ld c,.wrseq call BDOS ; Write record pop de pop bc or a ; Test success jp nz,l02ce ; Nope, disk full call INCBC ; Add record length to reg BC ld hl,(l02f0) ; Get top length call CMPBH ; Test if end reached pop hl push af call INCHL ; Add record length to reg HL pop af jp c,l029f ; Not yet end pop hl ld (NXTBYT),hl ; Store byte pointer ld a,0ffh ret l02ce: pop hl pop hl ld c,.close call BDOS ; Close file on error ld de,l02da xor a ret ; l02da: db bel,cr,lf db 'Error: Disk full' db cr,lf,eot l02f0: dw 0 ; ; Close file ; ENTRY Reg HL points to outblock ; EXIT Accu holds result ; l02f2: CLOSEF:: xor a call BUFBYT ; Put byte to file push bc call GETCNT ; Load byte count ld a,c and reclng-1 ; Test record filled pop bc jp nz,l02f2 ; Nope, fill it call GETBLK ; Load data from parameter block push hl push bc call MLT128 ; Map sector count to record length ld l,c ; Get length ld h,b pop bc call CMPBH ; Test end reached pop hl ld a,1 call c,l028f or a ret z ld c,.close call BDOS ; Close file inc a ld de,l0321 ret ; l0321: db bel,cr,lf db 'Error: Cannot close output file' db cr,lf,eot NSECT: db 0 ; Sector count NXTBYT: dw 0 ; Byte pointer ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; CLRFCB: ld hl,l000c add hl,de ld b,15h jp l0bfc ; ; Load data from parameter block ; ENTRY Reg HL holds file parameter block ; EXIT Reg DE holds FCB ; Reg BC holds remaining count ; Reg HL points to input buffer ; Accu holds sector count ; GETBLK: ld e,(hl) ; Load FCB inc hl ld d,(hl) inc hl ld c,(hl) ; Load count inc hl ld b,(hl) inc hl push de ex de,hl ld a,(de) ; Load input buffer ld l,a inc de ld a,(de) ld h,a inc de ld a,(de) ; Load sector count pop de ret ; ; Store data to parameter block ; ENTRY Reg HL holds file parameter block ; Reg DE holds FCB ; Reg BC points to input buffer ; Accu holds sector count ; SAVBLK: push hl ld (hl),e ; Store FCB inc hl ld (hl),d inc hl inc hl inc hl ld (hl),c ; Store input buffer inc hl ld (hl),b inc hl ld (hl),a ; Store sector count pop hl ret ; ; Set base adress of buffer ; ENTRY Reg HL holds input parameter block ; BYTADR: push hl push de ld de,_BUFF add hl,de ; Point to buffer address ld e,(hl) ; Load address inc hl ld d,(hl) ex de,hl ld (NXTBYT),hl ; Store as base pop de pop hl ret ; ; Load byte count ; ENTRY Reg HL holds parameter block ; EXIT Reg BC holds count ; GETCNT: push hl inc hl inc hl ld c,(hl) inc hl ld b,(hl) pop hl ret ; ; Store byte count ; ENTRY Reg HL holds parameter block ; Reg BC holds count ; SAVCNT: push hl push de inc hl inc hl ld (hl),c ; Store it inc hl ld (hl),b ex de,hl ld hl,(NXTBYT) ; Get byte pointer ex de,hl push bc ld bc,_BUFF-(_COUNT+1) add hl,bc ld (hl),e ; Store current pointer inc hl ld (hl),d pop bc pop de pop hl ret ; ; Scan directory for matches to an afn ; ENTRY Reg DE points to afn ; Reg HL points to resulting FCB array ; EXIT Accu holds resulting file count ; DSCAN: push hl push de push bc ld (l0411),hl ; Save FCB pointer push de ld de,DMA ld c,.setdma call BDOS ; Set default buffer pop de xor a ld (l0413),a ; Init file count ld c,.srcfrs l03b9: call BDOS ; Search for file ld (l0414),a ; Save directory code inc a ; Test file found ld a,(l0413) ; Get file count jp z,l03d5 ; No more files found ld a,(DMA) ; *** WHY ??? call l03d9 ld hl,l0413 inc (hl) ; Update file count ld c,.srcnxt jp l03b9 l03d5: pop bc pop de pop hl ret ; ; ; l03d9: ld a,(l0414) ; Get directory code add a,a ; *32 add a,a add a,a add a,a add a,a ld de,0 ld e,a ; Set index ld hl,DMA add hl,de ; Position to file found ex de,hl ld hl,(l0411) ld b,' ' call l0be3 ld b,4 call l0bfc ld de,l0004 add hl,de ld (l0411),hl ret ; ; Get address of FCB ; ENTRY Accu holds number of FCB ; Reg HL points to start of FCB array ; EXIT Reg DE points to resulting FCB ; FCBADR: dec a ; Fix number push bc ex de,hl ld h,0 ld l,a ; Get for index add hl,hl ; * 2 add hl,hl ; * 4 ld b,h ld c,l add hl,hl ; * 8 add hl,hl ; *16 add hl,hl ; *32 add hl,bc ; *36 add hl,de ; Build pointer ex de,hl pop bc ret ; l0411: dw 0 l0413: db 0 l0414: db 0 ; ; Check address in common memory ; ENTRY Reg HL points to address ; EXIT Accu holds result ; COMCHK: push de push bc push hl ld de,l042c ld c,.scb call BDOS ; Get base address of common memory ex de,hl ; Into reg DE pop hl call CMPHD ; Compare addresses ld a,0 ; Zero is not within common pop bc pop de ret c ; Not in common dec a ; Change it ret ; l042c: db 5dh,0 ; ; Return entry addr of next RSX ; ENTRY Reg DE points to name of RSX ; Reg BC holds start address ; EXIT Reg DE points to next RSX ; Reg HL holds BDOS entry point ; Accu holds resulting code ; l042e: RSXCHK:: push de push bc ld de,l047d ld c,.scb call BDOS ; Get address of SCB dec hl dec hl dec hl dec hl ld e,(hl) inc hl ld d,(hl) ex de,hl ld (l047f),hl ld a,h pop bc cp b ld a,0 pop de ret z ret c l044b: ld hl,l0012 add hl,bc ld a,(hl) or a ld a,0 ld hl,(l047f) ret nz ld hl,l000a add hl,bc push bc push de ld b,8 call l0c15 pop de pop bc or a jp nz,l0472 ld hl,l0004 add hl,bc ld c,(hl) inc hl ld b,(hl) jp l044b l0472: ld hl,l0004 add hl,bc ld e,(hl) inc hl ld d,(hl) ld hl,(l047f) ret ; l047d: db 3ah,0 l047f: dw 0 ; ; Get value from system control block (SCB) ; ENTRY Accu holds offset within SCB ; EXIT Accu holds byte from offset ; Reg HL holds word from offset ; GETSCB: push de push bc ld de,l048f ld (de),a ; Save offset ld c,.scb call BDOS ; Get values pop bc pop de ret ; l048f: db 0 ; Offset in SCB db 0 ; Load instruction ; ; ASCII-binary conversion routine ; ENTRY HL points to ASCII binary ; EXIT Reg DE holds result ; l0491: ASCBIN:: ld de,0 ; Init result call LENSTR ; Get length of string ld b,a ; Set length or a ; Test character there ret z ; Nope call GETADR ; Convert address if mode BASIC call l04b2 ; Skip white spaces ret z ; End if only spaces here call l04c1 ; Check sign requested push hl call l04cf call l04e5 ; Set number base pop hl ex de,hl call l04ff ex de,hl ret ; ; Skip white spaces ; ENTRY Reg HL points to string ; Reg B holds length of string ; EXIT Reg HL updated ; Zero flag set indicates end of string ; l04b2: ld a,(hl) ; Get character cp ' ' ; Test space jp z,l04bb cp tab ret nz ; Nope l04bb: inc hl dec b ; Test end of string jp nz,l04b2 ; Nope, try next ret ; ; Check sign requested ; l04c1: cp '+' ; Test '+' jp z,l04cc ; Skip it sub '-' ; Test '-' ld (l057a),a ; Set sign ret nz ; No sign l04cc: inc hl ; Fix pointer dec b ; Fix length ret ; ; ; l04cf: push bc ld c,b ld b,0 dec bc add hl,bc pop bc l04d6: ld a,(hl) cp ' ' jp z,l04df cp tab ret nz l04df: dec hl dec b jp nz,l04d6 ret ; ; Set number base ; ENTRY Accu holds possible base character ; l04e5: call UPCHR ; Convert to upper case ld hl,l0579 ; Point to selected base dec b ; Fix remaining count cp 'B' ; Test 'B'inary ld (hl),2 ; Set base ret z cp 'H' ; Maybe 'H'ex ld (hl),16 ret z cp 'O' ; Maybe 'O'ctal ld (hl),8 ret z ld (hl),10 ; Set default 'D'ecimal inc b ; Reset remaining count ret ; ; ; l04ff: ld a,(de) call UPCHR ; Convert to upper case sub '0' cp 9+1 jp c,l050c sub 'A'-'0'-10 l050c: push hl ld hl,l0579 ; Point to selected base cp (hl) pop hl jp nc,l0575 inc de push bc ld c,a ld b,0 ld a,(l0579) ; Get selected base add hl,hl jp c,l0571 cp 2 jp z,l0555 push bc ld c,l ld b,h add hl,hl jp nc,l0531 pop bc jp l0571 l0531: add hl,hl jp nc,l0539 pop bc jp l0571 l0539: cp 8 jp z,l054b cp 16 jp z,l054b add hl,bc jp nc,l054b pop bc jp l0571 l054b: pop bc cp 16 jp nz,l0555 add hl,hl jp c,l0571 l0555: add hl,bc jp c,l0571 pop bc dec b jp nz,l04ff ld a,h rla ld b,1 ret c dec b ld a,(l057a) ; Get sign or a ; Test '-' ld a,l ret nz ; Nope cpl ld l,a ld a,h cpl ld h,a inc hl ret l0571: ld b,1 pop hl ret l0575: ld b,2 pop hl ret ; l0579: db 0 ; Selected number base l057a: db -1 ; Selected sign, 0 means '-' ; ; Convert binary to decimal ; ENTRY Reg DE holds binary ; Reg HL points to string ; BINDEC: push hl push de push bc push af call NULSTR ; Init string ld (l05d2),hl ; Save address ex de,hl ld b,'0' ld de,-10000 call l05ba cp b call nz,l05c6 ld de,-1000 call l05ba cp b call nz,l05c6 ld de,-100 call l05ba cp b call nz,l05c6 ld de,-10 call l05ba cp b call nz,l05c6 ld a,l add a,b call l05c6 pop af pop bc pop de pop hl ret ; ; ; l05ba: ld c,'0'-1 l05bc: inc c add hl,de jp c,l05bc call SUXHD ; Subtract HL-DE ld a,c ret ; ; ; l05c6: push hl push bc ld hl,(l05d2) ; Get base address of string ld c,a call ADDCHR ; Add character to string pop bc pop hl ret ; l05d2: dw 0 ; Base address of string ; ; Return command line parameter string ; ENTRY Reg HL points to CCP command line ; Reg DE points to parameter string ; EXIT First byte of parameter string holds length ; l05d4: SETARG:: ex de,hl call NULSTR ; Init string ex de,hl ld c,'[' call l0864 ld c,a or a ld b,0 ret z push bc ld c,']' call l0864 or a pop bc ld b,1 ret z cp c ret c ld b,a inc c ld a,b sub c ld b,a call l07c1 ld b,0 ret ; ; Return next parameter ; ENTRY Reg HL points to CCP command line ; Reg DE points to parameter string ; EXIT First byte of parameter string holds length ; l05fb: GETARG:: ex de,hl call NULSTR ; Init string ex de,hl ld a,(hl) or a ret z ld b,a ld c,1 l0606: push bc call l06c5 pop bc cp ',' ret z push bc ld c,a ex de,hl call ADDCHR ; Add character to string ex de,hl pop bc dec b jp nz,l0606 ret ; ; Set or get string format ; ENTRY Reg C holds ??? ; EXIT Reg B holds ??? ; l061b: STRTYP:: ld a,c cp 0ffh ld a,(l0630) ld b,0 ret z ld a,c cp 2 ld b,1 ret nc ld (l0630),a ld b,0 ret ; l0630: db 0 ; ; Convert address if mode BASIC ; ENTRY Reg HL points to string started with length byte ; EXIT Reg HL points to string ; GETADR: inc hl ; Skip length ld a,(l0630) ; Get mode or a ; Test BASIC ret z ; Nope push de ld e,(hl) ; Fetch following address inc hl ld d,(hl) ex de,hl ; Set for start of string pop de ret ; ; Init string ; ENTRY Reg HL points to string ; EXIT Reg B holds 0 ; NULSTR: xor a ld (hl),a ; Set empty string ld b,a ; Init length ret ; ; Get length of string ; ENTRY Reg HL points to length field of string ; EXIT Accu holds length ; Reg B initialized to zero ; LENSTR: ld a,(hl) ; Load length ld b,0 ; Init reg ret ; ; Add character to string ; ENTRY Reg HL points to string ; Accu holds character to add ; EXIT Reg B indicates string overflow if set non zero ; ADDCHR: ld a,(hl) ; Get length of string inc a ; Test free space ld b,1 ret z ; Nope, overflow push hl push de ld e,(hl) ; Get length for index inc (hl) ; Update length call GETADR ; Convert address if mode BASIC ld d,0 add hl,de ; Position to end of string ld (hl),c ; Append character ld b,d pop de pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l065a: CONSTR:: ld a,(hl) or a ld b,a ret z push hl call GETADR ; Convert address if mode BASIC l0662: ld a,(hl) call CONCHR ; Put to console inc hl dec b jp nz,l0662 pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l066d: LSTSTR:: ld a,(hl) or a ld b,a ret z push hl call GETADR ; Convert address if mode BASIC l0675: ld a,(hl) call LSTCHR ; Put to printer inc hl dec b jp nz,l0675 pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0680: AUXSTR:: ld a,(hl) or a ld b,a ret z push hl call GETADR ; Convert address if mode BASIC l0688: ld a,(hl) call AUXCHR ; Print character on auxiliary device inc hl dec b jp nz,l0688 pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0693: MIDCHR:: ld b,1 ld a,c or a ret z inc b ld a,(hl) cp c ret c push hl call GETADR ; Convert address if mode BASIC ld b,0 add hl,bc dec hl ld a,(hl) pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l06a7: SUBCHR:: ld a,c or a ld a,b ld b,1 ret z ld b,a ld a,(hl) cp c ld a,b ld b,2 ret c ld b,a push hl push bc call GETADR ; Convert address if mode BASIC ld b,0 add hl,bc dec hl ld a,(hl) pop bc ld (hl),b pop hl ld b,0 ret ; ; Delete character ; ENTRY REg C holds position of character ; Reg HL points to string ; EXIT Accu holds deleted character ; l06c5: DELCHR:: ld a,c or a ld b,1 ret z ld a,(hl) inc b sub c ret c dec (hl) ld b,0 push hl push af call GETADR ; Convert address if mode BASIC pop af ld a,(hl) pop hl ret z push hl push de ld d,(hl) call GETADR ; Convert address if mode BASIC dec c ld b,0 add hl,bc ld a,(hl) ld b,d ld e,l ld d,h inc de push af call l0be3 pop af pop de pop hl ld b,0 ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l06f3: INSCHR:: ld a,c or a ld d,b ld b,1 ret z ld a,(hl) ld e,a inc b inc a ret z inc b sub c ret c push hl push de push af inc (hl) call GETADR ; Convert address if mode BASIC ld c,e ld b,0 add hl,bc ld e,l ld d,h dec de pop af ld b,a call nz,l0bec pop de ld (hl),d pop hl ld b,0 ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l071a: UPSTR:: ld a,(hl) ld b,0 or a ret z ld b,(hl) push hl call GETADR ; Convert address if mode BASIC l0724: ld a,(hl) call UPCHR ; Convert to upper case ld (hl),a inc hl dec b jp nz,l0724 pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0730: LOWSTR:: ld a,(hl) ld b,0 or a ret z ld b,(hl) push hl call GETADR ; Convert address if mode BASIC l073a: ld a,(hl) call l0bb8 ld (hl),a inc hl dec b jp nz,l073a pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0746: FMTSTR:: ld b,(hl) ld a,b or a ret z push hl call GETADR ; Convert address if mode BASIC call l0753 pop hl ret ; ; ; l0753: ld a,(hl) cp ' ' jp z,l075e cp '(' jp nz,l0764 l075e: inc hl dec b ret z jp l0753 l0764: call UPCHR ; Convert to upper case ld (hl),a inc hl dec b ret z l076b: ld a,(hl) call l0bb8 ld (hl),a inc hl dec b ret z cp ' ' jp z,l0753 cp '(' jp z,l0753 jp l076b ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0780: ASSSTR:: ld a,(de) ld (hl),a or a ret z ld b,a ret z call GETADR ; Convert address if mode BASIC ex de,hl call GETADR ; Convert address if mode BASIC ex de,hl push hl push de call l0be3 pop de pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0796: SWPSTR:: ld a,(l0630) or a ld b,3 jp nz,l0c06 ld b,(hl) ld a,(de) cp b jp c,l0c06 ld b,a jp l0c06 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l07a9: ADDSTR:: ld a,(de) or a ld b,a ret z add a,(hl) ld b,1 ret c ld c,(hl) ld (hl),a call GETADR ; Convert address if mode BASIC dec b add hl,bc ex de,hl ld b,(hl) call GETADR ; Convert address if mode BASIC ex de,hl jp l0be3 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l07c1: MIDSTR:: ld a,b ld (l0919),a or a ld b,1 ret z ld a,c inc b or a ret z ld a,(l0919) add a,c ld b,a ld a,(hl) cp b ld b,3 ret c ld a,(l0919) ld (de),a ld b,a push hl push de call GETADR ; Convert address if mode BASIC push bc ld b,0 dec c add hl,bc pop bc ex de,hl call GETADR ; Convert address if mode BASIC call l0be3 pop de pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l07f1: LENTRM:: push hl push bc ld b,0 l07f5: ld a,(hl) cp eot jp z,l0800 inc hl inc b jp l07f5 l0800: ld a,b pop bc pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0804: CNVSTR:: push hl push bc push af call l07f1 ld b,a l080b: ld c,(hl) ld (hl),b ld b,c or a jp z,l0817 dec a inc hl jp l080b l0817: pop af pop bc pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l081b: PTITLE:: ld a,1 call l0a27 call l09b7 call l0829 jp l09c3 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0829: PCENTR:: call l09ab ld a,(l0aa6) sub (hl) and a rra call l0a07 jp l065a ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0838: PRIGHT:: ld a,(l0aa6) sub (hl) inc a call l0a07 jp l065a ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0843: NOSPC1:: push de ld a,(hl) or a ret z ld e,a ld d,0 dec de push hl call GETADR ; Convert address if mode BASIC add hl,de ex de,hl pop hl l0852: ld a,(de) cp ' ' jp z,l085d cp tab jp nz,l0862 l085d: dec de dec (hl) jp nz,l0852 l0862: pop de ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0864: POSCHR:: ld a,(hl) or a ret z push hl push de ld d,a ld b,1 call GETADR ; Convert address if mode BASIC l086f: ld a,(hl) cp c jp z,l087c inc hl inc b dec d jp nz,l086f ld b,0 l087c: ld a,b pop de pop hl ret ; ; Convert FCB to string ; ENTRY Reg DE points to FCB ; Reg HL points to string ; Accu holds user flag ; l0880: FCBSTR:: push af call NULSTR ; Init string pop af or a jp z,l08bf cp 2 ld a,(de) jp c,l08b2 ld b,a and LOMASK jp z,l08bf ld a,b push af and HIMASK rra rra rra rra cp 9+1 jp c,l08ab ld c,'1' sub 10 push af call ADDCHR ; Add character to string pop af l08ab: add a,'0' ld c,a call ADDCHR ; Add character to string pop af l08b2: and LOMASK add a,'@' ld c,a call ADDCHR ; Add character to string ld c,':' call ADDCHR ; Add character to string l08bf: inc de ld b,8 push de l08c3: ld a,(de) and NOMSB inc de cp ' ' jp z,l08d6 ld c,a push bc call ADDCHR ; Add character to string pop bc dec b jp nz,l08c3 l08d6: ld c,'.' call ADDCHR ; Add character to string pop de push hl ld hl,l0008 add hl,de ex de,hl pop hl ld b,3 l08e5: ld a,(de) and NOMSB inc de cp ' ' ret z ld c,a push bc call ADDCHR ; Add character to string pop bc dec b jp nz,l08e5 ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l08f7: ADDNCH:: ld a,b or a ret z ld a,(de) ld c,a call ADDCHR ; Add character to string inc de dec b jp l08f7 ; ; Return constant string ??? ; ENTRY Reg B holds character ; Reg C holds length ; Reg HL points to buffer ; l0904: FILSTR:: push bc call NULSTR ; Init string pop bc ld a,b or a ret z push hl ld (hl),b call GETADR ; Convert address if mode BASIC l0911: ld (hl),c inc hl dec b jp nz,l0911 pop hl ret ; l0919: db 0 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l091a: SVSIZE:: db 31 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l091b: SHSIZE:: db 90 ; ; ; l091c: push bc ld c,0ffh push af call l0c27 ld b,a ld c,6 call l0c27 pop af call CONCHR ; Put to console ld c,b call l0c27 pop bc ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0933: CRETRN:: push af ld a,0dh call l091c pop af ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l093b: CRLEFT:: push af ld a,8 call l091c pop af ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0943: CRIGHT:: push de ld de,l094c call l0cc7 pop de ret l094c: db esc,'C',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l094f: CURSUP:: push de ld de,l0958 call l0cc7 pop de ret ; l0958: db esc,'I',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l095b: CRSUP2:: push de ld de,l0964 call l0cc7 pop de ret ; l0964: db esc,'A',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0967: CRDOWN:: push af ld a,0ah call l091c pop af ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l096f: CURSON:: push de ld de,l0978 call l0cc7 pop de ret ; l0978: db esc,'e',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l097b: CRSOFF:: push de ld de,l0984 call l0cc7 pop de ret ; l0984: db esc,'f',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0987: SAVPOS:: push de ld de,l0990 call l0cc7 pop de ret ; l0990: db esc,'j',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0993: RSTPOS:: push de ld de,l099c call l0cc7 pop de ret ; l099c: db esc,'k',eot ; ; Home cursor ; l099f: HOME:: push de ld de,l09a8 call l0cc7 pop de ret ; l09a8: db esc,'H',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l09ab: CLRLIN:: push de ld de,l09b4 call l0cc7 pop de ret ; l09b4: db esc,'l',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l09b7: INVERT:: push de ld de,l09c0 call l0cc7 pop de ret ; l09c0: db esc,'p',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l09c3: NORMAL:: push de ld de,l09cc call l0cc7 pop de ret ; l09cc: db esc,'q',eot ; ; Clear viewport ; l09cf: CLVIEW:: push de ld de,l09d8 call l0cc7 pop de ret ; l09d8: db esc,'E',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l09db: BELL:: push af ld a,7 call l091c pop af ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l09e3: CLREND:: push de ld de,l09ec call l0cc7 pop de ret ; l09ec: db esc,'K',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l09ef: FULLVW:: push hl push de push af ld hl,l0000 ld a,(l091a) dec a ld e,a ld a,(l091b) dec a ld d,a call l0a77 pop af pop de pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a06: HMOVE:: ld a,(hl) ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a07: HPOS:: call l0933 push bc push af ld a,(l0aa6) ld b,a pop af push af l0a12: or a jp z,l0a23 inc b dec b jp z,l0a23 call l0943 dec b dec a jp l0a12 l0a23: pop af pop bc ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a26: VMOVE:: ld a,(hl) ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a27: VPOS:: push af ld a,(l0aa5) l0a2b: call l095b dec a jp nz,l0a2b pop af push bc push af ld a,(l0aa5) ld b,a pop af push af l0a3b: or a jp z,l0a4c inc b dec b jp z,l0a4c call l0967 dec b dec a jp l0a3b l0a4c: pop af pop bc ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0A4f: MOVETO:: ld h,(hl) ld a,(de) ld l,a ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a52: MOVE:: push de push af ld de,l0a69 call l0cc7 ld a,' ' add a,l call l091c ld a,' ' add a,h call l091c pop af pop de ret ; l0a69: db esc,'Y',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a6c: WINDOW:: call l0bc1 ld h,l ld l,e push hl call l0bdd ld d,l pop hl ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0a77: SETVW:: push af push de ld de,l0aa2 call l0cc7 pop de ld a,' ' add a,l call l091c ld a,' ' add a,h call l091c ld a,e sub l ld (l0aa5),a add a,' ' call l091c ld a,d sub h ld (l0aa6),a add a,' ' call l091c pop af ret ; l0aa2: db esc,'X',eot ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0aa5: HEIGHT:: db 30 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0aa6: WIDTH:: db 89 ; ; Print decimal value ; ENTRY Reg HL holds number ; l0aa7: PDECML:: push hl push de push bc push af ld b,'0' ld de,-10000 call l0adf cp b call nz,CONCHR ; Put to console ld de,-1000 call l0adf cp b call nz,CONCHR ld de,-100 call l0adf cp b call nz,CONCHR ld de,-10 call l0adf cp b call nz,CONCHR ld a,l add a,b call CONCHR pop af pop bc pop de pop hl ret ; ; ; l0adf: ld c,'0'-1 l0ae1: inc c add hl,de jp c,l0ae1 call SUXHD ; Subtract HL-DE ld a,c ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0aeb: PHEX:: push af rrca rrca rrca rrca call l0af7 pop af jp l0af7 l0af7: push af and LOMASK cp 9+1 jp nc,l0b04 add a,'0' jp l0b06 l0b04: add a,'A'-10 l0b06: call CONCHR ; Put to console pop af ret ; ; Print filename ; ENTRY Reg HL points to FCB ; Accu holds user print flag ; l0b0b: PNAMEF:: or a ; Test user requested ld a,(hl) jp z,l0b2e ; Nope push af and HIMASK rra rra rra rra cp 9+1 ld b,' ' jp c,l0b22 ld b,'1' sub 10 l0b22: ld c,a ld a,b call CONCHR ; Put to console ld a,c add a,'0' call CONCHR pop af l0b2e: and LOMASK or a jp z,l0b3e add a,'@' call CONCHR ld a,':' call CONCHR l0b3e: inc hl ld b,.nam call l0b4e ld a,'.' call CONCHR ld b,.ext jp l0b4e l0b4e: ld a,b or a ret z ld a,(hl) and NOMSB call CONCHR inc hl dec b jp l0b4e ; ; Multiply record length ; ENTRY Accu holds number of records ; EXIT Reg BC holds eqivalent of record count ; MLT128: ld bc,0 ; Init result l0b5f: or a ; Test done ret z call INCBC ; Add record length to reg BC dec a jp l0b5f ; Try next ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0b68: HLXA:: or a jp z,l0b7b push de ex de,hl ld hl,l0000 l0b71: add hl,de jp c,l0b79 dec a jp nz,l0b71 l0b79: pop de ret l0b7b: ld hl,l0000 ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0b7f: MULT16:: push af push de ld b,h ld c,l ld hl,l0000 l0b86: ld a,c rrca jp nc,l0b8c add hl,de l0b8c: xor a ld a,b rra ld b,a ld a,c rra ld c,a or b jp z,l0ba5 xor a ld a,e rla ld e,a ld a,d rla jp c,l0baa ld d,a or e jp nz,l0b86 l0ba5: ld b,0 pop de pop af ret l0baa: ld b,1 pop de pop af ret ; ; Upshhift character ; ENTRY Accu holds character ; EXIT Accu holds upshifted character ; UPCHR: cp 'z'+1 ; Test lower case ret nc ; Nope cp 'a' ret c sub 'a'-'A' ; Convert it ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0bb8: LOWCHR:: cp 'Z'+1 ret nc cp 'A' ret c add a,'a'-'A' ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0bc1: UNLOAD:: push de ld e,(hl) inc hl ld d,(hl) ex de,hl pop de push hl ex de,hl ld e,(hl) inc hl ld d,(hl) pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0bce: GETTBL:: push af ld a,(bc) ld l,a inc bc ld a,(bc) ld h,a inc bc ld a,(bc) ld e,a inc bc ld a,(bc) ld d,a inc bc pop af ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0bdd: UNLDBC:: call l0bce jp l0bc1 ; ; Block move ; ENTRY Reg DE points to source ; Reg HL points to destination ; Reg B holds number of bytes to move ; l0be3: BLKMOV:: ld a,(de) ld (hl),a inc de inc hl dec b jp nz,l0be3 ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0bec: RBKMOV:: ld a,(de) ld (hl),a dec de dec hl dec b jp nz,l0bec ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0bf5: FILMEM:: ld (hl),c inc hl dec b jp nz,l0bf5 ret ; ; Clear memory ; ENTRY Reg HL points to memory ; Reg B holds number of bytes to clear ; l0bfc: CLRMEM:: push hl l0bfd: ld (hl),0 inc hl dec b jp nz,l0bfd pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0c06: SWPMEM:: ld a,b or a ret z ld a,(de) push af ld a,(hl) ld (de),a pop af ld (hl),a inc hl inc de dec b jp l0c06 ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0c15: CMPMEM:: ld a,b or a ret z ld c,(hl) ld a,(de) cp c ld a,0 ret nz inc hl inc de dec b jp nz,l0c15 ld a,0ffh ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0c27: CHRFCN:: ld a,c inc a ld a,(l0c40) ; Get BDOS functon ret z ld a,c cp .conout jp z,l0c3b cp .condir jp z,l0c3b ld a,0ffh ret l0c3b: ld (l0c40),a ; Set BDOS functon xor a ret ; l0c40: db .conout ; ; Print character on console ; ENTRY Accu holds character ; CONCHR: push hl push de push bc push af ld e,a ; Unpack character ld a,(l0c40) ; Get BDOS function ld c,a call BDOS ; Put character pop af pop bc pop de pop hl ret ; ; Print character multiple ; ENTRY Reg C holds character ; Reg B holds count ; CNCHRS: push bc push af l0c54: ld a,c ; Get character call CONCHR ; Put to console dec b jp nz,l0c54 ; N-times pop af pop bc ret ; ; Print new line on console ; CNCRLF: push af ld a,cr call CONCHR ; Put new line to console ld a,lf call CONCHR pop af ret ; ; Print character on printer ; ENTRY Accu holds character ; LSTCHR: push hl push de push bc push af ld e,a ; Unpack character ld c,.lstout ; Get BDOS function call BDOS ; Put character pop af pop bc pop de pop hl ret ; ; Print new line on printer ; LSCRLF: push af ld a,cr call LSTCHR ; Put new line to printer ld a,lf call LSTCHR pop af ret ; ; Print character on auxiliary device ; ENTRY Accu holds character ; AUXCHR: push hl push de push bc push af ld e,a ; Unpack character ld c,.auxout ; Get BDOS function call BDOS ; Put character pop af pop bc pop de pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0c97: GETKEY:: push hl push de push bc l0c9a: ld c,.condir ld e,0ffh call BDOS or a jp z,l0c9a pop bc pop de pop hl ret ; ; Get character from keyboard ; EXIT Accu holds character or 0 if no available ; l0ca9: INKEY:: push hl push de push bc ld c,.condir ld e,0ffh call BDOS pop bc pop de pop hl ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0cb7: FLUSHB:: push hl push de push bc push af l0cbb: call l0ca9 or a jp nz,l0cbb pop af pop bc pop de pop hl ret ; ; Print '$' terminated string at console ; ENTRY Reg DE points to string ; l0cc7: CSTRNG:: push de push af l0cc9: ld a,(de) cp eot jp z,l0cd6 call CONCHR ; Put to console inc de jp l0cc9 l0cd6: pop af pop de ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0cd9: LSTRNG:: push de push af l0cdb: ld a,(de) cp eot jp z,l0ce8 call LSTCHR ; Put to printer inc de jp l0cdb l0ce8: pop af pop de ret ; ; Compare HL:DE ; ENTRY Reg HL and DE hold values ; EXIT Flags set accordingly ; CMPHD: ld a,h cp d ; Simple compare ret nz ld a,l cp e ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0cf1: CMPHB:: ld a,h cp b ; Simple compare ret nz ld a,l cp c ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0cf7: CMPDB:: ld a,d cp b ; Simple compare ret nz ld a,e cp c ret ; ; Compare BC:HL ; ENTRY Reg HL and DE hold values ; EXIT Flags set accordingly ; CMPBH: ld a,b cp h ; Simple compare ret nz ld a,c cp l ret ; ; Subtract HL-DE ; ENTRY Reg HL and DE hold numbers ; EXIT Reg HL holds difference ; SUXHD: push de push af ld a,e cpl ; Build complement ld e,a ld a,d cpl ld d,a inc de pop af add hl,de ; Subtract pop de ret ; ; xxxxxxxxxxxxxxxxxx ; ENTRY ; EXIT ; l0d10: SUXHB:: push bc push af ld a,c cpl ld c,a ld a,b cpl ld b,a inc bc pop af add hl,bc pop bc ret ; ; Add record length ; ENTRY Reg BC holds current length ; EXIT Reg BC holds updated length ; INCBC: push hl ld hl,reclng add hl,bc ; Add length ld b,h ; Get result ld c,l pop hl ret ; ; Add record length ; ENTRY Reg HL holds current length ; EXIT Reg HL holds updated length ; INCHL: push bc ld bc,reclng add hl,bc pop bc ret end