Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/emulator/xnes/snes9x/dsp.h
28550 views
1
/***********************************************************************************
2
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3
4
(c) Copyright 1996 - 2002 Gary Henderson ([email protected]),
5
Jerremy Koot ([email protected])
6
7
(c) Copyright 2002 - 2004 Matthew Kendora
8
9
(c) Copyright 2002 - 2005 Peter Bortas ([email protected])
10
11
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
12
13
(c) Copyright 2001 - 2006 John Weidman ([email protected])
14
15
(c) Copyright 2002 - 2006 funkyass ([email protected]),
16
Kris Bleakley ([email protected])
17
18
(c) Copyright 2002 - 2010 Brad Jorsch ([email protected]),
19
Nach ([email protected]),
20
21
(c) Copyright 2002 - 2011 zones ([email protected])
22
23
(c) Copyright 2006 - 2007 nitsuja
24
25
(c) Copyright 2009 - 2011 BearOso,
26
OV2
27
28
29
BS-X C emulator code
30
(c) Copyright 2005 - 2006 Dreamer Nom,
31
zones
32
33
C4 x86 assembler and some C emulation code
34
(c) Copyright 2000 - 2003 _Demo_ ([email protected]),
35
Nach,
36
zsKnight ([email protected])
37
38
C4 C++ code
39
(c) Copyright 2003 - 2006 Brad Jorsch,
40
Nach
41
42
DSP-1 emulator code
43
(c) Copyright 1998 - 2006 _Demo_,
44
Andreas Naive ([email protected]),
45
Gary Henderson,
46
Ivar ([email protected]),
47
John Weidman,
48
Kris Bleakley,
49
Matthew Kendora,
50
Nach,
51
neviksti ([email protected])
52
53
DSP-2 emulator code
54
(c) Copyright 2003 John Weidman,
55
Kris Bleakley,
56
Lord Nightmare ([email protected]),
57
Matthew Kendora,
58
neviksti
59
60
DSP-3 emulator code
61
(c) Copyright 2003 - 2006 John Weidman,
62
Kris Bleakley,
63
Lancer,
64
z80 gaiden
65
66
DSP-4 emulator code
67
(c) Copyright 2004 - 2006 Dreamer Nom,
68
John Weidman,
69
Kris Bleakley,
70
Nach,
71
z80 gaiden
72
73
OBC1 emulator code
74
(c) Copyright 2001 - 2004 zsKnight,
75
pagefault ([email protected]),
76
Kris Bleakley
77
Ported from x86 assembler to C by sanmaiwashi
78
79
SPC7110 and RTC C++ emulator code used in 1.39-1.51
80
(c) Copyright 2002 Matthew Kendora with research by
81
zsKnight,
82
John Weidman,
83
Dark Force
84
85
SPC7110 and RTC C++ emulator code used in 1.52+
86
(c) Copyright 2009 byuu,
87
neviksti
88
89
S-DD1 C emulator code
90
(c) Copyright 2003 Brad Jorsch with research by
91
Andreas Naive,
92
John Weidman
93
94
S-RTC C emulator code
95
(c) Copyright 2001 - 2006 byuu,
96
John Weidman
97
98
ST010 C++ emulator code
99
(c) Copyright 2003 Feather,
100
John Weidman,
101
Kris Bleakley,
102
Matthew Kendora
103
104
Super FX x86 assembler emulator code
105
(c) Copyright 1998 - 2003 _Demo_,
106
pagefault,
107
zsKnight
108
109
Super FX C emulator code
110
(c) Copyright 1997 - 1999 Ivar,
111
Gary Henderson,
112
John Weidman
113
114
Sound emulator code used in 1.5-1.51
115
(c) Copyright 1998 - 2003 Brad Martin
116
(c) Copyright 1998 - 2006 Charles Bilyue'
117
118
Sound emulator code used in 1.52+
119
(c) Copyright 2004 - 2007 Shay Green ([email protected])
120
121
SH assembler code partly based on x86 assembler code
122
(c) Copyright 2002 - 2004 Marcus Comstedt ([email protected])
123
124
2xSaI filter
125
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
126
127
HQ2x, HQ3x, HQ4x filters
128
(c) Copyright 2003 Maxim Stepin ([email protected])
129
130
NTSC filter
131
(c) Copyright 2006 - 2007 Shay Green
132
133
GTK+ GUI code
134
(c) Copyright 2004 - 2011 BearOso
135
136
Win32 GUI code
137
(c) Copyright 2003 - 2006 blip,
138
funkyass,
139
Matthew Kendora,
140
Nach,
141
nitsuja
142
(c) Copyright 2009 - 2011 OV2
143
144
Mac OS GUI code
145
(c) Copyright 1998 - 2001 John Stiles
146
(c) Copyright 2001 - 2011 zones
147
148
149
Specific ports contains the works of other authors. See headers in
150
individual files.
151
152
153
Snes9x homepage: http://www.snes9x.com/
154
155
Permission to use, copy, modify and/or distribute Snes9x in both binary
156
and source form, for non-commercial purposes, is hereby granted without
157
fee, providing that this license information and copyright notice appear
158
with all copies and any derived work.
159
160
This software is provided 'as-is', without any express or implied
161
warranty. In no event shall the authors be held liable for any damages
162
arising from the use of this software or it's derivatives.
163
164
Snes9x is freeware for PERSONAL USE only. Commercial users should
165
seek permission of the copyright holders first. Commercial use includes,
166
but is not limited to, charging money for Snes9x or software derived from
167
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
168
using Snes9x as a promotion for your commercial product.
169
170
The copyright holders request that bug fixes and improvements to the code
171
should be forwarded to them so everyone can benefit from the modifications
172
in future versions.
173
174
Super NES and Super Nintendo Entertainment System are trademarks of
175
Nintendo Co., Limited and its subsidiary companies.
176
***********************************************************************************/
177
178
179
#ifndef _DSP1_H_
180
#define _DSP1_H_
181
182
enum
183
{
184
M_DSP1_LOROM_S,
185
M_DSP1_LOROM_L,
186
M_DSP1_HIROM,
187
M_DSP2_LOROM,
188
M_DSP3_LOROM,
189
M_DSP4_LOROM
190
};
191
192
struct SDSP0
193
{
194
uint32 maptype;
195
uint32 boundary;
196
};
197
198
struct SDSP1
199
{
200
bool8 waiting4command;
201
bool8 first_parameter;
202
uint8 command;
203
uint32 in_count;
204
uint32 in_index;
205
uint32 out_count;
206
uint32 out_index;
207
uint8 parameters[512];
208
uint8 output[512];
209
210
int16 CentreX;
211
int16 CentreY;
212
int16 VOffset;
213
214
int16 VPlane_C;
215
int16 VPlane_E;
216
217
// Azimuth and Zenith angles
218
int16 SinAas;
219
int16 CosAas;
220
int16 SinAzs;
221
int16 CosAzs;
222
223
// Clipped Zenith angle
224
int16 SinAZS;
225
int16 CosAZS;
226
int16 SecAZS_C1;
227
int16 SecAZS_E1;
228
int16 SecAZS_C2;
229
int16 SecAZS_E2;
230
231
int16 Nx;
232
int16 Ny;
233
int16 Nz;
234
int16 Gx;
235
int16 Gy;
236
int16 Gz;
237
int16 C_Les;
238
int16 E_Les;
239
int16 G_Les;
240
241
int16 matrixA[3][3];
242
int16 matrixB[3][3];
243
int16 matrixC[3][3];
244
245
int16 Op00Multiplicand;
246
int16 Op00Multiplier;
247
int16 Op00Result;
248
249
int16 Op20Multiplicand;
250
int16 Op20Multiplier;
251
int16 Op20Result;
252
253
int16 Op10Coefficient;
254
int16 Op10Exponent;
255
int16 Op10CoefficientR;
256
int16 Op10ExponentR;
257
258
int16 Op04Angle;
259
int16 Op04Radius;
260
int16 Op04Sin;
261
int16 Op04Cos;
262
263
int16 Op0CA;
264
int16 Op0CX1;
265
int16 Op0CY1;
266
int16 Op0CX2;
267
int16 Op0CY2;
268
269
int16 Op02FX;
270
int16 Op02FY;
271
int16 Op02FZ;
272
int16 Op02LFE;
273
int16 Op02LES;
274
int16 Op02AAS;
275
int16 Op02AZS;
276
int16 Op02VOF;
277
int16 Op02VVA;
278
int16 Op02CX;
279
int16 Op02CY;
280
281
int16 Op0AVS;
282
int16 Op0AA;
283
int16 Op0AB;
284
int16 Op0AC;
285
int16 Op0AD;
286
287
int16 Op06X;
288
int16 Op06Y;
289
int16 Op06Z;
290
int16 Op06H;
291
int16 Op06V;
292
int16 Op06M;
293
294
int16 Op01m;
295
int16 Op01Zr;
296
int16 Op01Xr;
297
int16 Op01Yr;
298
299
int16 Op11m;
300
int16 Op11Zr;
301
int16 Op11Xr;
302
int16 Op11Yr;
303
304
int16 Op21m;
305
int16 Op21Zr;
306
int16 Op21Xr;
307
int16 Op21Yr;
308
309
int16 Op0DX;
310
int16 Op0DY;
311
int16 Op0DZ;
312
int16 Op0DF;
313
int16 Op0DL;
314
int16 Op0DU;
315
316
int16 Op1DX;
317
int16 Op1DY;
318
int16 Op1DZ;
319
int16 Op1DF;
320
int16 Op1DL;
321
int16 Op1DU;
322
323
int16 Op2DX;
324
int16 Op2DY;
325
int16 Op2DZ;
326
int16 Op2DF;
327
int16 Op2DL;
328
int16 Op2DU;
329
330
int16 Op03F;
331
int16 Op03L;
332
int16 Op03U;
333
int16 Op03X;
334
int16 Op03Y;
335
int16 Op03Z;
336
337
int16 Op13F;
338
int16 Op13L;
339
int16 Op13U;
340
int16 Op13X;
341
int16 Op13Y;
342
int16 Op13Z;
343
344
int16 Op23F;
345
int16 Op23L;
346
int16 Op23U;
347
int16 Op23X;
348
int16 Op23Y;
349
int16 Op23Z;
350
351
int16 Op14Zr;
352
int16 Op14Xr;
353
int16 Op14Yr;
354
int16 Op14U;
355
int16 Op14F;
356
int16 Op14L;
357
int16 Op14Zrr;
358
int16 Op14Xrr;
359
int16 Op14Yrr;
360
361
int16 Op0EH;
362
int16 Op0EV;
363
int16 Op0EX;
364
int16 Op0EY;
365
366
int16 Op0BX;
367
int16 Op0BY;
368
int16 Op0BZ;
369
int16 Op0BS;
370
371
int16 Op1BX;
372
int16 Op1BY;
373
int16 Op1BZ;
374
int16 Op1BS;
375
376
int16 Op2BX;
377
int16 Op2BY;
378
int16 Op2BZ;
379
int16 Op2BS;
380
381
int16 Op28X;
382
int16 Op28Y;
383
int16 Op28Z;
384
int16 Op28R;
385
386
int16 Op1CX;
387
int16 Op1CY;
388
int16 Op1CZ;
389
int16 Op1CXBR;
390
int16 Op1CYBR;
391
int16 Op1CZBR;
392
int16 Op1CXAR;
393
int16 Op1CYAR;
394
int16 Op1CZAR;
395
int16 Op1CX1;
396
int16 Op1CY1;
397
int16 Op1CZ1;
398
int16 Op1CX2;
399
int16 Op1CY2;
400
int16 Op1CZ2;
401
402
uint16 Op0FRamsize;
403
uint16 Op0FPass;
404
405
int16 Op2FUnknown;
406
int16 Op2FSize;
407
408
int16 Op08X;
409
int16 Op08Y;
410
int16 Op08Z;
411
int16 Op08Ll;
412
int16 Op08Lh;
413
414
int16 Op18X;
415
int16 Op18Y;
416
int16 Op18Z;
417
int16 Op18R;
418
int16 Op18D;
419
420
int16 Op38X;
421
int16 Op38Y;
422
int16 Op38Z;
423
int16 Op38R;
424
int16 Op38D;
425
};
426
427
struct SDSP2
428
{
429
bool8 waiting4command;
430
uint8 command;
431
uint32 in_count;
432
uint32 in_index;
433
uint32 out_count;
434
uint32 out_index;
435
uint8 parameters[512];
436
uint8 output[512];
437
438
bool8 Op05HasLen;
439
int32 Op05Len;
440
uint8 Op05Transparent;
441
442
bool8 Op06HasLen;
443
int32 Op06Len;
444
445
uint16 Op09Word1;
446
uint16 Op09Word2;
447
448
bool8 Op0DHasLen;
449
int32 Op0DOutLen;
450
int32 Op0DInLen;
451
};
452
453
struct SDSP3
454
{
455
uint16 DR;
456
uint16 SR;
457
uint16 MemoryIndex;
458
459
int16 WinLo;
460
int16 WinHi;
461
int16 AddLo;
462
int16 AddHi;
463
464
uint16 Codewords;
465
uint16 Outwords;
466
uint16 Symbol;
467
uint16 BitCount;
468
uint16 Index;
469
uint16 Codes[512];
470
uint16 BitsLeft;
471
uint16 ReqBits;
472
uint16 ReqData;
473
uint16 BitCommand;
474
uint8 BaseLength;
475
uint16 BaseCodes;
476
uint16 BaseCode;
477
uint8 CodeLengths[8];
478
uint16 CodeOffsets[8];
479
uint16 LZCode;
480
uint8 LZLength;
481
482
uint16 X;
483
uint16 Y;
484
485
uint8 Bitmap[8];
486
uint8 Bitplane[8];
487
uint16 BMIndex;
488
uint16 BPIndex;
489
uint16 Count;
490
491
int16 op3e_x;
492
int16 op3e_y;
493
494
int16 op1e_terrain[0x2000];
495
int16 op1e_cost[0x2000];
496
int16 op1e_weight[0x2000];
497
498
int16 op1e_cell;
499
int16 op1e_turn;
500
int16 op1e_search;
501
502
int16 op1e_x;
503
int16 op1e_y;
504
505
int16 op1e_min_radius;
506
int16 op1e_max_radius;
507
508
int16 op1e_max_search_radius;
509
int16 op1e_max_path_radius;
510
511
int16 op1e_lcv_radius;
512
int16 op1e_lcv_steps;
513
int16 op1e_lcv_turns;
514
};
515
516
struct SDSP4
517
{
518
bool8 waiting4command;
519
bool8 half_command;
520
uint16 command;
521
uint32 in_count;
522
uint32 in_index;
523
uint32 out_count;
524
uint32 out_index;
525
uint8 parameters[512];
526
uint8 output[512];
527
uint8 byte;
528
uint16 address;
529
530
// op control
531
int8 Logic; // controls op flow
532
533
// projection format
534
int16 lcv; // loop-control variable
535
int16 distance; // z-position into virtual world
536
int16 raster; // current raster line
537
int16 segments; // number of raster lines drawn
538
539
// 1.15.16 or 1.15.0 [sign, integer, fraction]
540
int32 world_x; // line of x-projection in world
541
int32 world_y; // line of y-projection in world
542
int32 world_dx; // projection line x-delta
543
int32 world_dy; // projection line y-delta
544
int16 world_ddx; // x-delta increment
545
int16 world_ddy; // y-delta increment
546
int32 world_xenv; // world x-shaping factor
547
int16 world_yofs; // world y-vertical scroll
548
int16 view_x1; // current viewer-x
549
int16 view_y1; // current viewer-y
550
int16 view_x2; // future viewer-x
551
int16 view_y2; // future viewer-y
552
int16 view_dx; // view x-delta factor
553
int16 view_dy; // view y-delta factor
554
int16 view_xofs1; // current viewer x-vertical scroll
555
int16 view_yofs1; // current viewer y-vertical scroll
556
int16 view_xofs2; // future viewer x-vertical scroll
557
int16 view_yofs2; // future viewer y-vertical scroll
558
int16 view_yofsenv; // y-scroll shaping factor
559
int16 view_turnoff_x; // road turnoff data
560
int16 view_turnoff_dx; // road turnoff delta factor
561
562
// drawing area
563
int16 viewport_cx; // x-center of viewport window
564
int16 viewport_cy; // y-center of render window
565
int16 viewport_left; // x-left of viewport
566
int16 viewport_right; // x-right of viewport
567
int16 viewport_top; // y-top of viewport
568
int16 viewport_bottom; // y-bottom of viewport
569
570
// sprite structure
571
int16 sprite_x; // projected x-pos of sprite
572
int16 sprite_y; // projected y-pos of sprite
573
int16 sprite_attr; // obj attributes
574
bool8 sprite_size; // sprite size: 8x8 or 16x16
575
int16 sprite_clipy; // visible line to clip pixels off
576
int16 sprite_count;
577
578
// generic projection variables designed for two solid polygons + two polygon sides
579
int16 poly_clipLf[2][2]; // left clip boundary
580
int16 poly_clipRt[2][2]; // right clip boundary
581
int16 poly_ptr[2][2]; // HDMA structure pointers
582
int16 poly_raster[2][2]; // current raster line below horizon
583
int16 poly_top[2][2]; // top clip boundary
584
int16 poly_bottom[2][2]; // bottom clip boundary
585
int16 poly_cx[2][2]; // center for left/right points
586
int16 poly_start[2]; // current projection points
587
int16 poly_plane[2]; // previous z-plane distance
588
589
// OAM
590
int16 OAM_attr[16]; // OAM (size, MSB) data
591
int16 OAM_index; // index into OAM table
592
int16 OAM_bits; // offset into OAM table
593
int16 OAM_RowMax; // maximum number of tiles per 8 aligned pixels (row)
594
int16 OAM_Row[32]; // current number of tiles per row
595
};
596
597
extern struct SDSP0 DSP0;
598
extern struct SDSP1 DSP1;
599
extern struct SDSP2 DSP2;
600
extern struct SDSP3 DSP3;
601
extern struct SDSP4 DSP4;
602
603
uint8 S9xGetDSP (uint16);
604
void S9xSetDSP (uint8, uint16);
605
void S9xResetDSP (void);
606
uint8 DSP1GetByte (uint16);
607
void DSP1SetByte (uint8, uint16);
608
uint8 DSP2GetByte (uint16);
609
void DSP2SetByte (uint8, uint16);
610
uint8 DSP3GetByte (uint16);
611
void DSP3SetByte (uint8, uint16);
612
uint8 DSP4GetByte (uint16);
613
void DSP4SetByte (uint8, uint16);
614
void DSP3_Reset (void);
615
616
extern uint8 (*GetDSP) (uint16);
617
extern void (*SetDSP) (uint8, uint16);
618
619
#endif
620
621