SDL_ikbdinterrupt.S
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:4k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /*
  2.     SDL - Simple DirectMedia Layer
  3.     Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.     This library is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.     Library General Public License for more details.
  12.     You should have received a copy of the GNU Library General Public
  13.     License along with this library; if not, write to the Free
  14.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  15.     Sam Lantinga
  16.     slouken@libsdl.org
  17. */
  18. #ifdef SAVE_RCSID
  19. static char rcsid =
  20.  "@(#) $Id: SDL_ikbdinterrupt.S,v 1.1 2002/04/22 21:38:04 wmay Exp $";
  21. #endif
  22. /*
  23.  * IKBD 6301 interrupt routine
  24.  *
  25.  * Patrice Mandin
  26.  */
  27. .text
  28. .globl _SDL_AtariIkbdInstall
  29. .globl _SDL_AtariIkbdUninstall
  30. .globl _SDL_AtariIkbd_keyboard
  31. .globl _SDL_AtariIkbd_mouseb
  32. .globl _SDL_AtariIkbd_mousex
  33. .globl _SDL_AtariIkbd_mousey
  34. .globl _SDL_AtariIkbd_joystick
  35. .globl _SDL_AtariIkbd_enabled
  36. /*--- Install our IKBD vector ---*/
  37. _SDL_AtariIkbdInstall:
  38. moveml d0-d1/a0-a1,sp@-
  39. | Init interrupts
  40. movew #0x2700,sr
  41. | Save MFP registers used for keyboard
  42. lea 0xfffffa00:w,a0
  43. btst #6,a0@(0x09)
  44. sne ikbd_ierb
  45. btst #6,a0@(0x15)
  46. sne ikbd_imrb
  47. | Set our routine
  48. movel 0x118:w,old_ikbd
  49. movel #ikbd,0x118:w
  50. bset #6,0xfffffa09:w | IERB
  51. bset #6,0xfffffa15:w | IMRB
  52. moveb #8,0xfffffc02:w
  53. movew #0x2300,sr
  54. | Interrupts done
  55. movew #0xffff,_SDL_AtariIkbd_enabled
  56. moveml sp@+,d0-d1/a0-a1
  57. rts
  58. /*--- Uninstall our IKBD vector ---*/
  59. _SDL_AtariIkbdUninstall:
  60. movel a0,sp@-
  61. | Stop interrupt
  62. movew #0x2700,sr
  63. | Restore previous MFP registers
  64. lea 0xfffffa00:w,a0
  65. bclr #6,a0@(0x09)
  66. tstb ikbd_ierb
  67. beq ikbd_restoreierb
  68. bset #6,a0@(0x09)
  69. ikbd_restoreierb:
  70. bclr #6,a0@(0x15)
  71. tstb ikbd_imrb
  72. beq ikbd_restoreimrb
  73. bset #6,a0@(0x15)
  74. ikbd_restoreimrb:
  75. movel old_ikbd,0x118:w
  76. | Clear keyboard buffer
  77. lea 0xfffffc00:w,a0
  78. ikbd_videbuffer:
  79. btst #0,a0@
  80. beq ikbd_finbuffer
  81. tstb a0@(0x02)
  82. bra ikbd_videbuffer
  83. ikbd_finbuffer:
  84. movew #0x2300,sr
  85. movel sp@+,a0
  86. rts
  87. .data
  88. .even
  89. .comm ikbd_ierb,4*1
  90. .even
  91. .comm ikbd_imrb,4*1
  92. /*--- Our custom IKBD vector ---*/
  93. .text
  94. .even
  95. .ascii "XBRA"
  96. .ascii "LSDL"
  97. .comm old_ikbd,4*1
  98. ikbd:
  99. moveml d0-d1/a0,sp@-
  100. moveb 0xfffffc02:w,d0
  101. | paquet joystick ?
  102. cmpb #0xff,d0
  103. beq ikbd_yes_joystick
  104. | paquet souris ?
  105. cmpb #0xf8,d0
  106. bmi ikbd_no_mouse
  107. cmpb #0xfc,d0
  108. bpl ikbd_no_mouse
  109. ikbd_yes_mouse:
  110. andw #3,d0
  111. movew d0,_SDL_AtariIkbd_mouseb
  112. movel #ikbd_mousex,0x118:w
  113. bra ikbd_endit
  114. ikbd_yes_joystick:
  115. movel #ikbd_joystick,0x118:w
  116. bra ikbd_endit
  117. ikbd_no_mouse:
  118. moveb d0,d1
  119. lea _SDL_AtariIkbd_keyboard,a0
  120. andl #0x7f,d1
  121. tas d0
  122. spl a0@(0,d1:w)
  123. ikbd_fin:
  124. | Fin interruption
  125. ikbd_endit:
  126. moveml sp@+,d0-d1/a0
  127. bclr #6,0xfffffa11:w
  128. rte
  129. ikbd_mousex:
  130. movel d0,sp@-
  131. moveb 0xfffffc02:w,d0
  132. extw d0
  133. addw d0,_SDL_AtariIkbd_mousex
  134. movel sp@+,d0
  135. movel #ikbd_mousey,0x118:w
  136. bclr #6,0xfffffa11:w
  137. rte
  138. ikbd_mousey:
  139. movel d0,sp@-
  140. moveb 0xfffffc02:w,d0
  141. extw d0
  142. addw d0,_SDL_AtariIkbd_mousey
  143. movel sp@+,d0
  144. movel #ikbd,0x118:w
  145. bclr #6,0xfffffa11:w
  146. rte
  147. ikbd_joystick:
  148. moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1
  149. movel #ikbd,0x118:w
  150. bclr #6,0xfffffa11:w
  151. rte
  152. .data
  153. .even
  154. _SDL_AtariIkbd_enabled:
  155. .word 0
  156. .even
  157. .comm _SDL_AtariIkbd_keyboard,128
  158. .even
  159. .comm _SDL_AtariIkbd_mousex,2*1
  160. .even
  161. .comm _SDL_AtariIkbd_mousey,2*1
  162. .even
  163. .comm _SDL_AtariIkbd_mouseb,2*1
  164. .even
  165. .comm _SDL_AtariIkbd_joystick,2*1