Added missing launcher
[mupen64plus-pandora.git] / source / mupen64plus-video-arachnoid / src / VI.cpp
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 "VI.h"
23 #include "GBIDefs.h" //_FIXED2FLOAT, _SHIFTR
24 #include "m64p.h"
25
26 //-----------------------------------------------------------------------------
27 //! Constructor
28 //-----------------------------------------------------------------------------
29 VI::VI()
30 {
31     m_width = 320;
32     m_height = 240;
33 }
34
35 //-----------------------------------------------------------------------------
36 //! Destructor
37 //-----------------------------------------------------------------------------
38 VI::~VI()
39 {
40
41 }
42
43 //-----------------------------------------------------------------------------
44 //* Calculate Size
45 //! Calculates width and height of video interface
46 //-----------------------------------------------------------------------------
47 void VI::calcSize(GFX_INFO*  graphicsInfo)
48 {
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;
54
55     //Get Scale
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);
58
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);
62
63     //Get horizontal coordinats
64     unsigned int hEnd = _SHIFTR( viStartHorizontal, 0, 10 );
65     unsigned int hStart = _SHIFTR( viStartHorizontal, 16, 10 );
66
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 );
71
72     //Calculate size
73     m_width = (int)((hEnd - hStart) * xScale);
74     m_height = (int)((vEnd - vStart) * yScale * 1.0126582f);
75
76     //If Zero: Set to defaults
77     if ( m_width == 0.0f ) m_width = 320;
78     if ( m_height == 0.0f ) m_height = 240;
79
80     //m_width = 320;
81     //m_height = 240;
82 }