diff --git a/accuracy/suite.py b/accuracy/suite.py index b5baebf..670b1be 100644 --- a/accuracy/suite.py +++ b/accuracy/suite.py @@ -67,7 +67,6 @@ screenshot ./.tests_screenshots/jsmolka_sram.png ''', screenshot='jsmolka_sram.png', - skip=True, ), Test( name="Jsmolka - save/none.gba", @@ -82,21 +81,19 @@ name="Jsmolka - save/flash64.gba", rom='jsmolka-flash64.gba', code=''' - frame 10 + frame 110 screenshot ./.tests_screenshots/jsmolka_flash64.png ''', screenshot='jsmolka_flash64.png', - skip=True, ), Test( name="Jsmolka - save/flash128.gba", rom='jsmolka-flash128.gba', code=''' - frame 10 + frame 110 screenshot ./.tests_screenshots/jsmolka_flash128.png ''', screenshot='jsmolka_flash128.png', - skip=True, ), # mGBA suite diff --git a/source/gba/memory/memory.c b/source/gba/memory/memory.c index f258eaf..7743e69 100644 --- a/source/gba/memory/memory.c +++ b/source/gba/memory/memory.c @@ -360,7 +360,7 @@ mem_openbus_read( }) /* -** Wriote a data of type T to memory at the given address. +** Write a data of type T to memory at the given address. ** ** T must be either uint32_t, uint16_t or uint8_t. */ @@ -468,20 +468,14 @@ mem_openbus_read( }; \ case SRAM_REGION: \ case SRAM_MIRROR_REGION: \ - _Generic(val, \ - uint32_t: ({ \ - mem_backup_storage_write8((gba), (unaligned_addr) + 0, (uint8_t)((val) >> 0)); \ - mem_backup_storage_write8((gba), (unaligned_addr) + 1, (uint8_t)((val) >> 8)); \ - mem_backup_storage_write8((gba), (unaligned_addr) + 2, (uint8_t)((val) >> 16)); \ - mem_backup_storage_write8((gba), (unaligned_addr) + 3, (uint8_t)((val) >> 24)); \ - }), \ - uint16_t: ({ \ - mem_backup_storage_write8((gba), (unaligned_addr) + 0, (uint8_t)((val) >> 0)); \ - mem_backup_storage_write8((gba), (unaligned_addr) + 1, (uint8_t)((val) >> 8)); \ - }), \ - default: ({ \ - mem_backup_storage_write8((gba), (unaligned_addr), (val)); \ - }) \ + /* + ** All writes to the backup storage are u8 writes, eventually rotated if the + ** address isn't aligned on T. + */ \ + mem_backup_storage_write8( \ + (gba), \ + (unaligned_addr), \ + ((val) >> (8 * ((unaligned_addr) % sizeof(T)))) \ ); \ break; \ default: { \ diff --git a/source/gba/memory/storage/flash.c b/source/gba/memory/storage/flash.c index 80963c1..96a653a 100644 --- a/source/gba/memory/storage/flash.c +++ b/source/gba/memory/storage/flash.c @@ -53,13 +53,6 @@ mem_flash_write8( case FLASH_CMD_ENTER_IDENTITY: flash->identity_mode = true; break; case FLASH_CMD_EXIT_IDENTITY: flash->identity_mode = false; break; case FLASH_CMD_PREP_ERASE: flash->state = FLASH_STATE_ERASE; break; - case FLASH_CMD_ERASE_CHIP: { - if (flash->state == FLASH_STATE_ERASE) { - memset(gba->shared_data.backup_storage.data, 0xFF, gba->shared_data.backup_storage.size); - gba->shared_data.backup_storage.dirty = true; - } - break; - }; case FLASH_CMD_WRITE: flash->state = FLASH_STATE_WRITE; break; case FLASH_CMD_SET_BANK: { if (gba->memory.backup_storage.type == BACKUP_FLASH128) { @@ -68,9 +61,12 @@ mem_flash_write8( break; }; } + } else if (flash->state == FLASH_STATE_ERASE && addr == 0x5555 && val == FLASH_CMD_ERASE_CHIP) { + memset(gba->shared_data.backup_storage.data, 0xFF, gba->shared_data.backup_storage.size); + gba->shared_data.backup_storage.dirty = true; + flash->state = FLASH_STATE_READY; } else if (flash->state == FLASH_STATE_ERASE && !(addr & ~0xF000) && val == FLASH_CMD_ERASE_SECTOR) { // Erase the desired sector - addr &= 0xF000; memset(gba->shared_data.backup_storage.data + addr + flash->bank * FLASH64_SIZE, 0xFF, 0x1000); gba->shared_data.backup_storage.dirty = true;