Debian Codegraph @

docs/DSP/wwdsp.c

raw symbols SCIP
1 /* important variables */
2 short mem[0x1000];
3 #define v_0341 mem[0x0341] /* op#2 saves a copy of 344 here */
4 #define v_0343 mem[0x0343] /* message type? */
5 #define v_0344 mem[0x0344] /* low byte of first word of message */
6 #define v_0345 mem[0x0345] /* copy of second word of message */
7 #define a_0346 mem[0x0346] /* buffer for message contents, size unknown */
8 #define v_034e mem[0x034e] /* init to 0, later set to most recent value written in a_04fc */
9
10 #define v_0350 mem[0x0350] /* init to 0x0280 (write location of messages) */
11 #define v_0351 mem[0x0351] /* init to 0x0280 (read location?) */
12 #define v_0352 mem[0x0352] /* init to 0 (number of messages pending?) */
13 #define v_0355 mem[0x0355] /* used by op#2, init to 0 */
14 #define a_0356 (mem+0x0356) /* message contents */
15
16 #define a_0388 (mem+0x388) /* where op 2 keeps its message */
17 #define a_038e (mem+0x38e) /* op#2 saves a copy of 345 here */
18
19 #define a_03a8 (mem+0x3a8) /* where op#2 dmas in its data, at least 0x80 */
20
21 #define v_03fa mem[0x03fa] /* temp for ax0.h during exception */
22 #define v_03fb mem[0x03fb] /* temp for ar0 during exception */
23 #define v_03fc mem[0x03fc] /* temp for r08 during exception */
24 #define v_03fd mem[0x03fd] /* temp for ac0.h during exception */
25 #define v_03fe mem[0x03fe] /* temp for ac0.m during exception */
26 #define v_03ff mem[0x03ff] /* temp for ac0.l during exception */
27
28 #define a_04e8 (mem+0x04e8) /* 4 element array */
29 #define a_04ec (mem+0x04ec) /* 4 element array (empty) */
30 #define a_04f0 (mem+0x04f0) /* 4 element array */
31 #define a_04f4 (mem+0x04f4) /* 4 element array (empty) */
32 #define a_04fc (mem+0x04fc) /* 16 element array, written by messages */
33 #define a_09a0 (mem+0x09a0) /* 0x50 element array, used by op#2, cleared */
34 #define a_0a00 (mem+0x0a00) /* 0x50 element array, used by op#2, cleared */
35 #define a_0b00 (mem+0x0b00) /* array from 0x0b00-0x0bff, involves accelerator? */
36 #define a_0ca0 (mem+0x0ca0) /* 0x50 element array, used by op#2, cleared */
37 #define a_0d00 (mem+0x0d00) /* 0x50 element array, used by op#2, cleared */
38 #define a_0d60 (mem+0x0d60) /* 0x50 element array, used by op#2, cleared */
39 #define a_0f40 (mem+0x0f40) /* 0x50 element array, used by op#2, cleared */
40
41
42
43 /* reset exception vector 0x0000 */
44 void main() {
45 /* JMP 0x0012 */
46 /* various inits */
47 SBCLR(5); /* disable interrupts? */
48 fcn_0057(); /* init hardware stuff */
49 for(ac1.m=0x1000,ac0.m=0;ac1.m>0;ac1.m--) mem[ac0.m++]=0; /* clear all vars */
50 fcn_0688(); /* init some vars */
51 fcn_04c0(); /* set something up related to the accelerator at a_0b00 */
52 fcn_0e14(); /* set up a table */
53 fcn_066a(0); /* send a message */
54 fcn_0674(0x1111); /* send a message */
55 v_034e=0;
56 SBSET(5); /* enable interrupts? */
57
58 /* jump to 0x06c5 */
59 mainloop:
60 while (v_0352) ; /* while no messages pending */
61
62 SBCLR(5); /* do not distrub */
63 v_0352--; /* important that this be atomic */
64 SBSET(5);
65
66 t=v_0351;
67 size=mem[t++];
68 if (!(size&0x8000)) { /* size > 0x7fff invalid */
69 if (size==0) { /* die on message of length 0? */
70 /* jump to 0x06f5 */
71 /* jump to 0x05f0 */
72
73 /* TODO: analysis of HALT */
74 HALT();
75 }
76 for (i=size,j=0;i>0;i--) {
77 a_0356[j++]=mem[t++];
78 a_0356[j++]=mem[t++];
79 }
80 v_0351=t;
81
82 /* jump to 0x002f */
83 /* actual command handling */
84 v_0345=a_0356[1];
85 v_0344=a_0356[0]&0x00ff;
86 v_0343=(a_0346[0]>>7)&0x7e;
87
88 /* jump table at 0x75 used here */
89 switch (v_0343>>1) {
90
91 // 0x43
92 case 0:
93 case 10:
94 case 11:
95 case 12:
96 case 14:
97 case 15:
98 /* invalid command? */
99 config=0x00ff;
100 fcn_066a(0x04); /* send off a message */
101 fcn_0674(a_0356[0]); /* send first word of command as a message */
102 goto mainloop;
103 break;
104 case 1:
105 /* jmp 0x0095 */
106 break;
107
108 case 2:
109 /* jmp 0x0243 */
110 sub_0243();
111 break;
112
113 case 3:
114 /* jmp 0x0073 */
115 break;
116
117 case 4:
118 /* jmp 0x580 */
119 break;
120
121 case 5:
122 /* jmp 0x592 */
123 break;
124
125 case 6:
126 /* jmp 0x469 */
127 break;
128
129 case 7:
130 /* jmp 0x41d */
131 break;
132
133 case 8: /* mix */
134 /* jmp 0x0485 */
135 fcn_0067(fcn_0067(0x0346)); /* read message twice? */
136 /* take in the two buffers to mix */
137 fcn_0525(mem[0x344],mem[0x346],mem[0x347],0x400); /* size, addrH, addrL, dsp addr */
138 fcn_0525(mem[0x344],mem[0x348],mem[0x349],0x800);
139 S16(); /* saturate all adds, multiplies to 16 bits? */
140
141 i=mem[0x0344];
142 src1=0x400;
143 src2=0x800;
144 scale=mem[0x345];
145
146 prod=scale*mem[src2++];
147 val2=mem[src2++];
148 do {
149 val1=mem[src1];
150 val1+=prod;
151 prod=scale*val2;
152 mem[src1]=val1;
153 val2=mem[src2];
154 src1++;
155 src2++;
156 } while (--i);
157
158 S40();
159
160 /* dma out mixed buf */
161 fcn_0523(mem[0x344],mem[0x346],mem[0x347],0x400);
162
163 break;
164
165 case 9:
166 /* jmp 0x44d */
167 break;
168
169 case 13:
170 /* jmp 0x00b2 */
171 break;
172 }
173 }
174
175 v_0351=t;
176
177 goto mainloop;
178 }
179
180 /* message in MBOX exception vector? 0x000e */
181 void exception() {
182 /* JMP 0x05b8 */
183
184 SBCLR(5);
185 S40();
186 /* save ax0.h,ac0.h,ac0.m, and ac0.l */
187
188 if ((tH=register_fffe)&0x8000) { /* CPU mailbox H */
189 if (!(tsize=register_ffff)) { /* CPU mailbox L */
190 /* empty message? */
191 while (!((tH=register_fffe)&0x8000)) ;
192 tH&=0xf;
193 v_034e=(tH+1)<<4;
194 a_04fc[tH]=register_ffff;
195 } else { /* nonempty message? */
196 /* jump to 0x0692 */
197 /* save ar0, r08 */
198 t=v_0350;
199 mem[t++]=tsize;
200
201 do {
202 while (!((tH=register_fffe)&0x8000)) ;
203 mem[t++]=tH;
204 mem[t++]=register_ffff;
205 } while (--tsize);
206
207 v_0350=t;
208 v_0352++;
209 /* restore ar0, r08 */
210
211 /* jump to 0x05e6 */
212 }
213 } else { /* interrupt without message? */
214 /* jump to 0x06b9 */
215 /* save ar0, r08 */
216 mem[v_0350]=0; /* empty message */
217 /* jump to 0x06ab */
218 v_0350++;
219 v_0352++;
220 /* restore ar0, r08 */
221
222 /* jump to 0x05e6 */
223 }
224
225 /* 0x05e6 */
226
227 /* restore ax0.h,ac0.h,ac0.m, and ac0.l */
228 SBSET(5);
229 /* RTI */
230 }
231
232 /* set up some registers */
233 void fcn_0057() {
234 SBCLR(2);
235 SBCLR(3);
236 SBCLR(4);
237 SBCLR(6);
238 S40(); /* 40-bit mode */
239 CLR15();
240 M0(); /* don't multiply result by 2 */
241 r08=-1;
242 r09=-1;
243 r0a=-1;
244 r0b=-1;
245 config=0xff;
246 }
247
248 void fcn_0688() {
249 v_0350=0x0280;
250 v_0351=0x0280;
251 v_0352=0;
252 }
253
254 void fcn_04c0() {
255 config=0xff;
256 for(i=0xff,ar0=0xb00;i>0;i--) mem[ar0++]=0;
257 mem[ar0++]=0; /* get the last one */
258 fcn_0573(0x0b00,0x0100,0);
259 }
260
261 /* a=an address in ac1.m, l=a length in ar0, v=a value? in ac0.m */
262 void fcn_0573(short a, short l, short v) {
263 fcn_0561(a,l,0x0001);
264 }
265
266 /* a=an address in ac1.m, l=a length in ar0, v=a value? in ac0.m, f is a flag? in ac0.h */
267 /* return is in ax0.h */
268 short fcn_0561(short a, short l, short v, short f) {
269 register_ffd1=0x0a; /* unknown reg, accel? */
270 register_ffd6=-1; /* accel end addr H */
271 register_ffd7=-1; /* accel end addr L */
272 register_ffd8=v>>1; /*
273 register_ffd9=?; /* has a value from way back? */
274
275 return f;
276 }
277
278 /* initializes some tables that look useful... */
279 void fcn_0e14() {
280 a_04e8[0]=0x8240;
281 a_04e8[1]=0x7fff;
282 a_04e8[2]=0x7dbf;
283 a_04e8[3]=0x843f;
284 a_04f0[0]=0xb23b;
285 a_04f0[1]=0x7fff;
286 a_04f0[2]=0x4dc4;
287 a_04f0[3]=0xd808;
288 a_04ec[0]=a_04ec[1]=a_04ec[2]=a_04ec[3]=0;
289 a_04f4[0]=a_04f4[1]=a_04f4[2]=a_04f4[3]=0;
290 }
291
292 /* send a message via DSP MBOX */
293 void fcn_066a(short m) {
294 fcn_0682(); /* wait for empty mbox */
295 register_fffc=0xdcd1;
296 register_fffd=m;
297 register_fffb=1; /* IRQ */
298 fcn_0682();
299 }
300
301 /* wait for dsp mbox empty */
302 void fcn_0682() {
303 while (register_fffc&0x8000);
304 }
305
306 void fcn_0674(short m) {
307 fcn_0682();
308 register_fffc=0xf355;
309 register_fffd=m;
310 fcn_0682();
311 }
312
313 /* a=address in ar0 */
314 /* fetch a message body (up to zero)? */
315 short fcn_0067(short a) {
316 i=0x0357;
317 j=a;
318 do {
319 mem[j++]=mem[i++];
320 mem[j++]=mem[i];
321 } while (mem[i++]);
322 return a;
323 }
324
325 /* dma in, I assume */
326 /* size=words to transfer in ar0, addrL=low word of RAM address in ac0.l, addrH=high word of RAM address in ac0.m, dspaddr=dsp address in ac1.m */
327 void fcn_0525(short size, short addrH, short addrL, short dspaddr) {
328 register_ffcd=dspaddr; /* dsp address */
329 register_ffc9=0; /* direction: ram->dsp */
330 register_ffce=addrH; /* memory address H */
331 register_ffcf=addrL; /* memory address L */
332 register_ffcb=size<<1; /* bytes to transfer (size must be in words) */
333 fcn_0536(); /* dma wait */
334 }
335
336 /* dma wait? */
337 void fcn_0536() {
338 while (!(register_ffc9&4));
339 }
340
341 /* dma out, I assume */
342 /* size=words to transfer in ar0, addrL=low word of RAM address is ac0.l, addrH=high word of RAM address in ac0.m, dspaddr=dsp address in ac1.m */
343 /* shares code with fcn_0525 */
344 void fcn_0523(short size, short addrH, short addrL, shot dspaddr) {
345 register_ffcd=dspaddr;
346 /* jump back into 0525 */
347 register_ffc9=1; /* direction dsp->ram */
348 register_ffce=addrH;
349 register_ffcf=addrL;
350 register_ffcb=size<<1;
351 fcn_0536();
352 }
353
354 /* huge subroutine, op #2 */
355 void sub_0243() {
356 fcn_0067(0x0388); /* called in an indirect manner... */
357 v_0341=v_0344; /* low byte first word of message */
358 v_038e=v_0345;
359 v_0355=0;
360 fcn_022a(); /* get stuffs */
361 fcn_05a4(); /* write to accel */
362
363 for (i=v_0341;i>0i--) {
364 fcn_0102();
365
366 }
367 }
368
369 void fcn_022a() {
370 /* something else must set 386, 387 */
371 fcn_0525(0x0040,v_0386,v_0387,0x03a8);
372 }
373
374 void fcn_05a4() {
375 register_ffd4=-1;
376 register_ffd5=-1;
377 register_ffd6=-1;
378 register_ffd7=-1;
379 }
380
381 void fcn_0102() {
382 for (i=0;i<0x50;i++) a_0d00[i]=0;
383 for (i=0;i<0x50;i++) a_0d60[i]=0;
384 fcn_0e3f();
385 for (i=0;i<0x50;i++) a_0ca0[i]=0;
386 for (i=0;i<0x50;i++) a_0f40[i]=0;
387 for (i=0;i<0x50;i++) a_0fa0[i]=0;
388 for (i=0;i<0x50;i++) a_0a00[i]=0;
389 for (i=0;i<0x50;i++) a_09a0[i]=0;
390 }
391
392 void fcn_0e3f() {
393 fcn_00fa(0x0f40,0x0b00,0x50,0x6784);
394 fcn_0ba4(0x04e8,0x0b00,0x04ec);
395 }
396
397 /* addr1=address in ar0, addr2=address in ar3, size=size of table at addr1 in ac1.m, val=in ax0.l */
398 void fcn_00fa(short addr1, short addr2, short size, short val) {
399 M2(); /* all multiplications 2x */
400
401 tmp=mem[addr1++];
402 prod=val*tmp*2;
403 tmp=mem[addr1++];
404 ac0.m=prod;
405 prod=val*tmp*2;
406 tmp=mem[addr1++];
407
408 do {
409 ac0.m=prod;
410 prod=val*tmp*2;
411 mem[addr2]=ac0.m;
412 tmp=mem[addr1];
413 addr1++;
414 addr2++;
415 } while (--size);
416
417 M0();
418 }
419
420 /* addr1=address in ar0 (source 4 element table?), addr2=address in ar1 (accelerator?), addr3=address in ar2 (destination 4 element table?) */
421 void fcn_00ba4(short addr1, short addr2, short addr3) {
422
423 }