Skip to content

Commit

Permalink
DSi/3DS: Add ROM pre-load settings for *Tomodachi Collection*
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Jan 1, 2025
1 parent e675c1e commit c182abe
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 24 deletions.
4 changes: 2 additions & 2 deletions retail/arm9/include/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ typedef struct configuration {
u32 apPatchSize;
u32 cheatSize;
u32 musicsSize;
u32 dataToPreloadAddr[2];
u32 dataToPreloadSize[2];
u32 dataToPreloadAddr[3];
u32 dataToPreloadSize[3];
// u32 dataToPreloadFrame;
u8 language;
char* guiLanguage;
Expand Down
4 changes: 2 additions & 2 deletions retail/arm9/source/conf_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ static void loadPreLoadSettings(configuration* conf, const char* pckPath, const
}

if (offset > 0) {
if (size > 0x10) {
size = 0x10;
if (size > 0x18) {
size = 0x18;
}
fseek(file, offset, SEEK_SET);
u32 *buffer = new u32[size/4];
Expand Down
8 changes: 4 additions & 4 deletions retail/arm9/source/nds_loader_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ int runNds(u32 cluster, u32 saveCluster, u32 donorTwlCluster, /* u32 gbaCluster,
loader->saveSize = conf->saveSize;
// loader->gbaRomSize = conf->gbaRomSize;
// loader->gbaSaveSize = conf->gbaSaveSize;
loader->dataToPreloadAddr[0] = conf->dataToPreloadAddr[0];
loader->dataToPreloadSize[0] = conf->dataToPreloadSize[0];
loader->dataToPreloadAddr[1] = conf->dataToPreloadAddr[1];
loader->dataToPreloadSize[1] = conf->dataToPreloadSize[1];
for (int i = 0; i < 3; i++) {
loader->dataToPreloadAddr[i] = conf->dataToPreloadAddr[i];
loader->dataToPreloadSize[i] = conf->dataToPreloadSize[i];
}
loader->wideCheatFileCluster = wideCheatCluster;
loader->wideCheatSize = conf->wideCheatSize;
loader->apPatchFileCluster = apPatchCluster;
Expand Down
2 changes: 2 additions & 0 deletions retail/bootloader/source/arm7/load_crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ saveSize:
dataToPreloadAddr:
.word 0x00000000
.word 0x00000000
.word 0x00000000
dataToPreloadSize:
.word 0x00000000
.word 0x00000000
.word 0x00000000
@dataToPreloadFrame:
@ .word 0x00000000
wideCheatFileCluster:
Expand Down
6 changes: 3 additions & 3 deletions retail/bootloaderi/source/arm7/hook_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ int hookNdsRetailArm9(
extern u32 baseFatOff;
extern u32 baseFatSize;
extern u32 romPaddingSize;
extern u32 dataToPreloadAddr[2];
extern u32 dataToPreloadSize[2];
extern u32 dataToPreloadAddr[3];
extern u32 dataToPreloadSize[3];
// extern u32 dataToPreloadFrame;
extern bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool isSdk5, const bool dsiBios, u32* romLocation);
extern u32 dataToPreloadFullSize(void);
Expand Down Expand Up @@ -343,7 +343,7 @@ int hookNdsRetailArm9(
romLocationAdjust(ndsHeader, laterSdk, (ce9->valueBits & b_isSdk5), (ce9->valueBits & b_dsiBios), &ce9->cacheAddress);
ce9->cacheSlots--;
}
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 3; i++) {
ce9->romPartSrc[i] = dataToPreloadAddr[i];
ce9->romPartSize[i] = dataToPreloadSize[i];
}
Expand Down
2 changes: 2 additions & 0 deletions retail/bootloaderi/source/arm7/load_crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ saveSize:
dataToPreloadAddr:
.word 0x00000000
.word 0x00000000
.word 0x00000000
dataToPreloadSize:
.word 0x00000000
.word 0x00000000
.word 0x00000000
@dataToPreloadFrame:
@ .word 0x00000000
wideCheatFileCluster:
Expand Down
17 changes: 10 additions & 7 deletions retail/bootloaderi/source/arm7/main.arm7.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ extern u32 romSize;
extern u32 saveSize;
// extern u32 gbaRomSize;
// extern u32 gbaSaveSize;
extern u32 dataToPreloadAddr[2];
extern u32 dataToPreloadSize[2];
extern u32 dataToPreloadAddr[3];
extern u32 dataToPreloadSize[3];
// extern u32 dataToPreloadFrame;
extern u32 wideCheatFileCluster;
extern u32 wideCheatSize;
Expand Down Expand Up @@ -1019,15 +1019,15 @@ static void my_readUserSettings(tNDSHeader* ndsHeader) {
}

u32 dataToPreloadFullSize(void) {
u32 dataToPreloadSizeAlign[2] = {dataToPreloadSize[0], dataToPreloadSize[1]};
for (int i = 0; i < 2; i++) {
u32 dataToPreloadSizeAlign[3] = {dataToPreloadSize[0], dataToPreloadSize[1], dataToPreloadSize[2]};
for (int i = 0; i < 3; i++) {
if (!dataToPreloadSize[i]) break;
while ((dataToPreloadSizeAlign[i] % 0x4000) != 0) {
dataToPreloadSizeAlign[i]++;
}
}

return dataToPreloadSizeAlign[0] + dataToPreloadSizeAlign[1];
return dataToPreloadSizeAlign[0] + dataToPreloadSizeAlign[1] + dataToPreloadSizeAlign[2];
}

bool dataToPreloadFound(const tNDSHeader* ndsHeader) {
Expand Down Expand Up @@ -1174,8 +1174,8 @@ static void buildRomMap(const tNDSHeader* ndsHeader, const module_params_t* modu
// Load ROM into RAM
const u32 romLocation = ROMinRAM ? getRomLocation(ndsHeader, !laterSdk, isSdk5(moduleParams), dsiBios) : getRomPartLocation(ndsHeader, !laterSdk, isSdk5(moduleParams), dsiBios);

u32 romOffset[2] = {(ROMinRAM ? 0 : dataToPreloadAddr[0]), (ROMinRAM ? 0 : dataToPreloadAddr[1])};
s32 romSizeEdit[2] = {(ROMinRAM ? baseRomSize : dataToPreloadSize[0]), (ROMinRAM ? baseRomSize : dataToPreloadSize[1])};
u32 romOffset[3] = {(ROMinRAM ? 0 : dataToPreloadAddr[0]), (ROMinRAM ? 0 : dataToPreloadAddr[1]), (ROMinRAM ? 0 : dataToPreloadAddr[2])};
s32 romSizeEdit[3] = {(ROMinRAM ? baseRomSize : dataToPreloadSize[0]), (ROMinRAM ? baseRomSize : dataToPreloadSize[1]), (ROMinRAM ? baseRomSize : dataToPreloadSize[2])};
int iCount = 1;
if (ROMinRAM) {
if (usesCloneboot) {
Expand Down Expand Up @@ -1206,6 +1206,9 @@ static void buildRomMap(const tNDSHeader* ndsHeader, const module_params_t* modu
if (dataToPreloadSize[1]) {
iCount++;
}
if (dataToPreloadSize[2]) {
iCount++;
}
}

/* dbg_printf("romOffset[0]: ");
Expand Down
2 changes: 1 addition & 1 deletion retail/cardenginei/arm9/source/cardDma.thumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void cardSetDma(u32 * params) {
//int romPartNo = 0;
if (!(ce9->valueBits & ROMinRAM)) {
#ifndef TWLSDK
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 3; i++) {
if (ce9->romPartSize[i] == 0) {
break;
}
Expand Down
2 changes: 2 additions & 0 deletions retail/cardenginei/arm9/source/card_engine_header.s
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ cacheBlockSize:
romPartSrc:
.word 0x00000000
.word 0x00000000
.word 0x00000000
romPartSize:
.word 0x00000000
.word 0x00000000
.word 0x00000000
#ifndef TWLSDK
romMapLines:
.word 0x00000000
Expand Down
2 changes: 1 addition & 1 deletion retail/cardenginei/arm9/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void cardRead(u32* cacheStruct, u8* dst0, u32 src0, u32 len0) {
//int romPartNo = 0;
if (!(ce9->valueBits & ROMinRAM)) {
#ifndef TWLSDK
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 3; i++) {
if (ce9->romPartSize[i] == 0) {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions retail/common/include/cardengine_header_arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ typedef struct cardengineArm9 {
u32 cacheAddress;
u16 cacheSlots;
u16 cacheBlockSize;
u32 romPartSrc[2];
u32 romPartSize[2];
u32 romPartSrc[3];
u32 romPartSize[3];
u32 romMapLines;
u32 romMap[8][3]; // 0: ROM part start, 1: ROM part start in RAM, 2: ROM part end in RAM
} cardengineArm9;
Expand Down
4 changes: 2 additions & 2 deletions retail/common/include/load_crt0.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ typedef struct loadCrt0 {
u32 saveSize;
// u32 gbaRomSize;
// u32 gbaSaveSize;
u32 dataToPreloadAddr[2];
u32 dataToPreloadSize[2];
u32 dataToPreloadAddr[3];
u32 dataToPreloadSize[3];
// u32 dataToPreloadFrame;
u32 wideCheatFileCluster;
u32 wideCheatSize;
Expand Down
7 changes: 7 additions & 0 deletions retail/preLoadSettings/Title list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ Super Mario 64 DS (Europe) (ASMP) (DSi)
Super Mario 64 DS (Japan) (ASMJ) (DSi)
Super Mario 64 DS (Korea) (ASMK) (DSi)
Shenyou Maliou DS (China) (ASMC) (DSi)
Tomodachi Collection (Japan) (CCUJ) (DSi/3DS)
Tomodachi Collection (Japan) (Rev 1) (CCUJ) (DSi/3DS)
Tomodachi Collection (English translation) (CCUJ-8554) (DSi/3DS)
TrackMania DS (USA) (CTRE) (3DS)
TrackMania DS (Europe) (CTRP) (3DS)
TrackMania Turbo (USA) (B2TE) (3DS)
Expand Down Expand Up @@ -219,5 +222,9 @@ Style Savvy (DSi/3DS):
Super Mario 64 DS (DSi):
- Everything except the level data

Tomodachi Collection (DSi/3DS):
- DSi: Most commonly used data: Cmn, Mdl, and Msg data
- 3DS: All commonly used data: Cmn, Mdl, Msg, Scn, and sound data (latter excluding credits music)

Yoshi Touch & Go (DSi):
- Everything except the `area` folder
Binary file added retail/preLoadSettings/files-3ds/CCUJ-61DC.bin
Binary file not shown.
Binary file added retail/preLoadSettings/files-3ds/CCUJ-8554.bin
Binary file not shown.
Binary file added retail/preLoadSettings/files-3ds/CCUJ-9B26.bin
Binary file not shown.
Binary file added retail/preLoadSettings/files-dsi/CCUJ-61DC.bin
Binary file not shown.
Binary file added retail/preLoadSettings/files-dsi/CCUJ-8554.bin
Binary file not shown.
Binary file added retail/preLoadSettings/files-dsi/CCUJ-9B26.bin
Binary file not shown.

0 comments on commit c182abe

Please sign in to comment.