From 4d1f3d419ee2859a243bc8fb1db37afaffee8a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Zumer?= Date: Tue, 10 Dec 2019 09:57:10 -0500 Subject: [PATCH] Clarify comments and credit DeSmuME for Flash I/O --- src/GBACart.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/GBACart.cpp b/src/GBACart.cpp index 2260e06c..1011971c 100644 --- a/src/GBACart.cpp +++ b/src/GBACart.cpp @@ -36,6 +36,7 @@ enum SaveType { S_FLASH1M }; +// from DeSmuME struct FlashProperties { u8 state; @@ -179,6 +180,7 @@ void RelocateSave(const char* path, bool write) fwrite(SRAM, SRAMLength, 1, SRAMFile); } +// mostly ported from DeSmuME u8 Read_Flash(u32 addr) { if (SRAMFlash.cmd == 0) // no cmd @@ -196,10 +198,10 @@ u8 Read_Flash(u32 addr) SRAMFlash.state = 0; SRAMFlash.cmd = 0; break; - case 0xA0: // erase command - break; // ignore here, handled during writes + case 0xA0: // write command + break; // ignore here, handled in Write_Flash() case 0xB0: // bank switching (128K only) - break; // ignore here, handled during writes + break; // ignore here, handled in Write_Flash() default: printf("GBACart_SRAM::Read_Flash: unknown command 0x%02X @ 0x%04X\n", SRAMFlash.cmd, addr); break; @@ -215,6 +217,7 @@ void Write_EEPROM(u32 addr, u8 val) // TODO: could be used in homebrew? } +// mostly ported from DeSmuME void Write_Flash(u32 addr, u8 val) { switch (SRAMFlash.state) @@ -352,7 +355,6 @@ void Write_SRAM(u32 addr, u8 val) { u8 prev = *(u8*)&SRAM[addr]; - // TODO: try not to do this for every byte if (prev != val) { *(u8*)&SRAM[addr] = val;