Skip to content

Commit 74b8260

Browse files
committed
B4DS: Add support for *Absolute BrickBuster*
ALSO: Optimize patching `otherPub`/`otherPrv` to `dataPub`/`dataPrv`
1 parent f5d18d4 commit 74b8260

File tree

7 files changed

+138
-43
lines changed

7 files changed

+138
-43
lines changed

retail/arm9/include/dsiwaresSetForBootloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static const char dsiWareForBootloader1[][4] = {
3434
"KXT", // 99Seconds
3535
"K2K", // Aa! Nikaku Dori
3636
"KE9", // Absolute Baseball (bootloaderi-exclusive)
37-
"K6Q", // Absolute BrickBuster (bootloaderi-exclusive)
37+
"K6Q", // Absolute BrickBuster
3838
"KCZ", // Absolute Chess (bootloaderi-exclusive)
3939
"KA8", // Absolute Reversi (bootloaderi-exclusive)
4040
"KXG", // Abyss

retail/bootloader/source/arm7/dsi2ds_patches.c

Lines changed: 76 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
4545
extern u32 fatTableAddr;
4646
extern u32 newArm7binarySize;
4747
const char* romTid = getRomTid(ndsHeader);
48-
// const char* dataPub = "dataPub:";
48+
const char* dataPub = "dataPub:";
4949
const char* dataPrv = "dataPrv:";
5050
const char* dsiRequiredMsg = "A Nintendo DSi is required to use this feature.";
5151
extern u32 relocateBssPart(const tNDSHeader* ndsHeader, u32 bssEnd, u32 bssPartStart, u32 bssPartEnd, u32 newPartStart);
@@ -698,7 +698,7 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
698698
*(u32*)0x02075FFC = 0xE3A00001; // mov r0, #1 (dsiSaveOpenDir)
699699
*(u32*)0x02076018 = 0xE3A00001; // mov r0, #1 (dsiSaveReadDir)
700700
*(u32*)0x02076244 = 0xE3A00000; // mov r0, #0 (dsiSaveReadDir)
701-
*(u32*)0x02076254 = 0xE3A00001; // mov r0, #1 (dsiSaveCloseDir)
701+
*(u32*)0x02076254 = 0xE1A00000; // nop (dsiSaveCloseDir)
702702
*(u32*)0x02076280 = 0xE3A00000; // mov r0, #0
703703
*(u32*)0x02076284 = 0xE12FFF1E; // bx lr
704704
setBL(0x020762FC, (u32)dsiSaveOpen);
@@ -712,10 +712,8 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
712712
setBL(0x020764A4, (u32)dsiSaveWrite);
713713
setBL(0x020764AC, (u32)dsiSaveClose); */
714714

715-
toncset((char*)0x020A05F4, 0, 9); // Redirect otherPrv to dataPrv
716-
tonccpy((char*)0x020A05F4, dataPrv, strlen(dataPrv));
717-
toncset((char*)0x020A0608, 0, 9);
718-
tonccpy((char*)0x020A0608, dataPrv, strlen(dataPrv));
715+
tonccpy((char*)0x020A05F4, dataPrv, strlen(dataPrv)+1); // Redirect otherPrv to dataPrv
716+
tonccpy((char*)0x020A0608, dataPrv, strlen(dataPrv)+1);
719717
}
720718

721719
// 21 Blackjack (USA)
@@ -2176,23 +2174,88 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
21762174
}*/
21772175

