Skip to content

Commit 57a937f

Browse files
committed
B4DS: Remove MEP requirement for *Word Searcher* (USA)
1 parent 461df2e commit 57a937f

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

retail/bootloader/source/arm7/dsi2ds_patches.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27974,14 +27974,27 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
2797427974
}
2797527975

2797627976
// Word Searcher (USA)
27977-
// Requires either 8MB of RAM or Memory Expansion Pak
27978-
else if (strcmp(romTid, "KWSE") == 0 && debugOrMep) {
27979-
const u32 mepAddr = (s2FlashcardId == ezFlash) ? 0x08800000 : 0x09000000;
27980-
27977+
else if (strcmp(romTid, "KWSE") == 0) {
2798127978
useSharedFont = (twlFontFound && extendedMemory);
2798227979
if (!useSharedFont) {
2798327980
*(u32*)0x020050D4 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
2798427981
}
27982+
if (!extendedMemory) {
27983+
// Stream BGMusic.wav file instead of pre-loading it
27984+
*(u32*)0x02005478 = 0xE1A00000; // nop
27985+
*(u32*)0x02005480 += 1; // cmp r0, #0 -> #1
27986+
*(u32*)0x020055C4 = 0xE1A00000; // nop (Skip loading data of BGMusic.wav file)
27987+
*(u32*)0x020055CC = 0xE1A00000; // nop
27988+
27989+
const u32 newCodeAddr = 0x0200602C;
27990+
extern u32 wordSrchStreamWavFile[];
27991+
extern u32 wordSrchStreamWavFileLen;
27992+
tonccpy((u32*)newCodeAddr, wordSrchStreamWavFile, wordSrchStreamWavFileLen);
27993+
27994+
setBL(0x02005EB8, newCodeAddr);
27995+
setBL(0x02005EC4, newCodeAddr);
27996+
setBL(0x02005ED8, newCodeAddr);
27997+
}
2798527998
setBL(0x020060FC, (u32)dsiSaveOpen);
2798627999
setBL(0x0200610C, (u32)dsiSaveClose);
2798728000
setBL(0x02006120, (u32)dsiSaveCreate);
@@ -28008,9 +28021,9 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
2800828021
setBL(0x0200B980, (u32)dsiSaveDelete);
2800928022
*(u32*)0x02023070 = 0xE1A00000; // nop
2801028023
*(u32*)0x02026400 = 0xE1A00000; // nop
28011-
patchInitDSiWare(0x0202B1F4, extendedMemory ? heapEnd : mepAddr+0x77C000);
28024+
patchInitDSiWare(0x0202B1F4, heapEnd);
2801228025
if (!extendedMemory) {
28013-
*(u32*)0x0202B564 = mepAddr;
28026+
*(u32*)0x0202B564 = *(u32*)0x02004FD0;
2801428027
}
2801528028
patchUserSettingsReadDSiWare(0x0202C698);
2801628029
*(u32*)0x0202CAC8 = 0xE1A00000; // nop
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@---------------------------------------------------------------------------------
2+
.global wordSrchStreamWavFile
3+
.align 4
4+
.arm
5+
6+
.global wordSrchStreamWavFileLen
7+
wordSrchStreamWavFileLen:
8+
.word wordSrchStreamWavFileEnd - wordSrchStreamWavFile
9+
10+
@---------------------------------------------------------------------------------
11+
wordSrchStreamWavFile:
12+
@---------------------------------------------------------------------------------
13+
stmfd sp!, {r4-r5,lr}
14+
15+
mov r5, r2 @ len
16+
mov r4, r1 @ dst
17+
add r1, r0, #0x2C @ src
18+
mov r0, r9
19+
mov r2, #0
20+
ldr r12, wordSrch_fileSeek
21+
.word 0xE12FFF3C @ blx r12
22+
23+
mov r0, r9
24+
mov r1, r4 @ dst
25+
mov r2, r5 @ len
26+
ldr r12, wordSrch_fileRead
27+
.word 0xE12FFF3C @ blx r12
28+
29+
ldmfd sp!, {r4-r5,pc}
30+
@---------------------------------------------------------------------------------
31+
wordSrch_fileSeek:
32+
.word 0x02024940
33+
wordSrch_fileRead:
34+
.word 0x0202496C
35+
@---------------------------------------------------------------------------------
36+
wordSrchStreamWavFileEnd:

retail/bootloader2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ endif
2222
#---------------------------------------------------------------------------------
2323
TARGET := load2
2424
BUILD := build
25-
SOURCES := ../bootloader/source ../bootloader/source/arm7 ../bootloader/source/arm7/libnds ../bootloader/source/arm7/save_patches ../bootloader/source/arm9 ../common/source ../common/source_general
25+
SOURCES := ../bootloader/source ../bootloader/source/arm7 ../bootloader/source/arm7/libnds ../bootloader/source/arm7/dsi2ds_patches2 ../bootloader/source/arm7/save_patches ../bootloader/source/arm9 ../common/source ../common/source_general
2626
INCLUDES := ../bootloader/include build ../common/include ../common/include_fat
2727
DATA := ../data
2828
SPECS := specs

0 commit comments

Comments
 (0)