Skip to content

Latest commit

 

History

History
183 lines (141 loc) · 3.11 KB

SDL_mintaudiointerrupt.S

File metadata and controls

183 lines (141 loc) · 3.11 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* Audio interrupt routines
*
* Patrice Mandin
*/
.text
.globl _SDL_MintAudio_Callback
.globl _SDL_MintAudio_IntDma
.globl _SDL_MintAudio_IntXbios
.globl _SDL_MintAudio_IntGsxb
.globl _SDL_MintAudio_mutex
.globl _SDL_MintAudio_audiobuf
.globl _SDL_MintAudio_numbuf
.globl _SDL_MintAudio_audiosize
/*
How it works:
- Audio is playing buffer #0 (resp. #1)
- We must calculate a sample in buffer #1 (resp. #0)
so we first call the callback to do it
- Then we swap the buffers
*/
/*--- DMA 8 bits interrupt vector ---*/
.text
_SDL_MintAudio_IntDma:
/* Check if we are not already running */
tstw _SDL_MintAudio_mutex
bnes intdma_end
notw _SDL_MintAudio_mutex
/* Reenable interrupts */
movew #0x2300,sr
/* Swap buffers */
moveml d0-d1/a0-a1,sp@-
movel _SDL_MintAudio_numbuf,d0
movel _SDL_MintAudio_audiobuf,d1
eorl #1,d0
beqs intdma_buffer0
movel _SDL_MintAudio_audiobuf+4,d1
intdma_buffer0:
movel d0,_SDL_MintAudio_numbuf
/* Callback */
movel d1,sp@-
jsr _SDL_MintAudio_Callback
movel sp@+,d1
/* Modify DMA addresses */
lea 0xffff8900:w,a0
moveb d1,a0@(0x07) /* Start address */
rorl #8,d1
moveb d1,a0@(0x05)
rorl #8,d1
moveb d1,a0@(0x03)
swap d1
addl _SDL_MintAudio_audiosize,d1
moveb d1,a0@(0x13) /* End address */
rorl #8,d1
moveb d1,a0@(0x11)
rorl #8,d1
moveb d1,a0@(0x0f)
moveml sp@+,d0-d1/a0-a1
clrw _SDL_MintAudio_mutex
intdma_end:
bclr #5,0xfffffa0f:w
rte
/*--- Xbios interrupt vector ---*/
.text
_SDL_MintAudio_IntXbios:
/* Check if we are not already running */
tstw _SDL_MintAudio_mutex
bnes intxbios_end
notw _SDL_MintAudio_mutex
/* Reenable interrupts */
movew #0x2300,sr
/* Swap buffers */
moveml d0-d2/a0-a2,sp@-
movel _SDL_MintAudio_numbuf,d0
movel _SDL_MintAudio_audiobuf,a0
eorl #1,d0
beqs intxbios_buffer0
movel _SDL_MintAudio_audiobuf+4,a0
intxbios_buffer0:
movel d0,_SDL_MintAudio_numbuf
/* Callback */
moveml a0,sp@-
jsr _SDL_MintAudio_Callback
moveml sp@+,a0
/* Setbuffer xbios function */
movel _SDL_MintAudio_audiosize,d1
lea a0@(0,d1:l),a1
movel a1,sp@-
movel a0,sp@-
clrw sp@-
movew #131,sp@-
trap #14
lea sp@(12),sp
moveml sp@+,d0-d2/a0-a2
clrw _SDL_MintAudio_mutex
intxbios_end:
bclr #5,0xfffffa0f:w
rte
/*--- GSXB interrupt vector ---*/
.text
_SDL_MintAudio_IntGsxb:
/* Check if we are not already running */
tstw _SDL_MintAudio_mutex
bnes intgsxb_end
notw _SDL_MintAudio_mutex
/* Swap buffers */
moveml d0-d2/a0-a2,sp@-
movel _SDL_MintAudio_numbuf,d0
movel _SDL_MintAudio_audiobuf,a0
eorl #1,d0
beqs intgsxb_buffer0
movel _SDL_MintAudio_audiobuf+4,a0
intgsxb_buffer0:
movel d0,_SDL_MintAudio_numbuf
/* Callback */
moveml a0,sp@-
jsr _SDL_MintAudio_Callback
moveml sp@+,a0
/* Setbuffer xbios function */
movel _SDL_MintAudio_audiosize,d1
lea a0@(0,d1:l),a1
movel a1,sp@-
movel a0,sp@-
clrw sp@-
movew #131,sp@-
trap #14
lea sp@(12),sp
moveml sp@+,d0-d2/a0-a2
clrw _SDL_MintAudio_mutex
intgsxb_end:
rts
/*--- Common variables ---*/
.data
.even
.comm _SDL_MintAudio_mutex,4
.even
.comm _SDL_MintAudio_audiobuf,8
.even
.comm _SDL_MintAudio_numbuf,4
.even
.comm _SDL_MintAudio_audiosize,4