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 *****************************************************************************/
23 #include "GBIDefs.h" //_FIXED2FLOAT, _SHIFTR
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 //! Calculates width and height of video interface
46 //-----------------------------------------------------------------------------
47 void VI::calcSize(GFX_INFO* graphicsInfo)
49 //Get video interface values
50 //unsigned int viScaleX = *graphicsInfo->VI_X_SCALE_REG;
51 //unsigned int viScaleY = *graphicsInfo->VI_X_SCALE_REG;
52 unsigned int viStartHorizontal = *graphicsInfo->VI_H_START_REG;
53 unsigned int viStartVertical = *graphicsInfo->VI_V_START_REG;
56 float xScale = _FIXED2FLOAT(_SHIFTR(*graphicsInfo->VI_X_SCALE_REG, 0, 12), 10);
57 float yScale = _FIXED2FLOAT(_SHIFTR(*graphicsInfo->VI_Y_SCALE_REG, 0, 12), 10);
59 //Get Offsets (no need for these?)
60 //float xOffset = _FIXED2FLOAT(_SHIFTR(viScaleX, 16, 12), 10);
61 //float yOffset = _FIXED2FLOAT(_SHIFTR(viScaleY, 16, 12), 10);
63 //Get horizontal coordinats
64 unsigned int hEnd = _SHIFTR( viStartHorizontal, 0, 10 );
65 unsigned int hStart = _SHIFTR( viStartHorizontal, 16, 10 );
67 //Get vertical coordinats
68 // These are in half-lines, so shift an extra bit
69 unsigned int vEnd = _SHIFTR( viStartVertical, 1, 9 );
70 unsigned int vStart = _SHIFTR( viStartVertical, 17, 9 );
73 m_width = (int)((hEnd - hStart) * xScale);
74 m_height = (int)((vEnd - vStart) * yScale * 1.0126582f);
76 //If Zero: Set to defaults
77 if ( m_width == 0.0f ) m_width = 320;
78 if ( m_height == 0.0f ) m_height = 240;