all repos — mgba @ c3e02f9c92f7f834a8baef8fc597ff6c0f5eb6b7

mGBA Game Boy Advance Emulator

GBA Savedata: Remove ability to disable realistic timing
Vicki Pfau vi@endrift.com
Tue, 08 May 2018 10:25:09 -0700
commit

c3e02f9c92f7f834a8baef8fc597ff6c0f5eb6b7

parent

a4e105737c43742d3a0e52ba8582730456569488

M CHANGESCHANGES

@@ -52,6 +52,7 @@ - GBA Memory: 64 MiB GBA Video cartridge support

- PSP2: Use system enter key by default - 3DS: Remove deprecated CSND interface - Qt: Options to mess around with layer placement + - GBA Savedata: Remove ability to disable realistic timing 0.6.3: (2017-04-14) Bugfixes:
M include/mgba/internal/gba/gba.hinclude/mgba/internal/gba/gba.h

@@ -112,7 +112,6 @@ int idleDetectionFailures;

int32_t cachedRegisters[16]; bool taintedRegisters[16]; - bool realisticTiming; bool hardCrash; bool allowOpposingDirections;
M include/mgba/internal/gba/savedata.hinclude/mgba/internal/gba/savedata.h

@@ -87,7 +87,6 @@

uint8_t* currentBank; struct mTiming* timing; - bool realisticTiming; unsigned settling; struct mTimingEvent dust;

@@ -105,10 +104,10 @@ void GBASavedataUnmask(struct GBASavedata* savedata);

size_t GBASavedataSize(const struct GBASavedata* savedata); bool GBASavedataClone(struct GBASavedata* savedata, struct VFile* out); bool GBASavedataLoad(struct GBASavedata* savedata, struct VFile* in); -void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type, bool realisticTiming); +void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type); -void GBASavedataInitFlash(struct GBASavedata* savedata, bool realisticTiming); -void GBASavedataInitEEPROM(struct GBASavedata* savedata, bool realisticTiming); +void GBASavedataInitFlash(struct GBASavedata* savedata); +void GBASavedataInitEEPROM(struct GBASavedata* savedata); void GBASavedataInitSRAM(struct GBASavedata* savedata); uint8_t GBASavedataReadFlash(struct GBASavedata* savedata, uint16_t address);
M src/gba/dma.csrc/gba/dma.c

