home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / enhancements / general / keymenu / keymenu.asm < prev    next >
Assembly Source File  |  1991-03-10  |  94KB  |  1,598 lines

  1. *******************************************************************************
  2. *
  3. * KeyMenu.asm  V1.03  02 Mar 1991      
  4. *                                     
  5. *
  6. * Usage:
  7. *   KeyMenu QUIT
  8. *   KeyMenu ?
  9. *   KeyMenu [<options>]
  10. *     Where <options> is one or more of the following:  
  11. *      -i  info about KeyMenu's current configuration
  12. *      -b  toggle Intuition pointer blanking            default=OFF
  13. *      -t  toggle clearing of RMBTRAP flag in windows   default=OFF
  14. *      -q# # = qualifier key(s) to supplement move keys default=Right Shift
  15. *      -p# # = input handler priority in decimal        default=51
  16. *      -a# # = hex keycode of ACTIVATION key            default=Right ALT
  17. *      -e# # = hex keycode of ESCAPE key                default=ESC
  18. *      -s# # = hex keycode of SELECT key                default=Return
  19. *      -l# # = hex keycode of LEFT key                  default=Cursor left
  20. *      -r# # = hex keycode of RIGHT key                 default=Cursor right
  21. *      -u# # = hex keycode of UP key                    default=Cursor up
  22. *      -d# # = hex keycode of DOWN key                  default=Cursor down
  23. *
  24. *
  25. *   This program serves as the user interface to the KeyMenu-Handler. It is 
  26. *   used to install the KeyMenu-Handler, change it's configuration at any time
  27. *   or remove the handler from the system. This program is completely
  28. *   re-entrant (pure).
  29. *
  30. *
  31. * Modification History:
  32. *
  33. *       Date       By                       Modification
  34. *     --------  --------------------    --------------------------------------
  35. *     09/09/89  Ken Lowther             Initial release, V1.01
  36. *
  37. *     09/13/89  Ken Lowther             V1.02 - Added qualifier option to allow
  38. *                                       changing the qualifier key that can be
  39. *                                       used with the movement keys.
  40. *
  41. *     09/30/89  Ken Lowther             V1.02 - This program no longer creates a
  42. *                                       process for the keymenu-handler module.
  43. *
  44. *     03/02/91  Ken Lowther             V1.03 - Re-installed intuition pointer
  45. *                                       blanking option.
  46. *
  47. *******************************************************************************
  48.             nolist
  49.             include "macros.i"
  50.             include "exec/types.i"
  51.             include "exec/strings.i"
  52.             include "exec/nodes.i"
  53.             include "exec/ports.i"
  54.             include "exec/execbase.i"
  55.             include "exec/ables.i"
  56.             include "exec/interrupts.i"
  57.             include "exec/memory.i"
  58.             include "exec/lists.i"
  59.             include "exec/io.i"
  60.             include "devices/input.i"
  61.             include "devices/inputevent.i"
  62.             include "intuition/intuition.i"
  63.             include "libraries/dos.i"
  64.             include "libraries/dosextens.i"
  65.             include "keymenu-handler.i"
  66.             include "keymenu.i"
  67.             list 
  68.             nomlist
  69.  
  70. kmw         equr    a4                          ; keymenu workarea register
  71. gbl         equr    a5                          ; handler global register
  72.  
  73. *******************************************************************************
  74. *                                                                             * 
  75. *           Miscellaneous equates                                             *
  76. *                                                                             *
  77. *******************************************************************************
  78. keynamesmax equ     (keynamesend-keynames)/2    ; maximum keycode in keynames
  79.                                                 ; table
  80. kmportl     equ     kmportend-kmport            ; port name length
  81. quitwordl   equ     quitwordend-quitword
  82. nomeml      equ     nomemend-nomem
  83.  
  84.             cseg
  85.             public  main
  86.             near    code
  87. *******************************************************************************
  88. *                                                                             * 
  89. *       main                                                                  *
  90. *                                                                             *
  91. *       This is the main routine of keymenu. It is where execution begins.    *
  92. *       Here we perform the following functions.                              *
  93. *           1) Initialize program                                             *
  94. *           2) parse the runtime command line and report errors if any.       *
  95. *           3) determine what work is to be done and call the appropriate     *
  96. *              routines to do it.                                             *
  97. *           4) perform program cleanup and exit.                              *
  98. *                                                                             *
  99. *       Input Registers:                                                      *
  100. *           a0 - command line address                                         *
  101. *           d0 - command line length                                          *
  102. *                                                                             *
  103. *       Output Registers:                                                     *
  104. *           d0 - amigados return code                                         *
  105. *                                                                             *
  106. *******************************************************************************
  107. main        movem.l mainregs,-(sp)          ; save entry registers
  108. *-----------------------------------------------------------------------------*
  109. *           go initialize, exit if initialization fails                       *
  110. *-----------------------------------------------------------------------------*
  111.             jsr     init                    ; go initialize
  112.             bne     mainexit                ; initialization failed, branch
  113. *-----------------------------------------------------------------------------*
  114. *           parse the runtime command, exit if errors                         *
  115. *-----------------------------------------------------------------------------*
  116.             jsr     parse                   ; go parse the runtime command
  117.             bne     maincleanup             ; parser failed, branch
  118. *-----------------------------------------------------------------------------*
  119. *           determine what is to be done                                      *
  120. *-----------------------------------------------------------------------------*
  121.             lea     kmport(pc),a1           ; point to handler's port name
  122.             Call    FindPort                ; go see if it exists
  123.             tst.l   d0                      ; does port exist ?
  124.             bne     main010                 ; yes, branch
  125. *-----------------------------------------------------------------------------*
  126. *           handler doesn't exist, create it                                  *
  127. *-----------------------------------------------------------------------------*
  128.             jsr     create                  ; go create handler
  129.             beq     maincleanup             ; branch if unable to create it
  130. main010     bset.b  #FLAGB_exists,kmw_flags(kmw) ; indicate port exists
  131.             move.l  d0,gbl                  ; setup handler global register
  132. main015     btst.b  #FLAGB_quit,kmw_flags(kmw) ; was 'quit' specified ?
  133.             beq     main020                 ; no, branch
  134. *-----------------------------------------------------------------------------*
  135. *           quit was specified, stop the handler and exit                     *
  136. *-----------------------------------------------------------------------------*
  137.             jsr     quit                    ; yes, get rid of handler
  138.             bra     maincleanup             ; get out            
  139. main020     btst.b  #FLAGB_exists,kmw_flags(kmw) ; does handler exist ?
  140.             beq     maincleanup             ; no, branch
  141. *-----------------------------------------------------------------------------*
  142. *           process any runtime parameters that may have been given           *
  143. *-----------------------------------------------------------------------------*
  144.             jsr     params                  ; yes, go process any runtime params
  145. *-----------------------------------------------------------------------------*
  146. *           do cleanup and exit.                                              *
  147. *-----------------------------------------------------------------------------*
  148. maincleanup move.l  kmw_dosbase(kmw),a1     ; get dos library base
  149.             Call    CloseLibrary            ; close it
  150.             move.l  kmw,a1                  ; get work area address
  151.             move.l  #kmw_size,d0            ; get size of work area
  152.             Call    FreeMem                 ; go free the work area
  153. mainexit    movem.l (sp)+,mainregs          ; restore registers
  154.             clr.l   d0                      ; set return code for dos
  155.             rts                             ; return to caller
  156. mainregs    reg     d1-d7/a0-a6             ; registers saved by main
  157.  
  158. *******************************************************************************
  159. *                                                                             * 
  160. *       init                                                                  *
  161. *                                                                             *
  162. *       This routine performs the following initialization tasks:             *
  163. *           1) opens the dos library                                          *
  164. *           2) gets std output file handle                                    *
  165. *           3) allocates and initializes our workarea                         *
  166. *                                                                             *
  167. *       Input Registers:                                                      *
  168. *           a0 - command line address                                         *
  169. *           d0 - command line length                                          *
  170. *                                                                             *
  171. *       Output Registers:                                                     *
  172. *           a4 - workarea address                                             *
  173. *           a6 - exec library base                                            *
  174. *           d0 - return code (0=initialization successful)                    *
  175. *                                                                             *
  176. *******************************************************************************
  177. init        move.l  AbsExecBase,a6          ; setup exec library base
  178.             move.l  a0,a3                   ; save command line address
  179.             move.l  d0,d3                   ; save command line length
  180. *-----------------------------------------------------------------------------*
  181. *           Open DOS Library                                                  *
  182. *-----------------------------------------------------------------------------*
  183.             lea     doslib(pc),a1           ; point to library name
  184.             moveq.l #0,d0                   ; we don't care what version
  185.             Call    OpenLibrary             ; go open the library
  186.             move.l  d0,a5                   ; save library base for use later
  187.             beq     init_err1               ; openlibrary failed - can't tell
  188.                                             ; user - just exit
  189. *-----------------------------------------------------------------------------*
  190. *           Get STD Output File Handle                                        *
  191. *-----------------------------------------------------------------------------*
  192.             Call    Output,a5               ; get file handle for screen
  193.             move.l  d0,a2                   ; save output file handle
  194.             beq     init_err                ; if no handle was returned - branch
  195. *-----------------------------------------------------------------------------*
  196. *           Allocate our workarea                                             *
  197. *-----------------------------------------------------------------------------*
  198.             move.l  #kmw_size,d0            ; set size of area to allocate
  199.             move.l  #MEMF_CLEAR,d1          ; indicate type of memory
  200.             Call    AllocMem                ; go get it
  201.             move.l  d0,kmw                  ; setup our workarea register
  202.             bne     init010                 ; if allocate was successful, branch
  203.             move.l  a2,d1                   ; get file handle
  204.             lea     nomem(pc),a0            ; get error message address
  205.             move.l  a0,d2
  206.             move.l  #nomeml,d3              ; get error message length
  207.             Call    Write,a5                ; write error message
  208.             bra     init_err                ; go cleanup
  209. *-----------------------------------------------------------------------------*
  210. *           Initialize our workarea                                           *
  211. *-----------------------------------------------------------------------------*
  212. init010
  213.             move.l  a5,kmw_dosbase(kmw)     ; save dos base address
  214.             move.l  a2,kmw_filehandle(kmw)  ; save output file handle
  215.             move.l  a3,kmw_cmd(kmw)         ; save runtime command address
  216.             move.w  d3,kmw_cmd_length(kmw)  ; save runtime command length
  217.             move.b  #-1,kmw_AKey(kmw)       ; initialize to null keys
  218.             move.b  #-1,kmw_DKey(kmw)
  219.             move.b  #-1,kmw_SKey(kmw)
  220.             move.b  #-1,kmw_UpKey(kmw)
  221.             move.b  #-1,kmw_DownKey(kmw)
  222.             move.b  #-1,kmw_LeftKey(kmw)
  223.             move.b  #-1,kmw_RightKey(kmw)
  224.             move.b  #handlerpri,kmw_handlerpri(kmw) ; default handler priority
  225.             bra     init_ok                 ; initialized ok - return
  226. *-----------------------------------------------------------------------------*
  227. *           Failed to get Output File Handle                                  *
  228. *-----------------------------------------------------------------------------*
  229. init_err    
  230.             move.l  a5,a1                   ; get dos library base
  231.             Call    CloseLibrary            ; close it
  232. *-----------------------------------------------------------------------------*
  233. *           Couldn't initialize for whatever reason - set return code         *
  234. *-----------------------------------------------------------------------------*
  235. init_err1   moveq.l #1,d0                   ; indicate failure
  236.             bra     initexit                ; get out
  237. *-----------------------------------------------------------------------------*
  238. *           initialized ok - set return code                                  *
  239. *-----------------------------------------------------------------------------*
  240. init_ok     clr.l   d0                      ; indicate success
  241. *-----------------------------------------------------------------------------*
  242. *           Common return point                                               *
  243. *-----------------------------------------------------------------------------*
  244. initexit    rts                             ; return
  245.  
  246. *******************************************************************************
  247. *                                                                             * 
  248. *       changekey                                                             *
  249. *                                                                             *
  250. *       This routine is called to change a keymenu configuration key from one *
  251. *       value to another and print a message documenting the change.          *
  252. *                                                                             *
  253. *       Input Registers:                                                      *
  254. *           a0 - address of keymenu's global area for the key being changed   *
  255. *           a1 - address of text describing the key being changed             *
  256. *           d0 - new key value to be used (-1 = no change)                    *
  257. *                                                                             *
  258. *       Output Registers:                                                     *
  259. *           none                                                              *
  260. *                                                                             *
  261. *******************************************************************************
  262. changekey   movem.l ckregs,-(sp)            ; save registers
  263.             cmp.b   #-1,d0                  ; was a new value given ?
  264.             beq     changekeyexit           ; no, branch
  265.             clr.l   d1                      ; clear work register
  266.             move.b  (a0),d1                 ; get old value of key
  267.             move.l  d0,d2                   ; get new key value
  268.             asl.w   #1,d2                   ; multiply by 2
  269.             lea     keynames(pc),a3         ; get address of key names table
  270.             lea     keyval(pc),a2           ; get address of key value table
  271.             move.w  d0,-(sp)                ; pass new key value
  272.             move.w  (a3,d2.w),d2            ; get disp of new key name
  273.             pea     (a2,d2.w)               ; pass addr of new key name
  274.             move.l  d1,d2                   ; get old key value
  275.             asl.w   #1,d2                   ; multiply by 2
  276.             move.w  d1,-(sp)                ; pass old key value
  277.             move.w  (a3,d2.w),d2            ; get disp of old key name
  278.             pea     (a2,d2.w)               ; pass address of old key name
  279.             move.l  a1,-(sp)                ; pass text of key being changed
  280.             move.b  d0,(a0)                 ; update keymenu's global area
  281.             lea     changemsg(pc),a0        ; get format string address
  282.             jsr     printf                  ; go print change message
  283.             add.l   #16,sp                  ; adjust stack pointer
  284. changekeyexit
  285.             movem.l (sp)+,ckregs
  286.             rts                             ; return to caller
  287. ckregs      reg     d0-d2/a0-a3
  288.             
  289. *******************************************************************************
  290. *                                                                             * 
  291. *       params                                                                *
  292. *                                                                             *
  293. *       This routine processes any runtime params that may have been given    *
  294. *       to change keymenu's configuration. Also, messages are produced        *
  295. *       indicating any changes that are made.                                 * 
  296. *                                                                             *
  297. *       Input Registers:                                                      *
  298. *           a4 - keymenu workarea address (kmw)                               *
  299. *           a5 - handler global area                                          *
  300. *                                                                             *
  301. *       Output Registers:                                                     *
  302. *           none                                                              *
  303. *                                                                             *
  304. *******************************************************************************
  305. params      clr.l   d0
  306. *-----------------------------------------------------------------------------*
  307. *           Change any of the various keys that keymenu uses.                 *
  308. *-----------------------------------------------------------------------------*
  309.             move.b  kmw_AKey(kmw),d0        ; load parameter
  310.             lea     gb_AKey(gbl),a0         ; point to global area
  311.             lea     akey(pc),a1             ; text for change message
  312.             jsr     changekey               ; go change the key if necessary
  313.             move.b  kmw_DKey(kmw),d0        ; load parameter
  314.             lea     gb_DKey(gbl),a0         ; point to global area
  315.             lea     dkey(pc),a1             ; text for change message
  316.             jsr     changekey               ; go change the key if necessary
  317.             move.b  kmw_SKey(kmw),d0        ; load parameter
  318.             lea     gb_SKey(gbl),a0         ; point to global area
  319.             lea     skey(pc),a1             ; text for change message
  320.             jsr     changekey               ; go change the key if necessary
  321.             move.b  kmw_UpKey(kmw),d0       ; load parameter
  322.             lea     gb_UpKey(gbl),a0        ; point to global area
  323.             lea     upkey(pc),a1            ; text for change message
  324.             jsr     changekey               ; go change the key if necessary
  325.             move.b  kmw_DownKey(kmw),d0     ; load parameter
  326.             lea     gb_DownKey(gbl),a0      ; point to global area
  327.             lea     downkey(pc),a1          ; text for change message
  328.             jsr     changekey               ; go change the key if necessary
  329.             move.b  kmw_LeftKey(kmw),d0     ; load parameter
  330.             lea     gb_LeftKey(gbl),a0      ; point to global area
  331.             lea     leftkey(pc),a1          ; text for change message
  332.             jsr     changekey               ; go change the key if necessary
  333.             move.b  kmw_RightKey(kmw),d0    ; load parameter
  334.             lea     gb_RightKey(gbl),a0     ; point to global area
  335.             lea     rightkey(pc),a1         ; text for change message
  336.             jsr     changekey               ; go change the key if necessary
  337.             btst.b  #FLAGB_trap,kmw_flags(kmw) ; was rmbtrap option specified ?
  338.             beq     params025               ;  ; no, branch
  339. *-----------------------------------------------------------------------------*
  340. *           Change the clear RMBTRAP option                                   *
  341. *-----------------------------------------------------------------------------*
  342.             lea     info4(pc),a0            ; point to message text
  343.             bchg.b  #FLAGB_Clear_rmbtrap,gb_flags(gbl) ; invert the bit
  344.             beq     params010               ; was off, now on, branch
  345.             pea     nowoff(pc)              ; indicate now off
  346.             bra     params020
  347. params010   pea     nowon(pc)               ; indicate now on
  348. params020   jsr     printf                  ; go tell what we did
  349.             addq.l  #4,sp                   ; adjust stack pointer
  350.  
  351. params025   btst.b  #FLAGB_Qual,kmw_flags(kmw) ; was a qualifier(s) specified ?
  352.             beq     params026                  ; no, branch
  353. *-----------------------------------------------------------------------------*
  354. *           Change qualifier(s)                                               *
  355. *-----------------------------------------------------------------------------*
  356.             move.b  kmw_Qual(kmw),gb_Qual(gbl) ; update global area
  357.             jsr     printqual               ; go print new keys
  358.             
  359. params026   btst.b  #FLAGB_blankp,kmw_flags(kmw) ; was blank pointer option
  360.                                                   ; given ?
  361.             beq     params030                     ; no, branch
  362. *-----------------------------------------------------------------------------*
  363. *           Change the blank intuition pointer option                         *
  364. *-----------------------------------------------------------------------------*
  365.             lea     info5(pc),a0            ; point to message text
  366.             bchg.b  #FLAGB_Blank_pointer,gb_flags(gbl) ; invert the bit
  367.             beq     params027               ; was off, now on, branch
  368.             pea     nowoff(pc)              ; indicate now off
  369.             bra     params028
  370. params027   pea     nowon(pc)               ; indicate now on
  371. params028   jsr     printf                  ; go tell what we did
  372.             addq.l  #4,sp                   ; adjust stack pointer
  373.  
  374. params030   btst.b  #FLAGB_info,kmw_flags(kmw) ; was info asked for ?
  375.             beq     params110                  ; no, branch
  376. *-----------------------------------------------------------------------------*
  377. *           print info about keymenu's configuration                          *
  378. *-----------------------------------------------------------------------------*
  379.             lea     info1(pc),a0            ; point to message text
  380.             pea     kmport(pc)              ; put portname address on the stack
  381.             jsr     printf                  ; go print it
  382.             addq.w  #4,sp                   ; adjust stack
  383.             move.b  gb_AKey(gbl),d0         ; load key's value
  384.             lea     akey(pc),a1             ; point to text describing the key
  385.             jsr     printkey                ; print info message
  386.             move.b  gb_DKey(gbl),d0
  387.             lea     dkey(pc),a1
  388.             jsr     printkey
  389.             move.b  gb_SKey(gbl),d0
  390.             lea     skey(pc),a1
  391.             jsr     printkey
  392.             move.b  gb_UpKey(gbl),d0
  393.             lea     upkey(pc),a1
  394.             jsr     printkey
  395.             move.b  gb_DownKey(gbl),d0
  396.             lea     downkey(pc),a1
  397.             jsr     printkey
  398.             move.b  gb_RightKey(gbl),d0
  399.             lea     rightkey(pc),a1
  400.             jsr     printkey
  401.             move.b  gb_LeftKey(gbl),d0
  402.             lea     leftkey(pc),a1
  403.             jsr     printkey
  404.             jsr     printqual               ; go print key qualifier(s)
  405.             lea     info5(pc),a0            ; point to message text
  406.             btst.b  #FLAGB_Blank_pointer,gb_flags(gbl) ; blank pointer option on ?
  407.             beq     params070                          ; no, branch
  408.             pea     on(pc)                  ; pass 'on' text to printf
  409.             bra     params080
  410. params070   pea     off(pc)                 ; pass 'off' text to printf
  411. params080   jsr     printf                  ; print the message
  412.             addq.l  #4,sp                   ; adjust the stack pointer
  413.             lea     info4(pc),a0            ; point to message text
  414.             btst.b  #FLAGB_Clear_rmbtrap,gb_flags(gbl) ; is clear rmbtrap on ?
  415.             beq     params090                          ; no, branch
  416.             pea     on(pc)                  ; pass 'on' text to printf
  417.             bra     params100
  418. params090   pea     off(pc)                 ; pass 'off' text to printf
  419. params100   jsr     printf                  ; print the message
  420.             addq.l  #4,sp                   ; adjust the stack pointer
  421. params110
  422.             rts                             ; return to caller
  423.  
  424. *******************************************************************************
  425. *                                                                             * 
  426. *       printkey                                                              *
  427. *                                                                             *
  428. *       This routine is called to print the configured value of a key         *
  429. *                                                                             *
  430. *       Input Registers:                                                      *
  431. *           a1 - address of text describing the key being changed             *
  432. *           d0 - key value                                                    *
  433. *                                                                             *
  434. *       Output Registers:                                                     *
  435. *           none                                                              *
  436. *                                                                             *
  437. *******************************************************************************
  438. printkey    movem.l pkregs,-(sp)            ; save registers
  439.             clr.l   d1                      ; clear work register
  440.             move.l  d0,d2                   ; get key value
  441.             asl.w   #1,d2                   ; multiply by 2
  442.             lea     keynames(pc),a3         ; get address of key names table
  443.             lea     keyval(pc),a2
  444.             move.w  d0,-(sp)                ; pass key value
  445.             move.w  (a3,d2.w),d2
  446.             pea     (a2,d2.w)
  447.             move.l  a1,-(sp)                ; pass text of key being changed
  448.             lea     info2(pc),a0            ; get format string address
  449.             jsr     printf                  ; go print change message
  450.             add.l   #10,sp                  ; adjust stack pointer
  451. printkeyexit
  452.             movem.l (sp)+,pkregs
  453.             rts                             ; return to caller
  454. pkregs      reg     d0-d2/a0-a3
  455.             
  456. *******************************************************************************
  457. *                                                                             * 
  458. *       printqual                                                             *
  459. *                                                                             *
  460. *       This routine is called to print the configured key qualifier(s)       *
  461. *                                                                             *
  462. *       Input Registers:                                                      *
  463. *           a5 - address of keymenu global area                               *
  464. *                                                                             *
  465. *       Output Registers:                                                     *
  466. *           none                                                              *
  467. *                                                                             *
  468. *******************************************************************************
  469. printqual   movem.l pqregs,-(sp)            ; save registers
  470.             lea     info3(pc),a0            ; get format string address
  471.             jsr     printf                  ; go print the string
  472.             lea     none(pc),a0
  473.             tst.b   gb_Qual(gbl)            ; are there any qualifiers
  474.             beq     pq030                   ; no, branch
  475.             moveq.l #7,d1                   ; set number of bits
  476. pq010       btst.b  d1,gb_Qual(gbl)         ; is qualifier present ?
  477.             beq     pq015                   ; no, branch
  478.             move.l  d1,d2
  479.             asl.w   #1,d2                   ; multiply by 2
  480.             lea     qualnames(pc),a3        ; get address of qualifier names
  481.             lea     keyval(pc),a2
  482.             move.w  (a3,d2.w),d2
  483.             pea     (a2,d2.w)
  484.             lea     info3a(pc),a0           ; get format string address
  485.             jsr     printf                  ; go print key name
  486.             addq.l  #4,sp                   ; adjust stack pointer
  487. pq015       dbra    d1,pq010
  488. pq020       lea     info3end(pc),a0
  489.  
  490. pq030       jsr     printf                  ; print end of the message
  491. printqualexit
  492.             movem.l (sp)+,pqregs
  493.             rts                             ; return to caller
  494. pqregs      reg     d0-d2/a0-a3
  495.             
  496. *******************************************************************************
  497. *                                                                             * 
  498. *       quit                                                                  *
  499. *                                                                             *
  500. *       This routine stops the input handler and frees all its remaining      *
  501. *       resources in the following manner:                                    *
  502. *           1) signal the handler that we are stopping.                       *
  503. *           2) wait for handler to signal back that it is ready to stop       *
  504. *           3) remove the handlers port and tell the input device to stop     *
  505. *              passing events to the handler.                                 *
  506. *           4) unload the handler's segment                                   *
  507. *                                                                             *
  508. *       Input Registers:                                                      *
  509. *           a4 - keymenu work area (kmw)                                      *
  510. *           a5 - handler global area (gbl)                                    *
  511. *                                                                             *
  512. *       Output Registers:                                                     *
  513. *           none                                                              *
  514. *                                                                             *
  515. *******************************************************************************
  516. quit        btst.b  #FLAGB_exists,kmw_flags(kmw) ; does handler exist ?
  517.             beq     quit020                 ; no, branch
  518.             lea     remove(pc),a0           ; get removing message address
  519.             jsr     printf                  ; go write removing message
  520. *-----------------------------------------------------------------------------*
  521. *           Signal the input handler that we intend to stop                   *
  522. *-----------------------------------------------------------------------------*
  523.             sub.l   a1,a1                   ; setup to find our task
  524.             Call    FindTask                ; go get our task pointer
  525.             move.l  d0,gb_task(gbl)         ; save our task pointer
  526.             moveq.l  #-1,d0                 ; setup to allocate a signal
  527.             Call    AllocSignal             ; go allocate one
  528.             move.b  d0,gb_tasksignum(gbl)   ; save signal number
  529.             move.l  #SIGBREAKF_CTRL_C,d0      ; set signal mask
  530.             move.l  gb_handtask(gbl),a1     ; get task to signal
  531.             Call    Signal                  ; signal the handler task to stop
  532. *-----------------------------------------------------------------------------*
  533. *           Wait for the handler to signal us that it's ok to stop            *
  534. *-----------------------------------------------------------------------------*
  535.             clr.l   d0
  536.             clr.l   d1
  537.             move.b  gb_tasksignum(gbl),d1
  538.             bset.l  d1,d0                   ; create wait mask
  539.             Call    Wait                    ; wait for handler to signal us
  540.             clr.l   d0
  541.             move.b  gb_tasksignum(gbl),d0   ; get allocated signal number
  542.             Call    FreeSignal              ; go free the signal
  543. *-----------------------------------------------------------------------------*
  544. *           remove the handler's port and tell input device to remove us from *
  545. *           the handler list                                                  *
  546. *-----------------------------------------------------------------------------*
  547.             move.l  gbl,a1                  ; get handler's port
  548.             Call    RemPort                 ; remove it from the public eye
  549.             moveq.l #IND_REMHANDLER,d0      ; indicate we want to remove handler
  550.             jsr     tellinputdevice         ; go tell it to the input.device
  551.             bne     quit010                 ; if removed, branch
  552.             lea     handlererr(pc),a0       ; get error message address
  553.             jsr     printf                  ; go tell user
  554.             bra     quit020
  555. *-----------------------------------------------------------------------------*
  556. *           Unload the handler's segment and tell user everything ok.         *
  557. *-----------------------------------------------------------------------------*
  558. quit010     move.l  gb_Segment(gbl),d1      ; get segment address
  559.             Call    UnLoadSeg,kmw_dosbase(kmw) ; get rid of it
  560.             lea     ok(pc),a0               ; get message address
  561.             jsr     printf                  ; write it
  562. *-----------------------------------------------------------------------------*
  563. *           cleanup remaining resources                                       *
  564. *-----------------------------------------------------------------------------*
  565. quit020     jsr     cleanup
  566.             rts                             ; return to caller
  567.  
  568. *******************************************************************************
  569. *                                                                             * 
  570. *       parse                                                                 *
  571. *                                                                             *
  572. *       This routine parses the command line setting flags and keyvalues in   *
  573. *       our work area indicating what options were given when we were invoked.*
  574. *                                                                             *
  575. *       Input Registers:                                                      *
  576. *           a4 - keymenu work area (kmw)                                      *
  577. *                                                                             *
  578. *       Output Registers:                                                     *
  579. *           d0 - return code (0=parsing successful)                           *
  580. *                                                                             *
  581. *******************************************************************************
  582. parse       movem.l parseregs,-(sp)         ; save registers
  583.             clr.l   d2                      ; clear length register
  584.             move.w  kmw_cmd_length(kmw),d2  ; get runtime command length
  585.             subq.w  #1,d2                   ; reduce by 1 for dbra instr  
  586.             beq     parseexit               ; no command to parse, branch
  587.             move.l  kmw_cmd(kmw),a2         ; get runtime command pointer
  588. *-----------------------------------------------------------------------------*
  589. *           Upshift the entire runtime command                                *
  590. *-----------------------------------------------------------------------------*
  591. parse010    move.b  (a2,d2.w),d0            ; get character
  592.             cmp.b   #'a',d0                 ; within lowercase range ?
  593.             blt     parse012                ; no, branch
  594.             cmp.b   #'z',d0
  595.             bgt     parse012
  596.             and.b   #$5f,d0                 ; upshift the character
  597. parse012    move.b  d0,(a2,d2.w)            ; put it back
  598.             dbra    d2,parse010             ; loop through entire command
  599.             clr.l   d2                      ; clear index register
  600. *-----------------------------------------------------------------------------*
  601. *           Scan runtime command searching for valid option specifiers        *
  602. *-----------------------------------------------------------------------------*
  603. parse015    cmp.b   #'-',(a2,d2.w)          ; option specifier ?
  604.             bne     parse065                ; no, branch
  605.             addq.w  #1,d2                   ; bump index
  606.             cmp.b   #'A',(a2,d2.w)          ; change activation key ?
  607.             bne     parse020                ; no, branch
  608.             lea     kmw_AKey(kmw),a3        ; yes, load result area address
  609.             bra     parsekey                ; go get new keyvalue
  610.  
  611. parse020    cmp.b   #'E',(a2,d2.w)          ; change escape key ?
  612.             bne     parse025                ; no, branch
  613.             lea     kmw_DKey(kmw),a3        ; yes, load result area address
  614.             bra     parsekey                ; go get new keyvalue
  615.  
  616. parse025    cmp.b   #'S',(a2,d2.w)          ; change select key ?
  617.             bne     parse030                ; no, branch
  618.             lea     kmw_SKey(kmw),a3        ; yes, load result area address
  619.             bra     parsekey                ; go get new keyvalue
  620.  
  621. parse030    cmp.b   #'U',(a2,d2.w)          ; change up key ?
  622.             bne     parse035                ; no, branch
  623.             lea     kmw_UpKey(kmw),a3       ; yes, load result area address
  624.             bra     parsekey                ; go get new keyvalue
  625.  
  626. parse035    cmp.b   #'D',(a2,d2.w)          ; change down key ?
  627.             bne     parse040                ; no, branch
  628.             lea     kmw_DownKey(kmw),a3     ; yes, load result area address
  629.             bra     parsekey                ; go get new keyvalue
  630.  
  631. parse040    cmp.b   #'L',(a2,d2.w)          ; change left key ?
  632.             bne     parse045                ; no, branch
  633.             lea     kmw_LeftKey(kmw),a3     ; yes, load result area address
  634.             bra     parsekey                ; go get new keyvalue
  635.  
  636. parse045    cmp.b   #'R',(a2,d2.w)          ; change right key ?
  637.             bne     parse050                ; no, branch
  638.             lea     kmw_RightKey(kmw),a3    ; yes, load result area address
  639. *-----------------------------------------------------------------------------*
  640. *           A keyvalue specifier has been found, check its validity and       *
  641. *           if valid save it for use later. If invalid, issue a message       *
  642. *           and quit.                                                         *
  643. *-----------------------------------------------------------------------------*
  644. parsekey    clr.l   d4                      ; indicate hex numbers
  645.             jsr     parsevalue              ; go parse the value
  646.             bne     parse_keyerror          ; bad value, branch
  647.             cmp.w   #keynamesmax,d0         ; is value within range ?
  648.             bgt     parse_keyerror          ; no, branch
  649.             lea     keynames(pc),a1
  650.             asl.w   #1,d0
  651.             cmp.w   #-1,(a1,d0.w)           ; is this a valid keyvalue ?
  652.             beq     parse_keyerror          ; no, branch
  653.             asr.w   #1,d0
  654.             move.l  d3,d2                   ; adjust index
  655.             move.b  d0,(a3)                 ; save keyvalue
  656.             bra     parse015                ; go check for end of command
  657.  
  658. parse050    cmp.b   #'T',(a2,d2.w)          ; toggle rmbtrap option ?
  659.             bne     parse054                ; no, branch
  660.             bset.b  #FLAGB_trap,kmw_flags(kmw) ; set indicator
  661. parse052    addq.w  #1,d2                   ; bump index
  662.             bra     parse015                ; loop for next character
  663.             
  664. parse054    cmp.b   #'B',(a2,d2.w)          ; toggle blank pointer option ?
  665.             bne     parse055                ; no, branch
  666.             bset.b  #FLAGB_blankp,kmw_flags(kmw) ; set indicator
  667.             bra     parse052                ; bump index & check next character
  668.  
  669. parse055    cmp.b   #'I',(a2,d2.w)          ; configuration info wanted ?
  670.             bne     parse057                ; no, branch
  671.             bset.b  #FLAGB_info,kmw_flags(kmw) ; set indicator
  672.             bra     parse052
  673.  
  674. parse057    cmp.b   #'Q',(a2,d2.w)          ; qualifier key(s) ?
  675.             bne     parse060                ; no, branch
  676.             moveq.l #1,d4                   ; indicate decimal number
  677.             jsr     parsevalue              ; go parse the value
  678.             bne     parse_qualerror         ; bad value, branch
  679.             cmp.w   #255,d0                 ; within range ?
  680.             bgt     parse_qualerror         ; no, branch
  681.             move.b  d0,kmw_Qual(kmw)        ; save qualifier
  682.             bset.b  #FLAGB_Qual,kmw_flags(kmw) ; indicate option specified
  683.             move.l  d3,d2                   ; adjust index
  684.             bra     parse015
  685.  
  686. parse060    cmp.b   #'P',(a2,d2.w)          ; handler priority option ?
  687.             bne     parse_optionerror       ; no, bad option specified, branch
  688.             moveq.l #1,d4                   ; indicate decimal number
  689.             jsr     parsevalue              ; go parse the value
  690.             bne     parse_prierror          ; bad value, branch
  691.             cmp.w   #255,d0                 ; is it within range ?
  692.             bgt     parse_prierror          ; no, branch
  693.             move.l  d3,d2                   ; adjust index
  694.             move.b  d0,kmw_handlerpri(kmw)  ; save priority
  695.             move.w  d0,-(sp)                ; pass pri value
  696.             lea     primsg(pc),a0           ; get format string address
  697.             jsr     printf                  ; go print change message
  698.             addq.l  #2,sp                   ; adjust stack pointer
  699.             bra     parse015
  700.             
  701. *-----------------------------------------------------------------------------*
  702. *           Print 'HELP' information ?                                        *
  703. *-----------------------------------------------------------------------------*
  704. parse065    cmp.b   #'?',(a2,d2.w)          ; help wanted ?
  705.             bne     parse070                ; no, branch
  706.             lea     help1(pc),a0            ; address of message
  707.             jsr     printf                  ; go write it
  708.             lea     help2(pc),a0            ; address of message
  709.             jsr     printf                  ; go write it
  710.             lea     help3(pc),a0            ; address of message
  711.             jsr     printf                  ; go write it
  712.             lea     help4(pc),a0            ; address of message
  713.             jsr     printf                  ; go write it
  714.             lea     help4a(pc),a0           ; address of message
  715.             jsr     printf                  ; go write it
  716.             lea     help5(pc),a0            ; address of message
  717.             jsr     printf                  ; go write it
  718.             lea     help6(pc),a0            ; address of message
  719.             jsr     printf                  ; go write it
  720.             lea     help6a(pc),a0           ; address of message
  721.             jsr     printf                  ; go write it
  722.             lea     help7(pc),a0            ; address of message
  723.             pea     akey(pc)                ; text describing key
  724.             jsr     printf                  ; go write it
  725.             addq.l  #4,sp                   ; adjust stack pointer
  726.             lea     help8(pc),a0            ; address of message
  727.             pea     dkey(pc)                ; text describing key
  728.             jsr     printf                  ; go write it
  729.             addq.l  #4,sp                   ; adjust stack pointer
  730.             lea     help9(pc),a0            ; address of message
  731.             pea     skey(pc)                ; text describing key
  732.             jsr     printf                  ; go write it
  733.             addq.l  #4,sp                   ; adjust stack pointer
  734.             lea     help10(pc),a0           ; address of message
  735.             pea     leftkey(pc)             ; text describing key
  736.             jsr     printf                  ; go write it
  737.             addq.l  #4,sp                   ; adjust stack pointer
  738.             lea     help11(pc),a0           ; address of message
  739.             pea     rightkey(pc)            ; text describing key
  740.             jsr     printf                  ; go write it
  741.             addq.l  #4,sp                   ; adjust stack pointer
  742.             lea     help12(pc),a0           ; address of message
  743.             pea     upkey(pc)               ; text describing key
  744.             jsr     printf                  ; go write it
  745.             addq.l  #4,sp                   ; adjust stack pointer
  746.             lea     help13(pc),a0           ; address of message
  747.             pea     downkey(pc)             ; text describing key
  748.             jsr     printf                  ; go write it
  749.             addq.l  #4,sp                   ; adjust stack pointer
  750.             bra     parse_error             ; get out
  751. *-----------------------------------------------------------------------------*
  752. *           'QUIT'ting KeyMenu                                                *
  753. *-----------------------------------------------------------------------------*
  754. parse070    lea     quitword(pc),a0
  755.             lea     (a2,d2.w),a1
  756.             move.w  #quitwordl-1,d0
  757. parse072    cmp.b   (a0)+,(a1)+             ; 'QUIT' ?
  758.             bne     parse075                ; no, branch
  759.             dbra    d0,parse072             ; loop control
  760.             bset.b  #FLAGB_quit,kmw_flags(kmw) ; set indicator
  761.             add.w   #quitwordl,d2           ; bump index
  762.             bra     parse015                ; loop for next option
  763. *-----------------------------------------------------------------------------*
  764. *           White space or end of command ?                                   *
  765. *-----------------------------------------------------------------------------*
  766. parse075    cmp.b   #' ',(a2,d2.w)          ; white space ?
  767.             bne     parse080                ; no, branch
  768.             addq.w  #1,d2                   ; yes, bump index
  769.             bra     parse015                ; loop for next character
  770.  
  771. parse080    cmp.b   #LF,(a2,d2.w)           ; are we at the end of the command ?
  772.             bne     parse_optionerror       ; no, branch
  773.             bra     parseok                 ; yes, branch
  774. *-----------------------------------------------------------------------------*
  775. *           Print 'Invalid key value specified' message                       *
  776. *-----------------------------------------------------------------------------*
  777. parse_keyerror
  778.             jsr     showerror               ; go list the command and show where
  779.                                             ; the error occurred
  780.             lea     keyerror(pc),a0         ; get address of message text
  781.             jsr     printf                  ; go write it
  782.             bra     parse_error             ; take error exit
  783. *-----------------------------------------------------------------------------*
  784. *           Print 'Invalid handler priority specified' message                *
  785. *-----------------------------------------------------------------------------*
  786. parse_prierror
  787.             jsr     showerror               ; go list the command and show where
  788.                                             ; the error occurred
  789.             lea     prierror(pc),a0         ; get address of message text
  790.             jsr     printf                  ; go write it
  791.             bra     parse_error             ; take error exit
  792. *-----------------------------------------------------------------------------*
  793. *           Print 'Invalid qualifier(s) specified' message                    *
  794. *-----------------------------------------------------------------------------*
  795. parse_qualerror
  796.             jsr     showerror               ; go list the command and show where
  797.                                             ; the error occurred
  798.             lea     qualerror(pc),a0        ; get address of message text
  799.             jsr     printf                  ; go write it
  800.             bra     parse_error             ; take error exit
  801. *-----------------------------------------------------------------------------*
  802. *           Print 'Invalid/Unknown option specified' message                  *
  803. *-----------------------------------------------------------------------------*
  804. parse_optionerror
  805.             jsr     showerror               ; go list the command and show where
  806.                                             ; the error occurred
  807.             lea     opterror(pc),a0         ; get address of message text
  808.             jsr     printf                  ; go write it
  809. *-----------------------------------------------------------------------------*
  810. *           Some kind of parsing error occured, set return code               *
  811. *-----------------------------------------------------------------------------*
  812. parse_error moveq.l #1,d0
  813.             bra     parseexit
  814. *-----------------------------------------------------------------------------*
  815. *           parsed ok - set return code                                       *
  816. *-----------------------------------------------------------------------------*
  817. parseok     moveq.l #0,d0
  818. *-----------------------------------------------------------------------------*
  819. *           Common return point                                               *
  820. *-----------------------------------------------------------------------------*
  821. parseexit   movem.l (sp)+,parseregs         ; restore registers
  822.             rts                             ; return to caller
  823. parseregs   reg     d1-d4/a0-a3
  824.  
  825.  
  826. *******************************************************************************
  827. *                                                                             * 
  828. *       parsevalue                                                            *
  829. *                                                                             *
  830. *       This routine parses ascii values and converts them to binary.         *
  831. *                                                                             *
  832. *       Input Registers:                                                      *
  833. *           a4 - keymenu work area (kmw)                                      *
  834. *           d2 - displacement into command where option containing value      *
  835. *                starts.                                                      *
  836. *           d4 - 0 = ascii numbers are in hex, 1 = ascii numbers are decimal  *
  837. *                                                                             *
  838. *       Output Registers:                                                     *
  839. *           d0 - binary value                                                 *
  840. *           d4 - 0 = parsed ok, 1 = parse error                               *
  841. *                                                                             *
  842. *******************************************************************************
  843. parsevalue  addq.w  #1,d2                   ; bump index
  844.             move.l  d2,d3                   ; use temporary index
  845.             clr.l   d0                      ; clear accumulator
  846.             clr.l   d1                      ; clear work register
  847. parseval010 move.b  (a2,d3.w),d1
  848.             cmp.b   #'0',d1                 ; within decimal range ?
  849.             blt     parseval015             ; no, branch
  850.             cmp.b   #'9',d1
  851.             bgt     parseval015            
  852.             sub.b   #'0',d1                 ; make binary
  853.             bra     parseval020
  854. parseval015 tst.l   d4                      ; hex number ?
  855.             bne     parseval025             ; no, branch
  856.             cmp.b   #'A',d1                 ; within hex alpha range ?
  857.             blt     parseval025             ; no, branch
  858.             cmp.b   #'F',d1
  859.             bgt     parseval025
  860.             sub.b   #'A'-10,d1              ; make binary
  861. parseval020 tst.l   d4                      ; hex number ?
  862.             beq     parseval023             ; yes, branch
  863.             mulu    #10,d0                  ; multiply accumulator by 10
  864.             bra     parseval024
  865. parseval023
  866.             asl.w   #4,d0                   ; multiply accumulator by 16
  867. parseval024
  868.             add.w   d1,d0                   ; add current digit
  869.             addq.w  #1,d3                   ; bump accumulator
  870.             bra     parseval010             ; loop for next char
  871. parseval025 cmp.b   #' ',d1                 ; end of value ?
  872.             beq     parseval030             ; yes, branch
  873.             cmp.b   #LF,d1                  ; end of command ?
  874.             beq     parseval030             ; yes, branch
  875.             bra     parse_valerror          ; no, error, branch
  876. parseval030 cmp.w   d2,d3                   ; was anything parsed ?
  877.             bne     parse_valok             ; no, branch
  878. parse_valerror
  879.             moveq.l #1,d4                   ; indicate error
  880.             bra     parse_valend            ; go to common return
  881. parse_valok clr.l   d4                      ; indicate value ok
  882. parse_valend
  883.             rts                             ; return to caller
  884.  
  885. *******************************************************************************
  886. *                                                                             * 
  887. *       showerror                                                             *
  888. *                                                                             *
  889. *       This routine displays the runtime command with a caret symbol         *
  890. *       underneath the portion of the command that caused the parsing error.  *
  891. *                                                                             *
  892. *       Input Registers:                                                      *
  893. *           a4 - keymenu work area (kmw)                                      *
  894. *           d2 - displacement into command where caret symbol should go       *
  895. *                                                                             *
  896. *       Output Registers:                                                     *
  897. *           none                                                              *
  898. *                                                                             *
  899. *******************************************************************************
  900. showerror   movem.l showerrorregs,-(sp)     ; save registers
  901.             move.l  kmw_cmd(kmw),a0         ; message text pointer
  902.             clr.l   d0
  903.             move.w  kmw_cmd_length(kmw),d0  ; message text length
  904.             jsr     putmessage              ; go write the command text
  905.             clr.l   d3                      ; clear counter
  906.             moveq.l #1,d0                   ; set length of text to write
  907.             lea     kmw_buffer(kmw),a0      ; get address of buffer
  908.             move.b  #' ',(a0)               ; put blank in buffer
  909. showerr010  cmp.w   d2,d3                   ; have we reached the displacement ?
  910.             bge     showerr015              ; yes, branch
  911.             jsr     putmessage              ; go write a blank
  912.             addq.w  #1,d3                   ; bump counter
  913.             bra     showerr010              ; loop
  914. showerr015  move.b  #'^',(a0)               ; put ^ in buffer
  915.             jsr     putmessage              ; go write it
  916.             move.b  #LF,(a0)                ; put linefeed in buffer
  917.             jsr     putmessage              ; go write it
  918.             movem.l (sp)+,showerrorregs     ; restore registers
  919.             rts
  920. showerrorregs reg d3
  921.  
  922. *******************************************************************************
  923. *                                                                             * 
  924. *       printf                                                                *
  925. *                                                                             *
  926. *       This routine is called to print a formatted message substituting data *
  927. *       into the message from parameters (passed on the stack) using 'C'-like *
  928. *       formatting characters. The calling routine is responsible for placing *
  929. *       the datastream parameters on the stack and then adjusting the stack   *
  930. *       after execution of this routine. It is assumed that the parameters    *
  931. *       are located 4 bytes beyond the current stack pointer upon entry to    *
  932. *       this routine.                                                         *
  933. *                                                                             *
  934. *       Input Registers:                                                      *
  935. *           a0 - address of format string                                     *
  936. *           a3 - address of current position in buffer                        *
  937. *           a4 - workarea address                                             *
  938. *                                                                             *
  939. *       Output Registers:                                                     *
  940. *           none.                                                             *
  941. *                                                                             *
  942. *******************************************************************************
  943. printf      lea     4(sp),a1                ; get datastream address
  944.             movem.l printfregs,-(sp)        ; save registers
  945.             lea     putchar(pc),a2          ; point to routine to build buffer
  946.             lea     kmw_buffer(kmw),a3      ; point to buffer
  947.             Call    RawDoFmt                ; go format the buffer
  948.             lea     kmw_buffer(kmw),a0      ; point to buffer
  949.             move.l  a0,a1                   ; save buffer start
  950.             move.l  #kmw_bsize-1,d0         ; get maximum size of buffer
  951. printf010   move.b  (a1),(a1)+              ; scan buffer for end
  952.             dbeq    d0,printf010            ; loop til end
  953.             sub.l   a0,a1                   ; compute size of datastream
  954.             move.l  a1,d0                   ; setup for putmessage
  955.             jsr     putmessage              ; go write the message
  956.             movem.l (sp)+,printfregs        ; restore registers
  957.             rts
  958. printfregs  reg     a2/a3
  959.  
  960. *******************************************************************************
  961. *                                                                             * 
  962. *       putmessage                                                            *
  963. *                                                                             *
  964. *       This routine writes a message to the standard output device           *
  965. *                                                                             *
  966. *       Input Registers:                                                      *
  967. *           a0 - address of message text to write                             *
  968. *           a4 - keymenu work area (kmw)                                      *
  969. *           d0 - length of message text to write                              *
  970. *                                                                             *
  971. *       Output Registers:                                                     *
  972. *           none                                                              *
  973. *                                                                             *
  974. *******************************************************************************
  975. putmessage  movem.l putmessageregs,-(sp)    ; save registers
  976.             move.l  a0,d2                   ; message text
  977.             move.l  d0,d3                   ; text length
  978.             move.l  kmw_filehandle(kmw),d1  ; output file handle
  979.             Call    Write,kmw_dosbase(kmw)  ; go write the message
  980.             movem.l (sp)+,putmessageregs    ; restore registers
  981.             rts
  982. putmessageregs reg  d0-d3/a0
  983.  
  984. *******************************************************************************
  985. *                                                                             * 
  986. *       putchar                                                               *
  987. *                                                                             *
  988. *       This routine is called by the 'RawDoFmt' exec function to put each    *
  989. *       character of a formatted datastring into an output buffer. The        *
  990. *       printf routine is used to pass the address of this routine to exec.   *
  991. *                                                                             *
  992. *       Input Registers:                                                      *
  993. *           d0 - character to be put into a buffer                            *
  994. *           a3 - address of current position in buffer                        *
  995. *                                                                             *
  996. *       Output Registers:                                                     *
  997. *           a3 - incremented to next position in buffer                       *
  998. *                                                                             *
  999. *******************************************************************************
  1000. putchar     move.b  d0,(a3)+                ; put character into buffer
  1001.             rts                             ; return to caller
  1002.  
  1003. *******************************************************************************
  1004. *                                                                             * 
  1005. *       create                                                                *
  1006. *                                                                             *
  1007. *       This routine loads the keymenu-handler code and adds it as an input   *
  1008. *       handler to the input.device, if possible                              *
  1009. *                                                                             *
  1010. *       Input Registers:                                                      *
  1011. *           a4 - workarea address                                             *
  1012. *                                                                             *
  1013. *       Output Registers:                                                     *
  1014. *           d0 - handler global area/null if unable to load/add handler       *
  1015. *                                                                             *
  1016. *******************************************************************************
  1017. create      btst.b  #FLAGB_quit,kmw_flags(kmw) ; was 'quit' specified ?
  1018.             bne     create_err              ; yes, keymenu not running, branch
  1019. *-----------------------------------------------------------------------------*
  1020. *           Allocate handler global area                                      *
  1021. *-----------------------------------------------------------------------------*
  1022.             move.l  #gb_size,d0             ; set size of area to allocate
  1023.             move.l  #MEMF_CLEAR+MEMF_PUBLIC,d1; indicate type of memory
  1024.             Call    AllocMem                ; go get it
  1025.             move.l  d0,gbl                  ; setup our global area register
  1026.             bne     create015               ; if allocate was successful, branch
  1027. create010   lea     nomem(pc),a0            ; get error message address
  1028.             jsr     printf                  ; go write error message
  1029.             bra     create_err              ; go cleanup
  1030. *-----------------------------------------------------------------------------*
  1031. *           Initialize global area                                            *
  1032. *-----------------------------------------------------------------------------*
  1033. create015   move.b  #ralt_down,gb_AKey(gbl)
  1034.             move.b  #esc_down,gb_DKey(gbl)
  1035.             move.b  #return_down,gb_SKey(gbl)
  1036.             move.b  #CURSORUP,gb_UpKey(gbl)
  1037.             move.b  #CURSORDOWN,gb_DownKey(gbl)
  1038.             move.b  #CURSORLEFT,gb_LeftKey(gbl)
  1039.             move.b  #CURSORRIGHT,gb_RightKey(gbl)
  1040.             move.b  #IEQUALIFIER_RSHIFT,gb_Qual(gbl)
  1041.             move.l  gbl,gb_handler+IS_DATA(gbl)
  1042.             moveq.l #blank_pointer_size,d0  ; set size of area to allocate
  1043.             move.l  #MEMF_CLEAR+MEMF_CHIP,d1 ; indicate type of memory
  1044.             Call    AllocMem                ; go get it
  1045.             move.l  d0,gb_blank_ptr(gbl)    ; save pointer data address
  1046.             bne     create020               ; if allocate was successful, branch
  1047. create018   jsr     cleanup                 ; go release everything
  1048.             bra     create010
  1049. *-----------------------------------------------------------------------------*
  1050. *           begin installing keymenu handler                                  *
  1051. *-----------------------------------------------------------------------------*
  1052. create020   lea     install(pc),a0          ; get install message address
  1053.             jsr     printf                  ; go write install message
  1054.             move.b  #PA_SIGNAL,gb_Port+MP_FLAGS(gbl) ; setup message port
  1055.             move.b  #0,gb_Port+LN_PRI(gbl)
  1056.             move.b  #NT_MSGPORT,gb_Port+LN_TYPE(gbl)
  1057.             move.l  #kmportl,d0             ; size of port name
  1058.             move.l  #MEMF_PUBLIC,d1         ; set type of memory to get
  1059.             Call    AllocMem                ; go allocate it
  1060.             move.l  d0,gb_Port+LN_NAME(gbl) ; save its address
  1061.             beq     create018               ; branch if allocation failed
  1062.             move.l  d0,a0                   ; get destination address
  1063.             lea     kmport(pc),a1           ; get address of port name
  1064.             move.w  #kmportl-1,d1           ; get length of area to move
  1065. create030   move.b  (a1,d1.w),(a0,d1.w)     ; copy port name
  1066.             dbra    d1,create030            ; loop through port name
  1067.             lea     gb_Port+MP_MSGLIST(gbl),a0 ; get address of message list
  1068.             NEWLIST a0                      ; initialize it
  1069. *-----------------------------------------------------------------------------*
  1070. *           Open Intuition Library                                            *
  1071. *-----------------------------------------------------------------------------*
  1072.             lea     intuitionlib(pc),a1     ; point to library name
  1073.             moveq.l #0,d0                   ; we don't care what version
  1074.             Call    OpenLibrary             ; go open the library
  1075.             move.l  d0,gb_IBase(gbl)        ; save lib base for handler's use
  1076.             bne     create040               ; openlibrary successful, branch
  1077.             jsr     cleanup                 ; go release everything
  1078.             lea     interr(pc),a0           ; get error message address
  1079.             jsr     printf                  ; go write error message
  1080.             bra     create_err              ; take error exit
  1081. *-----------------------------------------------------------------------------*
  1082. *           Load 'Keymenu-handler' segment                                    *
  1083. *-----------------------------------------------------------------------------*
  1084. create040   lea     handlerpath(pc),a0      ; use library path first
  1085.             move.l  a0,d1
  1086.             Call    LoadSeg,kmw_dosbase(kmw) ; try to load the segment
  1087.             move.l  d0,gb_Segment(gbl)      ; save segment pointer
  1088.             bne     create050               ; if loaded, branch
  1089.             lea     handlername(pc),a0      ; use current directory
  1090.             move.l  a0,d1
  1091.             Call    LoadSeg,kmw_dosbase(kmw) ; try load again
  1092.             move.l  d0,gb_Segment(gbl)      ; save segment pointer
  1093.             bne     create050               ; if loaded, branch
  1094.             lea     loaderr(pc),a0          ; get format string address
  1095.             pea     handlername(pc)         ; setup datastream
  1096.             jsr     printf                  ; go print the message
  1097.             addq.l  #4,sp                   ; adjust stack pointer
  1098.             jsr     cleanup                 ; go release everything
  1099.             bra     create_err              ; take error exit
  1100. *-----------------------------------------------------------------------------*
  1101. *           Add message port so that we can get access later.                 *
  1102. *-----------------------------------------------------------------------------*
  1103. create050   move.l  gbl,a1                  ; get port address
  1104.             Call    AddPort                 ; add the port to the system
  1105.             sub.l   a1,a1                   ; setup to find our task
  1106.             Call    FindTask                ; go get our task pointer
  1107.             move.l  d0,gb_task(gbl)         ; save our task pointer
  1108.             moveq.l  #-1,d0                 ; setup to allocate a signal
  1109.             Call    AllocSignal             ; go allocate one
  1110.             move.b  d0,gb_tasksignum(gbl)   ; save signal number
  1111.             move.l  gb_Port+LN_NAME(gbl),d1
  1112.             moveq.l #procpri,d2             ; process priority
  1113.             move.l  gb_Segment(gbl),d3      ; process code segment
  1114.             move.l  #procstack,d4           ; process stack size
  1115.             Call    CreateProc,kmw_dosbase(kmw) ; go create the process
  1116.             clr.l   d0
  1117.             clr.l   d1
  1118.             move.b  gb_tasksignum(gbl),d1
  1119.             bset.l  d1,d0                   ; create wait mask
  1120.             Call    Wait                    ; wait for handler to signal us
  1121. *-----------------------------------------------------------------------------*
  1122. *           Add handler to input.device                                       *
  1123. *-----------------------------------------------------------------------------*
  1124.             clr.l   d0
  1125.             move.b  gb_tasksignum(gbl),d0   ; get allocated signal number
  1126.             Call    FreeSignal              ; go free the signal number
  1127.             move.b  #handlerpri,gb_handler+LN_PRI(gbl)
  1128.             moveq.l #IND_ADDHANDLER,d0      ; indicate we want to add handler
  1129.             jsr     tellinputdevice         ; go tell it to the input.device
  1130.             bne     create060               ; if added, branch
  1131.             bset.b  #FLAGB_quit,kmw_flags(kmw) ; indicate that we want out
  1132.             lea     handlererr(pc),a0       ; get error message address
  1133.             jsr     printf                  ; go tell user
  1134.             bra     create_ok               ; take normal exit
  1135. create060   lea     handlerok(pc),a0        ; get format string address
  1136.             pea     kmport(pc)              ; put portname address on stack
  1137.             jsr     printf                  ; go print 'ok' message
  1138.             addq.l  #4,sp                   ; adjust stack pointer
  1139.             
  1140.             
  1141. create_ok   move.l  gbl,d0                  ; pass back address of global area
  1142.             bra     createexit
  1143. create_err  move.l  #0,d0                   ; indicate no handler
  1144.  
  1145. createexit  rts                             ; return to caller
  1146.  
  1147. *******************************************************************************
  1148. *                                                                             * 
  1149. *       tellinputdevice                                                       *
  1150. *                                                                             *
  1151. *       This routine is called to open the input.device, send a command to    *
  1152. *       it and then close it.                                                 *
  1153. *                                                                             *
  1154. *       Input Registers:                                                      *
  1155. *           d0 - function to be sent to the input.device                      *
  1156. *           a4 - keymenu workarea address (kmw)                               *
  1157. *           a5 - handler global area                                          *
  1158. *                                                                             *
  1159. *                                                                             *
  1160. *       Output Registers:                                                     *
  1161. *           d0 - return code (non-zero=success)                               *
  1162. *                                                                             *
  1163. *******************************************************************************
  1164. tellinputdevice
  1165.             movem.l tidregs,-(sp)           ; save registers
  1166.             move.l  d0,d3                   ; save function for use later
  1167.             moveq.l #-1,d2                  ; default to good return
  1168. *-----------------------------------------------------------------------------*
  1169. *           Create a port to communicate with the input.device                *
  1170. *-----------------------------------------------------------------------------*
  1171.             moveq.l  #-1,d0                 ; setup to allocate a signal
  1172.             Call    AllocSignal             ; go allocate one
  1173.             move.l  d0,d6                   ; save signal number for later use
  1174.             move.l  #MP_SIZE,d0             ; size of port
  1175.             move.l  #MEMF_PUBLIC+MEMF_CLEAR,d1 ; set type of memory to get
  1176.             Call    AllocMem                ; go allocate a message port
  1177.             move.l  d0,d4                   ; save its address
  1178.             bne     tid010                  ; if allocated ok, branch
  1179.             clr.l   d2                      ; set bad return code
  1180.             bra     tid070                  ; go free resources 
  1181. tid010      move.l  d4,a2
  1182.             move.b  #NT_MSGPORT,LN_TYPE(a2) ; initialize the port
  1183.             move.b  #PA_SIGNAL,MP_FLAGS(a2)
  1184.             move.b  gb_tasksignum(gbl),MP_SIGBIT(a2)
  1185.             sub.l   a1,a1
  1186.             Call    FindTask                ; go find our task
  1187.             move.l  d0,MP_SIGTASK(a2)
  1188.             lea     MP_MSGLIST(a2),a0
  1189.             NEWLIST a0
  1190. *-----------------------------------------------------------------------------*
  1191. *           Create a standard IO block                                        *
  1192. *-----------------------------------------------------------------------------*
  1193.             move.l  #IOSTD_SIZE,d0          ; size of std request
  1194.             move.l  #MEMF_CLEAR+MEMF_PUBLIC,d1 ; set type of memory
  1195.             Call    AllocMem                ; go allocate it
  1196.             move.l  d0,d5                   ; save its address
  1197.             bne     tid020                  ; branch if allocated ok
  1198.             clr.l   d2                      ; set bad return code
  1199.             bra     tid060                  ; go free resources
  1200. tid020      move.l  d5,a3
  1201.             move.b  #NT_MESSAGE,LN_TYPE(a3)
  1202.             move.l  d4,MN_REPLYPORT(a3)
  1203.             move.w  #IOSTD_SIZE,MN_LENGTH(a3)
  1204. *-----------------------------------------------------------------------------*
  1205. *           Open input device                                                 *
  1206. *-----------------------------------------------------------------------------*
  1207.             lea     inputdevice(pc),a0      ; point to device name
  1208.             clr.l   d0                      ; unit 0
  1209.             move.l  d5,a1                   ; inputblock
  1210.             clr.l   d1                      ; flags
  1211.             Call    OpenDevice              ; go open the input device
  1212.             tst.l   d0                      ; open ok ?
  1213.             beq     tid030                  ; yes, branch
  1214.             clr.l   d2                      ; set bad return code
  1215.             bra     tid050                  ; go free resources
  1216. *-----------------------------------------------------------------------------*
  1217. *           Issue request to input device                                     *
  1218. *-----------------------------------------------------------------------------*
  1219. tid030      move.w  d3,IO_COMMAND(a3)       ; set function in inputblock
  1220.             lea     gb_handler(gbl),a0      ; get address of handler data
  1221.             move.l  a0,IO_DATA(a3)          ; put it in the inputblock
  1222.             move.l  a3,a1
  1223.             Call    DoIO                    ; issue the I/O
  1224.             tst.l   d0                      ; was I/O successful ?
  1225.             beq     tid040                  ; yes, branch
  1226.             clr.l   d2                      ; no, set bad return code
  1227. *-----------------------------------------------------------------------------*
  1228. *           Close the input device                                            *
  1229. *-----------------------------------------------------------------------------*
  1230. tid040      move.l  d5,a1
  1231.             Call    CloseDevice             ; close the input device
  1232. *-----------------------------------------------------------------------------*
  1233. *           Delete the input block                                            *
  1234. *-----------------------------------------------------------------------------*
  1235. tid050      move.l  #IOSTD_SIZE,d0          ; get size of standard request
  1236.             move.l  d5,a1                   ; get pointer to block
  1237.             Call    FreeMem                 ; go deallocate memory
  1238. *-----------------------------------------------------------------------------*
  1239. *           Delete the input port                                             *
  1240. *-----------------------------------------------------------------------------*
  1241. tid060      move.l  #MP_SIZE,d0             ; get size of port
  1242.             move.l  d4,a1                   ; get pointer to port
  1243.             Call    FreeMem                 ; go deallocate the port
  1244. *-----------------------------------------------------------------------------*
  1245. *           Free the signal associated with the port                          *
  1246. *-----------------------------------------------------------------------------*
  1247. tid070      clr.l   d0
  1248.             move.b  gb_tasksignum(gbl),d0
  1249.             Call    FreeSignal              ; go free the signal
  1250. *-----------------------------------------------------------------------------*
  1251. *           Set return code and exit                                          *
  1252. *-----------------------------------------------------------------------------*
  1253.             move.l  d2,d0
  1254.             movem.l (sp)+,tidregs           ; restore registers
  1255.             rts                             ; return to caller
  1256. tidregs     reg     a2-a3/d2-d5
  1257.  
  1258. *******************************************************************************
  1259. *                                                                             * 
  1260. *       cleanup                                                               *
  1261. *                                                                             *
  1262. *       This routine frees resources that have been allocated or acquired     *
  1263. *       during execution.                                                     *
  1264. *                                                                             *
  1265. *       Input Registers:                                                      *
  1266. *           a4 - keymenu work area (kmw)                                      *
  1267. *           a5 - keymenu handler global area                                  *
  1268. *                                                                             *
  1269. *       Output Registers:                                                     *
  1270. *           none                                                              *
  1271. *                                                                             *
  1272. *******************************************************************************
  1273. cleanup     
  1274. *-----------------------------------------------------------------------------*
  1275. *           Close Intuition Library                                           *
  1276. *-----------------------------------------------------------------------------*
  1277.             move.l  gb_IBase(gbl),d0        ; get intuition library base
  1278.             beq     cleanup070              ; branch if not open
  1279.             move.l  d0,a1
  1280.             Call    CloseLibrary            ; close it
  1281. *-----------------------------------------------------------------------------*
  1282. *           Deallocate port name area                                         *
  1283. *-----------------------------------------------------------------------------*
  1284. cleanup070  move.l  gb_Port+LN_NAME(gbl),d0 ; get port name area address
  1285.             beq     cleanup080              ; branch if no area
  1286.             move.l  d0,a1
  1287.             move.l  #kmportl,d0             ; get size of area
  1288.             Call    FreeMem                 ; go free it
  1289. *-----------------------------------------------------------------------------*
  1290. *           Deallocate blank pointer chip memory                              *
  1291. *-----------------------------------------------------------------------------*
  1292. cleanup080  move.l  gb_blank_ptr(gbl),d0    ; get blank pointer area address
  1293.             beq     cleanup090              ; branch if no area
  1294.             move.l  d0,a1
  1295.             move.l  #blank_pointer_size,d0  ; get size of area
  1296.             Call    FreeMem                 ; go free it
  1297. *-----------------------------------------------------------------------------*
  1298. *           Deallocate handler global area                                    *
  1299. *-----------------------------------------------------------------------------*
  1300. cleanup090  move.l  gbl,a1                  ; get global area address
  1301.             move.l  #gb_size,d0             ; get size of work area
  1302.             Call    FreeMem                 ; go free it
  1303.             rts
  1304.  
  1305. *******************************************************************************
  1306. *                                                                             * 
  1307. *           Miscellaneous constants                                           *
  1308. *                                                                             *
  1309. *******************************************************************************
  1310. doslib      DOSNAME                         ; library names
  1311.  
  1312. intuitionlib INTUITIONNAME
  1313.  
  1314. inputdevice dc.b    'input.device',0
  1315.  
  1316.             portname kmport
  1317. kmportend
  1318.  
  1319. handlerpath dc.b    'L:'
  1320. handlername dc.b    'KeyMenu-Handler',0
  1321.  
  1322.  
  1323. install     dc.b    'Installing KeyMenu, ',0
  1324. remove      dc.b    'Removing KeyMenu, ',0
  1325. nomem       dc.b    'Unable to allocate work area, Aborted',LF,0
  1326. nomemend
  1327. interr      dc.b    'Unable to open Intuition library',LF,0
  1328. loaderr     dc.b    'Unable to find %s',LF,0
  1329. handlererr  dc.b    'Handler error',0
  1330. handlerok   dc.b    'ok. %s, PUBLIC DOMAIN.',LF,0
  1331. ok          dc.b    'ok',LF,0
  1332.  
  1333. help1       dc.b    'Usage: KeyMenu '
  1334. quitword    dc.b    'QUIT'
  1335. quitwordend
  1336.             dc.b    LF,0
  1337. help2       dc.b    '       KeyMenu [<options>]',LF,0
  1338. help3       dc.b    '    Where <options> is one or more of the following:',LF,0
  1339. help4       dc.b    "     -i  = info about KeyMenu's current settings",LF,0
  1340. help4a      dc.b    '     -b  = toggle Intuition pointer blanking',LF,0
  1341. help5       dc.b    '     -q# = key qualifier(s) in decimal',LF,0
  1342. help6       dc.b    '     -t  = toggle clear RMBTRAP flag option',LF,0
  1343. help6a      dc.b    '     -p# = input handler priority in decimal',LF,0 
  1344. help7       dc.b    '     -a# = %s',LF,0
  1345. help8       dc.b    '     -e# = %s',LF,0
  1346. help9       dc.b    '     -s# = %s',LF,0
  1347. help10      dc.b    '     -l# = %s',LF,0
  1348. help11      dc.b    '     -r# = %s',LF,0
  1349. help12      dc.b    '     -u# = %s',LF,0
  1350. help13      dc.b    '     -d# = %s',LF,0
  1351.  
  1352. akey        dc.b    'ACTIVATION key',0
  1353. dkey        dc.b    'ESCAPE key',0
  1354. skey        dc.b    'SELECT key',0
  1355. leftkey     dc.b    'LEFT key',0
  1356. rightkey    dc.b    'RIGHT key',0
  1357. upkey       dc.b    'UP key',0
  1358. downkey     dc.b    'DOWN key',0
  1359.  
  1360. keyerror    dc.b    'Invalid key value',LF,0
  1361. prierror    dc.b    'Invalid handler priority',LF,0
  1362. qualerror   dc.b    'Invalid qualifier(s)',LF,0
  1363. opterror    dc.b    'Invalid/unknown option',LF,0
  1364. changemsg   dc.b    '%s: %s (%x) changed to %s (%x)',LF,0
  1365. primsg      dc.b    'Input handler priority is %d',LF,0
  1366. nowoff      dc.b    'now '
  1367. off         dc.b    'OFF',0
  1368. nowon       dc.b    'now '
  1369. on          dc.b    'ON',0
  1370. info1       dc.b    '%s Configuration:',LF,0
  1371. info2       dc.b    '%14s is %s (%x)',LF,0
  1372. info3       dc.b    'Key qualifier(s):',0
  1373. info3a      dc.b    ' %s ',0
  1374. none        dc.b    ' None'
  1375. info3end    dc.b    LF,0
  1376. info4       dc.b    'Clear RMBTRAP option is %s',LF,0
  1377. info5       dc.b    'Blank Intuition Pointer option is %s',LF,0
  1378.  
  1379. *******************************************************************************
  1380. *                                                                             * 
  1381. *           Key Value Table                                                   *
  1382. *                                                                             *
  1383. *           Contains text descriptions of the various keys supported.         *
  1384. *           Entries are variable length null terminated strings. This table   *
  1385. *           is indexed by the keynames table. The order of the entries in     *
  1386. *           this table is not significant.                                    *
  1387. *                                                                             * 
  1388. *******************************************************************************
  1389. keyval                                      ; this label must be first
  1390. key00       dc.b    '`',0
  1391. key01       dc.b    '1',0
  1392. key02       dc.b    '2',0
  1393. key03       dc.b    '3',0
  1394. key04       dc.b    '4',0
  1395. key05       dc.b    '5',0
  1396. key06       dc.b    '6',0
  1397. key07       dc.b    '7',0
  1398. key08       dc.b    '8',0
  1399. key09       dc.b    '9',0
  1400. key0a       dc.b    '0',0
  1401. key0b       dc.b    '-',0
  1402. key0c       dc.b    '=',0
  1403. key0d       dc.b    '\',0
  1404. key0f       dc.b    'Numeric Pad 0',0
  1405. key10       dc.b    'Q',0
  1406. key11       dc.b    'W',0
  1407. key12       dc.b    'E',0
  1408. key13       dc.b    'R',0
  1409. key14       dc.b    'T',0
  1410. key15       dc.b    'Y',0
  1411. key16       dc.b    'U',0
  1412. key17       dc.b    'I',0
  1413. key18       dc.b    'O',0
  1414. key19       dc.b    'P',0
  1415. key1a       dc.b    '[',0
  1416. key1b       dc.b    ']',0
  1417. key1d       dc.b    'Numeric Pad 1',0
  1418. key1e       dc.b    'Numeric Pad 2',0
  1419. key1f       dc.b    'Numeric Pad 3',0
  1420. key20       dc.b    'A',0
  1421. key21       dc.b    'S',0
  1422. key22       dc.b    'D',0
  1423. key23       dc.b    'F',0
  1424. key24       dc.b    'G',0
  1425. key25       dc.b    'H',0
  1426. key26       dc.b    'J',0
  1427. key27       dc.b    'K',0
  1428. key28       dc.b    'L',0
  1429. key29       dc.b    ';',0
  1430. key2a       dc.b    "'",0
  1431. key2d       dc.b    'Numeric Pad 4',0
  1432. key2e       dc.b    'Numeric Pad 5',0
  1433. key2f       dc.b    'Numeric Pad 6',0
  1434. key31       dc.b    'Z',0
  1435. key32       dc.b    'X',0
  1436. key33       dc.b    'C',0
  1437. key34       dc.b    'V',0
  1438. key35       dc.b    'B',0
  1439. key36       dc.b    'N',0
  1440. key37       dc.b    'M',0
  1441. key38       dc.b    ',',0
  1442. key39       dc.b    '.',0
  1443. key3a       dc.b    '/',0
  1444. key3c       dc.b    'Numeric Pad .',0
  1445. key3d       dc.b    'Numeric Pad 7',0
  1446. key3e       dc.b    'Numeric Pad 8',0
  1447. key3f       dc.b    'Numeric Pad 9',0
  1448. key40       dc.b    'Space Bar',0
  1449. key41       dc.b    'Backspace',0
  1450. key42       dc.b    'Tab',0
  1451. key43       dc.b    'Numeric Pad Enter',0
  1452. key44       dc.b    'Return',0
  1453. key45       dc.b    'Escape',0
  1454. key46       dc.b    'Delete',0
  1455. key4a       dc.b    'Numeric Pad -',0
  1456. key4c       dc.b    'Cursor up',0
  1457. key4d       dc.b    'Cursor down',0
  1458. key4e       dc.b    'Cursor right',0
  1459. key4f       dc.b    'Cursor left',0
  1460. key50       dc.b    'F1',0
  1461. key51       dc.b    'F2',0
  1462. key52       dc.b    'F3',0
  1463. key53       dc.b    'F4',0
  1464. key54       dc.b    'F5',0
  1465. key55       dc.b    'F6',0
  1466. key56       dc.b    'F7',0
  1467. key57       dc.b    'F8',0
  1468. key58       dc.b    'F9',0
  1469. key59       dc.b    'F10',0
  1470. key5f       dc.b    'Help',0
  1471. key60       dc.b    'Left Shift',0
  1472. key61       dc.b    'Right Shift',0
  1473. key62       dc.b    'Caps Lock',0
  1474. key63       dc.b    'Control',0
  1475. key64       dc.b    'Left Alt',0
  1476. key65       dc.b    'Right Alt',0
  1477. key66       dc.b    'Left Amiga',0
  1478. key67       dc.b    'Right Amiga',0
  1479.  
  1480.  
  1481. *******************************************************************************
  1482. *                                                                             * 
  1483. *           Key Name Table                                                    *
  1484. *                                                                             *
  1485. *           Ordered by keycode. Each entry consists of a word displacement    *
  1486. *           into the keyval table. Entries for unsupported keycodes contain   *
  1487. *           a negative displacement.                                          *
  1488. *                                                                             *
  1489. *                                                                             * 
  1490. *******************************************************************************
  1491. keynames    dc.w    key00-keyval
  1492.             dc.w    key01-keyval
  1493.             dc.w    key02-keyval
  1494.             dc.w    key03-keyval
  1495.             dc.w    key04-keyval
  1496.             dc.w    key05-keyval
  1497.             dc.w    key06-keyval
  1498.             dc.w    key07-keyval
  1499.             dc.w    key08-keyval
  1500.             dc.w    key09-keyval
  1501.             dc.w    key0a-keyval
  1502.             dc.w    key0b-keyval
  1503.             dc.w    key0c-keyval
  1504.             dc.w    key0d-keyval
  1505.             dc.w    -1
  1506.             dc.w    key0f-keyval
  1507.             dc.w    key10-keyval
  1508.             dc.w    key11-keyval
  1509.             dc.w    key12-keyval
  1510.             dc.w    key13-keyval
  1511.             dc.w    key14-keyval
  1512.             dc.w    key15-keyval
  1513.             dc.w    key16-keyval
  1514.             dc.w    key17-keyval
  1515.             dc.w    key18-keyval
  1516.             dc.w    key19-keyval
  1517.             dc.w    key1a-keyval
  1518.             dc.w    key1b-keyval
  1519.             dc.w    -1
  1520.             dc.w    key1d-keyval
  1521.             dc.w    key1e-keyval
  1522.             dc.w    key1f-keyval
  1523.             dc.w    key20-keyval
  1524.             dc.w    key21-keyval
  1525.             dc.w    key22-keyval
  1526.             dc.w    key23-keyval
  1527.             dc.w    key24-keyval
  1528.             dc.w    key25-keyval
  1529.             dc.w    key26-keyval
  1530.             dc.w    key27-keyval
  1531.             dc.w    key28-keyval
  1532.             dc.w    key29-keyval
  1533.             dc.w    key2a-keyval
  1534.             dc.w    -1
  1535.             dc.w    -1
  1536.             dc.w    key2d-keyval
  1537.             dc.w    key2e-keyval
  1538.             dc.w    key2f-keyval
  1539.             dc.w    -1
  1540.             dc.w    key31-keyval
  1541.             dc.w    key32-keyval
  1542.             dc.w    key33-keyval
  1543.             dc.w    key34-keyval
  1544.             dc.w    key35-keyval
  1545.             dc.w    key36-keyval
  1546.             dc.w    key37-keyval
  1547.             dc.w    key38-keyval
  1548.             dc.w    key39-keyval
  1549.             dc.w    key3a-keyval
  1550.             dc.w    -1
  1551.             dc.w    key3c-keyval
  1552.             dc.w    key3d-keyval
  1553.             dc.w    key3e-keyval
  1554.             dc.w    key3f-keyval
  1555.             dc.w    key40-keyval
  1556.             dc.w    key41-keyval
  1557.             dc.w    key42-keyval
  1558.             dc.w    key43-keyval
  1559.             dc.w    key44-keyval
  1560.             dc.w    key45-keyval
  1561.             dc.w    key46-keyval
  1562.             dc.w    -1
  1563.             dc.w    -1
  1564.             dc.w    -1
  1565.             dc.w    key4a-keyval
  1566.             dc.w    -1
  1567.             dc.w    key4c-keyval
  1568.             dc.w    key4d-keyval
  1569.             dc.w    key4e-keyval
  1570.             dc.w    key4f-keyval
  1571.             dc.w    key50-keyval
  1572.             dc.w    key51-keyval
  1573.             dc.w    key52-keyval
  1574.             dc.w    key53-keyval
  1575.             dc.w    key54-keyval
  1576.             dc.w    key55-keyval
  1577.             dc.w    key56-keyval
  1578.             dc.w    key57-keyval
  1579.             dc.w    key58-keyval
  1580.             dc.w    key59-keyval
  1581.             dc.w    -1
  1582.             dc.w    -1
  1583.             dc.w    -1
  1584.             dc.w    -1
  1585.             dc.w    -1
  1586.             dc.w    key5f-keyval
  1587. qualnames   dc.w    key60-keyval
  1588.             dc.w    key61-keyval
  1589.             dc.w    key62-keyval
  1590.             dc.w    key63-keyval
  1591.             dc.w    key64-keyval
  1592.             dc.w    key65-keyval
  1593.             dc.w    key66-keyval
  1594. keynamesend dc.w    key67-keyval
  1595.  
  1596.             public  create
  1597.             end
  1598.