diff --git a/retail/arm9/source/conf_sd.cpp b/retail/arm9/source/conf_sd.cpp index 43201eece..570a97360 100644 --- a/retail/arm9/source/conf_sd.cpp +++ b/retail/arm9/source/conf_sd.cpp @@ -1869,7 +1869,7 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) { } } - const bool foto = (strncmp(romTid, "DMF", 3) == 0); + const bool foto = (strncmp(romTid, "DMF", 3) == 0 || strncmp(romTid, "DSY", 3) == 0); // Load ce9 binary if (b4dsDebugRam) { diff --git a/retail/bootloader/source/arm7/dsi2ds_patches.c b/retail/bootloader/source/arm7/dsi2ds_patches.c index 5615d49a8..dd480071c 100644 --- a/retail/bootloader/source/arm7/dsi2ds_patches.c +++ b/retail/bootloader/source/arm7/dsi2ds_patches.c @@ -216,6 +216,31 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) { *(u32*)0x02072984 += 0xE0000000; // beq -> b } + // System FLAW (USA) + // Requires 8MB of RAM + else if (strcmp(romTid, "DSYE") == 0 && extendedMemory) { + *(u32*)0x0200D0A0 = 0xE3A00000; // mov r0, #0 + *(u32*)0x0200F964 = 0xE1A00000; // nop + *(u32*)0x02012A90 = 0xE1A00000; // nop + patchInitDSiWare(0x02018070, heapEnd); + *(u32*)0x020183E0 = *(u32*)0x020510B4; + setBL(0x0201DA1C, (int)ce9->patches->musicPlay); // Play video + /* *(u32*)0x02023320 = 0xE12FFF1E; // bx lr (Disable music) + *(u32*)0x020234F0 = 0xE12FFF1E; // bx lr (Disable sound) + *(u32*)0x02023614 = 0xE12FFF1E; // bx lr (Disable sound) */ + } + + // System FLAW (Europe) + // Requires 8MB of RAM + else if (strcmp(romTid, "DSYP") == 0 && extendedMemory) { + *(u32*)0x0200D0F4 = 0xE3A00000; // mov r0, #0 + *(u32*)0x0200F9B8 = 0xE1A00000; // nop + *(u32*)0x02012AE4 = 0xE1A00000; // nop + patchInitDSiWare(0x020180C4, heapEnd); + *(u32*)0x02018434 = *(u32*)0x020510C8; + setBL(0x0201DA70, (int)ce9->patches->musicPlay); // Play video + } + // Patch DSiWare to run in DS mode // 1st Class Poker & BlackJack (USA) diff --git a/retail/bootloader/source/arm7/patch_arm9.c b/retail/bootloader/source/arm7/patch_arm9.c index 58060041e..66c10aa75 100644 --- a/retail/bootloader/source/arm7/patch_arm9.c +++ b/retail/bootloader/source/arm7/patch_arm9.c @@ -2187,6 +2187,7 @@ u32 patchCardNdsArm9(cardengineArm9* ce9, const tNDSHeader* ndsHeader, const mod || (strncmp(romTid, "DMD", 3) == 0 && extendedMemory) || strncmp(romTid, "DMP", 3) == 0 || strncmp(romTid, "DHS", 3) == 0 + || (strncmp(romTid, "DSY", 3) == 0 && extendedMemory) ) && arm7mbk == 0x080037C0 && donorFileCluster != CLUSTER_FREE) { u32 startOffset = (u32)ndsHeader->arm9executeAddress; if (moduleParams->sdk_version > 0x5050000) { diff --git a/retail/cardengine/arm9/source/cardengine.c b/retail/cardengine/arm9/source/cardengine.c index ee70e21db..9cfa1c1a2 100644 --- a/retail/cardengine/arm9/source/cardengine.c +++ b/retail/cardengine/arm9/source/cardengine.c @@ -1300,6 +1300,37 @@ void musicPlay(int id) #endif { #ifdef FOTO + if (strncmp(getRomTid(ndsHeader), "DSY", 3) == 0) { + // This is System FLAW + if (ce9->musicCluster == 0 || ce9->musicsSize < 0x18004*2) { + return; + } + + videoFrameLoading = true; + const u16 exmemcnt = REG_EXMEMCNT; + setDeviceOwner(); + + u32 frameOffset = (ndsHeader->gameCode[3] == 'P') ? 0x020767E0 : 0x02077C60; + static u32 frameOffsetAdd = 0x30000; + + fileRead((char*)frameOffset+frameOffsetAdd, &musicsFile, videoPos, (256*192)*2); + frameOffsetAdd += 0x30000; + if (frameOffsetAdd > 0x30000*4) frameOffsetAdd = 0; + + videoPos += 0x18004; // Seek to next frame + if (videoPos >= ce9->musicsSize) videoPos = 0; // Loop back to first frame after last frame has been reached + + REG_EXMEMCNT = exmemcnt; + videoFrameLoading = false; + + for (int i = 0; i < videoFrameDelayMax/2; i++) { + while (REG_VCOUNT != 191); + while (REG_VCOUNT == 191); + } + return; + } + + // Otherwise, this is Foto Showdown if (ce9->musicCluster == 0 || ce9->musicsSize < 0x18000) { toncset16((u16*)0x06008000, 0x8000, 256*192); return;