| 1 | /****************************************************************************** |
| 2 | * Arachnoid Graphics Plugin for Mupen64Plus |
| 3 | * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ |
| 4 | * |
| 5 | * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson |
| 6 | * |
| 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. |
| 11 | * |
| 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. |
| 16 | * |
| 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 | *****************************************************************************/ |
| 21 | |
| 22 | #include "UCode4.h" |
| 23 | #include "UCode0.h" |
| 24 | #include "GBI.h" |
| 25 | #include "RSP.h" |
| 26 | #include "UCodeDefs.h" |
| 27 | #include "GBIDefs.h" |
| 28 | #include "Logger.h" |
| 29 | |
| 30 | #define F3DWRUS_TRI2 0xB1 |
| 31 | |
| 32 | //----------------------------------------------------------------------------- |
| 33 | // Static Variables |
| 34 | //----------------------------------------------------------------------------- |
| 35 | GBI* UCode4::m_gbi = 0; |
| 36 | RSP* UCode4::m_rsp = 0; //!< Pointer to Reality Signal Processor |
| 37 | |
| 38 | //----------------------------------------------------------------------------- |
| 39 | //! Constructor |
| 40 | //----------------------------------------------------------------------------- |
| 41 | UCode4::UCode4() |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | //----------------------------------------------------------------------------- |
| 46 | //! Destructor |
| 47 | //----------------------------------------------------------------------------- |
| 48 | UCode4::~UCode4() |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | //----------------------------------------------------------------------------- |
| 53 | //! Initialize |
| 54 | //----------------------------------------------------------------------------- |
| 55 | void UCode4::initialize(GBI* gbi, RSP* rsp) |
| 56 | { |
| 57 | m_gbi = gbi; |
| 58 | m_rsp = rsp; |
| 59 | } |
| 60 | |
| 61 | //----------------------------------------------------------------------------- |
| 62 | //! Initialize GBI |
| 63 | //----------------------------------------------------------------------------- |
| 64 | void UCode4::initializeGBI() |
| 65 | { |
| 66 | UCode0::initializeGBI(m_gbi); |
| 67 | |
| 68 | //Init special Wave Race functions |
| 69 | GBI_SetGBI( GBI::G_VTX, F3D_VTX, m_gbi->m_cmds, WaveRace64_Vertex ); |
| 70 | GBI_SetGBI( GBI::G_TRI1, F3D_TRI1, m_gbi->m_cmds, WaveRace64_Tri1 ); |
| 71 | GBI_SetGBI( GBI::G_QUAD, F3D_QUAD, m_gbi->m_cmds, WaveRace64_Quad ); |
| 72 | GBI_SetGBI( GBI::G_TRI2, F3DWRUS_TRI2, m_gbi->m_cmds, WaveRace64_Tri2 ); |
| 73 | } |
| 74 | |
| 75 | //----------------------------------------------------------------------------- |
| 76 | //! Add Vertices |
| 77 | //! @param ucode instruction from displaylist with input data |
| 78 | //----------------------------------------------------------------------------- |
| 79 | void UCode4::WaveRace64_Vertex(MicrocodeArgument* ucode) |
| 80 | { |
| 81 | Logger::getSingleton().printMsg("WaveRace64_Vertex", M64MSG_VERBOSE); |
| 82 | RSPUCodeAddVerticesWaveRace64* temp = (RSPUCodeAddVerticesWaveRace64*)ucode; |
| 83 | |
| 84 | //Add Vertices |
| 85 | m_rsp->RSP_Vertex(temp->segmentAddress, temp->numVertices, temp->firstVertexIndex/5); |
| 86 | } |
| 87 | |
| 88 | //----------------------------------------------------------------------------- |
| 89 | //! Add one Triangle |
| 90 | //! @param ucode instruction from displaylist with input data |
| 91 | //----------------------------------------------------------------------------- |
| 92 | void UCode4::WaveRace64_Tri1(MicrocodeArgument* ucode) |
| 93 | { |
| 94 | Logger::getSingleton().printMsg("WaveRace64_Tri1", M64MSG_VERBOSE); |
| 95 | RSPUCodeAddOneTriangleF3D* temp = (RSPUCodeAddOneTriangleF3D*)ucode; |
| 96 | |
| 97 | //Add triangle |
| 98 | m_rsp->RSP_1Triangle(temp->index0 / 5, temp->index1 / 5, temp->index2 / 5 /*,temp->flag,*/ ); |
| 99 | } |
| 100 | |
| 101 | //----------------------------------------------------------------------------- |
| 102 | //! Add 2 Triangles |
| 103 | //! @param ucode instruction from displaylist with input data |
| 104 | //----------------------------------------------------------------------------- |
| 105 | void UCode4::WaveRace64_Tri2(MicrocodeArgument* ucode) |
| 106 | { |
| 107 | Logger::getSingleton().printMsg("WaveRace64_Tri2", M64MSG_VERBOSE); |
| 108 | RSPUCodeAddTwoTrianglesWaveRace64* temp = (RSPUCodeAddTwoTrianglesWaveRace64*)ucode; |
| 109 | |
| 110 | //Add Two triangles |
| 111 | m_rsp->RSP_2Triangles( temp->v0 / 5, temp->v1 / 5, temp->v2 / 5, 0, |
| 112 | temp->v3 / 5, temp->v4 / 5, temp->v5 / 5, 0); |
| 113 | } |
| 114 | |
| 115 | //----------------------------------------------------------------------------- |
| 116 | //! Add Quad |
| 117 | //! @param ucode instruction from displaylist with input data |
| 118 | //----------------------------------------------------------------------------- |
| 119 | void UCode4::WaveRace64_Quad(MicrocodeArgument* ucode) |
| 120 | { |
| 121 | Logger::getSingleton().printMsg("WaveRace64_Quad", M64MSG_VERBOSE); |
| 122 | RSPUCodeAddOneQuadF3D* temp = (RSPUCodeAddOneQuadF3D*)ucode; |
| 123 | |
| 124 | //Add Quad |
| 125 | m_rsp->RSP_1Quadrangle(temp->index0/5, temp->index1/5, temp->index2/5, temp->index3/5); |
| 126 | } |