comparison src/audio/mint/SDL_mintaudio_it.S @ 644:594422ab8f9f

Atari MiNT: added more audio drivers
author Patrice Mandin <patmandin@gmail.com>
date Mon, 07 Jul 2003 19:16:03 +0000
parents
children c4803992e09c
comparison
equal deleted inserted replaced
643:564716cfb502 644:594422ab8f9f
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
4
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.
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 Library General Public License for more details.
14
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
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22
23 /*
24 Audio interrupts
25
26 Patrice Mandin
27 */
28
29 .text
30
31 .globl _SDL_MintAudio_Callback
32
33 .globl _SDL_MintAudio_GsxbInterrupt
34 .globl _SDL_MintAudio_EmptyGsxbInterrupt
35 .globl _SDL_MintAudio_XbiosInterrupt
36 .globl _SDL_MintAudio_Dma8Interrupt
37 .globl _SDL_MintAudio_StfaInterrupt
38
39 .globl _SDL_MintAudio_mutex
40 .globl _SDL_MintAudio_audiobuf
41 .globl _SDL_MintAudio_numbuf
42 .globl _SDL_MintAudio_audiosize
43
44 .globl _SDL_MintAudio_stfa
45
46 /*
47 How it works:
48 - Audio is playing buffer #0 (resp. #1)
49 - We must calculate a sample in buffer #1 (resp. #0)
50 so we first call the callback to do it
51 - Then we swap the buffers
52 */
53
54 /*--- GSXB interrupt vector ---*/
55
56 .text
57 _SDL_MintAudio_GsxbInterrupt:
58
59 /* Check if we are not already running */
60 tstw _SDL_MintAudio_mutex
61 bnes _SDL_MintAudio_EmptyGsxbInterrupt
62 notw _SDL_MintAudio_mutex
63
64 /* Swap buffers */
65 moveml d0-d2/a0-a2,sp@-
66
67 movel _SDL_MintAudio_numbuf,d0
68 movel _SDL_MintAudio_audiobuf,a0
69 eorl #1,d0
70 beqs SDL_MintAudio_GsxbBuffer0
71 movel _SDL_MintAudio_audiobuf+4,a0
72 SDL_MintAudio_GsxbBuffer0:
73 movel d0,_SDL_MintAudio_numbuf
74
75 /* Callback */
76 movel a0,sp@-
77 jsr _SDL_MintAudio_Callback
78 movel sp@+,a0
79
80 /* Setbuffer xbios function */
81 movel _SDL_MintAudio_audiosize,d1
82 lea a0@(0,d1:l),a1
83
84 movel a1,sp@-
85 movel a0,sp@-
86 clrw sp@-
87 movew #131,sp@-
88 trap #14
89 lea sp@(12),sp
90
91 moveml sp@+,d0-d2/a0-a2
92
93 clrw _SDL_MintAudio_mutex
94 _SDL_MintAudio_EmptyGsxbInterrupt:
95 rts
96
97 /*--- Xbios interrupt vector ---*/
98
99 _SDL_MintAudio_XbiosInterrupt:
100
101 /* Reenable interrupts, so other interrupts can work */
102 movew #0x2300,sr
103
104 /* Clear service bit, so other MFP interrupts can work */
105 bclr #5,0xfffffa0f:w
106
107 /* Check if we are not already running */
108 tstw _SDL_MintAudio_mutex
109 bnes SDL_MintAudio_XbiosEnd
110 notw _SDL_MintAudio_mutex
111
112 /* Swap buffers */
113 moveml d0-d2/a0-a2,sp@-
114
115 movel _SDL_MintAudio_numbuf,d0
116 movel _SDL_MintAudio_audiobuf,a0
117 eorl #1,d0
118 beqs SDL_MintAudio_XbiosBuffer0
119 movel _SDL_MintAudio_audiobuf+4,a0
120 SDL_MintAudio_XbiosBuffer0:
121 movel d0,_SDL_MintAudio_numbuf
122
123 /* Callback */
124 movel a0,sp@-
125 jsr _SDL_MintAudio_Callback
126 movel sp@+,a0
127
128 /* Setbuffer xbios function */
129 movel _SDL_MintAudio_audiosize,d1
130 lea a0@(0,d1:l),a1
131
132 movel a1,sp@-
133 movel a0,sp@-
134 clrw sp@-
135 movew #131,sp@-
136 trap #14
137 lea sp@(12),sp
138
139 moveml sp@+,d0-d2/a0-a2
140
141 clrw _SDL_MintAudio_mutex
142 SDL_MintAudio_XbiosEnd:
143 rte
144
145 /*--- DMA 8 bits interrupt vector ---*/
146
147 _SDL_MintAudio_Dma8Interrupt:
148
149 /* Reenable interrupts, so other interrupts can work */
150 movew #0x2300,sr
151
152 /* Clear service bit, so other MFP interrupts can work */
153 bclr #5,0xfffffa0f:w
154
155 /* Check if we are not already running */
156 tstw _SDL_MintAudio_mutex
157 bnes SDL_MintAudio_Dma8End
158 notw _SDL_MintAudio_mutex
159
160 /* Swap buffers */
161 moveml d0-d1/a0-a1,sp@-
162
163 movel _SDL_MintAudio_numbuf,d0
164 movel _SDL_MintAudio_audiobuf,d1
165 eorl #1,d0
166 beqs SDL_MintAudio_Dma8Buffer0
167 movel _SDL_MintAudio_audiobuf+4,d1
168 SDL_MintAudio_Dma8Buffer0:
169 movel d0,_SDL_MintAudio_numbuf
170
171 /* Callback */
172 movel d1,sp@-
173 jsr _SDL_MintAudio_Callback
174 movel sp@+,d1
175
176 /* Modify DMA addresses */
177 lea 0xffff8900:w,a0
178
179 moveb d1,a0@(0x07) /* Start address */
180 rorl #8,d1
181 moveb d1,a0@(0x05)
182 rorl #8,d1
183 moveb d1,a0@(0x03)
184 swap d1
185
186 addl _SDL_MintAudio_audiosize,d1
187
188 moveb d1,a0@(0x13) /* End address */
189 rorl #8,d1
190 moveb d1,a0@(0x11)
191 rorl #8,d1
192 moveb d1,a0@(0x0f)
193
194 moveml sp@+,d0-d1/a0-a1
195
196 clrw _SDL_MintAudio_mutex
197 SDL_MintAudio_Dma8End:
198 rte
199
200 /*--- STFA interrupt vector ---*/
201
202 STFA_SOUND_START = 6
203 STFA_SOUND_END = STFA_SOUND_START+8
204
205 _SDL_MintAudio_StfaInterrupt:
206
207 /* Reenable interrupts, so other interrupts can work */
208 movew #0x2300,sr
209
210 /* Check if we are not already running */
211 tstw _SDL_MintAudio_mutex
212 bnes SDL_MintAudio_StfaEnd
213 notw _SDL_MintAudio_mutex
214
215 /* Swap buffers */
216 moveml d0-d1/a0-a1,sp@-
217
218 movel _SDL_MintAudio_numbuf,d0
219 movel _SDL_MintAudio_audiobuf,d1
220 eorl #1,d0
221 beqs SDL_MintAudio_StfaBuffer0
222 movel _SDL_MintAudio_audiobuf+4,d1
223 SDL_MintAudio_StfaBuffer0:
224 movel d0,_SDL_MintAudio_numbuf
225
226 /* Callback */
227 movel d1,sp@-
228 jsr _SDL_MintAudio_Callback
229 movel sp@+,d1
230
231 /* Modify STFA replay buffers */
232 movel _SDL_MintAudio_stfa,a0
233 movel d1,a0@(STFA_SOUND_START)
234 addl _SDL_MintAudio_audiosize,d1
235 movel d1,a0@(STFA_SOUND_END)
236
237 moveml sp@+,d0-d1/a0-a1
238
239 clrw _SDL_MintAudio_mutex
240 SDL_MintAudio_StfaEnd:
241 rte
242