GBA: Yank support, needs work
Jeffrey Pfau jeffrey@endrift.com
Fri, 19 Jun 2015 01:12:46 -0700
7 files changed,
28 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -21,6 +21,7 @@ - Ability to cap fast forward speed
- Finer control over FPS target - Holdable shortcut for rewinding one frame at a time - Ability to boot directly into the BIOS + - Preliminary support for yanking out the game pak while a game is running Bugfixes: - ARM7: Fix SWI and IRQ timings - GBA Audio: Force audio FIFOs to 32-bit
M
src/gba/gba.c
→
src/gba/gba.c
@@ -376,6 +376,7 @@ if (!gba->pristineRom) {
GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM"); return; } + gba->yankedRomSize = 0; gba->memory.rom = gba->pristineRom; gba->activeFile = fname; gba->memory.romSize = gba->pristineRomSize;@@ -383,6 +384,11 @@ gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize);
GBASavedataInit(&gba->memory.savedata, sav); GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]); // TODO: error check +} + +void GBAYankROM(struct GBA* gba) { + gba->yankedRomSize = gba->memory.romSize; + gba->memory.romSize = 0; } void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
M
src/gba/gba.h
→
src/gba/gba.h
@@ -146,6 +146,7 @@
struct GBARRContext* rr; void* pristineRom; size_t pristineRomSize; + size_t yankedRomSize; uint32_t romCrc32; struct VFile* romVf; struct VFile* biosVf;@@ -206,6 +207,7 @@ void GBASetBreakpoint(struct GBA* gba, struct ARMComponent* component, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);
void GBAClearBreakpoint(struct GBA* gba, uint32_t address, enum ExecutionMode mode, uint32_t opcode); void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname); +void GBAYankROM(struct GBA* gba); void GBALoadBIOS(struct GBA* gba, struct VFile* vf); void GBAApplyPatch(struct GBA* gba, struct Patch* patch);
M
src/gba/memory.c
→
src/gba/memory.c
@@ -18,7 +18,7 @@ #define IDLE_LOOP_THRESHOLD 10000
static uint32_t _popcount32(unsigned bits); static void _pristineCow(struct GBA* gba); -static uint32_t _deadbeef[2] = { 0xDEADBEEF, 0xFEEDFACE }; +static uint32_t _deadbeef[1] = { 0xF00FC7C8 }; static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t region); static void GBAMemoryServiceDMA(struct GBA* gba, int number, struct GBADMA* info);@@ -273,7 +273,9 @@ default:
memory->activeRegion = 0; cpu->memory.activeRegion = _deadbeef; cpu->memory.activeMask = 0; - GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address"); + if (!gba->yankedRomSize) { + GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address"); + } break; } cpu->memory.activeSeqCycles32 = memory->waitstatesPrefetchSeq32[memory->activeRegion];
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -325,6 +325,15 @@ openGame();
} } +void GameController::yankPak() { + if (!m_gameOpen) { + return; + } + threadInterrupt(); + GBAYankROM(m_threadContext.gba); + threadContinue(); +} + void GameController::loadPatch(const QString& path) { if (m_gameOpen) { closeGame();
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -97,6 +97,7 @@
public slots: void loadGame(const QString& path, bool dirmode = false); void loadBIOS(const QString& path); + void yankPak(); void setSkipBIOS(bool); void setUseBIOS(bool); void loadPatch(const QString& path);
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -698,6 +698,11 @@ QAction* shutdown = new QAction(tr("Sh&utdown"), emulationMenu);
connect(shutdown, SIGNAL(triggered()), m_controller, SLOT(closeGame())); m_gameActions.append(shutdown); addControlledAction(emulationMenu, shutdown, "shutdown"); + + QAction* yank = new QAction(tr("Yank game pak"), emulationMenu); + connect(yank, SIGNAL(triggered()), m_controller, SLOT(yankPak())); + m_gameActions.append(yank); + addControlledAction(emulationMenu, yank, "yank"); emulationMenu->addSeparator(); QAction* pause = new QAction(tr("&Pause"), emulationMenu);