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 / CPM / PROGRAMS / BKGRONDR / BGIIDRV.LBR / K8384FNK.AQM / K8384FNK.ASM
Assembly Source File  |  2000-06-30  |  7KB  |  379 lines

  1. .title    "K8384FNK.asm Kaypro function key overlay for BGii 11/8/86"
  2. .sbttl    "Copyright (c) 1986  Plu*Perfect Systems"
  3. ;
  4. ;
  5. ; NOTE >>>  Kaypro Universal rom not supported - just a dummy routine
  6. ;
  7. ; 8080 instruction set for CDL/TDL assembler.
  8. ;
  9. .ident    KAYFNK
  10. .pabs
  11. .phex
  12. .xsym
  13. .xlist
  14.  
  15. ; This overlay customizes the terminal's function keys for BGii.
  16. ;
  17. ; The first sector is an ascii identification.
  18. ;
  19. ; The next two sectors are a table of 8-bit codes
  20. ; for each function key, and an associated 4-character label.
  21. ;
  22. ; The following sectors are the function-key overlay.  It is called to:
  23. ;
  24. ; 1. initialize the terminal's function keys to the 8-bit codes
  25. ; 2. to shift (activate) the 8-bit codes
  26. ; 3. to unshift the 8-bit codes, restoring whatever codes were there
  27. ; 4. to save/restore those codes for each task
  28. ; 5. to deinitialize, restoring the user's codes when BG is removed.
  29. ;
  30. MAXLEN    equ    6*80H        ;MAX SIZE OF OVERLAY
  31. MAXCOD    equ    200h        ;MAX size of code & initialized data
  32. ;
  33. FNKSIZ    equ    18        ;18 arrow and numeric keypad keys
  34. MAXTAB    equ    3*FNKSIZ
  35. ;
  36. release    equ    '0'
  37. vers    equ    '5'
  38. ;
  39. NUL    EQU    0
  40. TRUE    EQU    0FFh
  41. ;
  42. ;===============================
  43. ; Identification sector at 3e80h
  44. ;
  45.     .loc    3e80h
  46. fnkyid:    .ascii    "Kaypro '83 & '84 fn-key overlay v. "
  47.     db    RELEASE
  48.     db    '.'
  49.     db    VERS
  50.     db    0        ;NUL-terminated string
  51. ;
  52. ;================================== 
  53. ; Table of Function-key 8-bit codes and associated labels at 3f00h.
  54. ; Each entry is a 1-byte key value, followed by a 4-byte ascii label.
  55. ;
  56.     .loc    3f00h
  57. ;
  58. labtbl:    db    nm8kys        ;number of keys
  59. ;
  60. fstky:    db    80h        ;1st 8-bit code
  61.     .ascii    "UP  "        ;its label
  62.     db    81h
  63.     .ascii    "DOWN"
  64.     db    82h
  65.     .ascii    "LEFT"
  66.     db    83h
  67.     .ascii    "RGHT"
  68.     db    84h
  69.     .ascii    "key0"
  70.     db    85h
  71.     .ascii    "key1"
  72.     db    86h
  73.     .ascii    "key2"
  74.     db    87h
  75.     .ascii    "key3"
  76.     db    88h
  77.     .ascii    "key4"
  78.     db    89h
  79.     .ascii    "key5"
  80.     db    8ah
  81.     .ascii    "key6"
  82.     db    8bh
  83.     .ascii    "key7"
  84.     db    8ch
  85.     .ascii    "key8"
  86.     db    8dh
  87.     .ascii    "key9"
  88.     db    8eh
  89.     .ascii    "key-"
  90.     db    8fh
  91.     .ascii    "key,"
  92.     db    90h
  93.     .ascii    "ENTR"
  94.     db    91h
  95.     .ascii    "key."
  96. ;
  97. nm8kys     equ    (.-fstky)/(1+4)
  98. ;
  99. .ifg (. - labtbl - 100h), [
  100.     .prntx    "Overflow in label table"
  101.     ]
  102.  
  103. .ifn (.-fstky)@(1+4), [
  104.     .prntx    "alignment error in labels"
  105.     ]
  106. ;
  107. ;
  108. ;==================================
  109. ; The function-key overlay at 4000h.
  110. ;
  111.     .loc    4000h
  112. ;
  113. ; Enter A = 0 ... 7 function number.
  114. ; After exit, this overlay is written to swap file to preserve
  115. ; changed data.
  116. ;
  117. START:    ora    a        ;*** patched to RET if u-rom, 
  118.                 ;as temporary measure
  119.     jz    init    ;0
  120.     dcr    a
  121.     jz    deinit    ;1
  122.     dcr    a
  123.     jz    ashft    ;2
  124.     dcr    a
  125.     jz    bshft    ;3
  126.     dcr    a
  127.     jz    aunshft    ;4
  128.     dcr    a
  129.     jz    bunshft    ;5
  130.     dcr    a
  131.     jz    asave    ;6
  132.     dcr    a
  133.     jz    bsave    ;7
  134.     dcr    a
  135.     jz    arest    ;8
  136.     dcr    a
  137.     jz    brest    ;9
  138.     ret        ;not supported
  139. ;
  140. ;-----------------
  141. ; Function 0. INIT.
  142. ; This routine is called when BG is first loaded.
  143. ;
  144. ; Determine version of Kaypro bios and parameter values/addresses.
  145. ; Save initial state of function keys.
  146. ; Install 8-bit function key codes for BG.
  147. ;
  148. INIT:    call    ckurom        ;check type of Kaypro bios
  149.     jnz    iniuro
  150. ;
  151. ; Non-U-rom Kaypro bios.
  152. ; It has 18 1-byte function key table at bios + 35h.
  153. ;
  154. ;
  155. notu:    lxi    h,FNKSIZ    ;table size is 17 bytes
  156.     shld    tabsiz
  157.     lhld    0001h        ;table is at bios+35h
  158.     mvi    l,35h
  159.     shld    tabptr
  160.     xra    a        ;set flag
  161.     sta    uromq
  162. ;
  163.     push    h        ;save initial table
  164.     lxi    d,usrtab
  165.     call    movit
  166.     pop    h
  167.     push    h
  168.     lxi    d,Atab
  169.     call    movit
  170.     pop    h
  171.     lxi    d,Btab
  172.     call    movit
  173. ;
  174. ; set bios function key table to these 8-bit single characters:
  175. ;     80h ... 91h sequential bytes
  176. ;
  177. set8b:    lda    uromq
  178.     ora    a
  179.     jnz    set8u
  180. ;
  181. ; Non-u rom. install sequential 80h ... 91h bytes
  182. ;
  183.     lhld    tabptr
  184.     mvi    a,80h
  185. st8lp:    mov    m,a
  186.     inx    h
  187.     inr    a
  188.     cpi    80h+FNKSIZ
  189.     jnz    st8lp
  190.     ret
  191. ;
  192. ;------------------------------
  193. ; >>>> CODE FOR A "Kaypro Universal Rom" is incomplete. <<<<
  194. ;
  195. ; At the moment is makes the functionkey driver simply do nothing
  196. ; and return on all calls.
  197. ;
  198. ; U-rom.  Set bios function-key table to send 80h ... 91h .
  199. ;
  200. set8u:
  201.     ret
  202. ;
  203. ;
  204. ;
  205. ; Check for U-rom.     Exit: NZ if u-rom.
  206. ;
  207. ; Turborom has 8-byte checksummed "PPS" signature at 0fff8h.
  208. ; U-rom has 8-byte checksummed area at same address.
  209. ;
  210. ckurom:    lxi    h,0FFF8h    ;checksum top 8 bytes of ram
  211.     mov    a,m
  212.     ora    a
  213.     rz            ;NUL is no signature
  214.     push    h
  215.     xra    a
  216.     mvi    b,8
  217. cks1:    add    m
  218.     inx    h
  219.     dcr    b
  220.     jnz    cks1
  221.     ora    a
  222.     pop    h
  223.     jz    ckturb        ;cksum is ok
  224.     xra    a        ;return Z
  225.     ret
  226. ckturb:    mov    a,m        ;checksum is ok, see if "PPS"
  227.     cpi    'P'        ;signature for Turborom
  228.     rnz            ;assume universal rom if not
  229.     inx    h
  230.     mov    a,m
  231.     cpi    'P'
  232.     rnz
  233.     inx    h
  234.     mov    a,m
  235.     cpi    'S'
  236.     ret
  237. ;
  238.     
  239. ; U-rom Kaypro bios
  240. ; It has a structure of 18 variable-length strings.
  241. ; Structure (appears to be):
  242. ;    cnt byte
  243. ;    index byte
  244. ;    ....
  245. ;    string 0
  246. ;    string 1
  247. ;    ...
  248. ;
  249. ;  -- FILL THIS IN !
  250. ;
  251. iniuro:
  252.     mvi    a,RET        ;******* TEMPORARY -- FORCE
  253.     sta    start        ;THIS MODULE TO DO NOTHING AT ALL
  254.     ret
  255. ;
  256. ; -- FIX THIS
  257. ;...
  258.     lxi    h,3*FNKSIZ    ; CORRECT ??
  259.     shld    tabsiz
  260. ; set ptr
  261. ; ;    lxi    h,???
  262. ;;    shld    tabptr
  263.     xra    a        ;set flag
  264.     dcr    a
  265.     sta    uromq
  266.     ret
  267. ;
  268.  
  269.     lxi    d,usrtab
  270.     call    movit
  271. ; + ......
  272.  
  273.     ret
  274.  
  275. ;-----------------------------
  276. ; save key table from bios to (DE)
  277. ;
  278. savtab:    lhld    tabptr
  279. ;
  280. ; move 'tabsiz' bytes from (hl) to (de)
  281. ;
  282. movit:    lbcd    tabsiz
  283.     ldir
  284.     ret
  285. ;
  286. ;-------------------
  287. ; Function 1. DEINIT.
  288. ; Restore user's function key table when BG was loaded.
  289. ;
  290. DEINIT:    lxi    h,usrtab        ;reinstall user's keys
  291. ;
  292. ; put table at (HL) into bios
  293. ;
  294. puttab:    lded    tabptr
  295.     jmp    movit
  296. ;
  297. ;----------------------
  298. ; Functions 2, 3. SHIFT.
  299. ; Save current bios function keys.
  300. ; Set bios to 8-bit function key mode.
  301. ; "A" refers to the initial task, "B" to the Alternate task.
  302. ;
  303. ASHFT:    lxi    d,Atab        ;buffer address
  304. ashft1:    call    savtab        ;save bios keys there
  305.     jmp    set8b        ;and set 8bit keys
  306. ;
  307. BSHFT:    lxi    d,Btab
  308.     jmp    ashft1
  309. ;
  310. ;------------------------
  311. ; Functions 4, 5. UNSHIFT.
  312. ; Restore current bios function keys.
  313. ;
  314. AUNSHF:    lxi    h,Atab
  315.     jmp    puttab
  316.  
  317. ;
  318. BUNSHF:    lxi    h,Btab
  319.     jmp    puttab
  320. ;
  321. ;---------------------
  322. ; Functions 6, 7. SAVE.
  323. ; Save current bios function keys in preparation for task swap.
  324. ;
  325. ASAVE:    lxi    d,Asvtab
  326.     jmp    savtab
  327. ;
  328. BSAVE:    lxi    d,Bsvtab
  329.     jmp    savtab
  330. ;
  331. ;------------------------
  332. ; Functions 8, 9. RESTORE.
  333. ; Restore current bios function keys following task swap.
  334. ;
  335. AREST:    lxi    h,Asvtab
  336.     jmp    puttab
  337. ;
  338. BREST:    lda    Bfirst        ;on first swap,
  339.     ora    a        ; there's nothing to restore
  340.     mvi    a,0
  341.     sta    Bfirst
  342.     rnz
  343.     lxi    h,Bsvtab
  344.     jmp    puttab
  345. ;
  346. ;--------------------------
  347. ;
  348. tabptr:    dw    0
  349. tabsiz:    dw    0        ;length of function key table
  350. uromq:    db    0        ;NZ if urom
  351. Bfirst:    db    TRUE        ;static TRUE
  352. ;
  353. undata equ .
  354. .ifg (undata - start - MAXCOD), [
  355.     .PRNTX    "Code exceeds maximum!"
  356.     ]
  357. ;
  358. ; Unitialized Data area.
  359. ;
  360. Usrtab:    ds    MAXTAB
  361. Atab:    ds    MAXTAB
  362. Btab:    ds    MAXTAB
  363. Asvtab:    ds    MAXTAB
  364. Bsvtab:    ds    MAXTAB
  365. ;
  366. .slist
  367. .list
  368. LENGTH equ . - START
  369. .ifg (length - MAXLEN), [
  370.     .prntx    "Overflow in Key Overlay module!"
  371.     ]
  372. .rlist
  373.     .end
  374.  
  375. jmp    pu