From: Pokemonhacker <pok...@us...> - 2004-11-14 18:54:28
|
Update of /cvsroot/vba/VisualBoyAdvance/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30268 Modified Files: Flash.cpp Flash.h GBA.cpp Sram.cpp Sram.h Log Message: - fixed battery saving bug when save type equals Flash or Sram - initialize sram and flash memory to 0xff instead of 0x00 - clean flash/sram on load/reload - fixed a compilation warning Index: Sram.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/Sram.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Sram.cpp 13 May 2004 15:06:44 -0000 1.3 --- Sram.cpp 14 Nov 2004 18:54:14 -0000 1.4 *************** *** 18,21 **** --- 18,22 ---- #include "GBA.h" + #include "Globals.h" #include "Flash.h" #include "Sram.h" *************** *** 25,28 **** --- 26,35 ---- return flashSaveMemory[address & 0xFFFF]; } + void sramDelayedWrite(u32 address, u8 byte) + { + saveType = 1; + cpuSaveGameFunc = sramWrite; + sramWrite(address, byte); + } void sramWrite(u32 address, u8 byte) Index: GBA.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/GBA.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** GBA.cpp 15 Sep 2004 22:12:52 -0000 1.57 --- GBA.cpp 14 Nov 2004 18:54:14 -0000 1.58 *************** *** 1400,1403 **** --- 1400,1405 ---- } + flashInit(); + CPUUpdateRenderBuffers(true); *************** *** 3297,3300 **** --- 3299,3303 ---- cpuEEPROMEnabled = true; cpuEEPROMSensorEnabled = false; + // EEPROM usage is automatically detected break; case 2: // SRAM *************** *** 3303,3307 **** cpuEEPROMEnabled = false; cpuEEPROMSensorEnabled = false; ! cpuSaveGameFunc = sramWrite; break; case 3: // FLASH --- 3306,3310 ---- cpuEEPROMEnabled = false; cpuEEPROMSensorEnabled = false; ! cpuSaveGameFunc = sramDelayedWrite; // to insure we detect the write break; case 3: // FLASH *************** *** 3310,3314 **** cpuEEPROMEnabled = false; cpuEEPROMSensorEnabled = false; ! cpuSaveGameFunc = flashWrite; break; case 4: // EEPROM+Sensor --- 3313,3317 ---- cpuEEPROMEnabled = false; cpuEEPROMSensorEnabled = false; ! cpuSaveGameFunc = flashDelayedWrite; // to insure we detect the write break; case 4: // EEPROM+Sensor *************** *** 3317,3320 **** --- 3320,3324 ---- cpuEEPROMEnabled = true; cpuEEPROMSensorEnabled = true; + // EEPROM usage is automatically detected break; case 5: // NONE *************** *** 3323,3326 **** --- 3327,3331 ---- cpuEEPROMEnabled = false; cpuEEPROMSensorEnabled = false; + // no save at all break; } Index: Flash.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/Flash.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Flash.h 13 May 2004 15:06:43 -0000 1.3 --- Flash.h 14 Nov 2004 18:54:14 -0000 1.4 *************** *** 25,32 **** --- 25,34 ---- extern u8 flashRead(u32 address); extern void flashWrite(u32 address, u8 byte); + extern void flashDelayedWrite(u32 address, u8 byte); extern u8 flashSaveMemory[0x20000]; extern void flashSaveDecide(u32 address, u8 byte); extern void flashReset(); extern void flashSetSize(int size); + extern void flashInit(); extern int flashSize; Index: Sram.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/Sram.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Sram.h 13 May 2004 15:06:44 -0000 1.2 --- Sram.h 14 Nov 2004 18:54:14 -0000 1.3 *************** *** 23,26 **** --- 23,27 ---- extern u8 sramRead(u32 address); extern void sramWrite(u32 address, u8 byte); + extern void sramDelayedWrite(u32 address, u8 byte); #endif // VBA_SRAM_H Index: Flash.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/Flash.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Flash.cpp 13 May 2004 15:06:43 -0000 1.7 --- Flash.cpp 14 Nov 2004 18:54:02 -0000 1.8 *************** *** 68,71 **** --- 68,76 ---- }; + void flashInit() + { + memset(flashSaveMemory, 0xff, sizeof(flashSaveMemory)); + } + void flashReset() { *************** *** 147,150 **** --- 152,162 ---- } + void flashDelayedWrite(u32 address, u8 byte) + { + saveType = 2; + cpuSaveGameFunc = flashWrite; + flashWrite(address, byte); + } + void flashWrite(u32 address, u8 byte) { |