Unverified Commit 142373d9 authored by Ignacio Sanchez Gines's avatar Ignacio Sanchez Gines
Browse files

Add bios support in desktop

parent 9778c49a
Pipeline #40282 passed with stages
in 4 minutes and 20 seconds
......@@ -17,7 +17,7 @@ SOURCES = $(EMULATOR_DESKTOP_SHARED_SRC)/main.cpp $(EMULATOR_DESKTOP_SHARED_SRC)
SOURCES += $(IMGUI_SRC)/imgui_impl_sdl.cpp $(IMGUI_SRC)/imgui_impl_opengl2.cpp $(IMGUI_SRC)/imgui.cpp $(IMGUI_SRC)/imgui_demo.cpp $(IMGUI_SRC)/imgui_draw.cpp $(IMGUI_SRC)/imgui_widgets.cpp $(IMGUI_FILEBROWSER_SRC)/ImGuiFileBrowser.cpp
SOURCES += $(EMULATOR_SRC)/Audio.cpp $(EMULATOR_SRC)/Cartridge.cpp $(EMULATOR_SRC)/CodemastersMemoryRule.cpp $(EMULATOR_SRC)/GameGearIOPorts.cpp $(EMULATOR_SRC)/GearsystemCore.cpp $(EMULATOR_SRC)/Input.cpp $(EMULATOR_SRC)/KoreanMemoryRule.cpp $(EMULATOR_SRC)/Memory.cpp $(EMULATOR_SRC)/MemoryRule.cpp $(EMULATOR_SRC)/MSXMemoryRule.cpp $(EMULATOR_SRC)/opcodes.cpp $(EMULATOR_SRC)/opcodes_cb.cpp $(EMULATOR_SRC)/opcodes_ed.cpp $(EMULATOR_SRC)/Processor.cpp $(EMULATOR_SRC)/RomOnlyMemoryRule.cpp $(EMULATOR_SRC)/SegaMemoryRule.cpp $(EMULATOR_SRC)/SG1000MemoryRule.cpp $(EMULATOR_SRC)/SmsIOPorts.cpp $(EMULATOR_SRC)/Video.cpp
SOURCES += $(EMULATOR_SRC)/Audio.cpp $(EMULATOR_SRC)/Cartridge.cpp $(EMULATOR_SRC)/CodemastersMemoryRule.cpp $(EMULATOR_SRC)/GameGearIOPorts.cpp $(EMULATOR_SRC)/GearsystemCore.cpp $(EMULATOR_SRC)/Input.cpp $(EMULATOR_SRC)/KoreanMemoryRule.cpp $(EMULATOR_SRC)/Memory.cpp $(EMULATOR_SRC)/MemoryRule.cpp $(EMULATOR_SRC)/MSXMemoryRule.cpp $(EMULATOR_SRC)/opcodes.cpp $(EMULATOR_SRC)/opcodes_cb.cpp $(EMULATOR_SRC)/opcodes_ed.cpp $(EMULATOR_SRC)/Processor.cpp $(EMULATOR_SRC)/RomOnlyMemoryRule.cpp $(EMULATOR_SRC)/SegaMemoryRule.cpp $(EMULATOR_SRC)/SG1000MemoryRule.cpp $(EMULATOR_SRC)/SmsIOPorts.cpp $(EMULATOR_SRC)/Video.cpp $(EMULATOR_SRC)/BootromMemoryRule.cpp
SOURCES += $(EMULATOR_AUDIO_SRC)/Blip_Buffer.cpp $(EMULATOR_AUDIO_SRC)/Effects_Buffer.cpp $(EMULATOR_AUDIO_SRC)/Sms_Apu.cpp $(EMULATOR_AUDIO_SRC)/Multi_Buffer.cpp
......
......@@ -114,6 +114,11 @@ void config_read(void)
config_emulator.zone = read_int("Emulator", "Zone", 0);
config_emulator.mapper = read_int("Emulator", "Mapper", 0);
config_emulator.region = read_int("Emulator", "Region", 0);
config_emulator.sms_bootrom = read_bool("Emulator", "SMSBootrom", false);
config_emulator.sms_bootrom_path = read_string("Emulator", "SMSBootromPath");
config_emulator.gg_bootrom = read_bool("Emulator", "GGBootrom", false);
config_emulator.gg_bootrom_path = read_string("Emulator", "GGBootromPath");
config_emulator.media = read_int("Emulator", "Media", 0);
for (int i = 0; i < config_max_recent_roms; i++)
{
......@@ -193,6 +198,11 @@ void config_write(void)
write_int("Emulator", "Zone", config_emulator.zone);
write_int("Emulator", "Mapper", config_emulator.mapper);
write_int("Emulator", "Region", config_emulator.region);
write_bool("Emulator", "SMSBootrom", config_emulator.sms_bootrom);
write_string("Emulator", "SMSBootromPath", config_emulator.sms_bootrom_path);
write_bool("Emulator", "GGBootrom", config_emulator.gg_bootrom);
write_string("Emulator", "GGBootromPath", config_emulator.gg_bootrom_path);
write_int("Emulator", "Media", config_emulator.media);
for (int i = 0; i < config_max_recent_roms; i++)
{
......
......@@ -48,6 +48,11 @@ struct config_Emulator
int region = 0;
bool show_info = false;
std::string recent_roms[config_max_recent_roms];
bool sms_bootrom;
std::string sms_bootrom_path;
bool gg_bootrom;
std::string gg_bootrom_path;
int media = 0;
};
struct config_Video
......
......@@ -308,6 +308,48 @@ void emu_debug_next_frame(void)
gearsystem->Pause(false);
}
void emu_load_bootrom_sms(const char* file_path)
{
gearsystem->GetMemory()->LoadBootromSMS(file_path);
}
void emu_load_bootrom_gg(const char* file_path)
{
gearsystem->GetMemory()->LoadBootromGG(file_path);
}
void emu_enable_bootrom_sms(bool enable)
{
gearsystem->GetMemory()->EnableBootromSMS(enable);
}
void emu_enable_bootrom_gg(bool enable)
{
gearsystem->GetMemory()->EnableBootromGG(enable);
}
void emu_set_media_slot(int slot)
{
Memory::MediaSlots media_slot = Memory::MediaSlots::CartridgeSlot;
switch (slot)
{
case 1:
media_slot = Memory::MediaSlots::CardSlot;
break;
case 2:
media_slot = Memory::MediaSlots::ExpansionSlot;
break;
case 3:
media_slot = Memory::MediaSlots::NoSlot;
break;
default:
media_slot = Memory::MediaSlots::CartridgeSlot;
}
gearsystem->GetMemory()->SetMediaSlot(media_slot);
}
static void save_ram(void)
{
#ifdef DEBUG_GEARSYSTEM
......
......@@ -67,6 +67,11 @@ EXTERN GearsystemCore* emu_get_core(void);
EXTERN void emu_debug_step(void);
EXTERN void emu_debug_continue(void);
EXTERN void emu_debug_next_frame(void);
EXTERN void emu_load_bootrom_sms(const char* file_path);
EXTERN void emu_load_bootrom_gg(const char* file_path);
EXTERN void emu_enable_bootrom_sms(bool enable);
EXTERN void emu_enable_bootrom_gg(bool enable);
EXTERN void emu_set_media_slot(int slot);
#undef EMU_IMPORT
#undef EXTERN
......
......@@ -43,6 +43,8 @@ static std::list<std::string> cheat_list;
static bool shortcut_open_rom = false;
static ImFont* default_font[4];
static bool show_main_menu = true;
static char sms_bootrom_path[4096] = "";
static char gg_bootrom_path[4096] = "";
static void main_menu(void);
static void main_window(void);
......@@ -51,6 +53,8 @@ static void file_dialog_load_ram(void);
static void file_dialog_save_ram(void);
static void file_dialog_load_state(void);
static void file_dialog_save_state(void);
static void file_dialog_load_sms_bootrom(void);
static void file_dialog_load_gg_bootrom(void);
static void file_dialog_load_symbols(void);
static void keyboard_configuration_item(const char* text, SDL_Scancode* key, int player);
static void gamepad_configuration_item(const char* text, int* button, int player);
......@@ -92,6 +96,18 @@ void gui_init(void)
gui_default_font = default_font[config_debug.font_size];
emu_audio_volume(config_audio.enable ? 1.0f: 0.0f);
strcpy(sms_bootrom_path, config_emulator.sms_bootrom_path.c_str());
strcpy(gg_bootrom_path, config_emulator.gg_bootrom_path.c_str());
if (strlen(sms_bootrom_path) > 0)
emu_load_bootrom_sms(sms_bootrom_path);
if (strlen(gg_bootrom_path) > 0)
emu_load_bootrom_gg(gg_bootrom_path);
emu_enable_bootrom_sms(config_emulator.sms_bootrom);
emu_enable_bootrom_gg(config_emulator.gg_bootrom);
emu_set_media_slot(config_emulator.media);
}
void gui_destroy(void)
......@@ -207,6 +223,8 @@ static void main_menu(void)
bool save_state = false;
bool open_about = false;
bool open_symbols = false;
bool open_sms_bootrom = false;
bool open_gg_bootrom = false;
if (show_main_menu && ImGui::BeginMainMenuBar())
{
......@@ -338,7 +356,7 @@ static void main_menu(void)
if (ImGui::BeginMenu("Mapper"))
{
ImGui::PushItemWidth(140.0f);
ImGui::PushItemWidth(130.0f);
ImGui::Combo("##emu_mapper", &config_emulator.mapper, "Auto\0ROM Only\0SEGA\0Codemasters\0Korean\0SG-1000\0MSX\0\0");
ImGui::PopItemWidth();
ImGui::EndMenu();
......@@ -359,6 +377,63 @@ static void main_menu(void)
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Media Slot"))
{
ImGui::PushItemWidth(130.0f);
if (ImGui::Combo("##emu_media", &config_emulator.media, "Cartridge\0Card\0Expansion\0None\0\0"))
{
emu_set_media_slot(config_emulator.media);
}
ImGui::PopItemWidth();
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::BeginMenu("Master System BIOS"))
{
if (ImGui::MenuItem("Enable", "", &config_emulator.sms_bootrom))
{
emu_enable_bootrom_sms(config_emulator.sms_bootrom);
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("When the BIOS is enabled it will execute as in original hardware,\ncausing invalid roms to lock or preventing some other to boot.\n\nSet 'Media Slot' to 'None'in order to boot the games included in BIOS.");
if (ImGui::MenuItem("Load BIOS..."))
{
open_sms_bootrom = true;
}
ImGui::PushItemWidth(350);
if (ImGui::InputText("##sms_bootrom_path", sms_bootrom_path, IM_ARRAYSIZE(sms_bootrom_path), ImGuiInputTextFlags_AutoSelectAll))
{
config_emulator.sms_bootrom_path.assign(sms_bootrom_path);
emu_load_bootrom_sms(sms_bootrom_path);
}
ImGui::PopItemWidth();
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Game Gear BIOS"))
{
if (ImGui::MenuItem("Enable", "", &config_emulator.gg_bootrom))
{
emu_enable_bootrom_gg(config_emulator.gg_bootrom);
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("When the BIOS is enabled it will execute as in original hardware,\ncausing invalid roms to lock or preventing some other to boot.\n\nSet 'Media Slot' to 'None'in order to boot the games included in BIOS.");
if (ImGui::MenuItem("Load BIOS..."))
{
open_gg_bootrom = true;
}
ImGui::PushItemWidth(350);
if (ImGui::InputText("##gg_bootrom_path", gg_bootrom_path, IM_ARRAYSIZE(gg_bootrom_path), ImGuiInputTextFlags_AutoSelectAll))
{
config_emulator.gg_bootrom_path.assign(gg_bootrom_path);
emu_load_bootrom_gg(sms_bootrom_path);
}
ImGui::PopItemWidth();
ImGui::EndMenu();
}
ImGui::Separator();
ImGui::MenuItem("Start Paused", "", &config_emulator.start_paused);
......@@ -740,6 +815,12 @@ static void main_menu(void)
if (save_state)
ImGui::OpenPopup("Save State As...");
if (open_sms_bootrom)
ImGui::OpenPopup("Load Master System BIOS From...");
if (open_gg_bootrom)
ImGui::OpenPopup("Load Game Gear BIOS From...");
if (open_symbols)
ImGui::OpenPopup("Load Symbols File...");
......@@ -755,6 +836,8 @@ static void main_menu(void)
file_dialog_save_ram();
file_dialog_load_state();
file_dialog_save_state();
file_dialog_load_sms_bootrom();
file_dialog_load_gg_bootrom();
file_dialog_load_symbols();
}
......@@ -919,6 +1002,28 @@ static void file_dialog_save_state(void)
}
}
static void file_dialog_load_sms_bootrom(void)
{
if(file_dialog.showFileDialog("Load Master System BIOS From...", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ImVec2(700, 310), ".sms,.bin,*.*", &dialog_in_use))
{
strcpy(sms_bootrom_path, file_dialog.selected_path.c_str());
config_emulator.sms_bootrom_path.assign(file_dialog.selected_path);
emu_load_bootrom_sms(sms_bootrom_path);
}
}
static void file_dialog_load_gg_bootrom(void)
{
if(file_dialog.showFileDialog("Load Game Gear BIOS From...", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ImVec2(700, 310), ".gg,.bin,*.*", &dialog_in_use))
{
strcpy(gg_bootrom_path, file_dialog.selected_path.c_str());
config_emulator.gg_bootrom_path.assign(file_dialog.selected_path);
emu_load_bootrom_gg(gg_bootrom_path);
}
}
static void file_dialog_load_symbols(void)
{
if(file_dialog.showFileDialog("Load Symbols File...", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ImVec2(700, 400), ".sym,*.*", &dialog_in_use))
......
......@@ -15,6 +15,7 @@ SOURCES_CXX := $(CORE_DIR)/libretro.cpp \
$(SOURCE_DIR)/KoreanMemoryRule.cpp \
$(SOURCE_DIR)/MSXMemoryRule.cpp \
$(SOURCE_DIR)/SG1000MemoryRule.cpp \
$(SOURCE_DIR)/BootromMemoryRule.cpp \
$(SOURCE_DIR)/SmsIOPorts.cpp \
$(SOURCE_DIR)/opcodes.cpp \
$(SOURCE_DIR)/opcodes_cb.cpp \
......
OBJS=$(GEARSYSTEM_RPI_SRC)/main.o $(GEARSYSTEM_SRC)/Audio.o $(GEARSYSTEM_SRC)/GearsystemCore.o $(GEARSYSTEM_SRC)/audio/Blip_Buffer.o $(GEARSYSTEM_SRC)/audio/Multi_Buffer.o $(GEARSYSTEM_SRC)/audio/Effects_Buffer.o $(GEARSYSTEM_SRC)/audio/Sms_Apu.o $(GEARSYSTEM_SRC)/MemoryRule.o $(GEARSYSTEM_SRC)/Input.o $(GEARSYSTEM_SRC)/Processor.o $(GEARSYSTEM_SRC)/Video.o $(GEARSYSTEM_SRC)/Memory.o $(GEARSYSTEM_SRC)/Cartridge.o $(GEARSYSTEM_SRC)/CodemastersMemoryRule.o $(GEARSYSTEM_SRC)/GameGearIOPorts.o $(GEARSYSTEM_AUDIO_SRC)/Sound_Queue.o $(GEARSYSTEM_SRC)/opcodes.o $(GEARSYSTEM_SRC)/opcodes_cb.o $(GEARSYSTEM_SRC)/opcodes_ed.o $(GEARSYSTEM_SRC)/RomOnlyMemoryRule.o $(GEARSYSTEM_SRC)/SegaMemoryRule.o $(GEARSYSTEM_SRC)/SG1000MemoryRule.o $(GEARSYSTEM_SRC)/KoreanMemoryRule.o $(GEARSYSTEM_SRC)/MSXMemoryRule.o $(GEARSYSTEM_SRC)/SmsIOPorts.o
OBJS=$(GEARSYSTEM_RPI_SRC)/main.o $(GEARSYSTEM_SRC)/Audio.o $(GEARSYSTEM_SRC)/GearsystemCore.o $(GEARSYSTEM_SRC)/audio/Blip_Buffer.o $(GEARSYSTEM_SRC)/audio/Multi_Buffer.o $(GEARSYSTEM_SRC)/audio/Effects_Buffer.o $(GEARSYSTEM_SRC)/audio/Sms_Apu.o $(GEARSYSTEM_SRC)/MemoryRule.o $(GEARSYSTEM_SRC)/Input.o $(GEARSYSTEM_SRC)/Processor.o $(GEARSYSTEM_SRC)/Video.o $(GEARSYSTEM_SRC)/Memory.o $(GEARSYSTEM_SRC)/Cartridge.o $(GEARSYSTEM_SRC)/CodemastersMemoryRule.o $(GEARSYSTEM_SRC)/GameGearIOPorts.o $(GEARSYSTEM_AUDIO_SRC)/Sound_Queue.o $(GEARSYSTEM_SRC)/opcodes.o $(GEARSYSTEM_SRC)/opcodes_cb.o $(GEARSYSTEM_SRC)/opcodes_ed.o $(GEARSYSTEM_SRC)/RomOnlyMemoryRule.o $(GEARSYSTEM_SRC)/SegaMemoryRule.o $(GEARSYSTEM_SRC)/SG1000MemoryRule.o $(GEARSYSTEM_SRC)/KoreanMemoryRule.o $(GEARSYSTEM_SRC)/MSXMemoryRule.o $(GEARSYSTEM_SRC)/SmsIOPorts.o $(GEARSYSTEM_SRC)/BootromMemoryRule.o
BIN=gearsystem
......@@ -16,6 +16,7 @@
<ClCompile Include="..\..\src\audio\Effects_Buffer.cpp" />
<ClCompile Include="..\..\src\audio\Multi_Buffer.cpp" />
<ClCompile Include="..\..\src\audio\Sms_Apu.cpp" />
<ClCompile Include="..\..\src\BootromMemoryRule.cpp" />
<ClCompile Include="..\..\src\Cartridge.cpp" />
<ClCompile Include="..\..\src\CodemastersMemoryRule.cpp" />
<ClCompile Include="..\..\src\GameGearIOPorts.cpp" />
......@@ -61,6 +62,7 @@
<ClInclude Include="..\..\src\audio\Multi_Buffer.h" />
<ClInclude Include="..\..\src\audio\Sms_Apu.h" />
<ClInclude Include="..\..\src\audio\Sms_Oscs.h" />
<ClInclude Include="..\..\src\BootromMemoryRule.h" />
<ClInclude Include="..\..\src\Cartridge.h" />
<ClInclude Include="..\..\src\CodemastersMemoryRule.h" />
<ClInclude Include="..\..\src\definitions.h" />
......
......@@ -75,6 +75,9 @@
<ClCompile Include="..\..\src\Audio.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\BootromMemoryRule.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Cartridge.cpp">
<Filter>core</Filter>
</ClCompile>
......@@ -203,6 +206,9 @@
<ClInclude Include="..\..\src\Audio.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\BootromMemoryRule.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Cartridge.h">
<Filter>core</Filter>
</ClInclude>
......
/*
* Gearsystem - Sega Master System / Game Gear Emulator
* Copyright (C) 2013 Ignacio Sanchez
* 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 3 of the License, or
* 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, see http://www.gnu.org/licenses/
*
*/
#include "BootromMemoryRule.h"
#include "Memory.h"
#include "Cartridge.h"
BootromMemoryRule::BootromMemoryRule(Memory* pMemory, Cartridge* pCartridge) : MemoryRule(pMemory, pCartridge)
{
Reset();
}
BootromMemoryRule::~BootromMemoryRule()
{
}
u8 BootromMemoryRule::PerformRead(u16 address)
{
if (address < 0x400)
{
// First 1KB (fixed)
return m_pBootrom[address];
}
else if (address < 0x4000)
{
// ROM page 0
return m_pBootromBanks[address + m_iMapperSlotAddress[0]];
}
else if (address < 0x8000)
{
// ROM page 1
return m_pBootromBanks[(address - 0x4000) + m_iMapperSlotAddress[1]];
}
else if (address < 0xC000)
{
// ROM page 2
return m_pBootromBanks[(address - 0x8000) + m_iMapperSlotAddress[2]];
}
else
{
// RAM + RAM mirror
return m_pMemory->Retrieve(address);
}
}
void BootromMemoryRule::PerformWrite(u16 address, u8 value)
{
if (address < 0x8000)
{
// ROM page 0 and 1
Log("--> ** Attempting to write on ROM address $%X %X", address, value);
}
else if (address < 0xC000)
{
// ROM page 2
Log("--> ** Attempting to write on ROM page 2 $%X %X", address, value);
}
else if (address < 0xE000)
{
// RAM
m_pMemory->Load(address, value);
m_pMemory->Load(address + 0x2000, value);
}
else
{
// RAM (mirror)
m_pMemory->Load(address, value);
m_pMemory->Load(address - 0x2000, value);
switch (address)
{
case 0xFFFC:
{
Log("--> ** Boot Attempting to write on RAM setup registry $%X %X", address, value);
break;
}
case 0xFFFD:
{
m_iMapperSlot[0] = value & m_iBankMax;
m_iMapperSlotAddress[0] = m_iMapperSlot[0] * 0x4000;
break;
}
case 0xFFFE:
{
m_iMapperSlot[1] = value & m_iBankMax;
m_iMapperSlotAddress[1] = m_iMapperSlot[1] * 0x4000;
break;
}
case 0xFFFF:
{
m_iMapperSlot[2] = value & m_iBankMax;
m_iMapperSlotAddress[2] = m_iMapperSlot[2] * 0x4000;
break;
}
}
}
}
void BootromMemoryRule::Reset()
{
m_pBootrom = m_pMemory->GetBootrom();
m_pBootromBanks = m_pCartridge->IsGameGear() ? m_pCartridge->GetROM() : m_pBootrom;
m_iBankMax = m_pCartridge->IsGameGear() ? (m_pCartridge->GetROMBankCount() - 1) : (m_pMemory->GetBootromBankCount() - 1);
for (int i = 0; i < 3; i++)
{
m_iMapperSlot[i] = i;
m_iMapperSlotAddress[i] = i * 0x4000;
}
}
u8* BootromMemoryRule::GetPage(int index)
{
switch (index)
{
case 0:
case 1:
case 2:
return m_pBootrom + m_iMapperSlotAddress[index];
default:
return NULL;
}
}
int BootromMemoryRule::GetBank(int index)
{
switch (index)
{
case 0:
case 1:
case 2:
return m_iMapperSlot[index];
default:
return 0;
}
}
/*
* Gearsystem - Sega Master System / Game Gear Emulator
* Copyright (C) 2013 Ignacio Sanchez
* 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 3 of the License, or
* 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, see http://www.gnu.org/licenses/
*
*/
#ifndef BOOTROMMEMORYRULE_H
#define BOOTROMMEMORYRULE_H
#include "MemoryRule.h"
class BootromMemoryRule : public MemoryRule
{
public:
BootromMemoryRule(Memory* pMemory, Cartridge* pCartridge);
virtual ~BootromMemoryRule();
virtual u8 PerformRead(u16 address);
virtual void PerformWrite(u16 address, u8 value);
virtual void Reset();
virtual u8* GetPage(int index);
virtual int GetBank(int index);
private:
int m_iMapperSlot[3];
int m_iMapperSlotAddress[3];
u8* m_pBootrom;
u8* m_pBootromBanks;
int m_iBankMax;
};
#endif /* BOOTROMMEMORYRULE_H */
......@@ -408,17 +408,6 @@ bool Cartridge::LoadFromBuffer(const u8* buffer, int size)
return false;
}
unsigned int Cartridge::Pow2Ceil(u16 n)
{
--n;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
++n;
return n;
}
bool Cartridge::TestValidROM(u16 location)
{
if (location + 0x10 > m_iROMSize)
......
......@@ -96,7 +96,6 @@ public:
void ClearGameGenieCheats();
private:
unsigned int Pow2Ceil(u16 n);
bool GatherMetadata(u32 crc);
void GetInfoFromDB(u32 crc);
bool LoadFromZipFile(const u8* buffer, int size);
......
......@@ -22,13 +22,15 @@
#include "Video.h"
#include "Input.h"
#include "Cartridge.h"
#include "Memory.h"
GameGearIOPorts::GameGearIOPorts(Audio* pAudio, Video* pVideo, Input* pInput, Cartridge* pCartridge)
GameGearIOPorts::GameGearIOPorts(Audio* pAudio, Video* pVideo, Input* pInput, Cartridge* pCartridge, Memory* pMemory)
{
m_pAudio = pAudio;
m_pVideo = pVideo;
m_pInput = pInput;
m_pCartridge = pCartridge;
m_pMemory = pMemory;
m_Port3F = 0;
m_Port3F_HC = 0;
}
......@@ -41,6 +43,7 @@ void GameGearIOPorts::Reset()
{
m_Port3F = 0;
m_Port3F_HC = 0;
m_Port2 = 0;
}
u8 GameGearIOPorts::DoInput(u8 port)
......@@ -58,6 +61,8 @@ u8 GameGearIOPorts::DoInput(u8 port)
}
case 0x01:
return 0x7F;
case 0x02:
return m_Port2;
case 0x03:
case 0x05:
return 0x00;
......@@ -124,6 +129,10 @@ void GameGearIOPorts::DoOutput(u8 port, u8 value)
// SN76489 PSG
m_pAudio->WriteGGStereoRegister(value);
}
else if (port == 0x02)
{
m_Port2 = value;
}
}
else if (port < 0x40)
{
......@@ -132,6 +141,7 @@ void GameGearIOPorts::DoOutput(u8 port, u8 value)
if ((port & 0x01) == 0x00)
{
Log("--> ** Output to memory control port $%X: %X", port, value);
m_pMemory->SetPort3E(value);
}
else
{
......
......@@ -26,11 +26,12 @@ class Audio;
class Video;
class Input;
class Cartridge;
class Memory;
class GameGearIOPorts : public IOPorts
{
public:
GameGearIOPorts(Audio* pAudio, Video* pVideo, Input* pInput, Cartridge* pCartridge);