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 *****************************************************************************/
27 #include "UCodeDefs.h"
31 #include "DisplayListParser.h"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
36 GBI* UCode2::m_gbi = 0; //!< Pointer to Graphics Binary Interface
37 RSP* UCode2::m_rsp = 0; //!< Pointer to Reality Signal Processor
38 RDP* UCode2::m_rdp = 0; //!< Pointer to Reality Drawing Processor
39 Memory* UCode2::m_memory = 0;
40 DisplayListParser* UCode2::m_displayListParser = 0;
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
58 //-----------------------------------------------------------------------------
59 void UCode2::initialize(GBI* gbi, RSP* rsp, RDP* rdp, Memory* mem, DisplayListParser* dlp)
65 m_displayListParser = dlp;
68 //-----------------------------------------------------------------------------
70 //! Assigns functions to the GBI
71 //-----------------------------------------------------------------------------
72 void UCode2::initializeGBI()
74 UCode0::initializeGBI(m_gbi);
75 GBI_SetGBI(GBI::G_RDPHALF_1, F3D_RDPHALF_1, m_gbi->m_cmds, renderSky);
78 //-----------------------------------------------------------------------------
79 //* RDP Half 1 With Sky Rendering
81 //! @todo Set Half 1 also?
82 //! @todo Use extracted color
83 //! @todo set x0 and x1
84 //-----------------------------------------------------------------------------
85 void UCode2::renderSky(MicrocodeArgument* ucode)
88 if ( (ucode->w1)>>24 != 0xCE )
93 unsigned int w2 = m_displayListParser->getNextWord();
94 m_displayListParser->getNextWord();
95 m_displayListParser->getNextWord();
96 m_displayListParser->getNextWord();
97 m_displayListParser->getNextWord();
98 m_displayListParser->getNextWord();
99 m_displayListParser->getNextWord();
100 m_displayListParser->getNextWord();
101 m_displayListParser->getNextWord();
103 //Extract Vertex Coordinats
104 unsigned int x0 = 0; //TODO Use VI pos or Viewport pos or Scissor pos ?
105 unsigned int y0 = (unsigned int)int(w2&0xFFFF)/4;
106 unsigned int x1 = 320; //TODO Use VI Height or Viewport Height or Scissor Height ?
107 unsigned int y1 = (unsigned int)int(w2>>16)/4;
109 m_rdp->RDP_TexRect(x0, y0, x1, y1, 0, 0, 0, 1024, 1024);