diff --git a/Makefile b/Makefile index 65a65ab..323f608 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,10 @@ all: $(OUTPUT) $(OUTPUT): $(INPUT) build/linked_processed.o +format: + @find . -not -path "./tools/*" -name *.c -o -not -path "./tools/*" -name *.h | xargs clang-format -i + @echo "Done." + tools: @$(MAKE) -C tools/elfedit @$(MAKE) -C tools/preproc diff --git a/include/constants/gba.h b/include/constants/gba.h index bc35c0d..8cf8a06 100644 --- a/include/constants/gba.h +++ b/include/constants/gba.h @@ -456,7 +456,7 @@ #define REG_DMA3CNT_L (*(vu16 *)REG_ADDR_DMA3CNT_L) #define REG_DMA3CNT_H (*(vu16 *)REG_ADDR_DMA3CNT_H) -#define REG_TMCNT(n) (*(vu16 *)(REG_ADDR_TMCNT + ((n)*4))) +#define REG_TMCNT(n) (*(vu16 *)(REG_ADDR_TMCNT + ((n) * 4))) #define REG_TM0CNT (*(vu32 *)REG_ADDR_TM0CNT) #define REG_TM0CNT_L (*(vu16 *)REG_ADDR_TM0CNT_L) #define REG_TM0CNT_H (*(vu16 *)REG_ADDR_TM0CNT_H) @@ -805,7 +805,7 @@ #define PLTT_SIZE_4BPP PLTT_SIZEOF(16) #define PLTT_SIZE_8BPP PLTT_SIZEOF(256) -#define PLTT_OFFSET_4BPP(n) ((n)*PLTT_SIZE_4BPP) +#define PLTT_OFFSET_4BPP(n) ((n) * PLTT_SIZE_4BPP) #define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) diff --git a/include/palette.h b/include/palette.h index 988d0a1..5e7d5ca 100644 --- a/include/palette.h +++ b/include/palette.h @@ -11,22 +11,22 @@ void LONG_CALL TransferPlttBuffer(void); struct PaletteFadeControl { - /*0x00*/ u32 multipurpose1; - /*0x04*/ u8 delayCounter:6; - /*0x05*/ u16 y:5; // blend coefficient + /*0x00*/ u32 multipurpose1; + /*0x04*/ u8 delayCounter:6; + /*0x05*/ u16 y:5; // blend coefficient /*0x05-06*/ u16 targetY:5; // target blend coefficient - /*0x07*/ u16 blendColor:15; - /*0x07*/ u16 active:1; - /*0x08*/ u16 multipurpose2:6; - /*0x08*/ u16 yDec:1; // whether blend coefficient is decreasing - /*0x08*/ u16 bufferTransferDisabled:1; - /*0x09*/ u16 mode:2; - /*0x09*/ u16 shouldResetBlendRegisters:1; - /*0x09*/ u16 hardwareFadeFinishing:1; + /*0x07*/ u16 blendColor:15; + /*0x07*/ u16 active:1; + /*0x08*/ u16 multipurpose2:6; + /*0x08*/ u16 yDec:1; // whether blend coefficient is decreasing + /*0x08*/ u16 bufferTransferDisabled:1; + /*0x09*/ u16 mode:2; + /*0x09*/ u16 shouldResetBlendRegisters:1; + /*0x09*/ u16 hardwareFadeFinishing:1; /*0x09-0a*/ u16 softwareFadeFinishingCounter:5; - /*0x0a*/ u16 softwareFadeFinishing:1; - /*0x0a*/ u16 objPaletteToggle:1; - /*0x0a*/ u8 deltaY:4; // rate of change of blend coefficient + /*0x0a*/ u16 softwareFadeFinishing:1; + /*0x0a*/ u16 objPaletteToggle:1; + /*0x0a*/ u8 deltaY:4; // rate of change of blend coefficient }; extern struct PaletteFadeControl gPaletteFade; \ No newline at end of file diff --git a/include/pokemon.h b/include/pokemon.h index 72b30c5..bfede84 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -65,7 +65,7 @@ struct PACKED BaseStats /*0x17*/ u8 ability2; /*0x18*/ u8 safariZoneFleeRate; /*0x19*/ u8 bodyColor:7; - u8 noFlip:1; + u8 noFlip:1; }; struct PACKED BoxPokemon diff --git a/include/script_menu.h b/include/script_menu.h index 8309cec..dd974f9 100644 --- a/include/script_menu.h +++ b/include/script_menu.h @@ -16,4 +16,5 @@ extern u8 gRepelMenuChoices[3]; void LONG_CALL DrawMultichoiceMenu( u8 left, u8 top, u8 count, const struct MenuAction *list, u8 ignoreBPress, u8 cursorPos); u8 LONG_CALL CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buffer); -void DrawListMenu(u8 left, u8 top, u8 displayCount, u8 totalCount, const struct MenuAction *list, u8 ignoreBPress, u8 cursorPos); +void DrawListMenu( + u8 left, u8 top, u8 displayCount, u8 totalCount, const struct MenuAction *list, u8 ignoreBPress, u8 cursorPos); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 4235036..d700a62 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -1,6 +1,6 @@ #include "types.h" -#include "event_object_movement.h" #include "field_control_avatar.h" +#include "event_object_movement.h" #include "field_message_box.h" #include "field_player_avatar.h" #include "flags.h" @@ -29,7 +29,7 @@ int ProcessPlayerFieldInput_Rest(struct FieldInput *input) #include "save_time_util.h" static const u8 sText_DisabledAutorun[] = _("Autorun {COLOR RED}disabled{COLOR DARK_GREY}."); -static const u8 sText_EnabledAutorun[] =_("Autorun {COLOR GREEN}enabled{COLOR DARK_GREY}."); +static const u8 sText_EnabledAutorun[] = _("Autorun {COLOR GREEN}enabled{COLOR DARK_GREY}."); static bool8 EnableAutoRun(void) { diff --git a/src/field_message_box.c b/src/field_message_box.c index 86e46ba..84aedd1 100644 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -36,7 +36,7 @@ static void PrintFieldMessageInstant(const u8 *message) lo = (u16 *)(&gTasks[taskId].data[2]); *hi = (u32)(message) >> 16; - *lo = (u32)(message)&0xffff; + *lo = (u32)(message) & 0xffff; } static void Task_FieldMessageBoxInstant(u8 taskId) diff --git a/src/pokemon.c b/src/pokemon.c index 2401fa7..7470b92 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -91,6 +91,7 @@ void CheckIfPartyHasMoveForElevator(void) u8 GetNature_(struct Pokemon *mon) { - if (mon->box.nature == 0) return GetNatureFromPersonality(GetMonData(mon, MON_DATA_PERSONALITY)); + if (mon->box.nature == 0) + return GetNatureFromPersonality(GetMonData(mon, MON_DATA_PERSONALITY)); return mon->box.nature - 1; } \ No newline at end of file diff --git a/src/pokemon_menu.c b/src/pokemon_menu.c index 10a0867..47ff8e5 100644 --- a/src/pokemon_menu.c +++ b/src/pokemon_menu.c @@ -94,61 +94,61 @@ void OpenPokemonContextMenu(void) } } -static const u8 sNatureName_Hardy[] = _("HARDY"); -static const u8 sNatureName_Lonely[] = _("LONELY"); -static const u8 sNatureName_Brave[] = _("BRAVE"); +static const u8 sNatureName_Hardy[] = _("HARDY"); +static const u8 sNatureName_Lonely[] = _("LONELY"); +static const u8 sNatureName_Brave[] = _("BRAVE"); static const u8 sNatureName_Adamant[] = _("ADAMANT"); static const u8 sNatureName_Naughty[] = _("NAUGHTY"); -static const u8 sNatureName_Bold[] = _("BOLD"); -static const u8 sNatureName_Docile[] = _("DOCILE"); +static const u8 sNatureName_Bold[] = _("BOLD"); +static const u8 sNatureName_Docile[] = _("DOCILE"); static const u8 sNatureName_Relaxed[] = _("RELAXED"); -static const u8 sNatureName_Impish[] = _("IMPISH"); -static const u8 sNatureName_Lax[] = _("LAX"); -static const u8 sNatureName_Timid[] = _("TIMID"); -static const u8 sNatureName_Hasty[] = _("HASTY"); +static const u8 sNatureName_Impish[] = _("IMPISH"); +static const u8 sNatureName_Lax[] = _("LAX"); +static const u8 sNatureName_Timid[] = _("TIMID"); +static const u8 sNatureName_Hasty[] = _("HASTY"); static const u8 sNatureName_Serious[] = _("SERIOUS"); -static const u8 sNatureName_Jolly[] = _("JOLLY"); -static const u8 sNatureName_Naive[] = _("NAIVE"); -static const u8 sNatureName_Modest[] = _("MODEST"); -static const u8 sNatureName_Mild[] = _("MILD"); -static const u8 sNatureName_Quiet[] = _("QUIET"); +static const u8 sNatureName_Jolly[] = _("JOLLY"); +static const u8 sNatureName_Naive[] = _("NAIVE"); +static const u8 sNatureName_Modest[] = _("MODEST"); +static const u8 sNatureName_Mild[] = _("MILD"); +static const u8 sNatureName_Quiet[] = _("QUIET"); static const u8 sNatureName_Bashful[] = _("BASHFUL"); -static const u8 sNatureName_Rash[] = _("RASH"); -static const u8 sNatureName_Calm[] = _("CALM"); -static const u8 sNatureName_Gentle[] = _("GENTLE"); -static const u8 sNatureName_Sassy[] = _("SASSY"); +static const u8 sNatureName_Rash[] = _("RASH"); +static const u8 sNatureName_Calm[] = _("CALM"); +static const u8 sNatureName_Gentle[] = _("GENTLE"); +static const u8 sNatureName_Sassy[] = _("SASSY"); static const u8 sNatureName_Careful[] = _("CAREFUL"); -static const u8 sNatureName_Quirky[] = _("QUIRKY"); +static const u8 sNatureName_Quirky[] = _("QUIRKY"); extern const u8 gOtherText_CancelNoTerminator[]; const struct MenuAction sNatureMenuActions[] = { - {sNatureName_Hardy, NULL}, - {sNatureName_Lonely, NULL}, - {sNatureName_Brave, NULL}, - {sNatureName_Adamant, NULL}, - {sNatureName_Naughty, NULL}, - {sNatureName_Bold, NULL}, - {sNatureName_Docile, NULL}, - {sNatureName_Relaxed, NULL}, - {sNatureName_Impish, NULL}, - {sNatureName_Lax, NULL}, - {sNatureName_Timid, NULL}, - {sNatureName_Hasty, NULL}, - {sNatureName_Serious, NULL}, - {sNatureName_Jolly, NULL}, - {sNatureName_Naive, NULL}, - {sNatureName_Modest, NULL}, - {sNatureName_Mild, NULL}, - {sNatureName_Quiet, NULL}, - {sNatureName_Bashful, NULL}, - {sNatureName_Rash, NULL}, - {sNatureName_Calm, NULL}, - {sNatureName_Gentle, NULL}, - {sNatureName_Sassy, NULL}, - {sNatureName_Careful, NULL}, - {sNatureName_Quirky, NULL}, - {gOtherText_CancelNoTerminator, NULL} + { sNatureName_Hardy, NULL }, + { sNatureName_Lonely, NULL }, + { sNatureName_Brave, NULL }, + { sNatureName_Adamant, NULL }, + { sNatureName_Naughty, NULL }, + { sNatureName_Bold, NULL }, + { sNatureName_Docile, NULL }, + { sNatureName_Relaxed, NULL }, + { sNatureName_Impish, NULL }, + { sNatureName_Lax, NULL }, + { sNatureName_Timid, NULL }, + { sNatureName_Hasty, NULL }, + { sNatureName_Serious, NULL }, + { sNatureName_Jolly, NULL }, + { sNatureName_Naive, NULL }, + { sNatureName_Modest, NULL }, + { sNatureName_Mild, NULL }, + { sNatureName_Quiet, NULL }, + { sNatureName_Bashful, NULL }, + { sNatureName_Rash, NULL }, + { sNatureName_Calm, NULL }, + { sNatureName_Gentle, NULL }, + { sNatureName_Sassy, NULL }, + { sNatureName_Careful, NULL }, + { sNatureName_Quirky, NULL }, + { gOtherText_CancelNoTerminator, NULL } }; void DrawNaturesWindow(void) @@ -158,7 +158,8 @@ void DrawNaturesWindow(void) void BufferNatureName(void) { - if (gSpecialVar_Result >= 25) return; + if (gSpecialVar_Result >= 25) + return; StringCopy(gStringVar1, gNatureNames[gSpecialVar_Result]); } @@ -190,5 +191,6 @@ void ChangePartyMonAbility(void) void BufferAlternateAbilityName(void) { struct Pokemon *mon = &gPlayerParty[gSpecialVar_0x8004]; - StringCopy(gStringVar1, gAbilityNames[GetAbilityBySpecies(GetMonData(mon, MON_DATA_SPECIES), !GetMonData(mon, MON_DATA_ALT_ABILITY))]); + StringCopy(gStringVar1, + gAbilityNames[GetAbilityBySpecies(GetMonData(mon, MON_DATA_SPECIES), !GetMonData(mon, MON_DATA_ALT_ABILITY))]); } \ No newline at end of file diff --git a/src/script_menu.c b/src/script_menu.c index 06889f0..8fb8dcd 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -4,8 +4,8 @@ #include "main.h" #include "menu.h" #include "palette.h" -#include "sound.h" #include "script.h" +#include "sound.h" #include "sprite.h" #include "task.h" #include "vars.h" @@ -20,7 +20,8 @@ static const u16 sRepelItems[3] = { ITEM_REPEL, ITEM_SUPER_REPEL, ITEM_MAX_REPEL static void Task_TrainerPicWindow(u8 taskId); static bool8 (*ScriptMenu_GetTrainerPicboxWaitFunc(void))(void); static bool8 IsPicboxClosed(void); -static void StartListMenuTask(const struct MenuAction *list, u8 left, u8 top, u8 right, u8 bottom, u8 ignoreBPress, u8 displayCount, u8 totalCount); +static void StartListMenuTask(const struct MenuAction *list, u8 left, u8 top, u8 right, u8 bottom, u8 ignoreBPress, + u8 displayCount, u8 totalCount); static void Task_HandleListMenuInput(u8 taskId); u16 LONG_CALL GetStringWidthInTilesForScriptMenu(const u8 *str); @@ -154,7 +155,8 @@ static bool8 IsPicboxClosed(void) #undef tWindowX #undef tWindowY -void DrawListMenu(u8 left, u8 top, u8 displayCount, u8 totalCount, const struct MenuAction *list, u8 ignoreBPress, u8 cursorPos) +void DrawListMenu( + u8 left, u8 top, u8 displayCount, u8 totalCount, const struct MenuAction *list, u8 ignoreBPress, u8 cursorPos) { u16 width = GetStringWidthInTilesForScriptMenu(list[0].text); u16 newWidth; @@ -199,13 +201,14 @@ void DrawListMenu(u8 left, u8 top, u8 displayCount, u8 totalCount, const struct #define tDisplayCount data[10] #define tTotalCount data[11] -static void StartListMenuTask(const struct MenuAction *list, u8 left, u8 top, u8 right, u8 bottom, u8 ignoreBPress, u8 displayCount, u8 totalCount) +static void StartListMenuTask(const struct MenuAction *list, u8 left, u8 top, u8 right, u8 bottom, u8 ignoreBPress, + u8 displayCount, u8 totalCount) { u8 taskId = CreateTask(Task_HandleListMenuInput, 80); gTasks[taskId].tListPtrHi = (u32)list >> 16; gTasks[taskId].tListPtrLo = (u32)list; - + gTasks[taskId].tLeft = left; gTasks[taskId].tTop = top; gTasks[taskId].tRight = right; @@ -235,8 +238,10 @@ static void Task_HandleListMenuInput(u8 taskId) s16 *data = gTasks[taskId].data; struct MenuAction *list = (struct MenuAction *)((u16)tListPtrHi << 16 | (u16)tListPtrLo); - if (gPaletteFade.active) return; - if (gMain.newKeys & A_BUTTON) { + if (gPaletteFade.active) + return; + if (gMain.newKeys & A_BUTTON) + { gSpecialVar_Result = tCursor + tScrollOffset; Menu_DestroyCursor(); Menu_EraseWindowRect(gTasks[taskId].tLeft, gTasks[taskId].tTop, gTasks[taskId].tRight, gTasks[taskId].tBottom); @@ -244,8 +249,11 @@ static void Task_HandleListMenuInput(u8 taskId) EnableBothScriptContexts(); DestroyVerticalScrollIndicator(TOP_ARROW); DestroyVerticalScrollIndicator(BOTTOM_ARROW); - } else if (gMain.newKeys & B_BUTTON) { - if (tIgnoreBPress) return; + } + else if (gMain.newKeys & B_BUTTON) + { + if (tIgnoreBPress) + return; gSpecialVar_Result = 127; Menu_DestroyCursor(); @@ -254,25 +262,37 @@ static void Task_HandleListMenuInput(u8 taskId) EnableBothScriptContexts(); DestroyVerticalScrollIndicator(TOP_ARROW); DestroyVerticalScrollIndicator(BOTTOM_ARROW); - } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { - if (tCursor == tDisplayCount - 1) { - if (tCursor + tScrollOffset == tTotalCount - 1) return; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + { + if (tCursor == tDisplayCount - 1) + { + if (tCursor + tScrollOffset == tTotalCount - 1) + return; PlaySE(SE_SELECT); tScrollOffset++; Menu_BlankWindowRect(tLeft + 1, tTop + 1, tRight - 1, tBottom - 1); Menu_PrintItems(tLeft + 1, tTop + 1, tDisplayCount, list + tScrollOffset); - } else { + } + else + { PlaySE(SE_SELECT); tCursor = Menu_MoveCursor(1); } - } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { - if (tCursor == 0) { - if (tScrollOffset == 0) return; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + { + if (tCursor == 0) + { + if (tScrollOffset == 0) + return; PlaySE(SE_SELECT); tScrollOffset--; Menu_BlankWindowRect(tLeft + 1, tTop + 1, tRight - 1, tBottom - 1); Menu_PrintItems(tLeft + 1, tTop + 1, tDisplayCount, list + tScrollOffset); - } else { + } + else + { PlaySE(SE_SELECT); tCursor = Menu_MoveCursor(-1); }