GBA Memory: Fix DMA register writing behavior (fixes #148)

This commit is contained in:
Jeffrey Pfau 2015-11-04 20:19:12 -08:00
parent ec32efd8e4
commit 31862db5a5
4 changed files with 23 additions and 26 deletions

View File

@ -7,13 +7,13 @@ Features:
Bugfixes:
- Util: Fix PowerPC PNG read/write pixel order
- Qt: Use safer isLoaded check in GameController
- GBA Memory: Fix DMAs from BIOS while not in BIOS
- GBA: Fix idle skip state being retained between games
- Qt: Fix a race condition in PainterGL that could lead to a crash
- Qt: Fix clear button/analog buttons in gamepad mapper on some platforms
- GBA Video: Fix _mix for 15-bit color
- VFS: Fix VFileReadline and remove _vfdReadline
- Qt: Fix font size in memory viewer
- GBA Memory: Fix DMA register writing behavior
Misc:
- Qt: Window size command line options are now supported
- Qt: Increase usability of key mapper

View File

@ -535,28 +535,28 @@ void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) {
GBAAudioWriteFIFO(&gba->audio, address, value);
break;
case REG_DMA0SAD_LO:
GBAMemoryWriteDMASAD(gba, 0, value);
value = GBAMemoryWriteDMASAD(gba, 0, value);
break;
case REG_DMA0DAD_LO:
GBAMemoryWriteDMADAD(gba, 0, value);
value = GBAMemoryWriteDMADAD(gba, 0, value);
break;
case REG_DMA1SAD_LO:
GBAMemoryWriteDMASAD(gba, 1, value);
value = GBAMemoryWriteDMASAD(gba, 1, value);
break;
case REG_DMA1DAD_LO:
GBAMemoryWriteDMADAD(gba, 1, value);
value = GBAMemoryWriteDMADAD(gba, 1, value);
break;
case REG_DMA2SAD_LO:
GBAMemoryWriteDMASAD(gba, 2, value);
value = GBAMemoryWriteDMASAD(gba, 2, value);
break;
case REG_DMA2DAD_LO:
GBAMemoryWriteDMADAD(gba, 2, value);
value = GBAMemoryWriteDMADAD(gba, 2, value);
break;
case REG_DMA3SAD_LO:
GBAMemoryWriteDMASAD(gba, 3, value);
value = GBAMemoryWriteDMASAD(gba, 3, value);
break;
case REG_DMA3DAD_LO:
GBAMemoryWriteDMADAD(gba, 3, value);
value = GBAMemoryWriteDMADAD(gba, 3, value);
break;
default:
GBAIOWrite(gba, address, value & 0xFFFF);

View File

@ -330,12 +330,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
LOAD_32(value, address, memory->bios); \
} else { \
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load32: 0x%08X", address); \
if (memory->activeDMA) { \
/* TODO: Test on hardware */ \
value = 0; \
} else { \
value = memory->biosPrefetch; \
} \
value = memory->biosPrefetch; \
} \
} else { \
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load32: 0x%08X", address); \
@ -451,11 +446,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
LOAD_16(value, address, memory->bios);
} else {
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load16: 0x%08X", address);
if (memory->activeDMA) {
value = 0;
} else {
value = (memory->biosPrefetch >> ((address & 2) * 8)) & 0xFFFF;
}
value = (memory->biosPrefetch >> ((address & 2) * 8)) & 0xFFFF;
}
} else {
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address);
@ -1320,14 +1311,20 @@ void GBAAdjustWaitstates(struct GBA* gba, uint16_t parameters) {
cpu->memory.activeNonseqCycles16 = memory->waitstatesNonseq16[memory->activeRegion];
}
void GBAMemoryWriteDMASAD(struct GBA* gba, int dma, uint32_t address) {
uint32_t GBAMemoryWriteDMASAD(struct GBA* gba, int dma, uint32_t address) {
struct GBAMemory* memory = &gba->memory;
memory->dma[dma].source = address & 0x0FFFFFFE;
if ((dma >= 1 || address < BASE_CART0) && address >= BASE_WORKING_RAM && address < BASE_CART_SRAM) {
memory->dma[dma].source = address & 0x0FFFFFFE;
}
return memory->dma[dma].source;
}
void GBAMemoryWriteDMADAD(struct GBA* gba, int dma, uint32_t address) {
uint32_t GBAMemoryWriteDMADAD(struct GBA* gba, int dma, uint32_t address) {
struct GBAMemory* memory = &gba->memory;
memory->dma[dma].dest = address & 0x0FFFFFFE;
if ((dma >= 1 || address < BASE_CART0) && address >= BASE_WORKING_RAM && address < BASE_CART_SRAM) {
memory->dma[dma].dest = address & 0x0FFFFFFE;
}
return memory->dma[dma].dest;
}
void GBAMemoryWriteDMACNT_LO(struct GBA* gba, int dma, uint16_t count) {

View File

@ -166,8 +166,8 @@ uint32_t GBAStoreMultiple(struct ARMCore*, uint32_t baseAddress, int mask, enum
void GBAAdjustWaitstates(struct GBA* gba, uint16_t parameters);
void GBAMemoryWriteDMASAD(struct GBA* gba, int dma, uint32_t address);
void GBAMemoryWriteDMADAD(struct GBA* gba, int dma, uint32_t address);
uint32_t GBAMemoryWriteDMASAD(struct GBA* gba, int dma, uint32_t address);
uint32_t GBAMemoryWriteDMADAD(struct GBA* gba, int dma, uint32_t address);
void GBAMemoryWriteDMACNT_LO(struct GBA* gba, int dma, uint16_t count);
uint16_t GBAMemoryWriteDMACNT_HI(struct GBA* gba, int dma, uint16_t control);