56420c3a12
Includes:
- Partial Expansion Module (XM) support
- XRAM
- XPokey (limited to single Pokey)
- Added support for cartridges with sizes greater than 144k
- Additional bank switching modes and cartridge types
- Multiple bank switching fixes
- Reworked cartridge header detection
- Now properly detects bank switching, RAM, etc.
- Detects Expansion Module (XM)
- Detects High score cartridge
- Detects Pokey at $0450
- Cartridge database
- Added several new cartridge properties
- Pokey at $0450
- Default difficulty switch settings
- Expansion Module (XM) enabled/disabled
- High score cartridge enabled/disabled
- Database content
- Fixed incorrect controller settings for Sirius, Crossbow,
and Alien Brigade
- Added many homebrew cartridges
- Fixed issue occurring when Kangaroo and Holey were enabled (caused
background to be displayed, resulting in large black squares)
Missing:
- High Score Cartridge support
140 lines
5.7 KiB
C++
Executable File
140 lines
5.7 KiB
C++
Executable File
// ----------------------------------------------------------------------------
|
|
// ___ ___ ___ ___ ___ ____ ___ _ _
|
|
// /__/ /__/ / / /__ /__/ /__ / /_ / |/ /
|
|
// / / \ /__/ ___/ ___/ ___/ / /__ / / emulator
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
// Copyright 2005 Greg Stanton
|
|
//
|
|
// This program is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
// ----------------------------------------------------------------------------
|
|
// Database.cpp
|
|
// ----------------------------------------------------------------------------
|
|
#include "Database.h"
|
|
#define DATABASE_SOURCE "Database.cpp"
|
|
|
|
bool cart_in_db = false;
|
|
bool database_enabled = true;
|
|
std::string database_filename;
|
|
|
|
static std::string database_GetValue(std::string entry) {
|
|
int index = entry.rfind('=');
|
|
return entry.substr(index + 1);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Initialize
|
|
// ----------------------------------------------------------------------------
|
|
void database_Initialize( ) {
|
|
database_filename = common_defaultPath + "ProSystem.dat";
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Load
|
|
// ----------------------------------------------------------------------------
|
|
bool database_Load(std::string digest) {
|
|
cart_in_db = false;
|
|
if(database_enabled) {
|
|
logger_LogInfo("Accessing database " + database_filename + ".", DATABASE_SOURCE);
|
|
|
|
FILE* file = fopen(database_filename.c_str( ), "r");
|
|
if(file == NULL) {
|
|
logger_LogError("Failed to open the database for reading.", DATABASE_SOURCE);
|
|
return false;
|
|
}
|
|
|
|
// max count of items in the database
|
|
static int count = 17;
|
|
|
|
char buffer[256];
|
|
while(fgets(buffer, 256, file) != NULL) {
|
|
std::string line = buffer;
|
|
if(line.compare(1, 32, digest.c_str( )) == 0) {
|
|
cart_in_db = true;
|
|
std::string entry[count];
|
|
for (int index = 0; index < count; index++) {
|
|
buffer[0] = '\0';
|
|
fgets(buffer, 256, file);
|
|
if (strchr(buffer, '[')) {
|
|
// Passed the current game in DB
|
|
break;
|
|
}
|
|
entry[index] = common_Remove(buffer, '\n');
|
|
entry[index] = common_Remove(entry[index], '\r');
|
|
}
|
|
|
|
cartridge_title = database_GetValue(entry[0]);
|
|
cartridge_type = common_ParseByte(database_GetValue(entry[1]));
|
|
cartridge_pokey = common_ParseBool(database_GetValue(entry[2]));
|
|
cartridge_controller[0] = common_ParseByte(database_GetValue(entry[3]));
|
|
cartridge_controller[1] = common_ParseByte(database_GetValue(entry[4]));
|
|
cartridge_region = common_ParseByte(database_GetValue(entry[5]));
|
|
cartridge_flags = common_ParseUint(database_GetValue(entry[6]));
|
|
|
|
// Optionally load the lightgun crosshair offsets, hblank, dual analog
|
|
for(int index = 7; index < count; index++)
|
|
{
|
|
if(entry[index].find("crossx") != std::string::npos)
|
|
{
|
|
cartridge_crosshair_x = common_ParseInt(database_GetValue(entry[index]));
|
|
}
|
|
if(entry[index].find("crossy") != std::string::npos)
|
|
{
|
|
cartridge_crosshair_y = common_ParseInt(database_GetValue(entry[index]));
|
|
}
|
|
if(entry[index].find("hblank") != std::string::npos)
|
|
{
|
|
cartridge_hblank = common_ParseInt(database_GetValue(entry[index]));
|
|
}
|
|
if(entry[index].find("dualanalog") != std::string::npos)
|
|
{
|
|
cartridge_dualanalog = common_ParseBool(database_GetValue(entry[index]));
|
|
}
|
|
if (entry[index].find("pokey450") != std::string::npos) {
|
|
cartridge_pokey450 = common_ParseBool(database_GetValue(entry[index]));
|
|
if (cartridge_pokey450) {
|
|
cartridge_pokey = true;
|
|
}
|
|
}
|
|
if (entry[index].find("xm") != std::string::npos) {
|
|
cartridge_xm = common_ParseBool(database_GetValue(entry[index]));
|
|
}
|
|
if (entry[index].find("disablebios") != std::string::npos) {
|
|
cartridge_disable_bios = common_ParseBool(database_GetValue(entry[index]));
|
|
}
|
|
if (entry[index].find("leftswitch") != std::string::npos) {
|
|
cartridge_left_switch = common_ParseByte(database_GetValue(entry[index]));
|
|
}
|
|
if (entry[index].find("rightswitch") != std::string::npos) {
|
|
cartridge_right_switch = common_ParseByte(database_GetValue(entry[index]));
|
|
}
|
|
if (entry[index].find("swapbuttons") != std::string::npos) {
|
|
cartridge_swap_buttons = common_ParseBool(database_GetValue(entry[index]));
|
|
}
|
|
if (entry[index].find("hsc") != std::string::npos) {
|
|
cartridge_hsc_enabled = common_ParseBool(database_GetValue(entry[index]));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
fclose(file);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|