.title "K8384FNK.asm Kaypro function key overlay for BGii 11/8/86" .sbttl "Copyright (c) 1986 Plu*Perfect Systems" ; ; ; NOTE >>> Kaypro Universal rom not supported - just a dummy routine ; ; 8080 instruction set for CDL/TDL assembler. ; .ident KAYFNK .pabs .phex .xsym .xlist ; This overlay customizes the terminal's function keys for BGii. ; ; The first sector is an ascii identification. ; ; The next two sectors are a table of 8-bit codes ; for each function key, and an associated 4-character label. ; ; The following sectors are the function-key overlay. It is called to: ; ; 1. initialize the terminal's function keys to the 8-bit codes ; 2. to shift (activate) the 8-bit codes ; 3. to unshift the 8-bit codes, restoring whatever codes were there ; 4. to save/restore those codes for each task ; 5. to deinitialize, restoring the user's codes when BG is removed. ; ; MAXLEN equ 6*80H ;MAX SIZE OF OVERLAY MAXCOD equ 200h ;MAX size of code & initialized data ; FNKSIZ equ 18 ;18 arrow and numeric keypad keys MAXTAB equ 3*FNKSIZ ; release equ '0' vers equ '5' ; NUL EQU 0 TRUE EQU 0FFh ; ;=============================== ; Identification sector at 3e80h ; .loc 3e80h fnkyid: .ascii "Kaypro '83 & '84 fn-key overlay v. " db RELEASE db '.' db VERS db 0 ;NUL-terminated string ; ;================================== ; Table of Function-key 8-bit codes and associated labels at 3f00h. ; Each entry is a 1-byte key value, followed by a 4-byte ascii label. ; .loc 3f00h ; labtbl: db nm8kys ;number of keys ; fstky: db 80h ;1st 8-bit code .ascii "UP " ;its label db 81h .ascii "DOWN" db 82h .ascii "LEFT" db 83h .ascii "RGHT" db 84h .ascii "key0" db 85h .ascii "key1" db 86h .ascii "key2" db 87h .ascii "key3" db 88h .ascii "key4" db 89h .ascii "key5" db 8ah .ascii "key6" db 8bh .ascii "key7" db 8ch .ascii "key8" db 8dh .ascii "key9" db 8eh .ascii "key-" db 8fh .ascii "key," db 90h .ascii "ENTR" db 91h .ascii "key." ; nm8kys equ (.-fstky)/(1+4) ; .ifg (. - labtbl - 100h), [ .prntx "Overflow in label table" ] .ifn (.-fstky)@(1+4), [ .prntx "alignment error in labels" ] ; ; ;================================== ; The function-key overlay at 4000h. ; .loc 4000h ; ; Enter A = 0 ... 7 function number. ; After exit, this overlay is written to swap file to preserve ; changed data. ; START: ora a ;*** patched to RET if u-rom, ;as temporary measure jz init ;0 dcr a jz deinit ;1 dcr a jz ashft ;2 dcr a jz bshft ;3 dcr a jz aunshft ;4 dcr a jz bunshft ;5 dcr a jz asave ;6 dcr a jz bsave ;7 dcr a jz arest ;8 dcr a jz brest ;9 ret ;not supported ; ;----------------- ; Function 0. INIT. ; This routine is called when BG is first loaded. ; ; Determine version of Kaypro bios and parameter values/addresses. ; Save initial state of function keys. ; Install 8-bit function key codes for BG. ; INIT: call ckurom ;check type of Kaypro bios jnz iniuro ; ; Non-U-rom Kaypro bios. ; It has 18 1-byte function key table at bios + 35h. ; ; notu: lxi h,FNKSIZ ;table size is 17 bytes shld tabsiz lhld 0001h ;table is at bios+35h mvi l,35h shld tabptr xra a ;set flag sta uromq ; push h ;save initial table lxi d,usrtab call movit pop h push h lxi d,Atab call movit pop h lxi d,Btab call movit ; ; set bios function key table to these 8-bit single characters: ; 80h ... 91h sequential bytes ; set8b: lda uromq ora a jnz set8u ; ; Non-u rom. install sequential 80h ... 91h bytes ; lhld tabptr mvi a,80h st8lp: mov m,a inx h inr a cpi 80h+FNKSIZ jnz st8lp ret ; ;------------------------------ ; >>>> CODE FOR A "Kaypro Universal Rom" is incomplete. <<<< ; ; At the moment is makes the functionkey driver simply do nothing ; and return on all calls. ; ; U-rom. Set bios function-key table to send 80h ... 91h . ; set8u: ret ; ; ; ; Check for U-rom. Exit: NZ if u-rom. ; ; Turborom has 8-byte checksummed "PPS" signature at 0fff8h. ; U-rom has 8-byte checksummed area at same address. ; ckurom: lxi h,0FFF8h ;checksum top 8 bytes of ram mov a,m ora a rz ;NUL is no signature push h xra a mvi b,8 cks1: add m inx h dcr b jnz cks1 ora a pop h jz ckturb ;cksum is ok xra a ;return Z ret ckturb: mov a,m ;checksum is ok, see if "PPS" cpi 'P' ;signature for Turborom rnz ;assume universal rom if not inx h mov a,m cpi 'P' rnz inx h mov a,m cpi 'S' ret ; ; U-rom Kaypro bios ; It has a structure of 18 variable-length strings. ; Structure (appears to be): ; cnt byte ; index byte ; .... ; string 0 ; string 1 ; ... ; ; -- FILL THIS IN ! ; iniuro: mvi a,RET ;******* TEMPORARY -- FORCE sta start ;THIS MODULE TO DO NOTHING AT ALL ret ; ; -- FIX THIS ;... lxi h,3*FNKSIZ ; CORRECT ?? shld tabsiz ; set ptr ; ; lxi h,??? ;; shld tabptr xra a ;set flag dcr a sta uromq ret ; ; lxi d,usrtab call movit ; + ...... ret ;----------------------------- ; save key table from bios to (DE) ; savtab: lhld tabptr ; ; move 'tabsiz' bytes from (hl) to (de) ; movit: lbcd tabsiz ldir ret ; ;------------------- ; Function 1. DEINIT. ; Restore user's function key table when BG was loaded. ; DEINIT: lxi h,usrtab ;reinstall user's keys ; ; put table at (HL) into bios ; puttab: lded tabptr jmp movit ; ;---------------------- ; Functions 2, 3. SHIFT. ; Save current bios function keys. ; Set bios to 8-bit function key mode. ; ; "A" refers to the initial task, "B" to the Alternate task. ; ASHFT: lxi d,Atab ;buffer address ashft1: call savtab ;save bios keys there jmp set8b ;and set 8bit keys ; BSHFT: lxi d,Btab jmp ashft1 ; ;------------------------ ; Functions 4, 5. UNSHIFT. ; Restore current bios function keys. ; ; AUNSHF: lxi h,Atab jmp puttab ; BUNSHF: lxi h,Btab jmp puttab ; ;--------------------- ; Functions 6, 7. SAVE. ; Save current bios function keys in preparation for task swap. ; ASAVE: lxi d,Asvtab jmp savtab ; BSAVE: lxi d,Bsvtab jmp savtab ; ;------------------------ ; Functions 8, 9. RESTORE. ; Restore current bios function keys following task swap. ; AREST: lxi h,Asvtab jmp puttab ; BREST: lda Bfirst ;on first swap, ora a ; there's nothing to restore mvi a,0 sta Bfirst rnz lxi h,Bsvtab jmp puttab ; ;-------------------------- ; tabptr: dw 0 tabsiz: dw 0 ;length of function key table uromq: db 0 ;NZ if urom Bfirst: db TRUE ;static TRUE ; undata equ . .ifg (undata - start - MAXCOD), [ .PRNTX "Code exceeds maximum!" ] ; ; Unitialized Data area. ; Usrtab: ds MAXTAB Atab: ds MAXTAB Btab: ds MAXTAB Asvtab: ds MAXTAB Bsvtab: ds MAXTAB ; .slist .list LENGTH equ . - START .ifg (length - MAXLEN), [ .prntx "Overflow in Key Overlay module!" ] .rlist .end