From afc0a9df57907264fb7526ba9065c9e1cf944022 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 7 Jan 2015 22:18:08 -0800 Subject: [PATCH] GBA BIOS: Implement (most of) RegisterRamReset --- CHANGES | 2 +- src/gba/gba-bios.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 57080449d..0cb62ea34 100644 --- a/CHANGES +++ b/CHANGES @@ -14,7 +14,7 @@ Features: - Support for games using the tilt sensor - Remappable shortcuts for keyboard and gamepad - Rewinding of emulation - - Implemented BIOS routines Diff8bitUnFilterWram, Diff8bitUnFilterVram, and Diff16bitUnFilter + - Implemented BIOS routines RegisterRamReset, Diff8bitUnFilterWram, Diff8bitUnFilterVram, and Diff16bitUnFilter Bugfixes: - Qt: Fix issue with set frame sizes being the wrong height - Qt: Fix emulator crashing when full screen if a game is not running diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index 5f3ad806d..16d112138 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -19,8 +19,32 @@ static void _unFilter(struct GBA* gba, int inwidth, int outwidth); static void _RegisterRamReset(struct GBA* gba) { uint32_t registers = gba->cpu->gprs[0]; - UNUSED(registers); - GBALog(gba, GBA_LOG_STUB, "RegisterRamReset unimplemented"); + struct ARMCore* cpu = gba->cpu; + cpu->memory.store16(cpu, BASE_IO | REG_DISPCNT, 0x0080, 0); + if (registers & 0x01) { + memset(gba->memory.wram, 0, SIZE_WORKING_RAM); + } + if (registers & 0x02) { + memset(gba->memory.iwram, 0, SIZE_WORKING_IRAM - 0x200); + } + if (registers & 0x04) { + memset(gba->video.palette, 0, SIZE_PALETTE_RAM); + } + if (registers & 0x08) { + memset(gba->video.renderer->vram, 0, SIZE_VRAM); + } + if (registers & 0x10) { + memset(gba->video.oam.raw, 0, SIZE_OAM); + } + if (registers & 0x20) { + GBALog(gba, GBA_LOG_STUB, "RegisterRamReset on SIO unimplemented"); + } + if (registers & 0x40) { + GBALog(gba, GBA_LOG_STUB, "RegisterRamReset on Audio unimplemented"); + } + if (registers & 0x80) { + GBALog(gba, GBA_LOG_STUB, "RegisterRamReset on IO unimplemented"); + } } static void _BgAffineSet(struct GBA* gba) {