mirror of https://github.com/mgba-emu/mgba.git
GBA DMA: Minor optimization of warm function
This commit is contained in:
parent
2ba42761b8
commit
3385f02b51
|
@ -244,7 +244,6 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
struct GBAMemory* memory = &gba->memory;
|
||||
struct ARMCore* cpu = gba->cpu;
|
||||
uint32_t width = 2 << GBADMARegisterGetWidth(info->reg);
|
||||
int32_t wordsRemaining = info->nextCount;
|
||||
uint32_t source = info->nextSource;
|
||||
uint32_t dest = info->nextDest;
|
||||
uint32_t sourceRegion = source >> BASE_OFFSET;
|
||||
|
@ -252,6 +251,8 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
int32_t cycles = 2;
|
||||
|
||||
gba->cpuBlocked = true;
|
||||
gba->performingDMA = 1 | (number << 1);
|
||||
|
||||
if (info->count == info->nextCount) {
|
||||
if (width == 4) {
|
||||
cycles += memory->waitstatesNonseq32[sourceRegion] + memory->waitstatesNonseq32[destRegion];
|
||||
|
@ -267,12 +268,10 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
}
|
||||
info->when += cycles;
|
||||
|
||||
gba->performingDMA = 1 | (number << 1);
|
||||
if (width == 4) {
|
||||
if (source) {
|
||||
memory->dmaTransferRegister = cpu->memory.load32(cpu, source, 0);
|
||||
}
|
||||
gba->bus = memory->dmaTransferRegister;
|
||||
cpu->memory.store32(cpu, dest, memory->dmaTransferRegister, 0);
|
||||
} else {
|
||||
if (sourceRegion == REGION_CART2_EX && (memory->savedata.type == SAVEDATA_EEPROM || memory->savedata.type == SAVEDATA_EEPROM512)) {
|
||||
|
@ -288,14 +287,13 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
GBASavedataInitEEPROM(&memory->savedata);
|
||||
}
|
||||
if (memory->savedata.type == SAVEDATA_EEPROM512 || memory->savedata.type == SAVEDATA_EEPROM) {
|
||||
GBASavedataWriteEEPROM(&memory->savedata, memory->dmaTransferRegister, wordsRemaining);
|
||||
GBASavedataWriteEEPROM(&memory->savedata, memory->dmaTransferRegister, info->nextCount);
|
||||
}
|
||||
} else {
|
||||
cpu->memory.store16(cpu, dest, memory->dmaTransferRegister, 0);
|
||||
|
||||
}
|
||||
gba->bus = memory->dmaTransferRegister;
|
||||
}
|
||||
gba->bus = memory->dmaTransferRegister;
|
||||
|
||||
int sourceOffset;
|
||||
if (info->nextSource >= BASE_CART0 && info->nextSource < BASE_CART_SRAM && GBADMARegisterGetSrcControl(info->reg) < 3) {
|
||||
|
@ -305,15 +303,12 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
}
|
||||
int destOffset = DMA_OFFSET[GBADMARegisterGetDestControl(info->reg)] * width;
|
||||
if (source) {
|
||||
source += sourceOffset;
|
||||
info->nextSource += sourceOffset;
|
||||
}
|
||||
dest += destOffset;
|
||||
--wordsRemaining;
|
||||
gba->performingDMA = 0;
|
||||
info->nextDest += destOffset;
|
||||
--info->nextCount;
|
||||
|
||||
info->nextCount = wordsRemaining;
|
||||
info->nextSource = source;
|
||||
info->nextDest = dest;
|
||||
gba->performingDMA = 0;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
|
@ -324,7 +319,7 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!wordsRemaining) {
|
||||
if (!info->nextCount) {
|
||||
info->nextCount |= 0x80000000;
|
||||
if (sourceRegion < REGION_CART0 || destRegion < REGION_CART0) {
|
||||
info->when += 2;
|
||||
|
|
Loading…
Reference in New Issue