1 /******************************************************************************
2 * Arachnoid Graphics Plugin for Mupen64Plus
3 * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/
5 * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *****************************************************************************/
22 #ifndef REALITY_SIGNAL_PROCESSOR_H_
23 #define REALITY_SIGNAL_PROCESSOR_H_
25 #define M64P_PLUGIN_PROTOTYPES 1
26 #include "m64p_plugin.h"
27 #include "UCodeDefs.h"
28 #include "RSPMatrixManager.h"
29 #include "RSPVertexManager.h"
32 //Forward declarations
37 class DisplayListParser;
38 class RSPLightManager;
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
46 #define RSP_TRI1 (RSP_1ST-0)
47 #define RSP_CULLDL (RSP_1ST-1)
48 #define RSP_POPMTX (RSP_1ST-2)
49 #define RSP_MOVEWORD (RSP_1ST-3)
50 #define RSP_TEXTURE (RSP_1ST-4)
51 #define RSP_SETOTHERMODE_H (RSP_1ST-5)
52 #define RSP_SETOTHERMODE_L (RSP_1ST-6)
53 #define RSP_ENDDL (RSP_1ST-7)
54 #define RSP_SETGEOMETRYMODE (RSP_1ST-8)
55 #define RSP_CLEARGEOMETRYMODE (RSP_1ST-9)
56 #define RSP_LINE3D (RSP_1ST-10)
57 #define RSP_RDPHALF_1 (RSP_1ST-11)
58 #define RSP_RDPHALF_2 (RSP_1ST-12)
59 #define RSP_RDPHALF_CONT (RSP_1ST-13)
61 #define RSP_MODIFYVTX (RSP_1ST-13)
62 #define RSP_TRI2 (RSP_1ST-14)
63 #define RSP_BRANCH_Z (RSP_1ST-15)
64 #define RSP_LOAD_UCODE (RSP_1ST-16)
66 #define RSP_SPRITE2D_SCALEFLIP (RSP_1ST-1)
67 #define RSP_SPRITE2D_DRAW (RSP_1ST-2)
69 // flags to inhibit pushing of the display list (on branch)
70 #define RSP_DLIST_PUSH 0x00
71 #define RSP_DLIST_NOPUSH 0x01
73 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
80 float x, y, width, height;
85 //-----------------------------------------------------------------------------
86 //! Struct used to store Information about Background Image
87 //-----------------------------------------------------------------------------
90 unsigned int address; //!< Where texture is stored (in RDRAM)
91 unsigned int width; //!< Width of texture
92 unsigned int height; //!< Height of texture
93 unsigned int format; //!< Format of texture
94 unsigned int size; //!< Size of texture
95 unsigned int palette; //!< What Texture Lookup Table to use
98 //-----------------------------------------------------------------------------
100 //! Struct used to store information about current texture on rsp
101 //-----------------------------------------------------------------------------
104 float scaleS, scaleT;
108 //-----------------------------------------------------------------------------
109 //! Singnal Processor Triangle
110 //-----------------------------------------------------------------------------
111 typedef SPVertex SPTriangle[3];
113 //*****************************************************************************
115 //! Class for emulating the Reality Signal Processor
116 //*****************************************************************************
126 bool initialize(GFX_INFO* graphicsInfo, RDP* rdp, Memory* memory, VI* vi, DisplayListParser* displayListParser, FogManager* fogMgr);
130 void updateGeometryStates();
133 void triggerInterrupt();
135 void moveSegment(int segmentID, int value);
137 void moveMemViewport(unsigned int segmentAddress);
139 RDPTile* getTile(int tile) { return m_textureTiles[tile]; }
140 void setTile(RDPTile* tile, int index) { m_textureTiles[index] = tile; }
141 RSPTexture& getTexture() { return m_texture; }
142 bool getTexturesChanged() { return m_texturesChanged; }
143 void setTexturesChanged(bool changed) { m_texturesChanged = changed; }
145 RSPMatrixManager* getMatrixMgr() { return m_matrixMgr; }
146 RSPVertexManager* getVertexMgr() { return m_vertexMgr; }
151 void RSP_Matrix( unsigned int segmentAddress, bool projectionMatrix, bool push, bool replace );
152 void RSP_PopMatrix();
153 void RSP_PopMatrixN(unsigned int num);
154 void RSP_InsertMatrix(unsigned int where, unsigned int num);
155 void RSP_DMAMatrix( unsigned int matrix, unsigned char index, unsigned char multiply );
156 void RSP_ForceMatrix( unsigned int segmentAddress );
157 void RSP_LookAt( unsigned int l );
158 void RSP_PerspNormalize( unsigned short scale );
161 void RSP_DisplayList(unsigned int segmentAddress);
162 void RSP_DMADisplayList( unsigned int w0, unsigned int w1 );
163 void RSP_CullDisplayList( unsigned int v0, unsigned int vn );
164 void RSP_BranchList( unsigned int dl );
165 void RSP_BranchLessZ( unsigned int branchdl, unsigned int vtx, float zval );
166 void RSP_EndDisplayList();
169 void RSP_Light( unsigned int lightIndex, unsigned int segmentAddress );
170 void RSP_NumLights( int n );
171 void RSP_LightColor( unsigned int lightIndex, unsigned int packedColor );
174 void RSP_Vertex(unsigned int segmentAddress, unsigned int numVertices, unsigned int firstVertexIndex);
175 void RSP_CIVertex(unsigned int segmentAddress, unsigned int numVertices, unsigned int firstVertexIndex);
176 void RSP_ModifyVertex( unsigned int vtx, unsigned int where, unsigned int val );
177 void RSP_SetVertexColor( unsigned int vtx, float r, float g, float b, float a);
178 void RSP_SetVertexTexCoord( unsigned int vtx, float s, float t);
180 void RSP_DMAVertex( unsigned int v, unsigned int n, unsigned int v0 );
181 void RSP_SetDMAOffsets( unsigned int mtxoffset, unsigned int vtxoffset );
182 void RSP_SetVertexColorBase(unsigned int segmentAddress);
185 void RSP_1Triangle( int v00, int v01, int v02 );
186 void RSP_2Triangles( int v00, int v01, int v02, int flag0,
187 int v10, int v11, int v12, int flag1 );
188 void RSP_4Triangles( int v00, int v01, int v02,
189 int v10, int v11, int v12,
190 int v20, int v21, int v22,
191 int v30, int v31, int v32 );
192 void RSP_DMATriangles( unsigned int tris, unsigned int n );
193 void RSP_1Quadrangle( int v0, int v1, int v2, int v4 );
196 void RSP_ObjRectangle( unsigned int sp );
197 void RSP_ObjSprite( unsigned int sp );
198 void RSP_ObjLoadTxtr( unsigned int tx );
199 void RSP_ObjLoadTxSprite( unsigned int txsp );
200 void RSP_ObjLoadTxRectR( unsigned int txsp );
201 void RSP_ObjMatrix( unsigned int mtx );
202 void RSP_ObjSubMatrix( unsigned int mtx );
205 void RSP_Line3D( int v0, int v1, int flag );
206 void RSP_LineW3D( int v0, int v1, int wd, int flag );
207 void RSP_BgRect1Cyc( unsigned int bg );
208 void RSP_BgRectCopy( unsigned int bg );
209 void RSP_Sprite2DBase( unsigned int base );
212 void RSP_GeometryMode( unsigned int clear, unsigned int set );
213 void RSP_SetGeometryMode( unsigned int mode );
214 void RSP_ClearGeometryMode( unsigned int mode );
217 void RSP_ClipRatio( unsigned int r );
220 void RSP_Texture( float sc, float tc, int level, int tile, int on );
223 void RSP_FogFactor( short fm, short fo );
226 void RSP_LoadUcodeEx( unsigned int uc_start, unsigned int uc_dstart, unsigned short uc_dsize );
230 //Pointers to big objects and managers
231 GFX_INFO* m_graphicsInfo; //!< Access to emulator data (like RDRAM ...)
232 VI* m_vi; //!< Videointerface
233 Memory* m_memory; //!< Memory managers (handles RDRAM, Texture Memory...)
234 DisplayListParser* m_displayListParser; //!< Display list parser
235 FogManager* m_fogMgr; //!< Manager that handles fog
236 RDP* m_rdp; //!< Pointer to Reality Drawing Processor
239 RSPMatrixManager* m_matrixMgr; //!< Handles matrix stack
240 RSPVertexManager* m_vertexMgr; //!< Vertex Manager, processes and modifies vertices
241 RSPLightManager* m_lightMgr; //!< Light Manager, handles lights
244 unsigned int m_geometryMode; //!< Contains states (lighting, shading, culling...)
247 RSPTexture m_texture;
248 RDPTile* m_textureTiles[2];
249 bool m_texturesChanged;