;ASCII TABLE APPLICATION FOR Write-Hand-Man ;Written by D.W.Clements for Hisoft 1986 ; Tided by Dave Nutkins Feb 87 ; .Z80 org 0 base equ $ bdos equ base+5 buf equ base+080h string equ 9 conio equ 6 esc equ 27 ctle equ 5 ctlx equ 24 ctla equ 1 ctld equ 4 return equ 13 .z80 xbios macro adr call 0fc5ah dw adr endm TE_ASK equ 0bfh KM_KT_GET equ 0dah KM_KT_PUT equ 0ddh SCR_RUN_ROUTINE equ 0e9h kshift equ 21 kalt equ 80 kextra equ 84 kshlock equ 70 kright equ 6 kleft equ 15 kup equ 14 kdown equ 79 kplus equ 23 kminus equ 76 kexit equ 8 kdelback equ 72 kcopy equ 11 kfind equ 20 kcut equ 10 kcr equ 18 kenter equ 78 kfind equ 20 kpaste equ 3 kC equ 62 kH equ 44 kJ equ 45 kV equ 55 kY equ 43 kcan equ 75 kf7 equ 77 kf5 equ 73 kf3 equ 0 kf1 equ 2 shift equ 5 ; bit in the shift status byte alt equ 7 org 0100h start: call dispage call setwindow ld b,8 loop: ld a,8 sub b ld (curasc),a push bc call doasc pop bc djnz loop keyloop: ;get key input inkey: key1: xbios KM_KT_GET jr nc,key1 ; key number in bc ;ignore shifted stuff on its own ld a,c cp kshift jr z,key1 cp kalt jr z,key1 cp kextra jr z,key1 cp kshlock jr Z,key1 res 3,b dec b inc b jr nz,key1 ;shifted cp kdown jp z,dodown cp kup jp z,doup cp kexit jp z,exit cp kleft jp z,backpage cp kright jp z,forpage cp kenter jp z,forpage cp kcr jp z,forpage normal: jr key1 home: defb esc,"H","$" dodown: ld de,home ld c,string call bdos ld a,(curasc) inc a ld (curasc),a sub 7 ld b,8 aloop: ld c,a push bc call doasc pop bc inc c ld a,c djnz aloop jp keyloop doup: ld de,home ld c,9 call bdos ld e,esc ld a,(curasc) dec a ld (curasc),a sub 7 ld b,8 uploop: ld c,a push bc call doasc pop bc ld a,c inc a djnz uploop jp keyloop backpage: ld de,home ld c,string call bdos ld a,(curasc) sub 15 ld b,8 bloop: ld c,a PUSH bc call doasc POP bc ld a,c inc a djnz bloop dec a ld (curasc),a jp keyloop forpage: ld de,home ld c,string call bdos ld a,(curasc) inc a ld b,8 floop: ld c,a push bc call doasc pop bc ld a,c inc a djnz floop dec a ld (curasc),a jp keyloop dispage: ;find the current viewport size and position so we can restore it xbios TE_ASK ld (viewtop),bc ld (viewsize),de ld de,home ld c,9 call bdos ld de,title ld c,string call bdos ld de,tline ld c,9 call bdos ld de,header ld c,9 call bdos ld bc,0909h loop21: ld de,bline push bc call bdos ld de,crlf ld c,9 call bdos pop bc djnz loop21 ld de,botl ld c,9 call bdos ret crlf: defb 13,10,024h title: defb esc,"p"," Ascii-Table ",13,10,"$" header: defm 095h,"Dec " defb 095h," Hex ",095h," Char ",095h," Ctrl ",095h defb " Mnem",095h,esc,"q",13,10,024h bline: defb 095h defs 4,32 defb 095h defs 5,32 defb 095h defs 6,32 defb 095h defs 6,32 defb 095h defs 5,32 defb 095h defb 024h botl: defb 093h defs 4,09ah defb 09bh defs 5,09ah defb 09bh defs 6,09ah defb 09bh defs 6,09ah defb 09bh defs 5,09ah defb 099h defb esc,"H","$" ; doasc: ;A = ascii code push af ;c = no of 100's ;d = no of 10's ;e = no of 1's ld b,0 ld c,b ld d,b ld e,b ld b,100 ld h,10 ld l,1 cloop: cp b jp c,donec sub b inc c jp cloop donec: dloop: cp h jp c,doned sub h inc d jp dloop doned: eloop: cp l jp c,donee dec a inc e jp eloop donee: push de ld a,c add a,48 ld e,a ld c,2 call bdos pop de push de ld a,d add a,48 ld e,a ld c,2 call bdos pop de ld a,e add a,48 ld e,a ld c,2 call bdos ;done dec ld de,linesp ld c,string call bdos hex: pop af push af ld c,a srl a srl a srl a srl a ld de,hextab ld l,a xor a ld h,a add hl,de ld a,(hl) ld b,a ld a,c and 15 ld de,hextab ld l,a xor a ld h,a add hl,de ld a,(hl) ld c,a push bc ld c,2 ld e,b call bdos pop bc ld e,c ld c,2 call bdos ld e,32 ld c,2 call bdos ld de,linesp ld c,string call bdos char: pop af push af cp 9 jp nz,nottab ld a,32 nottab: cp 32 jp nc,norchar ld e,27 ld c,2 push af call bdos pop af norchar: ld e,a ld c,2 call bdos ld de,space3 ld c,9 call bdos ld de,linesp ld c,9 call bdos ctrl: pop af push af cp 32 jp nc,notctrl ld e,"^" ld c,2 call bdos pop af push af add a,64 ld e,a ld c,2 call bdos ld de,linesp+1 ld c,9 call bdos ld de,linesp ld c,9 call bdos jp mnem notctrl: ld de,space3 ld c,9 call bdos ld e,32 ld c,2 call bdos ld de,linesp ld c,9 call bdos nomnem: pop af cp 127 jp nz,notdel ld de,DEL jp cont notdel: ld de,space3 cont: ld c,9 call bdos ld de,crlf ld c,9 call bdos ret curasc: defb 0 linesp: defb 095h,32,32,024h space3: defb 32,32,32,024h hextab: defm "0123456789ABCDEF" mnemtable: defm "NULSOHSTXETXEOTENQACKBEL BS HT" DEFM " LF VT FF CR SO SIDLEDC1DC2" DEFM "DC3DC4NAKSYNETBCAN EMSUBESC" DEL: DEFB 8,"DEL$" mnem: pop af push af cp 28 jp nc,nomnem ld e,8 ld c,2 call bdos pop af push af ld c,a add a,c add a,c ld de,mnemtable ld l,a xor a ld h,a add hl,de ld b,3 ld c,2 mloop: push hl ld e,(hl) push bc call bdos pop BC POP HL inc hl djnz mloop pop af ld de,crlf ld c,9 call bdos ret tline: defb 096h defs 4,09ah defb 09eh defs 5,09ah defb 09eh defs 6,09ah defb 09eh defs 6,09ah defb 09eh defs 5,09ah defb 09ch,13,10,"$" setwindow: setvp: ld a,27 call writechar ld a,'X' call writechar ld a,(viewtop+1) add a,4 ; 4 down call writeascii ld a,(viewtop) ; 2 across add a,2 call writeascii ld a,(viewsize+1) ; length as before call writeascii ld a,29 ;30 cols across call writeascii curoff: ld a,27 call writechar ld a,"f" jr writechar exit: restvp: ld a,27 call writechar ld a,'X' call writechar ld a,(viewtop+1) call writeascii ld a,(viewtop) call writeascii ld a,(viewsize+1) call writeascii ld a,(viewsize) call writeascii ld a,27 call writechar ld a,"e" ;cursor on call writechar jp base writeascii: add a,32 writechar: ld e,a ld c,6 jp bdos viewtop: dw 0 viewsize: dw 0 END