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 #include "RomDetector.h"
23 #include "assembler.h" //swapRomHeaderBytes
24 #include <string.h> //memcpy
25 #include "StringFunctions.h"
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
30 ROMDetector::ROMDetector()
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
38 ROMDetector::~ROMDetector()
43 //-----------------------------------------------------------------------------
45 //! Saves rom header, detects which rom it is, and sets states after
47 //! @param romHeader Header with information about rom.
48 //-----------------------------------------------------------------------------
49 void ROMDetector::initialize(unsigned char* romHeader)
53 memcpy(&m_romHeader, romHeader, sizeof(ROMHeader));
55 //Header are stored really strange, swap bytes around to make sense of it
56 swapRomHeaderBytes((void*)&m_romHeader, sizeof(ROMHeader));
58 //Trim rom name (remove unnecessary whitespaces)
59 StringFunctions::trim(m_romHeader.romName);
62 m_currentRomID = this->_getRomID(m_romHeader.romName);
65 //-----------------------------------------------------------------------------
67 //! Detects and returns which rom it is, and sets states after
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])
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;
81 //Return ROM-ID and set ROM options
82 if ( !strncmp(romName, "Banjo-Kazooie", 13) )
84 m_combinerType = CT_SIMPLE;
87 else if ( !strncmp(romName, "BANJO TOOIE", 11) )
89 m_combinerType = CT_SIMPLE;
92 else if ( !strncmp(romName, "F-ZERO X", 8) )
94 m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
97 else if ( !strncmp(romName, "STARFOX64", 9) )
99 m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
102 else if ( !strncmp(romName, "SMASH BROTHERS", 14) )
104 m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
105 return SUPER_SMASH_BROS;
107 else if ( !strncmp(romName, "SUPER MARIO 64", 14) )
109 return SUPER_MARIO_64;
111 else if ( !strncmp(romName, "BOMBERMAN64E", 11) )
113 m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
114 m_ignoreFillRects = true;
117 else if ( !strncmp(romName, "DONKEY KONG 64", 14) )
119 return DONKEY_KONG_64;
121 else if ( !strncmp(romName, "WAVE RACE 64", 12) )
123 m_clearType = CT_AFTER_ONE_DISPLAY_LIST;
124 m_ignoreFillRects = true;
127 else if ( !strncmp(romName, "GOLDENEYE", 9) )
131 else if ( !strncmp(romName, "PAPER MARIO", 11) )
133 m_clearType = CT_NEVER;