GBA Savedata: Remove ability to disable realistic timing

This commit is contained in:
Vicki Pfau 2018-05-08 10:25:09 -07:00
parent a4e105737c
commit c3e02f9c92
9 changed files with 25 additions and 35 deletions

View File

@ -52,6 +52,7 @@ Misc:
- 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:

View File

@ -112,7 +112,6 @@ struct GBA {
int32_t cachedRegisters[16];
bool taintedRegisters[16];
bool realisticTiming;
bool hardCrash;
bool allowOpposingDirections;

View File

@ -87,7 +87,6 @@ struct GBASavedata {
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);

View File

@ -265,7 +265,7 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
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 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
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 {

View File

@ -105,7 +105,6 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) {
gba->idleOptimization = IDLE_LOOP_REMOVE;
gba->idleLoop = IDLE_LOOP_NONE;
gba->realisticTiming = true;
gba->hardCrash = true;
gba->allowOpposingDirections = true;

View File

@ -895,7 +895,7 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
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 @@ void GBAStore8(struct ARMCore* cpu, uint32_t address, int8_t value, int* cycleCo
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);

View File

@ -296,7 +296,7 @@ void GBAOverrideSave(struct Configuration* config, const struct GBACartridgeOver
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) {

View File

@ -91,7 +91,7 @@ void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf, bool writeb
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 @@ void GBASavedataUnmask(struct GBASavedata* savedata) {
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 @@ bool GBASavedataLoad(struct GBASavedata* savedata, struct VFile* in) {
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 @@ void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType 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 @@ void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type,
}
}
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 @@ void GBASavedataInitFlash(struct GBASavedata* savedata, bool realisticTiming) {
}
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 @@ void GBASavedataInitEEPROM(struct GBASavedata* savedata, bool realisticTiming) {
}
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 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
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 @@ void GBASavedataWriteEEPROM(struct GBASavedata* savedata, uint16_t value, uint32
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 @@ void GBASavedataWriteEEPROM(struct GBASavedata* savedata, uint16_t value, uint32
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 GBASavedataSerialize(const struct GBASavedata* savedata, struct GBASerializ
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 @@ void _flashEraseSector(struct GBASavedata* savedata, uint16_t sectorStart) {
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);
}

View File

@ -117,7 +117,7 @@ bool GBASavedataImportSharkPort(struct GBA* gba, struct VFile* vf, bool testChec
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: