Skip to content

Commit 746e6a8

Browse files
committed
Make sound fix an option
1 parent 76d1b8e commit 746e6a8

File tree

12 files changed

+33
-6
lines changed

12 files changed

+33
-6
lines changed

arm9/include/configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef struct configuration {
2121
bool boostCpu;
2222
bool gameSoftReset;
2323
bool asyncPrefetch;
24+
bool soundFix;
2425
bool logging;
2526
bool initDisc;
2627
bool dldiPatchNds;

arm9/source/conf_sd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ static int callback(const char *section, const char *key, const char *value, voi
8989
// Async prefetch
9090
conf->asyncPrefetch = (bool)strtol(value, NULL, 0);
9191

92+
} else if (match(section, "NDS-BOOTSTRAP", key, "SOUND_FIX")) {
93+
// Sound fix
94+
conf->soundFix = (bool)strtol(value, NULL, 0);
95+
9296
} else if (match(section, "NDS-BOOTSTRAP", key, "LOGGING")) {
9397
// Logging
9498
conf->logging = (bool)strtol(value, NULL, 0);

arm9/source/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static inline void debugConf(configuration* conf) {
134134
dbg_printf("boostCpu: %s\n", btoa(conf->boostCpu));
135135
dbg_printf("gameSoftReset: %s\n", btoa(conf->gameSoftReset));
136136
dbg_printf("asyncPrefetch: %s\n", btoa(conf->asyncPrefetch));
137+
dbg_printf("soundFix: %s\n", btoa(conf->soundFix));
137138
dbg_printf("logging: %s\n", btoa(conf->logging));
138139
dbg_printf("initDisc: %s\n", btoa(conf->initDisc));
139140
dbg_printf("dldiPatchNds: %s\n", btoa(conf->dldiPatchNds));

arm9/source/nds_loader_arm9.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ void runNds(const void* loader, u32 loaderSize, u32 cluster, u32 saveCluster, co
238238
lc0->romread_LED = conf->romread_LED;
239239
lc0->gameSoftReset = conf->gameSoftReset;
240240
lc0->asyncPrefetch = conf->asyncPrefetch;
241+
lc0->soundFix = conf->soundFix;
241242
lc0->logging = conf->logging;
242243

243244
loadCheatData(conf->cheat_data, conf->cheat_data_len);

bootloader/include/hook.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ int hookNdsRetailArm7(
3939
u32 ROMinRAM,
4040
u32 consoleModel,
4141
u32 romread_LED,
42-
u32 gameSoftReset
42+
u32 gameSoftReset,
43+
u32 soundFix
4344
);
4445
int hookNdsRetailArm9(
4546
cardengineArm9* ce9,

bootloader/source/arm7/hook_arm7.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ int hookNdsRetailArm7(
253253
u32 ROMinRAM,
254254
u32 consoleModel,
255255
u32 romread_LED,
256-
u32 gameSoftReset
256+
u32 gameSoftReset,
257+
u32 soundFix
257258
) {
258259
nocashMessage("hookNdsRetailArm7");
259260

@@ -344,6 +345,7 @@ int hookNdsRetailArm7(
344345
ce7->consoleModel = consoleModel;
345346
ce7->romread_LED = romread_LED;
346347
ce7->gameSoftReset = gameSoftReset;
348+
ce7->soundFix = soundFix;
347349

348350
u32* ce7_cheat_data = getCheatData(ce7);
349351
endCheatData(ce7_cheat_data, &ce7->cheat_data_len);

bootloader/source/arm7/load_crt0.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
.global romread_LED
4242
.global gameSoftReset
4343
.global asyncPrefetch
44+
.global soundFix
4445
.global logging
4546
@---------------------------------------------------------------------------------
4647
.align 4
@@ -89,6 +90,8 @@ gameSoftReset:
8990
.word 0x00000000
9091
asyncPrefetch:
9192
.word 0x00000000
93+
soundFix:
94+
.word 0x00000000
9295
logging:
9396
.word 0x00000000
9497
cardengine_arm7_offset:

bootloader/source/arm7/main.arm7.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ extern u32 consoleModel;
9090
extern u32 romread_LED;
9191
extern u32 gameSoftReset;
9292
extern u32 asyncPrefetch;
93+
extern u32 soundFix;
9394
//extern u32 logging;
9495

9596
static void initMBK(void) {
@@ -657,7 +658,8 @@ int arm7_main(void) {
657658
ROMinRAM,
658659
consoleModel,
659660
romread_LED,
660-
gameSoftReset
661+
gameSoftReset,
662+
soundFix
661663
);
662664
if (errorCode == ERR_NONE) {
663665
nocashMessage("Card hook successful");

cardengine/arm7/source/card_engine_header.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
.global consoleModel
2222
.global romread_LED
2323
.global gameSoftReset
24+
.global soundFix
2425

2526
#define ICACHE_SIZE 0x2000
2627
#define DCACHE_SIZE 0x1000
@@ -53,6 +54,8 @@ romread_LED:
5354
.word 0x00000000
5455
gameSoftReset:
5556
.word 0x00000000
57+
soundFix:
58+
.word 0x00000000
5659
cheat_data_offset:
5760
.word cheat_data - patches_offset
5861
cheat_data_len:

cardengine/arm7/source/cardengine.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern u32 ROMinRAM;
5858
extern u32 consoleModel;
5959
extern u32 romread_LED;
6060
extern u32 gameSoftReset;
61+
extern u32 soundFix;
6162

6263
vu32* volatile sharedAddr = (vu32*)CARDENGINE_SHARED_ADDRESS;
6364

@@ -350,7 +351,9 @@ static void runCardEngineCheckHalt(void) {
350351
if (lockMutex(&cardEgnineCommandMutex)) {
351352
initialize();
352353

353-
cardReadTimeOut = 0;
354+
if (soundFix) {
355+
cardReadTimeOut = 0;
356+
}
354357

355358
//nocashMessage("runCardEngineCheck mutex ok");
356359
if (*(vu32*)(0x027FFB14) == (vu32)0x026FF800) {
@@ -413,8 +416,12 @@ void myIrqHandlerVBlank(void) {
413416
runCardEngineCheck();
414417
}
415418

416-
if (*(vu32*)(0x027FFB14) != 0 && cardReadTimeOut != 30) {
417-
cardReadTimeOut++;
419+
if (soundFix) {
420+
if (*(vu32*)(0x027FFB14) != 0 && cardReadTimeOut != 30) {
421+
cardReadTimeOut++;
422+
}
423+
} else {
424+
cardReadTimeOut = 30;
418425
}
419426

420427
if (REG_KEYINPUT & (KEY_L | KEY_R | KEY_DOWN | KEY_B)) {

common/include/cardengine_header_arm7.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ typedef struct cardengineArm7 {
7575
u32 consoleModel;
7676
u32 romread_LED;
7777
u32 gameSoftReset;
78+
u32 soundFix;
7879
u32 cheat_data_offset; //u32* cheat_data;
7980
u32 cheat_data_len;
8081
u32* romFile;

common/include/load_crt0.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ typedef struct loadCrt0 {
2626
u32 romread_LED;
2727
u32 gameSoftReset;
2828
u32 asyncPrefetch;
29+
u32 soundFix;
2930
u32 logging;
3031
u32 cardengine_arm7_offset; //cardengineArm7* cardengine_arm7;
3132
u32 cardengine_arm9_offset; //cardengineArm9* cardengine_arm9;

0 commit comments

Comments
 (0)