Repository navigation
Expand file tree
/
Copy pathaica.h
More file actions
383 lines (316 loc) · 5.53 KB
/
Copy pathaica.h
File metadata and controls
383 lines (316 loc) · 5.53 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/*
This file is part of libswirl
*/
#include "license/bsd"
#pragma once
#include "types.h"
#include "oslib/oslib.h"
#include "assert.h"
#define SCIEB_addr 0x289C
#define SCIPD_addr (0x289C+4)
#define SCIRE_addr (0x289C+8)
#define MCIEB_addr 0x28B4
#define MCIPD_addr (0x28B4+4)
#define MCIRE_addr (0x28B4+8)
#define TIMER_A 0x2890
#define TIMER_B (0x2890+4)
#define TIMER_C (0x2890+8)
#define REG_L (0x2D00)
#define REG_M (0x2D04)
#define entry(name,sz) u32 name:sz;
#pragma pack(push, 1)
struct CommonData_struct
{
//+0
entry(MVOL,4);
entry(VER,4);
entry(DAC18B,1);
entry(MEM8MB,1);
entry(pad0_0,5);
entry(Mono,1);
u32 :16;
//+4
entry(RBP,12);
entry(pad1_0,1);
entry(RBL,2);
entry(TESTB0,1);
u32 :16;
//+8
entry(MIBUF,8);
entry(MIEMP,1);
entry(MIFUL ,1);
entry(MIOVF ,1);
entry(MOEMP ,1);
entry(MOFUL ,1);
entry(pad3_0,3);
u32 :16;
//+C
entry(MOBUF,8);
entry(MSLC,6);
entry(AFSET,1);
entry(padC_0,1);
u32 :16;
//+10
entry(EG,13);
entry(SGC,2);
entry(LP,1);
u32 :16;
//+14
entry(CA,16);
u32 :16;
//quite a bit padding here :)
u8 pad_med_0[0x6C-4];
//+80
entry(MRWINH,4);
entry($T,1);
entry($TSCD,3);
entry(pad80_0,1);
entry(DMEA_hi,7);
u32 :16;
//+84
entry(pad84_0,2);
entry(DMEA_lo,14);
u32 :16;
//+88
entry(pad88_0,2);
entry(DRGA,13);
entry(DGATE,1);
u32 :16;
//+8C
entry(DEXE,1);
entry(pad8C_0,1);
entry(DLG,13);
entry(DDIR,1);
u32 :16;
//+90
entry(TIMA,8);
entry(TACTL,3);
entry(pad90_0,5);
u32 :16;
//+94
entry(TIMB,8);
entry(TBCTL,3);
entry(pad94_0,5);
u32 :16;
//+98
entry(TIMC,8);
entry(TCCTL,3);
entry(pad98_0,5);
u32 :16;
//+9C
entry(SCIEB,11);
entry(pad9C_0,5);
u32 :16;
//+A0
entry(SCIPD,11);
entry(padA0_0,5);
u32 :16;
//+A4
entry(SCIRE,11);
entry(padA4_0,5);
u32 :16;
//+A8
entry(SCILV0,8);
entry(padA8_0,8);
u32 :16;
//+AC
entry(SCILV1,8);
entry(padAC_0,8);
u32 :16;
//+B0
entry(SCILV2,8);
entry(padB0_0,8);
u32 :16;
//+B4
entry(MCIEB,11);
entry(padB4_0,5)
u32 :16;
//+B8
entry(MCIPD,11);
entry(padB8_0,5)
u32 :16;
//+BC
entry(MCIRE,11);
entry(padBC_0,5)
u32 :16;
//some other misc shit FAR away is here :p
u8 pad_lot_0[0x344-4];
//+400 , hopefully :p
entry(AR,1);
entry(pad400_0,7);
entry(VREG,2);
entry(pad400_1,6);
u32 :16;
//Even more
u8 pad_lot_1[0x100-4];
//+500 , hopefully :p
entry(L0_r,1);
entry(L1_r,1);
entry(L2_r,1);
entry(L3_r,1);
entry(L4_r,1);
entry(L5_r,1);
entry(L6_r,1);
entry(L7_r,1);
entry(pad500_0,8);
u32 :16;
//+504
entry(M0_r,1);
entry(M1_r,1);
entry(M2_r,1);
entry(M3_r,1);
entry(M4_r,1);
entry(M5_r,1);
entry(M6_r,1);
entry(M7_r,1);
entry(RP,1);
entry(pad504_0,7);
u32 :16;
};
//should be 0x15C8 in size
struct DSPData_struct
{
//+0x000
u32 COEF[128]; //15:3
//+0x200
u32 MADRS[64]; //15:0
//+0x300
u8 PAD0[0x100];
//+0x400
u32 MPRO[128*4]; //15:0
//+0xC00
u8 PAD1[0x400];
//+0x1000
struct
{
u32 l; //7:0
u32 h; //15:0 (23:8)
}
TEMP[128];
//+0x1400
struct
{
u32 l; //7:0
u32 h; //15:0 (23:8)
}
MEMS[32];
//+0x1500
struct
{
u32 l; //3:0
u32 h; //15:0 (19:4)
}
MIXS[16];
//+0x1580
u32 EFREG[16]; //15:0
//+0x15C0
u32 EXTS[2]; //15:0
};
union InterruptInfo
{
struct
{
//Bit 0 (R): Requests interrupt to external interrupt input pin "INTON". (SCSI)
entry(INTON,1);
//Bit 1 (R): Reserved.
entry(res_1,1);
//Bit 2 (R): Reserved.
entry(res_3,1);
//Bit 3 (R): MIDI input interrupt.
//(Interrupt request generated when input FIFO has fetched valid data. Hence, if the CPU reads FIFO data, it must read the lot once and leave the FIFO empty. When the FIFO has changed to empty status, the interrupt request is canceled automatically.)
entry(MIDI_IN,1);
//Bit 4 (R): DMA end interrupt
entry(DMA_END,1);
//Bit 5 (R/W): SCPU interrupt caused by data being written to the CPU, so only "1" can be written. (Writing "0" has no effect.) This flag can be set from either the MCPU or the SCPU.
entry(SCPU,1);
//Bit 6 (R): Timer A interrupt
entry(TimerA,1);
//Bit 7 (R): Timer B interrupt
entry(TimerB,1);
//Bit 8 (R): Timer C interrupt
entry(TimerC,1);
//Bit 9 (R): MIDI output interrupt.
//(If the output FIFO changes to empty status, an interrupt request is generated.)
//(If the status is no longer empty because data is written to the output FIFO, the interrupt request is canceled automatically.)
entry(MIDI_OUT,1);
//Bit 10 (R): Interrupt of one sample interval
entry(SAMPLE_DONE,1);
};
u32 full;
};
struct AicaTimerData
{
union
{
struct
{
u32 count:8;
u32 md:3;
u32 nil:5;
u32 pad:16;
};
u32 data;
};
};
#pragma pack(pop)
#undef entry
////
//Timers :)
class AicaTimer
{
public:
AicaTimerData* data;
InterruptInfo* MCIPD;
InterruptInfo* SCIPD;
s32 c_step;
u32 m_step;
u32 id;
void Init(u8* regbase, InterruptInfo* MCIPD, InterruptInfo* SCIPD,u32 timer)
{
data=(AicaTimerData*)®base[0x2890 + timer*4];
this->MCIPD = MCIPD;
this->SCIPD = SCIPD;
id=timer;
m_step=1<<(data->md);
c_step=m_step;
}
void StepTimer(u32 samples)
{
do
{
c_step--;
if (c_step==0)
{
c_step=m_step;
data->count++;
if (data->count==0)
{
if (id==0)
{
SCIPD->TimerA=1;
MCIPD->TimerA=1;
}
else if (id==1)
{
SCIPD->TimerB=1;
MCIPD->TimerB=1;
}
else
{
SCIPD->TimerC=1;
MCIPD->TimerC=1;
}
}
}
} while(--samples);
}
void RegisterWrite()
{
u32 n_step=1<<(data->md);
if (n_step!=m_step)
{
m_step=n_step;
c_step=m_step;
}
}
};