From 58765c186767db31c960c69e8bf6e5b4ea1bef0e Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Mon, 10 Mar 2025 00:25:50 -0400 Subject: [PATCH] main_loops data --- data/data_code_2.s | 144 ------------------------------------------ ld_script.txt | 2 +- src/data/main_loops.h | 77 ++++++++++++++++++++++ src/main_loops.c | 41 +++++------- 4 files changed, 94 insertions(+), 170 deletions(-) delete mode 100644 data/data_code_2.s create mode 100644 src/data/main_loops.h diff --git a/data/data_code_2.s b/data/data_code_2.s deleted file mode 100644 index 80d7f7327..000000000 --- a/data/data_code_2.s +++ /dev/null @@ -1,144 +0,0 @@ - .section .rodata - - .string "pksdir0\0" - - .global gBaseKindTable -gBaseKindTable: @ 80B690C - .byte 0x00, 0x00, 0x00, 0x00 - .byte 0x19, 0x00, 0x00, 0x00 - .byte 0x01, 0x00, 0x00, 0x00 - .byte 0x34, 0x00, 0x00, 0x00 - .byte 0x02, 0x00, 0x00, 0x00 - .byte 0x85, 0x00, 0x00, 0x00 - .byte 0x03, 0x00, 0x00, 0x00 - .byte 0x45, 0x01, 0x00, 0x00 - .byte 0x04, 0x00, 0x00, 0x00 - .byte 0x07, 0x00, 0x00, 0x00 - .byte 0x05, 0x00, 0x00, 0x00 - .byte 0x9e, 0x00, 0x00, 0x00 - .byte 0x06, 0x00, 0x00, 0x00 - .byte 0x1b, 0x01, 0x00, 0x00 - .byte 0x07, 0x00, 0x00, 0x00 - .byte 0x36, 0x00, 0x00, 0x00 - .byte 0x08, 0x00, 0x00, 0x00 - .byte 0x04, 0x00, 0x00, 0x00 - .byte 0x09, 0x00, 0x00, 0x00 - .byte 0x18, 0x01, 0x00, 0x00 - .byte 0x0a, 0x00, 0x00, 0x00 - .byte 0x9b, 0x00, 0x00, 0x00 - .byte 0x0b, 0x00, 0x00, 0x00 - .byte 0x68, 0x00, 0x00, 0x00 - .byte 0x0c, 0x00, 0x00, 0x00 - .byte 0x42, 0x00, 0x00, 0x00 - .byte 0x0d, 0x00, 0x00, 0x00 - .byte 0x01, 0x00, 0x00, 0x00 - .byte 0x0e, 0x00, 0x00, 0x00 - .byte 0x98, 0x00, 0x00, 0x00 - .byte 0x0f, 0x00, 0x00, 0x00 - .byte 0x15, 0x01, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00 - - .global gTalkKindTable -gTalkKindTable: @ 80B6994 - .byte 0x01, 0x00, 0x00, 0x00 - .byte 0x07, 0x00, 0x00, 0x00 - .byte 0x01, 0x00, 0x00, 0x00 - .byte 0x9e, 0x00, 0x00, 0x00 - .byte 0x03, 0x00, 0x00, 0x00 - .byte 0x18, 0x01, 0x00, 0x00 - .byte 0x03, 0x00, 0x00, 0x00 - .byte 0x98, 0x00, 0x00, 0x00 - .byte 0x02, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00 - - .global gPMDBuildVersion -gPMDBuildVersion: @ 80B69BC - .string "PKDi ver 1.0 [Apr 28 2006] 16:37:54\0" - .align 2,0 - - .global titlen0_text - titlen0_text: - .string "titlen0\0" - .align 2,0 - - .global titlen1_text - titlen1_text: - .string "titlen1\0" - .align 2,0 - - .global titlen2_text - titlen2_text: - .string "titlen2\0" - .align 2,0 - - .global gLoadScreenBackgroundFileNames -gLoadScreenBackgroundFileNames: @ 80B69F8 - .4byte titlen0_text - .4byte titlen1_text - .4byte titlen2_text - - .global titlen0p_text - titlen0p_text: - .string "titlen0p\0" - .align 2,0 - - .global titlen1p_text - titlen1p_text: - .string "titlen1p\0" - .align 2,0 - - .global titlen2p_text - titlen2p_text: - .string "titlen2p\0" - .align 2,0 - - .global gLoadScreenBackgroundPaletteFileNames -gLoadScreenBackgroundPaletteFileNames: @ 80B6A28 - .4byte titlen0p_text - .4byte titlen1p_text - .4byte titlen2p_text - -gSaveTextQuicksaving:: @ 80B6A34 - .string "{CENTER_ALIGN}Quicksaving your adventure...\n" - .string "{CENTER_ALIGN}Please don't turn off the power.\0" - .align 2, 0 - -gSaveTextYourAdventureHasBeenSaved:: @ 80B6A7C - .string "{CENTER_ALIGN}Your adventure has been saved.\0" - .align 2, 0 - -gSaveTextYourAdventureHasBeenSavedLong:: @ 80B6AA0 - .string "{CENTER_ALIGN}Your adventure has been saved.\n" - .string "{CENTER_ALIGN}When you are in a dungeon, quicksave\n" - .string "{CENTER_ALIGN}your progress before ending the game.\0" - .align 2, 0 - -gSaveTextTheDataCouldNotBeWritten:: @ 80B6B14 - .string "{CENTER_ALIGN}The data could not be written.\n" - .string "{CENTER_ALIGN}Please turn off the power and remove\n" - .string "{CENTER_ALIGN}and reinsert the DS Card.\0" - .align 2, 0 - -gSaveTextFailed:: @ 80B6B78 - .string "{CENTER_ALIGN}Save failed.\0" - .align 2, 0 - -gSaveTextError:: @ 80B6B88 - .string "{CENTER_ALIGN}Error reading data.\n" - .string "{CENTER_ALIGN}Please turn off the power and reinsert\n" - .string "{CENTER_ALIGN}the DS Game Card.\0" - .align 2, 0 - -gSaveTextCantResume:: @ 80B6BDC - .string "{CENTER_ALIGN}Your data was not properly saved,\n" - .string "{CENTER_ALIGN}so your game cannot be resumed\n" - .string "{CENTER_ALIGN}from your last spot.{EXTRA_MSG}{CENTER_ALIGN}Your last outing is considered a defeat.\n" - .string "{CENTER_ALIGN}Before shutting down, save in your\n" - .string "{CENTER_ALIGN}team base, or quicksave in a dungeon.\0" - .align 2, 0 - -gSaveTextMayNotResume:: @ 80B6CB8 - .string "{CENTER_ALIGN}You may not resume your dungeon\n" - .string "{CENTER_ALIGN}adventure using this saved data.\n" - .string "{CENTER_ALIGN}Your last outing is considered a defeat.\0" \ No newline at end of file diff --git a/ld_script.txt b/ld_script.txt index 52795576c..f426af3ff 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -400,7 +400,7 @@ SECTIONS { .rodata : ALIGN(4) { - data/data_code_2.o(.rodata); + src/main_loops.o(.rodata); data/data.o(.rodata); src/memory.o(.rodata); data/data1.o(.rodata); diff --git a/src/data/main_loops.h b/src/data/main_loops.h new file mode 100644 index 000000000..5578fb3ca --- /dev/null +++ b/src/data/main_loops.h @@ -0,0 +1,77 @@ +static const unkTalkTable sBaseKindTable[17] = { + [0] = { .unk0 = 0, .species = MONSTER_PIKACHU }, + [1] = { .unk0 = 1, .species = MONSTER_MEOWTH }, + [2] = { .unk0 = 2, .species = MONSTER_EEVEE }, + [3] = { .unk0 = 3, .species = MONSTER_SKITTY }, + [4] = { .unk0 = 4, .species = MONSTER_SQUIRTLE }, + [5] = { .unk0 = 5, .species = MONSTER_TOTODILE }, + [6] = { .unk0 = 6, .species = MONSTER_MUDKIP }, + [7] = { .unk0 = 7, .species = MONSTER_PSYDUCK }, + [8] = { .unk0 = 8, .species = MONSTER_CHARMANDER }, + [9] = { .unk0 = 9, .species = MONSTER_TORCHIC }, + [10] = { .unk0 = 10, .species = MONSTER_CYNDAQUIL }, + [11] = { .unk0 = 11, .species = MONSTER_CUBONE }, + [12] = { .unk0 = 12, .species = MONSTER_MACHOP }, + [13] = { .unk0 = 13, .species = MONSTER_BULBASAUR }, + [14] = { .unk0 = 14, .species = MONSTER_CHIKORITA }, + [15] = { .unk0 = 15, .species = MONSTER_TREECKO }, + [16] = { .unk0 = 0, .species = MONSTER_NONE }, +}; + +static const unkTalkTable sTalkKindTable[5] = { + [0] = { .unk0 = 1, .species = MONSTER_SQUIRTLE }, + [1] = { .unk0 = 1, .species = MONSTER_TOTODILE }, + [2] = { .unk0 = 3, .species = MONSTER_TORCHIC }, + [3] = { .unk0 = 3, .species = MONSTER_CHIKORITA }, + [4] = { .unk0 = 2, .species = MONSTER_NONE }, +}; + +ALIGNED(4) static const u8 sPMDBuildVersion[] = _("PKDi ver 1.0 [Apr 28 2006] 16:37:54"); + +ALIGNED(4) static const u8 sTitlen0[] = _("titlen0"); +ALIGNED(4) static const u8 sTitlen1[] = _("titlen1"); +ALIGNED(4) static const u8 sTitlen2[] = _("titlen2"); +/* static */ // TODO: Uncomment +ALIGNED(4) const u8* const sLoadScreenBackgroundFileNames[3] = { sTitlen0, sTitlen1, sTitlen2 }; + +ALIGNED(4) static const u8 sTitlen0p[] = _("titlen0p"); +ALIGNED(4) static const u8 sTitlen1p[] = _("titlen1p"); +ALIGNED(4) static const u8 sTitlen2p[] = _("titlen2p"); +/* static */ // TODO: Uncomment +ALIGNED(4) const u8* const sLoadScreenBackgroundPaletteFileNames[3] = { sTitlen0p, sTitlen1p, sTitlen2p }; + +ALIGNED(4) static const u8 sSaveTextQuicksaving[] = _( + "{CENTER_ALIGN}Quicksaving your adventure...\n" + "{CENTER_ALIGN}Please don't turn off the power."); + +ALIGNED(4) static const u8 sSaveTextYourAdventureHasBeenSaved[] = _("{CENTER_ALIGN}Your adventure has been saved."); + +ALIGNED(4) static const u8 sSaveTextYourAdventureHasBeenSavedLong[] = _( + "{CENTER_ALIGN}Your adventure has been saved.\n" + "{CENTER_ALIGN}When you are in a dungeon, quicksave\n" + "{CENTER_ALIGN}your progress before ending the game."); + +ALIGNED(4) static const u8 sSaveTextTheDataCouldNotBeWritten[] = _( + "{CENTER_ALIGN}The data could not be written.\n" + "{CENTER_ALIGN}Please turn off the power and remove\n" + "{CENTER_ALIGN}and reinsert the DS Card."); + +ALIGNED(4) static const u8 sSaveTextFailed[] = _("{CENTER_ALIGN}Save failed."); + +ALIGNED(4) static const u8 sSaveTextError[] = _( + "{CENTER_ALIGN}Error reading data.\n" + "{CENTER_ALIGN}Please turn off the power and reinsert\n" + "{CENTER_ALIGN}the DS Game Card."); + +ALIGNED(4) static const u8 sSaveTextCantResume[] = _( + "{CENTER_ALIGN}Your data was not properly saved,\n" + "{CENTER_ALIGN}so your game cannot be resumed\n" + "{CENTER_ALIGN}from your last spot.{EXTRA_MSG}" + "{CENTER_ALIGN}Your last outing is considered a defeat.\n" + "{CENTER_ALIGN}Before shutting down, save in your\n" + "{CENTER_ALIGN}team base, or quicksave in a dungeon."); + +ALIGNED(4) static const u8 sSaveTextMayNotResume[] = _( + "{CENTER_ALIGN}You may not resume your dungeon\n" + "{CENTER_ALIGN}adventure using this saved data.\n" + "{CENTER_ALIGN}Your last outing is considered a defeat."); \ No newline at end of file diff --git a/src/main_loops.c b/src/main_loops.c index 019f55975..5d96313f0 100644 --- a/src/main_loops.c +++ b/src/main_loops.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "constants/bg_music.h" #include "constants/main_menu.h" #include "structs/str_dungeon_8042F6C.h" @@ -61,17 +62,7 @@ static EWRAM_INIT PersonalityRelated sPersonalityRelated_203B040 = { .PartnerNick = {""}, }; -extern const u8 gPMDBuildVersion[]; -extern const u8 gSaveTextYourAdventureHasBeenSaved[]; -extern const u8 gSaveTextYourAdventureHasBeenSavedLong[]; -extern const u8 gSaveTextFailed[]; -extern const u8 gSaveTextTheDataCouldNotBeWritten[]; -extern const u8 gSaveTextQuicksaving[]; -extern const u8 gSaveTextError[]; -extern const u8 gSaveTextCantResume[]; -extern const u8 gSaveTextMayNotResume[]; -extern const unkTalkTable gTalkKindTable[]; -extern const unkTalkTable gBaseKindTable[]; +#include "data/main_loops.h" static void LoadTitleScreen(void); static void NDS_LoadOverlay_GroundMain(); @@ -113,7 +104,7 @@ void GameLoop(void) sub_800CD64(0x8000, FALSE); sub_8012284(); InitializeGameOptions(TRUE); - SetWindowTitle(gPMDBuildVersion); + SetWindowTitle(sPMDBuildVersion); sub_800DAAC(); SetSavingIconCoords(NULL); @@ -366,8 +357,8 @@ static void LoadTitleScreen(void) " pop {r0}\n" " bx r0\n" " .align 2, 0\n" -"_08000708: .4byte gLoadScreenBackgroundFileNames\n" -"_0800070C: .4byte gLoadScreenBackgroundPaletteFileNames\n" +"_08000708: .4byte sLoadScreenBackgroundFileNames\n" +"_0800070C: .4byte sLoadScreenBackgroundPaletteFileNames\n" "_08000710: .4byte 0x00005b20\n" "_08000714: .4byte gTitleMenuFileArchive\n" "_08000718: .4byte sTitlePaletteFile\n" @@ -407,7 +398,7 @@ void QuickSave(u32 mode) SetCharacterMask(3); sub_8005838(NULL, 0); sub_80060EC(); - CreateDialogueBoxAndPortrait(gSaveTextQuicksaving, 0, 0, 0x20); + CreateDialogueBoxAndPortrait(sSaveTextQuicksaving, 0, 0, 0x20); while (TRUE) { xxx_update_stuff(0); @@ -442,7 +433,7 @@ void QuickSave(u32 mode) switch (mode) { case 1: case 3: { - CreateDialogueBoxAndPortrait(gSaveTextYourAdventureHasBeenSaved, 0, 0, 0x321); + CreateDialogueBoxAndPortrait(sSaveTextYourAdventureHasBeenSaved, 0, 0, 0x321); counter = 60; saveStatus = SAVE_NOT_WRTTEN; break; @@ -450,7 +441,7 @@ void QuickSave(u32 mode) case 0: case 2: default: { - CreateDialogueBoxAndPortrait(gSaveTextYourAdventureHasBeenSavedLong, 0, 0, 0x321); + CreateDialogueBoxAndPortrait(sSaveTextYourAdventureHasBeenSavedLong, 0, 0, 0x321); counter = 60; saveStatus = SAVE_NOT_WRTTEN; break; @@ -458,11 +449,11 @@ void QuickSave(u32 mode) } } else if (saveStatus == SAVE_NOT_WRTTEN) { - CreateDialogueBoxAndPortrait(gSaveTextTheDataCouldNotBeWritten, 0, 0, 0); + CreateDialogueBoxAndPortrait(sSaveTextTheDataCouldNotBeWritten, 0, 0, 0); saveStatus = SAVE_UNK3; } else { - CreateDialogueBoxAndPortrait(gSaveTextFailed, 0, 0, 0x301); + CreateDialogueBoxAndPortrait(sSaveTextFailed, 0, 0, 0x301); saveStatus = SAVE_FAILED; } break; @@ -520,22 +511,22 @@ void sub_80008C0(u32 errorKind) switch (errorKind) { case 0: { - CreateDialogueBoxAndPortrait(gSaveTextError, 0, 0, 0x20); + CreateDialogueBoxAndPortrait(sSaveTextError, 0, 0, 0x20); saveStatus = SAVE_FAILED; break; } case 1: { - CreateDialogueBoxAndPortrait(gSaveTextCantResume, 0, 0, 0x301); + CreateDialogueBoxAndPortrait(sSaveTextCantResume, 0, 0, 0x301); saveStatus = SAVE_NOT_WRTTEN; break; } case 2: { - CreateDialogueBoxAndPortrait(gSaveTextMayNotResume, 0, 0, 0x301); + CreateDialogueBoxAndPortrait(sSaveTextMayNotResume, 0, 0, 0x301); saveStatus = SAVE_NOT_WRTTEN; break; } case 3: { - CreateDialogueBoxAndPortrait(gSaveTextMayNotResume, 0, 0, 0x301); + CreateDialogueBoxAndPortrait(sSaveTextMayNotResume, 0, 0, 0x301); saveStatus = SAVE_NOT_WRTTEN; break; } @@ -1331,7 +1322,7 @@ void sub_8001064(void) } if (sPersonalityRelated_203B040.StarterID != MONSTER_NONE) { - psVar2 = &gBaseKindTable[0]; + psVar2 = &sBaseKindTable[0]; while (psVar2->species != MONSTER_NONE && sPersonalityRelated_203B040.StarterID != psVar2->species) { psVar2++; } @@ -1339,7 +1330,7 @@ void sub_8001064(void) } if (sPersonalityRelated_203B040.PartnerID != MONSTER_NONE) { - psVar2 = &gTalkKindTable[0]; + psVar2 = &sTalkKindTable[0]; while (psVar2->species != MONSTER_NONE && sPersonalityRelated_203B040.PartnerID != psVar2->species) { psVar2++; }