home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 510.lha / KeyMenu_v1.04 / KeyMenu.asm < prev    next >
Encoding:
Assembly Source File  |  1991-05-07  |  92.2 KB  |  1,606 lines

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