From 8c6c194f26547480b9f9394f73bbd3cb2e4b583f Mon Sep 17 00:00:00 2001 From: Pseurae Date: Mon, 3 Jul 2023 01:22:40 +0530 Subject: [PATCH] Clean up and format all scripts till now --- .clang-format | 3 +- include/constants/gba.h | 196 +++++++++--------- include/event_object_movement.h | 2 +- include/field_effect_helpers.h | 2 + include/field_player_avatar.h | 24 ++- include/fieldmap.h | 67 +++--- include/sprite.h | 36 ++-- include/types.h | 6 +- main.asm | 6 +- scripts/bugfixes/fadescreen_shade.asm | 4 +- scripts/bugfixes/field_mon_sprite.asm | 4 +- scripts/bugfixes/fix_poke_types.asm | 7 - scripts/bugfixes/revert_diseased_types.asm | 0 scripts/bugfixes/shop_frame_tiles.asm | 4 +- scripts/bugfixes/text_colors.asm | 4 - scripts/colored_field_moves.asm | 30 +-- scripts/emerald_save_prompt.asm | 20 +- scripts/hm_system.asm | 8 +- scripts/include/{macros.asm => scripts.asm} | 0 scripts/ow_shadows.asm | 37 ++-- scripts/predefs/common.asm | 25 +++ scripts/predefs/gba.asm | 3 + .../{common.asm => predefs/pokemon_data.asm} | 19 +- scripts/ps_split.asm | 4 +- scripts/reusable_tms.asm | 8 +- scripts/summary_screen.asm | 4 +- src/calculate_dmg.c | 16 +- src/event_object_movement.c | 31 ++- src/field_effect.c | 2 +- src/field_effect_helpers.c | 14 +- src/pokemon.c | 8 +- src/save_menu_util.c | 4 +- 32 files changed, 295 insertions(+), 303 deletions(-) delete mode 100644 scripts/bugfixes/revert_diseased_types.asm rename scripts/include/{macros.asm => scripts.asm} (100%) create mode 100644 scripts/predefs/common.asm create mode 100644 scripts/predefs/gba.asm rename scripts/{common.asm => predefs/pokemon_data.asm} (76%) diff --git a/.clang-format b/.clang-format index ff8c104..7d19584 100644 --- a/.clang-format +++ b/.clang-format @@ -5,7 +5,7 @@ BinPackArguments: false AllowShortFunctionsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false -BreakBeforeBinaryOperators: false +BreakBeforeBinaryOperators: NonAssignment IndentWidth: 4 NamespaceIndentation: All AllowAllParametersOfDeclarationOnNextLine: false @@ -18,6 +18,7 @@ AlignConsecutiveMacros: AcrossComments: false AlignConsecutiveBitFields: false BitFieldColonSpacing: None +SpaceBeforeAssignmentOperators: true AlignOperands: AlignAfterOperator IncludeBlocks: Merge IncludeCategories: diff --git a/include/constants/gba.h b/include/constants/gba.h index b427097..893e95e 100644 --- a/include/constants/gba.h +++ b/include/constants/gba.h @@ -392,42 +392,42 @@ #define REG_BLDY (*(vu16 *)REG_ADDR_BLDY) #define REG_SOUND1CNT_L (*(vu16 *)REG_ADDR_SOUND1CNT_L) -#define REG_NR10 (*(vu8 *)REG_ADDR_NR10) +#define REG_NR10 (*(vu8 *)REG_ADDR_NR10) #define REG_SOUND1CNT_H (*(vu16 *)REG_ADDR_SOUND1CNT_H) -#define REG_NR11 (*(vu8 *)REG_ADDR_NR11) -#define REG_NR12 (*(vu8 *)REG_ADDR_NR12) +#define REG_NR11 (*(vu8 *)REG_ADDR_NR11) +#define REG_NR12 (*(vu8 *)REG_ADDR_NR12) #define REG_SOUND1CNT_X (*(vu16 *)REG_ADDR_SOUND1CNT_X) -#define REG_NR13 (*(vu8 *)REG_ADDR_NR13) -#define REG_NR14 (*(vu8 *)REG_ADDR_NR14) +#define REG_NR13 (*(vu8 *)REG_ADDR_NR13) +#define REG_NR14 (*(vu8 *)REG_ADDR_NR14) #define REG_SOUND2CNT_L (*(vu16 *)REG_ADDR_SOUND2CNT_L) -#define REG_NR21 (*(vu8 *)REG_ADDR_NR21) -#define REG_NR22 (*(vu8 *)REG_ADDR_NR22) +#define REG_NR21 (*(vu8 *)REG_ADDR_NR21) +#define REG_NR22 (*(vu8 *)REG_ADDR_NR22) #define REG_SOUND2CNT_H (*(vu16 *)REG_ADDR_SOUND2CNT_H) -#define REG_NR23 (*(vu8 *)REG_ADDR_NR23) -#define REG_NR24 (*(vu8 *)REG_ADDR_NR24) +#define REG_NR23 (*(vu8 *)REG_ADDR_NR23) +#define REG_NR24 (*(vu8 *)REG_ADDR_NR24) #define REG_SOUND3CNT_L (*(vu16 *)REG_ADDR_SOUND3CNT_L) -#define REG_NR30 (*(vu8 *)REG_ADDR_NR30) +#define REG_NR30 (*(vu8 *)REG_ADDR_NR30) #define REG_SOUND3CNT_H (*(vu16 *)REG_ADDR_SOUND3CNT_H) -#define REG_NR31 (*(vu8 *)REG_ADDR_NR31) -#define REG_NR32 (*(vu8 *)REG_ADDR_NR32) +#define REG_NR31 (*(vu8 *)REG_ADDR_NR31) +#define REG_NR32 (*(vu8 *)REG_ADDR_NR32) #define REG_SOUND3CNT_X (*(vu16 *)REG_ADDR_SOUND3CNT_X) -#define REG_NR33 (*(vu8 *)REG_ADDR_NR33) -#define REG_NR34 (*(vu8 *)REG_ADDR_NR34) +#define REG_NR33 (*(vu8 *)REG_ADDR_NR33) +#define REG_NR34 (*(vu8 *)REG_ADDR_NR34) #define REG_SOUND4CNT_L (*(vu16 *)REG_ADDR_SOUND4CNT_L) -#define REG_NR41 (*(vu8 *)REG_ADDR_NR41) -#define REG_NR42 (*(vu8 *)REG_ADDR_NR42) +#define REG_NR41 (*(vu8 *)REG_ADDR_NR41) +#define REG_NR42 (*(vu8 *)REG_ADDR_NR42) #define REG_SOUND4CNT_H (*(vu16 *)REG_ADDR_SOUND4CNT_H) -#define REG_NR43 (*(vu8 *)REG_ADDR_NR43) -#define REG_NR44 (*(vu8 *)REG_ADDR_NR44) +#define REG_NR43 (*(vu8 *)REG_ADDR_NR43) +#define REG_NR44 (*(vu8 *)REG_ADDR_NR44) #define REG_SOUNDCNT_L (*(vu16 *)REG_ADDR_SOUNDCNT_L) -#define REG_NR50 (*(vu8 *)REG_ADDR_NR50) -#define REG_NR51 (*(vu8 *)REG_ADDR_NR51) +#define REG_NR50 (*(vu8 *)REG_ADDR_NR50) +#define REG_NR51 (*(vu8 *)REG_ADDR_NR51) #define REG_SOUNDCNT_H (*(vu16 *)REG_ADDR_SOUNDCNT_H) #define REG_SOUNDCNT_X (*(vu16 *)REG_ADDR_SOUNDCNT_X) -#define REG_NR52 (*(vu8 *)REG_ADDR_NR52) +#define REG_NR52 (*(vu8 *)REG_ADDR_NR52) #define REG_SOUNDBIAS (*(vu16 *)REG_ADDR_SOUNDBIAS) -#define REG_SOUNDBIAS_L (*(vu8 *)REG_ADDR_SOUNDBIAS_L) -#define REG_SOUNDBIAS_H (*(vu8 *)REG_ADDR_SOUNDBIAS_H) +#define REG_SOUNDBIAS_L (*(vu8 *)REG_ADDR_SOUNDBIAS_L) +#define REG_SOUNDBIAS_H (*(vu8 *)REG_ADDR_SOUNDBIAS_H) #define REG_WAVE_RAM0 (*(vu32 *)REG_ADDR_WAVE_RAM0) #define REG_WAVE_RAM1 (*(vu32 *)REG_ADDR_WAVE_RAM1) #define REG_WAVE_RAM2 (*(vu32 *)REG_ADDR_WAVE_RAM2) @@ -459,7 +459,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) @@ -524,78 +524,80 @@ #define DISPSTAT_VCOUNT_INTR 0x0020 // V-Count interrupt enabled // BGCNT -#define BGCNT_PRIORITY(n) (n) // Values 0 - 3. Lower priority BGs will be drawn on top of higher priority BGs. +#define BGCNT_PRIORITY(n) (n) // Values 0 - 3. Lower priority BGs will be drawn on top of higher priority BGs. #define BGCNT_CHARBASE(n) ((n) << 2) // Values 0 - 3. Base block for tile pixel data. -#define BGCNT_MOSAIC 0x0040 -#define BGCNT_16COLOR 0x0000 // 4 bits per pixel -#define BGCNT_256COLOR 0x0080 // 8 bits per pixel +#define BGCNT_MOSAIC 0x0040 +#define BGCNT_16COLOR 0x0000 // 4 bits per pixel +#define BGCNT_256COLOR 0x0080 // 8 bits per pixel #define BGCNT_SCREENBASE(n) ((n) << 8) // Values 0 - 31. Base block for tile map. -#define BGCNT_WRAP 0x2000 // Only affects affine BGs. Text BGs wrap by default. -#define BGCNT_TXT256x256 0x0000 // Internal screen size size of text mode BG in pixels. -#define BGCNT_TXT512x256 0x4000 -#define BGCNT_TXT256x512 0x8000 -#define BGCNT_TXT512x512 0xC000 -#define BGCNT_AFF128x128 0x0000 // Internal screen size size of affine mode BG in pixels. -#define BGCNT_AFF256x256 0x4000 -#define BGCNT_AFF512x512 0x8000 -#define BGCNT_AFF1024x1024 0xC000 +#define BGCNT_WRAP 0x2000 // Only affects affine BGs. Text BGs wrap by default. +#define BGCNT_TXT256x256 0x0000 // Internal screen size size of text mode BG in pixels. +#define BGCNT_TXT512x256 0x4000 +#define BGCNT_TXT256x512 0x8000 +#define BGCNT_TXT512x512 0xC000 +#define BGCNT_AFF128x128 0x0000 // Internal screen size size of affine mode BG in pixels. +#define BGCNT_AFF256x256 0x4000 +#define BGCNT_AFF512x512 0x8000 +#define BGCNT_AFF1024x1024 0xC000 // WININ/OUT -#define WININ_WIN0_BG0 (1 << 0) -#define WININ_WIN0_BG1 (1 << 1) -#define WININ_WIN0_BG2 (1 << 2) -#define WININ_WIN0_BG3 (1 << 3) -#define WININ_WIN0_BG_ALL (WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3) -#define WININ_WIN0_OBJ (1 << 4) -#define WININ_WIN0_CLR (1 << 5) -#define WININ_WIN1_BG0 (1 << 8) -#define WININ_WIN1_BG1 (1 << 9) -#define WININ_WIN1_BG2 (1 << 10) -#define WININ_WIN1_BG3 (1 << 11) -#define WININ_WIN1_BG_ALL (WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_BG3) -#define WININ_WIN1_OBJ (1 << 12) -#define WININ_WIN1_CLR (1 << 13) - -#define WINOUT_WIN01_BG0 (1 << 0) -#define WINOUT_WIN01_BG1 (1 << 1) -#define WINOUT_WIN01_BG2 (1 << 2) -#define WINOUT_WIN01_BG3 (1 << 3) -#define WINOUT_WIN01_BG_ALL (WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3) -#define WINOUT_WIN01_OBJ (1 << 4) -#define WINOUT_WIN01_CLR (1 << 5) -#define WINOUT_WINOBJ_BG0 (1 << 8) -#define WINOUT_WINOBJ_BG1 (1 << 9) -#define WINOUT_WINOBJ_BG2 (1 << 10) -#define WINOUT_WINOBJ_BG3 (1 << 11) +#define WININ_WIN0_BG0 (1 << 0) +#define WININ_WIN0_BG1 (1 << 1) +#define WININ_WIN0_BG2 (1 << 2) +#define WININ_WIN0_BG3 (1 << 3) +#define WININ_WIN0_BG_ALL (WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3) +#define WININ_WIN0_OBJ (1 << 4) +#define WININ_WIN0_CLR (1 << 5) +#define WININ_WIN1_BG0 (1 << 8) +#define WININ_WIN1_BG1 (1 << 9) +#define WININ_WIN1_BG2 (1 << 10) +#define WININ_WIN1_BG3 (1 << 11) +#define WININ_WIN1_BG_ALL (WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_BG3) +#define WININ_WIN1_OBJ (1 << 12) +#define WININ_WIN1_CLR (1 << 13) + +#define WINOUT_WIN01_BG0 (1 << 0) +#define WINOUT_WIN01_BG1 (1 << 1) +#define WINOUT_WIN01_BG2 (1 << 2) +#define WINOUT_WIN01_BG3 (1 << 3) +#define WINOUT_WIN01_BG_ALL (WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3) +#define WINOUT_WIN01_OBJ (1 << 4) +#define WINOUT_WIN01_CLR (1 << 5) +#define WINOUT_WINOBJ_BG0 (1 << 8) +#define WINOUT_WINOBJ_BG1 (1 << 9) +#define WINOUT_WINOBJ_BG2 (1 << 10) +#define WINOUT_WINOBJ_BG3 (1 << 11) #define WINOUT_WINOBJ_BG_ALL (WINOUT_WINOBJ_BG0 | WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_BG3) -#define WINOUT_WINOBJ_OBJ (1 << 12) -#define WINOUT_WINOBJ_CLR (1 << 13) +#define WINOUT_WINOBJ_OBJ (1 << 12) +#define WINOUT_WINOBJ_CLR (1 << 13) -#define WIN_RANGE(a, b) (((a) << 8) | (b)) -#define WIN_RANGE2(a, b) ((b) | ((a) << 8)) +#define WIN_RANGE(a, b) (((a) << 8) | (b)) +#define WIN_RANGE2(a, b) ((b) | ((a) << 8)) // BLDCNT // Bits 0-5 select layers for the 1st target -#define BLDCNT_TGT1_BG0 (1 << 0) -#define BLDCNT_TGT1_BG1 (1 << 1) -#define BLDCNT_TGT1_BG2 (1 << 2) -#define BLDCNT_TGT1_BG3 (1 << 3) -#define BLDCNT_TGT1_OBJ (1 << 4) -#define BLDCNT_TGT1_BD (1 << 5) -#define BLDCNT_TGT1_ALL (BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD) +#define BLDCNT_TGT1_BG0 (1 << 0) +#define BLDCNT_TGT1_BG1 (1 << 1) +#define BLDCNT_TGT1_BG2 (1 << 2) +#define BLDCNT_TGT1_BG3 (1 << 3) +#define BLDCNT_TGT1_OBJ (1 << 4) +#define BLDCNT_TGT1_BD (1 << 5) +#define BLDCNT_TGT1_ALL \ + (BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD) // Bits 6-7 select the special effect -#define BLDCNT_EFFECT_NONE (0 << 6) // no special effect -#define BLDCNT_EFFECT_BLEND (1 << 6) // 1st+2nd targets mixed (controlled by BLDALPHA) -#define BLDCNT_EFFECT_LIGHTEN (2 << 6) // 1st target becomes whiter (controlled by BLDY) -#define BLDCNT_EFFECT_DARKEN (3 << 6) // 1st target becomes blacker (controlled by BLDY) +#define BLDCNT_EFFECT_NONE (0 << 6) // no special effect +#define BLDCNT_EFFECT_BLEND (1 << 6) // 1st+2nd targets mixed (controlled by BLDALPHA) +#define BLDCNT_EFFECT_LIGHTEN (2 << 6) // 1st target becomes whiter (controlled by BLDY) +#define BLDCNT_EFFECT_DARKEN (3 << 6) // 1st target becomes blacker (controlled by BLDY) // Bits 8-13 select layers for the 2nd target -#define BLDCNT_TGT2_BG0 (1 << 8) -#define BLDCNT_TGT2_BG1 (1 << 9) -#define BLDCNT_TGT2_BG2 (1 << 10) -#define BLDCNT_TGT2_BG3 (1 << 11) -#define BLDCNT_TGT2_OBJ (1 << 12) -#define BLDCNT_TGT2_BD (1 << 13) -#define BLDCNT_TGT2_ALL (BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD) +#define BLDCNT_TGT2_BG0 (1 << 8) +#define BLDCNT_TGT2_BG1 (1 << 9) +#define BLDCNT_TGT2_BG2 (1 << 10) +#define BLDCNT_TGT2_BG3 (1 << 11) +#define BLDCNT_TGT2_OBJ (1 << 12) +#define BLDCNT_TGT2_BD (1 << 13) +#define BLDCNT_TGT2_ALL \ + (BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD) // BLDALPHA #define BLDALPHA_BLEND(target1, target2) (((target2) << 8) | (target1)) @@ -702,16 +704,16 @@ #define JOY_EXCL_DPAD 0x030F // interrupt flags -#define INTR_FLAG_VBLANK (1 << 0) -#define INTR_FLAG_HBLANK (1 << 1) -#define INTR_FLAG_VCOUNT (1 << 2) -#define INTR_FLAG_TIMER0 (1 << 3) -#define INTR_FLAG_TIMER1 (1 << 4) -#define INTR_FLAG_TIMER2 (1 << 5) -#define INTR_FLAG_TIMER3 (1 << 6) -#define INTR_FLAG_SERIAL (1 << 7) -#define INTR_FLAG_DMA0 (1 << 8) -#define INTR_FLAG_DMA1 (1 << 9) +#define INTR_FLAG_VBLANK (1 << 0) +#define INTR_FLAG_HBLANK (1 << 1) +#define INTR_FLAG_VCOUNT (1 << 2) +#define INTR_FLAG_TIMER0 (1 << 3) +#define INTR_FLAG_TIMER1 (1 << 4) +#define INTR_FLAG_TIMER2 (1 << 5) +#define INTR_FLAG_TIMER3 (1 << 6) +#define INTR_FLAG_SERIAL (1 << 7) +#define INTR_FLAG_DMA0 (1 << 8) +#define INTR_FLAG_DMA1 (1 << 9) #define INTR_FLAG_DMA2 (1 << 10) #define INTR_FLAG_DMA3 (1 << 11) #define INTR_FLAG_KEYPAD (1 << 12) @@ -759,7 +761,7 @@ #define WAITCNT_PREFETCH_ENABLE (1 << 14) -#define WAITCNT_AGB (0 << 15) -#define WAITCNT_CGB (1 << 15) +#define WAITCNT_AGB (0 << 15) +#define WAITCNT_CGB (1 << 15) #endif // GUARD_GBA_IO_REG_H diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 9d2bb45..52c3b1a 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -78,6 +78,6 @@ void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *); #define GROUND_EFFECT_FLAG_SEAWEED (1 << 19) #define GROUND_EFFECT_FLAG_SHADOW (1 << 20) -#define OBJECT_EVENTS_COUNT 16 +#define OBJECT_EVENTS_COUNT 16 extern struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT]; diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h index 694616a..371ebd3 100644 --- a/include/field_effect_helpers.h +++ b/include/field_effect_helpers.h @@ -1,5 +1,7 @@ #pragma once +#include "sprite.h" + extern const u16 gShadowVerticalOffsets[4]; extern const void *const gFieldEffectObjectTemplatePointers[]; extern const u8 gShadowEffectTemplateIds[]; diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 79cc323..121e126 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -1,6 +1,7 @@ #pragma once -enum { +enum +{ PLAYER_AVATAR_STATE_NORMAL, PLAYER_AVATAR_STATE_MACH_BIKE, PLAYER_AVATAR_STATE_ACRO_BIKE, @@ -14,21 +15,28 @@ enum { struct PlayerAvatar /* 0x202E858 */ { /*0x00*/ u8 flags; - /*0x01*/ u8 unk1; // used to be named bike, but its definitely not that. seems to be some transition flags + /*0x01*/ u8 unk1; // used to be named bike, but its definitely not that. seems to be some transition flags /*0x02*/ u8 runningState; // this is a static running state. 00 is not moving, 01 is turn direction, 02 is moving. - /*0x03*/ u8 tileTransitionState; // this is a transition running state: 00 is not moving, 01 is transition between tiles, 02 means you are on the frame in which you have centered on a tile but are about to keep moving, even if changing directions. 2 is also used for a ledge hop, since you are transitioning. + /*0x03*/ u8 tileTransitionState; // this is a transition running state: 00 is not moving, 01 is transition between + // tiles, 02 means you are on the frame in which you have centered on a tile but + // are about to keep moving, even if changing directions. 2 is also used for a + // ledge hop, since you are transitioning. /*0x04*/ u8 spriteId; /*0x05*/ u8 objectEventId; /*0x06*/ bool8 preventStep; /*0x07*/ u8 gender; /*0x08*/ u8 acroBikeState; // 00 is normal, 01 is turning, 02 is standing wheelie, 03 is hopping wheelie - /*0x09*/ u8 newDirBackup; // during bike movement, the new direction as opposed to player's direction is backed up here. - /*0x0A*/ u8 bikeFrameCounter; // on the mach bike, when this value is 1, the bike is moving but not accelerating yet for 1 tile. on the acro bike, this acts as a timer for acro bike. + /*0x09*/ u8 + newDirBackup; // during bike movement, the new direction as opposed to player's direction is backed up here. + /*0x0A*/ u8 bikeFrameCounter; // on the mach bike, when this value is 1, the bike is moving but not accelerating yet + // for 1 tile. on the acro bike, this acts as a timer for acro bike. /*0x0B*/ u8 bikeSpeed; - // acro bike only - /*0x0C*/ u32 directionHistory; // up/down/left/right history is stored in each nybble, but using the field directions and not the io inputs. + // acro bike only + /*0x0C*/ u32 directionHistory; // up/down/left/right history is stored in each nybble, but using the field + // directions and not the io inputs. /*0x10*/ u32 abStartSelectHistory; // same as above but for A + B + start + select only - // these two are timer history arrays which [0] is the active timer for acro bike. every element is backed up to the next element upon update. + // these two are timer history arrays which [0] is the active timer for acro + // bike. every element is backed up to the next element upon update. /*0x14*/ u8 dirTimerHistory[8]; /*0x1C*/ u8 abStartSelectTimerHistory[8]; }; diff --git a/include/fieldmap.h b/include/fieldmap.h index e8d6f42..850fc6e 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -31,32 +31,32 @@ struct MapHeader struct PACKED ObjectEvent { /*0x00*/ u32 active:1; - u32 singleMovementActive:1; - u32 triggerGroundEffectsOnMove:1; - u32 triggerGroundEffectsOnStop:1; - u32 disableCoveringGroundEffects:1; // disables ground effects that cover parts of the object's sprite - u32 landingJump:1; - u32 heldMovementActive:1; - u32 heldMovementFinished:1; + u32 singleMovementActive:1; + u32 triggerGroundEffectsOnMove:1; + u32 triggerGroundEffectsOnStop:1; + u32 disableCoveringGroundEffects:1; // disables ground effects that cover parts of the object's sprite + u32 landingJump:1; + u32 heldMovementActive:1; + u32 heldMovementFinished:1; /*0x01*/ u32 frozen:1; - u32 facingDirectionLocked:1; - u32 disableAnim:1; // used to disable forced movement sliding animations (like on ice) - u32 enableAnim:1; - u32 inanimate:1; - u32 invisible:1; - u32 offScreen:1; - u32 trackedByCamera:1; // only set for the player object + u32 facingDirectionLocked:1; + u32 disableAnim:1; // used to disable forced movement sliding animations (like on ice) + u32 enableAnim:1; + u32 inanimate:1; + u32 invisible:1; + u32 offScreen:1; + u32 trackedByCamera:1; // only set for the player object /*0x02*/ u32 isPlayer:1; - u32 hasReflection:1; - u32 inShortGrass:1; - u32 inShallowFlowingWater:1; - u32 inSandPile:1; - u32 inHotSprings:1; - u32 hasShadow:1; - u32 spriteAnimPausedBackup:1; + u32 hasReflection:1; + u32 inShortGrass:1; + u32 inShallowFlowingWater:1; + u32 inSandPile:1; + u32 inHotSprings:1; + u32 hasShadow:1; + u32 spriteAnimPausedBackup:1; /*0x03*/ u32 spriteAffineAnimPausedBackup:1; - u32 disableJumpLandingGroundEffect:1; - u32 fixedPriority:1; + u32 disableJumpLandingGroundEffect:1; + u32 fixedPriority:1; /*0x04*/ u8 spriteId; /*0x05*/ u8 graphicsId; /*0x06*/ u8 movementType; @@ -65,19 +65,21 @@ struct PACKED ObjectEvent /*0x09*/ u8 mapNum; /*0x0A*/ u8 mapGroup; /*0x0B*/ u8 currentElevation:4; - u8 previousElevation:4; + u8 previousElevation:4; /*0x0C*/ struct Coords16 initialCoords; /*0x10*/ struct Coords16 currentCoords; /*0x14*/ struct Coords16 previousCoords; /*0x18*/ u8 facingDirection:4; /*0x18*/ u8 movementDirection:4; - /*0x19*/ union PACKED { + /*0x19*/ union PACKED + { u8 as_byte; - struct PACKED { + struct PACKED + { u16 x:4; u16 y:4; } as_nybbles; - } range; + } range; /*0x1A*/ u8 fieldEffectSpriteId; /*0x1B*/ u8 warpArrowSpriteId; /*0x1C*/ u8 movementActionId; @@ -86,11 +88,12 @@ struct PACKED ObjectEvent /*0x1F*/ u8 previousMetatileBehavior; /*0x20*/ u8 previousMovementDirection; /*0x21*/ u8 directionSequenceIndex; - /*0x22*/ u8 playerCopyableMovement; // used as an index to gCopyPlayerMovementFuncs for the "copy player" movement types + /*0x22*/ u8 + playerCopyableMovement; // used as an index to gCopyPlayerMovementFuncs for the "copy player" movement types /*size = 0x24*/ }; -struct PACKED ObjectEventGraphicsInfo +struct PACKED ObjectEventGraphicsInfo { /*0x00*/ u16 tileTag; /*0x02*/ u16 paletteTag; @@ -99,9 +102,9 @@ struct PACKED ObjectEventGraphicsInfo /*0x08*/ s16 width; /*0x0A*/ s16 height; /*0x0C*/ u8 paletteSlot:4; - u8 shadowSize:2; - u8 inanimate:1; - u8 disableReflectionPaletteLoad:1; + u8 shadowSize:2; + u8 inanimate:1; + u8 disableReflectionPaletteLoad:1; /*0x0D*/ u8 tracks; /*0x10*/ const struct OamData *oam; /*0x14*/ const struct SubspriteTable *subspriteTables; diff --git a/include/sprite.h b/include/sprite.h index 6bd708f..da92b6d 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -53,34 +53,34 @@ struct PACKED Sprite /*0x2A*/ u8 animNum; /*0x2B*/ u8 animCmdIndex; /*0x2C*/ u8 animDelayCounter:6; - u8 animPaused:1; - u8 affineAnimPaused:1; + u8 animPaused:1; + u8 affineAnimPaused:1; /*0x2D*/ u8 animLoopCounter; // general purpose data fields /*0x2E*/ s16 data[8]; - /*0x3E*/ u16 inUse:1; //1 - u16 coordOffsetEnabled:1; //2 - bool16 invisible:1; //4 - u16 flags_3:1; //8 - u16 flags_4:1; //0x10 - u16 flags_5:1; //0x20 - u16 flags_6:1; //0x40 - u16 flags_7:1; //0x80 + /*0x3E*/ u16 inUse:1; // 1 + u16 coordOffsetEnabled:1; // 2 + bool16 invisible:1; // 4 + u16 flags_3:1; // 8 + u16 flags_4:1; // 0x10 + u16 flags_5:1; // 0x20 + u16 flags_6:1; // 0x40 + u16 flags_7:1; // 0x80 /*0x3F*/ u16 hFlip:1; - u16 vFlip:1; - u16 animBeginning:1; - u16 affineAnimBeginning:1; - u16 animEnded:1; - u16 affineAnimEnded:1; - u16 usingSheet:1; - u16 flags_f:1; + u16 vFlip:1; + u16 animBeginning:1; + u16 affineAnimBeginning:1; + u16 animEnded:1; + u16 affineAnimEnded:1; + u16 usingSheet:1; + u16 flags_f:1; /*0x40*/ u16 sheetTileStart; /*0x42*/ u8 subspriteTableNum:6; - u8 subspriteMode:2; + u8 subspriteMode:2; /*0x43*/ u8 subpriority; }; diff --git a/include/types.h b/include/types.h index 0dde45b..37625f0 100644 --- a/include/types.h +++ b/include/types.h @@ -39,9 +39,9 @@ struct UCoords16 typedef void (*MainCallback)(void); -#define TRUE 1 -#define FALSE 0 +#define TRUE 1 +#define FALSE 0 -#define NULL 0x0 +#define NULL 0x0 #define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0])) diff --git a/main.asm b/main.asm index 2a3fc17..0a066a8 100644 --- a/main.asm +++ b/main.asm @@ -9,8 +9,8 @@ .include "scripts/include/fldeff.asm" .include "scripts/include/items.asm" -.include "scripts/include/macros.asm" .include "scripts/include/moves.asm" +.include "scripts/include/scripts.asm" .include "scripts/include/species.asm" .include "scripts/include/types.asm" .include "scripts/include/vars_flags.asm" @@ -27,7 +27,9 @@ .importobj "build/linked.o" .endautoregion -.include "scripts/common.asm" +.include "scripts/predefs/common.asm" +.include "scripts/predefs/gba.asm" +.include "scripts/predefs/pokemon_data.asm" .include "scripts/bugfixes/movement/birch_chase.asm" .include "scripts/bugfixes/movement/chloe_entry.asm" diff --git a/scripts/bugfixes/fadescreen_shade.asm b/scripts/bugfixes/fadescreen_shade.asm index 2fd7ce9..f86100d 100644 --- a/scripts/bugfixes/fadescreen_shade.asm +++ b/scripts/bugfixes/fadescreen_shade.asm @@ -2,7 +2,5 @@ .if SHADE_FADESCREEN .org 0x807d644 -ldr r3, =FadeScreen | 1 -bx r3 -.pool +set_function_hook r3, FadeScreen .endif diff --git a/scripts/bugfixes/field_mon_sprite.asm b/scripts/bugfixes/field_mon_sprite.asm index 879d981..efaf052 100644 --- a/scripts/bugfixes/field_mon_sprite.asm +++ b/scripts/bugfixes/field_mon_sprite.asm @@ -1,6 +1,4 @@ .if OW_MON_PIC .org 0x8085ad4 -ldr r7, =CreateMonSprite_PicBox | 1 -bx r7 -.pool +set_function_hook r7, CreateMonSprite_PicBox .endif diff --git a/scripts/bugfixes/fix_poke_types.asm b/scripts/bugfixes/fix_poke_types.asm index 45e4e14..da1f73d 100644 --- a/scripts/bugfixes/fix_poke_types.asm +++ b/scripts/bugfixes/fix_poke_types.asm @@ -1,10 +1,3 @@ -.macro replace_poke_types, i, t1, t2 -.org 0x81fec18 + (0x1c * i) + 6 -.area 0x2, 0x0 -.byte t1, t2 -.endarea -.endmacro - .if FIX_POKEMON_TYPES ; Replace type icons with default ones. diff --git a/scripts/bugfixes/revert_diseased_types.asm b/scripts/bugfixes/revert_diseased_types.asm deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/bugfixes/shop_frame_tiles.asm b/scripts/bugfixes/shop_frame_tiles.asm index b5ef658..7d276eb 100644 --- a/scripts/bugfixes/shop_frame_tiles.asm +++ b/scripts/bugfixes/shop_frame_tiles.asm @@ -2,7 +2,5 @@ .if SHOP_MONEYBOX_FIX .org 0x80b3a70 -ldr r7, =Shop_PrintItemDescText | 1 -bx r7 -.pool +set_function_hook r7, Shop_PrintItemDescText .endif \ No newline at end of file diff --git a/scripts/bugfixes/text_colors.asm b/scripts/bugfixes/text_colors.asm index 63b586f..df79625 100644 --- a/scripts/bugfixes/text_colors.asm +++ b/scripts/bugfixes/text_colors.asm @@ -1,7 +1,3 @@ -.macro gba_color, rv, gv, bv -.halfword (rv | (gv << 5) | (bv << 10)) -.endmacro - .if SOFTER_TEXT_COLORS .org 0x81e66b2 .area 0x20 diff --git a/scripts/colored_field_moves.asm b/scripts/colored_field_moves.asm index ecf2d93..3f6fa4a 100644 --- a/scripts/colored_field_moves.asm +++ b/scripts/colored_field_moves.asm @@ -1,4 +1,4 @@ -.macro set_pokemenu_action_string, i, p +.macro @set_pokemenu_action_string, i, p .org 0x839f494 + (8 * i) .area 0x4, 0x0 .word p @@ -8,20 +8,20 @@ @OptionColor equ 0x4 .if COLORED_FIELD_MOVES -set_pokemenu_action_string 10, @Cut -set_pokemenu_action_string 11, @Flash -set_pokemenu_action_string 12, @RockSmash -set_pokemenu_action_string 13, @Surf -set_pokemenu_action_string 14, @Strength -set_pokemenu_action_string 15, @Fly -set_pokemenu_action_string 16, @Dive -set_pokemenu_action_string 17, @Waterfall -set_pokemenu_action_string 18, @Teleport -set_pokemenu_action_string 19, @Dig -set_pokemenu_action_string 20, @SecretPower -set_pokemenu_action_string 21, @MilkDrink -set_pokemenu_action_string 22, @SoftBoiled -set_pokemenu_action_string 23, @SweetScent +@set_pokemenu_action_string 10, @Cut +@set_pokemenu_action_string 11, @Flash +@set_pokemenu_action_string 12, @RockSmash +@set_pokemenu_action_string 13, @Surf +@set_pokemenu_action_string 14, @Strength +@set_pokemenu_action_string 15, @Fly +@set_pokemenu_action_string 16, @Dive +@set_pokemenu_action_string 17, @Waterfall +@set_pokemenu_action_string 18, @Teleport +@set_pokemenu_action_string 19, @Dig +@set_pokemenu_action_string 20, @SecretPower +@set_pokemenu_action_string 21, @MilkDrink +@set_pokemenu_action_string 22, @SoftBoiled +@set_pokemenu_action_string 23, @SweetScent .autoregion @Cut: diff --git a/scripts/emerald_save_prompt.asm b/scripts/emerald_save_prompt.asm index 0c2c032..f1816e6 100644 --- a/scripts/emerald_save_prompt.asm +++ b/scripts/emerald_save_prompt.asm @@ -1,28 +1,18 @@ .if EMERALD_SAVE_PROMPT .org 0x8094740 -ldr r7, =(PrintSavePlayerName | 1) -bx r7 -.pool +set_function_hook r7, PrintSavePlayerName .org 0x8094778 -ldr r7, =(PrintSaveMapName | 1) -bx r7 -.pool +set_function_hook r7, PrintSaveMapName .org 0x80947b0 -ldr r7, =(PrintSaveBadges | 1) -bx r7 -.pool +set_function_hook r7, PrintSaveBadges .org 0x80947f8 -ldr r7, =(PrintSavePokedexCount | 1) -bx r7 -.pool +set_function_hook r7, PrintSavePokedexCount .org 0x8094844 -ldr r7, =(PrintSavePlayTime | 1) -bx r7 -.pool +set_function_hook r7, PrintSavePlayTime .endif \ No newline at end of file diff --git a/scripts/hm_system.asm b/scripts/hm_system.asm index 8c74d16..1c73332 100644 --- a/scripts/hm_system.asm +++ b/scripts/hm_system.asm @@ -31,9 +31,7 @@ .if NEW_HM_SYSTEM ; Replace Party Context Menu function .org 0x8089a8c -ldr r3, =OpenPokemonContextMenu | 1 -bx r3 -.pool +set_function_hook r3, OpenPokemonContextMenu .org 0x81b0dcc s_goto @EventScript_CutTree @@ -55,9 +53,7 @@ s_goto @EventScript_StrengthBoulder .org 0x80598e0 .area 0x8059930 - 0x80598e0, 0xFE -ldr r7, =PartyHasMonWithSurf | 1 -bx r7 -.pool +set_function_hook r7, PartyHasMonWithSurf .endarea .org 0x8068728 diff --git a/scripts/include/macros.asm b/scripts/include/scripts.asm similarity index 100% rename from scripts/include/macros.asm rename to scripts/include/scripts.asm diff --git a/scripts/ow_shadows.asm b/scripts/ow_shadows.asm index f505976..1ac4e62 100644 --- a/scripts/ow_shadows.asm +++ b/scripts/ow_shadows.asm @@ -10,29 +10,25 @@ nop .if OW_EVENT_SHADOWS .org 0x80635f0 ; GetAllGroundEffectFlags_OnSpawn -ldr r7, =(GetAllGroundEffectFlags_OnSpawn | 1) -bx r7 -.pool +set_function_hook r7, GetAllGroundEffectFlags_OnSpawn .org 0x8063638 ; GetAllGroundEffectFlags_OnBeginStep -ldr r7, =(GetAllGroundEffectFlags_OnBeginStep | 1) -bx r7 -.pool +set_function_hook r7, GetAllGroundEffectFlags_OnBeginStep + .org 0x8063690 ; GetAllGroundEffectFlags_OnFinishStep -ldr r7, =(GetAllGroundEffectFlags_OnFinishStep | 1) -bx r7 -.pool +set_function_hook r7, GetAllGroundEffectFlags_OnFinishStep .org 0x8064218 ; StartTriggeredGroundEffects -ldr r7, =(StartTriggeredGroundEffects | 1) -bx r7 -.pool +set_function_hook r7, StartTriggeredGroundEffects +; Update field effect script to use new FldEff_Shadow. .org 0x81D9C46 .byte 0x3 .word (FldEff_Shadow_ | 1 ) +; Nop out all assignments to objEvent->hasShadow by jumping movements. + ; Jump 2 @NopShadowFlagSetting 0x80613d4 @NopShadowFlagSetting 0x806142c @@ -51,7 +47,7 @@ bx r7 @NopShadowFlagSetting 0x80623cc @NopShadowFlagSetting 0x8062424 -; Mixed JumpInPlace +; Mixed direction JumpInPlace @NopShadowFlagSetting 0x806247c @NopShadowFlagSetting 0x80624d4 @NopShadowFlagSetting 0x806252c @@ -75,9 +71,11 @@ bx r7 @NopShadowFlagSetting 0x8062f6c @NopShadowFlagSetting 0x8062fc4 +; Disable shadows till player sprite reaches the ground. .org 0x839F454 .word (FlyInFieldEffect_BirdSwoopDown | 1) +; Update all 4 sprite callbacks. .org 0x08374560 + 0x14 .word (UpdateShadowFieldEffect_ | 1) @@ -90,20 +88,15 @@ bx r7 .org 0x083745a8 + 0x14 .word (UpdateShadowFieldEffect_ | 1) +; Patch weather functions to use Weather_SetBlendCoeff. .org 0x807cae8 -ldr r7, = (None_InitVars | 1) -bx r7 -.pool +set_function_hook r7, None_InitVars .org 0x807df9c -ldr r0, = (Sunny_InitVars | 1) -bx r0 -.pool +set_function_hook r0, Sunny_InitVars .org 0x8080430 -ldr r7, =(Shade_InitVars | 1) -bx r7 -.pool +set_function_hook r7, Shade_InitVars .org 0x807df24 mov r0, #0x8 diff --git a/scripts/predefs/common.asm b/scripts/predefs/common.asm new file mode 100644 index 0000000..cc18367 --- /dev/null +++ b/scripts/predefs/common.asm @@ -0,0 +1,25 @@ +; Set a bl instruction to two nops +.macro set_nop_bl, p +.org p +.area 0x4, 0x0 +nop +nop +.endarea +.endmacro + +; Set a 2 byte instruction to a nop +.macro set_nop, p +.org p +.area 0x2, 0x0 +nop +.endarea +.endmacro + +; Set a long call hook with bx +.macro set_function_hook, reg, func +.area 0x8, 0x0 +ldr reg, =(func | 1) +bx reg +.pool +.endarea +.endmacro diff --git a/scripts/predefs/gba.asm b/scripts/predefs/gba.asm new file mode 100644 index 0000000..0c20a6a --- /dev/null +++ b/scripts/predefs/gba.asm @@ -0,0 +1,3 @@ +.macro gba_color, rv, gv, bv +.halfword (rv | (gv << 5) | (bv << 10)) +.endmacro \ No newline at end of file diff --git a/scripts/common.asm b/scripts/predefs/pokemon_data.asm similarity index 76% rename from scripts/common.asm rename to scripts/predefs/pokemon_data.asm index 997f804..2fc0c6b 100644 --- a/scripts/common.asm +++ b/scripts/predefs/pokemon_data.asm @@ -1,21 +1,12 @@ -; Set a bl instruction to two nops -.macro set_nop_bl, p -.org p -.area 0x4, 0x0 -nop -nop -.endarea -.endmacro - -; Set a 2 byte instruction to a nop -.macro set_nop, p -.org p +; Stats-related +.macro replace_poke_types, i, t1, t2 +.org 0x81fec18 + (0x1c * i) + 6 .area 0x2, 0x0 -nop +.byte t1, t2 .endarea .endmacro -; Pokemon Definition +; GFX-related .macro set_poke_front_gfx, i, p .org 0x81e8354 + 8 * i .word p diff --git a/scripts/ps_split.asm b/scripts/ps_split.asm index e428239..983407a 100644 --- a/scripts/ps_split.asm +++ b/scripts/ps_split.asm @@ -2,8 +2,6 @@ ; Hook new function .org 0x803ba2c .area 0x803c348 - 0x803ba2c, 0xFE -ldr r4, =CalculateBaseDamage | 1 -bx r4 -.pool +set_function_hook r4, CalculateBaseDamage .endarea .endif diff --git a/scripts/reusable_tms.asm b/scripts/reusable_tms.asm index 013af17..a9fb585 100644 --- a/scripts/reusable_tms.asm +++ b/scripts/reusable_tms.asm @@ -2,9 +2,7 @@ ; Mark TMs as important .org 0x80a9a08 .area 0x1C, 0xFE -ldr r3, =ItemId_GetImportance | 1 -bx r3 -.pool +set_function_hook r3, ItemId_GetImportance .endarea ; Nop out the TM removeitem command @@ -13,8 +11,6 @@ set_nop_bl 0x806f21c ; Hook the TM menu's print callback .org 0x80A4548 .area 0x1B4, 0xFE -ldr r3, =Menu_PrintTMHM | 1 -bx r3 -.pool +set_function_hook r3, Menu_PrintTMHM .endarea .endif diff --git a/scripts/summary_screen.asm b/scripts/summary_screen.asm index b5b64eb..4015b2d 100644 --- a/scripts/summary_screen.asm +++ b/scripts/summary_screen.asm @@ -2,8 +2,6 @@ ; Hook Summary Screen's change page function .org 0x809F284 .area 0x8C, 0xFF -ldr r5, =ChangeSummaryPokemonNormal | 1 -bx r5 -.pool +set_function_hook r5, ChangeSummaryPokemonNormal .endarea .endif diff --git a/src/calculate_dmg.c b/src/calculate_dmg.c index 6978aac..c4a7308 100644 --- a/src/calculate_dmg.c +++ b/src/calculate_dmg.c @@ -24,8 +24,8 @@ ({ \ if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) \ { \ - if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) && gTrainerBattleOpponent != SECRET_BASE_OPPONENT && \ - FlagGet(FLAG_BADGE0##badge##_GET) && GetBattlerSide(bank) == B_SIDE_PLAYER) \ + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) && gTrainerBattleOpponent != SECRET_BASE_OPPONENT \ + && FlagGet(FLAG_BADGE0##badge##_GET) && GetBattlerSide(bank) == B_SIDE_PLAYER) \ (stat) = (110 * (stat)) / 100; \ } \ }) @@ -107,8 +107,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de spAttack *= 2; if (defenderHoldEffect == HOLD_EFFECT_METAL_POWDER && defender->species == SPECIES_DITTO) defense *= 2; - if (attackerHoldEffect == HOLD_EFFECT_THICK_CLUB && - (attacker->species == SPECIES_CUBONE || attacker->species == SPECIES_MAROWAK)) + if (attackerHoldEffect == HOLD_EFFECT_THICK_CLUB + && (attacker->species == SPECIES_CUBONE || attacker->species == SPECIES_MAROWAK)) attack *= 2; if (defender->ability == ABILITY_THICK_FAT && (type == TYPE_FIRE || type == TYPE_ICE)) gBattleMovePower /= 2; @@ -225,8 +225,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de damage /= 2; // are effects of weather negated with cloud nine or air lock - if (!AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_CLOUD_NINE, 0, 0) && - !AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_AIR_LOCK, 0, 0)) + if (!AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_CLOUD_NINE, 0, 0) + && !AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_AIR_LOCK, 0, 0)) { if (gBattleWeather & WEATHER_RAIN_TEMPORARY) { @@ -242,8 +242,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de } // any weather except sun weakens solar beam - if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL)) && - gCurrentMove == MOVE_SOLAR_BEAM) + if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL)) + && gCurrentMove == MOVE_SOLAR_BEAM) damage /= 2; // sunny diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 47ffedd..e200a0e 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1,13 +1,13 @@ #include "types.h" #include "event_object_movement.h" -#include "fieldmap.h" -#include "sprite.h" +#include "field_effect_helpers.h" #include "field_weather.h" +#include "fieldmap.h" #include "metatile_behavior.h" -#include "field_effect_helpers.h" +#include "sprite.h" #include "constants/field_effects.h" -#include "constants/weather.h" #include "constants/gba.h" +#include "constants/weather.h" static bool8 IsSuitableWeatherForShadow(void); @@ -32,18 +32,18 @@ void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct Sprite * GroundEffect_ShortGrass, GroundEffect_HotSprings, GroundEffect_Seaweed, - GroundEffect_Shadow + GroundEffect_Shadow, }; static bool8 IsSuitableWeatherForShadow(void) { switch (gWeatherPtr->currWeather) { - case WEATHER_NONE: - case WEATHER_SUNNY: - case WEATHER_SHADE: - case WEATHER_CLOUDS: - return TRUE; + case WEATHER_NONE: + case WEATHER_SUNNY: + case WEATHER_SHADE: + case WEATHER_CLOUDS: + return TRUE; } return FALSE; @@ -51,15 +51,13 @@ static bool8 IsSuitableWeatherForShadow(void) static void GetGroundEffectFlags_Shadow(struct ObjectEvent *objEvent, u32 *flags) { - if (!IsSuitableWeatherForShadow() - || MetatileBehavior_IsPokeGrass(objEvent->currentMetatileBehavior) + if (!IsSuitableWeatherForShadow() || MetatileBehavior_IsPokeGrass(objEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objEvent->previousMetatileBehavior) || MetatileBehavior_IsReflective(objEvent->currentMetatileBehavior) || MetatileBehavior_IsReflective(objEvent->previousMetatileBehavior) - || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior) - || objEvent->inSandPile || objEvent->inHotSprings || objEvent->inShallowFlowingWater - || objEvent->inanimate) + || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior) || objEvent->inSandPile + || objEvent->inHotSprings || objEvent->inShallowFlowingWater || objEvent->inanimate) { objEvent->hasShadow = FALSE; } @@ -77,7 +75,8 @@ void GroundEffect_Shadow(struct ObjectEvent *objEvent, struct Sprite *sprite) { (void)sprite; // StartFieldEffectForObjectEvent(FLDEFF_SHADOW, objEvent); - ObjectEventGetLocalIdAndMap(objEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); + ObjectEventGetLocalIdAndMap( + objEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); FldEff_Shadow_(); } diff --git a/src/field_effect.c b/src/field_effect.c index f6917b8..baea439 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,6 +1,6 @@ #include "types.h" -#include "event_object_movement.h" #include "field_effect.h" +#include "event_object_movement.h" #include "field_player_avatar.h" #include "task.h" diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index afa6182..08312a7 100644 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -1,9 +1,9 @@ #include "types.h" -#include "sprite.h" -#include "event_object_movement.h" #include "field_effect_helpers.h" -#include "metatile_behavior.h" +#include "event_object_movement.h" #include "fieldmap.h" +#include "metatile_behavior.h" +#include "sprite.h" #include "constants/field_effects.h" // TODO: Replace this function with a proper one @@ -26,10 +26,12 @@ u32 FldEff_Shadow_(void) const struct ObjectEventGraphicsInfo *graphicsInfo; u8 spriteId; - objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + objectEventId = + GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[gShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94); - + spriteId = CreateSpriteAtEnd( + gFieldEffectObjectTemplatePointers[gShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94); + if (spriteId != MAX_SPRITES) { gSprites[spriteId].coordOffsetEnabled = TRUE; diff --git a/src/pokemon.c b/src/pokemon.c index c4d5a86..9294c41 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -13,8 +13,8 @@ bool8 CheckIfMonCanUseHM(struct Pokemon *mon, u16 hm) if (!species || species == SPECIES_EGG) return FALSE; - if ((CheckBagHasItem(hm, 1) && CanMonLearnTMHM(mon, hm - ITEM_TM01_FOCUS_PUNCH)) || - (MonKnowsMove(mon, ItemIdToBattleMoveId(hm)) == TRUE)) + if ((CheckBagHasItem(hm, 1) && CanMonLearnTMHM(mon, hm - ITEM_TM01_FOCUS_PUNCH)) + || (MonKnowsMove(mon, ItemIdToBattleMoveId(hm)) == TRUE)) return TRUE; return FALSE; @@ -39,8 +39,8 @@ bool8 CheckIfPartyCanUseHM(void) if (!species || species == SPECIES_EGG) return FALSE; - if ((CanMonLearnTMHM(&gPlayerParty[i], tm - ITEM_TM01_FOCUS_PUNCH)) || - (MonKnowsMove(&gPlayerParty[i], ItemIdToBattleMoveId(tm)) == TRUE)) + if ((CanMonLearnTMHM(&gPlayerParty[i], tm - ITEM_TM01_FOCUS_PUNCH)) + || (MonKnowsMove(&gPlayerParty[i], ItemIdToBattleMoveId(tm)) == TRUE)) { gSpecialVar_Result = i; gSpecialVar_0x8004 = species; diff --git a/src/save_menu_util.c b/src/save_menu_util.c index d4cc0e6..14c5b92 100644 --- a/src/save_menu_util.c +++ b/src/save_menu_util.c @@ -1,8 +1,8 @@ #include "types.h" +#include "fieldmap.h" #include "menu.h" -#include "string_util.h" #include "save_time_util.h" -#include "fieldmap.h" +#include "string_util.h" #include "text.h" void PrintSavePlayerName(s16 x, s16 y)