Added missing launcher
[mupen64plus-pandora.git] / source / mupen64plus-video-arachnoid / src / RomDetector.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 "RomDetector.h"
23 #include "assembler.h"   //swapRomHeaderBytes
24 #include <string.h>      //memcpy
25 #include "StringFunctions.h"
26
27 //-----------------------------------------------------------------------------
28 //! Constructor
29 //-----------------------------------------------------------------------------
30 ROMDetector::ROMDetector()
31 {
32
33 }
34
35 //-----------------------------------------------------------------------------
36 //! Destructor
37 //-----------------------------------------------------------------------------
38 ROMDetector::~ROMDetector()
39 {
40
41 }
42
43 //-----------------------------------------------------------------------------
44 //* Initialzie
45 //! Saves rom header, detects which rom it is, and sets states after
46 //! which rom it is.
47 //! @param romHeader Header with information about rom.
48 //-----------------------------------------------------------------------------
49 void ROMDetector::initialize(unsigned char* romHeader)
50 {
51
52     //Copy Header
53     memcpy(&m_romHeader, romHeader, sizeof(ROMHeader));
54
55     //Header are stored really strange, swap bytes around to make sense of it
56     swapRomHeaderBytes((void*)&m_romHeader, sizeof(ROMHeader));
57
58     //Trim rom name (remove unnecessary whitespaces)
59     StringFunctions::trim(m_romHeader.romName);
60
61     //What game is it?
62     m_currentRomID = this->_getRomID(m_romHeader.romName);
63 }
64
65 //-----------------------------------------------------------------------------
66 //* Get ROM ID
67 //! Detects and returns which rom it is, and sets states after
68 //! which rom it is.
69 //! @param romName Name of rom from rom-header.
70 //! @return ID of the rom that was identified by rom name.
71 //-----------------------------------------------------------------------------
72 N64_ROM_ID ROMDetector::_getRomID(char romName[20])
73 {  
74     m_combinerType            = CT_ADVANCED;  //Use advanced combiner
75     m_clearType               = CT_NEVER;     //Never Clear Screen
76     m_ignoreFillRects         = false;
77     m_forceDisableFaceCulling = false;
78     m_useMultiTexture         = true;
79     m_useSecondaryColor       = true;
80
81     //Return ROM-ID and set ROM options
82     if ( !strncmp(romName, "Banjo-Kazooie", 13) )
83     {
84         m_combinerType = CT_SIMPLE;
85         return BANJO_KAZOOIE;
86     }
87     else if ( !strncmp(romName, "BANJO TOOIE", 11) )
88     {
89         m_combinerType = CT_SIMPLE;
90         return BANJO_TOOIE;
91     }
92     else if ( !strncmp(romName, "F-ZERO X", 8) )
93     {
94         m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
95         return F_ZERO_X;
96     }
97     else if ( !strncmp(romName, "STARFOX64", 9) )
98     {
99         m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
100         return STAR_FOX_64;
101     }
102     else if ( !strncmp(romName, "SMASH BROTHERS", 14) )
103     {
104         m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
105         return SUPER_SMASH_BROS;
106     }
107     else if ( !strncmp(romName, "SUPER MARIO 64", 14) )
108     {
109         return SUPER_MARIO_64;
110     }
111     else if ( !strncmp(romName, "BOMBERMAN64E", 11) )
112     {
113         m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
114         m_ignoreFillRects         = true;
115         return BOMBERMAN_64;
116     }
117     else if ( !strncmp(romName, "DONKEY KONG 64", 14) )
118     {
119         return DONKEY_KONG_64;
120     }
121     else if ( !strncmp(romName, "WAVE RACE 64", 12) )
122     {        
123         m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
124         m_ignoreFillRects = true;
125         return WAVE_RACE_64;
126     }        
127     else if ( !strncmp(romName, "GOLDENEYE", 9) )
128     {
129         return GOLDEN_EYE;
130     }
131     else if ( !strncmp(romName, "PAPER MARIO", 11) )
132     {
133         m_clearType = CT_NEVER;
134         return PAPER_MARIO;
135     }
136     else
137     {
138         return UNKNOWN_ROM;
139     }
140 }