home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d528 / keymenu.lha / KeyMenu / src.lzh / KeyMenu.asm < prev    next >
Assembly Source File  |  1991-08-03  |  94KB  |  1,604 lines

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