From 4202a8f826305c6a36b02fe08e28a76488430a75 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Wed, 29 Mar 2017 22:12:53 +0200 Subject: [PATCH] finish Flash support, mostly --- src/NDSCart.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index a53154ca..f291d7bc 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -361,6 +361,20 @@ void Write_Flash(u8 val, bool islast) { switch (CurCmd) { + case 0x02: + if (DataPos < 3) + { + Addr <<= 8; + Addr |= val; + Data = 0; + } + else + { + SRAM[Addr & (SRAMLength-1)] = 0; + Addr++; + } + break; + case 0x03: if (DataPos < 3) { @@ -393,6 +407,40 @@ void Write_Flash(u8 val, bool islast) Data = 0xFF; break; + case 0xD8: + if (DataPos < 3) + { + Addr <<= 8; + Addr |= val; + Data = 0; + } + if (DataPos == 2) + { + for (u32 i = 0; i < 0x10000; i++) + { + SRAM[Addr & (SRAMLength-1)] = 0; + Addr++; + } + } + break; + + case 0xDB: + if (DataPos < 3) + { + Addr <<= 8; + Addr |= val; + Data = 0; + } + if (DataPos == 2) + { + for (u32 i = 0; i < 0x100; i++) + { + SRAM[Addr & (SRAMLength-1)] = 0; + Addr++; + } + } + break; + default: if (DataPos==0) printf("unknown Flash save command %02X\n", CurCmd);