GB Memory: Support running from blocked memory

This commit is contained in:
Vicki Pfau 2018-12-05 19:39:29 -08:00
parent 42f65db396
commit 0332db8961
2 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Bugfixes:
Misc:
- GBA Savedata: EEPROM performance fixes
- GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash
- GB Memory: Support running from blocked memory
0.7.0: (Future)
Features:

View File

@ -45,6 +45,8 @@ static const enum GBBus _oamBlockCGB[] = {
GB_BUS_CPU // 0xE000
};
static const uint8_t _blockedRegion[1] = { 0xFF };
static void _pristineCow(struct GB* gba);
static uint8_t GBFastLoad8(struct LR35902Core* cpu, uint16_t address) {
@ -92,6 +94,15 @@ static void GBSetActiveRegion(struct LR35902Core* cpu, uint16_t address) {
cpu->memory.cpuLoad8 = GBLoad8;
break;
}
if (gb->memory.dmaRemaining) {
const enum GBBus* block = gb->model < GB_MODEL_CGB ? _oamBlockDMG : _oamBlockCGB;
enum GBBus dmaBus = block[memory->dmaSource >> 13];
enum GBBus accessBus = block[address >> 13];
if ((dmaBus != GB_BUS_CPU && dmaBus == accessBus) || (address >= GB_BASE_OAM && address < GB_BASE_UNUSABLE)) {
cpu->memory.activeRegion = _blockedRegion;
cpu->memory.activeMask = 0;
}
}
}
static void _GBMemoryDMAService(struct mTiming* timing, void* context, uint32_t cyclesLate);