|
|
@@ -220,7 +220,7 @@ uint8_t GBLoad8(struct LR35902Core* cpu, uint16_t address) { |
|
|
return memory->rtcRegs[memory->activeRtcReg];
|
|
|
} else if (memory->mbcRead) {
|
|
|
return memory->mbcRead(memory, address);
|
|
|
- } else if (memory->sramAccess) {
|
|
|
+ } else if (memory->sramAccess && memory->sram) {
|
|
|
return memory->sramBank[address & (GB_SIZE_EXTERNAL_RAM - 1)];
|
|
|
} else if (memory->mbcType == GB_HuC3) {
|
|
|
return 0x01; // TODO: Is this supposed to be the current SRAM bank?
|
|
|
@@ -289,7 +289,7 @@ void GBStore8(struct LR35902Core* cpu, uint16_t address, int8_t value) { |
|
|
case GB_REGION_EXTERNAL_RAM + 1:
|
|
|
if (memory->rtcAccess) {
|
|
|
memory->rtcRegs[memory->activeRtcReg] = value;
|
|
|
- } else if (memory->sramAccess) {
|
|
|
+ } else if (memory->sramAccess && memory->sram) {
|
|
|
memory->sramBank[address & (GB_SIZE_EXTERNAL_RAM - 1)] = value;
|
|
|
} else if (memory->mbcType == GB_MBC7) {
|
|
|
GBMBC7Write(memory, address, value);
|
|
|
@@ -387,7 +387,7 @@ uint8_t GBView8(struct LR35902Core* cpu, uint16_t address, int segment) { |
|
|
if (memory->rtcAccess) {
|
|
|
return memory->rtcRegs[memory->activeRtcReg];
|
|
|
} else if (memory->sramAccess) {
|
|
|
- if (segment < 0) {
|
|
|
+ if (segment < 0 && memory->sram) {
|
|
|
return memory->sramBank[address & (GB_SIZE_EXTERNAL_RAM - 1)];
|
|
|
} else if ((size_t) segment * GB_SIZE_EXTERNAL_RAM < gb->sramSize) {
|
|
|
return memory->sram[(address & (GB_SIZE_EXTERNAL_RAM - 1)) + segment *GB_SIZE_EXTERNAL_RAM];
|
|
|
|
0 comments on commit
aa9994a