From 75b285b45c43a3c7a4222eee8680e752fe0ed50e Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Sun, 13 Sep 2009 10:13:18 +0000 Subject: [PATCH] core: - add load logo data into ARM9 BIOS area; (for a GBAgame not need external BIOS now) --- desmume/src/NDSSystem.cpp | 20 +++++++++++ desmume/src/addons/gbagame.cpp | 61 ++++++++++++++++++++++------------ desmume/src/common.cpp | 2 +- desmume/src/common.h | 2 +- 4 files changed, 62 insertions(+), 23 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index ff849d986..4bd01a203 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -2375,6 +2375,7 @@ void NDS_Reset() INFO("ARM9 BIOS is loaded.\n"); } else { NDS_ARM9.swi_tab = ARM9_swi_tab; +#if 0 _MMU_write32(0xFFFF0018, 0xEA000000); _MMU_write32(0xFFFF0020, 0xE92D500F); _MMU_write32(0xFFFF0024, 0xEE190F11); @@ -2385,6 +2386,25 @@ void NDS_Reset() _MMU_write32(0xFFFF0038, 0xE510F004); _MMU_write32(0xFFFF003C, 0xE8BD500F); _MMU_write32(0xFFFF0040, 0xE25EF004); +#else + for (int t = 0; t < 4096; t++) + MMU.ARM9_BIOS[t] = 0xFF; + + _MMU_write32(0xFFFF0018, 0xEA000027); + + for (int t = 0; t < 156; t++) // load logo + MMU.ARM9_BIOS[t + 0x20] = logo_data[t]; + + _MMU_write32(0xFFFF0274, 0xE92D500F); + _MMU_write32(0xFFFF0278, 0xEE190F11); + _MMU_write32(0xFFFF027C, 0xE1A00620); + _MMU_write32(0xFFFF0280, 0xE1A00600); + _MMU_write32(0xFFFF0284, 0xE2800C40); + _MMU_write32(0xFFFF0288, 0xE28FE000); + _MMU_write32(0xFFFF028C, 0xE510F004); + _MMU_write32(0xFFFF0290, 0xE8BD500F); + _MMU_write32(0xFFFF0294, 0xE25EF004); +#endif } if(CommonSettings.UseExtFirmware == true) diff --git a/desmume/src/addons/gbagame.cpp b/desmume/src/addons/gbagame.cpp index f0dbcf4c3..f81f5f8e0 100644 --- a/desmume/src/addons/gbagame.cpp +++ b/desmume/src/addons/gbagame.cpp @@ -58,7 +58,7 @@ static void gbaWriteFlash(u32 adr, u8 val) { if (val == 0xF0) { - //INFO("GBAslot: Flash: reset\n"); + //INFO("GBAgame: Flash: reset\n"); gbaFlash.state = 0; gbaFlash.cmd = 0; return; @@ -76,7 +76,7 @@ static void gbaWriteFlash(u32 adr, u8 val) { gbaFlash.bank = val; gbaFlash.cmd = 0; - //INFO("GBAslot: Flash: change bank %i\n", val); + //INFO("GBAgame: Flash: change bank %i\n", val); return; } } @@ -92,13 +92,17 @@ static void gbaWriteFlash(u32 adr, u8 val) case 2: if (adr == 0x0A005555) { - //INFO("GBAslot: Flash: send command flash 0x%02X\n", val); + //INFO("GBAgame: Flash: send command flash 0x%02X\n", val); switch (val) { case 0x80: // Erase gbaFlash.state = 0x80; break; + case 0x90: // Chip Identification + gbaFlash.state = 0x90; + break; + case 0xA0: // Write gbaFlash.state = 0; break; @@ -136,13 +140,37 @@ static void gbaWriteFlash(u32 adr, u8 val) if (val == 0x30) { u32 ofs = (adr & 0x0000F000); - //INFO("GBAslot: Flash: erase from 0x%08X to 0x%08X\n", ofs + 0x0A000000, ofs + 0x0A001000); + //INFO("GBAgame: Flash: erase from 0x%08X to 0x%08X\n", ofs + 0x0A000000, ofs + 0x0A001000); for (int i = ofs; i < (ofs + 0x1000); i++) saveData[i] = 0xFF; } gbaFlash.state = 0; gbaFlash.cmd = 0; return; + + // Chip Identification + case 0x90: + if ( (adr == 0x0A005555) && (val == 0xAA) ) + { + gbaFlash.state = 0x91; + return; + } + gbaFlash.state = 0; + break; + + case 0x91: + if ( (adr == 0x0A002AAA) && (val == 0x55) ) + { + gbaFlash.state = 0x92; + return; + } + gbaFlash.state = 0; + break; + + case 0x92: + gbaFlash.state = 0; + gbaFlash.cmd = 0; + return; } if (gbaFlash.cmd == 0xA0) // write @@ -152,18 +180,18 @@ static void gbaWriteFlash(u32 adr, u8 val) gbaFlash.cmd = 0; return; } - //INFO("GBAslot: Flash: write unknown atn 0x%08X = 0x%02X\n", adr, val); + INFO("GBAgame: Flash: write unknown atn 0x%08X = 0x%02X\n", adr, val); } static u8 gbaReadFlash(u32 adr) { if (gbaFlash.cmd == 0) { - //INFO("GBAslot: flash read at 0x%08X = 0x%02X\n", adr, saveData[(adr & 0x1FFFF)+(0x10000*gbaFlash.bank)]); + //INFO("GBAgame: flash read at 0x%08X = 0x%02X\n", adr, saveData[(adr & 0x1FFFF)+(0x10000*gbaFlash.bank)]); return saveData[(adr & 0x1FFFF)+(0x10000*gbaFlash.bank)]; } - //INFO("GBAslot: flash read at 0x%08X\n", adr); + //INFO("GBAgame: flash read at 0x%08X\n", adr); switch (gbaFlash.cmd) { @@ -173,7 +201,7 @@ static u8 gbaReadFlash(u32 adr) break; case 0xF0: // - //INFO("GBAslot: Flash: reset2\n"); + //INFO("GBAgame: Flash: reset2\n"); gbaFlash.state = 0; gbaFlash.cmd = 0; break; @@ -182,7 +210,7 @@ static u8 gbaReadFlash(u32 adr) break; default: - INFO("GBAslot: Flash: read - unknown command at 0x%08X = 0x%02X\n", adr, gbaFlash.cmd); + INFO("GBAgame: Flash: read - unknown command at 0x%08X = 0x%02X\n", adr, gbaFlash.cmd); break; } @@ -339,7 +367,7 @@ static void GBAgame_config(void) {} static void GBAgame_write08(u32 adr, u8 val) { - //INFO("GBAslot: write08 at 0x%08X val=0x%02X\n", adr, val); + //INFO("GBAgame: write08 at 0x%08X val=0x%02X\n", adr, val); if ( (adr >= 0x0A000000) && (adr < 0x0A010000) ) { switch (saveType) @@ -367,9 +395,6 @@ static void GBAgame_write32(u32 adr, u32 val) static u8 GBAgame_read08(u32 adr) { - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return MMU.MMU_MEM[0][0xFF][(adr +0x1C) & MMU.MMU_MASK[0][0xFF]]; - //INFO("GBAgame: read08 at 0x%08X value 0x%02X\n", adr, (u8)T1ReadByte(GBArom, (adr - 0x08000000))); if (adr < 0x0A000000) @@ -398,9 +423,6 @@ static u8 GBAgame_read08(u32 adr) static u16 GBAgame_read16(u32 adr) { - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return T1ReadWord(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); - //INFO("GBAgame: read16 at 0x%08X value 0x%04X\n", adr, (u16)T1ReadWord(GBArom, (adr - 0x08000000))); if (adr < 0x0A000000) @@ -408,7 +430,7 @@ static u16 GBAgame_read16(u32 adr) if (adr < 0x0A010000) { - //INFO("GBAslot: flash read16 at 0x%08X\n", adr); + //INFO("GBAgame: flash read16 at 0x%08X\n", adr); return (u16)T1ReadWord(saveData, (adr - 0x0A000000)); } return 0xFFFF; @@ -416,9 +438,6 @@ static u16 GBAgame_read16(u32 adr) static u32 GBAgame_read32(u32 adr) { - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); - //INFO("GBAgame: read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000))); if (adr < 0x0A000000) @@ -426,7 +445,7 @@ static u32 GBAgame_read32(u32 adr) if (adr < 0x0A010000) { - //INFO("GBAslot: flash read32 at 0x%08X\n", adr); + //INFO("GBAgame: flash read32 at 0x%08X\n", adr); return (u32)T1ReadLong(saveData, (adr - 0x0A000000)); } return 0xFFFFFFFF; diff --git a/desmume/src/common.cpp b/desmume/src/common.cpp index 6df5cd606..400536e43 100644 --- a/desmume/src/common.cpp +++ b/desmume/src/common.cpp @@ -25,7 +25,7 @@ #include #include "common.h" -u8 gba_header_data_0x04[156] = { +u8 logo_data[156] = { 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD, 0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20, 0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF, diff --git a/desmume/src/common.h b/desmume/src/common.h index af87d4b78..b559dfaeb 100644 --- a/desmume/src/common.h +++ b/desmume/src/common.h @@ -28,7 +28,7 @@ #include "types.h" #include -extern u8 gba_header_data_0x04[156]; +extern u8 logo_data[156]; #ifdef WIN32 #include