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 / S19FNK.AQM / S19FNK.ASM
Assembly Source File  |  2000-06-30  |  6KB  |  327 lines

  1. .title    "S19FNK.asm Super19 function key overlay for BG 6/17/86"
  2. ;
  3. ; For Super19 Rom for Heath/Zenith 19/89/90 terminals.
  4. ;
  5. ; NOTE:
  6. ;    There is apparently no way to determine the current status
  7. ;    of the terminal's modes.  Therefore, the initialiation/
  8. ;    deinitialization routines cannot save/restore the startup
  9. ;    modes.
  10. ;    
  11. .ident    S19FNK
  12. .pabs
  13. .phex
  14. .xsym
  15. .xlist
  16.  
  17. MAXLEN    equ    6*80H        ;MAX SIZE OF OVERLAY
  18. MAXCOD    equ    200h        ;MAX size of code & initialized data
  19. ;
  20. release    equ    '0'
  21. vers    equ    '1'
  22. ;
  23. NUL    EQU    0
  24. ESC    EQU    1Bh
  25. TRUE    EQU    0FFh
  26. ;
  27. ;===============================
  28. ; Identification sector at 3e80h
  29. ;
  30.     .loc    3e80h
  31. fnkyid:    .ascii    "Super 19 (Heath/Zenith 19/89/90) function-key overlay v. "
  32.     db    release
  33.     db    '.'
  34.     db    vers
  35.     db    0        ;NUL-terminated string
  36. ;
  37. ;================================== 
  38. ; Table of Function-key 8-bit codes and associated labels at 3f00h.
  39. ; Each entry is a 1-byte key value, followed by a 4-byte ascii label.
  40. ;
  41.     .loc    3f00h
  42. ;
  43. labtbl:    db    nm8kys        ;number of keys
  44. ;
  45. fstky:
  46. ;
  47. ; Alternate Keypad Mode - top row function keys
  48.     db    'P'+80H
  49.     .ascii    "blue"        ;blue
  50.     db    'Q'+80H
  51.     .ascii    "red "        ;red
  52.     db    'R'+80H
  53.     .ascii    "whit"        ;white/grey
  54.     db    'S'+80H
  55.     .ascii    "f1  "        ;f1
  56.     db    'T'+80H
  57.     .ascii    "f2  "        ;f2
  58.     db    'U'+80H
  59.     .ascii    "f3  "        ;f3
  60.     db    'V'+80H
  61.     .ascii    "f4  "        ;f4
  62.     db    'W'+80H
  63.     .ascii    "f5  "        ;f5
  64.     db    'J'+80H
  65.     .ascii    "eras"        ;erase
  66. ;
  67. ; Shifted Alternate Keypad Mode - top row function keys
  68.     db    '$'+80H
  69.     .ascii    "BLUE"
  70.     db    '%'+80H
  71.     .ascii    "RED "
  72.     db    '&'+80H
  73.     .ascii    "WHIT"
  74.     db    "'"+80H
  75.     .ascii    "F1  "
  76.     db    '{'+80H
  77.     .ascii    "F2  "
  78.     db    '}'+80H
  79.     .ascii    "F3  "
  80.     db    '*'+80H
  81.     .ascii    "F4  "
  82.     db    '+'+80H
  83.     .ascii    "F5  "
  84.     db    'E'+80H
  85.     .ascii    "ERAS"
  86. ;
  87. ; Shifted Keypad Mode - numeric keypad keys
  88.     db    'L'+80H
  89.     .ascii    "key1"
  90.     db    'B'+80H
  91.     .ascii    "key2"
  92.     db    'M'+80H
  93.     .ascii    "key3"
  94.     db    'D'+80H
  95.     .ascii    "key4"
  96.     db    'H'+80H
  97.     .ascii    "key5"
  98.     db    'C'+80H
  99.     .ascii    "key6"
  100.     db    '@'+80H        ; kp 7
  101.     .ascii    "key7"
  102.     db    'O'+80H        ; kp 7 if insert on. ??
  103.     .ascii    "key7"
  104.     db    'A'+80H
  105.     .ascii    "key8"
  106.     db    'N'+80H
  107.     .ascii    "key9"
  108. ;
  109. ; Alternate or Shifted Alternate Keypad Mode - numeric keypad keys
  110.     db    '1'+80H
  111.     .ascii    "KEY1"
  112.     db    '2'+80H
  113.     .ascii    "KEY2"
  114.     db    '3'+80H
  115.     .ascii    "KEY3"
  116.     db    '4'+80H
  117.     .ascii    "KEY4"
  118.     db    '5'+80H
  119.     .ascii    "KEY5"
  120.     db    '6'+80H
  121.     .ascii    "KEY6"
  122.     db    '7'+80H        ; kp 7
  123.     .ascii    "KEY7"
  124.     db    '8'+80H
  125.     .ascii    "KEY8"
  126.     db    '9'+80H
  127.     .ascii    "KEY9"
  128. ;
  129. ; Alternate Keypad Mode
  130.     db    '0'+80H
  131.     .ascii    "key0"        ;zero
  132.     db    '.'+80H
  133.     .ascii    "key."        ;dot
  134.     db    '/'+80H
  135.     .ascii    "entr"        ;enter
  136. ;
  137. ; Shifted Alternate Keypad Mode
  138.     db    '_'+80H
  139.     .ascii    "KEY0"        ;ZERO
  140.                 ; DOT is the same
  141.     db    '?'+80H
  142.     .ascii    "ENTR"        ;ENTER
  143. ;
  144. nm8kys     equ    (.-fstky)/(1+4)
  145. ;
  146. .ifg (. - labtbl - 100h), [
  147.     .prntx    "Overflow in label table"
  148.     ]
  149. ;
  150. .ifn (.-fstky)@(1+4), [
  151.     .prntx    "alignment error in labels"
  152.     ]
  153. ;
  154. ;==================================
  155. ; The function-key overlay at 4000h.
  156. ;
  157.     .loc    4000h
  158. ;
  159. ; Enter A = 0 ... 7 function number.
  160. ; After exit, this overlay is written to swap file to preserve
  161. ; changed data.
  162. ;
  163. START:    ora    a
  164.     jz    init    ;0
  165.     dcr    a
  166.     jz    deinit    ;1
  167.     dcr    a
  168.     jz    ashft    ;2
  169.     dcr    a
  170.     jz    bshft    ;3
  171.     dcr    a
  172.     jz    aunshft    ;4
  173.     dcr    a
  174.     jz    bunshft    ;5
  175.     dcr    a
  176.     jz    asave    ;6
  177.     dcr    a
  178.     jz    bsave    ;7
  179.     dcr    a
  180.     jz    arest    ;8
  181.     dcr    a
  182.     jz    brest    ;9
  183.     ret        ;not supported
  184. ;
  185. ;-----------------
  186. ; Function 0. INIT.
  187. ; This routine is called when BG is first loaded.
  188. ;
  189. ; Save initial state of function keys.
  190. ; Set 8-bit function key codes for BG.
  191. ;
  192. INIT:    lxi    h,Zshift        ;8bit and alternate
  193.     jmp    display
  194. ;
  195. ;-------------------
  196. ; Function 1. DEINIT.
  197. ; Restore 7-bit mode.
  198. ;
  199. DEINIT:    lxi    h,Zunshft    ;7 bit and not alternate
  200.     jmp    display
  201. ;
  202. ;----------------------
  203. ; Functions 2, 3. SHIFT.
  204. ;
  205. ; Set 8-bit function key mode.
  206. ; "A" refers to the initial task, "B" to the Alternate task.
  207. ;
  208. ASHFT:    mvi    a,TRUE        ;record mode
  209.     sta    Ashftq
  210. doshft:    lxi    h,Zshift
  211.     jmp    display
  212. ;
  213. BSHFT:    mvi    a,TRUE
  214.     sta    Bshftq
  215.     jmp    doshft
  216. ;
  217. ;------------------------
  218. ; Functions 4, 5. UNSHIFT.
  219. ; Restore 7-bit mode.
  220. ;
  221. AUNSHF:    xra    a
  222.     sta    Ashftq
  223. dounsh:    lxi    h,Zunshft
  224.     jmp    display
  225. ;
  226. BUNSHF:    xra    a
  227.     sta    Bshftq
  228.     jmp    dounsh
  229. ;
  230. ;---------------------
  231. ; Functions 6, 7. SAVE.
  232. ; Save current function keys in preparation for task swap.
  233. ;
  234. ASAVE:    RET
  235. ;
  236. BSAVE:    RET
  237. ;
  238. ;------------------------
  239. ; Functions 8, 9. RESTORE.
  240. ; Restore current function keys following task swap.
  241. ;
  242. AREST:    lda    Ashftq
  243. arest1:    ora    a
  244.     jnz    doshft
  245.     jmp    dounsh
  246. ;
  247. BREST:    lda    Bfirst        ;on first swap, there's nothing to restore
  248.     ora    a
  249.     mvi    a,0
  250.     sta    Bfirst
  251.     rnz
  252.     lda    Bshftq
  253.     jmp    arest1
  254. ;
  255. ;--------------------------
  256. ;
  257. ; print NUl-terminated string to conout
  258. display:
  259.     mov    a,m
  260.     ora    a
  261.     rz
  262.     push    h
  263.     mov    c,a
  264.     call    bios0c
  265.     pop    h
  266.     inx    h
  267.     jmp    display
  268. ;
  269. bios0c:    lhld    1            ;bios conout
  270.     mvi    l,0ch
  271.     pchl
  272. ;
  273. ;
  274. Zshift:
  275. zset8b:    db    ESC,'e','C'        ;fn keys send 8-bit mode
  276. Zaltkp:    db    ESC,'=',NUL        ;set alternate keypad
  277. ;
  278. Zunshft:
  279. znot8b:    db    ESC,'e','A'        ;fn keys send ESC sequences
  280. Zregkp:    db    ESC,'>',NUL        ;reset alternate keypad
  281. ;
  282. ; this could perhaps be used for deinit.
  283. ; If so, include a delay loop to allow H19 rom to complete the
  284. ; operation without dropping following characters.
  285. ;
  286. ;Zdeini:    db    ESC,'Z',NUL        ;restore to power-up config.
  287. ;
  288. ; what is this: ??
  289. ;zenab:    db    ESC,'x','7',NUL        ;enable alternate keypad
  290. ;
  291. ;
  292. Ashftq:    db    0            ;A mode state
  293. Bshftq:    db    0            ;B mode state
  294. Bfirst:    db    TRUE            ;first-time flag , static TRUE
  295. ;
  296. undata equ .
  297. .ifg (undata - start - MAXCOD), [
  298.     .PRNTX    "Code exceeds maximum!"
  299.     ]
  300. ;
  301. ; Unitialized Data area.
  302. ;
  303. ; NONE.
  304. ;
  305. .slist
  306. .list
  307. LENGTH equ . - START
  308. .ifg (length - MAXLEN), [
  309.     .prntx    "Overflow in Key Overlay module!"
  310.     ]
  311. .rlist
  312.     .END
  313.  
  314. 
  315.     rz
  316.     push    h
  317.     mov    c,a
  318.     call    bios0c
  319.     pop    h
  320.     inx    h
  321.     jmp    display
  322. ;
  323. bios0c:    lhld    1            ;bios conout
  324.     mvi    l,0ch
  325.     pchl