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 RSP_MATRIX_MANAGER_H_
23
#define RSP_MATRIX_MANAGER_H_
27
//Forward Declarations
30
//*****************************************************************************
31
//! RSP Matrix Manager
32
//*****************************************************************************
33
class RSPMatrixManager
37
//Constructor / Destructor
41
bool initialize(Memory* memory);
44
void addMatrix(unsigned int segmentAddress, bool projectionMatrix, bool push, bool replace);
45
void insertMatrix(unsigned int where, unsigned int num);
49
void popMatrixN(unsigned int num);
50
void ForceMatrix( unsigned int segmentAddress );
51
void selectViewMatrix(unsigned int index) { m_modelViewMatrixTop = index; _updateCombinedMatrix(); }
52
void DMAMatrix(unsigned int segmentAddress, unsigned char index, unsigned char multiply );
53
//void RSP_ForceMatrix( unsigned int mptr );
54
//void RSP_LookAt( unsigned int l );
55
//void RSP_PerspNormalize( unsigned short scale );
57
void setRDRAMOffset(unsigned int offset) { m_rdramOffset = offset; }
63
float* getModelViewMatrix() { return m_modelViewMatrices[m_modelViewMatrixTop]._m; }
64
float* getProjectionMatrix() { return m_projectionMatrices[m_projectionMatrixTop]._m; }
65
float* getViewProjectionMatrix() { return m_worldProject._m; }
69
void _loadMatrix(unsigned int addr, Matrix4& out);
70
void _setProjection(const Matrix4& mat, bool push, bool replace);
71
void _setWorldView(const Matrix4 & mat, bool push, bool replace);
72
void _updateCombinedMatrix();
76
Memory* m_memory; //!< Pointer to memory
78
static const int NUM_STACK_MATRICES = 60;
80
unsigned int m_rdramOffset;
83
unsigned int m_modelViewMatrixTop;
84
unsigned int m_projectionMatrixTop;
87
Matrix4 m_modelViewMatrices[NUM_STACK_MATRICES]; //!< Stack with projection matrices
88
Matrix4 m_projectionMatrices[NUM_STACK_MATRICES]; //!< Stack with projection matrices
89
Matrix4 m_worldProject; //!< Combined modelviewprojection matrix