diff --git a/NDS.cpp b/NDS.cpp index d7a85036..4cde37a2 100644 --- a/NDS.cpp +++ b/NDS.cpp @@ -289,7 +289,7 @@ void Reset() // test //LoadROM(); //LoadFirmware(); - NDSCart::LoadROM("rom/peach.nds"); + NDSCart::LoadROM("rom/sonic.nds"); Running = true; // hax } diff --git a/NDSCart.cpp b/NDSCart.cpp index 3bfc814d..523f5750 100644 --- a/NDSCart.cpp +++ b/NDSCart.cpp @@ -56,6 +56,7 @@ void Write_Discover(u8 val, bool islast); void Init() { SRAM = NULL; + Discover_Buffer = NULL; } void Reset() @@ -66,6 +67,7 @@ void Reset() void LoadSave(char* path) { if (SRAM) delete[] SRAM; + if (Discover_Buffer) delete[] Discover_Buffer; strncpy(SRAMPath, path, 255); SRAMPath[255] = '\0'; @@ -181,6 +183,8 @@ void SetMemoryType() } CurCmd = prev_cmd; + + delete[] Discover_Buffer; } void Write_Discover(u8 val, bool islast) @@ -272,9 +276,7 @@ void Write_EEPROM(u8 val, bool islast) } else { - if (Addr < SRAMLength) - SRAM[Addr] = val; - + SRAM[Addr & (SRAMLength-1)] = val; Addr++; } break; @@ -288,11 +290,7 @@ void Write_EEPROM(u8 val, bool islast) } else { - if (Addr >= SRAMLength) - Data = 0; - else - Data = SRAM[Addr]; - + Data = SRAM[Addr & (SRAMLength-1)]; Addr++; } break; @@ -321,6 +319,7 @@ void Write_Flash(u8 val, bool islast) } else { + // CHECKME: does Flash also wraparound when the address is out of bounds? if (Addr >= SRAMLength) Data = 0; else diff --git a/melonDS.depend b/melonDS.depend index 1eca451d..f7fbfb0a 100644 --- a/melonDS.depend +++ b/melonDS.depend @@ -10,7 +10,7 @@ 1481161027 c:\documents\sources\melonds\types.h -1486310027 source:c:\documents\sources\melonds\nds.cpp +1486312246 source:c:\documents\sources\melonds\nds.cpp "NDS.h" @@ -24,7 +24,7 @@ "RTC.h" "Wifi.h" -1486310306 source:c:\documents\sources\melonds\arm.cpp +1486310992 source:c:\documents\sources\melonds\arm.cpp "NDS.h" "ARM.h" @@ -137,7 +137,7 @@ 1485980863 c:\documents\sources\melonds\ndscart.h "types.h" -1486309588 source:c:\documents\sources\melonds\ndscart.cpp +1486312231 source:c:\documents\sources\melonds\ndscart.cpp "NDS.h"