home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI01.ARJ / ictari.01 / ASSEMBLY / NOLOCK / NOLOCK.ASM next >
Assembly Source File  |  1989-09-25  |  4KB  |  163 lines

  1. *****************************************************************
  2. *                                *
  3. *    NOLOCK                            *
  4. *                                *
  5. * After this program is executed, the CapsLock key will have    *
  6. * no effect, provided the keyboard translation table is set    *
  7. * only by calls to Keytbl() and Bioskeys().  You can still set    *
  8. * the tables by setting pointers into the vector whose address    *
  9. * is returned by Keytbl().                    *
  10. *                                *
  11. * Written for jas (Sozobon assembler).  Thanks to Abacus's    *
  12. * "Atari ST Internals" for insights.                *
  13. *                                *
  14. * Copyright (c) 1989, David Brooks, All Rights Reserved.  Use    *
  15. * and distribute freely.                    *
  16. *                                *
  17. *****************************************************************
  18. *
  19. *
  20. * Some constant definitions (trap codes mainly)
  21. *
  22.  
  23. GEMDOS        equ    1
  24. BIOS        equ    13
  25. XBIOS        equ    14
  26. Keytbl        equ    16
  27. Bioskeys    equ    24
  28. Setexec        equ    5
  29. Keep        equ    $31
  30.  
  31. XBIOSV        equ    46
  32. XBIOSVAD    equ    $b8
  33.  
  34. sbit        equ    13        * Supervisor status bit
  35.  
  36. Magicnum    equ    $44424e4c    * 'DBNL' must be just before trapad
  37. *
  38. * Program starts here.  It's all one text section, as we need to
  39. * intermix code and data.  The initialization is at the end, and
  40. * will be handed back to GEMDOS.
  41. *
  42.  
  43. start:        bra    setup
  44.  
  45. *
  46. * Static data:
  47. *
  48.  
  49. transp:        ds.l    1        * Will point to table ptr vector
  50. normp:        ds.l    1        * Default non-shift table
  51. shiftp:        ds.l    1        * Default shifted table
  52. trap14:        ds.l    1        * Replaced xbios vector
  53.  
  54. magic:        dc.l    Magicnum
  55.  
  56. *
  57. * Here's the xbios trap
  58. *
  59.  
  60. trapad:
  61.         lea    6(a7),a0    * Point to args if in super mode
  62.         btst    #sbit,(a7)
  63.         bne    checkcodes
  64.         dc.w    $4e68        * move.l  USP,a0 -- Point to args
  65.                     *  if in user mode
  66. checkcodes:
  67.         cmpi.w    #Bioskeys,(a0)
  68.         beq    dobioskeys
  69.         cmpi.w    #Keytbl,(a0)+
  70.         beq    dokeytbl
  71.  
  72.         move.l    trap14,a0    * Go to standard trap handler
  73.         jmp    (a0)
  74. *
  75. * One of these routines for Bioskeys or Keytbl
  76. *
  77. dobioskeys:
  78.         move.l    transp,a1    * No args, no return.  Just
  79.         move.l    normp,d0    *  set the table to norm, shift, norm
  80.         move.l    d0,(a1)+
  81.         move.l    shiftp,(a1)+
  82.         move.l    d0,(a1)
  83.         rte
  84.  
  85. dokeytbl:
  86.         move.l    transp,d0    * Three args, returns address of vector
  87.         move.l    d0,a1
  88.         move.l    (a0)+,d1
  89.         bmi    nostd
  90.         move.l    d1,(a1)        * put arg1 into standard and capslock
  91.         move.l    d1,8(a1)
  92. nostd:
  93.         move.l    (a0),d1        * put arg2 into shift
  94.         bmi    noshift
  95.         move.l    d1,4(a1)
  96. noshift:
  97.         rte
  98. keeptop:                * Top of kept memory
  99.  
  100. *
  101. * Setup code.  The stack will be at tpa, and can be somewhat abused.
  102. * 4(sp) points to the basepage.  All of this can be done in user
  103. * mode.
  104. *
  105.  
  106. setup:
  107.         move.l    4(sp),a4
  108. *
  109. * First we look for our magic number.
  110. *
  111.         moveq.l    #-1,d5
  112.         move.l    d5,(sp)
  113.         move.w    #XBIOSV,-(sp)
  114.         move.w    #Setexec,-(sp)
  115.         trap    #BIOS        * Setexec(46, -1L)
  116.         move.l    d0,a0        * Check current vector
  117.         cmpi.l    #Magicnum,-(a0)
  118.         beq    quickexit    * Already installed
  119.  
  120. *
  121. * Locate the original (actually, the current) key table vector and the two
  122. * interesting pointers.  d5 has -1L (see above).
  123. *
  124.         move.l    d5,(sp)
  125.         move.l    d5,-(sp)
  126.         move.l    d5,-(sp)
  127.         move.w    #Keytbl,-(sp)    * addr = Keytbl(-1L, -1L, -1L)
  128.         trap    #XBIOS
  129.         move.l    d0,transp    * Save the vector pointer
  130.         move.l    d0,a0
  131.         move.l    (a0)+,d1    * Save the normal table address
  132.         move.l    d1,normp
  133.         move.l    (a0)+,shiftp    * Save the shift table address
  134.         move.l    d1,(a0)        * Set capslock = normal
  135. *
  136. * Insinuate our code in the trap 14 vector
  137. *
  138.         pea    trapad
  139.         move.w    #XBIOSV,-(sp)
  140.         move.w    #Setexec,-(sp)
  141.         trap    #BIOS        * Setexec(46, trapad)
  142.         move.l    d0,trap14    * Save old vector
  143. *
  144. * Exit, keeping the active code
  145. *
  146.         lea    keeptop,a0
  147.         sub.l    a4,a0        * keeptop - basepage
  148.         clr.w    (sp)
  149.         move.l    a0,-(sp)
  150.         move.w    #Keep,-(sp)
  151.         trap    #GEMDOS        * Keep(nbytes, 0)
  152.  
  153. *
  154. * Come here if already installed for immediate exit
  155. *
  156. quickexit:
  157.         clr.w    (sp)
  158.         trap    #GEMDOS
  159.  
  160.         end
  161.  
  162.  
  163.