2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 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 /*--- Xbios interrupt vector to measure Falcon external clock ---*/
60 _SDL_MintAudio_XbiosInterruptMeasureClock: /* 1 mS */
62 btst #0,0xFFFF8901:w /* state DMA sound */
63 beqs SDL_MintAudio_EndIntMeasure
64 addql #1,_SDL_MintAudio_clocktics
65 SDL_MintAudio_EndIntMeasure:
66 bclr #5,0xFFFFFA0F:w /* Clear service bit */
69 /*--- Xbios interrupt vector ---*/
71 _SDL_MintAudio_XbiosInterrupt:
73 /* Reenable interrupts, so other interrupts can work */
76 /* Clear service bit, so other MFP interrupts can work */
79 /* Check if we are not already running */
80 tstw _SDL_MintAudio_mutex
81 bne SDL_MintAudio_XbiosEnd
82 notw _SDL_MintAudio_mutex
85 eorw #1,_SDL_MintAudio_numbuf
87 moveml d0-d7/a0-a6,sp@-
89 /* Save FPU if needed */
90 tstw _SDL_MintAudio_hasfpu
91 beqs SDL_MintAudio_Xbios_nofpu1
94 fmoveml fpcr/fpsr/fpiar,sp@-
97 SDL_MintAudio_Xbios_nofpu1:
100 jsr _SDL_MintAudio_Callback
102 /* Restore FPU if needed */
103 tstw _SDL_MintAudio_hasfpu
104 beqs SDL_MintAudio_Xbios_nofpu2
107 fmoveml sp@+,fpcr/fpsr/fpiar
110 SDL_MintAudio_Xbios_nofpu2:
112 /* Reserve space for registers */
118 movel _SDL_MintAudio_audiosize,d1
120 movew _SDL_MintAudio_numbuf,d0
122 lea _SDL_MintAudio_audiobuf,a0
134 /* Restore registers space */
137 moveml sp@+,d0-d7/a0-a6
139 clrw _SDL_MintAudio_mutex
140 SDL_MintAudio_XbiosEnd:
143 /*--- DMA 8 bits interrupt vector ---*/
145 _SDL_MintAudio_Dma8Interrupt:
147 /* Reenable interrupts, so other interrupts can work */
150 /* Clear service bit, so other MFP interrupts can work */
153 /* Check if we are not already running */
154 tstw _SDL_MintAudio_mutex
155 bne SDL_MintAudio_Dma8End
156 notw _SDL_MintAudio_mutex
159 eorw #1,_SDL_MintAudio_numbuf
161 moveml d0-d1/a0-a1,sp@-
163 /* Save FPU if needed */
164 tstw _SDL_MintAudio_hasfpu
165 beqs SDL_MintAudio_Dma8_nofpu1
168 fmoveml fpcr/fpsr/fpiar,sp@-
171 SDL_MintAudio_Dma8_nofpu1:
174 jsr _SDL_MintAudio_Callback
176 /* Restore FPU if needed */
177 tstw _SDL_MintAudio_hasfpu
178 beqs SDL_MintAudio_Dma8_nofpu2
181 fmoveml sp@+,fpcr/fpsr/fpiar
184 SDL_MintAudio_Dma8_nofpu2:
190 movew _SDL_MintAudio_numbuf,d0
192 lea _SDL_MintAudio_audiobuf,a0
195 /* Modify DMA addresses */
198 moveb d1,a0@(0x07) /* Start address */
205 addl _SDL_MintAudio_audiosize,d1
207 moveb d1,a0@(0x13) /* End address */
213 moveml sp@+,d0-d1/a0-a1
215 clrw _SDL_MintAudio_mutex
216 SDL_MintAudio_Dma8End:
219 /*--- STFA interrupt vector ---*/
222 STFA_SOUND_END = STFA_SOUND_START+8
224 _SDL_MintAudio_StfaInterrupt:
226 /* Reenable interrupts, so other interrupts can work */
229 /* Check if we are not already running */
230 tstw _SDL_MintAudio_mutex
231 bnes SDL_MintAudio_StfaEnd
232 notw _SDL_MintAudio_mutex
235 eorw #1,_SDL_MintAudio_numbuf
237 moveml d0-d7/a0-a6,sp@-
239 /* Save FPU if needed */
240 tstw _SDL_MintAudio_hasfpu
241 beqs SDL_MintAudio_Stfa_nofpu1
244 fmoveml fpcr/fpsr/fpiar,sp@-
247 SDL_MintAudio_Stfa_nofpu1:
250 jsr _SDL_MintAudio_Callback
252 /* Restore FPU if needed */
253 tstw _SDL_MintAudio_hasfpu
254 beqs SDL_MintAudio_Stfa_nofpu2
257 fmoveml sp@+,fpcr/fpsr/fpiar
260 SDL_MintAudio_Stfa_nofpu2:
265 movel _SDL_MintAudio_stfa,a1
267 movew _SDL_MintAudio_numbuf,d0
269 lea _SDL_MintAudio_audiobuf,a0
272 /* Modify STFA replay buffers */
273 movel d1,a1@(STFA_SOUND_START)
274 addl _SDL_MintAudio_audiosize,d1
275 movel d1,a1@(STFA_SOUND_END)
277 moveml sp@+,d0-d7/a0-a6
279 clrw _SDL_MintAudio_mutex
280 SDL_MintAudio_StfaEnd: