Skip to content

Commit b56ece1

Browse files
committed
B4DS: Add support for *Kuniya Burete Sanga Ari: Hills and Rivers Remain*
1 parent f27ec97 commit b56ece1

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

retail/arm9/include/dsiwaresSetForBootloader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ static const char dsiWareForBootloader1[][4] = {
294294
"KEK", // Koukou Eitango: Kiho 400 Go Master
295295
"KVF", // Kuizu Ongaku Nojika (bootloaderi-exclusive)
296296
"KT9", // Kung Fu Dragon
297+
"KY3", // Kuniya Burete Sanga Ari: Hills and Rivers Remain
297298
"K47", // Kyou Hanan no hi Hyakka: Hyakkajiten Maipedea Yori (bootloaderi-exclusive)
298299
"K5M", // G.G Series: The Last Knight
299300
"KQ9", // The Legend of Zelda: Four Swords: Anniversary Edition

retail/arm9/source/conf_sd.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,7 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
21102110
|| strncmp(romTid, "KEG", 3) == 0 // Electroplankton: Lumiloop
21112111
|| strncmp(romTid, "KEA", 3) == 0 // Electroplankton: Trapy
21122112
|| strncmp(romTid, "KFO", 3) == 0 // Frenzic
2113+
|| strncmp(romTid, "KY3", 3) == 0 // Kuniya Burete Sanga Ari: Hills and Rivers Remain
21132114
|| strncmp(romTid, "K5M", 3) == 0 // G.G Series: The Last Knight
21142115
|| strncmp(romTid, "KPT", 3) == 0 // Link 'n' Launch
21152116
|| strncmp(romTid, "KNP", 3) == 0 // Need for Speed: Nitro-X

retail/bootloader/source/arm7/dsi2ds_patches.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
7474
const u32 heapEnd = extendedMemory ? (((u32)ndsHeader->arm9destination >= 0x02004000) ? 0x027D8000 : 0x02700000) : heapEndRetail;
7575
const u32 heapEnd8MBHack = extendedMemory ? heapEnd : heapEndRetail+0x400000; // extendedMemory ? #0x27B0000 : #0x27E0000 (mirrors to 0x23E0000 on retail DS units)
7676
const u32 heapEndExceed = extendedMemory ? heapEnd+0x800000 : heapEndRetail+0xC00000; // extendedMemory ? #0x2FB0000 (mirrors to 0x27B0000 on debug DS units) : #0x2FE0000 (mirrors to 0x23E0000 on retail DS units)
77-
const u32 heapEndMaxForRetail = maxHeapOpen ? ((_io_dldi_size == 0x0F) ? 0x023F6000 : (_io_dldi_size == 0x0E) ? 0x023FA000 : 0x023FC000) : heapEnd;
78-
const u32 heapEndMaxForRetail2 = maxHeapOpen ? ((_io_dldi_size == 0x0F) ? heapEndMaxForRetail : 0x023FF000) : heapEnd;
79-
const u32 heapEndMaxForRetail32 = maxHeapOpen ? 0x023FF000 : heapEnd;
80-
const u32 heapEndMaxForRetailMus = maxHeapOpen ? heapEndMaxForRetail-0x4000 : heapEnd;
81-
// const u32 heapEndMaxForDebug = maxHeapOpen ? ((_io_dldi_size == 0x0F) ? 0x027F6000 : (_io_dldi_size == 0x0E) ? 0x027FA000 : 0x027FC000) : heapEnd;
77+
const u32 heapEndMaxForRetail = (maxHeapOpen && !extendedMemory) ? ((_io_dldi_size == 0x0F) ? 0x023F6000 : (_io_dldi_size == 0x0E) ? 0x023FA000 : 0x023FC000) : heapEnd;
78+
const u32 heapEndMaxForRetail2 = (maxHeapOpen && !extendedMemory) ? ((_io_dldi_size == 0x0F) ? heapEndMaxForRetail : 0x023FF000) : heapEnd;
79+
const u32 heapEndMaxForRetail32 = (maxHeapOpen && !extendedMemory) ? 0x023FF000 : heapEnd;
80+
const u32 heapEndMaxForRetailMus = (maxHeapOpen && !extendedMemory) ? heapEndMaxForRetail-0x4000 : heapEnd;
81+
// const u32 heapEndMaxForDebug = (maxHeapOpen && extendedMemory) ? ((_io_dldi_size == 0x0F) ? 0x027F6000 : (_io_dldi_size == 0x0E) ? 0x027FA000 : 0x027FC000) : heapEnd;
8282
const u32 heapEnd_512KBFreeForDebug = extendedMemory ? 0x02740000 : heapEnd;
8383
// const u32 heapEnd_512KBFreeForDebugAlt = extendedMemory ? 0x02700000 : heapEnd;
8484
const u32 heapEndMaxForRetail_512KBFreeForDebugAlt = extendedMemory ? 0x02700000 : heapEndMaxForRetail;
@@ -15055,6 +15055,33 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
1505515055
setBL(0x02024980, (u32)dsiSaveCreate);
1505615056
}
1505715057

15058+
// Kuniya Burete Sanga Ari: Hills and Rivers Remain (Japan)
15059+
// Saving not supported due to using more than one file in filesystem
15060+
// Requires either 8MB of RAM or Memory Expansion Pak
15061+
else if (strcmp(romTid, "KY3J") == 0 && twlFontFound && debugOrMep) {
15062+
useSharedFont = true;
15063+
if (!extendedMemory) {
15064+
const u32 newCodeAddr = 0x02019224;
15065+
codeCopy((u32*)newCodeAddr, (u32*)0x0201F874, 0x28);
15066+
setBL(0x0202A74C, newCodeAddr);
15067+
patchTwlFontLoad(false, newCodeAddr+0x10, 0x02018590);
15068+
}
15069+
15070+
*(u32*)0x02004AA0 = 0xE1A00000; // nop
15071+
*(u32*)0x0200E4E8 = 0xE1A00000; // nop
15072+
*(u32*)0x02011A24 = 0xE1A00000; // nop
15073+
*(u32*)0x02016AC8 = 0xE3A00001; // mov r0, #1
15074+
patchInitDSiWare(0x02016AE0, heapEndMaxForRetail2);
15075+
patchUserSettingsReadDSiWare(0x02017FD8);
15076+
*(u32*)0x02018000 = wirelessReturnCodeArm;
15077+
*(u32*)0x02018004 = 0xE12FFF1E; // bx lr
15078+
*(u32*)0x0201800C = 0xE3A00000; // mov r0, #0
15079+
*(u32*)0x02018010 = 0xE12FFF1E; // bx lr
15080+
if (!extendedMemory) {
15081+
*(u32*)0x0202B328 = 0xE3A01901; // mov r1, #0x4000 (Shrink SDAT heap from 0x80000)
15082+
}
15083+
}
15084+
1505815085
// Kyara Pasha!: Hello Kitty (Japan)
1505915086
// Shows Japanese error screen (Possibly related to camera)
1506015087
/*else if (strcmp(romTid, "KYKJ") == 0) {

retail/bootloader/source/arm7/main.arm7.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ int arm7_main(void) {
14571457
|| strncmp(romTid, "KEA", 3) == 0 // Electroplankton: Trapy
14581458
|| strncmp(romTid, "KFO", 3) == 0 // Frenzic
14591459
// || strncmp(romTid, "KHB", 3) == 0 // Happy Birthday Mart
1460+
|| strncmp(romTid, "KY3", 3) == 0 // Kuniya Burete Sanga Ari: Hills and Rivers Remain
14601461
|| strncmp(romTid, "K5M", 3) == 0 // G.G Series: The Last Knight
14611462
|| strncmp(romTid, "KPT", 3) == 0 // Link 'n' Launch
14621463
|| strncmp(romTid, "CLJ", 3) == 0 // Mario & Luigi: Bowser's Inside Story
@@ -1591,7 +1592,8 @@ int arm7_main(void) {
15911592
}
15921593
u32 ce9DldiItcm = 0;
15931594
if (
1594-
strncmp(romTid, "K6T", 3) == 0 // Orion's Odyssey
1595+
strncmp(romTid, "KY3", 3) == 0 // Kuniya Burete Sanga Ari: Hills and Rivers Remain
1596+
|| strncmp(romTid, "K6T", 3) == 0 // Orion's Odyssey
15951597
|| strncmp(romTid, "KPS", 3) == 0 // Phantasy Star 0 Mini
15961598
|| strncmp(romTid, "KHR", 3) == 0 // Picture Perfect: Pocket Stylist
15971599
|| strncmp(romTid, "KZU", 3) == 0 // Tales to Enjoy!: Little Red Riding Hood

0 commit comments

Comments
 (0)