21782176
// Absolute BrickBuster (USA)
2179-
// Crashes after starting a game mode
2180-
// Requires 8MB of RAM
2181-
/* else if (strcmp(romTid, "K6QE") == 0) {
2177+
// Crashes after selecting or starting Free Play mode
2178+
// Saving seems difficult to get working
2179+
else if (strcmp(romTid, "K6QE") == 0) {
21822180
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
2183-
/ *(u32*)0x02055B74 = 0xE3A00000; // mov r0, #0 // Part of .pck file
2181+
/* *(u32*)0x02055B74 = 0xE3A00000; // mov r0, #0 // Part of .pck file
21842182
*(u32*)0x02055B78 = 0xE12FFF1E; // bx lr
21852183
*(u32*)0x02055C48 = 0xE3A00000; // mov r0, #0
2186-
*(u32*)0x02055C4C = 0xE12FFF1E; // bx lr /
2184+
*(u32*)0x02055C4C = 0xE12FFF1E; // bx lr */
2185+
2186+
/* *(u32*)0x02056230 = 0xE3A00001; // mov r0, #1 (dsiSaveOpenDir)
2187+
*(u32*)0x0205624C = 0xE3A00001; // mov r0, #1 (dsiSaveReadDir)
2188+
*(u32*)0x02056274 = 0xE3A00001; // mov r0, #1
2189+
*(u32*)0x02056288 = 0xE3A00001; // mov r0, #1
2190+
*(u32*)0x02056488 = 0xE3A00000; // mov r0, #0 (dsiSaveReadDir)
2191+
*(u32*)0x02056498 = 0xE1A00000; // nop (dsiSaveCloseDir)
2192+
*(u32*)0x020564C4 = 0xE3A00000; // mov r0, #0
2193+
*(u32*)0x020564C8 = 0xE12FFF1E; // bx lr
2194+
setBL(0x02056540, (u32)dsiSaveOpen);
2195+
setBL(0x02056558, (u32)dsiSaveGetLength);
2196+
setBL(0x02056584, (u32)dsiSaveRead);
2197+
setBL(0x0205658C, (u32)dsiSaveClose);
2198+
setBL(0x02056664, (u32)dsiSaveCreate);
2199+
setBL(0x02056674, (u32)dsiSaveOpen);
2200+
setBL(0x02056684, (u32)dsiSaveGetResultCode);
2201+
setBL(0x020566B8, (u32)dsiSaveSetLength);
2202+
setBL(0x020566E8, (u32)dsiSaveWrite);
2203+
setBL(0x020566F0, (u32)dsiSaveClose); */
2204+
21872205
*(u32*)0x0205C8DC = 0xE1A00000; // nop
21882206
*(u32*)0x02060D94 = 0xE1A00000; // nop
21892207
patchInitDSiWare(0x0206D9CC, heapEnd);
2208+
*(u32*)0x0206DD3C = *(u32*)0x0205F0D8;
21902209
patchUserSettingsReadDSiWare(0x0206EE64);
2191-
*(u32*)0x0206EEEC = 0xE3A00001; // mov r0, #1
2210+
*(u32*)0x0206EEEC = wirelessReturnCodeArm;
21922211
*(u32*)0x0206EEF0 = 0xE12FFF1E; // bx lr
21932212
*(u32*)0x0206EEF8 = 0xE3A00000; // mov r0, #0
21942213
*(u32*)0x0206EEFC = 0xE12FFF1E; // bx lr
2195-
} */
2214+
2215+
tonccpy((char*)0x02095CD4, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
2216+
tonccpy((char*)0x02095CE8, dataPub, strlen(dataPub)+1);
2217+
}
2218+
2219+
// At Enta!: Burokku Kuzushi (Japan)
2220+
// Crashes after selecting or starting Free Play mode
2221+
// Saving seems difficult to get working
2222+
else if (strcmp(romTid, "K6QJ") == 0) {
2223+
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
2224+
/* *(u32*)0x02055980 = 0xE3A00000; // mov r0, #0 // Part of .pck file
2225+
*(u32*)0x02055984 = 0xE12FFF1E; // bx lr
2226+
*(u32*)0x02055A54 = 0xE3A00000; // mov r0, #0
2227+
*(u32*)0x02055A58 = 0xE12FFF1E; // bx lr */
2228+
2229+
/* *(u32*)0x0205603C = 0xE3A00001; // mov r0, #1 (dsiSaveOpenDir) // Part of .pck file
2230+
*(u32*)0x02056058 = 0xE3A00001; // mov r0, #1 (dsiSaveReadDir)
2231+
*(u32*)0x02056284 = 0xE3A00000; // mov r0, #0 (dsiSaveReadDir)
2232+
*(u32*)0x02056294 = 0xE1A00000; // nop (dsiSaveCloseDir)
2233+
*(u32*)0x020562C0 = 0xE3A00000; // mov r0, #0
2234+
*(u32*)0x020562C4 = 0xE12FFF1E; // bx lr
2235+
setBL(0x0205633C, (u32)dsiSaveOpen);
2236+
setBL(0x02056354, (u32)dsiSaveGetLength);
2237+
setBL(0x02056380, (u32)dsiSaveRead);
2238+
setBL(0x02056388, (u32)dsiSaveClose);
2239+
setBL(0x02056460, (u32)dsiSaveCreate);
2240+
setBL(0x02056470, (u32)dsiSaveOpen);
2241+
setBL(0x02056480, (u32)dsiSaveGetResultCode);
2242+
setBL(0x020564B4, (u32)dsiSaveSetLength);
2243+
setBL(0x020564E4, (u32)dsiSaveWrite);
2244+
setBL(0x020564EC, (u32)dsiSaveClose); */
2245+
2246+
*(u32*)0x0205C810 = 0xE1A00000; // nop
2247+
*(u32*)0x02060CC8 = 0xE1A00000; // nop
2248+
patchInitDSiWare(0x0206D900, heapEnd);
2249+
*(u32*)0x0206DC70 = *(u32*)0x0205F00C;
2250+
patchUserSettingsReadDSiWare(0x0206ED98);
2251+
*(u32*)0x0206EE20 = wirelessReturnCodeArm;
2252+
*(u32*)0x0206EE24 = 0xE12FFF1E; // bx lr
2253+
*(u32*)0x0206EE2C = 0xE3A00000; // mov r0, #0
2254+
*(u32*)0x0206EE30 = 0xE12FFF1E; // bx lr
2255+
2256+
tonccpy((char*)0x020943B0, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
2257+
tonccpy((char*)0x020943C4, dataPub, strlen(dataPub)+1);
2258+
}
21962259

21972260
// Abyss (USA)
21982261
// Abyss (Europe)

retail/bootloaderi/source/arm7/patch_common.c

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void dsiWarePatch(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
328328
*(u32*)0x02075FFC = 0xE3A00001; // mov r0, #1 (dsiSaveOpenDir)
329329
*(u32*)0x02076018 = 0xE3A00001; // mov r0, #1 (dsiSaveReadDir)
330330
*(u32*)0x02076244 = 0xE3A00000; // mov r0, #0 (dsiSaveReadDir)
331-
*(u32*)0x02076254 = 0xE3A00001; // mov r0, #1 (dsiSaveCloseDir)
331+
*(u32*)0x02076254 = 0xE1A00000; // nop (dsiSaveCloseDir)
332332
*(u32*)0x02076280 = 0xE3A00000; // mov r0, #0
333333
*(u32*)0x02076284 = 0xE12FFF1E; // bx lr
334334
setBL(0x020762FC, (u32)dsiSaveOpen);
@@ -342,10 +342,8 @@ void dsiWarePatch(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
342342
setBL(0x020764A4, (u32)dsiSaveWrite);
343343
setBL(0x020764AC, (u32)dsiSaveClose);
344344
} */
345-
toncset((char*)0x020A05F4, 0, 9); // Redirect otherPrv to dataPrv
346-
tonccpy((char*)0x020A05F4, dataPrv, strlen(dataPrv));
347-
toncset((char*)0x020A0608, 0, 9);
348-
tonccpy((char*)0x020A0608, dataPrv, strlen(dataPrv));
345+
tonccpy((char*)0x020A05F4, dataPrv, strlen(dataPrv)+1); // Redirect otherPrv to dataPrv
346+
tonccpy((char*)0x020A0608, dataPrv, strlen(dataPrv)+1);
349347
}
350348

351349
// 21 Blackjack (USA)
@@ -1249,6 +1247,7 @@ void dsiWarePatch(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
12491247
} */
12501248

12511249
// Absolute BrickBuster (USA)
1250+
// Saving seems difficult to get working
12521251
else if (strcmp(romTid, "K6QE") == 0) {
12531252
if (!twlFontFound) {
12541253
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
@@ -1259,65 +1258,98 @@ void dsiWarePatch(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
12591258
*(u32*)0x02055C48 = 0xE3A00000; // mov r0, #0
12601259
*(u32*)0x02055C4C = 0xE12FFF1E; // bx lr
12611260
} */
1262-
toncset((char*)0x02095CD4, 0, 9); // Redirect otherPub to dataPub
1263-
tonccpy((char*)0x02095CD4, dataPub, strlen(dataPub));
1264-
toncset((char*)0x02095CE8, 0, 9);
1265-
tonccpy((char*)0x02095CE8, dataPub, strlen(dataPub));
1261+
/* if (saveOnFlashcardNtr) {
1262+
*(u32*)0x02056230 = 0xE3A00001; // mov r0, #1 (dsiSaveOpenDir)
1263+
*(u32*)0x0205624C = 0xE3A00001; // mov r0, #1 (dsiSaveReadDir)
1264+
*(u32*)0x02056274 = 0xE3A00001; // mov r0, #1
1265+
*(u32*)0x02056288 = 0xE3A00001; // mov r0, #1
1266+
*(u32*)0x02056488 = 0xE3A00000; // mov r0, #0 (dsiSaveReadDir)
1267+
*(u32*)0x02056498 = 0xE1A00000; // nop (dsiSaveCloseDir)
1268+
*(u32*)0x020564C4 = 0xE3A00000; // mov r0, #0
1269+
*(u32*)0x020564C8 = 0xE12FFF1E; // bx lr
1270+
setBL(0x02056540, (u32)dsiSaveOpen);
1271+
setBL(0x02056558, (u32)dsiSaveGetLength);
1272+
setBL(0x02056584, (u32)dsiSaveRead);
1273+
setBL(0x0205658C, (u32)dsiSaveClose);
1274+
setBL(0x02056664, (u32)dsiSaveCreate);
1275+
setBL(0x02056674, (u32)dsiSaveOpen);
1276+
setBL(0x02056684, (u32)dsiSaveGetResultCode);
1277+
setBL(0x020566B8, (u32)dsiSaveSetLength);
1278+
setBL(0x020566E8, (u32)dsiSaveWrite);
1279+
setBL(0x020566F0, (u32)dsiSaveClose);
1280+
} */
1281+
tonccpy((char*)0x02095CD4, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
1282+
tonccpy((char*)0x02095CE8, dataPub, strlen(dataPub)+1);
12661283
}
12671284

12681285
// At Enta!: Burokku Kuzushi (Japan)
1286+
// Saving seems difficult to get working
12691287
else if (strcmp(romTid, "K6QJ") == 0) {
12701288
if (!twlFontFound) {
12711289
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
12721290
}
1273-
toncset((char*)0x020943B0, 0, 9);
1274-
tonccpy((char*)0x020943B0, dataPub, strlen(dataPub));
1275-
toncset((char*)0x020943C4, 0, 9);
1276-
tonccpy((char*)0x020943C4, dataPub, strlen(dataPub));
1291+
/* if (saveOnFlashcardNtr) { // Part of .pck file
1292+
*(u32*)0x02055980 = 0xE3A00000; // mov r0, #0
1293+
*(u32*)0x02055984 = 0xE12FFF1E; // bx lr
1294+
*(u32*)0x02055A54 = 0xE3A00000; // mov r0, #0
1295+
*(u32*)0x02055A58 = 0xE12FFF1E; // bx lr
1296+
} */
1297+
/* if (saveOnFlashcardNtr) {
1298+
*(u32*)0x0205603C = 0xE3A00001; // mov r0, #1 (dsiSaveOpenDir)
1299+
*(u32*)0x02056058 = 0xE3A00001; // mov r0, #1 (dsiSaveReadDir)
1300+
*(u32*)0x02056284 = 0xE3A00000; // mov r0, #0 (dsiSaveReadDir)
1301+
*(u32*)0x02056294 = 0xE1A00000; // nop (dsiSaveCloseDir)
1302+
*(u32*)0x020562C0 = 0xE3A00000; // mov r0, #0
1303+
*(u32*)0x020562C4 = 0xE12FFF1E; // bx lr
1304+
setBL(0x0205633C, (u32)dsiSaveOpen);
1305+
setBL(0x02056354, (u32)dsiSaveGetLength);
1306+
setBL(0x02056380, (u32)dsiSaveRead);
1307+
setBL(0x02056388, (u32)dsiSaveClose);
1308+
setBL(0x02056460, (u32)dsiSaveCreate);
1309+
setBL(0x02056470, (u32)dsiSaveOpen);
1310+
setBL(0x02056480, (u32)dsiSaveGetResultCode);
1311+
setBL(0x020564B4, (u32)dsiSaveSetLength);
1312+
setBL(0x020564E4, (u32)dsiSaveWrite);
1313+
setBL(0x020564EC, (u32)dsiSaveClose);
1314+
} */
1315+
tonccpy((char*)0x020943B0, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
1316+
tonccpy((char*)0x020943C4, dataPub, strlen(dataPub)+1);
12771317
}
12781318

12791319
// Absolute Chess (USA)
12801320
else if (strcmp(romTid, "KCZE") == 0) {
12811321
if (!twlFontFound) {
12821322
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
12831323
}
1284-
toncset((char*)0x0209E9C8, 0, 9); // Redirect otherPub to dataPub
1285-
tonccpy((char*)0x0209E9C8, dataPub, strlen(dataPub));
1286-
toncset((char*)0x0209E9DC, 0, 9);
1287-
tonccpy((char*)0x0209E9DC, dataPub, strlen(dataPub));
1324+
tonccpy((char*)0x0209E9C8, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
1325+
tonccpy((char*)0x0209E9DC, dataPub, strlen(dataPub)+1);
12881326
}
12891327

12901328
// At Chisu: Charenji Supirittsu (Japan)
12911329
else if (strcmp(romTid, "KCZJ") == 0) {
12921330
if (!twlFontFound) {
12931331
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
12941332
}
1295-
toncset((char*)0x0209CCDC, 0, 9); // Redirect otherPub to dataPub
1296-
tonccpy((char*)0x0209CCDC, dataPrv, strlen(dataPrv));
1297-
toncset((char*)0x0209CCF0, 0, 9);
1298-
tonccpy((char*)0x0209CCF0, dataPrv, strlen(dataPrv));
1333+
tonccpy((char*)0x0209CCDC, dataPrv, strlen(dataPrv)+1); // Redirect otherPrv to dataPrv
1334+
tonccpy((char*)0x0209CCF0, dataPrv, strlen(dataPrv)+1);
12991335
}
13001336

13011337
// Absolute Reversi (USA)
13021338
else if (strcmp(romTid, "KA8E") == 0) {
13031339
if (!twlFontFound) {
13041340
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
13051341
}
1306-
toncset((char*)0x0209D220, 0, 9); // Redirect otherPub to dataPub
1307-
tonccpy((char*)0x0209D220, dataPub, strlen(dataPub));
1308-
toncset((char*)0x0209D234, 0, 9);
1309-
tonccpy((char*)0x0209D234, dataPub, strlen(dataPub));
1342+
tonccpy((char*)0x0209D220, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
1343+
tonccpy((char*)0x0209D234, dataPub, strlen(dataPub)+1);
13101344
}
13111345

13121346
// At Enta!: Taisen Ribashi (Japan)
13131347
else if (strcmp(romTid, "KA8J") == 0) {
13141348
if (!twlFontFound) {
13151349
*(u32*)0x020053E4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
13161350
}
1317-
toncset((char*)0x0209C1C0, 0, 9); // Redirect otherPub to dataPub
1318-
tonccpy((char*)0x0209C1C0, dataPub, strlen(dataPub));
1319-
toncset((char*)0x0209C1D4, 0, 9);
1320-
tonccpy((char*)0x0209C1D4, dataPub, strlen(dataPub));
1351+
tonccpy((char*)0x0209C1C0, dataPub, strlen(dataPub)+1); // Redirect otherPub to dataPub
1352+
tonccpy((char*)0x0209C1D4, dataPub, strlen(dataPub)+1);
13211353
}
13221354

13231355
// Abyss (USA)
144 Bytes
Binary file not shown.
128 Bytes
Binary file not shown.
32 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)