2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 Patrice Mandin, Didier Méquignon
31 .globl _SDL_MintAudio_Callback
33 .globl _SDL_MintAudio_XbiosInterrupt
34 .globl _SDL_MintAudio_XbiosInterruptMeasureClock
35 .globl _SDL_MintAudio_Dma8Interrupt
36 .globl _SDL_MintAudio_StfaInterrupt
38 .globl _SDL_MintAudio_mutex
39 .globl _SDL_MintAudio_audiobuf
40 .globl _SDL_MintAudio_numbuf
41 .globl _SDL_MintAudio_audiosize
42 .globl _SDL_MintAudio_clocktics
43 .globl _SDL_MintAudio_hasfpu
45 .globl _SDL_MintAudio_stfa
49 - Audio is playing buffer #0 (resp. #1)
50 - We must calculate a sample in buffer #1 (resp. #0)
51 so we first call the callback to do it
52 - Then we swap the buffers
58 /*--- Save/restore FPU context ---*/
60 #if defined(__mcoldfire__)
62 #define SAVE_FPU_CONTEXT \
69 #define RESTORE_FPU_CONTEXT \
70 fmovemd sp@,fp0-fp7; \
78 #define SAVE_FPU_CONTEXT \
81 fmoveml fpcr/fpsr/fpiar,sp@-; \
82 fmovemx fp0-fp7,sp@-; \
85 #define RESTORE_FPU_CONTEXT \
87 fmovemx sp@+,fp0-fp7; \
88 fmoveml sp@+,fpcr/fpsr/fpiar; \
94 /*--- Xbios interrupt vector to measure Falcon external clock ---*/
96 _SDL_MintAudio_XbiosInterruptMeasureClock: /* 1 mS */
97 #if defined(__mcoldfire__)
101 btst d0,0xFFFF8901:w /* state DMA sound */
103 btst #0,0xFFFF8901:w /* state DMA sound */
105 beqs SDL_MintAudio_EndIntMeasure
106 addql #1,_SDL_MintAudio_clocktics
107 SDL_MintAudio_EndIntMeasure:
108 #if defined(__mcoldfire__)
110 bclr d0,0xFFFFFA0F:w /* Clear service bit */
114 bclr #5,0xFFFFFA0F:w /* Clear service bit */
118 /*--- Xbios interrupt vector ---*/
120 _SDL_MintAudio_XbiosInterrupt:
121 #if defined(__mcoldfire__)
123 moveml d0-d7/a0-a6,sp@
125 moveml d0-d7/a0-a6,sp@-
128 /* Reenable interrupts, so other interrupts can work */
131 /* Clear service bit, so other MFP interrupts can work */
132 #if defined(__mcoldfire__)
139 /* Check if we are not already running */
140 tstw _SDL_MintAudio_mutex
141 bne SDL_MintAudio_XbiosEnd
143 #if defined(__mcoldfire__)
144 movew _SDL_MintAudio_mutex,d0
146 movew d0,_SDL_MintAudio_mutex
148 movew _SDL_MintAudio_numbuf,d1
150 movew d1,_SDL_MintAudio_numbuf
152 notw _SDL_MintAudio_mutex
155 eorw #1,_SDL_MintAudio_numbuf
158 /* Save FPU if needed */
159 tstw _SDL_MintAudio_hasfpu
160 beqs SDL_MintAudio_Xbios_nofpu1
162 SDL_MintAudio_Xbios_nofpu1:
165 jsr _SDL_MintAudio_Callback
167 /* Restore FPU if needed */
168 tstw _SDL_MintAudio_hasfpu
169 beqs SDL_MintAudio_Xbios_nofpu2
171 SDL_MintAudio_Xbios_nofpu2:
173 /* Reserve space for registers */
174 #if defined(__mcoldfire__)
184 movel _SDL_MintAudio_audiosize,d1
186 movew _SDL_MintAudio_numbuf,d0
188 lea _SDL_MintAudio_audiobuf,a0
200 /* Restore registers space */
201 #if defined(__mcoldfire__)
208 clrw _SDL_MintAudio_mutex
209 SDL_MintAudio_XbiosEnd:
210 #if defined(__mcoldfire__)
211 moveml sp@,d0-d7/a0-a6
214 moveml sp@+,d0-d7/a0-a6
218 /*--- DMA 8 bits interrupt vector ---*/
220 _SDL_MintAudio_Dma8Interrupt:
221 #if defined(__mcoldfire__)
223 moveml d0-d1/a0-a1,sp@
225 moveml d0-d1/a0-a1,sp@-
228 /* Reenable interrupts, so other interrupts can work */
231 /* Clear service bit, so other MFP interrupts can work */
232 #if defined(__mcoldfire__)
238 /* Check if we are not already running */
239 tstw _SDL_MintAudio_mutex
240 bne SDL_MintAudio_Dma8End
242 #if defined(__mcoldfire__)
243 movew _SDL_MintAudio_mutex,d0
245 movew d0,_SDL_MintAudio_mutex
247 movew _SDL_MintAudio_numbuf,d1
249 movew d1,_SDL_MintAudio_numbuf
251 notw _SDL_MintAudio_mutex
254 eorw #1,_SDL_MintAudio_numbuf
257 /* Save FPU if needed */
258 tstw _SDL_MintAudio_hasfpu
259 beqs SDL_MintAudio_Dma8_nofpu1
261 SDL_MintAudio_Dma8_nofpu1:
264 jsr _SDL_MintAudio_Callback
266 /* Restore FPU if needed */
267 tstw _SDL_MintAudio_hasfpu
268 beqs SDL_MintAudio_Dma8_nofpu2
270 SDL_MintAudio_Dma8_nofpu2:
276 movew _SDL_MintAudio_numbuf,d0
278 lea _SDL_MintAudio_audiobuf,a0
281 /* Modify DMA addresses */
286 moveb d0,a0@(0x07) /* Start address */
292 addl _SDL_MintAudio_audiosize,d1
296 moveb d0,a0@(0x13) /* End address */
302 clrw _SDL_MintAudio_mutex
303 SDL_MintAudio_Dma8End:
304 #if defined(__mcoldfire__)
305 moveml sp@,d0-d1/a0-a1
308 moveml sp@+,d0-d1/a0-a1
312 /*--- STFA interrupt vector ---*/
315 STFA_SOUND_END = STFA_SOUND_START+8
317 _SDL_MintAudio_StfaInterrupt:
318 /* Reenable interrupts, so other interrupts can work */
321 /* Check if we are not already running */
322 tstw _SDL_MintAudio_mutex
324 #if defined(__mcoldfire__)
325 bne SDL_MintAudio_StfaEnd
328 moveml d0-d7/a0-a6,sp@
330 movew _SDL_MintAudio_mutex,d0
332 movew d0,_SDL_MintAudio_mutex
334 movew _SDL_MintAudio_numbuf,d1
336 movew d1,_SDL_MintAudio_numbuf
338 bnes SDL_MintAudio_StfaEnd
340 moveml d0-d7/a0-a6,sp@-
342 notw _SDL_MintAudio_mutex
345 eorw #1,_SDL_MintAudio_numbuf
348 /* Save FPU if needed */
349 tstw _SDL_MintAudio_hasfpu
350 beqs SDL_MintAudio_Stfa_nofpu1
352 SDL_MintAudio_Stfa_nofpu1:
355 jsr _SDL_MintAudio_Callback
357 /* Restore FPU if needed */
358 tstw _SDL_MintAudio_hasfpu
359 beqs SDL_MintAudio_Stfa_nofpu2
361 SDL_MintAudio_Stfa_nofpu2:
366 movel _SDL_MintAudio_stfa,a1
368 movew _SDL_MintAudio_numbuf,d0
370 lea _SDL_MintAudio_audiobuf,a0
373 /* Modify STFA replay buffers */
374 movel d1,a1@(STFA_SOUND_START)
375 addl _SDL_MintAudio_audiosize,d1
376 movel d1,a1@(STFA_SOUND_END)
378 #if defined(__mcoldfire__)
379 moveml sp@,d0-d7/a0-a6
382 moveml sp@+,d0-d7/a0-a6
384 clrw _SDL_MintAudio_mutex
385 SDL_MintAudio_StfaEnd: