mirror of https://github.com/mgba-emu/mgba.git
DS Memory: Allow ARM7 to use mapped VRAM
This commit is contained in:
parent
0cb9c41a4a
commit
2f0ab002e2
|
@ -264,8 +264,17 @@ static void DS7SetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
||||||
cpu->memory.activeMask = DS_SIZE_RAM - 1;
|
cpu->memory.activeMask = DS_SIZE_RAM - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
goto jump_error;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
if (address < 0x06040000 && ds->memory.vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
// TODO: redzones
|
||||||
|
cpu->memory.activeRegion = (uint32_t*) ds->memory.vram7[(address & 0x3FFFF) >> 17];
|
||||||
|
cpu->memory.activeMask = 0x1FFFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
// Fall through
|
// Fall through
|
||||||
default:
|
default:
|
||||||
|
jump_error:
|
||||||
memory->activeRegion = -1;
|
memory->activeRegion = -1;
|
||||||
cpu->memory.activeRegion = _deadbeef;
|
cpu->memory.activeRegion = _deadbeef;
|
||||||
cpu->memory.activeMask = 0;
|
cpu->memory.activeMask = 0;
|
||||||
|
@ -305,6 +314,12 @@ uint32_t DS7Load32(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
||||||
case DS_REGION_IO:
|
case DS_REGION_IO:
|
||||||
value = DS7IORead32(ds, address & 0x00FFFFFC);
|
value = DS7IORead32(ds, address & 0x00FFFFFC);
|
||||||
break;
|
break;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
if (address < 0x06040000 && memory->vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
LOAD_32(value, address & 0x1FFFC, memory->vram7[(address & 0x3FFFF) >> 17]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Fall through
|
||||||
default:
|
default:
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS7 Load32: %08X", address);
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 Load32: %08X", address);
|
||||||
break;
|
break;
|
||||||
|
@ -345,6 +360,12 @@ uint32_t DS7Load16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
||||||
case DS_REGION_IO:
|
case DS_REGION_IO:
|
||||||
value = DS7IORead(ds, address & DS_OFFSET_MASK);
|
value = DS7IORead(ds, address & DS_OFFSET_MASK);
|
||||||
break;
|
break;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
if (address < 0x06040000 && memory->vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
LOAD_16(value, address & 0x1FFFE, memory->vram7[(address & 0x3FFFF) >> 17]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Fall through
|
||||||
default:
|
default:
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS7 Load16: %08X", address);
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 Load16: %08X", address);
|
||||||
break;
|
break;
|
||||||
|
@ -418,6 +439,12 @@ void DS7Store32(struct ARMCore* cpu, uint32_t address, int32_t value, int* cycle
|
||||||
case DS_REGION_IO:
|
case DS_REGION_IO:
|
||||||
DS7IOWrite32(ds, address & DS_OFFSET_MASK, value);
|
DS7IOWrite32(ds, address & DS_OFFSET_MASK, value);
|
||||||
break;
|
break;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
if (address < 0x06040000 && memory->vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
STORE_32(value, address & 0x1FFFC, memory->vram7[(address & 0x3FFFF) >> 17]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Fall through
|
||||||
default:
|
default:
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS7 Store32: %08X:%08X", address, value);
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 Store32: %08X:%08X", address, value);
|
||||||
break;
|
break;
|
||||||
|
@ -452,6 +479,12 @@ void DS7Store16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
|
||||||
case DS_REGION_IO:
|
case DS_REGION_IO:
|
||||||
DS7IOWrite(ds, address & DS_OFFSET_MASK, value);
|
DS7IOWrite(ds, address & DS_OFFSET_MASK, value);
|
||||||
break;
|
break;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
if (address < 0x06040000 && memory->vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
STORE_16(value, address & 0x1FFFE, memory->vram7[(address & 0x3FFFF) >> 17]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Fall through
|
||||||
default:
|
default:
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS7 Store16: %08X:%04X", address, value);
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 Store16: %08X:%04X", address, value);
|
||||||
break;
|
break;
|
||||||
|
@ -601,6 +634,13 @@ uint32_t DS7LoadMultiple(struct ARMCore* cpu, uint32_t address, int mask, enum L
|
||||||
case DS_REGION_IO:
|
case DS_REGION_IO:
|
||||||
LDM_LOOP(value = DS7IORead32(ds, address));
|
LDM_LOOP(value = DS7IORead32(ds, address));
|
||||||
break;
|
break;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
LDM_LOOP(if (address < 0x06040000 && memory->vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
LOAD_32(value, address & 0x1FFFF, memory->vram7[(address & 0x3FFFF) >> 17]);
|
||||||
|
} else {
|
||||||
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 LDM: %08X", address);
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS7 LDM: %08X", address);
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 LDM: %08X", address);
|
||||||
LDM_LOOP(value = 0);
|
LDM_LOOP(value = 0);
|
||||||
|
@ -660,6 +700,13 @@ uint32_t DS7StoreMultiple(struct ARMCore* cpu, uint32_t address, int mask, enum
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS9 STM: %08X", address);
|
mLOG(DS_MEM, STUB, "Unimplemented DS9 STM: %08X", address);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case DS_REGION_VRAM:
|
||||||
|
STM_LOOP(if (address < 0x06040000 && memory->vram7[(address & 0x3FFFF) >> 17]) {
|
||||||
|
STORE_32(value, address & 0x1FFFF, memory->vram7[(address & 0x3FFFF) >> 17]);
|
||||||
|
} else {
|
||||||
|
mLOG(DS_MEM, STUB, "Unimplemented DS7 STM: %08X", address);
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
mLOG(DS_MEM, STUB, "Unimplemented DS9 STM: %08X", address);
|
mLOG(DS_MEM, STUB, "Unimplemented DS9 STM: %08X", address);
|
||||||
STM_LOOP();
|
STM_LOOP();
|
||||||
|
|
Loading…
Reference in New Issue