2 * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
4 * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5 * Jerremy Koot (jkoot@snes9x.com)
7 * Super FX C emulator code
8 * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
10 * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
12 * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13 * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14 * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
16 * DOS port code contains the works of other authors. See headers in
19 * Snes9x homepage: http://www.snes9x.com
21 * Permission to use, copy, modify and distribute Snes9x in both binary and
22 * source form, for non-commercial purposes, is hereby granted without fee,
23 * providing that this license information and copyright notice appear with
24 * all copies and any derived work.
26 * This software is provided 'as-is', without any express or implied
27 * warranty. In no event shall the authors be held liable for any damages
28 * arising from the use of this software.
30 * Snes9x is freeware for PERSONAL USE only. Commercial users should
31 * seek permission of the copyright holders first. Commercial use includes
32 * charging money for Snes9x or software derived from Snes9x.
34 * The copyright holders request that bug fixes and improvements to the code
35 * should be forwarded to them so everyone can benefit from the modifications
38 * Super NES and Super Nintendo Entertainment System are trademarks of
39 * Nintendo Co., Limited and its subsidiary companies.
44 // Simple vector and matrix types
45 typedef double MATRIX[3][3];
46 typedef double VECTOR[3];
48 enum AttitudeMatrix { MatrixA, MatrixB, MatrixC };
51 bool8 waiting4command;
52 bool8 first_parameter;
58 uint16 parameters [10];
66 // Matrix and translaton vector for
67 // transforming a 3D position into the global coordinate system,
68 // from the view space coordinate system.
75 // A precalculated value for optimization
78 // Raster position of horizon
81 // Convert a 2D screen coordinate to a 3D ground coordinate in global coordinate system.
82 void ScreenToGround(VECTOR &v, double X2d, double Y2d);
84 MATRIX &GetMatrix( AttitudeMatrix Matrix );
87 ///////////////// DSP Commands ////////////////////
92 DSP1_Parameter( int16 Fx, int16 Fy, int16 Fz,
93 uint16 Lfe, uint16 Les,
96 // Raster number of imaginary center
97 int16 Vof; // -32768 ~ +32767
99 // Raster number representing
101 int16 Vva; // -32768 ~ +32767
103 // X,Y coordinate of the point
104 // projected on the center of the screen
105 // (ground coordinate)
106 int16 Cx; // -32768 ~ +32767
107 int16 Cy; // -32768 ~ +32767
113 DSP1_Raster( int16 Vs );
115 // Linear transformation matrix elements
126 DSP1_Project( int16 x, int16 y, int16 z );
136 DSP1_Target( int16 h, int16 v );
145 DSP1_Triangle (int16 Theta, int16 r );
153 DSP1_Radius( int16 x, int16 y, int16 z );
159 int16 DSP1_Range( int16 x, int16 y, int16 z, int16 r );
162 int16 DSP1_Distance( int16 x, int16 y, int16 z );
167 DSP1_Rotate (int16 A, int16 x1, int16 y1);
176 DSP1_Polar( int8 Za, int8 Xa, int8 Ya, int16 x, int16 y, int16 z );
183 // DSP1 Command 01h, 11h and 21h
184 void DSP1_Attitude( int16 m, int8 Za, int8 Xa, int8 Ya, AttitudeMatrix Matrix );
186 // DSP1 Command 0Dh, 1Dh and 2Dh
187 struct DSP1_Objective
189 DSP1_Objective( int16 x, int16 y, int16 z, AttitudeMatrix Matrix );
196 // DSP1 Command 03h, 13h and 23h
197 struct DSP1_Subjective
199 DSP1_Subjective( int16 F, int16 L, int16 U, AttitudeMatrix Matrix );
206 // DSP1 Command 0Bh, 1Bh and 2Bh
207 int16 DSP1_Scalar( int16 x, int16 y, int16 z, AttitudeMatrix Matrix );
212 DSP1_Gyrate( int8 Zi, int8 Xi, int8 Yi,
213 int8 dU, int8 dF, int8 dL );
221 int16 DSP1_Multiply( int16 k, int16 I );
226 DSP1_Inverse( int16 a, int16 b );
233 void S9xResetDSP1 ();
234 uint8 S9xGetDSP (uint16 Address);
235 void S9xSetDSP (uint8 Byte, uint16 Address);
239 extern struct SDSP1 DSP1;
241 extern "C" struct SDSP1 DSP1;