@@ -265,7 +265,7 @@ } else {

if (sourceRegion == REGION_CART2_EX && memory->savedata.type == SAVEDATA_EEPROM) { if (memory->savedata.type == SAVEDATA_AUTODETECT) { mLOG(GBA_MEM, INFO, "Detected EEPROM savegame"); - GBASavedataInitEEPROM(&memory->savedata, gba->realisticTiming); + GBASavedataInitEEPROM(&memory->savedata); } memory->dmaTransferRegister = GBASavedataReadEEPROM(&memory->savedata); } else {

@@ -276,7 +276,7 @@ }

if (destRegion == REGION_CART2_EX) { if (memory->savedata.type == SAVEDATA_AUTODETECT) { mLOG(GBA_MEM, INFO, "Detected EEPROM savegame"); - GBASavedataInitEEPROM(&memory->savedata, gba->realisticTiming); + GBASavedataInitEEPROM(&memory->savedata); } GBASavedataWriteEEPROM(&memory->savedata, memory->dmaTransferRegister, wordsRemaining); } else {
M src/gba/gba.csrc/gba/gba.c

@@ -105,7 +105,6 @@

gba->idleOptimization = IDLE_LOOP_REMOVE; gba->idleLoop = IDLE_LOOP_NONE; - gba->realisticTiming = true; gba->hardCrash = true; gba->allowOpposingDirections = true;
M src/gba/memory.csrc/gba/memory.c

@@ -895,7 +895,7 @@ break;

case REGION_CART2_EX: if (memory->savedata.type == SAVEDATA_AUTODETECT) { mLOG(GBA_MEM, INFO, "Detected EEPROM savegame"); - GBASavedataInitEEPROM(&memory->savedata, gba->realisticTiming); + GBASavedataInitEEPROM(&memory->savedata); } GBASavedataWriteEEPROM(&memory->savedata, value, 1); break;

@@ -961,7 +961,7 @@ case REGION_CART_SRAM_MIRROR:

if (memory->savedata.type == SAVEDATA_AUTODETECT) { if (address == SAVEDATA_FLASH_BASE) { mLOG(GBA_MEM, INFO, "Detected Flash savegame"); - GBASavedataInitFlash(&memory->savedata, gba->realisticTiming); + GBASavedataInitFlash(&memory->savedata); } else { mLOG(GBA_MEM, INFO, "Detected SRAM savegame"); GBASavedataInitSRAM(&memory->savedata);
M src/gba/overrides.csrc/gba/overrides.c

@@ -296,7 +296,7 @@ }

void GBAOverrideApply(struct GBA* gba, const struct GBACartridgeOverride* override) { if (override->savetype != SAVEDATA_AUTODETECT) { - GBASavedataForceType(&gba->memory.savedata, override->savetype, gba->realisticTiming); + GBASavedataForceType(&gba->memory.savedata, override->savetype); } if (override->hardware != HW_NO_OVERRIDE) {
M src/gba/savedata.csrc/gba/savedata.c

@@ -91,7 +91,7 @@ GBASavedataDeinit(savedata);

savedata->vf = vf; savedata->mapMode = MAP_READ; savedata->maskWriteback = writeback; - GBASavedataForceType(savedata, type, savedata->realisticTiming); + GBASavedataForceType(savedata, type); } void GBASavedataUnmask(struct GBASavedata* savedata) {

@@ -103,7 +103,7 @@ struct VFile* vf = savedata->vf;

GBASavedataDeinit(savedata); savedata->vf = savedata->realVf; savedata->mapMode = MAP_WRITE; - GBASavedataForceType(savedata, type, savedata->realisticTiming); + GBASavedataForceType(savedata, type); if (savedata->maskWriteback) { GBASavedataLoad(savedata, vf); savedata->maskWriteback = false;

@@ -193,7 +193,7 @@ }

return true; } -void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type, bool realisticTiming) { +void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type) { if (savedata->type != SAVEDATA_AUTODETECT) { struct VFile* vf = savedata->vf; GBASavedataDeinit(savedata);

@@ -203,10 +203,10 @@ switch (type) {

case SAVEDATA_FLASH512: case SAVEDATA_FLASH1M: savedata->type = type; - GBASavedataInitFlash(savedata, realisticTiming); + GBASavedataInitFlash(savedata); break; case SAVEDATA_EEPROM: - GBASavedataInitEEPROM(savedata, realisticTiming); + GBASavedataInitEEPROM(savedata); break; case SAVEDATA_SRAM: GBASavedataInitSRAM(savedata);

@@ -219,7 +219,7 @@ break;

} } -void GBASavedataInitFlash(struct GBASavedata* savedata, bool realisticTiming) { +void GBASavedataInitFlash(struct GBASavedata* savedata) { if (savedata->type == SAVEDATA_AUTODETECT) { savedata->type = SAVEDATA_FLASH512; }

@@ -244,13 +244,12 @@ savedata->data = savedata->vf->map(savedata->vf, flashSize, savedata->mapMode);

} savedata->currentBank = savedata->data; - savedata->realisticTiming = realisticTiming; if (end < SIZE_CART_FLASH512) { memset(&savedata->data[end], 0xFF, flashSize - end); } } -void GBASavedataInitEEPROM(struct GBASavedata* savedata, bool realisticTiming) { +void GBASavedataInitEEPROM(struct GBASavedata* savedata) { if (savedata->type == SAVEDATA_AUTODETECT) { savedata->type = SAVEDATA_EEPROM; } else {

@@ -271,7 +270,6 @@ eepromSize = SIZE_CART_EEPROM;

} savedata->data = savedata->vf->map(savedata->vf, eepromSize, savedata->mapMode); } - savedata->realisticTiming = realisticTiming; if (end < SIZE_CART_EEPROM512) { memset(&savedata->data[end], 0xFF, SIZE_CART_EEPROM512 - end); }

@@ -327,10 +325,8 @@ case FLASH_COMMAND_PROGRAM:

savedata->dirty |= SAVEDATA_DIRT_NEW; savedata->currentBank[address] = value; savedata->command = FLASH_COMMAND_NONE; - if (savedata->realisticTiming) { - mTimingDeschedule(savedata->timing, &savedata->dust); - mTimingSchedule(savedata->timing, &savedata->dust, FLASH_PROGRAM_CYCLES); - } + mTimingDeschedule(savedata->timing, &savedata->dust); + mTimingSchedule(savedata->timing, &savedata->dust, FLASH_PROGRAM_CYCLES); break; case FLASH_COMMAND_SWITCH_BANK: if (address == 0 && value < 2) {

@@ -452,10 +448,8 @@ current &= ~(1 << (0x7 - (savedata->writeAddress & 0x7)));

current |= (value & 0x1) << (0x7 - (savedata->writeAddress & 0x7)); savedata->dirty |= SAVEDATA_DIRT_NEW; savedata->data[savedata->writeAddress >> 3] = current; - if (savedata->realisticTiming) { - mTimingDeschedule(savedata->timing, &savedata->dust); - mTimingSchedule(savedata->timing, &savedata->dust, EEPROM_SETTLE_CYCLES); - } + mTimingDeschedule(savedata->timing, &savedata->dust); + mTimingSchedule(savedata->timing, &savedata->dust, EEPROM_SETTLE_CYCLES); ++savedata->writeAddress; } else { mLOG(GBA_SAVE, GAME_ERROR, "Writing beyond end of EEPROM: %08X", (savedata->writeAddress >> 3));

@@ -478,7 +472,7 @@ }

uint16_t GBASavedataReadEEPROM(struct GBASavedata* savedata) { if (savedata->command != EEPROM_COMMAND_READ) { - if (!savedata->realisticTiming || !mTimingIsScheduled(savedata->timing, &savedata->dust)) { + if (!mTimingIsScheduled(savedata->timing, &savedata->dust)) { return 1; } else { return 0;

@@ -551,7 +545,7 @@

void GBASavedataDeserialize(struct GBASavedata* savedata, const struct GBASerializedState* state) { if (savedata->type != state->savedata.type) { mLOG(GBA_SAVE, DEBUG, "Switching save types"); - GBASavedataForceType(savedata, state->savedata.type, savedata->realisticTiming); + GBASavedataForceType(savedata, state->savedata.type); } savedata->command = state->savedata.command; GBASerializedSavedataFlags flags = state->savedata.flags;

@@ -609,9 +603,7 @@ if (savedata->type == SAVEDATA_FLASH1M) {

mLOG(GBA_SAVE, DEBUG, "Performing unknown sector-size erase at 0x%04x", sectorStart); } savedata->settling = sectorStart >> 12; - if (savedata->realisticTiming) { - mTimingDeschedule(savedata->timing, &savedata->dust); - mTimingSchedule(savedata->timing, &savedata->dust, FLASH_ERASE_CYCLES); - } + mTimingDeschedule(savedata->timing, &savedata->dust); + mTimingSchedule(savedata->timing, &savedata->dust, FLASH_ERASE_CYCLES); memset(&savedata->currentBank[sectorStart & ~(size - 1)], 0xFF, size); }
M src/gba/sharkport.csrc/gba/sharkport.c

@@ -117,7 +117,7 @@ uint32_t copySize = size - 0x1C;

switch (gba->memory.savedata.type) { case SAVEDATA_FLASH512: if (copySize > SIZE_CART_FLASH512) { - GBASavedataForceType(&gba->memory.savedata, SAVEDATA_FLASH1M, gba->memory.savedata.realisticTiming); + GBASavedataForceType(&gba->memory.savedata, SAVEDATA_FLASH1M); } // Fall through default: