Home | History | Annotate | Download | only in ataricommon
      1 /*
      2     SDL - Simple DirectMedia Layer
      3     Copyright (C) 1997-2012 Sam Lantinga
      4 
      5     This library is free software; you can redistribute it and/or
      6     modify it under the terms of the GNU Lesser General Public
      7     License as published by the Free Software Foundation; either
      8     version 2.1 of the License, or (at your option) any later version.
      9 
     10     This library is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     Lesser General Public License for more details.
     14 
     15     You should have received a copy of the GNU Lesser General Public
     16     License along with this library; if not, write to the Free Software
     17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     18 
     19     Sam Lantinga
     20     slouken (at) libsdl.org
     21 */
     22 
     23 /*
     24  *	XBIOS mouse & joystick vectors
     25  *
     26  *	Patrice Mandin
     27  */
     28 
     29 	.text
     30 
     31 	.globl	_SDL_AtariXbios_Install
     32 	.globl	_SDL_AtariXbios_Restore
     33 	.globl	_SDL_AtariXbios_MouseVector
     34 	.globl	_SDL_AtariXbios_JoystickVector
     35 
     36 	.globl	_SDL_AtariXbios_mouselock
     37 	.globl	_SDL_AtariXbios_mouseb
     38 	.globl	_SDL_AtariXbios_mousex
     39 	.globl	_SDL_AtariXbios_mousey
     40 	.globl	_SDL_AtariXbios_joystick
     41 
     42 /*--- Vector installer ---*/
     43 
     44 _SDL_AtariXbios_Install:
     45 	movel	sp@(4),a0
     46 
     47 	/* Stop interrupts */
     48 
     49 	movew	#0x2700,sr
     50 
     51 	/* Save old mouse vector, set our routine */
     52 
     53 	clrl	oldmousevector
     54 	movel	sp@(8),d0
     55 	beqs	no_new_mouse_vector
     56 #if defined(__mcoldfire__)
     57 	movel	a0@(16),d1
     58 	movel	d1,oldmousevector
     59 #else
     60 	movel	a0@(16),oldmousevector
     61 #endif
     62 	movel	d0,a0@(16)
     63 no_new_mouse_vector:
     64 
     65 	/* Save old joystick vector, set our routine */
     66 
     67 	clrl	oldjoystickvector
     68 	movel	sp@(12),d0
     69 	beqs	no_new_joystick_vector
     70 #if defined(__mcoldfire__)
     71 	movel	a0@(24),d1
     72 	movel	d1,oldjoystickvector
     73 #else
     74 	movel	a0@(24),oldjoystickvector
     75 #endif
     76 	movel	d0,a0@(24)
     77 no_new_joystick_vector:
     78 
     79 	/* Restart interrupts */
     80 
     81 	movew	#0x2300,sr
     82 
     83 	rts
     84 
     85 /*--- Vector restorer ---*/
     86 
     87 _SDL_AtariXbios_Restore:
     88 	movel	sp@(4),a0
     89 
     90 	/* Stop interrupts */
     91 
     92 	movew	#0x2700,sr
     93 
     94 	/* Restore mouse vector */
     95 
     96 	movel	oldmousevector,d0
     97 	beqs	no_restore_mouse
     98 	movel	d0,a0@(16)
     99 no_restore_mouse:
    100 
    101 	/* Restore joystick vector */
    102 
    103 	movel	oldjoystickvector,d0
    104 	beqs	no_restore_joystick
    105 	movel	d0,a0@(24)
    106 no_restore_joystick:
    107 
    108 	/* Restart interrupts */
    109 
    110 	movew	#0x2300,sr
    111 
    112 	rts
    113 
    114 /*--- Our mouse vector ---*/
    115 
    116 	.text
    117 	.even
    118 	.ascii "XBRA"
    119 	.ascii "LSDL"
    120 	.comm	oldmousevector,4*1
    121 _SDL_AtariXbios_MouseVector:
    122 #if defined(__mcoldfire__)
    123 	lea	sp@(-8),sp
    124 	moveml	d0-d1,sp@
    125 #else
    126 	movel	d0,sp@-
    127 #endif
    128 
    129 	/* Mouse buttons */
    130 	moveb	(a0),d0
    131 #if defined(__mcoldfire__)
    132 	andl	#3,d0
    133 #else
    134 	andw	#3,d0
    135 #endif
    136 	movew	d0,_SDL_AtariXbios_mouseb
    137 
    138 	/* X movement */
    139 	moveb	a0@(1),d0
    140 	extw	d0
    141 #if defined(__mcoldfire__)
    142 	movew	_SDL_AtariXbios_mousex,d1
    143 	addl	d1,d0
    144 	movew	d0,_SDL_AtariXbios_mousex
    145 #else
    146 	addw	d0,_SDL_AtariXbios_mousex
    147 #endif
    148 
    149 	/* Y movement */
    150 	moveb	a0@(2),d0
    151 	extw	d0
    152 #if defined(__mcoldfire__)
    153 	movew	_SDL_AtariXbios_mousey,d1
    154 	addl	d1,d0
    155 	movew	d0,_SDL_AtariXbios_mousey
    156 #else
    157 	addw	d0,_SDL_AtariXbios_mousey
    158 #endif
    159 
    160 	/* Lock mouse position ? */
    161 	tstw	_SDL_AtariXbios_mouselock
    162 	beq.s	no_mouse_lock
    163 	clrb	a0@(1)
    164 	clrb	a0@(2)
    165 no_mouse_lock:
    166 
    167 	/* Jump through old vector */
    168 #if defined(__mcoldfire__)
    169 	moveml	sp@,d0-d1
    170 	lea	sp@(8),sp
    171 #else
    172 	movel	sp@+,d0
    173 #endif
    174 
    175 	movel	oldmousevector,sp@-
    176 	rts
    177 
    178 	.data
    179 	.even
    180 	.comm	_SDL_AtariXbios_mouselock,2*1
    181 	.comm	_SDL_AtariXbios_mousex,2*1
    182 	.comm	_SDL_AtariXbios_mousey,2*1
    183 	.comm	_SDL_AtariXbios_mouseb,2*1
    184 
    185 /*--- Our joystick vector ---*/
    186 
    187 	.text
    188 	.even
    189 	.ascii "XBRA"
    190 	.ascii "LSDL"
    191 	.comm	oldjoystickvector,4*1
    192 _SDL_AtariXbios_JoystickVector:
    193 	movel	d0,sp@-
    194 
    195 	/* New joystick state */
    196 	moveb	a0@(2),d0
    197 #if defined(__mcoldfire__)
    198 	andl	#0x8f,d0
    199 #else
    200 	andw	#0x8f,d0
    201 #endif
    202 	movew	d0,_SDL_AtariXbios_joystick
    203 
    204 	/* Jump through old vector */
    205 	movel	sp@+,d0
    206 
    207 	movel	oldjoystickvector,sp@-
    208 	rts
    209 
    210 	.data
    211 	.even
    212 	.comm	_SDL_AtariXbios_joystick,2*1
    213