| 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 "UCode9.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 F3DPD_VTXCOLORBASE 0x07 |
| 31 | |
| 32 | //----------------------------------------------------------------------------- |
| 33 | // Static Variables |
| 34 | //----------------------------------------------------------------------------- |
| 35 | RSP* UCode9::m_rsp = 0; //!< Pointer to Reality Signal Processor |
| 36 | |
| 37 | //----------------------------------------------------------------------------- |
| 38 | //! Constructor |
| 39 | //----------------------------------------------------------------------------- |
| 40 | UCode9::UCode9() |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | //----------------------------------------------------------------------------- |
| 45 | //! Destructor |
| 46 | //----------------------------------------------------------------------------- |
| 47 | UCode9::~UCode9() |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | //----------------------------------------------------------------------------- |
| 52 | //! Initialize |
| 53 | //----------------------------------------------------------------------------- |
| 54 | void UCode9::initialize(RSP* rsp) |
| 55 | { |
| 56 | m_rsp = rsp; |
| 57 | } |
| 58 | |
| 59 | //----------------------------------------------------------------------------- |
| 60 | //! Initialize GBI |
| 61 | //----------------------------------------------------------------------------- |
| 62 | void UCode9::initializeGBI(GBI* gbi) |
| 63 | { |
| 64 | // Set GeometryMode flags |
| 65 | GBI_InitFlags( F3D ); |
| 66 | |
| 67 | // GBI Command Command Value Command Function |
| 68 | GBI_SetGBI( GBI::G_SPNOOP, F3D_SPNOOP, gbi->m_cmds, UCode0::F3D_SPNoOp ); |
| 69 | GBI_SetGBI( GBI::G_MTX, F3D_MTX, gbi->m_cmds, UCode0::F3D_Mtx ); |
| 70 | GBI_SetGBI( GBI::G_RESERVED0, F3D_RESERVED0, gbi->m_cmds, UCode0::F3D_Reserved0 ); |
| 71 | GBI_SetGBI( GBI::G_MOVEMEM, F3D_MOVEMEM, gbi->m_cmds, UCode0::F3D_MoveMem ); |
| 72 | GBI_SetGBI( GBI::G_VTX, F3D_VTX, gbi->m_cmds, PerfectDark_Vertex ); |
| 73 | GBI_SetGBI( GBI::G_RESERVED1, F3D_RESERVED1, gbi->m_cmds, UCode0::F3D_Reserved1 ); |
| 74 | GBI_SetGBI( GBI::G_DL, F3D_DL, gbi->m_cmds, UCode0::F3D_DList ); |
| 75 | GBI_SetGBI( GBI::G_VTXCOLORBASE, F3DPD_VTXCOLORBASE, gbi->m_cmds, PerfectDark_VertexColorBase ); |
| 76 | GBI_SetGBI( GBI::G_RESERVED3, F3D_RESERVED3, gbi->m_cmds, UCode0::F3D_Reserved3 ); |
| 77 | GBI_SetGBI( GBI::G_SPRITE2D_BASE, F3D_SPRITE2D_BASE, gbi->m_cmds, UCode0::F3D_Sprite2D_Base ); |
| 78 | GBI_SetGBI( GBI::G_TRI1, F3D_TRI1, gbi->m_cmds, UCode0::F3D_Tri1 ); |
| 79 | GBI_SetGBI( GBI::G_CULLDL, F3D_CULLDL, gbi->m_cmds, UCode0::F3D_CullDL ); |
| 80 | GBI_SetGBI( GBI::G_POPMTX, F3D_POPMTX, gbi->m_cmds, UCode0::F3D_PopMtx ); |
| 81 | GBI_SetGBI( GBI::G_MOVEWORD, F3D_MOVEWORD, gbi->m_cmds, UCode0::F3D_MoveWord ); |
| 82 | GBI_SetGBI( GBI::G_TEXTURE, F3D_TEXTURE, gbi->m_cmds, UCode0::F3D_Texture ); |
| 83 | GBI_SetGBI( GBI::G_SETOTHERMODE_H, F3D_SETOTHERMODE_H, gbi->m_cmds, UCode0::F3D_SetOtherMode_H ); |
| 84 | GBI_SetGBI( GBI::G_SETOTHERMODE_L, F3D_SETOTHERMODE_L, gbi->m_cmds, UCode0::F3D_SetOtherMode_L ); |
| 85 | GBI_SetGBI( GBI::G_ENDDL, F3D_ENDDL, gbi->m_cmds, UCode0::F3D_EndDL ); |
| 86 | GBI_SetGBI( GBI::G_SETGEOMETRYMODE, F3D_SETGEOMETRYMODE, gbi->m_cmds, UCode0::F3D_SetGeometryMode ); |
| 87 | GBI_SetGBI( GBI::G_CLEARGEOMETRYMODE,F3D_CLEARGEOMETRYMODE, gbi->m_cmds, UCode0::F3D_ClearGeometryMode ); |
| 88 | GBI_SetGBI( GBI::G_QUAD, F3D_QUAD, gbi->m_cmds, UCode0::F3D_Quad ); |
| 89 | GBI_SetGBI( GBI::G_RDPHALF_1, F3D_RDPHALF_1, gbi->m_cmds, UCode0::F3D_RDPHalf_1 ); |
| 90 | GBI_SetGBI( GBI::G_RDPHALF_2, F3D_RDPHALF_2, gbi->m_cmds, UCode0::F3D_RDPHalf_2 ); |
| 91 | GBI_SetGBI( GBI::G_RDPHALF_CONT, F3D_RDPHALF_CONT, gbi->m_cmds, UCode0::F3D_RDPHalf_Cont ); |
| 92 | GBI_SetGBI( GBI::G_TRI4, F3D_TRI4, gbi->m_cmds, UCode0::F3D_Tri4 ); |
| 93 | |
| 94 | //Set DMA Offset |
| 95 | m_rsp->RSP_SetDMAOffsets(0,0); |
| 96 | } |
| 97 | |
| 98 | //----------------------------------------------------------------------------- |
| 99 | //! Perfect Dark Vertex |
| 100 | //----------------------------------------------------------------------------- |
| 101 | void UCode9::PerfectDark_Vertex(MicrocodeArgument* ucode) |
| 102 | { |
| 103 | Logger::getSingleton().printMsg("PerfectDark_Vertex", M64MSG_VERBOSE); |
| 104 | RSPUCode9AddColorIndexVertices* temp = (RSPUCode9AddColorIndexVertices*)ucode; |
| 105 | |
| 106 | //Set Color Index Vertices |
| 107 | m_rsp->RSP_CIVertex(temp->segmentAddress, temp->numVertices + 1, temp->firstVertexIndex); |
| 108 | } |
| 109 | |
| 110 | //----------------------------------------------------------------------------- |
| 111 | //! Perfect Dark Color Base |
| 112 | //----------------------------------------------------------------------------- |
| 113 | void UCode9::PerfectDark_VertexColorBase(MicrocodeArgument* ucode) |
| 114 | { |
| 115 | Logger::getSingleton().printMsg("PerfectDark_VertexColorBase", M64MSG_VERBOSE); |
| 116 | RSPUCodeSetVertexColorBase* temp = (RSPUCodeSetVertexColorBase*)ucode; |
| 117 | |
| 118 | //Set Vertex Color Base |
| 119 | m_rsp->RSP_SetVertexColorBase(temp->rdramAddress); |
| 120 | } |