diff --git a/CHANGES b/CHANGES index 4713fe88..7b81e757 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +Refresh 15 (mostly a hotfix for RSP microcode selection) + +1.) Renamed frame_buffer funcs and _ZBUFFER (#1184) +2.) RSP Microcode Hotfix (#1183) +3.) Label osSetTimer.c (#1182) +4.) Fix styling (#1177) +5.) Rename all `FrameBuffer` variants to `Framebuffer` (#1176) +6.) Remove (WIP) from sh. +7.) Allow both archives and ELF objects to be patched (#1127) + Refresh 14 1.) Label whomp and some object fields (#1174) diff --git a/README.md b/README.md index 5bd36006..aee71d4f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A prior copy of the game is required to extract the assets. 1. Install prerequisites: `sudo apt install -y build-essential git binutils-mips-linux-gnu python3` 2. Clone the repo from within Linux: `git clone https://github.com/n64decomp/sm64.git` -3. Place a Super Mario 64 ROM called `baserom..z64` into the project folder for asset extraction, where `VERSION` can be `us`, `jp`, or `eu`. +3. Place a Super Mario 64 ROM called `baserom..z64` into the project folder for asset extraction, where `VERSION` can be `us`, `jp`, `eu`, or `sh`. 4. Run `make` to build. Qualify the version through `make VERSION=`. Add `-j4` to improve build speed (hardware dependent). Ensure the repo path length does not exceed 255 characters. Long path names result in build errors. @@ -79,7 +79,7 @@ You may also use [Docker](#docker-installation) to handle installing an image wi #### Step 2: Copy baserom(s) for asset extraction -For each version (jp/us/eu) for which you want to build a ROM, put an existing ROM at +For each version (jp/us/eu/sh) for which you want to build a ROM, put an existing ROM at `./baserom..z64` for asset extraction. ##### Step 3: Build the ROM @@ -116,7 +116,7 @@ brew install capstone coreutils make pkg-config tehzz/n64-dev/mips64-elf-binutil #### Step 2: Copy baserom(s) for asset extraction -For each version (jp/us/eu) for which you want to build a ROM, put an existing ROM at +For each version (jp/us/eu/sh) for which you want to build a ROM, put an existing ROM at `./baserom..z64` for asset extraction. ##### Step 3: Build the ROM diff --git a/actors/group0.h b/actors/group0.h index 44f8b05d..62387f20 100644 --- a/actors/group0.h +++ b/actors/group0.h @@ -236,7 +236,7 @@ extern const Gfx mario_right_hand_cap_bottom_dl[]; extern const Gfx mario_right_hand_cap_dl[]; extern const Gfx mario_right_hand_cap_wings_half_1_dl[]; extern const Gfx mario_right_hand_cap_wings_half_2_dl[]; -extern const Gfx mario_right_hand_cap_wings_intial_dl[]; +extern const Gfx mario_right_hand_cap_wings_initial_dl[]; extern const Gfx mario_right_hand_cap_wings_end_dl[]; extern const Gfx mario_right_hand_cap[]; extern const Gfx mario_right_hand_cap_wings[]; @@ -250,7 +250,7 @@ extern const Gfx mario_cap_unused_base_bottom_dl[]; extern const Gfx mario_cap_unused_base_dl[]; extern const Gfx mario_wings_half_1_unused_dl[]; extern const Gfx mario_wings_half_2_unused_dl[]; -extern const Gfx mario_cap_wings_unused_intial_dl[]; +extern const Gfx mario_cap_wings_unused_initial_dl[]; extern const Gfx mario_cap_wings_unused_end_dl[]; extern const Gfx mario_cap_unused_dl[]; extern const Gfx mario_metal_cap_unused_dl[]; diff --git a/actors/mario/model.inc.c b/actors/mario/model.inc.c index 191d5332..e5d632e1 100644 --- a/actors/mario/model.inc.c +++ b/actors/mario/model.inc.c @@ -6060,7 +6060,7 @@ const Gfx mario_right_hand_cap_wings_half_2_dl[] = { }; // 0x0401B0E0 - 0x0401B138 -const Gfx mario_right_hand_cap_wings_intial_dl[] = { +const Gfx mario_right_hand_cap_wings_initial_dl[] = { gsDPPipeSync(), gsDPSetCombineMode(G_CC_MODULATERGBFADEA, G_CC_MODULATERGBFADEA), gsSPClearGeometryMode(G_CULL_BACK | G_SHADING_SMOOTH), @@ -6104,7 +6104,7 @@ const Gfx mario_right_hand_cap[] = { // 0x0401B1D8 - 0x0401B230 const Gfx mario_right_hand_cap_wings[] = { - gsSPDisplayList(mario_right_hand_cap_wings_intial_dl), + gsSPDisplayList(mario_right_hand_cap_wings_initial_dl), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, mario_texture_wings_half_1), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), @@ -6132,7 +6132,7 @@ const Gfx mario_metal_right_hand_cap_shared_dl[] = { // 0x0401B278 - 0x0401B2D0 const Gfx mario_metal_right_hand_cap_shared_dl_wings[] = { - gsSPDisplayList(mario_right_hand_cap_wings_intial_dl), + gsSPDisplayList(mario_right_hand_cap_wings_initial_dl), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, mario_texture_metal_wings_half_1), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), @@ -6590,7 +6590,7 @@ const Gfx mario_wings_half_2_unused_dl[] = { }; // 0x0401C6D8 - 0x0401C730 -const Gfx mario_cap_wings_unused_intial_dl[] = { +const Gfx mario_cap_wings_unused_initial_dl[] = { gsDPPipeSync(), gsDPSetCombineMode(G_CC_MODULATERGBA, G_CC_MODULATERGBA), gsSPClearGeometryMode(G_CULL_BACK | G_SHADING_SMOOTH), @@ -6656,7 +6656,7 @@ const Gfx mario_metal_cap_unused_dl[] = { // 0x0401C890 - 0x0401C8E8 # Unreferenced, unused like the duplicated cap, same case const Gfx mario_cap_wings_unused[] = { - gsSPDisplayList(mario_cap_wings_unused_intial_dl), + gsSPDisplayList(mario_cap_wings_unused_initial_dl), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, mario_texture_wings_half_1), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), @@ -6671,7 +6671,7 @@ const Gfx mario_cap_wings_unused[] = { // 0x0401C8E8 - 0x0401C940 # Unreferenced, unused like the duplicated cap, same case const Gfx mario_metal_cap_wings_unused[] = { - gsSPDisplayList(mario_cap_wings_unused_intial_dl), + gsSPDisplayList(mario_cap_wings_unused_initial_dl), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, mario_texture_metal_wings_half_1), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), diff --git a/bin/segment2.c b/bin/segment2.c index 35f0a130..ea305277 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2097,13 +2097,13 @@ const Gfx dl_hud_img_begin[] = { gsDPSetTexturePersp(G_TP_NONE), gsDPSetAlphaCompare(G_AC_THRESHOLD), gsDPSetBlendColor(255, 255, 255, 255), -#if defined(VERSION_EU) || defined(VERSION_SH) +#if defined(VERSION_JP) || defined(VERSION_US) + gsDPSetRenderMode(G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2), +#else gsDPSetRenderMode(G_RM_NOOP, G_RM_NOOP2), #endif #ifdef VERSION_EU gsDPSetTextureFilter(G_TF_POINT), -#elif defined(VERSION_JP) || defined(VERSION_US) - gsDPSetRenderMode(G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2), #endif gsSPEndDisplayList(), }; diff --git a/data/behavior_data.c b/data/behavior_data.c index 379fb2af..e9234e53 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -874,7 +874,7 @@ const BehaviorScript bhvMrIBlueCoin[] = { OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), BILLBOARD(), SET_INT(oIntangibleTimer, 0), - SET_FLOAT(oMrIUnk110, 20), + SET_FLOAT(oCoinUnk110, 20), SET_INT(oAnimState, -1), SET_OBJ_PHYSICS(/*Wall hitbox radius*/ 30, /*Gravity*/ -400, /*Bounciness*/ -70, /*Drag strength*/ 1000, /*Friction*/ 1000, /*Buoyancy*/ 200, /*Unused*/ 0, 0), CALL_NATIVE(bhv_coin_init), diff --git a/include/config.h b/include/config.h index a9f685ea..044b0694 100644 --- a/include/config.h +++ b/include/config.h @@ -24,7 +24,7 @@ #define BUGFIX_STAR_BOWSER_KEY (0 || VERSION_US || VERSION_EU || VERSION_SH) /// Fixes bug that enables Mario in time stop even if is not ready to speak #define BUGFIX_DIALOG_TIME_STOP (0 || VERSION_US || VERSION_EU || VERSION_SH) -/// Fixes bug that causes Mario to still collide with Bowser in BITS after his defeat +/// Fixes bug that causes Mario to still collide with Bowser in BitS after his defeat #define BUGFIX_BOWSER_COLLIDE_BITS_DEAD (0 || VERSION_US || VERSION_EU || VERSION_SH) /// Fixes bug where Bowser wouldn't reset his speed when fallen off (and adds missing checks) #define BUGFIX_BOWSER_FALLEN_OFF_STAGE (0 || VERSION_US || VERSION_EU || VERSION_SH) diff --git a/include/course_table.h b/include/course_table.h index ec2d4296..c8963274 100644 --- a/include/course_table.h +++ b/include/course_table.h @@ -12,8 +12,7 @@ #define DEFINE_BONUS_COURSE(courseenum, _1) courseenum, -enum CourseNum -{ +enum CourseNum { #include "levels/course_defines.h" COURSE_END, // To mark end + 1 for marking max and count. // TODO: clean this up. This is still bad. Which @@ -27,6 +26,7 @@ enum CourseNum #undef DEFINE_COURSES_END #undef DEFINE_BONUS_COURSE -#define COURSE_IS_MAIN_COURSE(cmd) (cmd >= COURSE_MIN && cmd <= COURSE_STAGES_MAX) +#define COURSE_IS_MAIN_COURSE(cmd) ((cmd) >= COURSE_MIN && (cmd) <= COURSE_STAGES_MAX) +#define COURSE_NUM_TO_INDEX(cmd) ((cmd) - 1) #endif // COURSE_TABLE_H diff --git a/include/level_table.h b/include/level_table.h index e3062c49..b0c2c633 100644 --- a/include/level_table.h +++ b/include/level_table.h @@ -7,8 +7,7 @@ #define STUB_LEVEL(_0, levelenum, _2, _3, _4, _5, _6, _7, _8) levelenum, #define DEFINE_LEVEL(_0, levelenum, _2, _3, _4, _5, _6, _7, _8, _9, _10) levelenum, -enum LevelNum -{ +enum LevelNum { LEVEL_NONE, #include "levels/level_defines.h" LEVEL_COUNT, diff --git a/include/macro_presets.h b/include/macro_presets.h index e96c7b75..38b1eb69 100644 --- a/include/macro_presets.h +++ b/include/macro_presets.h @@ -5,8 +5,7 @@ #include "behavior_data.h" #include "model_ids.h" -struct MacroPreset -{ +struct MacroPreset { /*0x00*/ const BehaviorScript *behavior; /*0x04*/ s16 model; /*0x06*/ s16 param; diff --git a/include/mario_animation_ids.h b/include/mario_animation_ids.h index 1d22d3d1..954ddb04 100644 --- a/include/mario_animation_ids.h +++ b/include/mario_animation_ids.h @@ -3,8 +3,7 @@ /* Mario Animation IDs */ -enum MarioAnimID -{ +enum MarioAnimID { /* 0x00 */ MARIO_ANIM_SLOW_LEDGE_GRAB, /* 0x01 */ MARIO_ANIM_FALL_OVER_BACKWARDS, /* 0x02 */ MARIO_ANIM_BACKWARD_AIR_KB, @@ -196,7 +195,7 @@ enum MarioAnimID /* 0xBC */ MARIO_ANIM_TURNING_PART1, /* 0xBD */ MARIO_ANIM_TURNING_PART2, /* 0xBE */ MARIO_ANIM_SLIDEFLIP_LAND, - /* 0XBF */ MARIO_ANIM_SLIDEFLIP, + /* 0xBF */ MARIO_ANIM_SLIDEFLIP, /* 0xC0 */ MARIO_ANIM_TRIPLE_JUMP_LAND, /* 0xC1 */ MARIO_ANIM_TRIPLE_JUMP, /* 0xC2 */ MARIO_ANIM_FIRST_PERSON, diff --git a/include/mario_geo_switch_case_ids.h b/include/mario_geo_switch_case_ids.h index 007d23b0..d824e83d 100644 --- a/include/mario_geo_switch_case_ids.h +++ b/include/mario_geo_switch_case_ids.h @@ -3,8 +3,7 @@ /* Mario Geo-Switch-Case IDs */ -enum MarioEyesGSCId -{ +enum MarioEyesGSCId { /*0x00*/ MARIO_EYES_BLINK, /*0x01*/ MARIO_EYES_OPEN, /*0x02*/ MARIO_EYES_HALF_CLOSED, @@ -16,8 +15,7 @@ enum MarioEyesGSCId /*0x08*/ MARIO_EYES_DEAD }; -enum MarioHandGSCId -{ +enum MarioHandGSCId { /*0x00*/ MARIO_HAND_FISTS, /*0x01*/ MARIO_HAND_OPEN, /*0x02*/ MARIO_HAND_PEACE_SIGN, @@ -26,16 +24,14 @@ enum MarioHandGSCId /*0x05*/ MARIO_HAND_RIGHT_OPEN }; -enum MarioCapGSCId -{ +enum MarioCapGSCId { /*0x00*/ MARIO_HAS_DEFAULT_CAP_ON, /*0x01*/ MARIO_HAS_DEFAULT_CAP_OFF, /*0x02*/ MARIO_HAS_WING_CAP_ON, /*0x03*/ MARIO_HAS_WING_CAP_OFF // unused }; -enum MarioGrabPosGSCId -{ +enum MarioGrabPosGSCId { /*0x00*/ GRAB_POS_NULL, /*0x01*/ GRAB_POS_LIGHT_OBJ, /*0x02*/ GRAB_POS_HEAVY_OBJ, diff --git a/include/model_ids.h b/include/model_ids.h index 3e7c8845..c51b0b23 100644 --- a/include/model_ids.h +++ b/include/model_ids.h @@ -385,7 +385,7 @@ // group 9 #define MODEL_BOO 0x54 // boo_geo -#define MODEL_BETA_BOO_KEY 0x55 // small_key_geo +#define MODEL_BETA_BOO_KEY 0x55 // small_key_geo #define MODEL_HAUNTED_CHAIR 0x56 // haunted_chair_geo #define MODEL_MAD_PIANO 0x57 // mad_piano_geo #define MODEL_BOOKEND_PART 0x58 // bookend_part_geo @@ -562,7 +562,7 @@ #define MODEL_PEACH 0xDE // peach_geo #define MODEL_CHUCKYA 0xDF // chuckya_geo #define MODEL_WHITE_PUFF 0xE0 // white_puff_geo -#define MODEL_TRAJECTORY_MARKER_BALL 0xE1 // bowling_ball_track_geo - duplicate used in SSL Pyramid small sized and as a track ball +#define MODEL_TRAJECTORY_MARKER_BALL 0xE1 // bowling_ball_track_geo - duplicate used in SSL Pyramid small sized and as a track ball // Menu Models (overwrites Level Geometry IDs) #define MODEL_MAIN_MENU_MARIO_SAVE_BUTTON MODEL_LEVEL_GEOMETRY_03 // main_menu_geo_0001D0 diff --git a/include/object_constants.h b/include/object_constants.h index 76664b23..16dfe90c 100644 --- a/include/object_constants.h +++ b/include/object_constants.h @@ -47,9 +47,9 @@ #define OBJ_FLAG_30 (1 << 30) // 0x40000000 /* oHeldState */ -#define HELD_FREE 0 -#define HELD_HELD 1 -#define HELD_THROWN 2 +#define HELD_FREE 0 +#define HELD_HELD 1 +#define HELD_THROWN 2 #define HELD_DROPPED 3 /* oDialogState */ @@ -115,12 +115,12 @@ #define ACTIVE_PARTICLE_TRIANGLE (1 << 19) // 0x00080000 /* oAction */ -#define OBJ_ACT_LAVA_DEATH 100 +#define OBJ_ACT_LAVA_DEATH 100 #define OBJ_ACT_DEATH_PLANE_DEATH 101 #define OBJ_ACT_HORIZONTAL_KNOCKBACK 100 -#define OBJ_ACT_VERTICAL_KNOCKBACK 101 -#define OBJ_ACT_SQUISHED 102 +#define OBJ_ACT_VERTICAL_KNOCKBACK 101 +#define OBJ_ACT_SQUISHED 102 /* gTTCSpeedSetting */ #define TTC_SPEED_SLOW 0 @@ -130,67 +130,73 @@ /* Bob-omb */ /* oBehParams2ndByte */ - #define BOBOMB_BP_STYPE_GENERIC 0 + #define BOBOMB_BP_STYPE_GENERIC 0 #define BOBOMB_BP_STYPE_STATIONARY 1 + /* oAction */ - #define BOBOMB_ACT_PATROL 0 - #define BOBOMB_ACT_LAUNCHED 1 - #define BOBOMB_ACT_CHASE_MARIO 2 - #define BOBOMB_ACT_EXPLODE 3 - #define BOBOMB_ACT_LAVA_DEATH 100 + #define BOBOMB_ACT_PATROL 0 + #define BOBOMB_ACT_LAUNCHED 1 + #define BOBOMB_ACT_CHASE_MARIO 2 + #define BOBOMB_ACT_EXPLODE 3 + #define BOBOMB_ACT_LAVA_DEATH 100 #define BOBOMB_ACT_DEATH_PLANE_DEATH 101 /* Hidden Blue Coin */ /* oAction */ #define HIDDEN_BLUE_COIN_ACT_INACTIVE 0 - #define HIDDEN_BLUE_COIN_ACT_WAITING 1 - #define HIDDEN_BLUE_COIN_ACT_ACTIVE 2 + #define HIDDEN_BLUE_COIN_ACT_WAITING 1 + #define HIDDEN_BLUE_COIN_ACT_ACTIVE 2 /* Blue Coin Switch */ /* oAction */ - #define BLUE_COIN_SWITCH_ACT_IDLE 0 + #define BLUE_COIN_SWITCH_ACT_IDLE 0 #define BLUE_COIN_SWITCH_ACT_RECEDING 1 - #define BLUE_COIN_SWITCH_ACT_TICKING 2 + #define BLUE_COIN_SWITCH_ACT_TICKING 2 /* Moving Blue Coin */ /* oAction */ - #define MOV_BCOIN_ACT_STILL 0 + #define MOV_BCOIN_ACT_STILL 0 #define MOV_BCOIN_ACT_MOVING 1 /* Moving Yellow Coin */ /* oAction */ - #define MOV_YCOIN_ACT_IDLE 0 - #define MOV_YCOIN_ACT_BLINKING 1 - #define MOV_YCOIN_ACT_LAVA_DEATH 100 + #define MOV_YCOIN_ACT_IDLE 0 + #define MOV_YCOIN_ACT_BLINKING 1 + #define MOV_YCOIN_ACT_LAVA_DEATH 100 #define MOV_YCOIN_ACT_DEATH_PLANE_DEATH 101 /* Bob-omb Buddy */ /* oBehParams2ndByte */ - #define BOBOMB_BUDDY_BP_STYPE_GENERIC 0 - #define BOBOMB_BUDDY_BP_STYPE_BOB_GRASS_KBB 1 + #define BOBOMB_BUDDY_BP_STYPE_GENERIC 0 + #define BOBOMB_BUDDY_BP_STYPE_BOB_GRASS_KBB 1 #define BOBOMB_BUDDY_BP_STYPE_BOB_CANNON_KBB 2 - #define BOBOMB_BUDDY_BP_STYPE_BOB_GRASS 3 + #define BOBOMB_BUDDY_BP_STYPE_BOB_GRASS 3 + /* oAction */ - #define BOBOMB_BUDDY_ACT_IDLE 0 + #define BOBOMB_BUDDY_ACT_IDLE 0 #define BOBOMB_BUDDY_ACT_TURN_TO_TALK 2 - #define BOBOMB_BUDDY_ACT_TALK 3 + #define BOBOMB_BUDDY_ACT_TALK 3 + /* oBobombBuddyRole */ #define BOBOMB_BUDDY_ROLE_ADVICE 0 #define BOBOMB_BUDDY_ROLE_CANNON 1 + /* oBobombBuddyCannonStatus */ - #define BOBOMB_BUDDY_CANNON_UNOPENED 0 - #define BOBOMB_BUDDY_CANNON_OPENING 1 - #define BOBOMB_BUDDY_CANNON_OPENED 2 + #define BOBOMB_BUDDY_CANNON_UNOPENED 0 + #define BOBOMB_BUDDY_CANNON_OPENING 1 + #define BOBOMB_BUDDY_CANNON_OPENED 2 #define BOBOMB_BUDDY_CANNON_STOP_TALKING 3 + /* oBobombBuddyHasTalkedToMario */ #define BOBOMB_BUDDY_HAS_NOT_TALKED 0 - #define BOBOMB_BUDDY_HAS_TALKED 2 + #define BOBOMB_BUDDY_HAS_TALKED 2 /* Bowser */ /* Tail oAction */ #define BOWSER_ACT_TAIL_DEFAULT 0 #define BOWSER_ACT_TAIL_THROWN 1 #define BOWSER_ACT_TAIL_TOUCHED_MARIO 2 + /* oAction */ #define BOWSER_ACT_DEFAULT 0 #define BOWSER_ACT_THROWN 1 @@ -212,6 +218,7 @@ #define BOWSER_ACT_QUICK_JUMP 17 #define BOWSER_ACT_UNUSED_SLOW_WALK 18 #define BOWSER_ACT_TILT_LAVA_PLATFORM 19 + /* Animations */ #define BOWSER_ANIM_STAND_UP 0 #define BOWSER_ANIM_STAND_UP_UNUSED 1 // slightly different @@ -240,25 +247,30 @@ #define BOWSER_ANIM_EDGE_STOP 24 #define BOWSER_ANIM_FLIP 25 #define BOWSER_ANIM_STAND_UP_FROM_FLIP 26 + /* oBehParams2ndByte */ #define BOWSER_BP_BITDW 0 #define BOWSER_BP_BITFS 1 #define BOWSER_BP_BITS 2 + /* oBowserCamAct */ #define BOWSER_CAM_ACT_IDLE 0 #define BOWSER_CAM_ACT_WALK 1 #define BOWSER_CAM_ACT_END 2 + /* oBowserStatus */ #define BOWSER_STATUS_ANGLE_MARIO (1 << 1) // 0x00000002 - #define BOWSER_STATUS_ANGLE_CENTRE (1 << 2) // 0x00000004 + #define BOWSER_STATUS_ANGLE_CENTER (1 << 2) // 0x00000004 #define BOWSER_STATUS_DIST_MARIO (1 << 3) // 0x00000008 - #define BOWSER_STATUS_DIST_CENTRE (1 << 4) // 0x00000010 + #define BOWSER_STATUS_DIST_CENTER (1 << 4) // 0x00000010 #define BOWSER_STATUS_BIG_JUMP (1 << 16) // 0x00010000 #define BOWSER_STATUS_FIRE_SKY (1 << 17) // 0x00020000 + /* oBowserGrabbedStatus */ #define BOWSER_GRAB_STATUS_NONE 0 #define BOWSER_GRAB_STATUS_GRABBED 1 #define BOWSER_GRAB_STATUS_HOLDING 2 + /* oSubAction */ #define BOWSER_SUB_ACT_DEAD_FLY_BACK 0 #define BOWSER_SUB_ACT_DEAD_BOUNCE 1 @@ -281,10 +293,10 @@ #define BOWSER_SUB_ACT_HIT_MINE_FALL 1 #define BOWSER_SUB_ACT_HIT_MINE_STOP 2 - #define BOWSER_SUB_ACT_JUMP_ON_STAGE_IDLE 0 - #define BOWSER_SUB_ACT_JUMP_ON_STAGE_START 1 - #define BOWSER_SUB_ACT_JUMP_ON_STAGE_LAND 2 - #define BOWSER_SUB_ACT_JUMP_ON_STAGE_STOP 3 + #define BOWSER_SUB_ACT_JUMP_ON_STAGE_IDLE 0 + #define BOWSER_SUB_ACT_JUMP_ON_STAGE_START 1 + #define BOWSER_SUB_ACT_JUMP_ON_STAGE_LAND 2 + #define BOWSER_SUB_ACT_JUMP_ON_STAGE_STOP 3 /* Bowser Bits Platform*/ /* oAction */ @@ -297,6 +309,7 @@ #define FISH_SPAWNER_ACT_SPAWN 0 #define FISH_SPAWNER_ACT_IDLE 1 #define FISH_SPAWNER_ACT_RESPAWN 2 + /* oBehParams2ndByte */ #define FISH_SPAWNER_BP_MANY_BLUE 0 #define FISH_SPAWNER_BP_FEW_BLUE 1 @@ -311,29 +324,29 @@ /* Blue_Fish */ /* oAction */ - #define BLUE_FISH_ACT_DIVE 0 - #define BLUE_FISH_ACT_TURN 1 - #define BLUE_FISH_ACT_ASCEND 2 + #define BLUE_FISH_ACT_DIVE 0 + #define BLUE_FISH_ACT_TURN 1 + #define BLUE_FISH_ACT_ASCEND 2 #define BLUE_FISH_ACT_TURN_BACK 3 /* oAction: bhv_blue_fish_spawn_loop */ - #define BLUE_FISH_ACT_SPAWN 0 - #define BLUE_FISH_ACT_ROOM 1 + #define BLUE_FISH_ACT_SPAWN 0 + #define BLUE_FISH_ACT_ROOM 1 #define BLUE_FISH_ACT_DUPLICATE 2 /* Cannon Trap Door */ /* oAction */ - #define CANNON_TRAP_DOOR_ACT_CLOSED 0 + #define CANNON_TRAP_DOOR_ACT_CLOSED 0 #define CANNON_TRAP_DOOR_ACT_CAM_ZOOM 1 - #define CANNON_TRAP_DOOR_ACT_OPENING 2 - #define CANNON_TRAP_DOOR_ACT_OPEN 3 + #define CANNON_TRAP_DOOR_ACT_OPENING 2 + #define CANNON_TRAP_DOOR_ACT_OPEN 3 /* Homing Amp */ /* oAction */ - #define HOMING_AMP_ACT_INACTIVE 0 - #define HOMING_AMP_ACT_APPEAR 1 - #define HOMING_AMP_ACT_CHASE 2 - #define HOMING_AMP_ACT_GIVE_UP 3 + #define HOMING_AMP_ACT_INACTIVE 0 + #define HOMING_AMP_ACT_APPEAR 1 + #define HOMING_AMP_ACT_CHASE 2 + #define HOMING_AMP_ACT_GIVE_UP 3 #define HOMING_AMP_ACT_ATTACK_COOLDOWN 4 /* Amp */ @@ -344,57 +357,60 @@ #define AMP_BP_ROT_RADIUS_0 3 /* oAction */ - #define AMP_ACT_IDLE 2 + #define AMP_ACT_IDLE 2 #define AMP_ACT_ATTACK_COOLDOWN 4 /* Butterfly */ /* oAction */ - #define BUTTERFLY_ACT_RESTING 0 + #define BUTTERFLY_ACT_RESTING 0 #define BUTTERFLY_ACT_FOLLOW_MARIO 1 - #define BUTTERFLY_ACT_RETURN_HOME 2 + #define BUTTERFLY_ACT_RETURN_HOME 2 /* Hoot */ /* oHootAvailability */ #define HOOT_AVAIL_ASLEEP_IN_TREE 0 - #define HOOT_AVAIL_WANTS_TO_TALK 1 - #define HOOT_AVAIL_READY_TO_FLY 2 + #define HOOT_AVAIL_WANTS_TO_TALK 1 + #define HOOT_AVAIL_READY_TO_FLY 2 + /* oAction */ #define HOOT_ACT_ASCENT 0 - #define HOOT_ACT_CARRY 1 - #define HOOT_ACT_TIRED 2 + #define HOOT_ACT_CARRY 1 + #define HOOT_ACT_TIRED 2 /* Bully (all variants) */ /* oBehParams2ndByte */ #define BULLY_BP_SIZE_SMALL 0 - #define BULLY_BP_SIZE_BIG 1 + #define BULLY_BP_SIZE_BIG 1 + /* oAction */ - #define BULLY_ACT_PATROL 0 - #define BULLY_ACT_CHASE_MARIO 1 - #define BULLY_ACT_KNOCKBACK 2 - #define BULLY_ACT_BACK_UP 3 - #define BULLY_ACT_INACTIVE 4 - #define BULLY_ACT_ACTIVATE_AND_FALL 5 - #define BULLY_ACT_LAVA_DEATH 100 + #define BULLY_ACT_PATROL 0 + #define BULLY_ACT_CHASE_MARIO 1 + #define BULLY_ACT_KNOCKBACK 2 + #define BULLY_ACT_BACK_UP 3 + #define BULLY_ACT_INACTIVE 4 + #define BULLY_ACT_ACTIVATE_AND_FALL 5 + #define BULLY_ACT_LAVA_DEATH 100 #define BULLY_ACT_DEATH_PLANE_DEATH 101 + /* oBullySubtype */ - #define BULLY_STYPE_GENERIC 0 - #define BULLY_STYPE_MINION 1 - #define BULLY_STYPE_CHILL 16 + #define BULLY_STYPE_GENERIC 0 + #define BULLY_STYPE_MINION 1 + #define BULLY_STYPE_CHILL 16 /* Water Ring (all variants) */ /* oAction */ #define WATER_RING_ACT_NOT_COLLECTED 0 - #define WATER_RING_ACT_COLLECTED 1 + #define WATER_RING_ACT_COLLECTED 1 /* Jet Stream Water Ring Spawner */ /* oAction */ - #define JS_RING_SPAWNER_ACT_ACTIVE 0 + #define JS_RING_SPAWNER_ACT_ACTIVE 0 #define JS_RING_SPAWNER_ACT_INACTIVE 1 /* Celebration Star */ /* oAction */ #define CELEB_STAR_ACT_SPIN_AROUND_MARIO 0 - #define CELEB_STAR_ACT_FACE_CAMERA 1 + #define CELEB_STAR_ACT_FACE_CAMERA 1 /* LLL Drawbridge */ /* oAction */ @@ -403,108 +419,110 @@ /* Bomp (both variants) */ /* oAction */ - #define BOMP_ACT_WAIT 0 + #define BOMP_ACT_WAIT 0 #define BOMP_ACT_POKE_OUT 1 - #define BOMP_ACT_EXTEND 2 - #define BOMP_ACT_RETRACT 3 + #define BOMP_ACT_EXTEND 2 + #define BOMP_ACT_RETRACT 3 /* WF Sliding Brick Platform */ /* oBehParams2ndByte */ #define WF_SLID_BRICK_PTFM_BP_MOV_VEL_10 1 #define WF_SLID_BRICK_PTFM_BP_MOV_VEL_15 2 #define WF_SLID_BRICK_PTFM_BP_MOV_VEL_20 3 + /* oAction */ - #define WF_SLID_BRICK_PTFM_ACT_WAIT 0 - #define WF_SLID_BRICK_PTFM_ACT_EXTEND 1 + #define WF_SLID_BRICK_PTFM_ACT_WAIT 0 + #define WF_SLID_BRICK_PTFM_ACT_EXTEND 1 #define WF_SLID_BRICK_PTFM_ACT_RETRACT 2 /* Fake Moneybag Coin */ /* oAction */ - #define FAKE_MONEYBAG_COIN_ACT_IDLE 0 + #define FAKE_MONEYBAG_COIN_ACT_IDLE 0 #define FAKE_MONEYBAG_COIN_ACT_TRANSFORM 1 /* Moneybag */ /* oAction */ - #define MONEYBAG_ACT_APPEAR 0 + #define MONEYBAG_ACT_APPEAR 0 #define MONEYBAG_ACT_UNUSED_APPEAR 1 - #define MONEYBAG_ACT_MOVE_AROUND 2 - #define MONEYBAG_ACT_RETURN_HOME 3 - #define MONEYBAG_ACT_DISAPPEAR 4 - #define MONEYBAG_ACT_DEATH 5 + #define MONEYBAG_ACT_MOVE_AROUND 2 + #define MONEYBAG_ACT_RETURN_HOME 3 + #define MONEYBAG_ACT_DISAPPEAR 4 + #define MONEYBAG_ACT_DEATH 5 + /* oMoneybagJumpState */ - #define MONEYBAG_JUMP_LANDING 0 - #define MONEYBAG_JUMP_PREPARE 1 - #define MONEYBAG_JUMP_JUMP 2 + #define MONEYBAG_JUMP_LANDING 0 + #define MONEYBAG_JUMP_PREPARE 1 + #define MONEYBAG_JUMP_JUMP 2 #define MONEYBAG_JUMP_JUMP_AND_BOUNCE 3 - #define MONEYBAG_JUMP_WALK_AROUND 4 - #define MONEYBAG_JUMP_WALK_HOME 5 + #define MONEYBAG_JUMP_WALK_AROUND 4 + #define MONEYBAG_JUMP_WALK_HOME 5 /* Bowling Ball */ /* oAction */ #define BBALL_ACT_INITIALIZE 0 - #define BBALL_ACT_ROLL 1 + #define BBALL_ACT_ROLL 1 /* Bowling Ball + Bowling Ball Spawner (all variants) */ /* oBehParams2ndByte */ #define BBALL_BP_STYPE_BOB_UPPER 0 - #define BBALL_BP_STYPE_TTM 1 + #define BBALL_BP_STYPE_TTM 1 #define BBALL_BP_STYPE_BOB_LOWER 2 #define BBALL_BP_STYPE_THI_LARGE 3 #define BBALL_BP_STYPE_THI_SMALL 4 /* Bowling Ball (Free) */ /* oAction */ - #define FREE_BBALL_ACT_IDLE 0 - #define FREE_BBALL_ACT_ROLL 1 + #define FREE_BBALL_ACT_IDLE 0 + #define FREE_BBALL_ACT_ROLL 1 #define FREE_BBALL_ACT_RESET 2 /* Beta Chest Lid */ /* oAction */ #define BETA_CHEST_ACT_IDLE_CLOSED 0 - #define BETA_CHEST_ACT_OPENING 1 - #define BETA_CHEST_ACT_IDLE_OPEN 2 + #define BETA_CHEST_ACT_OPENING 1 + #define BETA_CHEST_ACT_IDLE_OPEN 2 /* BBH Tilting Trap Platform */ /* oAction */ // Unused in original Japanese version - #define BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_ON 0 + #define BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_ON 0 #define BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_OFF 1 /* Boo */ /* oBooDeathStatus */ #define BOO_DEATH_STATUS_ALIVE 0 #define BOO_DEATH_STATUS_DYING 1 - #define BOO_DEATH_STATUS_DEAD 2 + #define BOO_DEATH_STATUS_DEAD 2 /* attackStatus */ - #define BOO_NOT_ATTACKED 0 - #define BOO_ATTACKED 1 - #define BOO_BOUNCED_ON -1 + #define BOO_NOT_ATTACKED 0 + #define BOO_ATTACKED 1 + #define BOO_BOUNCED_ON -1 /* Beta Boo Key */ /* oAction */ - #define BETA_BOO_KEY_ACT_IN_BOO 0 + #define BETA_BOO_KEY_ACT_IN_BOO 0 #define BETA_BOO_KEY_ACT_DROPPING 1 - #define BETA_BOO_KEY_ACT_DROPPED 2 + #define BETA_BOO_KEY_ACT_DROPPED 2 /* Boo Cage */ /* oAction */ - #define BOO_CAGE_ACT_IN_BOO 0 - #define BOO_CAGE_ACT_FALLING 1 - #define BOO_CAGE_ACT_ON_GROUND 2 + #define BOO_CAGE_ACT_IN_BOO 0 + #define BOO_CAGE_ACT_FALLING 1 + #define BOO_CAGE_ACT_ON_GROUND 2 #define BOO_CAGE_ACT_MARIO_JUMPING_IN 3 - #define BOO_CAGE_ACT_USELESS 4 + #define BOO_CAGE_ACT_USELESS 4 /* BBH Haunted Bookshelf */ /* oAction */ - #define HAUNTED_BOOKSHELF_ACT_IDLE 0 + #define HAUNTED_BOOKSHELF_ACT_IDLE 0 #define HAUNTED_BOOKSHELF_ACT_RECEDE 1 /* BBH Merry-Go-Round */ /* gMarioCurrentRoom */ #define BBH_NEAR_MERRY_GO_ROUND_ROOM 10 - #define BBH_DYNAMIC_SURFACE_ROOM 0 - #define BBH_OUTSIDE_ROOM 13 + #define BBH_DYNAMIC_SURFACE_ROOM 0 + #define BBH_OUTSIDE_ROOM 13 /* Coffin Spawner */ /* oAction */ @@ -520,71 +538,71 @@ /* WDW Arrow Lift */ /* oAction */ - #define ARROW_LIFT_ACT_IDLE 0 + #define ARROW_LIFT_ACT_IDLE 0 #define ARROW_LIFT_ACT_MOVING_AWAY 1 #define ARROW_LIFT_ACT_MOVING_BACK 2 /* status */ #define ARROW_LIFT_NOT_DONE_MOVING 0 - #define ARROW_LIFT_DONE_MOVING 1 + #define ARROW_LIFT_DONE_MOVING 1 /* Yoshi */ /* oAction */ - #define YOSHI_ACT_IDLE 0 - #define YOSHI_ACT_WALK 1 - #define YOSHI_ACT_TALK 2 - #define YOSHI_ACT_WALK_JUMP_OFF_ROOF 3 - #define YOSHI_ACT_FINISH_JUMPING_AND_DESPAWN 4 - #define YOSHI_ACT_GIVE_PRESENT 5 - #define YOSHI_ACT_CREDITS 10 + #define YOSHI_ACT_IDLE 0 + #define YOSHI_ACT_WALK 1 + #define YOSHI_ACT_TALK 2 + #define YOSHI_ACT_WALK_JUMP_OFF_ROOF 3 + #define YOSHI_ACT_FINISH_JUMPING_AND_DESPAWN 4 + #define YOSHI_ACT_GIVE_PRESENT 5 + #define YOSHI_ACT_CREDITS 10 /* Koopa */ /* oAction */ - #define KOOPA_UNSHELLED_ACT_RUN 0 - #define KOOPA_UNSHELLED_ACT_DIVE 1 - #define KOOPA_UNSHELLED_ACT_LYING 2 + #define KOOPA_UNSHELLED_ACT_RUN 0 + #define KOOPA_UNSHELLED_ACT_DIVE 1 + #define KOOPA_UNSHELLED_ACT_LYING 2 #define KOOPA_UNSHELLED_ACT_UNUSED3 3 - #define KOOPA_SHELLED_ACT_STOPPED 0 - #define KOOPA_SHELLED_ACT_WALK 1 + #define KOOPA_SHELLED_ACT_STOPPED 0 + #define KOOPA_SHELLED_ACT_WALK 1 #define KOOPA_SHELLED_ACT_RUN_FROM_MARIO 2 - #define KOOPA_SHELLED_ACT_LYING 3 - #define KOOPA_SHELLED_ACT_DIE 4 + #define KOOPA_SHELLED_ACT_LYING 3 + #define KOOPA_SHELLED_ACT_DIE 4 #define KOOPA_THE_QUICK_ACT_WAIT_BEFORE_RACE 0 - #define KOOPA_THE_QUICK_ACT_UNUSED1 1 - #define KOOPA_THE_QUICK_ACT_SHOW_INIT_TEXT 2 - #define KOOPA_THE_QUICK_ACT_RACE 3 - #define KOOPA_THE_QUICK_ACT_DECELERATE 4 - #define KOOPA_THE_QUICK_ACT_STOP 5 - #define KOOPA_THE_QUICK_ACT_AFTER_RACE 6 + #define KOOPA_THE_QUICK_ACT_UNUSED1 1 + #define KOOPA_THE_QUICK_ACT_SHOW_INIT_TEXT 2 + #define KOOPA_THE_QUICK_ACT_RACE 3 + #define KOOPA_THE_QUICK_ACT_DECELERATE 4 + #define KOOPA_THE_QUICK_ACT_STOP 5 + #define KOOPA_THE_QUICK_ACT_AFTER_RACE 6 /* oSubAction */ #define KOOPA_SHELLED_SUB_ACT_START_WALK 0 - #define KOOPA_SHELLED_SUB_ACT_WALK 1 - #define KOOPA_SHELLED_SUB_ACT_STOP_WALK 2 + #define KOOPA_SHELLED_SUB_ACT_WALK 1 + #define KOOPA_SHELLED_SUB_ACT_STOP_WALK 2 #define KOOPA_THE_QUICK_SUB_ACT_START_RUN 0 - #define KOOPA_THE_QUICK_SUB_ACT_RUN 1 - #define KOOPA_THE_QUICK_SUB_ACT_JUMP 2 + #define KOOPA_THE_QUICK_SUB_ACT_RUN 1 + #define KOOPA_THE_QUICK_SUB_ACT_JUMP 2 /* oKoopaTheQuickRaceIndex */ #define KOOPA_THE_QUICK_BOB_INDEX 0 #define KOOPA_THE_QUICK_THI_INDEX 1 /* oBehParams2ndByte */ - #define KOOPA_BP_UNSHELLED 0 - #define KOOPA_BP_NORMAL 1 + #define KOOPA_BP_UNSHELLED 0 + #define KOOPA_BP_NORMAL 1 #define KOOPA_BP_KOOPA_THE_QUICK_BASE 2 - #define KOOPA_BP_KOOPA_THE_QUICK_BOB (KOOPA_BP_KOOPA_THE_QUICK_BASE + KOOPA_THE_QUICK_BOB_INDEX) - #define KOOPA_BP_KOOPA_THE_QUICK_THI (KOOPA_BP_KOOPA_THE_QUICK_BASE + KOOPA_THE_QUICK_THI_INDEX) - #define KOOPA_BP_TINY 4 + #define KOOPA_BP_KOOPA_THE_QUICK_BOB (KOOPA_BP_KOOPA_THE_QUICK_BASE + KOOPA_THE_QUICK_BOB_INDEX) + #define KOOPA_BP_KOOPA_THE_QUICK_THI (KOOPA_BP_KOOPA_THE_QUICK_BASE + KOOPA_THE_QUICK_THI_INDEX) + #define KOOPA_BP_TINY 4 /* Pokey */ /* oAction */ #define POKEY_ACT_UNINITIALIZED 0 - #define POKEY_ACT_WANDER 1 - #define POKEY_ACT_UNLOAD_PARTS 2 + #define POKEY_ACT_WANDER 1 + #define POKEY_ACT_UNLOAD_PARTS 2 /* Swoop */ /* oAction */ @@ -593,48 +611,49 @@ /* Fly guy */ /* oAction */ - #define FLY_GUY_ACT_IDLE 0 + #define FLY_GUY_ACT_IDLE 0 #define FLY_GUY_ACT_APPROACH_MARIO 1 - #define FLY_GUY_ACT_LUNGE 2 - #define FLY_GUY_ACT_SHOOT_FIRE 3 + #define FLY_GUY_ACT_LUNGE 2 + #define FLY_GUY_ACT_SHOOT_FIRE 3 /* Goomba triplet spawner */ /* oBehParams2ndByte */ - #define GOOMBA_TRIPLET_SPAWNER_BP_SIZE_MASK 0x00000003 + #define GOOMBA_TRIPLET_SPAWNER_BP_SIZE_MASK 0x00000003 #define GOOMBA_TRIPLET_SPAWNER_BP_EXTRA_GOOMBAS_MASK 0x000000FC + /* oAction */ #define GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED 0 - #define GOOMBA_TRIPLET_SPAWNER_ACT_LOADED 1 + #define GOOMBA_TRIPLET_SPAWNER_ACT_LOADED 1 /* Goomba */ /* oBehParams2ndByte */ - #define GOOMBA_BP_SIZE_MASK 0x00000003 - #define GOOMBA_SIZE_REGULAR 0 - #define GOOMBA_SIZE_HUGE 1 - #define GOOMBA_SIZE_TINY 2 + #define GOOMBA_BP_SIZE_MASK 0x00000003 + #define GOOMBA_SIZE_REGULAR 0 + #define GOOMBA_SIZE_HUGE 1 + #define GOOMBA_SIZE_TINY 2 #define GOOMBA_BP_TRIPLET_FLAG_MASK 0x000000FC /* oAction */ - #define GOOMBA_ACT_WALK 0 + #define GOOMBA_ACT_WALK 0 #define GOOMBA_ACT_ATTACKED_MARIO 1 - #define GOOMBA_ACT_JUMP 2 + #define GOOMBA_ACT_JUMP 2 /* Chain chomp */ /* oAction */ #define CHAIN_CHOMP_ACT_UNINITIALIZED 0 - #define CHAIN_CHOMP_ACT_MOVE 1 - #define CHAIN_CHOMP_ACT_UNLOAD_CHAIN 2 + #define CHAIN_CHOMP_ACT_MOVE 1 + #define CHAIN_CHOMP_ACT_UNLOAD_CHAIN 2 /* oSubAction */ - #define CHAIN_CHOMP_SUB_ACT_TURN 0 + #define CHAIN_CHOMP_SUB_ACT_TURN 0 #define CHAIN_CHOMP_SUB_ACT_LUNGE 1 /* oChainChompReleaseStatus */ - #define CHAIN_CHOMP_NOT_RELEASED 0 + #define CHAIN_CHOMP_NOT_RELEASED 0 #define CHAIN_CHOMP_RELEASED_TRIGGER_CUTSCENE 1 - #define CHAIN_CHOMP_RELEASED_LUNGE_AROUND 2 - #define CHAIN_CHOMP_RELEASED_BREAK_GATE 3 - #define CHAIN_CHOMP_RELEASED_JUMP_AWAY 4 - #define CHAIN_CHOMP_RELEASED_END_CUTSCENE 5 + #define CHAIN_CHOMP_RELEASED_LUNGE_AROUND 2 + #define CHAIN_CHOMP_RELEASED_BREAK_GATE 3 + #define CHAIN_CHOMP_RELEASED_JUMP_AWAY 4 + #define CHAIN_CHOMP_RELEASED_END_CUTSCENE 5 /* Chain chomp chain part */ /* oBehParams2ndByte */ @@ -646,55 +665,55 @@ /* Wiggler */ /* oAction */ - #define WIGGLER_ACT_UNINITIALIZED 0 - #define WIGGLER_ACT_WALK 1 - #define WIGGLER_ACT_KNOCKBACK 2 - #define WIGGLER_ACT_JUMPED_ON 3 - #define WIGGLER_ACT_SHRINK 4 + #define WIGGLER_ACT_UNINITIALIZED 0 + #define WIGGLER_ACT_WALK 1 + #define WIGGLER_ACT_KNOCKBACK 2 + #define WIGGLER_ACT_JUMPED_ON 3 + #define WIGGLER_ACT_SHRINK 4 #define WIGGLER_ACT_FALL_THROUGH_FLOOR 5 /* oWigglerTextStatus */ - #define WIGGLER_TEXT_STATUS_AWAIT_DIALOG 0 - #define WIGGLER_TEXT_STATUS_SHOWING_DIALOG 1 + #define WIGGLER_TEXT_STATUS_AWAIT_DIALOG 0 + #define WIGGLER_TEXT_STATUS_SHOWING_DIALOG 1 #define WIGGLER_TEXT_STATUS_COMPLETED_DIALOG 2 /* Spiny */ /* oAction */ - #define SPINY_ACT_WALK 0 - #define SPINY_ACT_HELD_BY_LAKITU 1 + #define SPINY_ACT_WALK 0 + #define SPINY_ACT_HELD_BY_LAKITU 1 #define SPINY_ACT_THROWN_BY_LAKITU 2 - #define SPINY_ACT_ATTACKED_MARIO 3 + #define SPINY_ACT_ATTACKED_MARIO 3 /* Evil lakitu */ /* oAction */ #define ENEMY_LAKITU_ACT_UNINITIALIZED 0 - #define ENEMY_LAKITU_ACT_MAIN 1 + #define ENEMY_LAKITU_ACT_MAIN 1 /* oSubAction */ - #define ENEMY_LAKITU_SUB_ACT_NO_SPINY 0 - #define ENEMY_LAKITU_SUB_ACT_HOLD_SPINY 1 + #define ENEMY_LAKITU_SUB_ACT_NO_SPINY 0 + #define ENEMY_LAKITU_SUB_ACT_HOLD_SPINY 1 #define ENEMY_LAKITU_SUB_ACT_THROW_SPINY 2 /* Cloud */ /* oAction */ - #define CLOUD_ACT_SPAWN_PARTS 0 - #define CLOUD_ACT_MAIN 1 - #define CLOUD_ACT_UNLOAD 2 + #define CLOUD_ACT_SPAWN_PARTS 0 + #define CLOUD_ACT_MAIN 1 + #define CLOUD_ACT_UNLOAD 2 #define CLOUD_ACT_FWOOSH_HIDDEN 3 /* oBehParams2ndByte */ - #define CLOUD_BP_FWOOSH 0 + #define CLOUD_BP_FWOOSH 0 #define CLOUD_BP_LAKITU_CLOUD 1 /* Camera lakitu */ /* oAction */ #define CAMERA_LAKITU_INTRO_ACT_TRIGGER_CUTSCENE 0 - #define CAMERA_LAKITU_INTRO_ACT_SPAWN_CLOUD 1 - #define CAMERA_LAKITU_INTRO_ACT_UNK2 2 + #define CAMERA_LAKITU_INTRO_ACT_SPAWN_CLOUD 1 + #define CAMERA_LAKITU_INTRO_ACT_UNK2 2 /* oBehParams2ndByte */ #define CAMERA_LAKITU_BP_FOLLOW_CAMERA 0 - #define CAMERA_LAKITU_BP_INTRO 1 + #define CAMERA_LAKITU_BP_INTRO 1 /* Manta Ray */ /* oAction */ @@ -703,14 +722,14 @@ /* Monty mole */ /* oAction */ - #define MONTY_MOLE_ACT_SELECT_HOLE 0 - #define MONTY_MOLE_ACT_RISE_FROM_HOLE 1 - #define MONTY_MOLE_ACT_SPAWN_ROCK 2 + #define MONTY_MOLE_ACT_SELECT_HOLE 0 + #define MONTY_MOLE_ACT_RISE_FROM_HOLE 1 + #define MONTY_MOLE_ACT_SPAWN_ROCK 2 #define MONTY_MOLE_ACT_BEGIN_JUMP_INTO_HOLE 3 - #define MONTY_MOLE_ACT_THROW_ROCK 4 - #define MONTY_MOLE_ACT_JUMP_INTO_HOLE 5 - #define MONTY_MOLE_ACT_HIDE 6 - #define MONTY_MOLE_ACT_JUMP_OUT_OF_HOLE 7 + #define MONTY_MOLE_ACT_THROW_ROCK 4 + #define MONTY_MOLE_ACT_JUMP_INTO_HOLE 5 + #define MONTY_MOLE_ACT_HIDE 6 + #define MONTY_MOLE_ACT_JUMP_OUT_OF_HOLE 7 /* oBehParams2ndByte */ #define MONTY_MOLE_BP_NO_ROCK 0 @@ -798,36 +817,39 @@ /* Piranha Plant */ /* oAction */ - #define PIRANHA_PLANT_ACT_IDLE 0 - #define PIRANHA_PLANT_ACT_SLEEPING 1 - #define PIRANHA_PLANT_ACT_BITING 2 - #define PIRANHA_PLANT_ACT_WOKEN_UP 3 - #define PIRANHA_PLANT_ACT_STOPPED_BITING 4 - #define PIRANHA_PLANT_ACT_ATTACKED 5 - #define PIRANHA_PLANT_ACT_SHRINK_AND_DIE 6 + #define PIRANHA_PLANT_ACT_IDLE 0 + #define PIRANHA_PLANT_ACT_SLEEPING 1 + #define PIRANHA_PLANT_ACT_BITING 2 + #define PIRANHA_PLANT_ACT_WOKEN_UP 3 + #define PIRANHA_PLANT_ACT_STOPPED_BITING 4 + #define PIRANHA_PLANT_ACT_ATTACKED 5 + #define PIRANHA_PLANT_ACT_SHRINK_AND_DIE 6 #define PIRANHA_PLANT_ACT_WAIT_TO_RESPAWN 7 - #define PIRANHA_PLANT_ACT_RESPAWN 8 + #define PIRANHA_PLANT_ACT_RESPAWN 8 + + /* oPiranhaPlantSleepMusicState */ + #define PIRANHA_PLANT_SLEEP_MUSIC_PLAYING 0 /* Piranha Plant bubble */ - #define PIRANHA_PLANT_BUBBLE_ACT_IDLE 0 + #define PIRANHA_PLANT_BUBBLE_ACT_IDLE 0 #define PIRANHA_PLANT_BUBBLE_ACT_GROW_SHRINK_LOOP 1 - #define PIRANHA_PLANT_BUBBLE_ACT_BURST 2 + #define PIRANHA_PLANT_BUBBLE_ACT_BURST 2 /* Platform on track */ /* oAction */ - #define PLATFORM_ON_TRACK_ACT_INIT 0 - #define PLATFORM_ON_TRACK_ACT_WAIT_FOR_MARIO 1 + #define PLATFORM_ON_TRACK_ACT_INIT 0 + #define PLATFORM_ON_TRACK_ACT_WAIT_FOR_MARIO 1 #define PLATFORM_ON_TRACK_ACT_MOVE_ALONG_TRACK 2 - #define PLATFORM_ON_TRACK_ACT_PAUSE_BRIEFLY 3 - #define PLATFORM_ON_TRACK_ACT_FALL 4 + #define PLATFORM_ON_TRACK_ACT_PAUSE_BRIEFLY 3 + #define PLATFORM_ON_TRACK_ACT_FALL 4 /* oBehParams >> 16 */ - #define PLATFORM_ON_TRACK_BP_MASK_PATH 0xF - #define PLATFORM_ON_TRACK_BP_MASK_TYPE (0x7 << 4) + #define PLATFORM_ON_TRACK_BP_MASK_PATH 0xF + #define PLATFORM_ON_TRACK_BP_MASK_TYPE (0x7 << 4) #define PLATFORM_ON_TRACK_BP_RETURN_TO_START (1 << 8) - #define PLATFORM_ON_TRACK_BP_DONT_DISAPPEAR (1 << 9) - #define PLATFORM_ON_TRACK_BP_DONT_TURN_YAW (1 << 10) - #define PLATFORM_ON_TRACK_BP_DONT_TURN_ROLL (1 << 11) + #define PLATFORM_ON_TRACK_BP_DONT_DISAPPEAR (1 << 9) + #define PLATFORM_ON_TRACK_BP_DONT_TURN_YAW (1 << 10) + #define PLATFORM_ON_TRACK_BP_DONT_TURN_ROLL (1 << 11) #define PLATFORM_ON_TRACK_TYPE_CARPET 0 #define PLATFORM_ON_TRACK_TYPE_SKI_LIFT 1 @@ -849,18 +871,18 @@ /* Pyramid top */ #define PYRAMID_TOP_ACT_CHECK_IF_SOLVED 0 - #define PYRAMID_TOP_ACT_SPINNING 1 - #define PYRAMID_TOP_ACT_EXPLODE 2 + #define PYRAMID_TOP_ACT_SPINNING 1 + #define PYRAMID_TOP_ACT_EXPLODE 2 /* Pyramid wall */ /* oAction */ #define PYRAMID_WALL_ACT_MOVING_DOWN 0 - #define PYRAMID_WALL_ACT_MOVING_UP 1 + #define PYRAMID_WALL_ACT_MOVING_UP 1 /* oBehParams2ndByte */ - #define PYRAMID_WALL_BP_POSITION_HIGH 0 + #define PYRAMID_WALL_BP_POSITION_HIGH 0 #define PYRAMID_WALL_BP_POSITION_MIDDLE 1 - #define PYRAMID_WALL_BP_POSITION_LOW 2 + #define PYRAMID_WALL_BP_POSITION_LOW 2 /* Penguins (general) */ /* Walking sounds */ @@ -873,58 +895,57 @@ /* Racing penguin */ /* oAction */ - #define RACING_PENGUIN_ACT_WAIT_FOR_MARIO 0 - #define RACING_PENGUIN_ACT_SHOW_INIT_TEXT 1 + #define RACING_PENGUIN_ACT_WAIT_FOR_MARIO 0 + #define RACING_PENGUIN_ACT_SHOW_INIT_TEXT 1 #define RACING_PENGUIN_ACT_PREPARE_FOR_RACE 2 - #define RACING_PENGUIN_ACT_RACE 3 - #define RACING_PENGUIN_ACT_FINISH_RACE 4 - #define RACING_PENGUIN_ACT_SHOW_FINAL_TEXT 5 + #define RACING_PENGUIN_ACT_RACE 3 + #define RACING_PENGUIN_ACT_FINISH_RACE 4 + #define RACING_PENGUIN_ACT_SHOW_FINAL_TEXT 5 /* SL walking penguin */ /* oAction */ - #define SL_WALKING_PENGUIN_ACT_MOVING_FORWARDS 0 - #define SL_WALKING_PENGUIN_ACT_TURNING_BACK 1 - #define SL_WALKING_PENGUIN_ACT_RETURNING 2 + #define SL_WALKING_PENGUIN_ACT_MOVING_FORWARDS 0 + #define SL_WALKING_PENGUIN_ACT_TURNING_BACK 1 + #define SL_WALKING_PENGUIN_ACT_RETURNING 2 #define SL_WALKING_PENGUIN_ACT_TURNING_FORWARDS 3 /* Snowman wind */ /* oSubAction */ - #define SL_SNOWMAN_WIND_ACT_IDLE 0 + #define SL_SNOWMAN_WIND_ACT_IDLE 0 #define SL_SNOWMAN_WIND_ACT_TALKING 1 #define SL_SNOWMAN_WIND_ACT_BLOWING 2 - /* Water bomb */ /* oAction */ #define WATER_BOMB_ACT_SHOT_FROM_CANNON 0 - #define WATER_BOMB_ACT_INIT 1 - #define WATER_BOMB_ACT_DROP 2 - #define WATER_BOMB_ACT_EXPLODE 3 + #define WATER_BOMB_ACT_INIT 1 + #define WATER_BOMB_ACT_DROP 2 + #define WATER_BOMB_ACT_EXPLODE 3 /* TTC rotating solid */ /* oBehParams2ndByte */ - #define TTC_ROTATING_SOLID_BP_CUBE 0 + #define TTC_ROTATING_SOLID_BP_CUBE 0 #define TTC_ROTATING_SOLID_BP_TRIANGULAR_PRISM 1 /* TTC moving bar */ /* oAction */ - #define TTC_MOVING_BAR_ACT_WAIT 0 + #define TTC_MOVING_BAR_ACT_WAIT 0 #define TTC_MOVING_BAR_ACT_PULL_BACK 1 - #define TTC_MOVING_BAR_ACT_EXTEND 2 - #define TTC_MOVING_BAR_ACT_RETRACT 3 + #define TTC_MOVING_BAR_ACT_EXTEND 2 + #define TTC_MOVING_BAR_ACT_RETRACT 3 /* TTC cog */ /* oBehParams2ndByte */ - #define TTC_COG_BP_SHAPE_MASK 0x00000002 - #define TTC_COG_BP_SHAPE_HEXAGON (0 << 1) + #define TTC_COG_BP_SHAPE_MASK 0x00000002 + #define TTC_COG_BP_SHAPE_HEXAGON (0 << 1) #define TTC_COG_BP_SHAPE_TRIANGLE (1 << 1) - #define TTC_COG_BP_DIR_MASK 0x00000001 - #define TTC_COG_BP_DIR_CCW (0 << 0) // TODO: Check these - #define TTC_COG_BP_DIR_CW (1 << 0) + #define TTC_COG_BP_DIR_MASK 0x00000001 + #define TTC_COG_BP_DIR_CCW (0 << 0) // TODO: Check these + #define TTC_COG_BP_DIR_CW (1 << 0) /* TTC 2D Rotator */ /* oBehParams2ndByte */ - #define TTC_2D_ROTATOR_BP_HAND 0 + #define TTC_2D_ROTATOR_BP_HAND 0 #define TTC_2D_ROTATOR_BP_2D_COG 1 /* Activated Back-and-Forth Platform */ @@ -935,13 +956,13 @@ /* Dorrie */ /* oAction */ - #define DORRIE_ACT_MOVE 0 + #define DORRIE_ACT_MOVE 0 #define DORRIE_ACT_LOWER_HEAD 1 #define DORRIE_ACT_RAISE_HEAD 2 /* Mad piano */ /* oAction */ - #define MAD_PIANO_ACT_WAIT 0 + #define MAD_PIANO_ACT_WAIT 0 #define MAD_PIANO_ACT_ATTACK 1 /* Fire piranha plant */ @@ -951,56 +972,56 @@ /* Fire spitter */ /* oAction */ - #define FIRE_SPITTER_ACT_IDLE 0 + #define FIRE_SPITTER_ACT_IDLE 0 #define FIRE_SPITTER_ACT_SPIT_FIRE 1 /* Eyerok boss */ /* oAction */ - #define EYEROK_BOSS_ACT_SLEEP 0 - #define EYEROK_BOSS_ACT_WAKE_UP 1 + #define EYEROK_BOSS_ACT_SLEEP 0 + #define EYEROK_BOSS_ACT_WAKE_UP 1 #define EYEROK_BOSS_ACT_SHOW_INTRO_TEXT 2 - #define EYEROK_BOSS_ACT_FIGHT 3 - #define EYEROK_BOSS_ACT_DIE 4 + #define EYEROK_BOSS_ACT_FIGHT 3 + #define EYEROK_BOSS_ACT_DIE 4 /* Eyerok hand */ /* oAction */ - #define EYEROK_HAND_ACT_SLEEP 0 - #define EYEROK_HAND_ACT_IDLE 1 - #define EYEROK_HAND_ACT_OPEN 2 - #define EYEROK_HAND_ACT_SHOW_EYE 3 - #define EYEROK_HAND_ACT_CLOSE 4 - #define EYEROK_HAND_ACT_RETREAT 5 - #define EYEROK_HAND_ACT_TARGET_MARIO 6 - #define EYEROK_HAND_ACT_SMASH 7 - #define EYEROK_HAND_ACT_FIST_PUSH 8 - #define EYEROK_HAND_ACT_FIST_SWEEP 9 + #define EYEROK_HAND_ACT_SLEEP 0 + #define EYEROK_HAND_ACT_IDLE 1 + #define EYEROK_HAND_ACT_OPEN 2 + #define EYEROK_HAND_ACT_SHOW_EYE 3 + #define EYEROK_HAND_ACT_CLOSE 4 + #define EYEROK_HAND_ACT_RETREAT 5 + #define EYEROK_HAND_ACT_TARGET_MARIO 6 + #define EYEROK_HAND_ACT_SMASH 7 + #define EYEROK_HAND_ACT_FIST_PUSH 8 + #define EYEROK_HAND_ACT_FIST_SWEEP 9 #define EYEROK_HAND_ACT_BEGIN_DOUBLE_POUND 10 // raising for double smash - #define EYEROK_HAND_ACT_DOUBLE_POUND 11 // double smashing - #define EYEROK_HAND_ACT_ATTACKED 12 - #define EYEROK_HAND_ACT_RECOVER 13 - #define EYEROK_HAND_ACT_BECOME_ACTIVE 14 - #define EYEROK_HAND_ACT_DIE 15 + #define EYEROK_HAND_ACT_DOUBLE_POUND 11 // double smashing + #define EYEROK_HAND_ACT_ATTACKED 12 + #define EYEROK_HAND_ACT_RECOVER 13 + #define EYEROK_HAND_ACT_BECOME_ACTIVE 14 + #define EYEROK_HAND_ACT_DIE 15 /* Klepto */ /* oAction */ - #define KLEPTO_ACT_CIRCLE_TARGET_HOLDING 0 + #define KLEPTO_ACT_CIRCLE_TARGET_HOLDING 0 #define KLEPTO_ACT_APPROACH_TARGET_HOLDING 1 - #define KLEPTO_ACT_WAIT_FOR_MARIO 2 - #define KLEPTO_ACT_TURN_TOWARD_MARIO 3 - #define KLEPTO_ACT_DIVE_AT_MARIO 4 - #define KLEPTO_ACT_RESET_POSITION 5 - #define KLEPTO_ACT_STRUCK_BY_MARIO 6 - #define KLEPTO_ACT_RETREAT 7 + #define KLEPTO_ACT_WAIT_FOR_MARIO 2 + #define KLEPTO_ACT_TURN_TOWARD_MARIO 3 + #define KLEPTO_ACT_DIVE_AT_MARIO 4 + #define KLEPTO_ACT_RESET_POSITION 5 + #define KLEPTO_ACT_STRUCK_BY_MARIO 6 + #define KLEPTO_ACT_RETREAT 7 /* oAnimState */ #define KLEPTO_ANIM_STATE_HOLDING_NOTHING 0 - #define KLEPTO_ANIM_STATE_HOLDING_CAP 1 - #define KLEPTO_ANIM_STATE_HOLDING_STAR 2 + #define KLEPTO_ANIM_STATE_HOLDING_CAP 1 + #define KLEPTO_ANIM_STATE_HOLDING_STAR 2 /* Bird */ /* oAction */ #define BIRD_ACT_INACTIVE 0 - #define BIRD_ACT_FLY 1 + #define BIRD_ACT_FLY 1 /* oBehParams2ndByte */ #define BIRD_BP_SPAWNED 0 @@ -1008,9 +1029,9 @@ /* Skeeter */ /* oAction */ - #define SKEETER_ACT_IDLE 0 + #define SKEETER_ACT_IDLE 0 #define SKEETER_ACT_LUNGE 1 - #define SKEETER_ACT_WALK 2 + #define SKEETER_ACT_WALK 2 /* Snufit */ /* oAction */ @@ -1030,68 +1051,69 @@ /* Triplet butterfly */ /* oAction */ - #define TRIPLET_BUTTERFLY_ACT_INIT 0 - #define TRIPLET_BUTTERFLY_ACT_WANDER 1 + #define TRIPLET_BUTTERFLY_ACT_INIT 0 + #define TRIPLET_BUTTERFLY_ACT_WANDER 1 #define TRIPLET_BUTTERFLY_ACT_ACTIVATE 2 - #define TRIPLET_BUTTERFLY_ACT_EXPLODE 3 + #define TRIPLET_BUTTERFLY_ACT_EXPLODE 3 /* oBehParams2ndByte */ #define TRIPLET_BUTTERFLY_BP_BUTTERFLY_NUM 0x00000003 - #define TRIPLET_BUTTERFLY_BP_NO_BOMBS 0x00000004 + #define TRIPLET_BUTTERFLY_BP_NO_BOMBS 0x00000004 /* oTripletButterflyType */ - #define TRIPLET_BUTTERFLY_TYPE_NORMAL -1 - #define TRIPLET_BUTTERFLY_TYPE_EXPLODES 0 - #define TRIPLET_BUTTERFLY_TYPE_SPAWN_1UP 1 + #define TRIPLET_BUTTERFLY_TYPE_NORMAL -1 + #define TRIPLET_BUTTERFLY_TYPE_EXPLODES 0 + #define TRIPLET_BUTTERFLY_TYPE_SPAWN_1UP 1 /* Water level diamond */ /* oAction */ // Loading - #define WATER_LEVEL_DIAMOND_ACT_INIT 0 + #define WATER_LEVEL_DIAMOND_ACT_INIT 0 // Idling when Mario isn't inside its hitbox - #define WATER_LEVEL_DIAMOND_ACT_IDLE 1 + #define WATER_LEVEL_DIAMOND_ACT_IDLE 1 // While the water level is changing #define WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL 2 // After the water level has changed but Mario hasn't left its hitbox yet - #define WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING 3 + #define WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING 3 /* Mips */ /* oAction */ - #define MIPS_ACT_WAIT_FOR_NEARBY_MARIO 0 - #define MIPS_ACT_FOLLOW_PATH 1 + #define MIPS_ACT_WAIT_FOR_NEARBY_MARIO 0 + #define MIPS_ACT_FOLLOW_PATH 1 #define MIPS_ACT_WAIT_FOR_ANIMATION_DONE 2 - #define MIPS_ACT_FALL_DOWN 3 - #define MIPS_ACT_IDLE 4 + #define MIPS_ACT_FALL_DOWN 3 + #define MIPS_ACT_IDLE 4 /* oMipsStarStatus */ - #define MIPS_STAR_STATUS_HAVENT_SPAWNED_STAR 0 - #define MIPS_STAR_STATUS_SHOULD_SPAWN_STAR 1 + #define MIPS_STAR_STATUS_HAVENT_SPAWNED_STAR 0 + #define MIPS_STAR_STATUS_SHOULD_SPAWN_STAR 1 #define MIPS_STAR_STATUS_ALREADY_SPAWNED_STAR 2 /* Falling Pillar */ /* oAction */ - #define FALLING_PILLAR_ACT_IDLE 0 + #define FALLING_PILLAR_ACT_IDLE 0 #define FALLING_PILLAR_ACT_TURNING 1 #define FALLING_PILLAR_ACT_FALLING 2 /* Bowser Puzzle */ /* oAction */ - #define BOWSER_PUZZLE_ACT_SPAWN_PIECES 0 + #define BOWSER_PUZZLE_ACT_SPAWN_PIECES 0 #define BOWSER_PUZZLE_ACT_WAIT_FOR_COMPLETE 1 - #define BOWSER_PUZZLE_ACT_DONE 2 + #define BOWSER_PUZZLE_ACT_DONE 2 /* Mr Blizzard */ /* oAction */ - #define MR_BLIZZARD_ACT_SPAWN_SNOWBALL 0 - #define MR_BLIZZARD_ACT_HIDE_UNHIDE 1 + #define MR_BLIZZARD_ACT_SPAWN_SNOWBALL 0 + #define MR_BLIZZARD_ACT_HIDE_UNHIDE 1 #define MR_BLIZZARD_ACT_RISE_FROM_GROUND 2 - #define MR_BLIZZARD_ACT_ROTATE 3 - #define MR_BLIZZARD_ACT_THROW_SNOWBALL 4 - #define MR_BLIZZARD_ACT_BURROW 5 - #define MR_BLIZZARD_ACT_DEATH 6 - #define MR_BLIZZARD_ACT_JUMP 7 + #define MR_BLIZZARD_ACT_ROTATE 3 + #define MR_BLIZZARD_ACT_THROW_SNOWBALL 4 + #define MR_BLIZZARD_ACT_BURROW 5 + #define MR_BLIZZARD_ACT_DEATH 6 + #define MR_BLIZZARD_ACT_JUMP 7 + /* oBehParams2ndByte */ - #define MR_BLIZZARD_STYPE_NO_CAP 0 + #define MR_BLIZZARD_STYPE_NO_CAP 0 #define MR_BLIZZARD_STYPE_JUMPING 1 #endif // OBJECT_CONSTANTS_H diff --git a/include/object_fields.h b/include/object_fields.h index d9dda336..8159f4aa 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -186,8 +186,8 @@ #define /*0x0FC*/ oHomingAmpAvgY OBJECT_FIELD_F32(0x1D) /* Arrow Lift */ -#define /*0x0F4*/ oArrowLiftDisplacement OBJECT_FIELD_F32(0x1B) -#define /*0x100*/ oArrowLiftUnk100 OBJECT_FIELD_S32(0x1E) +#define /*0x0F4*/ oArrowLiftDisplacement OBJECT_FIELD_F32(0x1B) +#define /*0x100*/ oArrowLiftUnk100 OBJECT_FIELD_S32(0x1E) /* Back-and-Forth Platform */ #define /*0x0F4*/ oBackAndForthPlatformDirection OBJECT_FIELD_F32(0x1B) @@ -277,14 +277,14 @@ #define /*0x088*/ oBowserCamAct OBJECT_FIELD_S32(0x00) #define /*0x0F4*/ oBowserStatus OBJECT_FIELD_S32(0x1B) #define /*0x0F8*/ oBowserTimer OBJECT_FIELD_S32(0x1C) -#define /*0x0FC*/ oBowserDistToCentre OBJECT_FIELD_F32(0x1D) +#define /*0x0FC*/ oBowserDistToCenter OBJECT_FIELD_F32(0x1D) #define /*0x106*/ oBowserBitsJustJump OBJECT_FIELD_S16(0x1F, 1) #define /*0x108*/ oBowserRandSplitFloor OBJECT_FIELD_S16(0x20, 0) #define /*0x10A*/ oBowserHeldAnglePitch OBJECT_FIELD_S16(0x20, 1) #define /*0x10D*/ oBowserHeldAngleVelYaw OBJECT_FIELD_S16(0x21, 0) #define /*0x10E*/ oBowserGrabbedStatus OBJECT_FIELD_S16(0x21, 1) #define /*0x110*/ oBowserIsReacting OBJECT_FIELD_S16(0x22, 0) -#define /*0x112*/ oBowserAngleToCentre OBJECT_FIELD_S16(0x22, 1) +#define /*0x112*/ oBowserAngleToCenter OBJECT_FIELD_S16(0x22, 1) #define /*0x1AC*/ oBowserTargetOpacity OBJECT_FIELD_S16(0x49, 0) #define /*0x1AE*/ oBowserEyesTimer OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oBowserEyesShut OBJECT_FIELD_S16(0x4A, 0) @@ -319,9 +319,9 @@ #define /*0x108*/ oBubbaUnk108 OBJECT_FIELD_F32(0x20) #define /*0x10C*/ oBubbaUnk10C OBJECT_FIELD_F32(0x21) #define /*0x1AC*/ oBubbaUnk1AC OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oBubbaUnk1AE OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oBubbaUnk1AE OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oBubbaUnk1B0 OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oBubbaUnk1B2 OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oBubbaUnk1B2 OBJECT_FIELD_S16(0x4A, 1) /* Bullet Bill */ #define /*0x0F8*/ oBulletBillInitialMoveYaw OBJECT_FIELD_S32(0x1C) @@ -406,7 +406,7 @@ #endif /* Collision Particle */ -#define /*0x0F4*/ oCollisionParticleUnkF4 OBJECT_FIELD_F32(0x1B) +#define /*0x0F4*/ oCollisionParticleUnkF4 OBJECT_FIELD_F32(0x1B) /* Controllable Platform */ #define /*0x0F8*/ oControllablePlatformUnkF8 OBJECT_FIELD_S32(0x1C) @@ -442,9 +442,9 @@ #define /*0x104*/ oDorrieYawVel OBJECT_FIELD_S32(0x1F) #define /*0x10C*/ oDorrieLiftingMario OBJECT_FIELD_S32(0x21) #define /*0x1AC*/ oDorrieGroundPounded OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oDorrieAngleToHome OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oDorrieAngleToHome OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oDorrieNeckAngle OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oDorrieHeadRaiseSpeed OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oDorrieHeadRaiseSpeed OBJECT_FIELD_S16(0x4A, 1) /* Elevator */ #define /*0x0F4*/ oElevatorUnkF4 OBJECT_FIELD_F32(0x1B) @@ -523,7 +523,7 @@ #define /*0x0F4*/ oFloatingPlatformUnkF4 OBJECT_FIELD_S32(0x1B) #define /*0x0F8*/ oFloatingPlatformUnkF8 OBJECT_FIELD_F32(0x1C) #define /*0x0FC*/ oFloatingPlatformUnkFC OBJECT_FIELD_F32(0x1D) -#define /*0x100*/ oFloatingPlatformUnk100 OBJECT_FIELD_S32(0x1E) +#define /*0x100*/ oFloatingPlatformUnk100 OBJECT_FIELD_S32(0x1E) /* Floor Switch Press Animation */ #define /*0x0F4*/ oFloorSwitchPressAnimationUnkF4 OBJECT_FIELD_S32(0x1B) @@ -604,9 +604,9 @@ #define /*0x10C*/ oKleptoStartPosZ OBJECT_FIELD_F32(0x21) #define /*0x110*/ oKleptoTimeUntilTargetChange OBJECT_FIELD_S32(0x22) #define /*0x1AC*/ oKleptoTargetNumber OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oKleptoUnk1AE OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oKleptoUnk1AE OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oKleptoUnk1B0 OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oKleptoYawToTarget OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oKleptoYawToTarget OBJECT_FIELD_S16(0x4A, 1) /* Koopa */ #define /*0x0F4*/ oKoopaAgility OBJECT_FIELD_F32(0x1B) @@ -631,7 +631,7 @@ /* Koopa Shell Flame */ #define /*0x0F4*/ oKoopaShellFlameUnkF4 OBJECT_FIELD_F32(0x1B) -#define /*0x0F8*/ oKoopaShellFlameUnkF8 OBJECT_FIELD_F32(0x1C) +#define /*0x0F8*/ oKoopaShellFlameScale OBJECT_FIELD_F32(0x1C) /* Camera Lakitu */ #define /*0x0F4*/ oCameraLakituBlinkTimer OBJECT_FIELD_S32(0x1B) @@ -642,7 +642,7 @@ #define /*0x104*/ oCameraLakituUnk104 OBJECT_FIELD_S32(0x1F) #endif #define /*0x1AC*/ oCameraLakituPitchVel OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oCameraLakituYawVel OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oCameraLakituYawVel OBJECT_FIELD_S16(0x49, 1) /* Evil Lakitu */ #define /*0x0F4*/ oEnemyLakituNumSpinies OBJECT_FIELD_S32(0x1B) @@ -651,14 +651,14 @@ #define /*0x100*/ oEnemyLakituFaceForwardCountdown OBJECT_FIELD_S32(0x1E) /* Intro Cutscene Lakitu */ -#define /*0x0F8*/ oIntroLakituSplineSegmentProgress OBJECT_FIELD_F32(0x1C) -#define /*0x0FC*/ oIntroLakituSplineSegment OBJECT_FIELD_F32(0x1D) -#define /*0x100*/ oIntroLakituUnk100 OBJECT_FIELD_F32(0x1E) -#define /*0x104*/ oIntroLakituUnk104 OBJECT_FIELD_F32(0x1F) -#define /*0x108*/ oIntroLakituUnk108 OBJECT_FIELD_F32(0x20) -#define /*0x10C*/ oIntroLakituUnk10C OBJECT_FIELD_F32(0x21) -#define /*0x110*/ oIntroLakituUnk110 OBJECT_FIELD_F32(0x22) -#define /*0x1AC*/ oIntroLakituCloud OBJECT_FIELD_OBJ(0x49) +#define /*0x0F8*/ oIntroLakituSplineSegmentProgress OBJECT_FIELD_F32(0x1C) +#define /*0x0FC*/ oIntroLakituSplineSegment OBJECT_FIELD_F32(0x1D) +#define /*0x100*/ oIntroLakituUnk100 OBJECT_FIELD_F32(0x1E) +#define /*0x104*/ oIntroLakituUnk104 OBJECT_FIELD_F32(0x1F) +#define /*0x108*/ oIntroLakituUnk108 OBJECT_FIELD_F32(0x20) +#define /*0x10C*/ oIntroLakituUnk10C OBJECT_FIELD_F32(0x21) +#define /*0x110*/ oIntroLakituUnk110 OBJECT_FIELD_F32(0x22) +#define /*0x1AC*/ oIntroLakituCloud OBJECT_FIELD_OBJ(0x49) /* Main Menu Button */ #define /*0x0F4*/ oMenuButtonState OBJECT_FIELD_S32(0x1B) @@ -715,7 +715,7 @@ #define /*0x100*/ oMrIUnk100 OBJECT_FIELD_S32(0x1E) #define /*0x104*/ oMrIUnk104 OBJECT_FIELD_S32(0x1F) #define /*0x108*/ oMrIUnk108 OBJECT_FIELD_S32(0x20) -#define /*0x10C*/ oMrISize OBJECT_FIELD_F32(0x21) +#define /*0x10C*/ oMrIScale OBJECT_FIELD_F32(0x21) #define /*0x110*/ oMrIUnk110 OBJECT_FIELD_S32(0x22) /* Object Respawner */ @@ -737,9 +737,9 @@ // 0x1D-0x21 reserved for pathing #define /*0x110*/ oRacingPenguinWeightedNewTargetSpeed OBJECT_FIELD_F32(0x22) #define /*0x1AC*/ oRacingPenguinFinalTextbox OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oRacingPenguinMarioWon OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oRacingPenguinMarioWon OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oRacingPenguinReachedBottom OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oRacingPenguinMarioCheated OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oRacingPenguinMarioCheated OBJECT_FIELD_S16(0x4A, 1) /* Small Penguin */ #define /*0x088*/ oSmallPenguinUnk88 OBJECT_FIELD_S32(0x00) @@ -760,7 +760,7 @@ /* Fire Piranha Plant */ #define /*0x0F4*/ oFirePiranhaPlantNeutralScale OBJECT_FIELD_F32(0x1B) -#define /*0x0F8*/ oFirePiranhaPlantScale OBJECT_FIELD_F32(0x1C) //Shared with above obj? Coincidence? +#define /*0x0F8*/ oFirePiranhaPlantScale OBJECT_FIELD_F32(0x1C) // Shared with above obj? Coincidence? #define /*0x0FC*/ oFirePiranhaPlantActive OBJECT_FIELD_S32(0x1D) #define /*0x100*/ oFirePiranhaPlantDeathSpinTimer OBJECT_FIELD_S32(0x1E) #define /*0x104*/ oFirePiranhaPlantDeathSpinVel OBJECT_FIELD_F32(0x1F) @@ -792,9 +792,9 @@ #define /*0x10C*/ oPlatformOnTrackYaw OBJECT_FIELD_S32(0x21) #define /*0x110*/ oPlatformOnTrackOffsetY OBJECT_FIELD_F32(0x22) #define /*0x1AC*/ oPlatformOnTrackIsNotSkiLift OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oPlatformOnTrackIsNotHMC OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oPlatformOnTrackIsNotHMC OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oPlatformOnTrackType OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oPlatformOnTrackWasStoodOn OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oPlatformOnTrackWasStoodOn OBJECT_FIELD_S16(0x4A, 1) /* Platform Spawner */ #define /*0x0F4*/ oPlatformSpawnerUnkF4 OBJECT_FIELD_S32(0x1B) @@ -857,11 +857,11 @@ #define /*0x108*/ oSinkWhenSteppedOnUnk108 OBJECT_FIELD_F32(0x20) /* Skeeter */ -#define /*0x0F4*/ oSkeeterTargetAngle OBJECT_FIELD_S32(0x1B) -#define /*0x0F8*/ oSkeeterUnkF8 OBJECT_FIELD_S32(0x1C) -#define /*0x0FC*/ oSkeeterUnkFC OBJECT_FIELD_F32(0x1D) -#define /*0x100*/ oSkeeterWaitTime OBJECT_FIELD_S32(0x1E) -#define /*0x1AC*/ oSkeeterUnk1AC OBJECT_FIELD_S16(0x49, 0) +#define /*0x0F4*/ oSkeeterTargetAngle OBJECT_FIELD_S32(0x1B) +#define /*0x0F8*/ oSkeeterTurningAwayFromWall OBJECT_FIELD_S32(0x1C) +#define /*0x0FC*/ oSkeeterUnkFC OBJECT_FIELD_F32(0x1D) +#define /*0x100*/ oSkeeterWaitTime OBJECT_FIELD_S32(0x1E) +#define /*0x1AC*/ oSkeeterUnk1AC OBJECT_FIELD_S16(0x49, 0) /* Jrb Sliding Box */ #define /*0x0F4*/ oJrbSlidingBoxUnkF4 OBJECT_FIELD_OBJ(0x1B) @@ -875,7 +875,7 @@ #define /*0x0F4*/ oSmokeTimer OBJECT_FIELD_S32(0x1B) /* Snowman's Bottom */ -#define /*0x0F4*/ oSnowmansBottomUnkF4 OBJECT_FIELD_F32(0x1B) +#define /*0x0F4*/ oSnowmansBottomScale OBJECT_FIELD_F32(0x1B) #define /*0x0F8*/ oSnowmansBottomUnkF8 OBJECT_FIELD_S32(0x1C) #define /*0x1AC*/ oSnowmansBottomUnk1AC OBJECT_FIELD_S32(0x49) // 0x1D-0x21 reserved for pathing @@ -894,9 +894,9 @@ #define /*0x108*/ oSnufitBodyBaseScale OBJECT_FIELD_S32(0x20) #define /*0x10C*/ oSnufitBullets OBJECT_FIELD_S32(0x21) #define /*0x1AC*/ oSnufitXOffset OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oSnufitYOffset OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oSnufitYOffset OBJECT_FIELD_S16(0x49, 1) #define /*0x1B0*/ oSnufitZOffset OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oSnufitBodyScale OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oSnufitBodyScale OBJECT_FIELD_S16(0x4A, 1) /* Spindel */ #define /*0x0F4*/ oSpindelUnkF4 OBJECT_FIELD_S32(0x1B) @@ -1065,7 +1065,7 @@ #define /*0x110*/ oUnagiUnk110 OBJECT_FIELD_F32(0x22) #define /*0x1AC*/ oUnagiUnk1AC OBJECT_FIELD_F32(0x49) #define /*0x1B0*/ oUnagiUnk1B0 OBJECT_FIELD_S16(0x4A, 0) -#define /*0x1B2*/ oUnagiUnk1B2 OBJECT_FIELD_S16(0x4A, + 1) +#define /*0x1B2*/ oUnagiUnk1B2 OBJECT_FIELD_S16(0x4A, 1) /* Water Bomb */ #define /*0x0F8*/ oWaterBombVerticalStretch OBJECT_FIELD_F32(0x1C) @@ -1144,7 +1144,7 @@ #define /*0x10C*/ oWigglerTargetYaw OBJECT_FIELD_S32(0x21) #define /*0x110*/ oWigglerWalkAwayFromWallTimer OBJECT_FIELD_S32(0x22) #define /*0x1AC*/ oWigglerUnused OBJECT_FIELD_S16(0x49, 0) -#define /*0x1AE*/ oWigglerTextStatus OBJECT_FIELD_S16(0x49, + 1) +#define /*0x1AE*/ oWigglerTextStatus OBJECT_FIELD_S16(0x49, 1) /* Lll Wood Piece */ #define /*0x0F4*/ oLllWoodPieceOscillationTimer OBJECT_FIELD_S32(0x1B) diff --git a/include/sounds.h b/include/sounds.h index f3a5f555..71709c90 100644 --- a/include/sounds.h +++ b/include/sounds.h @@ -291,18 +291,23 @@ #define SOUND_GENERAL_PLATFORM /* 0x302D8080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x2D, 0x80, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_DONUT_PLATFORM_EXPLOSION /* 0x302E2080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x2E, 0x20, SOUND_DISCRETE) #define SOUND_GENERAL_BOWSER_BOMB_EXPLOSION /* 0x312F0080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x2F, 0x00, SOUND_NO_VOLUME_LOSS | SOUND_DISCRETE) +#if defined(VERSION_JP) #define SOUND_GENERAL_COIN_SPURT /* 0x30300080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x30, 0x00, SOUND_DISCRETE) // unverified -#define SOUND_GENERAL_COIN_SPURT_2 /* 0x38300080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x30, 0x00, SOUND_CONSTANT_FREQUENCY | SOUND_DISCRETE) // unverified -#define SOUND_GENERAL_COIN_SPURT_EU /* 0x38302080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x30, 0x20, SOUND_CONSTANT_FREQUENCY | SOUND_DISCRETE) // unverified - +#elif defined(VERSION_US) +#define SOUND_GENERAL_COIN_SPURT /* 0x38300080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x30, 0x00, SOUND_CONSTANT_FREQUENCY | SOUND_DISCRETE) // unverified +#else +#define SOUND_GENERAL_COIN_SPURT /* 0x38302080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x30, 0x20, SOUND_CONSTANT_FREQUENCY | SOUND_DISCRETE) // unverified +#endif #define SOUND_GENERAL_EXPLOSION6 /* 0x30310000 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x31, 0x00, 0) // unverified, unused #define SOUND_GENERAL_UNK32 /* 0x30320000 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x32, 0x00, 0) // unverified, unused #define SOUND_GENERAL_BOAT_TILT1 /* 0x30344080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x34, 0x40, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_BOAT_TILT2 /* 0x30354080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x35, 0x40, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_COIN_DROP /* 0x30364080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x36, 0x40, SOUND_DISCRETE) // unverified -#define SOUND_GENERAL_UNKNOWN3_LOWPRIO /* 0x30370080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x37, 0x00, SOUND_DISCRETE) // unverified -#define SOUND_GENERAL_UNKNOWN3 /* 0x30378080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x37, 0x80, SOUND_DISCRETE) // unverified -#define SOUND_GENERAL_UNKNOWN3_2 /* 0x38378080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x37, 0x80, SOUND_CONSTANT_FREQUENCY | SOUND_DISCRETE) // unverified +#ifdef VERSION_JP +#define SOUND_GENERAL_UNKNOWN3 /* 0x30370080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x37, 0x00, SOUND_DISCRETE) // unverified +#else +#define SOUND_GENERAL_UNKNOWN3 /* 0x38378080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x37, 0x80, SOUND_CONSTANT_FREQUENCY | SOUND_DISCRETE) // unverified +#endif #define SOUND_GENERAL_PENDULUM_SWING /* 0x30380080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x38, 0x00, SOUND_DISCRETE) #define SOUND_GENERAL_CHAIN_CHOMP1 /* 0x30390080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x39, 0x00, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_CHAIN_CHOMP2 /* 0x303A0080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x3A, 0x00, SOUND_DISCRETE) // unverified @@ -319,8 +324,11 @@ #define SOUND_GENERAL_QUIET_POUND2 /* 0x30430080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x43, 0x00, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_BIG_POUND /* 0x30440080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x44, 0x00, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_UNK45 /* 0x30450080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x45, 0x00, SOUND_DISCRETE) // unverified -#define SOUND_GENERAL_UNK46_LOWPRIO /* 0x30460080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x46, 0x00, SOUND_DISCRETE) // unverified +#ifdef VERSION_JP +#define SOUND_GENERAL_UNK46 /* 0x30460080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x46, 0x00, SOUND_DISCRETE) // unverified +#else #define SOUND_GENERAL_UNK46 /* 0x30468080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x46, 0x80, SOUND_DISCRETE) // unverified +#endif #define SOUND_GENERAL_CANNON_UP /* 0x30478080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x47, 0x80, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_GRINDEL_ROLL /* 0x30480080 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x48, 0x00, SOUND_DISCRETE) // unverified #define SOUND_GENERAL_EXPLOSION7 /* 0x30490000 */ SOUND_ARG_LOAD(SOUND_BANK_GENERAL, 0x49, 0x00, 0) // unverified, unused @@ -412,7 +420,7 @@ #define SOUND_OBJ_MRI_DEATH /* 0x50140080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x14, 0x00, SOUND_DISCRETE) #define SOUND_OBJ_POUNDING1 /* 0x50155080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x15, 0x50, SOUND_DISCRETE) // unverified #define SOUND_OBJ_POUNDING1_HIGHPRIO /* 0x50158080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x15, 0x80, SOUND_DISCRETE) // unverified -#define SOUND_OBJ_WHOMP_LOWPRIO /* 0x50166080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x16, 0x60, SOUND_DISCRETE) +#define SOUND_OBJ_WHOMP /* 0x50166080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x16, 0x60, SOUND_DISCRETE) #define SOUND_OBJ_KING_BOBOMB /* 0x50168080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x16, 0x80, SOUND_DISCRETE) #define SOUND_OBJ_BULLY_METAL /* 0x50178080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x17, 0x80, SOUND_DISCRETE) // unverified #define SOUND_OBJ_BULLY_EXPLODE /* 0x5018A080 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ, 0x18, 0xA0, SOUND_DISCRETE) // unverified @@ -516,8 +524,11 @@ /* Menu Sound Effects */ #define SOUND_MENU_CHANGE_SELECT /* 0x7000F880 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x00, 0xF8, SOUND_DISCRETE) #define SOUND_MENU_REVERSE_PAUSE /* 0x70010000 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x01, 0x00, 0) // unverified, unused +#ifdef VERSION_JP #define SOUND_MENU_PAUSE /* 0x7002F080 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x02, 0xF0, SOUND_DISCRETE) -#define SOUND_MENU_PAUSE_HIGHPRIO /* 0x7002FF80 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x02, 0xFF, SOUND_DISCRETE) +#else +#define SOUND_MENU_PAUSE /* 0x7002FF80 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x02, 0xFF, SOUND_DISCRETE) +#endif #define SOUND_MENU_PAUSE_2 /* 0x7003FF80 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x03, 0xFF, SOUND_DISCRETE) #define SOUND_MENU_MESSAGE_APPEAR /* 0x70040080 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x04, 0x00, SOUND_DISCRETE) #define SOUND_MENU_MESSAGE_DISAPPEAR /* 0x70050080 */ SOUND_ARG_LOAD(SOUND_BANK_MENU, 0x05, 0x00, SOUND_DISCRETE) diff --git a/include/special_presets.h b/include/special_presets.h index e16ac6a8..9e2e1853 100644 --- a/include/special_presets.h +++ b/include/special_presets.h @@ -12,8 +12,7 @@ #define SPTYPE_UNKNOWN 3 // object is 14-bytes long, has 3 extra shorts that get converted to floats. #define SPTYPE_DEF_PARAM_AND_YROT 4 // object is 10-bytes long, has y-rotation and uses the default param -struct SpecialPreset -{ +struct SpecialPreset { /*00*/ u8 preset_id; /*01*/ u8 type; // Determines whether object is 8, 10, 12 or 14 bytes long. /*02*/ u8 defParam; // Default parameter, only used when type is SPTYPE_DEF_PARAM_AND_YROT @@ -23,8 +22,7 @@ struct SpecialPreset // Some Models ID's are missing their names because they are probably unused -static struct SpecialPreset SpecialObjectPresets[] = -{ +static struct SpecialPreset SpecialObjectPresets[] = { {0x00, SPTYPE_YROT_NO_PARAMS , 0x00, MODEL_NONE, NULL}, {0x01, SPTYPE_NO_YROT_OR_PARAMS , 0x00, MODEL_YELLOW_COIN, bhvYellowCoin}, {0x02, SPTYPE_NO_YROT_OR_PARAMS , 0x00, MODEL_YELLOW_COIN, bhvYellowCoin}, diff --git a/include/surface_terrains.h b/include/surface_terrains.h index 669a0ac2..f555d5b1 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -43,13 +43,13 @@ #define SURFACE_HARD_VERY_SLIPPERY 0x0036 // Hard and very slippery (Always has fall damage) #define SURFACE_HARD_NOT_SLIPPERY 0x0037 // Hard and Non-slippery (Always has fall damage) #define SURFACE_VERTICAL_WIND 0x0038 // Death at bottom with vertical wind -#define SURFACE_BOSS_FIGHT_CAMERA 0x0065 // Wide camera for BOB and WF bosses +#define SURFACE_BOSS_FIGHT_CAMERA 0x0065 // Wide camera for BoB and WF bosses #define SURFACE_CAMERA_FREE_ROAM 0x0066 // Free roam camera for THI and TTC #define SURFACE_THI3_WALLKICK 0x0068 // Surface where there's a wall kick section in THI 3rd area, has no action defined #define SURFACE_CAMERA_8_DIR 0x0069 // Surface that enables far camera for platforms, used in THI #define SURFACE_CAMERA_MIDDLE 0x006E // Surface camera that returns to the middle, used on the 4 pillars of SSL #define SURFACE_CAMERA_ROTATE_RIGHT 0x006F // Surface camera that rotates to the right (Bowser 1 & THI) -#define SURFACE_CAMERA_ROTATE_LEFT 0x0070 // Surface camera that rotates to the left (BOB & TTM) +#define SURFACE_CAMERA_ROTATE_LEFT 0x0070 // Surface camera that rotates to the left (BoB & TTM) #define SURFACE_CAMERA_BOUNDARY 0x0072 // Intangible Area, only used to restrict camera movement #define SURFACE_NOISE_VERY_SLIPPERY_73 0x0073 // Very slippery floor with noise, unused #define SURFACE_NOISE_VERY_SLIPPERY_74 0x0074 // Very slippery floor with noise, unused @@ -60,9 +60,9 @@ #define SURFACE_NO_CAM_COL_SLIPPERY 0x0079 // Surface with no cam collision flag, slippery with noise (CCM, PSS and TTM slides) #define SURFACE_SWITCH 0x007A // Surface with no cam collision flag, non-slippery with noise, used by switches and Dorrie #define SURFACE_VANISH_CAP_WALLS 0x007B // Vanish cap walls, pass through them with Vanish Cap -#define SURFACE_PAINTING_WOBBLE_A6 0x00A6 // Painting wobble (BOB Left) -#define SURFACE_PAINTING_WOBBLE_A7 0x00A7 // Painting wobble (BOB Middle) -#define SURFACE_PAINTING_WOBBLE_A8 0x00A8 // Painting wobble (BOB Right) +#define SURFACE_PAINTING_WOBBLE_A6 0x00A6 // Painting wobble (BoB Left) +#define SURFACE_PAINTING_WOBBLE_A7 0x00A7 // Painting wobble (BoB Middle) +#define SURFACE_PAINTING_WOBBLE_A8 0x00A8 // Painting wobble (BoB Right) #define SURFACE_PAINTING_WOBBLE_A9 0x00A9 // Painting wobble (CCM Left) #define SURFACE_PAINTING_WOBBLE_AA 0x00AA // Painting wobble (CCM Middle) #define SURFACE_PAINTING_WOBBLE_AB 0x00AB // Painting wobble (CCM Right) @@ -105,9 +105,9 @@ #define SURFACE_PAINTING_WOBBLE_D0 0x00D0 // Painting wobble (HMC & COTMC - Left), makes the painting wobble if touched #define SURFACE_PAINTING_WOBBLE_D1 0x00D1 // Painting wobble (Unused, HMC & COTMC - Middle) #define SURFACE_PAINTING_WOBBLE_D2 0x00D2 // Painting wobble (Unused, HMC & COTMC - Right) -#define SURFACE_PAINTING_WARP_D3 0x00D3 // Painting warp (BOB Left) -#define SURFACE_PAINTING_WARP_D4 0x00D4 // Painting warp (BOB Middle) -#define SURFACE_PAINTING_WARP_D5 0x00D5 // Painting warp (BOB Right) +#define SURFACE_PAINTING_WARP_D3 0x00D3 // Painting warp (BoB Left) +#define SURFACE_PAINTING_WARP_D4 0x00D4 // Painting warp (BoB Middle) +#define SURFACE_PAINTING_WARP_D5 0x00D5 // Painting warp (BoB Right) #define SURFACE_PAINTING_WARP_D6 0x00D6 // Painting warp (CCM Left) #define SURFACE_PAINTING_WARP_D7 0x00D7 // Painting warp (CCM Middle) #define SURFACE_PAINTING_WARP_D8 0x00D8 // Painting warp (CCM Right) diff --git a/include/types.h b/include/types.h index 5b092bb0..150de575 100644 --- a/include/types.h +++ b/include/types.h @@ -20,8 +20,7 @@ #endif -struct Controller -{ +struct Controller { /*0x00*/ s16 rawStickX; // /*0x02*/ s16 rawStickY; // /*0x04*/ float stickX; // [-64, 64] positive is right @@ -63,16 +62,14 @@ enum SpTaskState { SPTASK_STATE_FINISHED_DP }; -struct SPTask -{ +struct SPTask { /*0x00*/ OSTask task; /*0x40*/ OSMesgQueue *msgqueue; /*0x44*/ OSMesg msg; /*0x48*/ enum SpTaskState state; }; // size = 0x4C, align = 0x8 -struct VblankHandler -{ +struct VblankHandler { OSMesgQueue *queue; OSMesg msg; }; @@ -100,8 +97,7 @@ struct Animation { #define ANIMINDEX_NUMPARTS(animindex) (sizeof(animindex) / sizeof(u16) / 6 - 1) -struct GraphNode -{ +struct GraphNode { /*0x00*/ s16 type; // structure type /*0x02*/ s16 flags; // hi = drawing layer, lo = rendering modes /*0x04*/ struct GraphNode *prev; @@ -110,8 +106,7 @@ struct GraphNode /*0x10*/ struct GraphNode *children; }; -struct AnimInfo -{ +struct AnimInfo { /*0x00 0x38*/ s16 animID; /*0x02 0x3A*/ s16 animYTrans; /*0x04 0x3C*/ struct Animation *curAnim; @@ -121,8 +116,7 @@ struct AnimInfo /*0x10 0x48*/ s32 animAccel; }; -struct GraphNodeObject -{ +struct GraphNodeObject { /*0x00*/ struct GraphNode node; /*0x14*/ struct GraphNode *sharedChild; /*0x18*/ s8 areaIndex; @@ -136,8 +130,7 @@ struct GraphNodeObject /*0x54*/ Vec3f cameraToObject; }; -struct ObjectNode -{ +struct ObjectNode { struct GraphNodeObject gfx; struct ObjectNode *next; struct ObjectNode *prev; @@ -146,8 +139,7 @@ struct ObjectNode // NOTE: Since ObjectNode is the first member of Object, it is difficult to determine // whether some of these pointers point to ObjectNode or Object. -struct Object -{ +struct Object { /*0x000*/ struct ObjectNode header; /*0x068*/ struct Object *parentObj; /*0x06C*/ struct Object *prevObj; @@ -156,8 +148,7 @@ struct Object /*0x076*/ s16 numCollidedObjs; /*0x078*/ struct Object *collidedObjs[4]; /*0x088*/ - union - { + union { // Object fields. See object_fields.h. u32 asU32[0x50]; s32 asS32[0x50]; @@ -207,8 +198,7 @@ struct Object /*0x25C*/ void *respawnInfo; }; -struct ObjectHitbox -{ +struct ObjectHitbox { /*0x00*/ u32 interactType; /*0x04*/ u8 downOffset; /*0x05*/ s8 damageOrCoinValue; @@ -220,14 +210,12 @@ struct ObjectHitbox /*0x0E*/ s16 hurtboxHeight; }; -struct Waypoint -{ +struct Waypoint { s16 flags; Vec3s pos; }; -struct Surface -{ +struct Surface { /*0x00*/ s16 type; /*0x02*/ s16 force; /*0x04*/ s8 flags; @@ -246,8 +234,7 @@ struct Surface /*0x2C*/ struct Object *object; }; -struct MarioBodyState -{ +struct MarioBodyState { /*0x00*/ u32 action; /*0x04*/ s8 capState; /// see MarioCapGSCId /*0x05*/ s8 eyeState; @@ -259,11 +246,10 @@ struct MarioBodyState /*0x0C*/ Vec3s torsoAngle; /*0x12*/ Vec3s headAngle; /*0x18*/ Vec3f heldObjLastPosition; /// also known as HOLP - u8 padding[4]; + u8 filler[4]; }; -struct MarioState -{ +struct MarioState { /*0x00*/ u16 unk00; /*0x02*/ u16 input; /*0x04*/ u32 flags; diff --git a/levels/bbh/areas/1/collision.inc.c b/levels/bbh/areas/1/collision.inc.c index e17311a8..1abb9baf 100644 --- a/levels/bbh/areas/1/collision.inc.c +++ b/levels/bbh/areas/1/collision.inc.c @@ -3742,7 +3742,7 @@ const Collision bbh_seg7_collision_level[] = { COL_TRI(12, 14, 15), COL_TRI_STOP(), COL_SPECIAL_INIT(26), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 1434, -204, 4710, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 1434, -204, 4710, /*yaw*/ 128), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_haunted_door, /*pos*/ 0, -2457, 2099, /*yaw*/ 128), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_haunted_door, /*pos*/ -1996, -2457, 205, /*yaw*/ 192), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_haunted_door, /*pos*/ 1587, -2457, 205, /*yaw*/ 64), diff --git a/levels/bitdw/areas/1/collision.inc.c b/levels/bitdw/areas/1/collision.inc.c index 21eb923f..1d4de531 100644 --- a/levels/bitdw/areas/1/collision.inc.c +++ b/levels/bitdw/areas/1/collision.inc.c @@ -1324,7 +1324,7 @@ const Collision bitdw_seg7_collision_level[] = { COL_TRI(485, 486, 489), COL_TRI_STOP(), COL_SPECIAL_INIT(23), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7443, -3153, 3886, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7443, -3153, 3886, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -6368, -3972, 3883, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ -3245, -3358, 3893, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_05, /*pos*/ -2405, -1228, 1740, /*yaw*/ 0), diff --git a/levels/bitfs/areas/1/collision.inc.c b/levels/bitfs/areas/1/collision.inc.c index 0307e25c..e88d3d17 100644 --- a/levels/bitfs/areas/1/collision.inc.c +++ b/levels/bitfs/areas/1/collision.inc.c @@ -2053,7 +2053,7 @@ const Collision bitfs_seg7_collision_level[] = { COL_TRI(801, 802, 509), COL_TRI_STOP(), COL_SPECIAL_INIT(24), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7577, -2764, 0, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7577, -2764, 0, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -5938, -3071, 0, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ -5488, -1535, 41, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ 4342, 1741, 41, /*yaw*/ 0), diff --git a/levels/bits/areas/1/collision.inc.c b/levels/bits/areas/1/collision.inc.c index 130a24fe..af2e6c24 100644 --- a/levels/bits/areas/1/collision.inc.c +++ b/levels/bits/areas/1/collision.inc.c @@ -2400,7 +2400,7 @@ const Collision bits_seg7_collision_level[] = { COL_TRI(135, 216, 214), COL_TRI_STOP(), COL_SPECIAL_INIT(22), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7039, -4812, 4, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7039, -4812, 4, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -4505, -5119, 0, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ -2291, -2073, -762, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_05, /*pos*/ 3891, -3276, -705, /*yaw*/ 0), diff --git a/levels/bowser_1/areas/1/collision.inc.c b/levels/bowser_1/areas/1/collision.inc.c index 7593a37b..e2a25a55 100644 --- a/levels/bowser_1/areas/1/collision.inc.c +++ b/levels/bowser_1/areas/1/collision.inc.c @@ -77,7 +77,7 @@ const Collision bowser_1_seg7_collision_level[] = { COL_TRI(25, 27, 28), COL_TRI_STOP(), COL_SPECIAL_INIT(22), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 1843, 0, /*yaw*/ 1423), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 1843, 0, /*yaw*/ 1423), // unused, probably an early way to set initial position SPECIAL_OBJECT(/*preset*/ special_mine, /*pos*/ 2949, 589, 0), SPECIAL_OBJECT(/*preset*/ special_mine, /*pos*/ 0, 589, -2949), SPECIAL_OBJECT(/*preset*/ special_mine, /*pos*/ 0, 589, 2949), diff --git a/levels/bowser_2/areas/1/collision.inc.c b/levels/bowser_2/areas/1/collision.inc.c index 6853832e..628b171e 100644 --- a/levels/bowser_2/areas/1/collision.inc.c +++ b/levels/bowser_2/areas/1/collision.inc.c @@ -19,7 +19,7 @@ const Collision bowser_2_seg7_collision_lava[] = { COL_TRI(0, 5, 7), COL_TRI_STOP(), COL_SPECIAL_INIT(2), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 1229, 0, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 1229, 0, /*yaw*/ 128), // unused, probably an early way to set initial position SPECIAL_OBJECT(/*preset*/ special_bowser, /*pos*/ -8, 1229, -1418), COL_END(), }; diff --git a/levels/bowser_3/areas/1/collision.inc.c b/levels/bowser_3/areas/1/collision.inc.c index 20b0ef3a..68d64090 100644 --- a/levels/bowser_3/areas/1/collision.inc.c +++ b/levels/bowser_3/areas/1/collision.inc.c @@ -68,7 +68,7 @@ const Collision bowser_3_seg7_collision_level[] = { COL_TRI(0, 2, 3), COL_TRI_STOP(), COL_SPECIAL_INIT(7), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 307, 0, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 307, 0, /*yaw*/ 128), // unused, probably an early way to set initial position SPECIAL_OBJECT(/*preset*/ special_bowser, /*pos*/ 13, 307, -1024), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -3362, -204, 1121, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 0, -204, 3584, /*yaw*/ 0), diff --git a/levels/castle_courtyard/areas/1/collision.inc.c b/levels/castle_courtyard/areas/1/collision.inc.c index 14ea0d13..8d1f2bd3 100644 --- a/levels/castle_courtyard/areas/1/collision.inc.c +++ b/levels/castle_courtyard/areas/1/collision.inc.c @@ -847,7 +847,7 @@ const Collision castle_courtyard_seg7_collision[] = { COL_TRI(136, 45, 133), COL_TRI_STOP(), COL_SPECIAL_INIT(19), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 15, 0, 202, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 15, 0, 202, /*yaw*/ 128), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 0, 2048, 2662, /*yaw*/ 0), SPECIAL_OBJECT(/*preset*/ special_spiky_tree, /*pos*/ 2272, -214, -1432), SPECIAL_OBJECT(/*preset*/ special_spiky_tree, /*pos*/ 818, 10, 203), diff --git a/levels/castle_inside/areas/1/collision.inc.c b/levels/castle_inside/areas/1/collision.inc.c index 57455efc..a081bccf 100644 --- a/levels/castle_inside/areas/1/collision.inc.c +++ b/levels/castle_inside/areas/1/collision.inc.c @@ -3741,7 +3741,7 @@ const Collision inside_castle_seg7_area_1_collision[] = { COL_TRI(77, 79, 80), COL_TRI_STOP(), COL_SPECIAL_INIT(11), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -1023, 0, 1152, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -1023, 0, 1152, /*yaw*/ 128), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_wooden_door, /*pos*/ -271, 0, -824, /*yaw*/ 32), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_wooden_door, /*pos*/ -1775, 0, -824, /*yaw*/ 224), SPECIAL_OBJECT_WITH_YAW_AND_PARAM(/*preset*/ special_castle_door_warp, /*pos*/ -1100, 0, 2202, /*yaw*/ 0, /*behParam2*/ 0), diff --git a/levels/ccm/areas/1/collision.inc.c b/levels/ccm/areas/1/collision.inc.c index 33167b31..45068372 100644 --- a/levels/ccm/areas/1/collision.inc.c +++ b/levels/ccm/areas/1/collision.inc.c @@ -1747,7 +1747,7 @@ const Collision ccm_seg7_area_1_collision[] = { COL_TRI(336, 609, 616), COL_TRI_STOP(), COL_SPECIAL_INIT(21), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -1512, 2560, -2305, /*yaw*/ 100), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -1512, 2560, -2305, /*yaw*/ 100), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -409, 2765, -1637, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ 2355, -4095, 4096, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_05, /*pos*/ -4210, -1446, 1874, /*yaw*/ 0), diff --git a/levels/ccm/areas/2/collision.inc.c b/levels/ccm/areas/2/collision.inc.c index df408822..d75bdf58 100644 --- a/levels/ccm/areas/2/collision.inc.c +++ b/levels/ccm/areas/2/collision.inc.c @@ -1873,7 +1873,7 @@ const Collision ccm_seg7_area_2_collision[] = { COL_TRI(19, 23, 24), COL_TRI_STOP(), COL_SPECIAL_INIT(2), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -5836, 7465, -6143, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -5836, 7465, -6143, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW_AND_PARAM(/*preset*/ special_wooden_door_warp, /*pos*/ -7628, -5836, -6988, /*yaw*/ 64, /*behParam2*/ 20), COL_END(), }; diff --git a/levels/cotmc/areas/1/collision.inc.c b/levels/cotmc/areas/1/collision.inc.c index c9c1c7ac..b4f27890 100644 --- a/levels/cotmc/areas/1/collision.inc.c +++ b/levels/cotmc/areas/1/collision.inc.c @@ -990,7 +990,7 @@ const Collision cotmc_seg7_collision_level[] = { COL_TRI(208, 206, 207), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -4185, 20, -47, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -4185, 20, -47, /*yaw*/ 64), // unused, probably an early way to set initial position COL_WATER_BOX_INIT(1), COL_WATER_BOX(0, -1535, -7679, 1536, 3389, 0), COL_END(), diff --git a/levels/hmc/areas/1/collision.inc.c b/levels/hmc/areas/1/collision.inc.c index 341486c1..4fe8d829 100644 --- a/levels/hmc/areas/1/collision.inc.c +++ b/levels/hmc/areas/1/collision.inc.c @@ -3599,7 +3599,7 @@ const Collision hmc_seg7_collision_level[] = { COL_TRI(55, 58, 56), COL_TRI_STOP(), COL_SPECIAL_INIT(13), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7601, 2253, 7630, /*yaw*/ 96), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7601, 2253, 7630, /*yaw*/ 96), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_wooden_door, /*pos*/ 922, -4689, 2330, /*yaw*/ 192), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_wooden_door, /*pos*/ -3586, 1536, 647, /*yaw*/ 19), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_wooden_door, /*pos*/ 5911, -204, 870, /*yaw*/ 0), diff --git a/levels/jrb/areas/1/collision.inc.c b/levels/jrb/areas/1/collision.inc.c index f4a1c8a4..cb0eba6d 100644 --- a/levels/jrb/areas/1/collision.inc.c +++ b/levels/jrb/areas/1/collision.inc.c @@ -872,7 +872,7 @@ const Collision jrb_seg7_area_1_collision[] = { COL_TRI(7, 5, 0), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -6750, 1126, 1482, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -6750, 1126, 1482, /*yaw*/ 64), // unused, probably an early way to set initial position COL_WATER_BOX_INIT(3), COL_WATER_BOX(0, -6304, -669, 7992, 7814, 1024), COL_WATER_BOX(1, 4433, -4253, 5969, -669, -3016), diff --git a/levels/jrb/areas/1/movtext.inc.c b/levels/jrb/areas/1/movtext.inc.c index 12759f4f..8985f222 100644 --- a/levels/jrb/areas/1/movtext.inc.c +++ b/levels/jrb/areas/1/movtext.inc.c @@ -35,8 +35,8 @@ const struct MovtexQuadCollection jrb_movtex_water[] = { {-1, NULL}, }; -// 0x0700D2E4, appears if you enter the course the first time, then it disappears when you grab the first star -static Movtex jrb_movtex_intial_mist_data[] = { +// 0x0700D2E4, appears if you enter the course the first time, then it disappears when you collect the "Plunder in the Sunken Ship" star +static Movtex jrb_movtex_initial_mist_data[] = { MOV_TEX_INIT_LOAD( 1), MOV_TEX_ROT_SPEED( 20), MOV_TEX_ROT_SCALE( 10), @@ -51,7 +51,7 @@ static Movtex jrb_movtex_intial_mist_data[] = { }; // 0x0700D304 -const struct MovtexQuadCollection jrb_movtex_intial_mist[] = { - {51, jrb_movtex_intial_mist_data}, +const struct MovtexQuadCollection jrb_movtex_initial_mist[] = { + {51, jrb_movtex_initial_mist_data}, {-1, NULL}, }; diff --git a/levels/jrb/areas/2/collision.inc.c b/levels/jrb/areas/2/collision.inc.c index 31d002a0..f91b3e0c 100644 --- a/levels/jrb/areas/2/collision.inc.c +++ b/levels/jrb/areas/2/collision.inc.c @@ -584,7 +584,7 @@ const Collision jrb_seg7_area_2_collision[] = { COL_TRI(29, 79, 80), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 866, 798, -1248, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 866, 798, -1248, /*yaw*/ 128), // unused, probably an early way to set initial position COL_WATER_BOX_INIT(1), COL_WATER_BOX(0, -4095, -4095, 4096, 4096, 2765), COL_END(), diff --git a/levels/jrb/areas/2/movtext.inc.c b/levels/jrb/areas/2/movtext.inc.c index 90e466a7..958f9844 100644 --- a/levels/jrb/areas/2/movtext.inc.c +++ b/levels/jrb/areas/2/movtext.inc.c @@ -1,5 +1,5 @@ // 0x0701137C -static Movtex jrb_movtex_sinked_boat_water_data[] = { +static Movtex jrb_movtex_sunken_ship_water_data[] = { MOV_TEX_INIT_LOAD( 1), MOV_TEX_ROT_SPEED( 20), MOV_TEX_ROT_SCALE( 6), @@ -14,7 +14,7 @@ static Movtex jrb_movtex_sinked_boat_water_data[] = { }; // 0x0701139C -const struct MovtexQuadCollection jrb_movtex_sinked_boat_water[] = { - {0, jrb_movtex_sinked_boat_water_data}, +const struct MovtexQuadCollection jrb_movtex_sunken_ship_water[] = { + {0, jrb_movtex_sunken_ship_water_data}, {-1, NULL}, }; diff --git a/levels/jrb/header.h b/levels/jrb/header.h index c6887382..f142c5c0 100644 --- a/levels/jrb/header.h +++ b/levels/jrb/header.h @@ -52,13 +52,13 @@ extern const Collision jrb_seg7_collision_0700D1DC[]; extern const Trajectory jrb_seg7_trajectory_unagi_1[]; extern const Trajectory jrb_seg7_trajectory_unagi_2[]; extern const struct MovtexQuadCollection jrb_movtex_water[]; -extern const struct MovtexQuadCollection jrb_movtex_intial_mist[]; +extern const struct MovtexQuadCollection jrb_movtex_initial_mist[]; extern const Gfx jrb_seg7_dl_0700EF00[]; extern const Gfx jrb_seg7_dl_0700FE48[]; extern const Gfx jrb_seg7_dl_07010548[]; extern const Collision jrb_seg7_area_2_collision[]; extern const MacroObject jrb_seg7_area_2_macro_objs[]; -extern const struct MovtexQuadCollection jrb_movtex_sinked_boat_water[]; +extern const struct MovtexQuadCollection jrb_movtex_sunken_ship_water[]; // script extern const LevelScript level_jrb_entry[]; diff --git a/levels/lll/areas/1/collision.inc.c b/levels/lll/areas/1/collision.inc.c index ce5e107d..10047658 100644 --- a/levels/lll/areas/1/collision.inc.c +++ b/levels/lll/areas/1/collision.inc.c @@ -1376,7 +1376,7 @@ const Collision lll_seg7_area_1_collision[] = { COL_TRI(10, 52, 3), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -3839, 154, 6272, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -3839, 154, 6272, /*yaw*/ 64), // unused, probably an early way to set initial position COL_END(), #else COL_INIT(), @@ -2730,7 +2730,7 @@ const Collision lll_seg7_area_1_collision[] = { COL_TRI(3, 52, 71), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -3839, 154, 6272, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -3839, 154, 6272, /*yaw*/ 64), // unused, probably an early way to set initial position COL_END(), #endif }; diff --git a/levels/lll/areas/2/collision.inc.c b/levels/lll/areas/2/collision.inc.c index 65d5b898..2e747d31 100644 --- a/levels/lll/areas/2/collision.inc.c +++ b/levels/lll/areas/2/collision.inc.c @@ -1549,7 +1549,7 @@ const Collision lll_seg7_area_2_collision[] = { COL_TRI(324, 451, 450), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -955, 103, -1029, /*yaw*/ 84), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -955, 103, -1029, /*yaw*/ 84), // unused, probably an early way to set initial position COL_WATER_BOX_INIT(1), COL_WATER_BOX(10, -3071, -3071, 3072, 3072, 20), COL_END(), diff --git a/levels/rr/areas/1/collision.inc.c b/levels/rr/areas/1/collision.inc.c index aa0a8487..ddd55ec0 100644 --- a/levels/rr/areas/1/collision.inc.c +++ b/levels/rr/areas/1/collision.inc.c @@ -2694,7 +2694,7 @@ const Collision rr_seg7_collision_level[] = { COL_TRI_SPECIAL(31, 46, 45, 0x140), COL_TRI_STOP(), COL_SPECIAL_INIT(23), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 2599, -1833, 2071, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 2599, -1833, 2071, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 1902, -1833, 1063, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ 3803, -1833, 2036, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_05, /*pos*/ -4888, -2550, 5847, /*yaw*/ 0), @@ -5419,7 +5419,7 @@ const Collision rr_seg7_collision_level[] = { COL_TRI_SPECIAL(35, 46, 47, 0x100), COL_TRI_STOP(), COL_SPECIAL_INIT(23), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 2599, -1833, 2071, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 2599, -1833, 2071, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 1902, -1833, 1063, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ 3803, -1833, 2036, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_05, /*pos*/ -4888, -2550, 5847, /*yaw*/ 0), diff --git a/levels/sa/areas/1/collision.inc.c b/levels/sa/areas/1/collision.inc.c index 6d823ab2..c4806fd1 100644 --- a/levels/sa/areas/1/collision.inc.c +++ b/levels/sa/areas/1/collision.inc.c @@ -105,7 +105,7 @@ const Collision sa_seg7_collision[] = { COL_TRI(30, 47, 12), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, -1535, 0, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, -1535, 0, /*yaw*/ 64), // unused, probably an early way to set initial position COL_WATER_BOX_INIT(1), COL_WATER_BOX(0, -3173, -3173, 3174, 3174, 102), COL_END(), diff --git a/levels/sl/areas/1/collision.inc.c b/levels/sl/areas/1/collision.inc.c index 8dab56df..b5579698 100644 --- a/levels/sl/areas/1/collision.inc.c +++ b/levels/sl/areas/1/collision.inc.c @@ -1423,7 +1423,7 @@ const Collision sl_seg7_area_1_collision[] = { COL_TRI(510, 327, 321), COL_TRI_STOP(), COL_SPECIAL_INIT(10), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 5541, 1024, 443, /*yaw*/ 192), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 5541, 1024, 443, /*yaw*/ 192), // unused, probably an early way to set initial position SPECIAL_OBJECT(/*preset*/ special_snow_tree, /*pos*/ 5395, 1054, -5443), SPECIAL_OBJECT(/*preset*/ special_snow_tree, /*pos*/ 0, 4864, 0), SPECIAL_OBJECT(/*preset*/ special_snow_tree, /*pos*/ 5666, 1024, -3341), diff --git a/levels/sl/areas/2/collision.inc.c b/levels/sl/areas/2/collision.inc.c index 7b1d55c4..6a0ce64f 100644 --- a/levels/sl/areas/2/collision.inc.c +++ b/levels/sl/areas/2/collision.inc.c @@ -407,7 +407,7 @@ const Collision sl_seg7_area_2_collision[] = { COL_TRI(146, 187, 145), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 0, 2867, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 0, 2867, /*yaw*/ 128), // unused, probably an early way to set initial position COL_END(), }; diff --git a/levels/ssl/areas/1/collision.inc.c b/levels/ssl/areas/1/collision.inc.c index 80f9c40a..64e77cf6 100644 --- a/levels/ssl/areas/1/collision.inc.c +++ b/levels/ssl/areas/1/collision.inc.c @@ -1554,7 +1554,7 @@ const Collision ssl_seg7_area_1_collision[] = { COL_TRI(482, 483, 484), COL_TRI_STOP(), COL_SPECIAL_INIT(7), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 653, 38, 6566, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 653, 38, 6566, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 5760, 0, 5751, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -3583, 0, 2935, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -511, 0, 2935, /*yaw*/ 0), diff --git a/levels/ssl/areas/2/collision.inc.c b/levels/ssl/areas/2/collision.inc.c index a305da02..2a960a73 100644 --- a/levels/ssl/areas/2/collision.inc.c +++ b/levels/ssl/areas/2/collision.inc.c @@ -2655,7 +2655,7 @@ const Collision ssl_seg7_area_2_collision[] = { COL_TRI(359, 420, 419), COL_TRI_STOP(), COL_SPECIAL_INIT(4), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 0, 6451, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 0, 0, 6451, /*yaw*/ 128), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ 1741, -101, 1843, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ 0, -101, 528, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_04, /*pos*/ -1740, -101, 1843, /*yaw*/ 0), diff --git a/levels/thi/areas/1/collision.inc.c b/levels/thi/areas/1/collision.inc.c index 3e1f44f8..75e14627 100644 --- a/levels/thi/areas/1/collision.inc.c +++ b/levels/thi/areas/1/collision.inc.c @@ -1256,7 +1256,7 @@ const Collision thi_seg7_area_1_collision[] = { COL_TRI(412, 320, 319), COL_TRI_STOP(), COL_SPECIAL_INIT(2), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7372, -2969, 7373, /*yaw*/ 106), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -7372, -2969, 7373, /*yaw*/ 106), // unused, probably an early way to set initial position SPECIAL_OBJECT(/*preset*/ special_bubble_tree, /*pos*/ 4813, -511, 2254), COL_WATER_BOX_INIT(3), COL_WATER_BOX(0, -8191, -8191, -5119, 6246, -3071), diff --git a/levels/thi/areas/2/collision.inc.c b/levels/thi/areas/2/collision.inc.c index e47fe1c1..dce7d94a 100644 --- a/levels/thi/areas/2/collision.inc.c +++ b/levels/thi/areas/2/collision.inc.c @@ -970,7 +970,7 @@ const Collision thi_seg7_area_2_collision[] = { COL_TRI(244, 25, 148), COL_TRI_STOP(), COL_SPECIAL_INIT(3), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -2211, -890, 2212, /*yaw*/ 106), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -2211, -890, 2212, /*yaw*/ 106), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -40, -767, -4494, /*yaw*/ 0), SPECIAL_OBJECT(/*preset*/ special_bubble_tree, /*pos*/ 1444, -153, 676), COL_WATER_BOX_INIT(3), diff --git a/levels/totwc/areas/1/collision.inc.c b/levels/totwc/areas/1/collision.inc.c index 38ef427d..fb8816b1 100644 --- a/levels/totwc/areas/1/collision.inc.c +++ b/levels/totwc/areas/1/collision.inc.c @@ -587,7 +587,7 @@ const Collision totwc_seg7_collision[] = { COL_TRI(81, 97, 67), COL_TRI_STOP(), COL_SPECIAL_INIT(23), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -4095, 2935, 0, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -4095, 2935, 0, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 4608, -357, -511, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -4095, 666, 512, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -5631, -1893, 6144, /*yaw*/ 0), diff --git a/levels/ttc/areas/1/collision.inc.c b/levels/ttc/areas/1/collision.inc.c index 4eaba6ea..5fc0f7cb 100644 --- a/levels/ttc/areas/1/collision.inc.c +++ b/levels/ttc/areas/1/collision.inc.c @@ -1890,6 +1890,6 @@ const Collision ttc_seg7_collision_level[] = { COL_TRI(526, 625, 624), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 1046, -4822, -266, /*yaw*/ 192), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 1046, -4822, -266, /*yaw*/ 192), // unused, probably an early way to set initial position COL_END(), }; diff --git a/levels/ttm/areas/1/collision.inc.c b/levels/ttm/areas/1/collision.inc.c index f31d8ffb..dd923702 100644 --- a/levels/ttm/areas/1/collision.inc.c +++ b/levels/ttm/areas/1/collision.inc.c @@ -2293,7 +2293,7 @@ const Collision ttm_seg7_area_1_collision[] = { COL_TRI(516, 430, 819), COL_TRI_STOP(), COL_SPECIAL_INIT(29), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 102, -4332, 5734, /*yaw*/ 32), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 102, -4332, 5734, /*yaw*/ 32), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ -3276, -4423, -3685, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 7293, -5056, 1429, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_03, /*pos*/ 4938, -5568, 5115, /*yaw*/ 0), diff --git a/levels/vcutm/areas/1/collision.inc.c b/levels/vcutm/areas/1/collision.inc.c index 99de3350..f0489e16 100644 --- a/levels/vcutm/areas/1/collision.inc.c +++ b/levels/vcutm/areas/1/collision.inc.c @@ -844,6 +844,6 @@ const Collision vcutm_seg7_collision[] = { COL_TRI(40, 27, 30), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -6143, 5734, -6143, /*yaw*/ 0), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -6143, 5734, -6143, /*yaw*/ 0), // unused, probably an early way to set initial position COL_END(), }; diff --git a/levels/wdw/areas/1/collision.inc.c b/levels/wdw/areas/1/collision.inc.c index 122c3d62..b4901bc7 100644 --- a/levels/wdw/areas/1/collision.inc.c +++ b/levels/wdw/areas/1/collision.inc.c @@ -1345,7 +1345,7 @@ const Collision wdw_seg7_area_1_collision[] = { COL_TRI(85, 159, 157), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 3395, 1280, 384, /*yaw*/ 128), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 3395, 1280, 384, /*yaw*/ 128), // unused, probably an early way to set initial position COL_WATER_BOX_INIT(1), COL_WATER_BOX(0, -3839, -3839, 4608, 4608, 31), COL_END(), diff --git a/levels/wf/areas/1/collision.inc.c b/levels/wf/areas/1/collision.inc.c index 19301158..3a13fd68 100644 --- a/levels/wf/areas/1/collision.inc.c +++ b/levels/wf/areas/1/collision.inc.c @@ -1075,7 +1075,7 @@ const Collision wf_seg7_collision_070102D8[] = { COL_TRI(4, 7, 5), COL_TRI_STOP(), COL_SPECIAL_INIT(6), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 2560, 256, 5120, /*yaw*/ 64), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ 2560, 256, 5120, /*yaw*/ 64), // unused, probably an early way to set initial position SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_0E, /*pos*/ 3584, 154, 4864, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_0F, /*pos*/ 4608, 256, 1792, /*yaw*/ 0), SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_level_geo_11, /*pos*/ -2499, 1792, -261, /*yaw*/ 0), diff --git a/levels/wmotr/areas/1/collision.inc.c b/levels/wmotr/areas/1/collision.inc.c index 82a8a7ce..1a3670fc 100644 --- a/levels/wmotr/areas/1/collision.inc.c +++ b/levels/wmotr/areas/1/collision.inc.c @@ -2055,6 +2055,6 @@ const Collision wmotr_seg7_collision[] = { COL_TRI(288, 286, 289), COL_TRI_STOP(), COL_SPECIAL_INIT(1), - SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -67, 1669, -16, /*yaw*/ 192), // unused, probably an early way to set intial position + SPECIAL_OBJECT_WITH_YAW(/*preset*/ special_null_start, /*pos*/ -67, 1669, -16, /*yaw*/ 192), // unused, probably an early way to set initial position COL_END(), }; diff --git a/lib/rsp.s b/lib/rsp.s index a315b445..42893f92 100644 --- a/lib/rsp.s +++ b/lib/rsp.s @@ -134,9 +134,9 @@ glabel rspF3DDataEnd glabel rspF3DDataStart #ifdef F3DZEX_GBI_2 .incbin "lib/PR/f3dex2/F3DZEX_NoN_data.bin" - #elseif F3DEX_GBI + #elif defined(F3DEX_GBI) .incbin "lib/PR/f3dex/F3DEX_data.bin" - #elseif F3DEX_GBI_2 + #elif defined(F3DEX_GBI_2) .incbin "lib/PR/f3dex2/F3DEX2_data.bin" #endif glabel rspF3DDataEnd diff --git a/lib/src/D_802F4380.c b/lib/src/D_802F4380.c index bc7fce24..7183ab1d 100644 --- a/lib/src/D_802F4380.c +++ b/lib/src/D_802F4380.c @@ -57,7 +57,7 @@ u32 D_802F4380() { return 1; } sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize); - sp30->sectorNum += 1; + sp30->sectorNum++; osEPiRawStartDma(__osDiskHandle, 1, 0x05000400, sp2c->dramAddr, sp2c->sectorSize); return 1; } @@ -77,8 +77,7 @@ u32 D_802F4380() { sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize); } sp34 = HW_REG(ASIC_BM_STATUS, u32); - if (((C1_SINGLE & sp34) && (C1_DOUBLE & sp34)) || (sp34 & MICRO_STATUS)) - { + if (((C1_SINGLE & sp34) && (C1_DOUBLE & sp34)) || (sp34 & MICRO_STATUS)) { if (sp2c->C1ErrNum > 3) { if (sp30->transferMode != 3 || sp30->sectorNum > 0x52) { sp30->errStatus = 17; @@ -89,7 +88,7 @@ u32 D_802F4380() { sp28 = sp2c->C1ErrNum; sp2c->C1ErrSector[sp28] = sp30->sectorNum + 1; } - sp2c->C1ErrNum += 1; + sp2c->C1ErrNum++; } if (sp3c & C2_TRANSFER) { if (sp30->sectorNum != 87) { @@ -123,7 +122,7 @@ u32 D_802F4380() { sp30->errStatus = 0; func_802F4B08(); } - sp30->sectorNum += 1; + sp30->sectorNum++; if (sp3c & DATA_REQUEST) { if (sp30->sectorNum > 0x54) { sp30->errStatus = 6; diff --git a/lib/src/__osViInit.c b/lib/src/__osViInit.c index 980c7b89..9e0c9163 100644 --- a/lib/src/__osViInit.c +++ b/lib/src/__osViInit.c @@ -1,14 +1,6 @@ #include "libultra_internal.h" #include "hardware.h" -#ifdef VERSION_SH -extern s32 D_SH_80000300; // Potentially a TV type -#endif - -#ifndef VERSION_JP -extern u32 osTvType; -#endif - OSViContext sViContexts[2] = { 0 }; OSViContext *__osViCurr = &sViContexts[0]; OSViContext *__osViNext = &sViContexts[1]; @@ -80,6 +72,7 @@ void __osViInit(void) { osViClock = 0x02E6025C; #endif } + #endif __osViNext->unk00 = 0x20; diff --git a/lib/src/func_802F4A20.c b/lib/src/func_802F4A20.c index c38c23a4..499697d8 100644 --- a/lib/src/func_802F4A20.c +++ b/lib/src/func_802F4A20.c @@ -32,7 +32,7 @@ void func_802F4B08(void) { } sp24 = (sp28->first + sp28->validCount) % sp28->msgCount; sp28->msg[sp24] = sp2c->msg; - sp28->validCount += 1; + sp28->validCount++; if (sp28->mtqueue->next != NULL) { s0 = __osPopThread(&sp28->mtqueue); __osEnqueueThread(&D_80334898, s0); diff --git a/lib/src/leointerrupt.c b/lib/src/leointerrupt.c index ee66cf0b..83a4f39e 100644 --- a/lib/src/leointerrupt.c +++ b/lib/src/leointerrupt.c @@ -93,7 +93,7 @@ s32 __osLeoInterrupt() { int errNum = blockInfo->C1ErrNum; blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; } - blockInfo->C1ErrNum += 1; + blockInfo->C1ErrNum++; } if (stat & LEO_STATUS_C2_TRANSFER) { if (info->sectorNum != 87) { diff --git a/lib/src/osCreateViManager.c b/lib/src/osCreateViManager.c index 7c971826..67776ed6 100644 --- a/lib/src/osCreateViManager.c +++ b/lib/src/osCreateViManager.c @@ -13,8 +13,8 @@ static OSIoMesg viEventCounterMesg; extern void __osTimerServicesInit(void); extern void __osTimerInterrupt(void); -extern OSTime _osCurrentTime; -extern u32 D_80365DA8; +extern OSTime __osCurrentTime; +extern u32 __osBaseCounter; extern u32 __osViIntrCount; void viMgrMain(void *); @@ -92,13 +92,13 @@ void viMgrMain(void *vargs) { __osViIntrCount++; if (sp28) { sp24 = osGetCount(); - _osCurrentTime = sp24; + __osCurrentTime = sp24; sp28 = 0; } - sp24 = D_80365DA8; - D_80365DA8 = osGetCount(); - sp24 = D_80365DA8 - sp24; - _osCurrentTime = _osCurrentTime + sp24; + sp24 = __osBaseCounter; + __osBaseCounter = osGetCount(); + sp24 = __osBaseCounter - sp24; + __osCurrentTime = __osCurrentTime + sp24; break; case 14: diff --git a/lib/src/osEepromLongRead.c b/lib/src/osEepromLongRead.c index b9884abf..3260d138 100644 --- a/lib/src/osEepromLongRead.c +++ b/lib/src/osEepromLongRead.c @@ -20,7 +20,7 @@ s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { } nbytes -= 8; - address += 1; + address++; buffer += 8; osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff); osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK); diff --git a/lib/src/osEepromLongWrite.c b/lib/src/osEepromLongWrite.c index ef09fa92..69d367e3 100644 --- a/lib/src/osEepromLongWrite.c +++ b/lib/src/osEepromLongWrite.c @@ -21,7 +21,7 @@ s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { } nbytes -= 8; - address += 1; + address++; buffer += 8; osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff); osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK); diff --git a/lib/src/osGetTime.c b/lib/src/osGetTime.c index 93dc8cbe..45cef5ca 100644 --- a/lib/src/osGetTime.c +++ b/lib/src/osGetTime.c @@ -1,17 +1,18 @@ #include "libultra_internal.h" -extern OSTime _osCurrentTime; -extern u32 D_80365DA8; +extern OSTime __osCurrentTime; +extern u32 __osBaseCounter; OSTime osGetTime() { - u32 sp34; - u32 sp30; - OSTime sp28; - register u32 int_disabled; - int_disabled = __osDisableInt(); - sp34 = osGetCount(); - sp30 = sp34 - D_80365DA8; - sp28 = _osCurrentTime; - __osRestoreInt(int_disabled); - return sp28 + sp30; + u32 tmpTime; + u32 elapseCount; + OSTime currentCount; + register u32 saveMask; + + saveMask = __osDisableInt(); + tmpTime = osGetCount(); + elapseCount = tmpTime - __osBaseCounter; + currentCount = __osCurrentTime; + __osRestoreInt(saveMask); + return currentCount + elapseCount; } diff --git a/lib/src/osSetTime.c b/lib/src/osSetTime.c index ba906b69..cad09ab2 100644 --- a/lib/src/osSetTime.c +++ b/lib/src/osSetTime.c @@ -1,7 +1,7 @@ #include "libultra_internal.h" -extern OSTime _osCurrentTime; +extern OSTime __osCurrentTime; void osSetTime(OSTime time) { - _osCurrentTime = time; + __osCurrentTime = time; } diff --git a/lib/src/osSetTimer.c b/lib/src/osSetTimer.c index f7003b67..fc1258cf 100644 --- a/lib/src/osSetTimer.c +++ b/lib/src/osSetTimer.c @@ -1,23 +1,23 @@ #include "libultra_internal.h" -extern OSTimer *D_80334830; +extern OSTimer *__osTimerList; extern u64 __osInsertTimer(OSTimer *); -u32 osSetTimer(OSTimer *a0, OSTime a1, u64 a2, OSMesgQueue *a3, OSMesg a4) { - u64 sp18; - a0->next = NULL; - a0->prev = NULL; - a0->interval = a2; - if (a1 != 0) { - a0->remaining = a1; +u32 osSetTimer(OSTimer *t, OSTime countdown, OSTime interval, OSMesgQueue *mq, OSMesg msg) { + OSTime time; + t->next = NULL; + t->prev = NULL; + t->interval = interval; + if (countdown != 0) { + t->remaining = countdown; } else { - a0->remaining = a2; + t->remaining = interval; } - a0->mq = a3; - a0->msg = a4; - sp18 = __osInsertTimer(a0); - if (D_80334830->next == a0) { - __osSetTimerIntr(sp18); + t->mq = mq; + t->msg = msg; + time = __osInsertTimer(t); + if (__osTimerList->next == t) { + __osSetTimerIntr(time); } return 0; } diff --git a/lib/src/osTimer.c b/lib/src/osTimer.c index ffd0255f..2c13925b 100644 --- a/lib/src/osTimer.c +++ b/lib/src/osTimer.c @@ -1,88 +1,90 @@ #include "libultra_internal.h" -// TODO: document -OSTimer D_80365D80; -OSTimer *D_80334830 = &D_80365D80; -OSTime _osCurrentTime; -u32 D_80365DA8; +OSTimer __osBaseTimer; +OSTimer *__osTimerList = &__osBaseTimer; +OSTime __osCurrentTime; +u32 __osBaseCounter; u32 __osViIntrCount; -u32 D_80365DB0; +u32 __osTimerCounter; void __osTimerServicesInit(void) { - _osCurrentTime = 0; - D_80365DA8 = 0; + __osCurrentTime = 0; + __osBaseCounter = 0; __osViIntrCount = 0; - D_80334830->prev = D_80334830; - D_80334830->next = D_80334830->prev; - D_80334830->remaining = 0; - D_80334830->interval = D_80334830->remaining; - D_80334830->mq = NULL; - D_80334830->msg = NULL; + __osTimerList->prev = __osTimerList; + __osTimerList->next = __osTimerList->prev; + __osTimerList->remaining = 0; + __osTimerList->interval = __osTimerList->remaining; + __osTimerList->mq = NULL; + __osTimerList->msg = NULL; } void __osTimerInterrupt(void) { - OSTimer *sp24; - u32 sp20; - u32 sp1c; - if (D_80334830->next == D_80334830) { + OSTimer *t; + u32 count; + u32 elapsedCycles; + + if (__osTimerList->next == __osTimerList) { return; } + while (TRUE) { - sp24 = D_80334830->next; - if (sp24 == D_80334830) { + t = __osTimerList->next; + if (t == __osTimerList) { __osSetCompare(0); - D_80365DB0 = 0; + __osTimerCounter = 0; break; } - sp20 = osGetCount(); - sp1c = sp20 - D_80365DB0; - D_80365DB0 = sp20; - if (sp1c < sp24->remaining) { - sp24->remaining -= sp1c; - __osSetTimerIntr(sp24->remaining); + count = osGetCount(); + elapsedCycles = count - __osTimerCounter; + __osTimerCounter = count; + if (elapsedCycles < t->remaining) { + t->remaining -= elapsedCycles; + __osSetTimerIntr(t->remaining); return; } else { - sp24->prev->next = sp24->next; - sp24->next->prev = sp24->prev; - sp24->next = NULL; - sp24->prev = NULL; - if (sp24->mq != NULL) { - osSendMesg(sp24->mq, sp24->msg, OS_MESG_NOBLOCK); + t->prev->next = t->next; + t->next->prev = t->prev; + t->next = NULL; + t->prev = NULL; + if (t->mq != NULL) { + osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK); } - if (sp24->interval != 0) { - sp24->remaining = sp24->interval; - __osInsertTimer(sp24); + if (t->interval != 0) { + t->remaining = t->interval; + __osInsertTimer(t); } } } } -void __osSetTimerIntr(u64 a0) { - u64 tmp; - s32 intDisabled = __osDisableInt(); - D_80365DB0 = osGetCount(); - tmp = a0 + D_80365DB0; - __osSetCompare(tmp); - __osRestoreInt(intDisabled); +void __osSetTimerIntr(OSTime time) { + OSTime newTime; + s32 savedMask = __osDisableInt(); + __osTimerCounter = osGetCount(); + newTime = time + __osTimerCounter; + __osSetCompare(newTime); + __osRestoreInt(savedMask); } -u64 __osInsertTimer(OSTimer *a0) { - OSTimer *sp34; - u64 sp28; - s32 intDisabled; - intDisabled = __osDisableInt(); - for (sp34 = D_80334830->next, sp28 = a0->remaining; sp34 != D_80334830 && sp28 > sp34->remaining; - sp28 -= sp34->remaining, sp34 = sp34->next) { +OSTime __osInsertTimer(OSTimer *t) { + OSTimer *timep; + OSTime time; + s32 savedMask; + + savedMask = __osDisableInt(); + for (timep = __osTimerList->next, time = t->remaining; timep != __osTimerList && time > timep->remaining; + time -= timep->remaining, timep = timep->next) { ; } - a0->remaining = sp28; - if (sp34 != D_80334830) { - sp34->remaining -= sp28; + t->remaining = time; + if (timep != __osTimerList) { + timep->remaining -= time; } - a0->next = sp34; - a0->prev = sp34->prev; - sp34->prev->next = a0; - sp34->prev = a0; - __osRestoreInt(intDisabled); - return sp28; + t->next = timep; + t->prev = timep->prev; + timep->prev->next = t; + timep->prev = t; + __osRestoreInt(savedMask); + return time; } diff --git a/src/audio/external.c b/src/audio/external.c index a5edb5be..0c0283ff 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -2110,10 +2110,11 @@ void set_audio_muted(u8 muted) { for (i = 0; i < SEQUENCE_PLAYERS; i++) { #if defined(VERSION_EU) || defined(VERSION_SH) - if (muted) + if (muted) { func_802ad74c(0xf1000000, 0); - else + } else { func_802ad74c(0xf2000000, 0); + } #else gSequencePlayers[i].muted = muted; #endif diff --git a/src/audio/heap.c b/src/audio/heap.c index 08db2ead..4b84c001 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -82,8 +82,7 @@ void unk_pools_init(u32 size1, u32 size2); * Assuming 'k' in [9, 24], * Computes a newton's method step for f(x) = x^k - d */ -f64 root_newton_step(f64 x, s32 k, f64 d) -{ +f64 root_newton_step(f64 x, s32 k, f64 d) { f64 deg2 = x * x; f64 deg4 = deg2 * deg2; f64 deg8 = deg4 * deg4; diff --git a/src/audio/heap.h b/src/audio/heap.h index 4bc73bd3..7f9632b5 100644 --- a/src/audio/heap.h +++ b/src/audio/heap.h @@ -15,8 +15,7 @@ #define IS_BANK_LOAD_COMPLETE(bankId) (gBankLoadStatus[bankId] >= SOUND_LOAD_STATUS_COMPLETE) #define IS_SEQ_LOAD_COMPLETE(seqId) (gSeqLoadStatus[seqId] >= SOUND_LOAD_STATUS_COMPLETE) -struct SoundAllocPool -{ +struct SoundAllocPool { u8 *start; u8 *cur; u32 size; @@ -34,15 +33,13 @@ struct SeqOrBankEntry { #endif }; // size = 0xC -struct PersistentPool -{ +struct PersistentPool { /*0x00*/ u32 numEntries; /*0x04*/ struct SoundAllocPool pool; /*0x14*/ struct SeqOrBankEntry entries[32]; }; // size = 0x194 -struct TemporaryPool -{ +struct TemporaryPool { /*EU, SH*/ /*0x00, 0x00*/ u32 nextSide; /*0x04, */ struct SoundAllocPool pool; @@ -59,21 +56,18 @@ struct TemporaryPool /*0x28, 0x2A entries[1].id */ }; // size = 0x2C -struct SoundMultiPool -{ +struct SoundMultiPool { /*0x000*/ struct PersistentPool persistent; /*0x194*/ struct TemporaryPool temporary; /* */ u32 pad2[4]; }; // size = 0x1D0 -struct Unk1Pool -{ +struct Unk1Pool { struct SoundAllocPool pool; struct SeqOrBankEntry entries[32]; }; -struct UnkEntry -{ +struct UnkEntry { s8 used; s8 medium; s8 bankId; @@ -83,8 +77,7 @@ struct UnkEntry u32 size; }; -struct UnkPool -{ +struct UnkPool { /*0x00*/ struct SoundAllocPool pool; /*0x10*/ struct UnkEntry entries[64]; /*0x510*/ s32 numEntries; diff --git a/src/audio/internal.h b/src/audio/internal.h index 0924e073..f91c3a2e 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -93,8 +93,7 @@ struct NotePool; -struct AudioListItem -{ +struct AudioListItem { // A node in a circularly linked list. Each node is either a head or an item: // - Items can be either detached (prev = NULL), or attached to a list. // 'value' points to something of interest. @@ -111,8 +110,7 @@ struct AudioListItem struct NotePool *pool; }; // size = 0x10 -struct NotePool -{ +struct NotePool { struct AudioListItem disabled; struct AudioListItem decaying; struct AudioListItem releasing; @@ -154,8 +152,7 @@ struct AdsrEnvelope { s16 arg; }; // size = 0x4 -struct AdpcmLoop -{ +struct AdpcmLoop { u32 start; u32 end; u32 count; @@ -163,15 +160,13 @@ struct AdpcmLoop s16 state[16]; // only exists if count != 0. 8-byte aligned }; -struct AdpcmBook -{ +struct AdpcmBook { s32 order; s32 npredictors; s16 book[1]; // size 8 * order * npredictors. 8-byte aligned }; -struct AudioBankSample -{ +struct AudioBankSample { #ifdef VERSION_SH /* 0x00 */ u32 codec : 4; /* 0x00 */ u32 medium : 2; @@ -190,14 +185,12 @@ struct AudioBankSample #endif }; -struct AudioBankSound -{ +struct AudioBankSound { struct AudioBankSample *sample; f32 tuning; // frequency scale factor }; // size = 0x8 -struct Instrument -{ +struct Instrument { /*0x00*/ u8 loaded; /*0x01*/ u8 normalRangeLo; /*0x02*/ u8 normalRangeHi; @@ -208,8 +201,7 @@ struct Instrument /*0x18*/ struct AudioBankSound highNotesSound; }; // size = 0x20 -struct Drum -{ +struct Drum { u8 releaseRate; u8 pan; u8 loaded; @@ -217,14 +209,12 @@ struct Drum struct AdsrEnvelope *envelope; }; -struct AudioBank -{ +struct AudioBank { struct Drum **drums; struct Instrument *instruments[1]; }; // dynamic size -struct CtlEntry -{ +struct CtlEntry { #ifndef VERSION_SH u8 unused; #endif @@ -246,8 +236,7 @@ struct M64ScriptState { }; // size = 0x1C // Also known as a Group, according to debug strings. -struct SequencePlayer -{ +struct SequencePlayer { /*US/JP, EU, SH */ #if defined(VERSION_EU) || defined(VERSION_SH) /*0x000, 0x000, 0x000*/ u8 enabled : 1; @@ -325,8 +314,7 @@ struct SequencePlayer /*0x13C, 0x144*/ ssize_t bankDmaRemaining; }; // size = 0x140, 0x148 on EU, 0x14C on SH -struct AdsrSettings -{ +struct AdsrSettings { u8 releaseRate; #if defined(VERSION_EU) || defined(VERSION_SH) u8 sustain; @@ -388,8 +376,7 @@ struct ReverbInfo { s16 *filter; }; -struct NoteAttributes -{ +struct NoteAttributes { u8 reverbVol; #ifdef VERSION_SH u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1 @@ -412,8 +399,7 @@ struct NoteAttributes // Also known as a SubTrack, according to debug strings. // Confusingly, a SubTrack is a container of Tracks. -struct SequenceChannel -{ +struct SequenceChannel { /* U/J, EU, SH */ /*0x00, 0x00*/ u8 enabled : 1; /*0x00, 0x00*/ u8 finished : 1; @@ -495,8 +481,7 @@ struct SequenceChannel }; // size = 0xC0, 0xC4 in EU, 0xD0 in SH // Also known as a Track, according to debug strings. -struct SequenceChannelLayer -{ +struct SequenceChannelLayer { /* U/J, EU, SH */ /*0x00, 0x00*/ u8 enabled : 1; /*0x00, 0x00*/ u8 finished : 1; @@ -554,8 +539,7 @@ struct SequenceChannelLayer }; // size = 0x80 #if defined(VERSION_EU) || defined(VERSION_SH) -struct NoteSynthesisState -{ +struct NoteSynthesisState { /*0x00*/ u8 restart; /*0x01*/ u8 sampleDmaIndex; /*0x02*/ u8 prevHeadsetPanRight; @@ -570,8 +554,7 @@ struct NoteSynthesisState /*0x10*/ s16 curVolLeft; // UQ0.16 (EU Q1.15) /*0x12*/ s16 curVolRight; // UQ0.16 (EU Q1.15) }; -struct NotePlaybackState -{ +struct NotePlaybackState { /* U/J, EU, SH */ /*0x04, 0x00, 0x00*/ u8 priority; /* 0x01, 0x01*/ u8 waveId; @@ -591,8 +574,7 @@ struct NotePlaybackState /*0x74, 0x4C, */ struct Portamento portamento; /*0x84, 0x5C, */ struct VibratoState vibratoState; }; -struct NoteSubEu -{ +struct NoteSubEu { /*0x00*/ volatile u8 enabled : 1; /*0x00*/ u8 needsInit : 1; /*0x00*/ u8 finished : 1; @@ -624,8 +606,7 @@ struct NoteSubEu /*0x10*/ s16 *filter; #endif }; -struct Note -{ +struct Note { /* U/J, EU, SH */ /*0xA4, 0x00, 0x00*/ struct AudioListItem listItem; /* 0x10, 0x10*/ struct NoteSynthesisState synthesisState; @@ -660,14 +641,12 @@ struct Note }; // size = 0xC0, known to be 0xC8 on SH #else // volatile Note, needed in synthesis_process_notes -struct vNote -{ +struct vNote { /* U/J, EU */ /*0x00*/ volatile u8 enabled : 1; long long int force_structure_alignment; }; // size = 0xC0 -struct Note -{ +struct Note { /* U/J, EU */ /*0x00*/ u8 enabled : 1; /*0x00*/ u8 needsInit : 1; @@ -717,8 +696,7 @@ struct Note }; // size = 0xC0 #endif -struct NoteSynthesisBuffers -{ +struct NoteSynthesisBuffers { s16 adpcmdecState[0x10]; s16 finalResampleState[0x10]; #ifdef VERSION_SH @@ -737,15 +715,13 @@ struct NoteSynthesisBuffers }; #ifdef VERSION_EU -struct ReverbSettingsEU -{ +struct ReverbSettingsEU { u8 downsampleRate; u8 windowSize; // To be multiplied by 64 u16 gain; }; #else -struct ReverbSettingsEU -{ +struct ReverbSettingsEU { u8 downsampleRate; // always 1 u8 windowSize; // To be multiplied by 16 u16 gain; @@ -758,8 +734,7 @@ struct ReverbSettingsEU }; #endif -struct AudioSessionSettingsEU -{ +struct AudioSessionSettingsEU { /* 0x00 */ u32 frequency; /* 0x04 */ u8 unk1; // always 1 /* 0x05 */ u8 maxSimultaneousNotes; @@ -782,8 +757,7 @@ struct AudioSessionSettingsEU #endif }; // 0x30 on shindou -struct AudioSessionSettings -{ +struct AudioSessionSettings { /*0x00*/ u32 frequency; /*0x04*/ u8 maxSimultaneousNotes; /*0x05*/ u8 reverbDownsampleRate; // always 1 diff --git a/src/audio/load.c b/src/audio/load.c index 9766b455..896032dd 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -974,7 +974,8 @@ void audio_init() { #endif #ifdef TARGET_N64 - eu_stubbed_printf_3("Clear Workarea %x -%x size %x \n", + eu_stubbed_printf_3( + "Clear Workarea %x -%x size %x \n", (uintptr_t) &gAudioGlobalsStartMarker, (uintptr_t) &gAudioGlobalsEndMarker, (uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker diff --git a/src/audio/load_sh.c b/src/audio/load_sh.c index 5e79df1f..99593a28 100644 --- a/src/audio/load_sh.c +++ b/src/audio/load_sh.c @@ -254,8 +254,7 @@ void init_sample_dma_buffers(UNUSED s32 arg0) { sSampleDmas = sound_alloc_uninitialized(&gNotesAndBuffersPool, gMaxSimultaneousNotes * 4 * sizeof(struct SharedDma) * gAudioBufferParameters.presetUnk4); - for (i = 0; i < gMaxSimultaneousNotes * 3 * gAudioBufferParameters.presetUnk4; i++) - { + for (i = 0; i < gMaxSimultaneousNotes * 3 * gAudioBufferParameters.presetUnk4; i++) { if ((sSampleDmas[gSampleDmaNumListItems].buffer = sound_alloc_uninitialized(&gNotesAndBuffersPool, sDmaBufSize)) == NULL) { break; } @@ -622,8 +621,7 @@ void *func_sh_802f3764(s32 poolIdx, s32 idx, s32 *arg2) { devAddr = f->seqArray[idx].offset; - switch (sp18) - { + switch (sp18) { case 0: vAddr = unk_pool1_alloc(poolIdx, idx, size); if (vAddr == NULL) { @@ -1033,7 +1031,8 @@ void audio_init() { port_eu_init(); #ifdef TARGET_N64 - eu_stubbed_printf_3("Clear Workarea %x -%x size %x \n", + eu_stubbed_printf_3( + "Clear Workarea %x -%x size %x \n", (uintptr_t) &gAudioGlobalsStartMarker, (uintptr_t) &gAudioGlobalsEndMarker, (uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker @@ -1544,7 +1543,7 @@ s32 func_sh_802f573c(s32 audioResetStatus) { if (D_SH_8034F68C > 0) { if (audioResetStatus != 0) { - if (osRecvMesg(&gUnkQueue2, (OSMesg *) &idx, OS_MESG_NOBLOCK)){ + if (osRecvMesg(&gUnkQueue2, (OSMesg *) &idx, OS_MESG_NOBLOCK)) { } D_SH_8034F68C = 0; return 0; diff --git a/src/audio/port_eu.c b/src/audio/port_eu.c index 525ddd37..5ec259c9 100644 --- a/src/audio/port_eu.c +++ b/src/audio/port_eu.c @@ -134,44 +134,44 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { s32 i; switch (cmd->u.s.op) { - case 0x81: - preload_sequence(cmd->u.s.arg2, 3); - break; + case 0x81: + preload_sequence(cmd->u.s.arg2, 3); + break; - case 0x82: - case 0x88: - load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); - func_8031D690(cmd->u.s.arg1, cmd->u2.as_s32); - break; + case 0x82: + case 0x88: + load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); + func_8031D690(cmd->u.s.arg1, cmd->u2.as_s32); + break; - case 0x83: - if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) { - if (cmd->u2.as_s32 == 0) { - sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]); + case 0x83: + if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) { + if (cmd->u2.as_s32 == 0) { + sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]); + } + else { + seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32); + } } - else { - seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32); + break; + + case 0xf0: + gSoundMode = cmd->u2.as_s32; + break; + + case 0xf1: + for (i = 0; i < 4; i++) { + gSequencePlayers[i].muted = TRUE; + gSequencePlayers[i].recalculateVolume = TRUE; } - } - break; + break; - case 0xf0: - gSoundMode = cmd->u2.as_s32; - break; - - case 0xf1: - for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = TRUE; - gSequencePlayers[i].recalculateVolume = TRUE; - } - break; - - case 0xf2: - for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = FALSE; - gSequencePlayers[i].recalculateVolume = TRUE; - } - break; + case 0xf2: + for (i = 0; i < 4; i++) { + gSequencePlayers[i].muted = FALSE; + gSequencePlayers[i].recalculateVolume = TRUE; + } + break; } } @@ -259,55 +259,54 @@ void func_802ad7ec(u32 arg0) { } else if ((cmd->u.s.op & 0x40) != 0) { switch (cmd->u.s.op) { - case 0x41: - seqPlayer->fadeVolumeScale = cmd->u2.as_f32; - seqPlayer->recalculateVolume = TRUE; - break; + case 0x41: + seqPlayer->fadeVolumeScale = cmd->u2.as_f32; + seqPlayer->recalculateVolume = TRUE; + break; - case 0x47: - seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT; - break; + case 0x47: + seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT; + break; - case 0x48: - seqPlayer->transposition = cmd->u2.as_s8; - break; + case 0x48: + seqPlayer->transposition = cmd->u2.as_s8; + break; - case 0x46: - seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8; - break; + case 0x46: + seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8; + break; } } else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) { chan = seqPlayer->channels[cmd->u.s.arg2]; - if (IS_SEQUENCE_CHANNEL_VALID(chan)) - { + if (IS_SEQUENCE_CHANNEL_VALID(chan)) { switch (cmd->u.s.op) { - case 1: - chan->volumeScale = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; - break; - case 2: - chan->volume = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; - break; - case 3: - chan->newPan = cmd->u2.as_s8; - chan->changes.as_bitfields.pan = TRUE; - break; - case 4: - chan->freqScale = cmd->u2.as_f32; - chan->changes.as_bitfields.freqScale = TRUE; - break; - case 5: - chan->reverbVol = cmd->u2.as_s8; - break; - case 6: - if (cmd->u.s.arg3 < 8) { - chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8; - } - break; - case 8: - chan->stopSomething2 = cmd->u2.as_s8; + case 1: + chan->volumeScale = cmd->u2.as_f32; + chan->changes.as_bitfields.volume = TRUE; + break; + case 2: + chan->volume = cmd->u2.as_f32; + chan->changes.as_bitfields.volume = TRUE; + break; + case 3: + chan->newPan = cmd->u2.as_s8; + chan->changes.as_bitfields.pan = TRUE; + break; + case 4: + chan->freqScale = cmd->u2.as_f32; + chan->changes.as_bitfields.freqScale = TRUE; + break; + case 5: + chan->reverbVol = cmd->u2.as_s8; + break; + case 6: + if (cmd->u.s.arg3 < 8) { + chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8; + } + break; + case 8: + chan->stopSomething2 = cmd->u2.as_s8; } } } diff --git a/src/audio/port_sh.c b/src/audio/port_sh.c index 8c657b65..e7fae5b0 100644 --- a/src/audio/port_sh.c +++ b/src/audio/port_sh.c @@ -152,74 +152,74 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { struct NoteSubEu *sub; switch (cmd->u.s.op) { - case 0x81: - preload_sequence(cmd->u.s.arg2, 3); - break; + case 0x81: + preload_sequence(cmd->u.s.arg2, 3); + break; - case 0x82: - case 0x88: - load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); - func_8031D690(cmd->u.s.arg1, cmd->u2.as_s32); - break; + case 0x82: + case 0x88: + load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); + func_8031D690(cmd->u.s.arg1, cmd->u2.as_s32); + break; - case 0x83: - if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) { - if (cmd->u2.as_s32 == 0) { - sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]); + case 0x83: + if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) { + if (cmd->u2.as_s32 == 0) { + sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]); + } + else { + seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32); + } } - else { - seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32); + break; + + case 0x84: + break; + + case 0xf0: + gSoundMode = cmd->u2.as_s32; + break; + + case 0xf1: + for (i = 0; i < 4; i++) { + gSequencePlayers[i].muted = TRUE; + gSequencePlayers[i].recalculateVolume = TRUE; } - } - break; + break; - case 0x84: - break; - - case 0xf0: - gSoundMode = cmd->u2.as_s32; - break; - - case 0xf1: - for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = TRUE; - gSequencePlayers[i].recalculateVolume = TRUE; - } - break; - - case 0xf2: - if (cmd->u2.as_s32 == 1) { - for (i = 0; i < gMaxSimultaneousNotes; i++) { - note = &gNotes[i]; - sub = ¬e->noteSubEu; - if (note->noteSubEu.enabled && note->unkSH34 == 0) { - if ((note->parentLayer->seqChannel->muteBehavior & 8) != 0) { - sub->finished = TRUE; + case 0xf2: + if (cmd->u2.as_s32 == 1) { + for (i = 0; i < gMaxSimultaneousNotes; i++) { + note = &gNotes[i]; + sub = ¬e->noteSubEu; + if (note->noteSubEu.enabled && note->unkSH34 == 0) { + if ((note->parentLayer->seqChannel->muteBehavior & 8) != 0) { + sub->finished = TRUE; + } } } } - } - for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = FALSE; - gSequencePlayers[i].recalculateVolume = TRUE; - } - break; + for (i = 0; i < 4; i++) { + gSequencePlayers[i].muted = FALSE; + gSequencePlayers[i].recalculateVolume = TRUE; + } + break; - case 0xf3: - func_sh_802f3024(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); - break; + case 0xf3: + func_sh_802f3024(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); + break; - case 0xf4: - func_sh_802f30f4(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3, &gUnkQueue1); - break; + case 0xf4: + func_sh_802f30f4(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3, &gUnkQueue1); + break; - case 0xf5: - func_sh_802f3158(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3, &gUnkQueue1); - break; + case 0xf5: + func_sh_802f3158(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3, &gUnkQueue1); + break; - case 0xf6: - func_sh_802f3288(cmd->u.s.arg2); - break; + case 0xf6: + func_sh_802f3288(cmd->u.s.arg2); + break; } } @@ -344,75 +344,74 @@ void func_802ad7ec(u32 arg0) { } else if ((cmd->u.s.op & 0x40) != 0) { switch (cmd->u.s.op) { - case 0x41: - if (seqPlayer->fadeVolumeScale != cmd->u2.as_f32) { - seqPlayer->fadeVolumeScale = cmd->u2.as_f32; - seqPlayer->recalculateVolume = TRUE; - } - break; + case 0x41: + if (seqPlayer->fadeVolumeScale != cmd->u2.as_f32) { + seqPlayer->fadeVolumeScale = cmd->u2.as_f32; + seqPlayer->recalculateVolume = TRUE; + } + break; - case 0x47: - seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT; - break; + case 0x47: + seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT; + break; - case 0x49: - seqPlayer->tempoAdd = cmd->u2.as_s32 * TEMPO_SCALE; - break; + case 0x49: + seqPlayer->tempoAdd = cmd->u2.as_s32 * TEMPO_SCALE; + break; - case 0x48: - seqPlayer->transposition = cmd->u2.as_s8; - break; + case 0x48: + seqPlayer->transposition = cmd->u2.as_s8; + break; - case 0x46: - seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8; - break; + case 0x46: + seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8; + break; } } else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) { chan = seqPlayer->channels[cmd->u.s.arg2]; - if (IS_SEQUENCE_CHANNEL_VALID(chan)) - { + if (IS_SEQUENCE_CHANNEL_VALID(chan)) { switch (cmd->u.s.op) { - case 1: - if (chan->volumeScale != cmd->u2.as_f32) { - chan->volumeScale = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; - } - break; - case 2: - if (chan->volume != cmd->u2.as_f32) { - chan->volume = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; - } - break; - case 3: - if (chan->newPan != cmd->u2.as_s8) { - chan->newPan = cmd->u2.as_s8; - chan->changes.as_bitfields.pan = TRUE; - } - break; - case 4: - if (chan->freqScale != cmd->u2.as_f32) { - chan->freqScale = cmd->u2.as_f32; - chan->changes.as_bitfields.freqScale = TRUE; - } - break; - case 5: - //! @bug u8 s8 comparison (but harmless) - if (chan->reverbVol != cmd->u2.as_s8) { - chan->reverbVol = cmd->u2.as_s8; - } - break; - case 6: - if (cmd->u.s.arg3 < 8) { - chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8; - } - break; - case 8: - chan->stopSomething2 = cmd->u2.as_s8; - break; - case 9: - chan->muteBehavior = cmd->u2.as_s8; + case 1: + if (chan->volumeScale != cmd->u2.as_f32) { + chan->volumeScale = cmd->u2.as_f32; + chan->changes.as_bitfields.volume = TRUE; + } + break; + case 2: + if (chan->volume != cmd->u2.as_f32) { + chan->volume = cmd->u2.as_f32; + chan->changes.as_bitfields.volume = TRUE; + } + break; + case 3: + if (chan->newPan != cmd->u2.as_s8) { + chan->newPan = cmd->u2.as_s8; + chan->changes.as_bitfields.pan = TRUE; + } + break; + case 4: + if (chan->freqScale != cmd->u2.as_f32) { + chan->freqScale = cmd->u2.as_f32; + chan->changes.as_bitfields.freqScale = TRUE; + } + break; + case 5: + //! @bug u8 s8 comparison (but harmless) + if (chan->reverbVol != cmd->u2.as_s8) { + chan->reverbVol = cmd->u2.as_s8; + } + break; + case 6: + if (cmd->u.s.arg3 < 8) { + chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8; + } + break; + case 8: + chan->stopSomething2 = cmd->u2.as_s8; + break; + case 9: + chan->muteBehavior = cmd->u2.as_s8; } } } diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 90551603..13ee393b 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -1390,8 +1390,7 @@ s32 seq_channel_layer_process_script_part3(struct SequenceChannelLayer *layer, s layer->delay = sp3A; layer->duration = layer->noteDuration * sp3A >> 8; if ((seqPlayer->muted && (seqChannel->muteBehavior & 0x50) != 0) - || seqChannel->stopSomething2) - { + || seqChannel->stopSomething2) { layer->stopSomething = TRUE; return -1; } @@ -1404,8 +1403,7 @@ u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrume struct Instrument *inst; #if defined(VERSION_EU) || defined(VERSION_SH) inst = get_instrument_inner(seqChannel->bankId, instId); - if (inst == NULL) - { + if (inst == NULL) { *instOut = NULL; return 0; } @@ -1524,25 +1522,21 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) { for (;;) { cmd = m64_read_u8(state); #if !defined(VERSION_EU) && !defined(VERSION_SH) - if (cmd == 0xff) // chan_end - { + if (cmd == 0xff) { // chan_end if (state->depth == 0) { sequence_channel_disable(seqChannel); break; } state->depth--, state->pc = state->stack[state->depth]; } - if (cmd == 0xfe) // chan_delay1 - { + if (cmd == 0xfe) { // chan_delay1 break; } - if (cmd == 0xfd) // chan_delay - { + if (cmd == 0xfd) { // chan_delay seqChannel->delay = m64_read_compressed_u16(state); break; } - if (cmd == 0xf3) // chan_hang - { + if (cmd == 0xf3) { // chan_hang seqChannel->stopScript = TRUE; break; } @@ -2362,8 +2356,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { #endif for (;;) { cmd = m64_read_u8(state); - if (cmd == 0xff) // seq_end - { + if (cmd == 0xff) { // seq_end if (state->depth == 0) { sequence_player_disable(seqPlayer); break; @@ -2375,14 +2368,12 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { #endif } - if (cmd == 0xfd) // seq_delay - { + if (cmd == 0xfd) { // seq_delay seqPlayer->delay = m64_read_compressed_u16(state); break; } - if (cmd == 0xfe) // seq_delay1 - { + if (cmd == 0xfe) { // seq_delay1 seqPlayer->delay = 1; break; } @@ -2502,7 +2493,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { seqPlayer->tempo = gTempoInternalToExternal; } - //if (cmd){} + //if (cmd) {} if ((s16) seqPlayer->tempo <= 0) { seqPlayer->tempo = 1; diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index 9ca86439..b6465ac2 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -17,8 +17,7 @@ #define MAX_UPDATES_PER_FRAME 4 #endif -struct ReverbRingBufferItem -{ +struct ReverbRingBufferItem { s16 numSamplesAfterDownsampling; s16 chunkLen; // never read s16 *toDownsampleLeft; @@ -28,8 +27,7 @@ struct ReverbRingBufferItem s16 lengthB; // second length in ring buffer (from pos 0) }; // size = 0x14 -struct SynthesisReverb -{ +struct SynthesisReverb { /*0x00, 0x00, 0x00*/ u8 resampleFlags; /*0x01, 0x01, 0x01*/ u8 useReverb; /*0x02, 0x02, 0x02*/ u8 framesLeftToIgnore; @@ -53,8 +51,7 @@ struct SynthesisReverb /*0x08, 0x0C, 0x14*/ s32 nextRingBufferPos; /*0x0C, 0x10, 0x18*/ s32 unkC; // never read /*0x10, 0x14, 0x1C*/ s32 bufSizePerChannel; - struct - { + struct { s16 *left; s16 *right; } ringBuffer; diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c index 527fce94..0a7b6f7f 100644 --- a/src/buffers/buffers.c +++ b/src/buffers/buffers.c @@ -40,8 +40,3 @@ ALIGNED8 u8 gAudioSPTaskYieldBuffer[OS_YIELD_AUDIO_SIZE]; #if !defined(F3DEX_GBI_SHARED) && !defined(VERSION_EU) ALIGNED8 u8 gUnusedThread2Stack[0x1400]; #endif - - - - - diff --git a/src/buffers/framebuffers.c b/src/buffers/framebuffers.c index bb3589d2..09a84782 100644 --- a/src/buffers/framebuffers.c +++ b/src/buffers/framebuffers.c @@ -4,9 +4,9 @@ // 0x70800 bytes #ifdef AVOID_UB -u16 gFrameBuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT]; +u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT]; #else -u16 gFrameBuffer0[SCREEN_WIDTH * SCREEN_HEIGHT]; -u16 gFrameBuffer1[SCREEN_WIDTH * SCREEN_HEIGHT]; -u16 gFrameBuffer2[SCREEN_WIDTH * SCREEN_HEIGHT]; +u16 gFramebuffer0[SCREEN_WIDTH * SCREEN_HEIGHT]; +u16 gFramebuffer1[SCREEN_WIDTH * SCREEN_HEIGHT]; +u16 gFramebuffer2[SCREEN_WIDTH * SCREEN_HEIGHT]; #endif diff --git a/src/buffers/framebuffers.h b/src/buffers/framebuffers.h index d17f1fb7..70cee045 100644 --- a/src/buffers/framebuffers.h +++ b/src/buffers/framebuffers.h @@ -9,14 +9,14 @@ // -g codegen implies that they are separate variables. This is impossible to // reconcile without undefined behavior. Avoid that when possible. #ifdef AVOID_UB -extern u16 gFrameBuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT]; -#define gFrameBuffer0 gFrameBuffers[0] -#define gFrameBuffer1 gFrameBuffers[1] -#define gFrameBuffer2 gFrameBuffers[2] +extern u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT]; +#define gFramebuffer0 gFramebuffers[0] +#define gFramebuffer1 gFramebuffers[1] +#define gFramebuffer2 gFramebuffers[2] #else -extern u16 gFrameBuffer0[SCREEN_WIDTH * SCREEN_HEIGHT]; -extern u16 gFrameBuffer1[SCREEN_WIDTH * SCREEN_HEIGHT]; -extern u16 gFrameBuffer2[SCREEN_WIDTH * SCREEN_HEIGHT]; +extern u16 gFramebuffer0[SCREEN_WIDTH * SCREEN_HEIGHT]; +extern u16 gFramebuffer1[SCREEN_WIDTH * SCREEN_HEIGHT]; +extern u16 gFramebuffer2[SCREEN_WIDTH * SCREEN_HEIGHT]; #endif #endif // FRAMEBUFFERS_H diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 5617e5b9..64039c94 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -904,7 +904,7 @@ static BhvCommandProc BehaviorCmdTable[] = { // Execute the behavior script of the current object, process the object flags, and other miscellaneous code for updating objects. void cur_obj_update(void) { - UNUSED u32 unused; + UNUSED u8 filler[4]; s16 objFlags = gCurrentObject->oFlags; f32 distanceFromMario; diff --git a/src/engine/geo_layout.c b/src/engine/geo_layout.c index d071d1a6..2fd4afac 100644 --- a/src/engine/geo_layout.c +++ b/src/engine/geo_layout.c @@ -293,7 +293,7 @@ void geo_layout_cmd_nop3(void) { } /* - 0x0C: Create zbuffer-toggling scene graph node + 0x0C: Create z-buffer-toggling scene graph node cmd+0x01: u8 enableZBuffer (1 = on, 0 = off) */ void geo_layout_cmd_node_master_list(void) { diff --git a/src/engine/graph_node.c b/src/engine/graph_node.c index 8edf7f8f..4b2447e7 100644 --- a/src/engine/graph_node.c +++ b/src/engine/graph_node.c @@ -719,7 +719,7 @@ void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo graphNode->areaIndex = spawn->areaIndex; graphNode->activeAreaIndex = spawn->activeAreaIndex; - graphNode->sharedChild = spawn->unk18; + graphNode->sharedChild = spawn->model; graphNode->unk4C = spawn; graphNode->throwMatrix = NULL; graphNode->animInfo.curAnim = 0; @@ -791,9 +791,7 @@ s32 retrieve_animation_index(s32 frame, u16 **attributes) { */ s16 geo_update_animation_frame(struct AnimInfo *obj, s32 *accelAssist) { s32 result; - struct Animation *anim; - - anim = obj->curAnim; + struct Animation *anim = obj->curAnim; if (obj->animTimer == gAreaUpdateCounter || anim->flags & ANIM_FLAG_2) { if (accelAssist != NULL) { @@ -804,7 +802,7 @@ s16 geo_update_animation_frame(struct AnimInfo *obj, s32 *accelAssist) { } if (anim->flags & ANIM_FLAG_FORWARD) { - if (obj->animAccel) { + if (obj->animAccel != 0) { result = obj->animFrameAccelAssist - obj->animAccel; } else { result = (obj->animFrame - 1) << 16; diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h index e20064c3..08067e04 100644 --- a/src/engine/graph_node.h +++ b/src/engine/graph_node.h @@ -68,16 +68,14 @@ typedef Gfx *(*GraphNodeFunc)(s32 callContext, struct GraphNode *node, void *con * Many graph node types have an update function that gets called * when they are processed. */ -struct FnGraphNode -{ +struct FnGraphNode { /*0x00*/ struct GraphNode node; /*0x14*/ GraphNodeFunc func; }; /** The very root of the geo tree. Specifies the viewport. */ -struct GraphNodeRoot -{ +struct GraphNodeRoot { /*0x00*/ struct GraphNode node; /*0x14*/ u8 areaIndex; /*0x15*/ s8 unk15; // ? @@ -92,8 +90,7 @@ struct GraphNodeRoot /** A node that sets up an orthographic projection based on the global * root node. Used to draw the skybox image. */ -struct GraphNodeOrthoProjection -{ +struct GraphNodeOrthoProjection { /*0x00*/ struct GraphNode node; /*0x14*/ f32 scale; }; @@ -102,8 +99,7 @@ struct GraphNodeOrthoProjection * game world. It does not set up the camera position, that is done by * the child of this node, which has type GraphNodeCamera. */ -struct GraphNodePerspective -{ +struct GraphNodePerspective { /*0x00*/ struct FnGraphNode fnNode; /*0x18*/ s32 unused; /*0x1C*/ f32 fov; // horizontal field of view in degrees @@ -114,8 +110,7 @@ struct GraphNodePerspective /** An entry in the master list. It is a linked list of display lists * carrying a transformation matrix. */ -struct DisplayListNode -{ +struct DisplayListNode { Mtx *transform; void *displayList; struct DisplayListNode *next; @@ -126,8 +121,7 @@ struct DisplayListNode * different master list than opaque objects. * It also sets the z-buffer on before rendering and off after. */ -struct GraphNodeMasterList -{ +struct GraphNodeMasterList { /*0x00*/ struct GraphNode node; /*0x14*/ struct DisplayListNode *listHeads[GFX_NUM_MASTER_LISTS]; /*0x34*/ struct DisplayListNode *listTails[GFX_NUM_MASTER_LISTS]; @@ -136,8 +130,7 @@ struct GraphNodeMasterList /** Simply used as a parent to group multiple children. * Does not have any additional functionality. */ -struct GraphNodeStart -{ +struct GraphNodeStart { /*0x00*/ struct GraphNode node; }; @@ -147,8 +140,7 @@ struct GraphNodeStart * Usage examples: Mario has three level's of detail: Normal, low-poly arms only, and fully low-poly * The tower in Whomp's fortress has two levels of detail. */ -struct GraphNodeLevelOfDetail -{ +struct GraphNodeLevelOfDetail { /*0x00*/ struct GraphNode node; /*0x14*/ s16 minDistance; /*0x16*/ s16 maxDistance; @@ -159,8 +151,7 @@ struct GraphNodeLevelOfDetail * which is set in the node's function. * Usage examples: room visibility, coin animation, blinking, Mario's power-up / hand pose / cap */ -struct GraphNodeSwitchCase -{ +struct GraphNodeSwitchCase { /*0x00*/ struct FnGraphNode fnNode; /*0x18*/ s32 unused; /*0x1C*/ s16 numCases; @@ -171,8 +162,7 @@ struct GraphNodeSwitchCase * GraphNode that specifies the location and aim of the camera. * When the roll is 0, the up vector is (0, 1, 0). */ -struct GraphNodeCamera -{ +struct GraphNodeCamera { /*0x00*/ struct FnGraphNode fnNode; /*0x18*/ union { // When the node is created, a mode is assigned to the node. @@ -195,8 +185,7 @@ struct GraphNodeCamera * based on the ENEMYINFO array. * The display list can be null, in which case it won't draw anything itself. */ -struct GraphNodeTranslationRotation -{ +struct GraphNodeTranslationRotation { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; /*0x18*/ Vec3s translation; @@ -207,12 +196,11 @@ struct GraphNodeTranslationRotation * Usage example: SUPER MARIO logo letters in debug level select. * The display list can be null, in which case it won't draw anything itself. */ -struct GraphNodeTranslation -{ +struct GraphNodeTranslation { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; /*0x18*/ Vec3s translation; - u8 pad1E[2]; + u8 filler[2]; }; /** GraphNode that rotates itself and its children. @@ -220,12 +208,11 @@ struct GraphNodeTranslation * set by a parent script node in that case. * The display list can be null, in which case it won't draw anything itself. */ -struct GraphNodeRotation -{ +struct GraphNodeRotation { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; /*0x18*/ Vec3s rotation; - u8 pad1E[2]; + u8 filler[2]; }; /** GraphNode part that transforms itself and its children based on animation @@ -235,8 +222,7 @@ struct GraphNodeRotation * Used for Mario, enemies and anything else with animation data. * The display list can be null, in which case it won't draw anything itself. */ -struct GraphNodeAnimatedPart -{ +struct GraphNodeAnimatedPart { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; /*0x18*/ Vec3s translation; @@ -247,8 +233,7 @@ struct GraphNodeAnimatedPart * then it simply sets the billboard flag for the entire object, this node is * used for billboard parts (like a chuckya or goomba body). */ -struct GraphNodeBillboard -{ +struct GraphNodeBillboard { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; /*0x18*/ Vec3s translation; @@ -257,8 +242,7 @@ struct GraphNodeBillboard /** A GraphNode that simply draws a display list without doing any * transformation beforehand. It does inherit the parent's transformation. */ -struct GraphNodeDisplayList -{ +struct GraphNodeDisplayList { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; }; @@ -271,8 +255,7 @@ struct GraphNodeDisplayList * There is also a level command that scales the entire level, used for THI. * The display list can be null, in which case it won't draw anything itself. */ -struct GraphNodeScale -{ +struct GraphNodeScale { /*0x00*/ struct GraphNode node; /*0x14*/ void *displayList; /*0x18*/ f32 scale; @@ -283,8 +266,7 @@ struct GraphNodeScale * The shadow type determines the shape (round or rectangular), vertices (4 or 9) * and other features. */ -struct GraphNodeShadow -{ +struct GraphNodeShadow { /*0x00*/ struct GraphNode node; /*0x14*/ s16 shadowScale; // diameter (when a circle) or side (when a square) of shadow /*0x16*/ u8 shadowSolidity; // opacity of shadow, 255 = opaque @@ -294,8 +276,7 @@ struct GraphNodeShadow /** GraphNode that contains as its sharedChild a group node containing all * object nodes. */ -struct GraphNodeObjectParent -{ +struct GraphNodeObjectParent { /*0x00*/ struct GraphNode node; /*0x14*/ struct GraphNode *sharedChild; }; @@ -308,8 +289,7 @@ struct GraphNodeObjectParent * The parameter field gives extra context info. For shifting sand or paintings, * it can determine which texture to use. */ -struct GraphNodeGenerated -{ +struct GraphNodeGenerated { /*0x00*/ struct FnGraphNode fnNode; /*0x18*/ u32 parameter; // extra context for the function }; @@ -317,8 +297,7 @@ struct GraphNodeGenerated /** GraphNode that draws a background image or a rectangle of a color. * Drawn in an orthographic projection, used for skyboxes. */ -struct GraphNodeBackground -{ +struct GraphNodeBackground { /*0x00*/ struct FnGraphNode fnNode; /*0x18*/ s32 unused; /*0x1C*/ s32 background; // background ID, or rgba5551 color if fnNode.func is null @@ -326,8 +305,7 @@ struct GraphNodeBackground /** Renders the object that Mario is holding. */ -struct GraphNodeHeldObject -{ +struct GraphNodeHeldObject { /*0x00*/ struct FnGraphNode fnNode; /*0x18*/ s32 playerIndex; /*0x1C*/ struct Object *objNode; @@ -339,11 +317,10 @@ struct GraphNodeHeldObject * object node. Used for very large objects, such as shock wave rings that Bowser * creates, tornadoes, the big eel. */ -struct GraphNodeCullingRadius -{ +struct GraphNodeCullingRadius { /*0x00*/ struct GraphNode node; /*0x14*/ s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustum culling - u8 pad1E[2]; + u8 filler[2]; }; extern struct GraphNodeMasterList *gCurGraphNodeMasterList; diff --git a/src/engine/level_script.c b/src/engine/level_script.c index e6bd3c20..b0463393 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -286,7 +286,7 @@ static void level_cmd_load_mario_head(void) { if (addr != NULL) { gdm_init(addr, DOUBLE_SIZE_ON_64_BIT(0xE1000)); gd_add_to_heap(gZBuffer, sizeof(gZBuffer)); // 0x25800 - gd_add_to_heap(gFrameBuffer0, 3 * sizeof(gFrameBuffer0)); // 0x70800 + gd_add_to_heap(gFramebuffer0, 3 * sizeof(gFramebuffer0)); // 0x70800 gdm_setup(); gdm_maketestdl(CMD_GET(s16, 2)); } else { @@ -425,7 +425,7 @@ static void level_cmd_init_mario(void) { gMarioSpawnInfo->areaIndex = 0; gMarioSpawnInfo->behaviorArg = CMD_GET(u32, 4); gMarioSpawnInfo->behaviorScript = CMD_GET(void *, 8); - gMarioSpawnInfo->unk18 = gLoadedGraphNodes[CMD_GET(u8, 3)]; + gMarioSpawnInfo->model = gLoadedGraphNodes[CMD_GET(u8, 3)]; gMarioSpawnInfo->next = NULL; sCurrentCmd = CMD_NEXT; @@ -453,7 +453,7 @@ static void level_cmd_place_object(void) { spawnInfo->behaviorArg = CMD_GET(u32, 16); spawnInfo->behaviorScript = CMD_GET(void *, 20); - spawnInfo->unk18 = gLoadedGraphNodes[model]; + spawnInfo->model = gLoadedGraphNodes[model]; spawnInfo->next = gAreas[sCurrAreaIndex].objectSpawnInfos; gAreas[sCurrAreaIndex].objectSpawnInfos = spawnInfo; @@ -545,8 +545,8 @@ static void level_cmd_3A(void) { struct UnusedArea28 *val4; if (sCurrAreaIndex != -1) { - if ((val4 = gAreas[sCurrAreaIndex].unused28) == NULL) { - val4 = gAreas[sCurrAreaIndex].unused28 = + if ((val4 = gAreas[sCurrAreaIndex].unused) == NULL) { + val4 = gAreas[sCurrAreaIndex].unused = alloc_only_pool_alloc(sLevelPool, sizeof(struct UnusedArea28)); } diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 318a8043..c59a1436 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -211,7 +211,7 @@ s32 find_wall_collisions(struct WallCollisionData *colData) { numCollisions += find_wall_collisions_from_list(node, colData); // Increment the debug tracker. - gNumCalls.wall += 1; + gNumCalls.wall++; return numCollisions; } @@ -305,18 +305,20 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32 */ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) { s16 cellZ, cellX; + struct Surface *ceil, *dynamicCeil; struct SurfaceNode *surfaceList; + f32 height = CELL_HEIGHT_LIMIT; f32 dynamicHeight = CELL_HEIGHT_LIMIT; - s16 x, y, z; //! (Parallel Universes) Because position is casted to an s16, reaching higher - // float locations can return ceilings despite them not existing there. - //(Dynamic ceilings will unload due to the range.) - x = (s16) posX; - y = (s16) posY; - z = (s16) posZ; + // float locations can return ceilings despite them not existing there. + // (Dynamic ceilings will unload due to the range.) + s16 x = (s16) posX; + s16 y = (s16) posY; + s16 z = (s16) posZ; + *pceil = NULL; if (x <= -LEVEL_BOUNDARY_MAX || x >= LEVEL_BOUNDARY_MAX) { @@ -346,7 +348,7 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) { *pceil = ceil; // Increment the debug tracker. - gNumCalls.ceil += 1; + gNumCalls.ceil++; return height; } @@ -518,8 +520,8 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { f32 dynamicHeight = FLOOR_LOWER_LIMIT; //! (Parallel Universes) Because position is casted to an s16, reaching higher - // float locations can return floors despite them not existing there. - //(Dynamic floors will unload due to the range.) + // float locations can return floors despite them not existing there. + // (Dynamic floors will unload due to the range.) s16 x = (s16) xPos; s16 y = (s16) yPos; s16 z = (s16) zPos; @@ -563,7 +565,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { // If a floor was missed, increment the debug counter. if (floor == NULL) { - gNumFindFloorMisses += 1; + gNumFindFloorMisses++; } if (dynamicHeight > height) { @@ -574,7 +576,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { *pfloor = floor; // Increment the debug tracker. - gNumCalls.floor += 1; + gNumCalls.floor++; return height; } @@ -624,7 +626,7 @@ f32 find_water_level(f32 x, f32 z) { f32 find_poison_gas_level(f32 x, f32 z) { s32 i; s32 numRegions; - UNUSED s32 unused; + UNUSED u8 filler[4]; s16 val; f32 loX, hiX, loZ, hiZ; f32 gasLevel = FLOOR_LOWER_LIMIT; diff --git a/src/engine/surface_collision.h b/src/engine/surface_collision.h index ad5e6406..f4695081 100644 --- a/src/engine/surface_collision.h +++ b/src/engine/surface_collision.h @@ -17,19 +17,17 @@ // It doesn't match if ".0" is removed or ".f" is added #define FLOOR_LOWER_LIMIT_SHADOW (FLOOR_LOWER_LIMIT + 1000.0) -struct WallCollisionData -{ +struct WallCollisionData { /*0x00*/ f32 x, y, z; /*0x0C*/ f32 offsetY; /*0x10*/ f32 radius; - /*0x14*/ s16 unused; + /*0x14*/ u8 filler[2]; /*0x16*/ s16 numWalls; /*0x18*/ struct Surface *walls[4]; }; -struct FloorGeometry -{ - f32 unused[4]; // possibly position data? +struct FloorGeometry { + u8 filler[16]; // possibly position data? f32 normalX; f32 normalY; f32 normalZ; diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 74ee5e7f..399423f0 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -1,7 +1,5 @@ #include -#include "prevent_bss_reordering.h" - #include "sm64.h" #include "game/ingame_menu.h" #include "graph_node.h" @@ -213,7 +211,7 @@ static s16 lower_cell_index(s16 coord) { //! Some wall checks are larger than the buffer, meaning wall checks can // miss walls that are near a cell border. if (coord % CELL_SIZE < 50) { - index -= 1; + index--; } if (index < 0) { @@ -245,7 +243,7 @@ static s16 upper_cell_index(s16 coord) { //! Some wall checks are larger than the buffer, meaning wall checks can // miss walls that are near a cell border. if (coord % CELL_SIZE > CELL_SIZE - 50) { - index += 1; + index++; } if (index > NUM_CELLS_INDEX) { @@ -442,12 +440,12 @@ static void load_static_surfaces(s16 **data, s16 *vertexData, s16 surfaceType, s s16 flags = surf_has_no_cam_collision(surfaceType); numSurfaces = *(*data); - *data += 1; + (*data)++; for (i = 0; i < numSurfaces; i++) { if (*surfaceRooms != NULL) { room = *(*surfaceRooms); - *surfaceRooms += 1; + (*surfaceRooms)++; } surface = read_surface_data(vertexData, data); @@ -467,7 +465,7 @@ static void load_static_surfaces(s16 **data, s16 *vertexData, s16 surfaceType, s *data += 3; if (hasForce) { - *data += 1; + (*data)++; } } } @@ -477,8 +475,7 @@ static void load_static_surfaces(s16 **data, s16 *vertexData, s16 surfaceType, s */ static s16 *read_vertex_data(s16 **data) { s32 numVertices; - UNUSED s16 unused1[3]; - UNUSED s16 unused2[3]; + UNUSED u8 filler[16]; s16 *vertexData; numVertices = *(*data); @@ -590,7 +587,7 @@ u32 get_area_terrain_size(s16 *data) { void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects) { s16 terrainLoadType; s16 *vertexData; - UNUSED s32 unused; + UNUSED u8 filler[4]; // Initialize the data for this. gEnvironmentRegions = NULL; @@ -756,7 +753,7 @@ void load_object_surfaces(s16 **data, s16 *vertexData) { * Transform an object's vertices, reload them, and render the object. */ void load_object_collision_model(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; s16 vertexData[600]; s16 *collisionData = gCurrentObject->collisionData; diff --git a/src/engine/surface_load.h b/src/engine/surface_load.h index e41a04a4..e00e2bc0 100644 --- a/src/engine/surface_load.h +++ b/src/engine/surface_load.h @@ -9,14 +9,12 @@ #define NUM_CELLS (2 * LEVEL_BOUNDARY_MAX / CELL_SIZE) #define NUM_CELLS_INDEX (NUM_CELLS - 1) -struct SurfaceNode -{ +struct SurfaceNode { struct SurfaceNode *next; struct Surface *surface; }; -enum -{ +enum { SPATIAL_PARTITION_FLOORS, SPATIAL_PARTITION_CEILS, SPATIAL_PARTITION_WALLS diff --git a/src/game/area.c b/src/game/area.c index fc2b7b69..bca1ceaa 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -109,7 +109,7 @@ void print_intro_text(void) { #ifdef VERSION_EU s32 language = eu_get_language(); #endif - if ((gGlobalTimer & 0x1F) < 20) { + if ((gGlobalTimer & 31) < 20) { if (gControllerBits == 0) { #ifdef VERSION_EU print_text_centered(SCREEN_WIDTH / 2, 20, gNoControllerMsg[language]); @@ -194,7 +194,7 @@ void clear_areas(void) { gAreaData[i].instantWarps = NULL; gAreaData[i].objectSpawnInfos = NULL; gAreaData[i].camera = NULL; - gAreaData[i].unused28 = NULL; + gAreaData[i].unused = NULL; gAreaData[i].whirlpools[0] = NULL; gAreaData[i].whirlpools[1] = NULL; gAreaData[i].dialog[0] = DIALOG_NONE; @@ -330,16 +330,14 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) { gWarpTransition.data.texTimer = 0; - if (transType & 1) // Is the image fading in? - { + if (transType & 1) { // Is the image fading in? gWarpTransition.data.startTexRadius = GFX_DIMENSIONS_FULL_RADIUS; if (transType >= 0x0F) { gWarpTransition.data.endTexRadius = 16; } else { gWarpTransition.data.endTexRadius = 0; } - } else // The image is fading out. (Reverses start & end circles) - { + } else { // The image is fading out. (Reverses start & end circles) if (transType >= 0x0E) { gWarpTransition.data.startTexRadius = 16; } else { @@ -409,7 +407,7 @@ void render_game(void) { if (D_8032CE78 != NULL) { clear_viewport(D_8032CE78, gWarpTransFBSetColor); } else { - clear_frame_buffer(gWarpTransFBSetColor); + clear_framebuffer(gWarpTransFBSetColor); } } diff --git a/src/game/area.h b/src/game/area.h index 60010a70..9141005b 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -7,16 +7,14 @@ #include "camera.h" #include "engine/graph_node.h" -struct WarpNode -{ +struct WarpNode { /*00*/ u8 id; /*01*/ u8 destLevel; /*02*/ u8 destArea; /*03*/ u8 destNode; }; -struct ObjectWarpNode -{ +struct ObjectWarpNode { /*0x00*/ struct WarpNode node; /*0x04*/ struct Object *object; /*0x08*/ struct ObjectWarpNode *next; @@ -26,27 +24,24 @@ struct ObjectWarpNode #define INSTANT_WARP_INDEX_START 0x00 // Equal and greater than Surface 0x1B #define INSTANT_WARP_INDEX_STOP 0x04 // Less than Surface 0x1F -struct InstantWarp -{ +struct InstantWarp { /*0x00*/ u8 id; // 0 = 0x1B / 1 = 0x1C / 2 = 0x1D / 3 = 0x1E /*0x01*/ u8 area; /*0x02*/ Vec3s displacement; }; -struct SpawnInfo -{ +struct SpawnInfo { /*0x00*/ Vec3s startPos; /*0x06*/ Vec3s startAngle; /*0x0C*/ s8 areaIndex; /*0x0D*/ s8 activeAreaIndex; /*0x10*/ u32 behaviorArg; /*0x14*/ void *behaviorScript; - /*0x18*/ struct GraphNode *unk18; + /*0x18*/ struct GraphNode *model; /*0x1C*/ struct SpawnInfo *next; }; -struct UnusedArea28 -{ +struct UnusedArea28 { /*0x00*/ s16 unk00; /*0x02*/ s16 unk02; /*0x04*/ s16 unk04; @@ -54,14 +49,12 @@ struct UnusedArea28 /*0x08*/ s16 unk08; }; -struct Whirlpool -{ +struct Whirlpool { /*0x00*/ Vec3s pos; /*0x03*/ s16 strength; }; -struct Area -{ +struct Area { /*0x00*/ s8 index; /*0x01*/ s8 flags; // Only has 1 flag: 0x01 = Is this the active area? /*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31) @@ -74,7 +67,7 @@ struct Area /*0x1C*/ struct InstantWarp *instantWarps; /*0x20*/ struct SpawnInfo *objectSpawnInfos; /*0x24*/ struct Camera *camera; - /*0x28*/ struct UnusedArea28 *unused28; // Filled by level script 0x3A, but is unused. + /*0x28*/ struct UnusedArea28 *unused; // Filled by level script 0x3A, but is unused. /*0x2C*/ struct Whirlpool *whirlpools[2]; /*0x34*/ u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30) /*0x36*/ u16 musicParam; @@ -82,8 +75,7 @@ struct Area }; // All the transition data to be used in screen_transition.c -struct WarpTransitionData -{ +struct WarpTransitionData { /*0x00*/ u8 red; /*0x01*/ u8 green; /*0x02*/ u8 blue; @@ -109,8 +101,7 @@ struct WarpTransitionData #define WARP_TRANSITION_FADE_FROM_BOWSER 0x12 #define WARP_TRANSITION_FADE_INTO_BOWSER 0x13 -struct WarpTransition -{ +struct WarpTransition { /*0x00*/ u8 isActive; // Is the transition active. (either TRUE or FALSE) /*0x01*/ u8 type; // Determines the type of transition to use (circle, star, etc.) /*0x02*/ u8 time; // Amount of time to complete the transition (in frames) diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index a42849a5..9800146f 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -47,47 +47,18 @@ #define o gCurrentObject -struct WFRotatingPlatformData { - s16 pad; - s16 scale; - const Collision *collisionData; - s16 collisionDistance; +static s32 sCapSaveFlags[] = { + SAVE_FLAG_HAVE_WING_CAP, + SAVE_FLAG_HAVE_METAL_CAP, + SAVE_FLAG_HAVE_VANISH_CAP, }; -struct Struct8032F34C { - s16 numBridgeSections; - s16 bridgeRelativeStartingXorZ; - s16 platformWidth; - s16 model; - const void *segAddr; -}; - -struct Struct802C0DF0 { - u8 unk0; - u8 unk1; - u8 unk2; - u8 model; - const BehaviorScript *behavior; -}; - -struct Struct8032F754 { - s32 unk0; - Vec3f unk1; - f32 unk2; -}; - -struct OpenableGrill { - s16 halfWidth; - s16 modelID; - const Collision *collision; -}; - -static s32 sCapSaveFlags[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP }; - // Boo Roll -static s16 sBooHitRotations[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, 2775, - 2517, 2271, 2039, 1818, 1611, 1416, 1233, 1063, 906, 761, 629, - 509, 402, 308, 226, 157, 100, 56, 25, 4, 0 }; +static s16 sBooHitRotations[] = { + 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, 2775, + 2517, 2271, 2039, 1818, 1611, 1416, 1233, 1063, 906, 761, 629, + 509, 402, 308, 226, 157, 100, 56, 25, 4, 0, +}; #include "behaviors/star_door.inc.c" #include "behaviors/mr_i.inc.c" @@ -108,13 +79,27 @@ static s16 sBooHitRotations[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624 #include "behaviors/white_puff_explode.inc.c" // not in behavior file -struct SpawnParticlesInfo sMistParticles = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f }; +static struct SpawnParticlesInfo sMistParticles = { + /* behParam: */ 2, + /* count: */ 20, + /* model: */ MODEL_MIST, + /* offsetY: */ 0, + /* forwardVelBase: */ 40, + /* forwardVelRange: */ 5, + /* velYBase: */ 30, + /* velYRange: */ 20, + /* gravity: */ 252, + /* dragStrength: */ 30, + /* sizeBase: */ 330.0f, + /* sizeRange: */ 10.0f, +}; // generate_wind_puffs/dust (something like that) void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) { sMistParticles.sizeBase = size; sMistParticles.sizeRange = size / 20.0; sMistParticles.offsetY = offsetY; + if (count == 0) { sMistParticles.count = 20; } else if (count > 20) { @@ -122,6 +107,7 @@ void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) { } else { sMistParticles.count = 4; } + cur_obj_spawn_particles(&sMistParticles); } @@ -159,16 +145,16 @@ void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) { // not sure what this is doing here. not in a behavior file. Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) { Mat4 sp20; - struct Object *sp1C; if (run == TRUE) { - sp1C = (struct Object *) gCurGraphNodeObject; + struct Object *sp1C = (struct Object *) gCurGraphNodeObject; if (sp1C == gMarioObject && sp1C->prevObj != NULL) { create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr); obj_update_pos_from_parent_transformation(sp20, sp1C->prevObj); obj_set_gfx_pos_from_pos(sp1C->prevObj); } } + return NULL; } @@ -185,6 +171,7 @@ void spawn_sparkle_particles(s32 n, s32 a1, s32 a2, s32 r) { static s16 D_8035FF10; s32 i; s16 separation = 0x10000 / n; // Evenly spread around a circle + for (i = 0; i < n; i++) { spawn_object_relative(0, sins(D_8035FF10 + i * separation) * a1, (i + 1) * a2, coss(D_8035FF10 + i * separation) * a1, o, MODEL_NONE, bhvSparkleSpawn); @@ -233,13 +220,17 @@ void vec3f_copy_2(Vec3f dest, Vec3f src) { s32 set_obj_anim_with_accel_and_sound(s16 a0, s16 a1, s32 a2) { f32 sp1C; - if ((sp1C = o->header.gfx.animInfo.animAccel / (f32) 0x10000) == 0) + + if ((sp1C = o->header.gfx.animInfo.animAccel / (f32) 0x10000) == 0) { sp1C = 1.0f; + } + if (cur_obj_check_anim_frame_in_range(a0, sp1C) || cur_obj_check_anim_frame_in_range(a1, sp1C)) { cur_obj_play_sound_2(a2); - return 1; + return TRUE; } - return 0; + + return FALSE; } #include "behaviors/tuxie.inc.c" diff --git a/src/game/behaviors/activated_bf_plat.inc.c b/src/game/behaviors/activated_bf_plat.inc.c index bb553c51..8b6399b7 100644 --- a/src/game/behaviors/activated_bf_plat.inc.c +++ b/src/game/behaviors/activated_bf_plat.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvActivatedBackAndForthPlatform. * There are only 2 of these in the game; the BitFS gray elevator @@ -16,7 +17,7 @@ * move off of it. To do this, they changed it to a bhvPlatformOnTrack, but * forgot to remove its entry in this table. */ -static void const *sActivatedBackAndForthPlatformCollisionModels[] = { +static Collision const *sActivatedBackAndForthPlatformCollisionModels[] = { /* ACTIVATED_BF_PLAT_TYPE_BITS_ARROW_PLAT */ bits_seg7_collision_0701AD54, /* ACTIVATED_BF_PLAT_TYPE_BITFS_MESH_PLAT */ bitfs_seg7_collision_070157E0, /* ACTIVATED_BF_PLAT_TYPE_BITFS_ELEVATOR */ bitfs_seg7_collision_07015124 @@ -61,7 +62,7 @@ void bhv_activated_back_and_forth_platform_init(void) { * Activated back-and-forth platform update function. */ void bhv_activated_back_and_forth_platform_update(void) { - UNUSED s32 unused[3]; + UNUSED u8 filler[12]; // oVelY is used for vertical platforms' movement and also for // horizontal platforms' dipping up/down when Mario gets on/off them @@ -78,7 +79,7 @@ void bhv_activated_back_and_forth_platform_update(void) { // and one more frame of "lag" after it finally reaches 0 here, // Mario actually has to wait 22 frames before the platform starts moving. if (o->oActivatedBackAndForthPlatformCountdown != 0) { - o->oActivatedBackAndForthPlatformCountdown -= 1; + o->oActivatedBackAndForthPlatformCountdown--; } else { // After the wait period is over, we start moving, by adding the velocity // to the positional offset. diff --git a/src/game/behaviors/amp.inc.c b/src/game/behaviors/amp.inc.c index 1a63bbb2..4fbdadb7 100644 --- a/src/game/behaviors/amp.inc.c +++ b/src/game/behaviors/amp.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvHomingAmp and bhvCirclingAmp. * These are distinct objects; one chases (homes in on) Mario, @@ -24,9 +25,9 @@ void bhv_homing_amp_init(void) { o->oHomeX = o->oPosX; o->oHomeY = o->oPosY; o->oHomeZ = o->oPosZ; - o->oGravity = 0; - o->oFriction = 1.0; - o->oBuoyancy = 1.0; + o->oGravity = 0.0f; + o->oFriction = 1.0f; + o->oBuoyancy = 1.0f; o->oHomingAmpAvgY = o->oHomeY; // Homing amps start at 1/10th their normal size. @@ -48,8 +49,9 @@ static void check_amp_attack(void) { if (o->oInteractStatus & INT_STATUS_INTERACTED) { // Unnecessary if statement, maybe caused by a macro for - // if (o->oInteractStatus & INT_STATUS_INTERACTED) + // if (o->oInteractStatus & INT_STATUS_INTERACTED) { // o->oAction = X; + // } // ? if (o->oInteractStatus & INT_STATUS_INTERACTED) { // This function is used for both normal amps and homing amps, @@ -88,7 +90,7 @@ static void homing_amp_appear_loop(void) { // Once the timer becomes greater than 90, i.e. 91 frames have passed, // reset the amp's size and start chasing Mario. - if (o->oTimer >= 91) { + if (o->oTimer > 90) { cur_obj_scale(1.0f); o->oAction = HOMING_AMP_ACT_CHASE; o->oAmpYPhase = 0; @@ -121,7 +123,7 @@ static void homing_amp_chase_loop(void) { o->oHomingAmpAvgY = gMarioObject->header.gfx.pos[1] + 150.0f; } - if (o->oTimer >= 31) { + if (o->oTimer > 30) { o->oHomingAmpLockedOn = FALSE; } } else { @@ -160,7 +162,7 @@ static void homing_amp_give_up_loop(void) { // Move forward for 152 frames o->oForwardVel = 15.0f; - if (o->oTimer >= 151) { + if (o->oTimer > 150) { // Hide the amp and reset it back to its inactive state o->oPosX = o->oHomeX; o->oPosY = o->oHomeY; @@ -168,7 +170,7 @@ static void homing_amp_give_up_loop(void) { o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; o->oAction = HOMING_AMP_ACT_INACTIVE; o->oAnimState = 0; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; o->oHomingAmpAvgY = o->oHomeY; } } @@ -179,15 +181,15 @@ static void homing_amp_give_up_loop(void) { static void amp_attack_cooldown_loop(void) { // Turn intangible and wait for 90 frames before chasing Mario again after hitting him. o->header.gfx.animInfo.animFrame += 2; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; cur_obj_become_intangible(); - if (o->oTimer >= 31) { + if (o->oTimer > 30) { o->oAnimState = 0; } - if (o->oTimer >= 91) { + if (o->oTimer > 90) { o->oAnimState = 1; cur_obj_become_tangible(); o->oAction = HOMING_AMP_ACT_CHASE; @@ -334,7 +336,6 @@ void bhv_circling_amp_loop(void) { } else { circling_amp_idle_loop(); } - break; case AMP_ACT_ATTACK_COOLDOWN: diff --git a/src/game/behaviors/animated_floor_switch.inc.c b/src/game/behaviors/animated_floor_switch.inc.c index 8f502310..e0e8471f 100644 --- a/src/game/behaviors/animated_floor_switch.inc.c +++ b/src/game/behaviors/animated_floor_switch.inc.c @@ -1,8 +1,8 @@ // animated_floor_switch.inc.c struct Struct80331A54 { - const void *unk00; - s16 unk04; + const Collision *collision; + s16 model; }; struct Struct80331A54 D_80331A54[][5] = { @@ -63,7 +63,7 @@ void bhv_animates_on_floor_switch_press_loop(void) { } if (o->oFloorSwitchPressAnimationUnkF8 < 9) { - o->oFloorSwitchPressAnimationUnkF8 += 1; + o->oFloorSwitchPressAnimationUnkF8++; } } else if ((o->oFloorSwitchPressAnimationUnkF8 -= 2) < 0) { o->oFloorSwitchPressAnimationUnkF8 = 0; @@ -71,7 +71,7 @@ void bhv_animates_on_floor_switch_press_loop(void) { } o->collisionData = segmented_to_virtual( - D_80331A54[o->oBehParams2ndByte][o->oFloorSwitchPressAnimationUnkF8 / 2].unk00); + D_80331A54[o->oBehParams2ndByte][o->oFloorSwitchPressAnimationUnkF8 / 2].collision); - cur_obj_set_model(D_80331A54[o->oBehParams2ndByte][o->oFloorSwitchPressAnimationUnkF8 / 2].unk04); + cur_obj_set_model(D_80331A54[o->oBehParams2ndByte][o->oFloorSwitchPressAnimationUnkF8 / 2].model); } diff --git a/src/game/behaviors/arrow_lift.inc.c b/src/game/behaviors/arrow_lift.inc.c index 127d3576..2dac2616 100644 --- a/src/game/behaviors/arrow_lift.inc.c +++ b/src/game/behaviors/arrow_lift.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for WDW arrow lifts. * When a player stands on an arrow lift, it starts moving between diff --git a/src/game/behaviors/bbh_haunted_bookshelf.inc.c b/src/game/behaviors/bbh_haunted_bookshelf.inc.c index 8a7eff1d..e6591217 100644 --- a/src/game/behaviors/bbh_haunted_bookshelf.inc.c +++ b/src/game/behaviors/bbh_haunted_bookshelf.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvHauntedBookshelf. * This is the bookshelf that recedes after solving the puzzle of the haunted books. @@ -29,6 +30,7 @@ void bhv_haunted_bookshelf_loop(void) { } break; + case HAUNTED_BOOKSHELF_ACT_RECEDE: // Move the bookshelf and play the sound o->oPosX += 5.0f; @@ -40,6 +42,7 @@ void bhv_haunted_bookshelf_loop(void) { } break; + default: break; } diff --git a/src/game/behaviors/bbh_merry_go_round.inc.c b/src/game/behaviors/bbh_merry_go_round.inc.c index 91640fde..5b634428 100644 --- a/src/game/behaviors/bbh_merry_go_round.inc.c +++ b/src/game/behaviors/bbh_merry_go_round.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvMerryGoRound. * This is the merry-go-round in BBH. diff --git a/src/game/behaviors/bbh_tilting_trap.inc.c b/src/game/behaviors/bbh_tilting_trap.inc.c index d18f33df..6f35cf06 100644 --- a/src/game/behaviors/bbh_tilting_trap.inc.c +++ b/src/game/behaviors/bbh_tilting_trap.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBbhTiltingTrapPlatform. * This is the tilting platform trap in the upper floor of BBH @@ -8,9 +9,9 @@ * Update function for bhvBbhTiltingTrapPlatform. */ void bhv_bbh_tilting_trap_platform_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; - // US (and probably later) versions use oAction for the + // Post-JP versions use oAction for the // if statement, while immediately setting it over here. // This was done so that Mario leaving or getting on the platform // resets oTimer to 0. @@ -29,14 +30,14 @@ void bhv_bbh_tilting_trap_platform_loop(void) { o->oFaceAnglePitch += o->oAngleVelPitch; } else #ifndef VERSION_JP - // In the US version, if the platform has tilted more than 3000 angle units + // In the post-JP versions, if the platform has tilted more than 3000 angle units // in less than 16 frames since Mario got on it, and he has stepped off, // this code will not run, so it will continue to rotate with the same // angular velocity for 16 more frames. This was probably done to make // the platform more dangerous. This code will not work correctly // without the oAction changes above, since oTimer will not ever // reset to 0 without them. - if ((absi(o->oFaceAnglePitch) < 3000) || (o->oTimer >= 16)) + if ((absi(o->oFaceAnglePitch) < 3000) || (o->oTimer > 15)) #endif { // Make the platform return to the horizontal at a speed of diff --git a/src/game/behaviors/beta_boo_key.inc.c b/src/game/behaviors/beta_boo_key.inc.c index 472aa0fb..23249555 100644 --- a/src/game/behaviors/beta_boo_key.inc.c +++ b/src/game/behaviors/beta_boo_key.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvAlphaBooKey and bhvBetaBooKey. * They were apparently intended to be a key that would be contained in boos @@ -163,8 +164,11 @@ static void beta_boo_key_inside_boo_loop(void) { o->oFaceAngleYaw += 0x200; } -static void (*sBetaBooKeyActions[])(void) = { beta_boo_key_inside_boo_loop, beta_boo_key_drop, - beta_boo_key_dropped_loop }; +static void (*sBetaBooKeyActions[])(void) = { + beta_boo_key_inside_boo_loop, + beta_boo_key_drop, + beta_boo_key_dropped_loop, +}; /** * Update function for bhvBetaBooKey. diff --git a/src/game/behaviors/beta_bowser_anchor.inc.c b/src/game/behaviors/beta_bowser_anchor.inc.c index e12d204c..f0475840 100644 --- a/src/game/behaviors/beta_bowser_anchor.inc.c +++ b/src/game/behaviors/beta_bowser_anchor.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBetaBowserAnchor. * This seems to be a beta bowser anchor object. It continuously updates to be @@ -9,15 +10,15 @@ * It continuously updates to be in front of Mario, * and attacks all non-Mario objects it touches. * It continuously sets its hitbox radius/height - * based on gDebugInfo[4]. + * based on gDebugInfo[DEBUG_PAGE_EFFECTINFO]. */ void bhv_beta_bowser_anchor_loop(void) { // Set the object's position to be 30 units above Mario's feet, // and 300 units in front of him. cur_obj_set_pos_relative(gMarioObject, 0, 30.0f, 300.0f); - o->hitboxRadius = gDebugInfo[4][0] + 100; - o->hitboxHeight = gDebugInfo[4][1] + 300; + o->hitboxRadius = gDebugInfo[DEBUG_PAGE_EFFECTINFO][0] + 100; + o->hitboxHeight = gDebugInfo[DEBUG_PAGE_EFFECTINFO][1] + 300; obj_attack_collided_from_other_object(o); } diff --git a/src/game/behaviors/beta_chest.inc.c b/src/game/behaviors/beta_chest.inc.c index 7a1a786d..53ac6149 100644 --- a/src/game/behaviors/beta_chest.inc.c +++ b/src/game/behaviors/beta_chest.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBetaChestBottom and bhvBetaChestLid. * These are apparently the beta versions of chests. @@ -49,6 +50,7 @@ void bhv_beta_chest_lid_loop(void) { } break; + case BETA_CHEST_ACT_OPENING: if (o->oTimer == 0) { // Spawn the bubble 80 units in the -Y direction and 120 units in the +Z direction. @@ -63,7 +65,7 @@ void bhv_beta_chest_lid_loop(void) { o->oAction++; // Set to BETA_CHEST_ACT_IDLE_OPEN } - // Fall-through + // fallthrough case BETA_CHEST_ACT_IDLE_OPEN: break; } diff --git a/src/game/behaviors/beta_fish_splash_spawner.inc.c b/src/game/behaviors/beta_fish_splash_spawner.inc.c index 6daab4c6..93a2ee12 100644 --- a/src/game/behaviors/beta_fish_splash_spawner.inc.c +++ b/src/game/behaviors/beta_fish_splash_spawner.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBetaFishSplashSpawner. * This is a now non-functional fish splash object found in WF @@ -12,6 +13,6 @@ * Update function for bhvBetaFishSplashSpawner. */ void bhv_beta_fish_splash_spawner_loop(void) { - UNUSED u8 pad[12]; - UNUSED f32 water_level = find_water_level(o->oPosX, o->oPosZ); + UNUSED u8 filler[12]; + UNUSED f32 waterLevel = find_water_level(o->oPosX, o->oPosZ); } diff --git a/src/game/behaviors/beta_holdable_object.inc.c b/src/game/behaviors/beta_holdable_object.inc.c index b4ec61f9..13af68e7 100644 --- a/src/game/behaviors/beta_holdable_object.inc.c +++ b/src/game/behaviors/beta_holdable_object.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBetaHoldableObject. * This is a simple implementation of a holdable object, probably used @@ -11,9 +12,9 @@ * Just sets various physics constants for the object. */ void bhv_beta_holdable_object_init(void) { - o->oGravity = 2.5; - o->oFriction = 0.8; - o->oBuoyancy = 1.3; + o->oGravity = 2.5f; + o->oFriction = 0.8f; + o->oBuoyancy = 1.3f; } /** @@ -27,8 +28,8 @@ static void beta_holdable_object_drop(void) { o->oHeldState = HELD_FREE; - o->oForwardVel = 0; - o->oVelY = 0; + o->oForwardVel = 0.0f; + o->oVelY = 0.0f; } /** @@ -46,8 +47,8 @@ static void beta_holdable_object_throw(void) { o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; // Set initial velocity - o->oForwardVel = 40.0; - o->oVelY = 20.0; + o->oForwardVel = 40.0f; + o->oVelY = 20.0f; } /** diff --git a/src/game/behaviors/beta_trampoline.inc.c b/src/game/behaviors/beta_trampoline.inc.c index f9c248f5..100ebc23 100644 --- a/src/game/behaviors/beta_trampoline.inc.c +++ b/src/game/behaviors/beta_trampoline.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBetaTrampolineTop and bhvBetaTrampolineSpring. * This was a trampoline that was never finished. The model and collision diff --git a/src/game/behaviors/bird.inc.c b/src/game/behaviors/bird.inc.c index e6d081a4..11d51058 100644 --- a/src/game/behaviors/bird.inc.c +++ b/src/game/behaviors/bird.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBird. These are the birds in the castle grounds * that fly away and scatter when Mario comes near them. There are @@ -52,7 +53,7 @@ static void bird_act_inactive(void) { * and the parent spawner bird if it's a spawned bird. */ static void bird_act_fly(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; f32 distance; // Compute forward velocity and vertical velocity from oBirdSpeed and pitch diff --git a/src/game/behaviors/blue_coin.inc.c b/src/game/behaviors/blue_coin.inc.c index d10e3600..902a6739 100644 --- a/src/game/behaviors/blue_coin.inc.c +++ b/src/game/behaviors/blue_coin.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvHiddenBlueCoin and bhvBlueCoinSwitch. * bhvHiddenBlueCoin are the stationary blue coins that appear when @@ -24,6 +25,7 @@ void bhv_hidden_blue_coin_loop(void) { } break; + case HIDDEN_BLUE_COIN_ACT_WAITING: // Wait until the blue coin switch starts ticking to activate. blueCoinSwitch = o->oHiddenBlueCoinSwitch; @@ -33,6 +35,7 @@ void bhv_hidden_blue_coin_loop(void) { } break; + case HIDDEN_BLUE_COIN_ACT_ACTIVE: // Become tangible cur_obj_enable_rendering(); @@ -85,6 +88,7 @@ void bhv_blue_coin_switch_loop(void) { load_object_collision_model(); break; + case BLUE_COIN_SWITCH_ACT_RECEDING: // Recede for 6 frames before going invisible and ticking. // This is probably an off-by-one error, since the switch is 100 units tall @@ -108,6 +112,7 @@ void bhv_blue_coin_switch_loop(void) { } break; + case BLUE_COIN_SWITCH_ACT_TICKING: // Tick faster when the blue coins start blinking if (o->oTimer < 200) { diff --git a/src/game/behaviors/blue_fish.inc.c b/src/game/behaviors/blue_fish.inc.c index dcaa35b3..452748da 100644 --- a/src/game/behaviors/blue_fish.inc.c +++ b/src/game/behaviors/blue_fish.inc.c @@ -1,3 +1,4 @@ + /** * @file blue_fish.inc.c * Implements behaviour and spawning for bhvBlueFish located in the castle aquarium outside of SA. @@ -8,17 +9,18 @@ */ void bhv_blue_fish_movement_loop(void) { f32 randomSwitch; + switch (o->oAction) { // Initial dive phase after spawning case BLUE_FISH_ACT_DIVE: cur_obj_init_animation_with_accel_and_sound(0, 1.0f); - + // Assigns random values to variables that help determine natural motion. if (o->oTimer == 0) { - o->oBlueFishRandomAngle = random_sign() << 11; + o->oBlueFishRandomAngle = random_sign() * 0x800; o->oBlueFishRandomVel = random_float() * 2; o->oBlueFishRandomTime = (s32)(random_float() * 30) & 0xFE; - + // Adjusts pitch velocity or sets to zero dependant on outcome of randomSwitch. randomSwitch = random_float() * 5; if (randomSwitch < 2.0f) { @@ -27,23 +29,24 @@ void bhv_blue_fish_movement_loop(void) { o->oAngleVelPitch = 0; } } - + // Set forward velocity and progress oAction to BLUE_FISH_ACT_TURN. o->oForwardVel = o->oBlueFishRandomVel + 3.0f; if (o->oTimer >= o->oBlueFishRandomTime + 60) { o->oAction++; } - + // Set pitch velocity if (o->oTimer < (o->oBlueFishRandomTime + 60) / 2) { o->oFaceAnglePitch += o->oAngleVelPitch; } else { o->oFaceAnglePitch -= o->oAngleVelPitch; } - + // Calculate new Y velocity o->oVelY = -sins(o->oFaceAnglePitch) * o->oForwardVel; break; + // Animates and adjusts fish yaw angle. case BLUE_FISH_ACT_TURN: cur_obj_init_animation_with_accel_and_sound(0, 2.0f); @@ -51,39 +54,41 @@ void bhv_blue_fish_movement_loop(void) { if (o->oTimer == 15) { o->oAction++; } - break; + break; + // Animates and adjusts pitch to an upward direction. case BLUE_FISH_ACT_ASCEND: cur_obj_init_animation_with_accel_and_sound(0, 1.0f); - - // Progresses oAction to BLUE_FISH_ACT_TURN_BACK after elapsed time. + + // Progresses oAction to BLUE_FISH_ACT_TURN_BACK after elapsed time. if (o->oTimer >= o->oBlueFishRandomTime + 60) { o->oAction++; } - + // Adjusts pitch angle. Direction relies on time not passed. if (o->oTimer < (o->oBlueFishRandomTime + 60) / 2) { o->oFaceAnglePitch -= o->oAngleVelPitch; } else { o->oFaceAnglePitch += o->oAngleVelPitch; } - break; + break; + // Animates and turns fish around case BLUE_FISH_ACT_TURN_BACK: cur_obj_init_animation_with_accel_and_sound(0, 2.0f); o->oMoveAngleYaw = (s32)(o->oBlueFishRandomAngle + o->oMoveAngleYaw); - + // Sets the fish back to the BLUE_FISH_ACT_DIVE phase. if (o->oTimer == 15) { o->oAction = BLUE_FISH_ACT_DIVE; } break; } - + // Calculates Y velocity and calls physics engine. o->oVelY = -sins(o->oFaceAnglePitch) * o->oForwardVel; cur_obj_move_using_fvel_and_gravity(); - + // Deletes object if the parent has oAction set to BLUE_FISH_ACT_DUPLICATE. if (o->parentObj->oAction == BLUE_FISH_ACT_DUPLICATE) { obj_mark_for_deletion(o); @@ -97,28 +102,29 @@ void bhv_blue_fish_movement_loop(void) { void bhv_tank_fish_group_loop(void) { struct Object *fish; s32 i; + switch (o->oAction) { case BLUE_FISH_ACT_SPAWN: if (gMarioCurrentRoom == 15 || gMarioCurrentRoom == 7) { - + // spawns fifteen fish and moves them within 200.0f for (i = 0; i < 15; i++) { fish = spawn_object_relative(0, 300, 0, -200, o, MODEL_FISH, bhvBlueFish); obj_translate_xyz_random(fish, 200.0f); } - + // Proceed to BLUE_FISH_ACT_ROOM phase. o->oAction++; } break; - + // Sets next oAction phase if Mario is not in rooms fifteen and seven. case BLUE_FISH_ACT_ROOM: if (gMarioCurrentRoom != 15 && gMarioCurrentRoom != 7) { o->oAction++; } break; - + // Sets oAction to the BLUE_FISH_ACT_SPAWN phase. case BLUE_FISH_ACT_DUPLICATE: o->oAction = BLUE_FISH_ACT_SPAWN; diff --git a/src/game/behaviors/bobomb.inc.c b/src/game/behaviors/bobomb.inc.c index 1f6124e4..4db4137b 100644 --- a/src/game/behaviors/bobomb.inc.c +++ b/src/game/behaviors/bobomb.inc.c @@ -1,4 +1,4 @@ -// bobomb.c.inc +// bobomb.inc.c static struct ObjectHitbox sBobombHitbox = { /* interactType: */ INTERACT_GRABBABLE, @@ -13,14 +13,14 @@ static struct ObjectHitbox sBobombHitbox = { }; void bhv_bobomb_init(void) { - o->oGravity = 2.5; - o->oFriction = 0.8; - o->oBuoyancy = 1.3; + o->oGravity = 2.5f; + o->oFriction = 0.8f; + o->oBuoyancy = 1.3f; o->oInteractionSubtype = INT_SUBTYPE_KICKABLE; } void bobomb_spawn_coin(void) { - if (((o->oBehParams >> 8) & 0x1) == 0) { + if (!((o->oBehParams >> 8) & 0x01)) { obj_spawn_yellow_coins(o, 1); o->oBehParams = 0x100; set_object_respawn_info_bits(o, 1); @@ -28,70 +28,70 @@ void bobomb_spawn_coin(void) { } void bobomb_act_explode(void) { - struct Object *explosion; - if (o->oTimer < 5) + if (o->oTimer < 5) { cur_obj_scale(1.0 + (f32) o->oTimer / 5.0); - else { - explosion = spawn_object(o, MODEL_EXPLOSION, bhvExplosion); + } else { + struct Object *explosion = spawn_object(o, MODEL_EXPLOSION, bhvExplosion); explosion->oGraphYOffset += 100.0f; bobomb_spawn_coin(); create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } - void bobomb_check_interactions(void) { obj_set_hitbox(o, &sBobombHitbox); - if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) - { - if ((o->oInteractStatus & INT_STATUS_MARIO_KNOCKBACK_DMG) != 0) - { + + if (o->oInteractStatus & INT_STATUS_INTERACTED) { + if (o->oInteractStatus & INT_STATUS_MARIO_KNOCKBACK_DMG) { o->oMoveAngleYaw = gMarioObject->header.gfx.angle[1]; - o->oForwardVel = 25.0; - o->oVelY = 30.0; + o->oForwardVel = 25.0f; + o->oVelY = 30.0f; o->oAction = BOBOMB_ACT_LAUNCHED; } - if ((o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB) != 0) + if (o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB) { o->oAction = BOBOMB_ACT_EXPLODE; + } o->oInteractStatus = 0; } - if (obj_attack_collided_from_other_object(o) == 1) + if (obj_attack_collided_from_other_object(o) == TRUE) { o->oAction = BOBOMB_ACT_EXPLODE; + } } void bobomb_act_patrol(void) { - UNUSED s8 filler[4]; - UNUSED s16 sp22; + UNUSED u8 filler[4]; + UNUSED s16 animFrame = o->header.gfx.animInfo.animFrame; s16 collisionFlags; - sp22 = o->header.gfx.animInfo.animFrame; - o->oForwardVel = 5.0; - + o->oForwardVel = 5.0f; collisionFlags = object_step(); - if ((obj_return_home_if_safe(o, o->oHomeX, o->oHomeY, o->oHomeZ, 400) == 1) + + if ((obj_return_home_if_safe(o, o->oHomeX, o->oHomeY, o->oHomeZ, 400) == TRUE) && (obj_check_if_facing_toward_angle(o->oMoveAngleYaw, o->oAngleToMario, 0x2000) == TRUE)) { o->oBobombFuseLit = 1; o->oAction = BOBOMB_ACT_CHASE_MARIO; } + obj_check_floor_death(collisionFlags, sObjFloor); } void bobomb_act_chase_mario(void) { UNUSED u8 filler[4]; - s16 sp1a, collisionFlags; - - sp1a = ++o->header.gfx.animInfo.animFrame; - o->oForwardVel = 20.0; + s16 animFrame = ++o->header.gfx.animInfo.animFrame; + s16 collisionFlags; + o->oForwardVel = 20.0f; collisionFlags = object_step(); - if (sp1a == 5 || sp1a == 16) + if (animFrame == 5 || animFrame == 16) { cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK); + } obj_turn_toward_object(o, gMarioObject, 16, 0x800); obj_check_floor_death(collisionFlags, sObjFloor); @@ -100,8 +100,9 @@ void bobomb_act_chase_mario(void) { void bobomb_act_launched(void) { s16 collisionFlags = 0; collisionFlags = object_step(); - if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) == OBJ_COL_FLAG_GROUNDED) - o->oAction = BOBOMB_ACT_EXPLODE; /* bit 0 */ + if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) == OBJ_COL_FLAG_GROUNDED) { + o->oAction = BOBOMB_ACT_EXPLODE; + } } void generic_bobomb_free_loop(void) { @@ -123,8 +124,9 @@ void generic_bobomb_free_loop(void) { break; case BOBOMB_ACT_LAVA_DEATH: - if (obj_lava_death() == 1) + if (obj_lava_death() == TRUE) { create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); + } break; case BOBOMB_ACT_DEATH_PLANE_DEATH: @@ -135,8 +137,9 @@ void generic_bobomb_free_loop(void) { bobomb_check_interactions(); - if (o->oBobombFuseTimer >= 151) + if (o->oBobombFuseTimer > 150) { o->oAction = 3; + } } void stationary_bobomb_free_loop(void) { @@ -150,8 +153,9 @@ void stationary_bobomb_free_loop(void) { break; case BOBOMB_ACT_LAVA_DEATH: - if (obj_lava_death() == 1) + if (obj_lava_death() == TRUE) { create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); + } break; case BOBOMB_ACT_DEATH_PLANE_DEATH: @@ -162,15 +166,17 @@ void stationary_bobomb_free_loop(void) { bobomb_check_interactions(); - if (o->oBobombFuseTimer >= 151) + if (o->oBobombFuseTimer > 150) { o->oAction = 3; + } } void bobomb_free_loop(void) { - if (o->oBehParams2ndByte == BOBOMB_BP_STYPE_GENERIC) + if (o->oBehParams2ndByte == BOBOMB_BP_STYPE_GENERIC) { generic_bobomb_free_loop(); - else + } else { stationary_bobomb_free_loop(); + } } void bobomb_held_loop(void) { @@ -179,7 +185,7 @@ void bobomb_held_loop(void) { cur_obj_set_pos_relative(gMarioObject, 0, 60.0f, 100.0); o->oBobombFuseLit = 1; - if (o->oBobombFuseTimer >= 151) { + if (o->oBobombFuseTimer > 150) { //! Although the Bob-omb's action is set to explode when the fuse timer expires, // bobomb_act_explode() will not execute until the bob-omb's held state changes. // This allows the Bob-omb to be regrabbed indefinitely. @@ -203,14 +209,12 @@ void bobomb_thrown_loop(void) { o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; o->oHeldState = 0; - o->oFlags &= ~0x8; /* bit 3 */ - o->oForwardVel = 25.0; - o->oVelY = 20.0; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; + o->oForwardVel = 25.0f; + o->oVelY = 20.0f; o->oAction = BOBOMB_ACT_LAUNCHED; } -// sp18 = blinkTimer - void curr_obj_random_blink(s32 *blinkTimer) { if (*blinkTimer == 0) { if ((s16)(random_float() * 100.0f) == 0) { @@ -219,11 +223,16 @@ void curr_obj_random_blink(s32 *blinkTimer) { } } else { (*blinkTimer)++; - if (*blinkTimer >= 6) + + if (*blinkTimer > 5) { o->oAnimState = 0; - if (*blinkTimer >= 11) + } + + if (*blinkTimer > 10) { o->oAnimState = 1; - if (*blinkTimer >= 16) { + } + + if (*blinkTimer > 15) { o->oAnimState = 0; *blinkTimer = 0; } @@ -232,7 +241,8 @@ void curr_obj_random_blink(s32 *blinkTimer) { void bhv_bobomb_loop(void) { s8 dustPeriodMinus1; - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 4000) != 0) { + + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 4000)) { switch (o->oHeldState) { case HELD_FREE: bobomb_free_loop(); @@ -254,14 +264,16 @@ void bhv_bobomb_loop(void) { curr_obj_random_blink(&o->oBobombBlinkTimer); if (o->oBobombFuseLit == 1) { - if (o->oBobombFuseTimer >= 121) + if (o->oBobombFuseTimer > 120) { dustPeriodMinus1 = 1; - else + } else { dustPeriodMinus1 = 7; + } - if ((dustPeriodMinus1 & o->oBobombFuseTimer) - == 0) /* oBobombFuseTimer % 2 or oBobombFuseTimer % 8 */ + // oBobombFuseTimer % 2 or oBobombFuseTimer % 8 + if (!(dustPeriodMinus1 & o->oBobombFuseTimer)) { spawn_object(o, MODEL_SMOKE, bhvBobombFuseSmoke); + } cur_obj_play_sound_1(SOUND_AIR_BOBOMB_LIT_FUSE); @@ -278,15 +290,15 @@ void bhv_bobomb_fuse_smoke_init(void) { } void bhv_bobomb_buddy_init(void) { - o->oGravity = 2.5; - o->oFriction = 0.8; - o->oBuoyancy = 1.3; + o->oGravity = 2.5f; + o->oFriction = 0.8f; + o->oBuoyancy = 1.3f; o->oInteractionSubtype = INT_SUBTYPE_NPC; } void bobomb_buddy_act_idle(void) { UNUSED u8 filler[4]; - s16 sp1a = o->header.gfx.animInfo.animFrame; + s16 animFrame = o->header.gfx.animInfo.animFrame; UNUSED s16 collisionFlags = 0; o->oBobombBuddyPosXCopy = o->oPosX; @@ -295,14 +307,17 @@ void bobomb_buddy_act_idle(void) { collisionFlags = object_step(); - if ((sp1a == 5) || (sp1a == 16)) + if (animFrame == 5 || animFrame == 16) { cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK); + } - if (o->oDistanceToMario < 1000.0f) + if (o->oDistanceToMario < 1000.0f) { o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, 0x140); + } - if (o->oInteractStatus == INT_STATUS_INTERACTED) + if (o->oInteractStatus == INT_STATUS_INTERACTED) { o->oAction = BOBOMB_BUDDY_ACT_TURN_TO_TALK; + } } /** @@ -320,27 +335,30 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) { switch (o->oBobombBuddyCannonStatus) { case BOBOMB_BUDDY_CANNON_UNOPENED: buddyText = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogFirstText); - if (buddyText != 0) { + if (buddyText != DIALOG_RESPONSE_NONE) { save_file_set_cannon_unlocked(); cannonClosed = cur_obj_nearest_object_with_behavior(bhvCannonClosed); - if (cannonClosed != 0) + if (cannonClosed != NULL) { o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_OPENING; - else + } else { o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_STOP_TALKING; + } } break; case BOBOMB_BUDDY_CANNON_OPENING: cannonClosed = cur_obj_nearest_object_with_behavior(bhvCannonClosed); cutscene = cutscene_object(CUTSCENE_PREPARE_CANNON, cannonClosed); - if (cutscene == -1) + if (cutscene == -1) { o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_OPENED; + } break; case BOBOMB_BUDDY_CANNON_OPENED: buddyText = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogSecondText); - if (buddyText != 0) + if (buddyText != DIALOG_RESPONSE_NONE) { o->oBobombBuddyCannonStatus = BOBOMB_BUDDY_CANNON_STOP_TALKING; + } break; case BOBOMB_BUDDY_CANNON_STOP_TALKING: @@ -373,23 +391,28 @@ void bobomb_buddy_act_talk(void) { break; case BOBOMB_BUDDY_ROLE_CANNON: - if (gCurrCourseNum == COURSE_BOB) + if (gCurrCourseNum == COURSE_BOB) { bobomb_buddy_cannon_dialog(DIALOG_004, DIALOG_105); - else + } else { bobomb_buddy_cannon_dialog(DIALOG_047, DIALOG_106); + } break; } } } void bobomb_buddy_act_turn_to_talk(void) { - s16 sp1e = o->header.gfx.animInfo.animFrame; - if ((sp1e == 5) || (sp1e == 16)) + s16 animFrame = o->header.gfx.animInfo.animFrame; + + if (animFrame == 5 || animFrame == 16) { cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK); + } o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, 0x1000); - if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario) + + if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario) { o->oAction = BOBOMB_BUDDY_ACT_TALK; + } cur_obj_play_sound_2(SOUND_ACTION_READ_SIGN); } diff --git a/src/game/behaviors/bomp.inc.c b/src/game/behaviors/bomp.inc.c index 26b38931..4109e2f9 100644 --- a/src/game/behaviors/bomp.inc.c +++ b/src/game/behaviors/bomp.inc.c @@ -1,4 +1,4 @@ -// bomp.c.inc +// bomp.inc.c void bhv_small_bomp_init(void) { o->oFaceAngleYaw -= 0x4000; @@ -9,7 +9,7 @@ void bhv_small_bomp_init(void) { void bhv_small_bomp_loop(void) { switch (o->oAction) { case BOMP_ACT_WAIT: - if (o->oTimer >= 101) { + if (o->oTimer > 100) { o->oAction = BOMP_ACT_POKE_OUT; o->oForwardVel = 30.0f; } @@ -18,7 +18,7 @@ void bhv_small_bomp_loop(void) { case BOMP_ACT_POKE_OUT: if (o->oPosX > 3450.0f) { o->oPosX = 3450.0f; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; } if (o->oTimer == 15.0) { @@ -31,7 +31,7 @@ void bhv_small_bomp_loop(void) { case BOMP_ACT_EXTEND: if (o->oPosX > 3830.0f) { o->oPosX = 3830.0f; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; } if (o->oTimer == 60) { @@ -45,7 +45,7 @@ void bhv_small_bomp_loop(void) { case BOMP_ACT_RETRACT: if (o->oPosX < 3330.0f) { o->oPosX = 3330.0f; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; } if (o->oTimer == 90) { @@ -65,7 +65,7 @@ void bhv_large_bomp_init(void) { void bhv_large_bomp_loop(void) { switch (o->oAction) { case BOMP_ACT_WAIT: - if (o->oTimer >= 101) { + if (o->oTimer > 100) { o->oAction = BOMP_ACT_POKE_OUT; o->oForwardVel = 30.0f; } @@ -74,7 +74,7 @@ void bhv_large_bomp_loop(void) { case BOMP_ACT_POKE_OUT: if (o->oPosX > 3450.0f) { o->oPosX = 3450.0f; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; } if (o->oTimer == 15.0) { @@ -87,7 +87,7 @@ void bhv_large_bomp_loop(void) { case BOMP_ACT_EXTEND: if (o->oPosX > 3830.0f) { o->oPosX = 3830.0f; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; } if (o->oTimer == 60) { @@ -101,7 +101,7 @@ void bhv_large_bomp_loop(void) { case BOMP_ACT_RETRACT: if (o->oPosX < 3330.0f) { o->oPosX = 3330.0f; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; } if (o->oTimer == 90) { diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index 24a11420..1f935acd 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -1,22 +1,24 @@ -// boo.c.inc +// boo.inc.c + +#define SPAWN_CASTLE_BOO_STAR_REQUIREMENT 12 static struct ObjectHitbox sBooGivingStarHitbox = { - /* interactType: */ 0, - /* downOffset: */ 0, + /* interactType: */ 0, + /* downOffset: */ 0, /* damageOrCoinValue: */ 3, - /* health: */ 3, - /* numLootCoins: */ 0, - /* radius: */ 140, - /* height: */ 80, - /* hurtboxRadius: */ 40, - /* hurtboxHeight: */ 60, + /* health: */ 3, + /* numLootCoins: */ 0, + /* radius: */ 140, + /* height: */ 80, + /* hurtboxRadius: */ 40, + /* hurtboxHeight: */ 60, }; // Relative positions static s16 sCourtyardBooTripletPositions[][3] = { - {0, 50, 0}, - {210, 110, 210}, - {-210, 70, -210} + { 0, 50, 0 }, + { 210, 110, 210 }, + { -210, 70, -210 }, }; static void boo_stop(void) { @@ -41,10 +43,8 @@ static s32 boo_should_be_stopped(void) { return TRUE; } - if (o->oRoom == 10) { - if (gTimeStopState & TIME_STOP_MARIO_OPENED_DOOR) { - return TRUE; - } + if (o->oRoom == 10 && (gTimeStopState & TIME_STOP_MARIO_OPENED_DOOR)) { + return TRUE; } } @@ -71,10 +71,8 @@ static s32 boo_should_be_active(void) { return TRUE; } } else if (!boo_should_be_stopped()) { - if ( - o->oDistanceToMario < activationRadius && - (o->oRoom == gMarioCurrentRoom || gMarioCurrentRoom == 0) - ) { + if (o->oDistanceToMario < activationRadius + && (o->oRoom == gMarioCurrentRoom || gMarioCurrentRoom == 0)) { return TRUE; } } @@ -84,21 +82,14 @@ static s32 boo_should_be_active(void) { void bhv_courtyard_boo_triplet_init(void) { s32 i; - struct Object *boo; - if (gHudDisplay.stars < 12) { + if (gHudDisplay.stars < SPAWN_CASTLE_BOO_STAR_REQUIREMENT) { obj_mark_for_deletion(o); } else { for (i = 0; i < 3; i++) { - boo = spawn_object_relative( - 0x01, - sCourtyardBooTripletPositions[i][0], - sCourtyardBooTripletPositions[i][1], - sCourtyardBooTripletPositions[i][2], - o, - MODEL_BOO, - bhvGhostHuntBoo - ); + struct Object *boo = spawn_object_relative( + 1, sCourtyardBooTripletPositions[i][0], sCourtyardBooTripletPositions[i][1], + sCourtyardBooTripletPositions[i][2], o, MODEL_BOO, bhvGhostHuntBoo); boo->oMoveAngleYaw = random_u16(); } @@ -124,14 +115,14 @@ static void boo_approach_target_opacity_and_update_scale(void) { } } - scale = (o->oOpacity/255.0f * 0.4 + 0.6) * o->oBooBaseScale; + scale = (o->oOpacity / 255.0f * 0.4 + 0.6) * o->oBooBaseScale; obj_scale(o, scale); // why no cur_obj_scale? was cur_obj_scale written later? } static void boo_oscillate(s32 ignoreOpacity) { o->oFaceAnglePitch = sins(o->oBooOscillationTimer) * 0x400; - if (o->oOpacity == 0xFF || ignoreOpacity == TRUE) { + if (o->oOpacity == 255 || ignoreOpacity == TRUE) { o->header.gfx.scale[0] = sins(o->oBooOscillationTimer) * 0.08 + o->oBooBaseScale; o->header.gfx.scale[1] = -sins(o->oBooOscillationTimer) * 0.08 + o->oBooBaseScale; o->header.gfx.scale[2] = o->header.gfx.scale[0]; @@ -145,15 +136,13 @@ static s32 boo_vanish_or_appear(void) { s16 relativeMarioFaceAngle = abs_angle_diff(o->oMoveAngleYaw, gMarioObject->oFaceAngleYaw); // magic? s16 relativeAngleToMarioThreshhold = 0x1568; - s16 relativeMarioFaceAngleThreshhold = 0x6b58; + s16 relativeMarioFaceAngleThreshhold = 0x6B58; s32 doneAppearing = FALSE; o->oVelY = 0.0f; - if ( - relativeAngleToMario > relativeAngleToMarioThreshhold || - relativeMarioFaceAngle < relativeMarioFaceAngleThreshhold - ) { + if (relativeAngleToMario > relativeAngleToMarioThreshhold + || relativeMarioFaceAngle < relativeMarioFaceAngleThreshhold) { if (o->oOpacity == 40) { o->oBooTargetOpacity = 255; cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_LONG); @@ -175,9 +164,9 @@ static void boo_set_move_yaw_for_during_hit(s32 hurt) { o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oBooMoveYawBeforeHit = (f32) o->oMoveAngleYaw; - if (hurt != FALSE) { + if (hurt) { o->oBooMoveYawDuringHit = gMarioObject->oMoveAngleYaw; - } else if (coss((s16)o->oMoveAngleYaw - (s16)o->oAngleToMario) < 0.0f) { + } else if (coss((s16) o->oMoveAngleYaw - (s16) o->oAngleToMario) < 0.0f) { o->oBooMoveYawDuringHit = o->oMoveAngleYaw; } else { o->oBooMoveYawDuringHit = (s16)(o->oMoveAngleYaw + 0x8000); @@ -196,7 +185,7 @@ static void boo_move_during_hit(s32 roll, f32 fVel) { o->oVelY = coss(oscillationVel); o->oMoveAngleYaw = o->oBooMoveYawDuringHit; - if (roll != FALSE) { + if (roll) { o->oFaceAngleYaw += sBooHitRotations[o->oTimer]; o->oFaceAngleRoll += sBooHitRotations[o->oTimer]; } @@ -223,11 +212,12 @@ static s32 boo_update_after_bounced_on(f32 a0) { } if (o->oTimer < 32) { - boo_move_during_hit(FALSE, sBooHitRotations[o->oTimer]/5000.0f * a0); + boo_move_during_hit(FALSE, sBooHitRotations[o->oTimer] / 5000.0f * a0); } else { cur_obj_become_tangible(); boo_reset_after_hit(); o->oAction = 1; + return TRUE; } @@ -243,13 +233,12 @@ static s32 big_boo_update_during_nonlethal_hit(f32 a0) { } if (o->oTimer < 32) { - boo_move_during_hit(TRUE, sBooHitRotations[o->oTimer]/5000.0f * a0); + boo_move_during_hit(TRUE, sBooHitRotations[o->oTimer] / 5000.0f * a0); } else if (o->oTimer < 48) { big_boo_shake_after_hit(); } else { cur_obj_become_tangible(); boo_reset_after_hit(); - o->oAction = 1; return TRUE; @@ -261,8 +250,6 @@ static s32 big_boo_update_during_nonlethal_hit(f32 a0) { // called every frame once mario lethally hits the boo until the boo is deleted, // returns whether death is complete static s32 boo_update_during_death(void) { - struct Object *parentBigBoo; - if (o->oTimer == 0) { o->oForwardVel = 40.0f; o->oMoveAngleYaw = gMarioObject->oMoveAngleYaw; @@ -278,14 +265,14 @@ static s32 boo_update_during_death(void) { o->oBooDeathStatus = BOO_DEATH_STATUS_DEAD; if (o->oBooParentBigBoo != NULL) { - parentBigBoo = o->oBooParentBigBoo; + struct Object *parentBigBoo = o->oBooParentBigBoo; #ifndef VERSION_JP if (!cur_obj_has_behavior(bhvBoo)) { +#endif parentBigBoo->oBigBooNumMinionBoosKilled++; +#ifndef VERSION_JP } -#else - parentBigBoo->oBigBooNumMinionBoosKilled++; #endif } @@ -312,7 +299,8 @@ static s32 boo_get_attack_status(void) { s32 attackStatus = BOO_NOT_ATTACKED; if (o->oInteractStatus & INT_STATUS_INTERACTED) { - if ((o->oInteractStatus & INT_STATUS_WAS_ATTACKED) && !obj_has_attack_type(ATTACK_FROM_ABOVE)) { + if ((o->oInteractStatus & INT_STATUS_WAS_ATTACKED) + && !obj_has_attack_type(ATTACK_FROM_ABOVE)) { cur_obj_become_intangible(); o->oInteractStatus = 0; @@ -338,7 +326,7 @@ static void boo_chase_mario(f32 a0, s16 a1, f32 a2) { s16 sp1A; if (boo_vanish_or_appear()) { - o->oInteractType = 0x8000; + o->oInteractType = INTERACT_BOUNCE_TOP; if (cur_obj_lateral_dist_from_mario_to_home() > 1500.0f) { sp1A = cur_obj_angle_to_home(); @@ -349,10 +337,11 @@ static void boo_chase_mario(f32 a0, s16 a1, f32 a2) { cur_obj_rotate_yaw_toward(sp1A, a1); o->oVelY = 0.0f; - if (mario_is_in_air_action() == 0) { + if (!mario_is_in_air_action()) { sp1C = o->oPosY - gMarioObject->oPosY; if (a0 < sp1C && sp1C < 500.0f) { - o->oVelY = increment_velocity_toward_range(o->oPosY, gMarioObject->oPosY + 50.0f, 10.f, 2.0f); + o->oVelY = increment_velocity_toward_range + (o->oPosY, gMarioObject->oPosY + 50.0f, 10.0f, 2.0f); } } @@ -383,7 +372,7 @@ static void boo_act_0(void) { o->oBooParentBigBoo = cur_obj_nearest_object_with_behavior(bhvGhostHuntBigBoo); o->oBooBaseScale = 1.0f; - o->oBooTargetOpacity = 0xFF; + o->oBooTargetOpacity = 255; if (boo_should_be_active()) { // Condition is met if the object is bhvBalconyBigBoo or bhvMerryGoRoundBoo @@ -417,6 +406,7 @@ static void boo_act_1(void) { } boo_chase_mario(-100.0f, o->oBooTurningSpeed + 0x180, 0.5f); + attackStatus = boo_get_attack_status(); if (boo_should_be_stopped()) { @@ -480,7 +470,7 @@ static void (*sBooActions[])(void) = { boo_act_2, boo_act_3, boo_act_4, - boo_act_5 + boo_act_5, }; void bhv_boo_loop(void) { @@ -491,10 +481,9 @@ void bhv_boo_loop(void) { cur_obj_move_standard(78); boo_approach_target_opacity_and_update_scale(); - if (obj_has_behavior(o->parentObj, bhvMerryGoRoundBooManager)) { - if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) { - o->parentObj->oMerryGoRoundBooManagerNumBoosKilled++; - } + if (obj_has_behavior(o->parentObj, bhvMerryGoRoundBooManager) + && o->activeFlags == ACTIVE_FLAG_DEACTIVATED) { + o->parentObj->oMerryGoRoundBooManagerNumBoosKilled++; } o->oInteractStatus = 0; @@ -510,11 +499,13 @@ static void big_boo_act_0(void) { o->oBooParentBigBoo = NULL; + if (boo_should_be_active() #ifndef VERSION_JP - if (boo_should_be_active() && gDebugInfo[5][0] + 5 <= o->oBigBooNumMinionBoosKilled) { + && o->oBigBooNumMinionBoosKilled >= gDebugInfo[DEBUG_PAGE_ENEMYINFO][0] + 5 #else - if (boo_should_be_active() && o->oBigBooNumMinionBoosKilled >= 5) { + && o->oBigBooNumMinionBoosKilled >= 5 #endif + ) { o->oAction = 1; cur_obj_set_pos_to_home(); @@ -522,7 +513,7 @@ static void big_boo_act_0(void) { cur_obj_unhide(); - o->oBooTargetOpacity = 0xFF; + o->oBooTargetOpacity = 255; o->oBooBaseScale = 3.0f; o->oHealth = 3; @@ -569,7 +560,7 @@ static void big_boo_act_1(void) { o->oAction = 3; } - if (attackStatus == 1) { + if (attackStatus == BOO_ATTACKED) { create_sound_spawner(SOUND_OBJ_THWOMP); } } @@ -660,7 +651,7 @@ static void (*sBooGivingStarActions[])(void) = { big_boo_act_1, big_boo_act_2, big_boo_act_3, - big_boo_act_4 + big_boo_act_4, }; void bhv_big_boo_loop(void) { @@ -675,12 +666,13 @@ void bhv_big_boo_loop(void) { cur_obj_move_standard(78); boo_approach_target_opacity_and_update_scale(); + o->oInteractStatus = 0; } static void boo_with_cage_act_0(void) { o->oBooParentBigBoo = NULL; - o->oBooTargetOpacity = 0xFF; + o->oBooTargetOpacity = 255; o->oBooBaseScale = 2.0f; cur_obj_scale(2.0f); @@ -724,12 +716,10 @@ static void boo_with_cage_act_3(void) { } void bhv_boo_with_cage_init(void) { - struct Object* cage; - - if (gHudDisplay.stars < 12) { + if (gHudDisplay.stars < SPAWN_CASTLE_BOO_STAR_REQUIREMENT) { obj_mark_for_deletion(o); } else { - cage = spawn_object(o, MODEL_HAUNTED_CAGE, bhvBooCage); + struct Object *cage = spawn_object(o, MODEL_HAUNTED_CAGE, bhvBooCage); cage->oBehParams = o->oBehParams; } } @@ -738,11 +728,10 @@ static void (*sBooWithCageActions[])(void) = { boo_with_cage_act_0, boo_with_cage_act_1, boo_with_cage_act_2, - boo_with_cage_act_3 + boo_with_cage_act_3, }; -void bhv_boo_with_cage_loop(void) -{ +void bhv_boo_with_cage_loop(void) { //PARTIAL_UPDATE cur_obj_update_floor_and_walls(); @@ -750,6 +739,7 @@ void bhv_boo_with_cage_loop(void) cur_obj_move_standard(78); boo_approach_target_opacity_and_update_scale(); + o->oInteractStatus = 0; } @@ -759,7 +749,8 @@ void bhv_merry_go_round_boo_manager_loop(void) { if (o->oDistanceToMario < 1000.0f) { if (o->oMerryGoRoundBooManagerNumBoosKilled < 5) { if (o->oMerryGoRoundBooManagerNumBoosSpawned != 5) { - if (o->oMerryGoRoundBooManagerNumBoosSpawned - o->oMerryGoRoundBooManagerNumBoosKilled < 2) { + if (o->oMerryGoRoundBooManagerNumBoosSpawned + - o->oMerryGoRoundBooManagerNumBoosKilled < 2) { spawn_object(o, MODEL_BOO, bhvMerryGoRoundBoo); o->oMerryGoRoundBooManagerNumBoosSpawned++; } @@ -768,7 +759,7 @@ void bhv_merry_go_round_boo_manager_loop(void) { o->oAction++; } - if (o->oMerryGoRoundBooManagerNumBoosKilled > 4) { + if (o->oMerryGoRoundBooManagerNumBoosKilled >= 5) { struct Object *boo = spawn_object(o, MODEL_BOO, bhvMerryGoRoundBigBoo); obj_copy_behavior_params(boo, o); @@ -783,12 +774,14 @@ void bhv_merry_go_round_boo_manager_loop(void) { } break; + case 1: if (o->oTimer > 60) { o->oAction = 0; } break; + case 2: break; } @@ -810,7 +803,7 @@ void bhv_boo_in_castle_loop(void) { if (o->oAction == 0) { cur_obj_hide(); - if (gHudDisplay.stars < 12) { + if (gHudDisplay.stars < SPAWN_CASTLE_BOO_STAR_REQUIREMENT) { obj_mark_for_deletion(o); } @@ -878,7 +871,7 @@ void bhv_boo_staircase(void) { break; } - switch(o->oAction) { + switch (o->oAction) { case 0: o->oPosY = o->oHomeY - 620.0f; o->oAction++; @@ -893,6 +886,7 @@ void bhv_boo_staircase(void) { } break; + case 2: if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4_LOWPRIO); @@ -903,6 +897,7 @@ void bhv_boo_staircase(void) { } break; + case 3: if (o->oTimer == 0 && o->oBehParams2ndByte == 1) { play_puzzle_jingle(); diff --git a/src/game/behaviors/boo_cage.inc.c b/src/game/behaviors/boo_cage.inc.c index 24e4e062..76f1f04e 100644 --- a/src/game/behaviors/boo_cage.inc.c +++ b/src/game/behaviors/boo_cage.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvBooCage. * This is the cage inside the big boo in the castle courtyard @@ -10,22 +11,22 @@ * Mario has to enter to enter BBH. */ static struct ObjectHitbox sBooCageHitbox = { - /* interactType: */ INTERACT_BBH_ENTRANCE, - /* downOffset: */ 0, + /* interactType: */ INTERACT_BBH_ENTRANCE, + /* downOffset: */ 0, /* damageOrCoinValue: */ 0, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 120, - /* height: */ 300, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 120, + /* height: */ 300, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; /** * Update function for bhvBooCage. */ void bhv_boo_cage_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; obj_set_hitbox(o, &sBooCageHitbox); @@ -50,6 +51,7 @@ void bhv_boo_cage_loop(void) { } break; + case BOO_CAGE_ACT_FALLING: // Reset pitch and roll. This is useless, since the cage never rotates. // Was it meant to rotate inside the boo, like the beta boo key? @@ -78,6 +80,7 @@ void bhv_boo_cage_loop(void) { } break; + case BOO_CAGE_ACT_ON_GROUND: // Allow Mario to enter the cage once it's still on the ground. cur_obj_become_tangible(); @@ -91,6 +94,7 @@ void bhv_boo_cage_loop(void) { } break; + case BOO_CAGE_ACT_MARIO_JUMPING_IN: // All this action does is wait 100 frames after Mario starts // jumping into the cage to set the action to BOO_CAGE_ACT_USELESS, @@ -101,6 +105,7 @@ void bhv_boo_cage_loop(void) { } break; + case BOO_CAGE_ACT_USELESS: break; } diff --git a/src/game/behaviors/boulder.inc.c b/src/game/behaviors/boulder.inc.c index 18bd53fb..7a685bbd 100644 --- a/src/game/behaviors/boulder.inc.c +++ b/src/game/behaviors/boulder.inc.c @@ -1,4 +1,4 @@ -// boulder.c.inc +// boulder.inc.c void bhv_big_boulder_init(void) { o->oHomeX = o->oPosX; @@ -11,24 +11,27 @@ void bhv_big_boulder_init(void) { } void boulder_act_1(void) { - s16 sp1E; + s16 collisionFlags = object_step_without_floor_orient(); - sp1E = object_step_without_floor_orient(); - if ((sp1E & 0x09) == 0x01 && o->oVelY > 10.0f) { + if ((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAG_GROUNDED && o->oVelY > 10.0f) { cur_obj_play_sound_2(SOUND_GENERAL_GRINDEL_ROLL); spawn_mist_particles(); } - if (o->oForwardVel > 70.0) + if (o->oForwardVel > 70.0) { o->oForwardVel = 70.0f; + } - if (o->oPosY < -1000.0f) + if (o->oPosY < -1000.0f) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } void bhv_big_boulder_loop(void) { cur_obj_scale(1.5f); + o->oGraphYOffset = 270.0f; + switch (o->oAction) { case 0: o->oForwardVel = 40.0f; @@ -47,20 +50,23 @@ void bhv_big_boulder_loop(void) { void bhv_big_boulder_generator_loop(void) { struct Object *sp1C; + if (o->oTimer >= 256) { o->oTimer = 0; } - if (!current_mario_room_check(4) || is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1500)) + if (!current_mario_room_check(4) + || is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1500)) { return; + } if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 6000)) { - if ((o->oTimer & 0x3F) == 0) { + if (!(o->oTimer & 0x3F)) { sp1C = spawn_object(o, MODEL_HMC_ROLLING_ROCK, bhvBigBoulder); sp1C->oMoveAngleYaw = random_float() * 4096.0f; } } else { - if ((o->oTimer & 0x7F) == 0) { + if (!(o->oTimer & 0x7F)) { sp1C = spawn_object(o, MODEL_HMC_ROLLING_ROCK, bhvBigBoulder); sp1C->oMoveAngleYaw = random_float() * 4096.0f; } diff --git a/src/game/behaviors/bouncing_fireball.inc.c b/src/game/behaviors/bouncing_fireball.inc.c index 89dcfd18..49b8bdc6 100644 --- a/src/game/behaviors/bouncing_fireball.inc.c +++ b/src/game/behaviors/bouncing_fireball.inc.c @@ -1,54 +1,79 @@ -// bouncing_fireball.c.inc +// bouncing_fireball.inc.c void bhv_bouncing_fireball_flame_loop(void) { o->activeFlags |= ACTIVE_FLAG_UNK10; + cur_obj_update_floor_and_walls(); + switch (o->oAction) { case 0: if (o->oTimer == 0) { o->oAnimState = random_float() * 10.0f; o->oVelY = 30.0f; } - if (o->oMoveFlags & OBJ_MOVE_LANDED) + + if (o->oMoveFlags & OBJ_MOVE_LANDED) { o->oAction++; + } break; + case 1: if (o->oTimer == 0) { o->oVelY = 50.0f; o->oForwardVel = 30.0f; } - if (o->oMoveFlags & (OBJ_MOVE_UNDERWATER_ON_GROUND | OBJ_MOVE_AT_WATER_SURFACE | OBJ_MOVE_ON_GROUND) && o->oTimer > 100) + + if (o->oMoveFlags + & (OBJ_MOVE_ON_GROUND | OBJ_MOVE_AT_WATER_SURFACE | OBJ_MOVE_UNDERWATER_ON_GROUND) + && o->oTimer > 100) { obj_mark_for_deletion(o); + } break; } - if (o->oTimer > 300) + + if (o->oTimer > 300) { obj_mark_for_deletion(o); + } + cur_obj_move_standard(78); + o->oInteractStatus = 0; } void bhv_bouncing_fireball_loop(void) { struct Object *sp2C; f32 sp28; + switch (o->oAction) { case 0: - if (o->oDistanceToMario < 2000.0f) + if (o->oDistanceToMario < 2000.0f) { o->oAction = 1; + } break; + case 1: sp2C = spawn_object(o, MODEL_RED_FLAME, bhvBouncingFireballFlame); sp28 = (10 - o->oTimer) * 0.5; + obj_scale_xyz(sp2C, sp28, sp28, sp28); - if (o->oTimer == 0) + + if (o->oTimer == 0) { obj_become_tangible(sp2C); - if (o->oTimer > 10) + } + + if (o->oTimer > 10) { o->oAction++; + } break; + case 2: - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oBouncingFireBallUnkF4 = random_float() * 100.0f; - if (o->oBouncingFireBallUnkF4 + 100 < o->oTimer) + } + + if (o->oBouncingFireBallUnkF4 + 100 < o->oTimer) { o->oAction = 0; + } break; } } diff --git a/src/game/behaviors/bowling_ball.inc.c b/src/game/behaviors/bowling_ball.inc.c index 0b9a139b..34fefb36 100644 --- a/src/game/behaviors/bowling_ball.inc.c +++ b/src/game/behaviors/bowling_ball.inc.c @@ -1,4 +1,4 @@ -// bowling_ball.c.inc +// bowling_ball.inc.c static struct ObjectHitbox sBowlingBallHitbox = { /* interactType: */ INTERACT_DAMAGE, @@ -48,8 +48,9 @@ void bhv_bowling_ball_init(void) { void bowling_ball_set_hitbox(void) { obj_set_hitbox(o, &sBowlingBallHitbox); - if (o->oInteractStatus & INT_STATUS_INTERACTED) + if (o->oInteractStatus & INT_STATUS_INTERACTED) { o->oInteractStatus = 0; + } } void bowling_ball_set_waypoints(void) { @@ -78,16 +79,16 @@ void bowling_ball_set_waypoints(void) { void bhv_bowling_ball_roll_loop(void) { s16 collisionFlags; - s32 sp18; + s32 followStatus; #ifdef AVOID_UB - sp18 = 0; + followStatus = 0; #endif bowling_ball_set_waypoints(); collisionFlags = object_step(); //! Uninitialzed parameter, but the parameter is unused in the called function - sp18 = cur_obj_follow_path(sp18); + followStatus = cur_obj_follow_path(followStatus); o->oBowlingBallTargetYaw = o->oPathedTargetYaw; o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oBowlingBallTargetYaw, 0x400); @@ -97,7 +98,7 @@ void bhv_bowling_ball_roll_loop(void) { bowling_ball_set_hitbox(); - if (sp18 == -1) { + if (followStatus == PATH_REACHED_END) { if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 7000)) { spawn_mist_particles(); spawn_mist_particles_variable(0, 0, 92.0f); @@ -106,20 +107,21 @@ void bhv_bowling_ball_roll_loop(void) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && (o->oVelY > 5.0f)) + if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && (o->oVelY > 5.0f)) { cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1_LOWPRIO); + } } -void bhv_bowling_ball_initializeLoop(void) { - s32 sp1c; +void bhv_bowling_ball_initialize_loop(void) { + s32 followStatus; #ifdef AVOID_UB - sp1c = 0; + followStatus = 0; #endif bowling_ball_set_waypoints(); //! Uninitialzed parameter, but the parameter is unused in the called function - sp1c = cur_obj_follow_path(sp1c); + followStatus = cur_obj_follow_path(followStatus); o->oMoveAngleYaw = o->oPathedTargetYaw; @@ -152,7 +154,7 @@ void bhv_bowling_ball_loop(void) { switch (o->oAction) { case BBALL_ACT_INITIALIZE: o->oAction = BBALL_ACT_ROLL; - bhv_bowling_ball_initializeLoop(); + bhv_bowling_ball_initialize_loop(); break; case BBALL_ACT_ROLL: @@ -160,8 +162,9 @@ void bhv_bowling_ball_loop(void) { break; } - if (o->oBehParams2ndByte != 4) + if (o->oBehParams2ndByte != BBALL_BP_STYPE_THI_SMALL) { set_camera_shake_from_point(SHAKE_POS_BOWLING_BALL, o->oPosX, o->oPosY, o->oPosZ); + } set_object_visibility(o, 4000); } @@ -186,42 +189,39 @@ void bhv_generic_bowling_ball_spawner_init(void) { } void bhv_generic_bowling_ball_spawner_loop(void) { - struct Object *bowlingBall; - - if (o->oTimer == 256) + if (o->oTimer == 256) { o->oTimer = 0; + } if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000) - || (o->oPosY < gMarioObject->header.gfx.pos[1])) + || o->oPosY < gMarioObject->header.gfx.pos[1]) { return; + } - if ((o->oTimer & o->oBBallSpawnerPeriodMinus1) == 0) /* Modulus */ - { - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, o->oBBallSpawnerMaxSpawnDist)) { - if ((s32)(random_float() * o->oBBallSpawnerSpawnOdds) == 0) { - bowlingBall = spawn_object(o, MODEL_BOWLING_BALL, bhvBowlingBall); - bowlingBall->oBehParams2ndByte = o->oBehParams2ndByte; - } + if ((o->oTimer & o->oBBallSpawnerPeriodMinus1) == 0) { /* Modulus */ + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, o->oBBallSpawnerMaxSpawnDist) + && (s32)(random_float() * o->oBBallSpawnerSpawnOdds) == 0) { + struct Object *bowlingBall = spawn_object(o, MODEL_BOWLING_BALL, bhvBowlingBall); + bowlingBall->oBehParams2ndByte = o->oBehParams2ndByte; } } } void bhv_thi_bowling_ball_spawner_loop(void) { - struct Object *bowlingBall; - - if (o->oTimer == 256) + if (o->oTimer == 256) { o->oTimer = 0; + } if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 800) - || (o->oPosY < gMarioObject->header.gfx.pos[1])) + || o->oPosY < gMarioObject->header.gfx.pos[1]) { return; + } if ((o->oTimer % 64) == 0) { - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 12000)) { - if ((s32)(random_float() * 1.5) == 0) { - bowlingBall = spawn_object(o, MODEL_BOWLING_BALL, bhvBowlingBall); - bowlingBall->oBehParams2ndByte = o->oBehParams2ndByte; - } + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 12000) + && (s32)(random_float() * 1.5) == 0) { + struct Object *bowlingBall = spawn_object(o, MODEL_BOWLING_BALL, bhvBowlingBall); + bowlingBall->oBehParams2ndByte = o->oBehParams2ndByte; } } } @@ -237,8 +237,9 @@ void bhv_bob_pit_bowling_ball_loop(void) { UNUSED s16 collisionFlags = object_step(); find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp1c); - if ((sp1c->normalX == 0) && (sp1c->normalZ == 0)) + if ((sp1c->normalX == 0) && (sp1c->normalZ == 0)) { o->oForwardVel = 28.0f; + } bowling_ball_set_hitbox(); set_camera_shake_from_point(SHAKE_POS_BOWLING_BALL, o->oPosX, o->oPosY, o->oPosZ); @@ -259,6 +260,7 @@ void bhv_free_bowling_ball_init(void) { void bhv_free_bowling_ball_roll_loop(void) { s16 collisionFlags = object_step(); + bowling_ball_set_hitbox(); if (o->oForwardVel > 10.0f) { @@ -266,8 +268,9 @@ void bhv_free_bowling_ball_roll_loop(void) { cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2); } - if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && !(collisionFlags & OBJ_COL_FLAGS_LANDED)) + if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && !(collisionFlags & OBJ_COL_FLAGS_LANDED)) { cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1_LOWPRIO); + } if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 6000)) { o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; @@ -298,8 +301,9 @@ void bhv_free_bowling_ball_loop(void) { break; case FREE_BBALL_ACT_RESET: - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 5000)) + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 5000)) { o->oAction = FREE_BBALL_ACT_IDLE; + } break; } } diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c index 4c29cce6..2cd9a96c 100644 --- a/src/game/behaviors/bowser.inc.c +++ b/src/game/behaviors/bowser.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for Bowser and it's actions (Tail, Flame, Body) */ @@ -14,7 +15,7 @@ void bowser_tail_anchor_act_default(void) { cur_obj_scale(1.0f); if (bowser->oAction == BOWSER_ACT_TILT_LAVA_PLATFORM) { - // Bowser cannot be touched when he tilts BITFS platform + // Bowser cannot be touched when he tilts BitFS platform bowser->oIntangibleTimer = -1; } else if (obj_check_if_collided_with_object(o, gMarioObject)) { // When Mario collides his tail, it now gets @@ -40,7 +41,7 @@ void bowser_tail_anchor_thrown(void) { * Makes the tail intangible so Mario can grab it */ void bowser_tail_anchor_act_touched_mario(void) { - // Return to main action when Bowser tilts BITFS platform + // Return to main action when Bowser tilts BitFS platform if (o->parentObj->oAction == BOWSER_ACT_TILT_LAVA_PLATFORM) { o->parentObj->oIntangibleTimer = -1; o->oAction = BOWSER_ACT_TAIL_DEFAULT; @@ -123,7 +124,7 @@ void bhv_bowser_body_anchor_loop(void) { // so that he can be ready to speak his dialog if (o->parentObj->oAction == BOWSER_ACT_DEAD) { #if BUGFIX_BOWSER_COLLIDE_BITS_DEAD - // Clear interaction type at the last sub action in BITS + // Clear interaction type at the last sub action in BitS // Fixes collision coliding after defeating him if (o->parentObj->oSubAction == BOWSER_SUB_ACT_DEAD_FINAL_END_OVER) { o->oInteractType = 0; @@ -137,7 +138,7 @@ void bhv_bowser_body_anchor_loop(void) { // Do damage if Mario touches Bowser o->oInteractType = INTERACT_DAMAGE; // Make body intangible while is transparent - // in BITFS (Teleporting) + // in BitFS (Teleporting) if (o->parentObj->oOpacity < 100) { cur_obj_become_intangible(); } else { @@ -152,12 +153,11 @@ void bhv_bowser_body_anchor_loop(void) { } /** - * Bowser's shockwave attack, spawns only in BITS + * Bowser's shockwave attack, spawns only in BitS */ s32 bowser_spawn_shockwave(void) { - struct Object *wave; if (o->oBehParams2ndByte == BOWSER_BP_BITS) { - wave = spawn_object(o, MODEL_BOWSER_WAVE, bhvBowserShockWave); + struct Object *wave = spawn_object(o, MODEL_BOWSER_WAVE, bhvBowserShockWave); wave->oPosY = o->oFloorHeight; return TRUE; } @@ -225,7 +225,6 @@ s32 bowser_set_anim_look_down_stop_walk(void) { } } - /** * Set Bowser an action depending of the CamAct value * CamAct changes value on the cutscene itself (cutscene_bowser_arena) @@ -235,7 +234,7 @@ void bowser_init_camera_actions(void) { o->oAction = BOWSER_ACT_WAIT; } else if (o->oBowserCamAct == BOWSER_CAM_ACT_WALK) { o->oAction = BOWSER_ACT_INTRO_WALK; - // Start with a big jump in BITFS to do a platform tilt + // Start with a big jump in BitFS to do a platform tilt } else if (o->oBehParams2ndByte == BOWSER_BP_BITFS) { o->oAction = BOWSER_ACT_BIG_JUMP; } else { @@ -303,9 +302,9 @@ s8 sBowserDebugActions[] = { * Debug function that allows to change Bowser's actions (most of them) */ UNUSED static void bowser_debug_actions(void) { - if (gDebugInfo[5][1] != 0) { - o->oAction = sBowserDebugActions[gDebugInfo[5][2] & 0xf]; - gDebugInfo[5][1] = 0; + if (gDebugInfo[DEBUG_PAGE_ENEMYINFO][1] != 0) { + o->oAction = sBowserDebugActions[gDebugInfo[DEBUG_PAGE_ENEMYINFO][2] & 0x0F]; + gDebugInfo[DEBUG_PAGE_ENEMYINFO][1] = 0; } } @@ -316,12 +315,12 @@ void bowser_bitdw_actions(void) { // Generate random float f32 rand = random_float(); // Set attacks when Bowser Reacts - if (o->oBowserIsReacting == FALSE) { + if (!o->oBowserIsReacting) { if (o->oBowserStatus & BOWSER_STATUS_ANGLE_MARIO) { - if (o->oDistanceToMario < 1500.0f) { - o->oAction = BOWSER_ACT_BREATH_FIRE; // nearby - } else { - o->oAction = BOWSER_ACT_QUICK_JUMP; // far away + if (o->oDistanceToMario < 1500.0f) { // nearby + o->oAction = BOWSER_ACT_BREATH_FIRE; + } else { // far away + o->oAction = BOWSER_ACT_QUICK_JUMP; } } else { // Keep walking @@ -333,21 +332,17 @@ void bowser_bitdw_actions(void) { // Set starting Bowser level actions, randomly he can also start // dancing after the introduction #ifndef VERSION_JP - if (!gCurrDemoInput) { // demo check because entry exits post JP + if (gCurrDemoInput == NULL) { // demo check because entry exits post JP +#endif if (rand < 0.1) { o->oAction = BOWSER_ACT_DANCE; // 10% chance } else { o->oAction = BOWSER_ACT_WALK_TO_MARIO; // common } +#ifndef VERSION_JP } else { o->oAction = BOWSER_ACT_WALK_TO_MARIO; } -#else - if (rand < 0.1) { - o->oAction = BOWSER_ACT_DANCE; // 10% chance - } else { - o->oAction = BOWSER_ACT_WALK_TO_MARIO; // common - } #endif } } @@ -359,7 +354,7 @@ void bowser_bitfs_actions(void) { // Generate random float f32 rand = random_float(); // Set attacks when Bowser Reacts - if (o->oBowserIsReacting == FALSE) { + if (!o->oBowserIsReacting) { if (o->oBowserStatus & BOWSER_STATUS_ANGLE_MARIO) { if (o->oDistanceToMario < 1300.0f) { // nearby if (rand < 0.5) { // 50% chance @@ -369,7 +364,7 @@ void bowser_bitfs_actions(void) { } } else { // far away o->oAction = BOWSER_ACT_CHARGE_MARIO; - if (500.0f < o->oBowserDistToCentre && o->oBowserDistToCentre < 1500.0f + if (500.0f < o->oBowserDistToCenter && o->oBowserDistToCenter < 1500.0f && rand < 0.5) { // 50% chance o->oAction = BOWSER_ACT_BIG_JUMP; } @@ -399,11 +394,13 @@ void bowser_bits_action_list(void) { o->oAction = BOWSER_ACT_SPIT_FIRE_INTO_SKY; // 80% chance } else { o->oAction = BOWSER_ACT_BREATH_FIRE; - } // far away - } else if (rand < 0.5) { - o->oAction = BOWSER_ACT_BIG_JUMP; // 50% chance - } else { - o->oAction = BOWSER_ACT_CHARGE_MARIO; + } + } else { // far away + if (rand < 0.5) { + o->oAction = BOWSER_ACT_BIG_JUMP; // 50% chance + } else { + o->oAction = BOWSER_ACT_CHARGE_MARIO; + } } } else { // Keep walking @@ -425,7 +422,7 @@ void bowser_set_act_big_jump(void) { void bowser_bits_actions(void) { switch (o->oBowserIsReacting) { case FALSE: - // oBowserBitsJustJump never changes value, + // oBowserBitsJustJump never changes value, // so its always FALSE, maybe a debug define if (o->oBowserBitsJustJump == FALSE) { bowser_bits_action_list(); @@ -434,6 +431,7 @@ void bowser_bits_actions(void) { } o->oBowserIsReacting = TRUE; break; + case TRUE: o->oBowserIsReacting = FALSE; o->oAction = BOWSER_ACT_WALK_TO_MARIO; @@ -446,11 +444,11 @@ void bowser_bits_actions(void) { */ #if BUGFIX_BOWSER_FALLEN_OFF_STAGE void bowser_reset_fallen_off_stage(void) { - if (o->oVelY < 0 && o->oPosY < (o->oHomeY - 300.0f)) { - o->oPosX = o->oPosZ = 0; + if (o->oVelY < 0.0f && o->oPosY < (o->oHomeY - 300.0f)) { + o->oPosX = o->oPosZ = 0.0f; o->oPosY = o->oHomeY + 2000.0f; - o->oVelY = 0; - o->oForwardVel = 0; + o->oVelY = 0.0f; + o->oForwardVel = 0.0f; } } #endif @@ -511,17 +509,21 @@ void bowser_act_walk_to_mario(void) { s16 angleFromMario = abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario); // Set turning speed depending of the health - // Also special case for BITFS + // Also special case for BitFS if (o->oBehParams2ndByte == BOWSER_BP_BITFS) { turnSpeed = 0x400; - } else if (o->oHealth > 2) { - turnSpeed = 0x400; - } else if (o->oHealth == 2) { - turnSpeed = 0x300; - } else { // 1 health (BITFS-BITS) - turnSpeed = 0x200; + } else { // BOWSER_BP_BITDW or BOWSER_BP_BITS + if (o->oHealth >= 3) { + turnSpeed = 0x400; + } else if (o->oHealth == 2) { + turnSpeed = 0x300; + } else { // 1 health + turnSpeed = 0x200; + } } + facing = cur_obj_rotate_yaw_toward(o->oAngleToMario, turnSpeed); + if (o->oSubAction == 0) { o->oBowserTimer = 0; // Start walking @@ -568,16 +570,16 @@ void bowser_act_teleport(void) { o->oMoveAngleYaw = o->oAngleToMario; } break; + case BOWSER_SUB_ACT_TELEPORT_MOVE: // reduce timer and set velocity teleport while at it if (o->oBowserTimer--) { o->oForwardVel = 100.0f; - } - else { + } else { o->oSubAction = BOWSER_SUB_ACT_TELEPORT_STOP; o->oMoveAngleYaw = o->oAngleToMario; // update angle } - // + if (abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) > 0x4000) { if (o->oDistanceToMario > 500.0f) { o->oSubAction = BOWSER_SUB_ACT_TELEPORT_STOP; @@ -586,12 +588,13 @@ void bowser_act_teleport(void) { } } break; + // Set opacity target to visible and become tangible case BOWSER_SUB_ACT_TELEPORT_STOP: o->oForwardVel = 0.0f; // reset velocity - o->oBowserTargetOpacity = 0xFF; + o->oBowserTargetOpacity = 255; // Set to default action once visible - if (o->oOpacity == 0xFF) { + if (o->oOpacity == 255) { o->oAction = BOWSER_ACT_DEFAULT; } cur_obj_become_tangible(); @@ -603,18 +606,18 @@ void bowser_act_teleport(void) { * Makes Bowser do a fire split into the sky */ void bowser_act_spit_fire_into_sky(void) { - s32 frame; + s32 animFrame; // Play animation cur_obj_init_animation_with_sound(BOWSER_ANIM_BREATH_UP); // Set frames - frame = o->header.gfx.animInfo.animFrame; + animFrame = o->header.gfx.animInfo.animFrame; // Spawn flames in the middle of the animation - if (frame > 24 && frame < 36) { + if (animFrame > 24 && animFrame < 36) { cur_obj_play_sound_1(SOUND_AIR_BOWSER_SPIT_FIRE); - if (frame == 35) { // Spawns Blue flames at this frame - spawn_object_relative(1, 0, 0x190, 0x64, o, MODEL_RED_FLAME, bhvBlueBowserFlame); + if (animFrame == 35) { // Spawns Blue flames at this frame + spawn_object_relative(1, 0, 400, 100, o, MODEL_RED_FLAME, bhvBlueBowserFlame); } else { // Spawns Red flames - spawn_object_relative(0, 0, 0x190, 0x64, o, MODEL_RED_FLAME, bhvBlueBowserFlame); + spawn_object_relative(0, 0, 400, 100, o, MODEL_RED_FLAME, bhvBlueBowserFlame); } } // Return to default act once the animation is over @@ -633,7 +636,7 @@ void bowser_act_hit_mine(void) { if (o->oTimer == 0) { o->oForwardVel = -400.0f; o->oVelY = 100.0f; - o->oMoveAngleYaw = o->oBowserAngleToCentre + 0x8000; + o->oMoveAngleYaw = o->oBowserAngleToCenter + 0x8000; o->oBowserEyesShut = TRUE; // close eyes } // Play flip animation @@ -656,7 +659,7 @@ void bowser_act_hit_mine(void) { // Play these actions once he is stand up } else if (o->oSubAction == BOWSER_SUB_ACT_HIT_MINE_STOP) { if (cur_obj_check_if_near_animation_end()) { - // Makes Bowser dance at one health (in BITS) + // Makes Bowser dance at one health (in BitS) if (o->oHealth == 1) { o->oAction = BOWSER_ACT_DANCE; } else { @@ -682,18 +685,18 @@ s32 bowser_set_anim_jump(void) { } /** - * Reset speed, play jump stop animation and do attacks in BITDW + * Reset speed, play jump stop animation and do attacks in BitDW * Returns TRUE when Bowser lands */ s32 bowser_land(void) { if (o->oMoveFlags & OBJ_MOVE_LANDED) { - o->oForwardVel = 0; - o->oVelY = 0; + o->oForwardVel = 0.0f; + o->oVelY = 0.0f; spawn_mist_particles_variable(0, 0, 60.0f); cur_obj_init_animation_with_sound(BOWSER_ANIM_JUMP_STOP); o->header.gfx.animInfo.animFrame = 0; cur_obj_start_cam_event(o, CAM_EVENT_BOWSER_JUMP); - // Set status attacks in BITDW since the other levels + // Set status attacks in BitDW since the other levels // have different attacks defined if (o->oBehParams2ndByte == BOWSER_BP_BITDW) { if (o->oDistanceToMario < 850.0f) { @@ -709,11 +712,11 @@ s32 bowser_land(void) { } /** - * Makes Bowser do a second hop speed only in BITS + * Makes Bowser do a second hop speed only in BitS */ void bowser_short_second_hop(void) { if (o->oBehParams2ndByte == BOWSER_BP_BITS && o->oBowserStatus & BOWSER_STATUS_BIG_JUMP) { - if (o->oBowserDistToCentre > 1000.0f) { + if (o->oBowserDistToCenter > 1000.0f) { o->oForwardVel = 60.0f; } } @@ -723,7 +726,8 @@ void bowser_short_second_hop(void) { * Makes Bowser do a big jump */ void bowser_act_big_jump(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; + if (o->oSubAction == 0) { // Set jump animation if (bowser_set_anim_jump()) { @@ -739,7 +743,7 @@ void bowser_act_big_jump(void) { } } else if (o->oSubAction == 1) { #if BUGFIX_BOWSER_FALLEN_OFF_STAGE - // Reset Bowser back on stage in BITS if he doesn't land properly + // Reset Bowser back on stage in BitS if he doesn't land properly if (o->oBehParams2ndByte == BOWSER_BP_BITS && o->oBowserStatus & BOWSER_STATUS_BIG_JUMP) { bowser_reset_fallen_off_stage(); } @@ -749,9 +753,9 @@ void bowser_act_big_jump(void) { o->oBowserStatus &= ~BOWSER_STATUS_BIG_JUMP; o->oForwardVel = 0.0f; o->oSubAction++; - // Spawn shockwave (BITS only) if is not on a platform + // Spawn shockwave (BitS only) if is not on a platform bowser_spawn_shockwave(); - // Tilt platform in BITFS + // Tilt platform in BitFS if (o->oBehParams2ndByte == BOWSER_BP_BITFS) { o->oAction = BOWSER_ACT_TILT_LAVA_PLATFORM; } @@ -770,11 +774,12 @@ s16 sBowserVelYAir[] = { 60 }; s16 sBowserFVelAir[] = { 50 }; /** - * Makes Bowser do a "quick" jump in BITDW + * Makes Bowser do a "quick" jump in BitDW */ void bowser_act_quick_jump(void) { f32 velY = sBowserVelYAir[0]; f32 fVel = sBowserFVelAir[0]; + if (o->oSubAction == 0) { // Set fixed val positions while jumping if (bowser_set_anim_jump()) { @@ -802,6 +807,7 @@ void bowser_act_hit_edge(void) { if (o->oTimer == 0) { o->oBowserTimer = 0; } + switch (o->oSubAction) { case 0: // Move on the edge @@ -813,6 +819,7 @@ void bowser_act_hit_edge(void) { o->oSubAction++; } break; + case 1: // Stop moving on the edge cur_obj_init_animation_with_sound(BOWSER_ANIM_EDGE_STOP); @@ -866,8 +873,10 @@ s32 bowser_turn_on_timer(s32 time, s16 yaw) { } else { cur_obj_init_animation_with_sound(BOWSER_ANIM_IDLE); } + o->oForwardVel = 0.0f; o->oMoveAngleYaw += yaw; + if (o->oTimer >= time) { return TRUE; } else { @@ -902,6 +911,7 @@ void bowser_act_charge_mario(void) { o->oSubAction = BOWSER_SUB_ACT_CHARGE_RUN; } break; + case BOWSER_SUB_ACT_CHARGE_RUN: // Set speed to run o->oForwardVel = 50.0f; @@ -921,6 +931,7 @@ void bowser_act_charge_mario(void) { // Rotate to Mario cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200); break; + case BOWSER_SUB_ACT_CHARGE_SLIP: // Spawn smoke puff while slipping o->oBowserTimer = 0; @@ -934,6 +945,7 @@ void bowser_act_charge_mario(void) { } cur_obj_extend_animation_if_at_end(); break; + case BOWSER_SUB_ACT_CHARGE_END: // Stop running o->oForwardVel = 0.0f; @@ -953,6 +965,7 @@ void bowser_act_charge_mario(void) { cur_obj_extend_animation_if_at_end(); break; } + // Bowser is close to falling so set hit edge action if (o->oMoveFlags & OBJ_MOVE_HIT_EDGE) { o->oAction = BOWSER_ACT_HIT_EDGE; @@ -979,10 +992,12 @@ s32 bowser_check_hit_mine(void) { * Bowser's thrown act that gets called after Mario releases him */ void bowser_act_thrown(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; + // Keep Bowser's timer at 0 unless he lands - if (o->oTimer < 2) + if (o->oTimer < 2) { o->oBowserTimer = 0; + } if (o->oSubAction == 0) { // Play shake animations and do bounce effects cur_obj_init_animation_with_sound(BOWSER_ANIM_SHAKING); @@ -993,8 +1008,9 @@ void bowser_act_thrown(void) { o->oSubAction++; // stops this current subaction } // Stand up and after play, set to default act - } else if (cur_obj_init_animation_and_check_if_near_end(BOWSER_ANIM_STAND_UP)) + } else if (cur_obj_init_animation_and_check_if_near_end(BOWSER_ANIM_STAND_UP)) { o->oAction = BOWSER_ACT_DEFAULT; + } // Hit mine check, reduce health and set specific action depending of it if (bowser_check_hit_mine()) { o->oHealth--; @@ -1023,7 +1039,7 @@ void bowser_set_goal_invisible(void) { */ void bowser_act_jump_onto_stage(void) { s32 onDynamicFloor; - UNUSED s32 unused; + UNUSED u8 filler[4]; struct Surface *floor = o->oFloor; // Set dynamic floor check (Object platforms) @@ -1049,45 +1065,48 @@ void bowser_act_jump_onto_stage(void) { } bowser_set_goal_invisible(); break; + // Start jump animation and make him visible after an animation frame case BOWSER_SUB_ACT_JUMP_ON_STAGE_START: cur_obj_init_animation_with_sound(BOWSER_ANIM_JUMP_START); if (cur_obj_check_anim_frame(11)) { - o->oMoveAngleYaw = o->oBowserAngleToCentre; + o->oMoveAngleYaw = o->oBowserAngleToCenter; o->oVelY = 150.0f; - o->oBowserTargetOpacity = 0xFF; + o->oBowserTargetOpacity = 255; o->oBowserTimer = 0; o->oSubAction++; } else { bowser_set_goal_invisible(); } break; + // Approach him back on stage case BOWSER_SUB_ACT_JUMP_ON_STAGE_LAND: if (o->oPosY > o->oHomeY) { o->oDragStrength = 0.0f; - if (o->oBowserDistToCentre < 2500.0f) { + if (o->oBowserDistToCenter < 2500.0f) { if (absf(o->oFloorHeight - o->oHomeY) < 100.0f) { approach_f32_signed(&o->oForwardVel, 0, -5.0f); } else { cur_obj_forward_vel_approach_upward(150.0f, 2.0f); } - } else + } else { cur_obj_forward_vel_approach_upward(150.0f, 2.0f); + } } // Land on stage if (bowser_land()) { o->oDragStrength = 10.0f; o->oSubAction++; - // Spawn shockwave (BITS only) if is not on a platform + // Spawn shockwave (BitS only) if is not on a platform if (onDynamicFloor == FALSE) { bowser_spawn_shockwave(); - // If is on a dynamic floor in BITS, then jump + // If is on a dynamic floor in BitS, then jump // because of the falling platform } else if (o->oBehParams2ndByte == BOWSER_BP_BITS) { o->oAction = BOWSER_ACT_BIG_JUMP; } - // If is on a dynamic floor in BITFS, then tilt platform + // If is on a dynamic floor in BitFS, then tilt platform if (o->oBehParams2ndByte == BOWSER_BP_BITFS) { o->oAction = BOWSER_ACT_TILT_LAVA_PLATFORM; } @@ -1104,6 +1123,7 @@ void bowser_act_jump_onto_stage(void) { } #endif break; + // Bowser landed, so reset action after he's done jumping case BOWSER_SUB_ACT_JUMP_ON_STAGE_STOP: if (cur_obj_check_if_near_animation_end()) { @@ -1113,6 +1133,7 @@ void bowser_act_jump_onto_stage(void) { } break; } + print_debug_bottom_up("sp %d", o->oForwardVel); } @@ -1137,7 +1158,7 @@ void bowser_act_dance(void) { /** * Spawn collectable that Bowser spawns after despawning - * Spawns a Key in BITDW/BITFS or Grand Star in BITS + * Spawns a Key in BitDW/BitFS or Grand Star in BitS */ void bowser_spawn_collectable(void) { if (o->oBehParams2ndByte == BOWSER_BP_BITS) { @@ -1154,14 +1175,14 @@ void bowser_spawn_collectable(void) { */ void bowser_fly_back_dead(void) { cur_obj_init_animation_with_sound(BOWSER_ANIM_FLIP_DOWN); - // More knockback in BITS + // More knockback in BitS if (o->oBehParams2ndByte == BOWSER_BP_BITS) { o->oForwardVel = -400.0f; } else { o->oForwardVel = -200.0f; } o->oVelY = 100.0f; - o->oMoveAngleYaw = o->oBowserAngleToCentre + 0x8000; + o->oMoveAngleYaw = o->oBowserAngleToCenter + 0x8000; o->oBowserTimer = 0; o->oSubAction++; // BOWSER_SUB_ACT_DEAD_BOUNCE } @@ -1203,6 +1224,7 @@ s32 bowser_dead_wait_for_mario(void) { */ s32 bowser_dead_twirl_up(void) { s32 ret = FALSE; + // Set angle rotation once he has low X scale value if (o->header.gfx.scale[0] < 0.8) { o->oAngleVelYaw += 0x80; @@ -1227,6 +1249,7 @@ s32 bowser_dead_twirl_up(void) { if (o->oOpacity >= 3) { o->oOpacity -= 2; } + return ret; } @@ -1246,11 +1269,12 @@ void bowser_dead_hide(void) { s16 sBowserDefeatedDialogText[3] = { DIALOG_119, DIALOG_120, DIALOG_121 }; /** - * Bowser's dead sequence that plays in BITDW/BITFS + * Bowser's dead sequence that plays in BitDW/BitFS * Returns TRUE once done */ s32 bowser_dead_default_stage_ending(void) { s32 ret = FALSE; + if (o->oBowserTimer < 2) { // Lower music volume if (o->oBowserTimer == 0) { @@ -1275,17 +1299,19 @@ s32 bowser_dead_default_stage_ending(void) { set_mario_npc_dialog(MARIO_DIALOG_STOP); ret = TRUE; } + return ret; } /** - * Bowser's dead sequence that plays in BITS + * Bowser's dead sequence that plays in BitS * Returns TRUE once done */ s32 bowser_dead_final_stage_ending(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; s32 ret = FALSE; s32 dialogID; + if (o->oBowserTimer < 2) { // Set dialog whenever you have 120 stars or not if (gHudDisplay.stars < 120) { @@ -1309,13 +1335,14 @@ s32 bowser_dead_final_stage_ending(void) { o->oBowserTimer++; } // Slowly fade him out - } else if (o->oOpacity > 4) + } else if (o->oOpacity > 4) { o->oOpacity -= 4; - else { + } else { // And at last, hide him bowser_dead_hide(); ret = TRUE; } + return ret; } @@ -1328,15 +1355,17 @@ void bowser_act_dead(void) { case BOWSER_SUB_ACT_DEAD_FLY_BACK: bowser_fly_back_dead(); break; + case BOWSER_SUB_ACT_DEAD_BOUNCE: bowser_dead_bounce(); break; + case BOWSER_SUB_ACT_DEAD_WAIT: // Check if Mario is close to Bowser if (bowser_dead_wait_for_mario()) { o->oBowserTimer = 0; - // Set different (final) subaction in BITS - // Non-BITS Bowser uses default subaction and sets dithering + // Set different (final) subaction in BitS + // Non-BitS Bowser uses default subaction and sets dithering if (o->oBehParams2ndByte == BOWSER_BP_BITS) { o->oSubAction = BOWSER_SUB_ACT_DEAD_FINAL_END; } else { @@ -1345,50 +1374,53 @@ void bowser_act_dead(void) { } } break; + case BOWSER_SUB_ACT_DEAD_DEFAULT_END: if (bowser_dead_default_stage_ending()) { o->oSubAction++; // BOWSER_SUB_ACT_DEAD_DEFAULT_END_OVER } break; + case BOWSER_SUB_ACT_DEAD_DEFAULT_END_OVER: break; + case BOWSER_SUB_ACT_DEAD_FINAL_END: if (bowser_dead_final_stage_ending()) { o->oSubAction++; // BOWSER_SUB_ACT_DEAD_FINAL_END_OVER } break; + case BOWSER_SUB_ACT_DEAD_FINAL_END_OVER: break; } } /** - * Sets values for the BITFS platform to tilt + * Sets values for the BitFS platform to tilt */ void bowser_tilt_platform(struct Object *platform, s16 angSpeed) { - s16 angle; - angle = o->oBowserAngleToCentre + 0x8000; + s16 angle = o->oBowserAngleToCenter + 0x8000; platform->oAngleVelPitch = coss(angle) * angSpeed; platform->oAngleVelRoll = -sins(angle) * angSpeed; } /** - * Struct for the BITFS tilt platform + * Struct for the BitFS tilt platform */ struct BowserTiltPlatformInfo { // Flag value to make sure platform moves smoothly // 0 = Don't move // 1 = Move angle behind Bowser // -1 = Move angle in front of Bowser - s16 flag; + s16 flag; // Sets platform's tilt angle speed (pattern: positive then negative) - s16 angSpeed; + s16 angSpeed; // Sets how much time the platform can tilt, increases each move - s16 time; + s16 time; }; /** - * Data for the BITFS tilt Platform + * Data for the BitFS tilt Platform */ struct BowserTiltPlatformInfo sBowsertiltPlatformData[] = { { 1, 10, 40 }, @@ -1406,22 +1438,21 @@ struct BowserTiltPlatformInfo sBowsertiltPlatformData[] = { }; /** - * Makes the platform in BITFS tilt from left to right + * Makes the platform in BitFS tilt from left to right */ void bowser_act_tilt_lava_platform(void) { // Set platform object struct Object *platform = cur_obj_nearest_object_with_behavior(bhvTiltingBowserLavaPlatform); - UNUSED s16 angle = o->oBowserAngleToCentre + 0x8000; + UNUSED s16 angle = o->oBowserAngleToCenter + 0x8000; s16 angSpeed; - UNUSED s32 unused; - s32 i; - s32 isNotTilting; + UNUSED u8 filler[4]; + // If there's not platform, return to default action if (platform == NULL) { o->oAction = BOWSER_ACT_DEFAULT; } else { - i = 0; - isNotTilting = TRUE; + s32 i = 0; + s32 isNotTilting = TRUE; // Active platform tilting if the timer is not 0 while (sBowsertiltPlatformData[i].time != 0) { // Move if the time values is more than the timer @@ -1464,8 +1495,9 @@ void bowser_act_tilt_lava_platform(void) { */ s32 bowser_check_fallen_off_stage(void) { if (o->oAction != BOWSER_ACT_JUMP_ONTO_STAGE && o->oAction != BOWSER_ACT_TILT_LAVA_PLATFORM) { - if (o->oPosY < o->oHomeY - 1000.0f) + if (o->oPosY < o->oHomeY - 1000.0f) { return TRUE; + } if (o->oMoveFlags & OBJ_MOVE_LANDED) { // Check for Fire Sea if (o->oFloorType == SURFACE_BURNING) { @@ -1503,7 +1535,7 @@ void (*sBowserActions[])(void) = { bowser_act_teleport, bowser_act_quick_jump, bowser_act_idle, - bowser_act_tilt_lava_platform + bowser_act_tilt_lava_platform, }; /** @@ -1557,7 +1589,7 @@ void bowser_free_update(void) { struct Object *platform; UNUSED f32 floorHeight; - // Platform displacement check (for BITFS) + // Platform displacement check (for BitFS) if ((platform = o->platform) != NULL) { apply_platform_displacement(FALSE, platform); } @@ -1589,6 +1621,7 @@ void bowser_held_update(void) { // Reset fire sky status and make him intangible o->oBowserStatus &= ~BOWSER_STATUS_FIRE_SKY; cur_obj_become_intangible(); + switch (o->oBowserGrabbedStatus) { // Play pickup sound, start grabbed animation, and set throw action // Throw action won't be played until he's actually released @@ -1607,6 +1640,7 @@ void bowser_held_update(void) { case BOWSER_GRAB_STATUS_HOLDING: break; } + // Reset move flags o->oMoveFlags = 0; // Copy angle values from Mario @@ -1620,6 +1654,7 @@ void bowser_held_update(void) { */ void bowser_thrown_dropped_update(void) { f32 swingSpd; + // Reset grabbed status o->oBowserGrabbedStatus = BOWSER_GRAB_STATUS_NONE; // Set throw action and vel values @@ -1653,13 +1688,13 @@ void bowser_thrown_dropped_update(void) { */ void bhv_bowser_loop(void) { s16 angleToMario; // AngleToMario from Bowser's perspective - s16 angleToCentre; // AngleToCentre from Bowser's perspective + s16 angleToCenter; // AngleToCenter from Bowser's perspective // Set distance/angle values - o->oBowserDistToCentre = sqrtf(o->oPosX * o->oPosX + o->oPosZ * o->oPosZ); - o->oBowserAngleToCentre = atan2s(0.0f - o->oPosZ, 0.0f - o->oPosX); + o->oBowserDistToCenter = sqrtf(o->oPosX * o->oPosX + o->oPosZ * o->oPosZ); + o->oBowserAngleToCenter = atan2s(0.0f - o->oPosZ, 0.0f - o->oPosX); angleToMario = abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario); - angleToCentre = abs_angle_diff(o->oMoveAngleYaw, o->oBowserAngleToCentre); + angleToCenter = abs_angle_diff(o->oMoveAngleYaw, o->oBowserAngleToCenter); // Reset Status o->oBowserStatus &= ~0xFF; @@ -1669,11 +1704,11 @@ void bhv_bowser_loop(void) { if (angleToMario < 0x2000) { o->oBowserStatus |= BOWSER_STATUS_ANGLE_MARIO; } - if (angleToCentre < 0x3800) { - o->oBowserStatus |= BOWSER_STATUS_ANGLE_CENTRE; // unused + if (angleToCenter < 0x3800) { + o->oBowserStatus |= BOWSER_STATUS_ANGLE_CENTER; // unused } - if (o->oBowserDistToCentre < 1000.0f) { - o->oBowserStatus |= BOWSER_STATUS_DIST_CENTRE; // unused + if (o->oBowserDistToCenter < 1000.0f) { + o->oBowserStatus |= BOWSER_STATUS_DIST_CENTER; // unused } if (o->oDistanceToMario < 850.0f) { o->oBowserStatus |= BOWSER_STATUS_DIST_MARIO; // unused @@ -1698,14 +1733,14 @@ void bhv_bowser_loop(void) { cur_obj_align_gfx_with_floor(); // Adjust opacity (when not dead) - // Mostly for the teleport action in BITFS + // Mostly for the teleport action in BitFS if (o->oAction != BOWSER_ACT_DEAD) { if (o->oBowserTargetOpacity != o->oOpacity) { - // increase opacity when oBowserTargetOpacity is 0xFF + // increase opacity when oBowserTargetOpacity is 255 if (o->oBowserTargetOpacity > o->oOpacity) { o->oOpacity += 20; - if (o->oOpacity >= 0x100) { - o->oOpacity = 0xFF; + if (o->oOpacity > 255) { + o->oOpacity = 255; } // reduce opacity when oBowserTargetOpacity is 0 } else { @@ -1727,8 +1762,8 @@ void bhv_bowser_init(void) { // It goes true when Bowser is a non-walking state o->oBowserIsReacting = TRUE; // Set no transparency opacity - o->oOpacity = 0xFF; - o->oBowserTargetOpacity = 0xFF; + o->oOpacity = 255; + o->oBowserTargetOpacity = 255; // Set Bowser B-param depending of the stage if (gCurrLevelNum == LEVEL_BOWSER_2) { level = BOWSER_BP_BITFS; @@ -1751,25 +1786,23 @@ void bhv_bowser_init(void) { } Gfx *geo_update_body_rot_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx) { - Mat4 mtx2; - struct Object *obj; - if (callContext == GEO_CONTEXT_RENDER) { - obj = (struct Object *) gCurGraphNodeObject; + Mat4 mtx2; + struct Object *obj = (struct Object *) gCurGraphNodeObject; if (obj->prevObj != NULL) { create_transformation_from_matrices(mtx2, mtx, *gCurGraphNodeCamera->matrixPtr); obj_update_pos_from_parent_transformation(mtx2, obj->prevObj); obj_set_gfx_pos_from_pos(obj->prevObj); } } + return NULL; } /** * Bowser's eyes Geo-Switch-Case IDs, defined from Mario's POV */ -enum BowserEyesGSCId -{ +enum BowserEyesGSCId { /*0x00*/ BOWSER_EYES_OPEN, /*0x01*/ BOWSER_EYES_HALF_CLOSED, /*0x02*/ BOWSER_EYES_CLOSED, @@ -1788,67 +1821,88 @@ enum BowserEyesGSCId void bowser_open_eye_switch(struct Object *obj, struct GraphNodeSwitchCase *switchCase) { s32 eyeCase; s16 angleFromMario; + angleFromMario = abs_angle_diff(obj->oMoveAngleYaw, obj->oAngleToMario); eyeCase = switchCase->selectedCase; + switch (eyeCase) { case BOWSER_EYES_OPEN: // Mario is in Bowser's field of view if (angleFromMario > 0x2000) { - if (obj->oAngleVelYaw > 0) + if (obj->oAngleVelYaw > 0) { switchCase->selectedCase = BOWSER_EYES_RIGHT; - if (obj->oAngleVelYaw < 0) + } + if (obj->oAngleVelYaw < 0) { switchCase->selectedCase = BOWSER_EYES_LEFT; + } } // Half close, start blinking - if (obj->oBowserEyesTimer > 50) + if (obj->oBowserEyesTimer > 50) { switchCase->selectedCase = BOWSER_EYES_HALF_CLOSED; + } break; + case BOWSER_EYES_HALF_CLOSED: // Close, blinking - if (obj->oBowserEyesTimer > 2) + if (obj->oBowserEyesTimer > 2) { switchCase->selectedCase = BOWSER_EYES_CLOSED; + } break; + case BOWSER_EYES_CLOSED: // Reset blinking - if (obj->oBowserEyesTimer > 2) + if (obj->oBowserEyesTimer > 2) { switchCase->selectedCase = BOWSER_EYES_RESET; + } break; + case BOWSER_EYES_RESET: // Open, no longer blinking - if (obj->oBowserEyesTimer > 2) + if (obj->oBowserEyesTimer > 2) { switchCase->selectedCase = BOWSER_EYES_OPEN; + } break; + case BOWSER_EYES_RIGHT: // Look more on the right if angle didn't change // Otherwise, look at the center (open) if (obj->oBowserEyesTimer > 2) { switchCase->selectedCase = BOWSER_EYES_FAR_RIGHT; - if (obj->oAngleVelYaw <= 0) + if (obj->oAngleVelYaw <= 0) { switchCase->selectedCase = BOWSER_EYES_OPEN; + } } break; + case BOWSER_EYES_FAR_RIGHT: // Look close right if angle was drastically changed - if (obj->oAngleVelYaw <= 0) + if (obj->oAngleVelYaw <= 0) { switchCase->selectedCase = BOWSER_EYES_RIGHT; + } break; + case BOWSER_EYES_LEFT: // Look more on the left if angle didn't change // Otherwise, look at the center (open) if (obj->oBowserEyesTimer > 2) { switchCase->selectedCase = BOWSER_EYES_FAR_LEFT; - if (obj->oAngleVelYaw >= 0) + if (obj->oAngleVelYaw >= 0) { switchCase->selectedCase = BOWSER_EYES_OPEN; + } } break; + case BOWSER_EYES_FAR_LEFT: // Look close left if angle was drastically changed - if (obj->oAngleVelYaw >= 0) + if (obj->oAngleVelYaw >= 0) { switchCase->selectedCase = BOWSER_EYES_LEFT; + } break; + default: switchCase->selectedCase = BOWSER_EYES_OPEN; } + // Reset timer if eye case has changed if (switchCase->selectedCase != eyeCase) { obj->oBowserEyesTimer = -1; @@ -1862,12 +1916,15 @@ void bowser_open_eye_switch(struct Object *obj, struct GraphNodeSwitchCase *swit */ Gfx *geo_switch_bowser_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx) { UNUSED s16 eyeShut; - UNUSED s32 unused; + UNUSED u8 filler[4]; struct Object *obj = (struct Object *) gCurGraphNodeObject; struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node; + if (callContext == GEO_CONTEXT_RENDER) { - if (gCurGraphNodeHeldObject != NULL) + if (gCurGraphNodeHeldObject != NULL) { obj = gCurGraphNodeHeldObject->objNode; + } + switch (eyeShut = obj->oBowserEyesShut) { case FALSE: // eyes open, handle eye looking direction bowser_open_eye_switch(obj, switchCase); @@ -1876,38 +1933,44 @@ Gfx *geo_switch_bowser_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 switchCase->selectedCase = BOWSER_EYES_CLOSED; break; } + obj->oBowserEyesTimer++; } + return NULL; } /** - * Geo switch that sets Bowser's Rainbow coloring (in BITS) + * Geo switch that sets Bowser's Rainbow coloring (in BitS) */ Gfx *geo_bits_bowser_coloring(s32 callContext, struct GraphNode *node, UNUSED s32 context) { Gfx *gfxHead = NULL; Gfx *gfx; - struct Object *obj; - struct GraphNodeGenerated *graphNode; if (callContext == GEO_CONTEXT_RENDER) { - obj = (struct Object *) gCurGraphNodeObject; - graphNode = (struct GraphNodeGenerated *) node; - if (gCurGraphNodeHeldObject != 0) { + struct Object *obj = (struct Object *) gCurGraphNodeObject; + struct GraphNodeGenerated *graphNode = (struct GraphNodeGenerated *) node; + + if (gCurGraphNodeHeldObject != NULL) { obj = gCurGraphNodeHeldObject->objNode; } + // Set layers if object is transparent or not - if (obj->oOpacity == 0xFF) { + if (obj->oOpacity == 255) { graphNode->fnNode.node.flags = (graphNode->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8); } else { graphNode->fnNode.node.flags = (graphNode->fnNode.node.flags & 0xFF) | (LAYER_TRANSPARENT << 8); } + gfx = gfxHead = alloc_display_list(2 * sizeof(Gfx)); + // If TRUE, clear lighting to give rainbow color - if (obj->oBowserRainbowLight != 0) { + if (obj->oBowserRainbowLight) { gSPClearGeometryMode(gfx++, G_LIGHTING); } + gSPEndDisplayList(gfx); } + return gfxHead; } diff --git a/src/game/behaviors/bowser_bomb.inc.c b/src/game/behaviors/bowser_bomb.inc.c index e1e560ae..756b2051 100644 --- a/src/game/behaviors/bowser_bomb.inc.c +++ b/src/game/behaviors/bowser_bomb.inc.c @@ -1,14 +1,13 @@ -// bowser_bomb.c.inc +// bowser_bomb.inc.c void bhv_bowser_bomb_loop(void) { - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { + if (obj_check_if_collided_with_object(o, gMarioObject) == TRUE) { o->oInteractStatus &= ~INT_STATUS_INTERACTED; spawn_object(o, MODEL_EXPLOSION, bhvExplosion); o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - if (o->oInteractStatus & INT_STATUS_HIT_MINE) - { + if (o->oInteractStatus & INT_STATUS_HIT_MINE) { spawn_object(o, MODEL_BOWSER_FLAMES, bhvBowserBombExplosion); create_sound_spawner(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION); set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ); @@ -19,33 +18,40 @@ void bhv_bowser_bomb_loop(void) { } void bhv_bowser_bomb_explosion_loop(void) { - struct Object *mineSmoke; - cur_obj_scale((f32) o->oTimer / 14.0f * 9.0 + 1.0); + if ((o->oTimer % 4 == 0) && (o->oTimer < 20)) { - mineSmoke = spawn_object(o, MODEL_BOWSER_SMOKE, bhvBowserBombSmoke); + struct Object *mineSmoke = spawn_object(o, MODEL_BOWSER_SMOKE, bhvBowserBombSmoke); mineSmoke->oPosX += random_float() * 600.0f - 400.0f; mineSmoke->oPosZ += random_float() * 600.0f - 400.0f; mineSmoke->oVelY += random_float() * 10.0f; } - if (o->oTimer % 2 == 0) + if (o->oTimer % 2 == 0) { o->oAnimState++; - if (o->oTimer == 28) + } + + if (o->oTimer == 28) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } void bhv_bowser_bomb_smoke_loop(void) { cur_obj_scale((f32) o->oTimer / 14.0f * 9.0 + 1.0); - if (o->oTimer % 2 == 0) + + if (o->oTimer % 2 == 0) { o->oAnimState++; + } o->oOpacity -= 10; - if (o->oOpacity < 10) + + if (o->oOpacity < 10) { o->oOpacity = 0; + } o->oPosY += o->oVelY; - if (o->oTimer == 28) + if (o->oTimer == 28) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } diff --git a/src/game/behaviors/bowser_falling_platform.inc.c b/src/game/behaviors/bowser_falling_platform.inc.c index 0d1e0e43..85da27a7 100644 --- a/src/game/behaviors/bowser_falling_platform.inc.c +++ b/src/game/behaviors/bowser_falling_platform.inc.c @@ -1,3 +1,5 @@ +// bowser_falling_platform.inc.c + struct BowserFallingPlatformData { const Collision *collision; s16 posX; @@ -16,32 +18,40 @@ struct BowserFallingPlatformData sBowserFallingPlatform[] = { { bowser_3_seg7_collision_07004EAC, 1158, 390, 18432 }, { bowser_3_seg7_collision_07004F30, 800, -1000, 20992 }, { bowser_3_seg7_collision_07004FB4, 800, -1000, -31744 }, - { bowser_3_seg7_collision_07005038, -800, -1000, 31744 } + { bowser_3_seg7_collision_07005038, -800, -1000, 31744 }, }; void falling_bowser_plat_act_start(void) { o->oBitsPlatformBowser = cur_obj_nearest_object_with_behavior(bhvBowser); obj_set_collision_data(o, sBowserFallingPlatform[o->oBehParams2ndByte].collision); - if (o->oBitsPlatformBowser != 0) + if (o->oBitsPlatformBowser != NULL) { o->oAction = BOWSER_BITS_PLAT_ACT_CHECK; + } } void falling_bowser_plat_act_check(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; struct Object *bowser = o->oBitsPlatformBowser; + if (bowser->platform == o) { - if (bowser->oAction == BOWSER_ACT_BIG_JUMP && bowser->oBowserStatus & BOWSER_STATUS_BIG_JUMP) { + if (bowser->oAction == BOWSER_ACT_BIG_JUMP + && bowser->oBowserStatus & BOWSER_STATUS_BIG_JUMP) { o->oAction = BOWSER_BITS_PLAT_ACT_FALL; } } - if (bowser->oHealth == 1 && (bowser->oAction == BOWSER_ACT_DANCE || bowser->oHeldState != HELD_FREE)) { + + if (bowser->oHealth == 1 + && (bowser->oAction == BOWSER_ACT_DANCE || bowser->oHeldState != HELD_FREE)) { o->oSubAction = 1; } + if (o->oSubAction == 0) { o->oBitsPlatformTimer = 0; } else { - if ((gDebugInfo[4][6] + 20) * (o->oBehParams2ndByte - 1) < o->oBitsPlatformTimer) + if ((gDebugInfo[DEBUG_PAGE_EFFECTINFO][6] + 20) + * (o->oBehParams2ndByte - 1) < o->oBitsPlatformTimer) { o->oAction = BOWSER_BITS_PLAT_ACT_FALL; + } o->oBitsPlatformTimer++; } } @@ -51,17 +61,22 @@ void falling_bowser_plat_act_fall(void) { s16 angle; f32 val; UNUSED struct Object *bowser = o->oBitsPlatformBowser; + if (o->oTimer == 0 || o->oTimer == 22) { cur_obj_play_sound_2(SOUND_GENERAL_BOWSER_PLATFORM_2); } + if (o->oTimer < 22) { set_environmental_camera_shake(SHAKE_ENV_FALLING_BITS_PLAT); o->oVelY = 8.0f; o->oGravity = 0.0f; - } else + } else { o->oGravity = -4.0f; - if ((o->oTimer & 1) == 0 && o->oTimer < 14) { - angle = sBowserFallingPlatform[o->oBehParams2ndByte].angle + (gDebugInfo[4][1] << 8); + } + + if (!(o->oTimer & 1) && o->oTimer < 14) { + angle = sBowserFallingPlatform[o->oBehParams2ndByte].angle + + (gDebugInfo[DEBUG_PAGE_EFFECTINFO][1] << 8); val = -(o->oTimer / 2) * 290 + 1740; vec3f_copy_2(pos, &o->oPosX); o->oPosX = sBowserFallingPlatform[o->oBehParams2ndByte].posX + sins(angle + 0x14B0) * val; @@ -73,7 +88,9 @@ void falling_bowser_plat_act_fall(void) { spawn_mist_particles_variable(4, 0, 100); vec3f_copy_2(&o->oPosX, pos); } + cur_obj_move_using_fvel_and_gravity(); + if (o->oTimer > 300) { obj_mark_for_deletion(o); } diff --git a/src/game/behaviors/bowser_flame.inc.c b/src/game/behaviors/bowser_flame.inc.c index 4501d977..08a6d670 100644 --- a/src/game/behaviors/bowser_flame.inc.c +++ b/src/game/behaviors/bowser_flame.inc.c @@ -1,25 +1,27 @@ +// bowser_flame.inc.c + struct ObjectHitbox sGrowingBowserFlameHitbox = { - /* interactType: */ INTERACT_FLAME, - /* downOffset: */ 20, + /* interactType: */ INTERACT_FLAME, + /* downOffset: */ 20, /* damageOrCoinValue: */ 1, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 10, - /* height: */ 40, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 10, + /* height: */ 40, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; struct ObjectHitbox sBowserFlameHitbox = { - /* interactType: */ INTERACT_FLAME, - /* downOffset: */ 0, + /* interactType: */ INTERACT_FLAME, + /* downOffset: */ 0, /* damageOrCoinValue: */ 1, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 10, - /* height: */ 40, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 10, + /* height: */ 40, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; void bowser_flame_despawn(void) { @@ -49,11 +51,7 @@ s32 bowser_flame_should_despawn(s32 maxTime) { void bhv_flame_bowser_init(void) { o->oAnimState = (s32)(random_float() * 10.0f); o->oMoveAngleYaw = random_u16(); - if (random_float() < 0.2) { - o->oVelY = 80.0f; - } else { - o->oVelY = 20.0f; - } + o->oVelY = random_float() < 0.2 ? 80.0f : 20.0f; o->oForwardVel = 10.0f; o->oGravity = -1.0f; o->oFlameScale = random_float() + 1.0f; @@ -68,8 +66,7 @@ void bhv_flame_large_burning_out_init(void) { } void bowser_flame_move(void) { - s32 timer; - timer = ((o->oFlameSpeedTimerOffset + gGlobalTimer) & 0x3F) << 10; + s32 timer = ((o->oFlameSpeedTimerOffset + gGlobalTimer) & 0x3F) << 10; o->oPosX += sins(o->oMoveAngleYaw) * sins(timer) * 4.0f; o->oPosZ += coss(o->oMoveAngleYaw) * sins(timer) * 4.0f; } @@ -77,12 +74,15 @@ void bowser_flame_move(void) { void bhv_flame_bowser_loop(void) { cur_obj_update_floor_and_walls(); cur_obj_move_standard(78); + if (o->oVelY < -4.0f) { o->oVelY = -4.0f; } + if (o->oAction == 0) { cur_obj_become_intangible(); bowser_flame_move(); + if (o->oMoveFlags & OBJ_MOVE_LANDED) { o->oAction++; if (cur_obj_has_behavior(bhvFlameLargeBurningOut)) { @@ -96,6 +96,7 @@ void bhv_flame_bowser_loop(void) { } } else { cur_obj_become_tangible(); + if (o->oTimer > o->oFlameScale * 10 + 5.0f) { o->oFlameScale -= 0.15; if (o->oFlameScale <= 0) { @@ -103,6 +104,7 @@ void bhv_flame_bowser_loop(void) { } } } + cur_obj_scale(o->oFlameScale); o->oGraphYOffset = o->header.gfx.scale[1] * 14.0f; obj_set_hitbox(o, &sBowserFlameHitbox); @@ -116,19 +118,24 @@ void bhv_flame_moving_forward_growing_init(void) { } void bhv_flame_moving_forward_growing_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; UNUSED struct Object *flame; + obj_set_hitbox(o, &sGrowingBowserFlameHitbox); o->oFlameScale = o->oFlameScale + 0.5; cur_obj_scale(o->oFlameScale); + if (o->oMoveAnglePitch > 0x800) { o->oMoveAnglePitch -= 0x200; } + cur_obj_set_pos_via_transform(); cur_obj_update_floor_height(); + if (o->oFlameScale > 30.0f) { obj_mark_for_deletion(o); } + if (o->oPosY < o->oFloorHeight) { o->oPosY = o->oFloorHeight; flame = spawn_object(o, MODEL_RED_FLAME, bhvFlameBowser); @@ -152,16 +159,20 @@ void bhv_flame_floating_landing_init(void) { f32 sFlameFloatingYLimit[] = { -8.0f, -6.0f, -3.0f }; void bhv_flame_floating_landing_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; + cur_obj_update_floor_and_walls(); cur_obj_move_standard(78); bowser_flame_move(); + if (bowser_flame_should_despawn(900)) { obj_mark_for_deletion(o); } + if (o->oVelY < sFlameFloatingYLimit[o->oBehParams2ndByte]) { o->oVelY = sFlameFloatingYLimit[o->oBehParams2ndByte]; } + if (o->oMoveFlags & OBJ_MOVE_LANDED) { if (o->oBehParams2ndByte == 0) { spawn_object(o, MODEL_RED_FLAME, bhvFlameLargeBurningOut); @@ -170,6 +181,7 @@ void bhv_flame_floating_landing_loop(void) { } obj_mark_for_deletion(o); } + o->oGraphYOffset = o->header.gfx.scale[1] * 14.0f; } @@ -186,14 +198,18 @@ void bhv_blue_bowser_flame_init(void) { void bhv_blue_bowser_flame_loop(void) { s32 i; + obj_set_hitbox(o, &sGrowingBowserFlameHitbox); + if (o->oFlameScale < 16.0f) { o->oFlameScale = o->oFlameScale + 0.5; } + cur_obj_scale(o->oFlameScale); cur_obj_update_floor_and_walls(); cur_obj_move_standard(78); - if (o->oTimer > 0x14) { + + if (o->oTimer > 20) { if (o->oBehParams2ndByte == 0) { for (i = 0; i < 3; i++) { spawn_object_relative_with_scale(0, 0, 0, 0, 5.0f, o, MODEL_RED_FLAME, @@ -219,9 +235,11 @@ void bhv_flame_bouncing_init(void) { void bhv_flame_bouncing_loop(void) { struct Object *bowser; + if (o->oTimer == 0) { o->oFlameBowser = cur_obj_nearest_object_with_behavior(bhvBowser); } + bowser = o->oFlameBowser; o->oForwardVel = 15.0f; o->oBounciness = -1.0f; @@ -229,9 +247,11 @@ void bhv_flame_bouncing_loop(void) { obj_set_hitbox(o, &sGrowingBowserFlameHitbox); cur_obj_update_floor_and_walls(); cur_obj_move_standard(78); + if (bowser_flame_should_despawn(300)) { obj_mark_for_deletion(o); } + if (bowser != NULL) { if (bowser->oHeldState == HELD_FREE) { if (lateral_dist_between_objects(o, bowser) < 300.0f) { @@ -244,12 +264,14 @@ void bhv_flame_bouncing_loop(void) { void bhv_blue_flames_group_loop(void) { struct Object *flame; s32 i; + if (o->oTimer == 0) { o->oMoveAngleYaw = obj_angle_to_object(o, gMarioObject); o->oBlueFlameNextScale = 5.0f; } + if (o->oTimer < 16) { - if ((o->oTimer & 1) == 0) { + if (!(o->oTimer & 1)) { for (i = 0; i < 3; i++) { flame = spawn_object(o, MODEL_BLUE_FLAME, bhvFlameBouncing); flame->oMoveAngleYaw += i * 0x5555; diff --git a/src/game/behaviors/bowser_key.inc.c b/src/game/behaviors/bowser_key.inc.c index 584b1900..df5d4447 100644 --- a/src/game/behaviors/bowser_key.inc.c +++ b/src/game/behaviors/bowser_key.inc.c @@ -1,41 +1,46 @@ -// bowser_key.c.inc +// bowser_key.inc.c struct ObjectHitbox sBowserKeyHitbox = { - /* interactType: */ INTERACT_STAR_OR_KEY, - /* downOffset: */ 0, + /* interactType: */ INTERACT_STAR_OR_KEY, + /* downOffset: */ 0, /* damageOrCoinValue: */ 0, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 160, - /* height: */ 100, - /* hurtboxRadius: */ 160, - /* hurtboxHeight: */ 100, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 160, + /* height: */ 100, + /* hurtboxRadius: */ 160, + /* hurtboxHeight: */ 100, }; void bhv_bowser_key_loop(void) { cur_obj_scale(0.5f); - if (o->oAngleVelYaw > 0x400) + + if (o->oAngleVelYaw > 0x400) { o->oAngleVelYaw -= 0x100; + } + o->oFaceAngleYaw += o->oAngleVelYaw; o->oFaceAngleRoll = -0x4000; o->oGraphYOffset = 165.0f; + if (o->oAction == 0) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oVelY = 70.0f; + } + spawn_sparkle_particles(3, 200, 80, -60); spawn_object(o, MODEL_NONE, bhvSparkleSpawn); cur_obj_update_floor_and_walls(); cur_obj_move_standard(78); - if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) + + if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) { o->oAction++; - else if (o->oMoveFlags & OBJ_MOVE_LANDED) -#ifndef VERSION_JP - cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN3_2); -#else - cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN3_LOWPRIO); -#endif + } else if (o->oMoveFlags & OBJ_MOVE_LANDED) { + cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN3); + } } else { obj_set_hitbox(o, &sBowserKeyHitbox); + if (o->oInteractStatus & INT_STATUS_INTERACTED) { mark_obj_for_deletion(o); o->oInteractStatus = 0; diff --git a/src/game/behaviors/bowser_key_cutscene.inc.c b/src/game/behaviors/bowser_key_cutscene.inc.c index e840b893..6f3ac484 100644 --- a/src/game/behaviors/bowser_key_cutscene.inc.c +++ b/src/game/behaviors/bowser_key_cutscene.inc.c @@ -1,47 +1,55 @@ // bowser_key_cutscene.inc.c Gfx *geo_scale_bowser_key(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]) { - struct Object *sp4; if (run == TRUE) { - sp4 = (struct Object *) gCurGraphNodeObject; + struct Object *sp4 = (struct Object *) gCurGraphNodeObject; ((struct GraphNodeScale *) node->next)->scale = sp4->oBowserKeyScale; } - return 0; + return NULL; } void bhv_bowser_key_unlock_door_loop(void) { - s32 animTimer; - animTimer = o->header.gfx.animInfo.animFrame; + s32 animFrame = o->header.gfx.animInfo.animFrame; + cur_obj_init_animation_with_sound(0); - if (animTimer < 38) + + if (animFrame < 38) { o->oBowserKeyScale = 0.0f; - else if (animTimer < 49) + } else if (animFrame < 49) { o->oBowserKeyScale = 0.2f; - else if (animTimer < 58) - o->oBowserKeyScale = (animTimer - 53) * 0.11875f + 0.2; // 0.11875? - else if (animTimer < 59) + } else if (animFrame < 58) { + o->oBowserKeyScale = (animFrame - 53) * 0.11875f + 0.2; // 0.11875? + } else if (animFrame < 59) { o->oBowserKeyScale = 1.1f; - else if (animTimer < 60) + } else if (animFrame < 60) { o->oBowserKeyScale = 1.05f; - else + } else { o->oBowserKeyScale = 1.0f; - if (o->oTimer > 150) + } + + if (o->oTimer > 150) { obj_mark_for_deletion(o); + } } void bhv_bowser_key_course_exit_loop(void) { - s32 animTimer = o->header.gfx.animInfo.animFrame; + s32 animFrame = o->header.gfx.animInfo.animFrame; + cur_obj_init_animation_with_sound(1); - if (animTimer < 38) + + if (animFrame < 38) { o->oBowserKeyScale = 0.2f; - else if (animTimer < 52) - o->oBowserKeyScale = (animTimer - 42) * 0.042857f + 0.2; // TODO 3/70? - else if (animTimer < 94) + } else if (animFrame < 52) { + o->oBowserKeyScale = (animFrame - 42) * 0.042857f + 0.2; // TODO 3/70? + } else if (animFrame < 94) { o->oBowserKeyScale = 0.8f; - else if (animTimer < 101) - o->oBowserKeyScale = (101 - animTimer) * 0.085714f + 0.2; // TODO 6/70? - else + } else if (animFrame < 101) { + o->oBowserKeyScale = (101 - animFrame) * 0.085714f + 0.2; // TODO 6/70? + } else { o->oBowserKeyScale = 0.2f; - if (o->oTimer > 138) + } + + if (o->oTimer > 138) { obj_mark_for_deletion(o); + } } diff --git a/src/game/behaviors/bowser_puzzle_piece.inc.c b/src/game/behaviors/bowser_puzzle_piece.inc.c index 14db4de6..aaed6022 100644 --- a/src/game/behaviors/bowser_puzzle_piece.inc.c +++ b/src/game/behaviors/bowser_puzzle_piece.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for the sliding Bowser puzzle in Lethal Lava Land. */ @@ -103,12 +104,13 @@ void bhv_lll_bowser_puzzle_spawn_pieces(f32 pieceWidth) { s32 i; // Spawn all 14 puzzle pieces. - for (i = 0; i < 14; i++) + for (i = 0; i < 14; i++) { bhv_lll_bowser_puzzle_spawn_piece(sBowserPuzzlePieces[i].model, bhvLllBowserPuzzlePiece, sBowserPuzzlePieces[i].xOffset * pieceWidth / 10.0f, sBowserPuzzlePieces[i].zOffset * pieceWidth / 10.0f, sBowserPuzzlePieces[i].initialAction, sBowserPuzzlePieces[i].actionList); + } // The pieces should only be spawned once so go to the next action. o->oAction++; @@ -119,17 +121,20 @@ void bhv_lll_bowser_puzzle_spawn_pieces(f32 pieceWidth) { */ void bhv_lll_bowser_puzzle_loop(void) { s32 i; - UNUSED struct Object *sp28; + switch (o->oAction) { case BOWSER_PUZZLE_ACT_SPAWN_PIECES: bhv_lll_bowser_puzzle_spawn_pieces(480.0f); break; + case BOWSER_PUZZLE_ACT_WAIT_FOR_COMPLETE: // If both completion flags are set and Mario is within 1000 units... if (o->oBowserPuzzleCompletionFlags == 3 && o->oDistanceToMario < 1000.0f) { // Spawn 5 coins. - for (i = 0; i < 5; i++) - sp28 = spawn_object(o, MODEL_YELLOW_COIN, bhvSingleCoinGetsSpawned); + for (i = 0; i < 5; i++) { + UNUSED struct Object *coin = + spawn_object(o, MODEL_YELLOW_COIN, bhvSingleCoinGetsSpawned); + } // Reset completion flags (even though they never get checked again). o->oBowserPuzzleCompletionFlags = 0; @@ -138,6 +143,7 @@ void bhv_lll_bowser_puzzle_loop(void) { o->oAction++; } break; + case BOWSER_PUZZLE_ACT_DONE: break; } @@ -164,8 +170,9 @@ void bhv_lll_bowser_puzzle_piece_update(void) { s8 *nextAction = o->oBowserPuzzlePieceNextAction; // If Mario is standing on this puzzle piece, set a flag in the parent. - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->parentObj->oBowserPuzzleCompletionFlags = 1; + } // If we should advance to the next action... if (o->oBowserPuzzlePieceContinuePerformingAction == 0) { @@ -193,14 +200,16 @@ void bhv_lll_bowser_puzzle_piece_update(void) { void bhv_lll_bowser_puzzle_piece_move(f32 xOffset, f32 zOffset, s32 duration, UNUSED s32 a3) { // For the first 20 frames, shake the puzzle piece up and down. if (o->oTimer < 20) { - if (o->oTimer % 2) + if (o->oTimer % 2) { o->oBowserPuzzlePieceOffsetY = 0.0f; - else + } else { o->oBowserPuzzlePieceOffsetY = -6.0f; + } } else { // On frame 20, play the shifting sound. - if (o->oTimer == 20) + if (o->oTimer == 20) { cur_obj_play_sound_2(SOUND_OBJ2_BOWSER_PUZZLE_PIECE_MOVE); + } // For the number of frames specified by duration, move the piece. if (o->oTimer < duration + 20) { @@ -208,8 +217,8 @@ void bhv_lll_bowser_puzzle_piece_move(f32 xOffset, f32 zOffset, s32 duration, UN o->oBowserPuzzlePieceOffsetZ += zOffset; } else { // This doesn't actually accomplish anything since - // cur_obj_change_action is going to be called before the - // next action is performed anyway. + // cur_obj_change_action is going to be called before the + // next action is performed anyway. o->oAction = 2; // Advance to the next action. @@ -219,14 +228,15 @@ void bhv_lll_bowser_puzzle_piece_move(f32 xOffset, f32 zOffset, s32 duration, UN } void bhv_lll_bowser_puzzle_piece_idle(void) { - UNUSED s32 sp4; + UNUSED s32 unused; // For the first 24 frames, do nothing. - if (o->oTimer < 24) - sp4 = 0; - else + if (o->oTimer < 24) { + unused = 0; + } else { // Then advance to the next action. o->oBowserPuzzlePieceContinuePerformingAction = 0; + } } void bhv_lll_bowser_puzzle_piece_move_left(void) { @@ -246,10 +256,13 @@ void bhv_lll_bowser_puzzle_piece_move_down(void) { } void (*sBowserPuzzlePieceActions[])(void) = { - bhv_lll_bowser_puzzle_piece_action_0, bhv_lll_bowser_puzzle_piece_action_1, - bhv_lll_bowser_puzzle_piece_idle, bhv_lll_bowser_puzzle_piece_move_left, - bhv_lll_bowser_puzzle_piece_move_right, bhv_lll_bowser_puzzle_piece_move_up, - bhv_lll_bowser_puzzle_piece_move_down + bhv_lll_bowser_puzzle_piece_action_0, + bhv_lll_bowser_puzzle_piece_action_1, + bhv_lll_bowser_puzzle_piece_idle, + bhv_lll_bowser_puzzle_piece_move_left, + bhv_lll_bowser_puzzle_piece_move_right, + bhv_lll_bowser_puzzle_piece_move_up, + bhv_lll_bowser_puzzle_piece_move_down, }; void bhv_lll_bowser_puzzle_piece_loop(void) { diff --git a/src/game/behaviors/break_particles.inc.c b/src/game/behaviors/break_particles.inc.c index c7160ecd..a3db1aa4 100644 --- a/src/game/behaviors/break_particles.inc.c +++ b/src/game/behaviors/break_particles.inc.c @@ -1,8 +1,9 @@ -// break_particles.c.inc +// break_particles.inc.c void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16 triAnimState) { struct Object *triangle; s32 i; + for (i = 0; i < numTris; i++) { triangle = spawn_object(o, triModel, bhvBreakBoxTriangle); triangle->oAnimState = triAnimState; @@ -11,6 +12,7 @@ void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16 triangle->oFaceAngleYaw = triangle->oMoveAngleYaw; triangle->oFaceAnglePitch = random_u16(); triangle->oVelY = random_f32_around_zero(50.0f); + if (triModel == MODEL_DIRT_ANIMATION || triModel == MODEL_SL_CRACKED_ICE_CHUNK) { triangle->oAngleVelPitch = 0xF00; triangle->oAngleVelYaw = 0x500; @@ -19,6 +21,7 @@ void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16 triangle->oAngleVelPitch = 0x80 * (s32)(random_float() + 50.0f); triangle->oForwardVel = 30.0f; } + obj_scale(triangle, triSize); } } diff --git a/src/game/behaviors/breakable_box.inc.c b/src/game/behaviors/breakable_box.inc.c index f46954c3..361e9290 100644 --- a/src/game/behaviors/breakable_box.inc.c +++ b/src/game/behaviors/breakable_box.inc.c @@ -1,11 +1,14 @@ -// breakable_box.c.inc +// breakable_box.inc.c void bhv_breakable_box_loop(void) { obj_set_hitbox(o, &sBreakableBoxHitbox); cur_obj_set_model(MODEL_BREAKABLE_BOX_SMALL); - if (o->oTimer == 0) + + if (o->oTimer == 0) { breakable_box_init(); - if (cur_obj_was_attacked_or_ground_pounded() != 0) { + } + + if (cur_obj_was_attacked_or_ground_pounded()) { obj_explode_and_spawn_coins(46.0f, 1); create_sound_spawner(SOUND_GENERAL_BREAK_BOX); } diff --git a/src/game/behaviors/breakable_box_small.inc.c b/src/game/behaviors/breakable_box_small.inc.c index fe962bf0..1cf6ae74 100644 --- a/src/game/behaviors/breakable_box_small.inc.c +++ b/src/game/behaviors/breakable_box_small.inc.c @@ -1,4 +1,4 @@ -// breakable_box.c.inc +// breakable_box.inc.c struct ObjectHitbox sBreakableBoxSmallHitbox = { /* interactType: */ INTERACT_GRABBABLE, @@ -29,19 +29,22 @@ void small_breakable_box_spawn_dust(void) { } void small_breakable_box_act_move(void) { - s16 sp1E = object_step(); + s16 collisionFlags = object_step(); obj_attack_collided_from_other_object(o); - if (sp1E == 1) + + if (collisionFlags == OBJ_COL_FLAG_GROUNDED) { cur_obj_play_sound_2(SOUND_GENERAL_BOX_LANDING_2); - if (sp1E & 1) { + } + + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { if (o->oForwardVel > 20.0f) { cur_obj_play_sound_2(SOUND_ENV_SLIDING); small_breakable_box_spawn_dust(); } } - if (sp1E & 2) { + if (collisionFlags & OBJ_COL_FLAG_HIT_WALL) { spawn_mist_particles(); spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 0.7f, 3); obj_spawn_yellow_coins(o, 3); @@ -49,7 +52,7 @@ void small_breakable_box_act_move(void) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - obj_check_floor_death(sp1E, sObjFloor); + obj_check_floor_death(collisionFlags, sObjFloor); } void breakable_box_small_released_loop(void) { @@ -57,10 +60,11 @@ void breakable_box_small_released_loop(void) { // Begin flashing if (o->oBreakableBoxSmallFramesSinceReleased > 810) { - if (o->oBreakableBoxSmallFramesSinceReleased & 1) + if (o->oBreakableBoxSmallFramesSinceReleased & 1) { o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; - else + } else { o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; + } } // Despawn, and create a corkbox respawner @@ -86,8 +90,9 @@ void breakable_box_small_idle_loop(void) { break; } - if (o->oBreakableBoxSmallReleased == 1) + if (o->oBreakableBoxSmallReleased == TRUE) { breakable_box_small_released_loop(); + } } void breakable_box_small_get_dropped(void) { @@ -96,7 +101,7 @@ void breakable_box_small_get_dropped(void) { cur_obj_get_dropped(); o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; o->oHeldState = 0; - o->oBreakableBoxSmallReleased = 1; + o->oBreakableBoxSmallReleased = TRUE; o->oBreakableBoxSmallFramesSinceReleased = 0; } @@ -106,10 +111,10 @@ void breakable_box_small_get_thrown(void) { cur_obj_enable_rendering(); o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; o->oHeldState = 0; - o->oFlags &= ~0x08; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oForwardVel = 40.0f; o->oVelY = 20.0f; - o->oBreakableBoxSmallReleased = 1; + o->oBreakableBoxSmallReleased = TRUE; o->oBreakableBoxSmallFramesSinceReleased = 0; o->activeFlags &= ~ACTIVE_FLAG_UNK9; } diff --git a/src/game/behaviors/breakable_wall.inc.c b/src/game/behaviors/breakable_wall.inc.c index dbb92c8d..53e21de0 100644 --- a/src/game/behaviors/breakable_wall.inc.c +++ b/src/game/behaviors/breakable_wall.inc.c @@ -1,16 +1,22 @@ -// breakable_wall.c.inc +// breakable_wall.inc.c void bhv_wf_breakable_wall_loop(void) { if (gMarioStates[0].action == ACT_SHOT_FROM_CANNON) { cur_obj_become_tangible(); + if (obj_check_if_collided_with_object(o, gMarioObject)) { - if (cur_obj_has_behavior(bhvWfBreakableWallRight)) + if (cur_obj_has_behavior(bhvWfBreakableWallRight)) { play_puzzle_jingle(); + } + create_sound_spawner(SOUND_GENERAL_WALL_EXPLOSION); - o->oInteractType = 8; + + o->oInteractType = INTERACT_DAMAGE; o->oDamageOrCoinValue = 1; + obj_explode_and_spawn_coins(80.0f, 0); } - } else + } else { cur_obj_become_intangible(); + } } diff --git a/src/game/behaviors/bub.inc.c b/src/game/behaviors/bub.inc.c index e8e63096..47c9b6ae 100644 --- a/src/game/behaviors/bub.inc.c +++ b/src/game/behaviors/bub.inc.c @@ -1,23 +1,24 @@ -// bub.c.inc +// bub.inc.c // NOTE: These first set of functions spawn a school of bub depending on objF4's // value. The later action functions seem to check Y distance to Mario and proceed // to do nothing, which indicates this behavior set is incomplete. -// TODO: Rename these. These have nothing to do with birds. void bub_spawner_act_0(void) { s32 i; s32 sp18 = o->oBirdChirpChirpUnkF4; if (o->oDistanceToMario < 1500.0f) { - for (i = 0; i < sp18; i++) + for (i = 0; i < sp18; i++) { spawn_object(o, MODEL_BUB, bhvBub); + } o->oAction = 1; } } void bub_spawner_act_1(void) { - if (gMarioObject->oPosY - o->oPosY > 2000.0f) + if (gMarioObject->oPosY - o->oPosY > 2000.0f) { o->oAction = 2; + } } void bub_spawner_act_2(void) { @@ -28,8 +29,12 @@ void bub_spawner_act_3(void) { o->oAction = 0; } -void (*sBirdChirpChirpActions[])(void) = { bub_spawner_act_0, bub_spawner_act_1, - bub_spawner_act_2, bub_spawner_act_3 }; +void (*sBirdChirpChirpActions[])(void) = { + bub_spawner_act_0, + bub_spawner_act_1, + bub_spawner_act_2, + bub_spawner_act_3, +}; void bhv_bub_spawner_loop(void) { cur_obj_call_action_function(sBirdChirpChirpActions); @@ -38,9 +43,9 @@ void bhv_bub_spawner_loop(void) { void bub_move_vertically(s32 a0) { f32 sp1C = o->parentObj->oPosY; if (sp1C - 100.0f - o->oCheepCheepUnk104 < o->oPosY - && o->oPosY < sp1C + 1000.0f + o->oCheepCheepUnk104) + && o->oPosY < sp1C + 1000.0f + o->oCheepCheepUnk104) { o->oPosY = approach_f32_symmetric(o->oPosY, o->oCheepCheepUnkF8, a0); - else { + } else { } } @@ -52,73 +57,115 @@ void bub_act_0(void) { void bub_act_1(void) { f32 dy; + if (o->oTimer == 0) { o->oForwardVel = random_float() * 2 + 2; o->oCheepCheepUnk108 = random_float(); } + dy = o->oPosY - gMarioObject->oPosY; + if (o->oPosY < o->oCheepCheepUnkF4 - 50.0f) { - if (dy < 0.0f) + if (dy < 0.0f) { dy = 0.0f - dy; - if (dy < 500.0f) + } + + if (dy < 500.0f) { bub_move_vertically(1); - else + } else { bub_move_vertically(4); + } } else { o->oPosY = o->oCheepCheepUnkF4 - 50.0f; - if (dy > 300.0f) + + if (dy > 300.0f) { o->oPosY = o->oPosY - 1.0f; + } } - if (800.0f < cur_obj_lateral_dist_from_mario_to_home()) + + if (800.0f < cur_obj_lateral_dist_from_mario_to_home()) { o->oAngleToMario = cur_obj_angle_to_home(); + } + cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x100); - if (o->oDistanceToMario < 200.0f) - if (o->oCheepCheepUnk108 < 0.5) + + if (o->oDistanceToMario < 200.0f) { + if (o->oCheepCheepUnk108 < 0.5) { o->oAction = 2; - if (o->oInteractStatus & INT_STATUS_INTERACTED) + } + } + + if (o->oInteractStatus & INT_STATUS_INTERACTED) { o->oAction = 2; + } } void bub_act_2(void) { f32 dy; + if (o->oTimer < 20) { - if (o->oInteractStatus & INT_STATUS_INTERACTED) + if (o->oInteractStatus & INT_STATUS_INTERACTED) { spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticleSnow); - } else + } + } else { o->oInteractStatus = 0; - if (o->oTimer == 0) + } + + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER); - if (o->oForwardVel == 0.0f) + } + + if (o->oForwardVel == 0.0f) { o->oForwardVel = 6.0f; + } + dy = o->oPosY - gMarioObject->oPosY; + if (o->oPosY < o->oCheepCheepUnkF4 - 50.0f) { - if (dy < 0.0f) + if (dy < 0.0f) { dy = 0.0f - dy; - if (dy < 500.0f) + } + + if (dy < 500.0f) { bub_move_vertically(2); - else + } else { bub_move_vertically(4); + } } else { o->oPosY = o->oCheepCheepUnkF4 - 50.0f; - if (dy > 300.0f) + + if (dy > 300.0f) { o->oPosY -= 1.0f; + } } - if (cur_obj_lateral_dist_from_mario_to_home() > 800.0f) + + if (cur_obj_lateral_dist_from_mario_to_home() > 800.0f) { o->oAngleToMario = cur_obj_angle_to_home(); + } + cur_obj_rotate_yaw_toward(o->oAngleToMario + 0x8000, 0x400); - if (o->oTimer > 200 && o->oDistanceToMario > 600.0f) + + if (o->oTimer > 200 && o->oDistanceToMario > 600.0f) { o->oAction = 1; + } } -void (*sCheepCheepActions[])(void) = { bub_act_0, bub_act_1, bub_act_2 }; +void (*sCheepCheepActions[])(void) = { + bub_act_0, + bub_act_1, + bub_act_2, +}; void bhv_bub_loop(void) { o->oCheepCheepUnkF4 = find_water_level(o->oPosX, o->oPosZ); o->oCheepCheepUnkF8 = gMarioObject->oPosY + o->oCheepCheepUnkFC; o->oWallHitboxRadius = 30.0f; + cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sCheepCheepActions); cur_obj_move_using_fvel_and_gravity(); - if (o->parentObj->oAction == 2) + + if (o->parentObj->oAction == 2) { obj_mark_for_deletion(o); + } } diff --git a/src/game/behaviors/bubba.inc.c b/src/game/behaviors/bubba.inc.c index 9964b0fe..b973496d 100644 --- a/src/game/behaviors/bubba.inc.c +++ b/src/game/behaviors/bubba.inc.c @@ -13,9 +13,8 @@ static struct ObjectHitbox sBubbaHitbox = { }; void bubba_act_0(void) { - f32 sp24; + f32 sp24 = cur_obj_lateral_dist_to_home(); - sp24 = cur_obj_lateral_dist_to_home(); treat_far_home_as_mario(2000.0f); o->oAnimState = 0; @@ -33,12 +32,12 @@ void bubba_act_0(void) { o->oBubbaUnkF8 = random_linear_offset(20, 30); } - if ((o->oBubbaUnkFC = o->oMoveFlags & OBJ_MOVE_HIT_WALL) != 0) { + if ((o->oBubbaUnkFC = o->oMoveFlags & OBJ_MOVE_HIT_WALL)) { o->oBubbaUnk1AE = cur_obj_reflect_move_angle_off_wall(); } else if (o->oTimer > 30 && o->oDistanceToMario < 2000.0f) { o->oAction = 1; } else if (o->oBubbaUnkF8 != 0) { - o->oBubbaUnkF8 -= 1; + o->oBubbaUnkF8--; } else { o->oBubbaUnk1AE = obj_random_fixed_turn(0x2000); o->oBubbaUnkF8 = random_linear_offset(100, 100); @@ -48,6 +47,7 @@ void bubba_act_0(void) { void bubba_act_1(void) { treat_far_home_as_mario(2500.0f); + if (o->oDistanceToMario > 2500.0f) { o->oAction = 0; } else if (o->oBubbaUnk100 != 0) { @@ -96,7 +96,7 @@ void bubba_act_1(void) { } void bhv_bubba_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; o->oInteractionSubtype &= ~INT_SUBTYPE_EATS_MARIO; o->oBubbaUnk104 = obj_turn_pitch_toward_mario(120.0f, 0); diff --git a/src/game/behaviors/bubble.inc.c b/src/game/behaviors/bubble.inc.c index 49b06275..9b977015 100644 --- a/src/game/behaviors/bubble.inc.c +++ b/src/game/behaviors/bubble.inc.c @@ -1,4 +1,4 @@ -// bubble.c.inc +// bubble.inc.c void bhv_object_bubble_init(void) { o->oPosX += random_float() * 30.0f; @@ -12,7 +12,7 @@ void bhv_object_bubble_loop(void) { f32 bubbleY = o->oPosY; if (bubbleY > waterY) { - if (gFreeObjectList.next) { + if (gFreeObjectList.next != NULL) { bubbleSplash = spawn_object_at_origin(o, 0, MODEL_SMALL_WATER_SPLASH, bhvBubbleSplash); bubbleSplash->oPosX = o->oPosX; bubbleSplash->oPosY = bubbleY + 5.0f; diff --git a/src/game/behaviors/bullet_bill.inc.c b/src/game/behaviors/bullet_bill.inc.c index 611bc945..64056cd6 100644 --- a/src/game/behaviors/bullet_bill.inc.c +++ b/src/game/behaviors/bullet_bill.inc.c @@ -1,6 +1,5 @@ // bullet_bill.inc.c -// bullet bill smoke void bhv_white_puff_smoke_init(void) { cur_obj_scale(random_float() * 2 + 2.0); } @@ -22,29 +21,37 @@ void bullet_bill_act_0(void) { void bullet_bill_act_1(void) { s16 sp1E = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); - if (sp1E < 0x2000 && 400.0f < o->oDistanceToMario && o->oDistanceToMario < 1500.0f) + if (sp1E < 0x2000 && 400.0f < o->oDistanceToMario && o->oDistanceToMario < 1500.0f) { o->oAction = 2; + } } void bullet_bill_act_2(void) { - if (o->oTimer < 40) + if (o->oTimer < 40) { o->oForwardVel = 3.0f; - else if (o->oTimer < 50) { - if (o->oTimer % 2) + } else if (o->oTimer < 50) { + if (o->oTimer % 2) { o->oForwardVel = 3.0f; - else + } else { o->oForwardVel = -3.0f; + } } else { - if (o->oTimer > 70) + if (o->oTimer > 70) { cur_obj_update_floor_and_walls(); + } + spawn_object(o, MODEL_SMOKE, bhvWhitePuffSmoke); o->oForwardVel = 30.0f; - if (o->oDistanceToMario > 300.0f) + + if (o->oDistanceToMario > 300.0f) { cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x100); + } + if (o->oTimer == 50) { cur_obj_play_sound_2(SOUND_OBJ_POUNDING_CANNON); cur_obj_shake_screen(SHAKE_POS_SMALL); } + if (o->oTimer > 150 || o->oMoveFlags & OBJ_MOVE_HIT_WALL) { o->oAction = 3; spawn_mist_particles(); @@ -61,18 +68,27 @@ void bullet_bill_act_4(void) { o->oForwardVel = -30.0f; cur_obj_become_intangible(); } + o->oFaceAnglePitch += 0x1000; o->oFaceAngleRoll += 0x1000; o->oPosY += 20.0f; - if (o->oTimer > 90) + + if (o->oTimer > 90) { o->oAction = 0; + } } -void (*sBulletBillActions[])(void) = { bullet_bill_act_0, bullet_bill_act_1, bullet_bill_act_2, - bullet_bill_act_3, bullet_bill_act_4 }; +void (*sBulletBillActions[])(void) = { + bullet_bill_act_0, + bullet_bill_act_1, + bullet_bill_act_2, + bullet_bill_act_3, + bullet_bill_act_4, +}; void bhv_bullet_bill_loop(void) { cur_obj_call_action_function(sBulletBillActions); - if (cur_obj_check_interacted()) + if (cur_obj_check_interacted()) { o->oAction = 4; + } } diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c index 21c561a7..85340bc1 100644 --- a/src/game/behaviors/bully.inc.c +++ b/src/game/behaviors/bully.inc.c @@ -1,4 +1,4 @@ -// bully.c.inc +// bully.inc.c static struct ObjectHitbox sSmallBullyHitbox = { /* interactType: */ INTERACT_BULLY, @@ -57,14 +57,15 @@ void bully_check_mario_collision(void) { o->oAction != BULLY_ACT_LAVA_DEATH && o->oAction != BULLY_ACT_DEATH_PLANE_DEATH && #endif o->oInteractStatus & INT_STATUS_INTERACTED) { - if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) + if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) { cur_obj_play_sound_2(SOUND_OBJ2_BULLY_ATTACKED); - else + } else { cur_obj_play_sound_2(SOUND_OBJ2_LARGE_BULLY_ATTACKED); + } o->oInteractStatus &= ~INT_STATUS_INTERACTED; o->oAction = BULLY_ACT_KNOCKBACK; - o->oFlags &= ~0x8; /* bit 3 */ + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; cur_obj_init_animation(3); o->oBullyMarioCollisionAngle = o->oMoveAngleYaw; } @@ -77,15 +78,17 @@ void bully_act_chase_mario(void) { if (o->oTimer < 10) { o->oForwardVel = 3.0; - obj_turn_toward_object(o, gMarioObject, 16, 4096); + obj_turn_toward_object(o, gMarioObject, 16, 0x1000); } else if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) { o->oForwardVel = 20.0; - if (o->oTimer >= 31) + if (o->oTimer > 30) { o->oTimer = 0; + } } else { o->oForwardVel = 30.0; - if (o->oTimer >= 36) + if (o->oTimer > 35) { o->oTimer = 0; + } } if (!is_point_within_radius_of_mario(homeX, posY, homeZ, 1000)) { @@ -98,11 +101,12 @@ void bully_act_knockback(void) { if (o->oForwardVel < 10.0 && (s32) o->oVelY == 0) { o->oForwardVel = 1.0; o->oBullyKBTimerAndMinionKOCounter++; - o->oFlags |= 0x8; /* bit 3 */ + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oMoveAngleYaw = o->oFaceAngleYaw; - obj_turn_toward_object(o, gMarioObject, 16, 1280); - } else + obj_turn_toward_object(o, gMarioObject, 16, 0x500); + } else { o->header.gfx.animInfo.animFrame = 0; + } if (o->oBullyKBTimerAndMinionKOCounter == 18) { o->oAction = BULLY_ACT_CHASE_MARIO; @@ -113,7 +117,7 @@ void bully_act_knockback(void) { void bully_act_back_up(void) { if (o->oTimer == 0) { - o->oFlags &= ~0x8; /* bit 3 */ + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oMoveAngleYaw += 0x8000; } @@ -128,14 +132,13 @@ void bully_act_back_up(void) { if (o->oTimer == 15) { o->oMoveAngleYaw = o->oFaceAngleYaw; - o->oFlags |= 0x8; /* bit 3 */ + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oAction = BULLY_ACT_PATROL; } } void bully_backup_check(s16 collisionFlags) { - if (!(collisionFlags & 0x8) && o->oAction != BULLY_ACT_KNOCKBACK) /* bit 3 */ - { + if (!(collisionFlags & OBJ_COL_FLAG_NO_Y_VEL) && o->oAction != BULLY_ACT_KNOCKBACK) { o->oPosX = o->oBullyPrevX; o->oPosZ = o->oBullyPrevZ; o->oAction = BULLY_ACT_BACK_UP; @@ -143,24 +146,27 @@ void bully_backup_check(s16 collisionFlags) { } void bully_play_stomping_sound(void) { - s16 sp26 = o->header.gfx.animInfo.animFrame; + s16 animFrame = o->header.gfx.animInfo.animFrame; + switch (o->oAction) { case BULLY_ACT_PATROL: - if (sp26 == 0 || sp26 == 12) { - if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) + if (animFrame == 0 || animFrame == 12) { + if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) { cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALK); - else + } else { cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALKING); + } } break; case BULLY_ACT_CHASE_MARIO: case BULLY_ACT_BACK_UP: - if (sp26 == 0 || sp26 == 5) { - if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) + if (animFrame == 0 || animFrame == 5) { + if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) { cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALK); - else + } else { cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALKING); + } } break; } @@ -168,26 +174,24 @@ void bully_play_stomping_sound(void) { void bully_step(void) { s16 collisionFlags = 0; + collisionFlags = object_step(); bully_backup_check(collisionFlags); bully_play_stomping_sound(); obj_check_floor_death(collisionFlags, sObjFloor); if (o->oBullySubtype & BULLY_STYPE_CHILL) { - if (o->oPosY < 1030.0f) + if (o->oPosY < 1030.0f) { o->oAction = BULLY_ACT_LAVA_DEATH; + } } } void bully_spawn_coin(void) { struct Object *coin = spawn_object(o, MODEL_YELLOW_COIN, bhvMovingYellowCoin); -#ifdef VERSION_JP // TODO: maybe move this ifdef logic to the header? + cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT); -#elif defined(VERSION_EU) || defined(VERSION_SH) - cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_EU); -#else - cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_2); -#endif + coin->oForwardVel = 10.0f; coin->oVelY = 100.0f; coin->oPosY = o->oPosY + 310.0f; @@ -195,20 +199,21 @@ void bully_spawn_coin(void) { } void bully_act_level_death(void) { - if (obj_lava_death() == 1) { + if (obj_lava_death() == TRUE) { if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) { - if (o->oBullySubtype == BULLY_STYPE_MINION) + if (o->oBullySubtype == BULLY_STYPE_MINION) { o->parentObj->oBullyKBTimerAndMinionKOCounter++; + } bully_spawn_coin(); } else { spawn_mist_particles(); - if (o->oBullySubtype == BULLY_STYPE_CHILL) + if (o->oBullySubtype == BULLY_STYPE_CHILL) { spawn_default_star(130.0f, 1600.0f, -4335.0f); - else { + } else { spawn_default_star(0, 950.0f, -6800.0f); - spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvLllTumblingBridge, 0, 154, -5631, 0, 0, - 0); + spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvLllTumblingBridge, + 0, 154, -5631, 0, 0, 0); } } } @@ -229,7 +234,7 @@ void bhv_bully_loop(void) { case BULLY_ACT_PATROL: o->oForwardVel = 5.0; - if (obj_return_home_if_safe(o, o->oHomeX, o->oPosY, o->oHomeZ, 800) == 1) { + if (obj_return_home_if_safe(o, o->oHomeX, o->oPosY, o->oHomeZ, 800) == TRUE) { o->oAction = BULLY_ACT_CHASE_MARIO; cur_obj_init_animation(1); } @@ -264,14 +269,9 @@ void bhv_bully_loop(void) { set_object_visibility(o, 3000); } -// sp38 = arg0 -// sp3c = arg1 -// sp40 = arg2 -// sp44 = arg3 - -void big_bully_spawn_minion(s32 arg0, s32 arg1, s32 arg2, s16 arg3) { +void big_bully_spawn_minion(s32 x, s32 y, s32 z, s16 yaw) { struct Object *bully = - spawn_object_abs_with_rot(o, 0, MODEL_BULLY, bhvSmallBully, arg0, arg1, arg2, 0, arg3, 00); + spawn_object_abs_with_rot(o, 0, MODEL_BULLY, bhvSmallBully, x, y, z, 0, yaw, 0); bully->oBullySubtype = BULLY_STYPE_MINION; bully->oBehParams2ndByte = BULLY_BP_SIZE_SMALL; } @@ -289,7 +289,7 @@ void bhv_big_bully_with_minions_init(void) { } void big_bully_spawn_star(void) { - if (obj_lava_death() == 1) { + if (obj_lava_death() == TRUE) { spawn_mist_particles(); spawn_default_star(3700.0f, 600.0f, -5500.0f); } @@ -308,7 +308,7 @@ void bhv_big_bully_with_minions_loop(void) { case BULLY_ACT_PATROL: o->oForwardVel = 5.0; - if (obj_return_home_if_safe(o, o->oHomeX, o->oPosY, o->oHomeZ, 1000) == 1) { + if (obj_return_home_if_safe(o, o->oHomeX, o->oPosY, o->oHomeZ, 1000) == TRUE) { o->oAction = BULLY_ACT_CHASE_MARIO; cur_obj_init_animation(1); } @@ -339,17 +339,19 @@ void bhv_big_bully_with_minions_loop(void) { if (o->oBullyKBTimerAndMinionKOCounter == 3) { play_puzzle_jingle(); - if (o->oTimer >= 91) + if (o->oTimer > 90) { o->oAction = BULLY_ACT_ACTIVATE_AND_FALL; + } } break; case BULLY_ACT_ACTIVATE_AND_FALL: collisionFlags = object_step(); - if ((collisionFlags & 0x9) == 0x9) /* bits 0 and 3 */ + if ((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAGS_LANDED) { o->oAction = BULLY_ACT_PATROL; + } - if (collisionFlags == 1) { + if (collisionFlags == OBJ_COL_FLAG_GROUNDED) { cur_obj_play_sound_2(SOUND_OBJ_THWOMP); set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ); spawn_mist_particles(); diff --git a/src/game/behaviors/butterfly.inc.c b/src/game/behaviors/butterfly.inc.c index 2b530d81..7e9563b8 100644 --- a/src/game/behaviors/butterfly.inc.c +++ b/src/game/behaviors/butterfly.inc.c @@ -1,4 +1,4 @@ -// butterfly.c.inc +// butterfly.inc.c void bhv_butterfly_init(void) { cur_obj_init_animation(1); @@ -10,8 +10,6 @@ void bhv_butterfly_init(void) { o->oHomeZ = o->oPosZ; } -// sp28 = speed - void butterfly_step(s32 speed) { struct FloorGeometry *sp24; s16 yaw = o->oMoveAngleYaw; @@ -26,19 +24,22 @@ void butterfly_step(s32 speed) { o->oPosX += o->oVelX; o->oPosZ += o->oVelZ; - if (o->oAction == BUTTERFLY_ACT_FOLLOW_MARIO) + if (o->oAction == BUTTERFLY_ACT_FOLLOW_MARIO) { o->oPosY -= o->oVelY + coss((s32)(yPhase * 655.36)) * 20.0f / 4; - else + } else { o->oPosY -= o->oVelY; + } floorY = find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp24); - if (o->oPosY < floorY + 2.0f) + if (o->oPosY < floorY + 2.0f) { o->oPosY = floorY + 2.0f; + } o->oButterflyYPhase++; - if (o->oButterflyYPhase >= 101) + if (o->oButterflyYPhase > 100) { o->oButterflyYPhase = 0; + } } void butterfly_calculate_angle(void) { @@ -67,8 +68,9 @@ void butterfly_act_follow_mario(void) { butterfly_step(7); - if (!is_point_within_radius_of_mario(o->oHomeX, o->oHomeY, o->oHomeZ, 1200)) + if (!is_point_within_radius_of_mario(o->oHomeX, o->oHomeY, o->oHomeZ, 1200)) { o->oAction = BUTTERFLY_ACT_RETURN_HOME; + } } void butterfly_act_return_home(void) { diff --git a/src/game/behaviors/camera_lakitu.inc.c b/src/game/behaviors/camera_lakitu.inc.c index 2b66cff3..b3371198 100644 --- a/src/game/behaviors/camera_lakitu.inc.c +++ b/src/game/behaviors/camera_lakitu.inc.c @@ -28,13 +28,11 @@ void bhv_camera_lakitu_init(void) { static void camera_lakitu_intro_act_trigger_cutscene(void) { //! These bounds are slightly smaller than the actual bridge bounds, allowing // the RTA speedrunning method of lakitu skip - if (gMarioObject->oPosX > -544.0f && gMarioObject->oPosX < 545.0f && gMarioObject->oPosY > 800.0f - && gMarioObject->oPosZ > -2000.0f && gMarioObject->oPosZ < -177.0f - && gMarioObject->oPosZ < -177.0f) // always double check your conditions - { - if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_START) { - o->oAction = CAMERA_LAKITU_INTRO_ACT_SPAWN_CLOUD; - } + if (gMarioObject->oPosX > -544.0f && gMarioObject->oPosX < 545.0f + && gMarioObject->oPosY > 800.0f && gMarioObject->oPosZ > -2000.0f + && gMarioObject->oPosZ < -177.0f && gMarioObject->oPosZ < -177.0f // always double check your conditions + && set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_START) { + o->oAction = CAMERA_LAKITU_INTRO_ACT_SPAWN_CLOUD; } } @@ -108,7 +106,6 @@ static void camera_lakitu_intro_act_show_dialog(void) { o->oCameraLakituUnk104 = TRUE; } #endif - // Once within 1000 units, slow down approach_f32_ptr(&o->oCameraLakituSpeed, 20.0f, 1.0f); if (o->oDistanceToMario < 500.0f @@ -125,10 +122,10 @@ static void camera_lakitu_intro_act_show_dialog(void) { } } - o->oCameraLakituPitchVel = approach_s16_symmetric(o->oCameraLakituPitchVel, 0x7D0, 0x190); + o->oCameraLakituPitchVel = approach_s16_symmetric(o->oCameraLakituPitchVel, 2000, 400); obj_move_pitch_approach(targetMovePitch, o->oCameraLakituPitchVel); - o->oCameraLakituYawVel = approach_s16_symmetric(o->oCameraLakituYawVel, 0x7D0, 0x64); + o->oCameraLakituYawVel = approach_s16_symmetric(o->oCameraLakituYawVel, 2000, 100); cur_obj_rotate_yaw_toward(targetMoveYaw, o->oCameraLakituYawVel); // vel y is explicitly computed, so gravity doesn't apply @@ -156,7 +153,8 @@ void bhv_camera_lakitu_update(void) { break; } } else { - f32 val0C = (f32) 0x875C3D / 0x800 - gLakituState.curPos[0]; + f32 val0C = 4331.53f - gLakituState.curPos[0]; + if (gLakituState.curPos[0] < 1700.0f || val0C < 0.0f) { cur_obj_hide(); } else { @@ -173,7 +171,7 @@ void bhv_camera_lakitu_update(void) { o->oFaceAnglePitch = atan2s(cur_obj_lateral_dist_to_home(), o->oPosY - gLakituState.curFocus[1]); - o->oPosX = (f32) 0x875C3D / 0x800 + val0C; + o->oPosX = 4331.53f + val0C; } } } diff --git a/src/game/behaviors/cannon.inc.c b/src/game/behaviors/cannon.inc.c index 6a18f18d..2b0dac0d 100644 --- a/src/game/behaviors/cannon.inc.c +++ b/src/game/behaviors/cannon.inc.c @@ -1,4 +1,4 @@ -// cannon.c.inc +// cannon.inc.c void bhv_cannon_base_unused_loop(void) { o->oPosY += o->oVelY; @@ -17,18 +17,18 @@ void opened_cannon_act_0(void) { cur_obj_enable_rendering(); cur_obj_become_tangible(); } + if (o->oDistanceToMario < 500.0f) { cur_obj_become_tangible(); cur_obj_enable_rendering(); if (o->oInteractStatus & INT_STATUS_INTERACTED - && (!(o->oInteractStatus - & INT_STATUS_TOUCHED_BOB_OMB))) // bob-omb explodes when it gets into a cannon - { + && !(o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB)) { // bob-omb explodes when it gets into a cannon o->oAction = 4; o->oCannonUnk10C = 1; o->oCannonUnkF8 = 1; - } else + } else { o->oInteractStatus = 0; + } } else { cur_obj_become_intangible(); cur_obj_disable_rendering(); @@ -37,11 +37,14 @@ void opened_cannon_act_0(void) { } void opened_cannon_act_4(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_OBJ_CANNON1); + } + o->oPosY += 5.0f; o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 2; o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 2; + if (o->oTimer > 67) { o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 4; o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 4; @@ -50,8 +53,10 @@ void opened_cannon_act_4(void) { } void opened_cannon_act_6(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_OBJ_CANNON2); + } + if (o->oTimer < 4) { o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 4.0f; o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 4.0f; @@ -72,25 +77,30 @@ void opened_cannon_act_6(void) { } void opened_cannon_act_5(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_OBJ_CANNON3); + } + if (o->oTimer < 4) { } else { if (o->oTimer < 20) { o->oCannonUnkF4 += 0x400; o->oMoveAnglePitch = sins(o->oCannonUnkF4) * 0x2000; } else if (o->oTimer < 25) { - } else + } else { o->oAction = 1; + } } } void opened_cannon_act_1(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; + cur_obj_become_intangible(); cur_obj_disable_rendering(); + o->oCannonUnk10C = 0; - gMarioShotFromCannon = 1; + gMarioShotFromCannon = TRUE; } void opened_cannon_act_2(void) { @@ -98,29 +108,41 @@ void opened_cannon_act_2(void) { } void opened_cannon_act_3(void) { - UNUSED s32 unused; - if (o->oTimer > 3) + UNUSED u8 filler[4]; + if (o->oTimer > 3) { o->oAction = 0; + } } -void (*sOpenedCannonActions[])(void) = { opened_cannon_act_0, opened_cannon_act_1, opened_cannon_act_2, - opened_cannon_act_3, opened_cannon_act_4, opened_cannon_act_5, - opened_cannon_act_6 }; +void (*sOpenedCannonActions[])(void) = { + opened_cannon_act_0, + opened_cannon_act_1, + opened_cannon_act_2, + opened_cannon_act_3, + opened_cannon_act_4, + opened_cannon_act_5, + opened_cannon_act_6, +}; void bhv_cannon_base_loop(void) { cur_obj_call_action_function(sOpenedCannonActions); - if (o->oCannonUnkF8) + + if (o->oCannonUnkF8) { o->oCannonUnkF8++; + } + o->oInteractStatus = 0; } void bhv_cannon_barrel_loop(void) { struct Object *parent = o->parentObj; + if (parent->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) { cur_obj_enable_rendering(); obj_copy_pos(o, o->parentObj); o->oMoveAngleYaw = o->parentObj->oMoveAngleYaw; o->oFaceAnglePitch = o->parentObj->oMoveAnglePitch; - } else + } else { cur_obj_disable_rendering(); + } } diff --git a/src/game/behaviors/cannon_door.inc.c b/src/game/behaviors/cannon_door.inc.c index cb710322..52ab3e86 100644 --- a/src/game/behaviors/cannon_door.inc.c +++ b/src/game/behaviors/cannon_door.inc.c @@ -1,11 +1,10 @@ -// cannon.c.inc +// cannon.inc.c void bhv_cannon_closed_init(void) { - struct Object *cannon; - - if (save_file_is_cannon_unlocked() == 1) { + if (save_file_is_cannon_unlocked() == TRUE) { // If the cannon is open, spawn a cannon and despawn the object. - cannon = spawn_object(o, MODEL_CANNON_BASE, bhvCannon); + struct Object *cannon = spawn_object(o, MODEL_CANNON_BASE, bhvCannon); + cannon->oBehParams2ndByte = o->oBehParams2ndByte; cannon->oPosX = o->oHomeX; cannon->oPosY = o->oHomeY; @@ -17,13 +16,14 @@ void bhv_cannon_closed_init(void) { } void cannon_door_act_opening(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_CANNON_UP); + } if (o->oTimer < 30) { o->oVelY = -0.5f; o->oPosY += o->oVelY; - o->oVelX = 0; + o->oVelX = 0.0f; } else { if (o->oTimer == 80) { bhv_cannon_closed_init(); @@ -31,7 +31,7 @@ void cannon_door_act_opening(void) { } o->oVelX = 4.0f; - o->oVelY = 0; + o->oVelY = 0.0f; o->oPosX += o->oVelX; } } @@ -39,18 +39,19 @@ void cannon_door_act_opening(void) { void bhv_cannon_closed_loop(void) { switch (o->oAction) { case CANNON_TRAP_DOOR_ACT_CLOSED: - o->oVelX = 0; - o->oVelY = 0; + o->oVelX = 0.0f; + o->oVelY = 0.0f; o->oDrawingDistance = 4000.0f; - if (save_file_is_cannon_unlocked() == 1) + if (save_file_is_cannon_unlocked() == TRUE) { o->oAction = CANNON_TRAP_DOOR_ACT_CAM_ZOOM; + } break; case CANNON_TRAP_DOOR_ACT_CAM_ZOOM: - if (o->oTimer == 60) + if (o->oTimer == 60) { o->oAction = CANNON_TRAP_DOOR_ACT_OPENING; - + } o->oDrawingDistance = 20000.0f; break; diff --git a/src/game/behaviors/cap.inc.c b/src/game/behaviors/cap.inc.c index 066ff1fb..2aacb145 100644 --- a/src/game/behaviors/cap.inc.c +++ b/src/game/behaviors/cap.inc.c @@ -1,4 +1,4 @@ -// cap.c.inc +// cap.inc.c static struct ObjectHitbox sCapHitbox = { /* interactType: */ INTERACT_CAP, @@ -14,13 +14,14 @@ static struct ObjectHitbox sCapHitbox = { s32 cap_set_hitbox(void) { obj_set_hitbox(o, &sCapHitbox); + if (o->oInteractStatus & INT_STATUS_INTERACTED) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oInteractStatus = 0; - return 1; + return TRUE; } - return 0; + return FALSE; } void cap_despawn(void) { @@ -30,8 +31,9 @@ void cap_despawn(void) { } void cap_check_quicksand(void) { - if (sObjFloor == NULL) + if (sObjFloor == NULL) { return; + } switch (sObjFloor->type) { case SURFACE_DEATH_PLANE: @@ -76,24 +78,24 @@ void cap_sink_quicksand(void) { break; case 11: - if (o->oTimer < 10) + if (o->oTimer < 10) { o->oGraphYOffset += -3.0f; - + } o->oFaceAnglePitch = 0x2000; break; case 12: o->oGraphYOffset += -1.0f; - if (o->oTimer >= 21) + if (o->oTimer > 20) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; - + } break; case 13: o->oGraphYOffset += -6.0f; - if (o->oTimer >= 21) + if (o->oTimer > 20) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; - + } o->oFaceAnglePitch = 0x2000; break; } @@ -118,11 +120,12 @@ void cap_scale_vertically(void) { } void wing_vanish_cap_act_0(void) { - s16 sp1E; + s16 collisionFlags; o->oFaceAngleYaw += o->oForwardVel * 128.0f; - sp1E = object_step(); - if (sp1E & 0x01) { + collisionFlags = object_step(); + + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { cap_check_quicksand(); if (o->oVelY != 0.0f) { o->oCapUnkF4 = 1; @@ -130,8 +133,9 @@ void wing_vanish_cap_act_0(void) { } } - if (o->oCapUnkF4 == 1) + if (o->oCapUnkF4 == 1) { cap_scale_vertically(); + } } void bhv_wing_vanish_cap_loop(void) { @@ -146,8 +150,9 @@ void bhv_wing_vanish_cap_loop(void) { break; } - if (o->oTimer > 20) + if (o->oTimer > 20) { cur_obj_become_tangible(); + } cap_despawn(); cap_set_hitbox(); @@ -157,16 +162,18 @@ void bhv_metal_cap_init(void) { o->oGravity = 2.4f; o->oFriction = 0.999f; o->oBuoyancy = 1.5f; - o->oOpacity = 0xFF; + o->oOpacity = 255; } void metal_cap_act_0(void) { - s16 sp1E; + s16 collisionFlags; o->oFaceAngleYaw += o->oForwardVel * 128.0f; - sp1E = object_step(); - if (sp1E & 0x01) + collisionFlags = object_step(); + + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { cap_check_quicksand(); + } } void bhv_metal_cap_loop(void) { @@ -181,8 +188,9 @@ void bhv_metal_cap_loop(void) { break; } - if (o->oTimer > 20) + if (o->oTimer > 20) { cur_obj_become_tangible(); + } cap_set_hitbox(); cap_despawn(); @@ -192,7 +200,7 @@ void bhv_normal_cap_init(void) { o->oGravity = 0.7f; o->oFriction = 0.89f; o->oBuoyancy = 0.9f; - o->oOpacity = 0xFF; + o->oOpacity = 255; save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ); } @@ -220,12 +228,13 @@ void normal_cap_set_save_flags(void) { } void normal_cap_act_0(void) { - s16 sp1E; + s16 collisionFlags; o->oFaceAngleYaw += o->oForwardVel * 128.0f; o->oFaceAnglePitch += o->oForwardVel * 80.0f; - sp1E = object_step(); - if (sp1E & 0x01) { + collisionFlags = object_step(); + + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { cap_check_quicksand(); if (o->oVelY != 0.0f) { @@ -235,8 +244,9 @@ void normal_cap_act_0(void) { } } - if (o->oCapUnkF4 == 1) + if (o->oCapUnkF4 == 1) { cap_scale_vertically(); + } } void bhv_normal_cap_loop(void) { @@ -251,14 +261,17 @@ void bhv_normal_cap_loop(void) { break; } - if ((s32) o->oForwardVel != 0) + if ((s32) o->oForwardVel != 0) { save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ); + } - if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) + if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) { normal_cap_set_save_flags(); + } - if (cap_set_hitbox() == 1) + if (cap_set_hitbox() == TRUE) { save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND); + } } void bhv_vanish_cap_init(void) { diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index 4aa69dbc..aecde91d 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -1,4 +1,4 @@ -// capswitch.c.inc +// capswitch.inc.c UNUSED u8 sCapSwitchText[] = { DIALOG_010, DIALOG_011, DIALOG_012 }; @@ -6,15 +6,19 @@ void cap_switch_act_0(void) { o->oAnimState = o->oBehParams2ndByte; cur_obj_scale(0.5f); o->oPosY += 71.0f; + spawn_object_relative_with_scale(0, 0, -71, 0, 0.5f, o, MODEL_CAP_SWITCH_BASE, bhvCapSwitchBase); + if (gCurrLevelNum != LEVEL_UNKNOWN_32) { if (save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte]) { o->oAction = 3; o->header.gfx.scale[1] = 0.1f; - } else + } else { o->oAction = 1; - } else + } + } else { o->oAction = 1; + } } void cap_switch_act_1(void) { @@ -26,7 +30,6 @@ void cap_switch_act_1(void) { } void cap_switch_act_2(void) { - s32 sp1C; if (o->oTimer < 5) { cur_obj_scale_over_time(2, 4, 0.5f, 0.1f); if (o->oTimer == 4) { @@ -41,18 +44,24 @@ void cap_switch_act_2(void) { //! Neither of these flags are defined in this function so they do nothing. // On an extra note, there's a specific check for this cutscene and // there's no dialog defined since the cutscene itself calls the dialog. - sp1C = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_FRONT, + s32 dialogResponse = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_FRONT, (DIALOG_FLAG_TEXT_RESPONSE | DIALOG_FLAG_UNK_CAPSWITCH), CUTSCENE_CAP_SWITCH_PRESS, 0); - if (sp1C) + if (dialogResponse) { o->oAction = 3; + } } } +// dead function void cap_switch_act_3(void) { -} // dead function +} -void (*sCapSwitchActions[])(void) = { cap_switch_act_0, cap_switch_act_1, - cap_switch_act_2, cap_switch_act_3 }; +void (*sCapSwitchActions[])(void) = { + cap_switch_act_0, + cap_switch_act_1, + cap_switch_act_2, + cap_switch_act_3, +}; void bhv_cap_switch_loop(void) { cur_obj_call_action_function(sCapSwitchActions); diff --git a/src/game/behaviors/castle_floor_trap.inc.c b/src/game/behaviors/castle_floor_trap.inc.c index 4bceb9e4..ee91a020 100644 --- a/src/game/behaviors/castle_floor_trap.inc.c +++ b/src/game/behaviors/castle_floor_trap.inc.c @@ -1,8 +1,9 @@ -// castle_floor_trap.c.inc +// castle_floor_trap.inc.c void bhv_floor_trap_in_castle_loop(void) { - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->parentObj->oInteractStatus |= INT_STATUS_TRAP_TURN; + } o->oFaceAngleRoll = o->parentObj->oFaceAngleRoll; } @@ -15,20 +16,24 @@ void bhv_castle_floor_trap_init(void) { void bhv_castle_floor_trap_open_detect(void) { if (gMarioStates[0].action == ACT_SPECIAL_EXIT_AIRBORNE - || gMarioStates[0].action == ACT_SPECIAL_DEATH_EXIT) + || gMarioStates[0].action == ACT_SPECIAL_DEATH_EXIT) { o->oAction = 4; // rotates trapdoor so it looks always open - else { + } else { o->oAngleVelRoll = 0x400; - if (o->oInteractStatus & INT_STATUS_TRAP_TURN) + if (o->oInteractStatus & INT_STATUS_TRAP_TURN) { o->oAction = 1; // detects interact then opens the trapdoor + } } } void bhv_castle_floor_trap_open(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_CASTLE_TRAP_OPEN); + } + o->oAngleVelRoll -= 0x100; o->oFaceAngleRoll += o->oAngleVelRoll; + if (o->oFaceAngleRoll < -0x4000) { o->oFaceAngleRoll = -0x4000; o->oAction = 2; // after opening is done, enable close detection @@ -36,12 +41,14 @@ void bhv_castle_floor_trap_open(void) { } void bhv_castle_floor_trap_close_detect(void) { - if (o->oDistanceToMario > 1000.0f) + if (o->oDistanceToMario > 1000.0f) { o->oAction = 3; // close trapdoor + } } void bhv_castle_floor_trap_close(void) { o->oFaceAngleRoll += 0x400; + if (o->oFaceAngleRoll > 0) { o->oFaceAngleRoll = 0; o->oAction = 0; // after closing, reloads open detection @@ -54,7 +61,8 @@ void bhv_castle_floor_trap_rotate(void) { } void bhv_castle_floor_trap_loop(void) { - UNUSED s32 unused[3]; + UNUSED u8 filler[12]; + switch (o->oAction) { case 0: bhv_castle_floor_trap_open_detect(); diff --git a/src/game/behaviors/celebration_star.inc.c b/src/game/behaviors/celebration_star.inc.c index 85f8964b..92cb866a 100644 --- a/src/game/behaviors/celebration_star.inc.c +++ b/src/game/behaviors/celebration_star.inc.c @@ -1,4 +1,4 @@ -// celebration_star.c.inc +// celebration_star.inc.c void bhv_celebration_star_init(void) { o->oHomeX = gMarioObject->header.gfx.pos[0]; @@ -10,7 +10,7 @@ void bhv_celebration_star_init(void) { if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2) { o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_BOWSER_KEY]; o->oFaceAnglePitch = 0; - o->oFaceAngleRoll = 49152; + o->oFaceAngleRoll = 0xC000; cur_obj_scale(0.1f); o->oCelebStarUnkF4 = 1; } else { @@ -35,17 +35,19 @@ void celeb_star_act_spin_around_mario(void) { o->oFaceAngleYaw += 0x1000; o->oMoveAngleYaw += 0x2000; - if (o->oTimer == 40) + if (o->oTimer == 40) { o->oAction = CELEB_STAR_ACT_FACE_CAMERA; + } + if (o->oTimer < 35) { spawn_object(o, MODEL_SPARKLES, bhvCelebrationStarSparkle); o->oCelebStarDiameterOfRotation++; - } else + } else { o->oCelebStarDiameterOfRotation -= 20; + } } void celeb_star_act_face_camera(void) { - if (o->oTimer < 10) { #if BUGFIX_STAR_BOWSER_KEY if (o->oCelebStarUnkF4 == 0) { @@ -61,8 +63,9 @@ void celeb_star_act_face_camera(void) { o->oFaceAngleYaw = gMarioObject->header.gfx.angle[1]; } - if (o->oTimer == 59) + if (o->oTimer == 59) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } void bhv_celebration_star_loop(void) { @@ -80,8 +83,9 @@ void bhv_celebration_star_loop(void) { void bhv_celebration_star_sparkle_loop(void) { o->oPosY -= 15.0f; - if (o->oTimer == 12) + if (o->oTimer == 12) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } void bhv_star_key_collection_puff_spawner_loop(void) { diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index 57afa831..54c136c9 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -13,15 +13,15 @@ * Hitbox for chain chomp. */ static struct ObjectHitbox sChainChompHitbox = { - /* interactType: */ INTERACT_MR_BLIZZARD, - /* downOffset: */ 0, + /* interactType: */ INTERACT_MR_BLIZZARD, + /* downOffset: */ 0, /* damageOrCoinValue: */ 3, - /* health: */ 1, - /* numLootCoins: */ 0, - /* radius: */ 80, - /* height: */ 160, - /* hurtboxRadius: */ 80, - /* hurtboxHeight: */ 160, + /* health: */ 1, + /* numLootCoins: */ 0, + /* radius: */ 80, + /* height: */ 160, + /* hurtboxRadius: */ 80, + /* hurtboxHeight: */ 160, }; /** @@ -190,7 +190,7 @@ static void chain_chomp_sub_act_turn(void) { o->oChainChompTargetPitch = obj_get_pitch_from_vel(); } } else { - o->oTimer -= 1; + o->oTimer--; } } else { o->oForwardVel = 0.0f; @@ -201,7 +201,7 @@ static void chain_chomp_sub_act_turn(void) { o->oVelY = 20.0f; } } else { - cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x190); + cur_obj_rotate_yaw_toward(o->oAngleToMario, 400); o->oTimer = 0; } } @@ -228,7 +228,7 @@ static void chain_chomp_sub_act_lunge(void) { } else { // Turn toward pivot cur_obj_rotate_yaw_toward(atan2s(o->oChainChompSegments[0].posZ, o->oChainChompSegments[0].posX), - 0x1000); + 0x1000); if (o->oChainChompUnk104 != 0.0f) { approach_f32_ptr(&o->oChainChompUnk104, 0.0f, 0.8f); @@ -274,9 +274,9 @@ static void chain_chomp_released_lunge_around(void) { if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { // Before first bounce, turn toward mario and wait 2 seconds if (o->oChainChompNumLunges == 0) { - if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x320)) { + if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 800)) { if (o->oTimer > 60) { - o->oChainChompNumLunges += 1; + o->oChainChompNumLunges++; // enable wall collision o->oWallHitboxRadius = 200.0f; } @@ -434,7 +434,7 @@ static void chain_chomp_act_move(void) { chain_chomp_update_chain_segments(); // Begin a lunge if mario tries to attack - if (obj_check_attacks(&sChainChompHitbox, o->oAction)) { + if (obj_check_attacks(&sChainChompHitbox, o->oAction) != 0) { o->oSubAction = CHAIN_CHOMP_SUB_ACT_LUNGE; o->oChainChompMaxDistFromPivotPerChainPart = 900.0f / 5; o->oForwardVel = 0.0f; diff --git a/src/game/behaviors/checkerboard_platform.inc.c b/src/game/behaviors/checkerboard_platform.inc.c index 30235a03..bfba5f0a 100644 --- a/src/game/behaviors/checkerboard_platform.inc.c +++ b/src/game/behaviors/checkerboard_platform.inc.c @@ -1,7 +1,15 @@ -// checkerboard_platform.c.inc +// checkerboard_platform.inc.c -struct Struct8032F754 D_8032F754[] = { { 145, { 0.7f, 1.5f, 0.7f }, 7.0f }, - { 235, { 1.2f, 2.0f, 1.2f }, 11.6f } }; +struct Struct8032F754 { + s32 unk0; + Vec3f unk1; + f32 unk2; +}; + +struct Struct8032F754 D_8032F754[] = { + { 145, { 0.7f, 1.5f, 0.7f }, 7.0f }, + { 235, { 1.2f, 2.0f, 1.2f }, 11.6f }, +}; void bhv_checkerboard_elevator_group_init(void) { s32 sp3C; @@ -9,15 +17,20 @@ void bhv_checkerboard_elevator_group_init(void) { s32 sp34; s32 i; struct Object *sp2C; - if (o->oBehParams2ndByte == 0) + + if (o->oBehParams2ndByte == 0) { o->oBehParams2ndByte = 65; + } + sp3C = o->oBehParams2ndByte * 10; - sp34 = (o->oBehParams >> 24) & 0XFF; + sp34 = (o->oBehParams >> 24) & 0xFF; + for (i = 0; i < 2; i++) { - if (i == 0) + if (i == 0) { sp38 = -D_8032F754[sp34].unk0; - else + } else { sp38 = D_8032F754[sp34].unk0; + } sp2C = spawn_object_relative(i, 0, i * sp3C, sp38, o, MODEL_CHECKERBOARD_PLATFORM, bhvCheckerboardPlatformSub); @@ -31,15 +44,17 @@ void checkerboard_plat_act_move_y(UNUSED s32 unused, f32 vel, s32 a2) { o->oAngleVelPitch = 0; o->oForwardVel = 0.0f; o->oVelY = vel; - if (o->oTimer > a2) + if (o->oTimer > a2) { o->oAction++; + } } void checkerboard_plat_act_rotate(s32 a0, s16 a1) { o->oVelY = 0.0f; o->oAngleVelPitch = a1; - if (o->oTimer + 1 == 0x8000 / absi(a1)) + if (o->oTimer + 1 == 0x8000 / absi(a1)) { o->oAction = a0; + } o->oCheckerBoardPlatformUnkF8 = a0; } @@ -49,15 +64,20 @@ void bhv_checkerboard_platform_init(void) { void bhv_checkerboard_platform_loop(void) { f32 sp24 = o->oCheckerBoardPlatformUnk1AC; + o->oCheckerBoardPlatformUnkF8 = 0; - if (o->oDistanceToMario < 1000.0f) + + if (o->oDistanceToMario < 1000.0f) { cur_obj_play_sound_1(SOUND_ENV_ELEVATOR4); + } + switch (o->oAction) { case 0: - if (o->oBehParams2ndByte == 0) + if (o->oBehParams2ndByte == 0) { o->oAction = 1; - else + } else { o->oAction = 3; + } break; case 1: checkerboard_plat_act_move_y(2, 10.0f, o->oCheckerBoardPlatformUnkFC); @@ -72,18 +92,23 @@ void bhv_checkerboard_platform_loop(void) { checkerboard_plat_act_rotate(1, -512); break; } + o->oMoveAnglePitch += absi(o->oAngleVelPitch); o->oFaceAnglePitch += absi(o->oAngleVelPitch); o->oFaceAngleYaw = o->oMoveAngleYaw; + if (o->oMoveAnglePitch != 0) { o->oForwardVel = signum_positive(o->oAngleVelPitch) * sins(o->oMoveAnglePitch) * sp24; o->oVelY = signum_positive(o->oAngleVelPitch) * coss(o->oMoveAnglePitch) * sp24; } + if (o->oCheckerBoardPlatformUnkF8 == 1) { o->oAngleVelPitch = 0; o->oFaceAnglePitch &= ~0x7FFF; cur_obj_move_using_fvel_and_gravity(); - } else + } else { cur_obj_move_using_fvel_and_gravity(); + } + load_object_collision_model(); } diff --git a/src/game/behaviors/chuckya.inc.c b/src/game/behaviors/chuckya.inc.c index e74fe9c1..6cc87f42 100644 --- a/src/game/behaviors/chuckya.inc.c +++ b/src/game/behaviors/chuckya.inc.c @@ -1,4 +1,4 @@ -// chuckya.c.inc +// chuckya.inc.c struct UnusedChuckyaData { u8 unk0; @@ -6,79 +6,97 @@ struct UnusedChuckyaData { f32 unk8; }; -struct UnusedChuckyaData sUnusedChuckyaData[] = { { 2, 0.f, 1.f }, - { 2, 10.f, 1.f }, - { 2, 20.f, 1.f }, - { 2, 20.f, 1.f }, - { 8, 10.f, 1.f }}; +struct UnusedChuckyaData sUnusedChuckyaData[] = { + { 2, 0.f, 1.f }, + { 2, 10.f, 1.f }, + { 2, 20.f, 1.f }, + { 2, 20.f, 1.f }, + { 8, 10.f, 1.f }, +}; void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) { switch (o->parentObj->oChuckyaUnk88) { case 0: break; + case 1: obj_set_gfx_pos_at_obj_pos(gMarioObject, o); break; + case 2: - gMarioObject->oInteractStatus |= (sp30 + INT_STATUS_MARIO_UNK2); + gMarioObject->oInteractStatus |= (INT_STATUS_MARIO_UNK2 + sp30); gMarioStates[0].forwardVel = sp28; gMarioStates[0].vel[1] = sp2C; o->parentObj->oChuckyaUnk88 = 0; break; + case 3: - gMarioObject->oInteractStatus |= - (INT_STATUS_MARIO_UNK2 + INT_STATUS_MARIO_UNK6); // loads 2 interactions at once? + gMarioObject->oInteractStatus |= (INT_STATUS_MARIO_UNK2 | INT_STATUS_MARIO_UNK6); gMarioStates[0].forwardVel = 10.0f; gMarioStates[0].vel[1] = 10.0f; o->parentObj->oChuckyaUnk88 = 0; break; } + o->oMoveAngleYaw = o->parentObj->oMoveAngleYaw; - if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { obj_mark_for_deletion(o); + } } void bhv_chuckya_anchor_mario_loop(void) { - common_anchor_mario_behavior(40.0f, 40.0f, 64); + common_anchor_mario_behavior(40.0f, 40.0f, INT_STATUS_MARIO_UNK6); } -s32 unknown_chuckya_function(s32 sp20, f32 sp24, f32 sp28, s32 sp2C) { +s32 unknown_chuckya_function(s32 sp20, f32 sp24, f32 sp28, s16 sp2C) { s32 sp1C = 0; + if (o->oChuckyaUnkF8 != 4) { if (sp24 < cur_obj_lateral_dist_from_mario_to_home()) { - if (cur_obj_lateral_dist_to_home() < 200.0f) + if (cur_obj_lateral_dist_to_home() < 200.0f) { sp1C = 0; - else { + } else { sp1C = 1; o->oAngleToMario = cur_obj_angle_to_home(); } } else if (o->oDistanceToMario > sp28) { - if (gGlobalTimer % (s16) sp2C == 0) + if (gGlobalTimer % sp2C == 0) { o->oAngleToMario = obj_angle_to_object(o, gMarioObject); + } sp1C = 2; - } else + } else { sp1C = 3; + } + if (sp20 && update_angle_from_move_flags(&o->oAngleToMario)) { sp1C = 4; o->oChuckyaUnkF8 = 4; } - } else + } else { sp1C = 4; + } + return sp1C; } -s32 approach_forward_vel(f32 *arr, f32 spC, f32 sp10) { +s32 approach_forward_vel(f32 *forwardVel, f32 spC, f32 sp10) { s32 sp4 = 0; - if (arr[0] > spC) { - arr[0] -= sp10; - if (arr[0] < spC) - arr[0] = spC; - } else if (arr[0] < spC) { - arr[0] += sp10; - if (arr[0] > spC) - arr[0] = spC; - } else + + if (*forwardVel > spC) { + *forwardVel -= sp10; + if (*forwardVel < spC) { + *forwardVel = spC; + } + } else if (*forwardVel < spC) { + *forwardVel += sp10; + if (*forwardVel > spC) { + *forwardVel = spC; + } + } else { sp4 = 1; + } + return sp4; } @@ -87,61 +105,81 @@ void chuckya_act_0(void) { #ifdef AVOID_UB sp3C = 0; #endif - UNUSED u8 pad[16]; + UNUSED u8 filler[16]; s32 sp28; - if (o->oTimer == 0) + + if (o->oTimer == 0) { o->oChuckyaUnkFC = 0; + } + o->oAngleToMario = obj_angle_to_object(o, gMarioObject); + switch (sp28 = o->oSubAction) { case 0: - o->oForwardVel = 0; + o->oForwardVel = 0.0f; if (cur_obj_lateral_dist_from_mario_to_home() < 2000.0f) { cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400); if (o->oChuckyaUnkFC > 40 - || abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) < 0x1000) + || abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) < 0x1000) { o->oSubAction = 1; - } else + } + } else { o->oSubAction = 3; + } break; + case 1: approach_forward_vel(&o->oForwardVel, 30.0f, 4.0f); - if (abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) > 0x4000) + if (abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) > 0x4000) { o->oSubAction = 2; - if (cur_obj_lateral_dist_from_mario_to_home() > 2000.0f) + } + if (cur_obj_lateral_dist_from_mario_to_home() > 2000.0f) { o->oSubAction = 3; + } break; + case 2: approach_forward_vel(&o->oForwardVel, 0, 4.0f); - if (o->oChuckyaUnkFC > 48) + if (o->oChuckyaUnkFC > 48) { o->oSubAction = 0; + } break; + case 3: - if (cur_obj_lateral_dist_to_home() < 500.0f) - o->oForwardVel = 0; - else { + if (cur_obj_lateral_dist_to_home() < 500.0f) { + o->oForwardVel = 0.0f; + } else { approach_forward_vel(&o->oForwardVel, 10.0f, 4.0f); o->oAngleToMario = cur_obj_angle_to_home(); cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x800); } - if (cur_obj_lateral_dist_from_mario_to_home() < 1900.0f) + if (cur_obj_lateral_dist_from_mario_to_home() < 1900.0f) { o->oSubAction = 0; + } break; } - if (o->oSubAction != sp28) + + if (o->oSubAction != sp28) { o->oChuckyaUnkFC = 0; - else + } else { o->oChuckyaUnkFC++; + } + cur_obj_init_animation_with_sound(4); - if (o->oForwardVel > 1.0f) + + if (o->oForwardVel > 1.0f) { cur_obj_play_sound_1(SOUND_AIR_CHUCKYA_MOVE); + } + print_debug_bottom_up("fg %d", sp3C); print_debug_bottom_up("sp %d", o->oForwardVel); } void chuckya_act_1(void) { if (o->oSubAction == 0) { - if (cur_obj_init_animation_and_check_if_near_end(0)) + if (cur_obj_init_animation_and_check_if_near_end(0)) { o->oSubAction++; + } o->oChuckyaUnkFC = random_float() * 30.0f + 10.0f; o->oChuckyaUnk100 = 0; o->oForwardVel = 0.0f; @@ -152,14 +190,14 @@ void chuckya_act_1(void) { if (o->oChuckyaUnk100 > 10) { o->oChuckyaUnk88 = 3; o->oAction = 3; - o->oInteractStatus &= ~(INT_STATUS_GRABBED_MARIO); + o->oInteractStatus &= ~INT_STATUS_GRABBED_MARIO; } else { cur_obj_init_animation_with_sound(1); o->oMoveAngleYaw += INT_STATUS_GRABBED_MARIO; - if (o->oChuckyaUnkFC-- < 0) - if (check_if_moving_over_floor(50.0f, 150.0f) || o->oChuckyaUnkFC < -16) { - o->oSubAction++; - } + if (o->oChuckyaUnkFC-- < 0 + && (check_if_moving_over_floor(50.0f, 150.0f) || o->oChuckyaUnkFC < -16)) { + o->oSubAction++; + } } } else { cur_obj_init_animation_with_sound(3); @@ -167,18 +205,19 @@ void chuckya_act_1(void) { cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN4); o->oChuckyaUnk88 = 2; o->oAction = 3; - o->oInteractStatus &= ~(INT_STATUS_GRABBED_MARIO); + o->oInteractStatus &= ~INT_STATUS_GRABBED_MARIO; } } } } void chuckya_act_3(void) { - o->oForwardVel = 0; - o->oVelY = 0; + o->oForwardVel = 0.0f; + o->oVelY = 0.0f; cur_obj_init_animation_with_sound(4); - if (o->oTimer > 100) + if (o->oTimer > 100) { o->oAction = 0; + } } void chuckya_act_2(void) { @@ -189,7 +228,12 @@ void chuckya_act_2(void) { } } -void (*sChuckyaActions[])(void) = { chuckya_act_0, chuckya_act_1, chuckya_act_2, chuckya_act_3 }; +void (*sChuckyaActions[])(void) = { + chuckya_act_0, + chuckya_act_1, + chuckya_act_2, + chuckya_act_3, +}; void chuckya_move(void) { cur_obj_update_floor_and_walls(); @@ -205,8 +249,10 @@ void chuckya_move(void) { void bhv_chuckya_loop(void) { f32 sp2C = 20.0f; f32 sp28 = 50.0f; + cur_obj_scale(2.0f); o->oInteractionSubtype |= INT_SUBTYPE_GRABS_MARIO; + switch (o->oHeldState) { case HELD_FREE: chuckya_move(); @@ -219,6 +265,8 @@ void bhv_chuckya_loop(void) { cur_obj_get_thrown_or_placed(sp2C, sp28, 2); break; } + o->oInteractStatus = 0; + print_debug_bottom_up("md %d", o->oAction); } diff --git a/src/game/behaviors/clam.inc.c b/src/game/behaviors/clam.inc.c index 36969800..5ee7b7eb 100644 --- a/src/game/behaviors/clam.inc.c +++ b/src/game/behaviors/clam.inc.c @@ -24,22 +24,20 @@ void clam_act_0(void) { cur_obj_play_sound_2(SOUND_GENERAL_CLAM_SHELL2); o->oAction = 1; } else if (o->oClamUnkF4 != 0) { - o->oClamUnkF4 -= 1; + o->oClamUnkF4--; cur_obj_shake_y(3.0f); } } void clam_act_1(void) { s16 val06; - s16 val04; - s16 val02; if (o->oTimer > 150) { o->oAction = 0; } else if (obj_is_rendering_enabled() && cur_obj_init_anim_check_frame(1, 8)) { for (val06 = -0x2000; val06 < 0x2000; val06 += 0x555) { - val04 = (s16)(100.0f * sins(val06)); - val02 = (s16)(100.0f * coss(val06)); + s16 val04 = (s16)(100.0f * sins(val06)); + s16 val02 = (s16)(100.0f * coss(val06)); spawn_object_relative(0, val04, 30, val02, o, MODEL_BUBBLE, bhvBubbleMaybe); } diff --git a/src/game/behaviors/clock_arm.inc.c b/src/game/behaviors/clock_arm.inc.c index 26ff8948..fbf8b931 100644 --- a/src/game/behaviors/clock_arm.inc.c +++ b/src/game/behaviors/clock_arm.inc.c @@ -1,9 +1,12 @@ +// clock_arm.inc.c + /** * Main loop of the hour and minute hands of the Tick Tock Clock painting. */ void bhv_rotating_clock_arm_loop(void) { struct Surface *marioSurface; u16 rollAngle = o->oFaceAngleRoll; + o->oFloorHeight = find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &marioSurface); @@ -12,9 +15,9 @@ void bhv_rotating_clock_arm_loop(void) { // Probably a safety check for when you leave the level through the painting // to make sure the setting isn't accidentally locked in as you fly out. if (o->oAction == 0) { - if (marioSurface->type == SURFACE_DEFAULT) - if (o->oTimer >= 4) - o->oAction++; + if (marioSurface->type == SURFACE_DEFAULT && o->oTimer >= 4) { + o->oAction++; + } } else if (o->oAction == 1) { // If Mario is touching the Tick Tock Clock painting... if (marioSurface != NULL @@ -26,16 +29,17 @@ void bhv_rotating_clock_arm_loop(void) { // Set Tick Tick Clock's speed based on the angle of the hand. // The angle actually counting down from 0xFFFF to 0 so // 11 o'clock is a small value and 1 o'clock is a large value. - if (rollAngle < 0xAAA) // > 345 degrees from 12 o'clock. + if (rollAngle < 0xAAA) { // > 345 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_STOPPED; - else if (rollAngle < 0x6aa4) // 210..345 degrees from 12 o'clock. + } else if (rollAngle < 0x6AA4) { // 210..345 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_FAST; - else if (rollAngle < 0x954C) // 150..210 degrees from 12 o'clock. + } else if (rollAngle < 0x954C) { // 150..210 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_RANDOM; - else if (rollAngle < 0xf546) // 15..150 degrees from 12 o'clock. + } else if (rollAngle < 0xF546) { // 15..150 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_SLOW; - else // < 15 degrees from 12 o'clock. + } else { // < 15 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_STOPPED; + } } // Increment the action to stop animating the hands. @@ -45,6 +49,7 @@ void bhv_rotating_clock_arm_loop(void) { } // Only rotate the hands until Mario enters the painting. - if (o->oAction < 2) + if (o->oAction < 2) { cur_obj_rotate_face_angle_using_vel(); + } } diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c index 527e5825..0efc7806 100644 --- a/src/game/behaviors/cloud.inc.c +++ b/src/game/behaviors/cloud.inc.c @@ -103,11 +103,9 @@ static void cloud_fwoosh_update(void) { * unloads, and when fwoosh blows wind. */ static void cloud_act_main(void) { - s16 localOffsetPhase; + s16 localOffsetPhase = 0x800 * gGlobalTimer; f32 localOffset; - localOffsetPhase = 0x800 * gGlobalTimer; - if (o->parentObj != o) { // Despawn if the parent lakitu does if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { @@ -176,7 +174,7 @@ void bhv_cloud_part_update(void) { if (o->parentObj->oAction == CLOUD_ACT_UNLOAD) { obj_mark_for_deletion(o); } else { - f32 size = 2.0f / 3.0f * o->parentObj->header.gfx.scale[0]; + f32 scale = 2.0f / 3.0f * o->parentObj->header.gfx.scale[0]; s16 angleFromCenter = o->parentObj->oFaceAngleYaw + 0x10000 / 5 * o->oBehParams2ndByte; // Takes 32 frames to cycle @@ -185,22 +183,22 @@ void bhv_cloud_part_update(void) { f32 cloudRadius; - cur_obj_scale(size); + cur_obj_scale(scale); // Cap fwoosh's face size - if (o->oBehParams2ndByte == 5 && size > 2.0f) { - size = o->header.gfx.scale[1] = 2.0f; + if (o->oBehParams2ndByte == 5 && scale > 2.0f) { + scale = o->header.gfx.scale[1] = 2.0f; } // Move back and forth along (1, 1, 1) - localOffset = 2 * coss(localOffsetPhase) * size; + localOffset = 2 * coss(localOffsetPhase) * scale; - cloudRadius = 25.0f * size; + cloudRadius = 25.0f * scale; o->oPosX = o->parentObj->oCloudCenterX + cloudRadius * sins(angleFromCenter) + localOffset; o->oPosY = - o->parentObj->oCloudCenterY + localOffset + size * sCloudPartHeights[o->oBehParams2ndByte]; + o->parentObj->oCloudCenterY + localOffset + scale * sCloudPartHeights[o->oBehParams2ndByte]; o->oPosZ = o->parentObj->oPosZ + cloudRadius * coss(angleFromCenter) + localOffset; diff --git a/src/game/behaviors/coffin.inc.c b/src/game/behaviors/coffin.inc.c index 5926bff8..d675fdcd 100644 --- a/src/game/behaviors/coffin.inc.c +++ b/src/game/behaviors/coffin.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvCoffinSpawner and bhvCoffin. * The coffins are spawned by a singular spawner, @@ -37,7 +38,7 @@ void bhv_coffin_spawner_loop(void) { // Behavior param of 0 for all even i, 1 for all odd coffin = spawn_object_relative(i & 1, coffinRelativePos[i].x, 0, relativeZ, o, - MODEL_BBH_WOODEN_TOMB, bhvCoffin); + MODEL_BBH_WOODEN_TOMB, bhvCoffin); // Never true, game would enter a while(1) before it could. // Possible a remnant of days this didn't happen. @@ -49,7 +50,7 @@ void bhv_coffin_spawner_loop(void) { } } - o->oAction += 1; + o->oAction++; } } else if (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) { o->oAction = COFFIN_SPAWNER_ACT_COFFINS_UNLOADED; @@ -62,13 +63,6 @@ void bhv_coffin_spawner_loop(void) { * Also controls laying the coffin down after it has stood up. */ void coffin_act_idle(void) { - f32 yawCos; - f32 yawSin; - f32 dx; - f32 dz; - f32 distForwards; - f32 distSideways; - if (o->oBehParams2ndByte != COFFIN_BP_STATIC) { // Lay down if standing if (o->oFaceAnglePitch != 0) { @@ -90,25 +84,23 @@ void coffin_act_idle(void) { o->oTimer = 0; } else { // Yaw never changes and is aligned, so yawCos = 1 or -1, yawSin = 0 - yawCos = coss(o->oFaceAngleYaw); - yawSin = sins(o->oFaceAngleYaw); + f32 yawCos = coss(o->oFaceAngleYaw); + f32 yawSin = sins(o->oFaceAngleYaw); - dx = gMarioObject->oPosX - o->oPosX; - dz = gMarioObject->oPosZ - o->oPosZ; + f32 dx = gMarioObject->oPosX - o->oPosX; + f32 dz = gMarioObject->oPosZ - o->oPosZ; - distForwards = dx * yawCos + dz * yawSin; - distSideways = dz * yawCos - dx * yawSin; + f32 distForwards = dx * yawCos + dz * yawSin; + f32 distSideways = dz * yawCos - dx * yawSin; // This checks a box around the coffin and if it has been a bit since it stood up. // It also checks in the case Mario is squished, so he doesn't get permanently squished. if (o->oTimer > 60 - && (o->oDistanceToMario > 100.0f || gMarioState->action == ACT_SQUISHED)) { - if (gMarioObject->oPosY - o->oPosY < 200.0f && absf(distForwards) < 140.0f) { - if (distSideways < 150.0f && distSideways > -450.0f) { - cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2_LOWPRIO); - o->oAction = COFFIN_ACT_STAND_UP; - } - } + && (o->oDistanceToMario > 100.0f || gMarioState->action == ACT_SQUISHED) + && gMarioObject->oPosY - o->oPosY < 200.0f && absf(distForwards) < 140.0f + && distSideways < 150.0f && distSideways > -450.0f) { + cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2_LOWPRIO); + o->oAction = COFFIN_ACT_STAND_UP; } o->oAngleVelPitch = 0; diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c index ea6b84cd..bbd07fcd 100644 --- a/src/game/behaviors/coin.inc.c +++ b/src/game/behaviors/coin.inc.c @@ -1,28 +1,39 @@ -// coin.c.inc +// coin.inc.c struct ObjectHitbox sYellowCoinHitbox = { - /* interactType: */ INTERACT_COIN, - /* downOffset: */ 0, + /* interactType: */ INTERACT_COIN, + /* downOffset: */ 0, /* damageOrCoinValue: */ 1, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 100, - /* height: */ 64, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 100, + /* height: */ 64, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; -s16 sCoinArrowPositions[][2] = { { 0, -150 }, { 0, -50 }, { 0, 50 }, { 0, 150 }, - { -50, 100 }, { -100, 50 }, { 50, 100 }, { 100, 50 } }; +s16 sCoinArrowPositions[][2] = { + { 0, -150 }, + { 0, -50 }, + { 0, 50 }, + { 0, 150 }, + { -50, 100 }, + { -100, 50 }, + { 50, 100 }, + { 100, 50 }, +}; s32 bhv_coin_sparkles_init(void) { - if (o->oInteractStatus & INT_STATUS_INTERACTED && !(o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB)) { + if (o->oInteractStatus & INT_STATUS_INTERACTED + && !(o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB)) { spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles); obj_mark_for_deletion(o); - return 1; + return TRUE; } + o->oInteractStatus = 0; - return 0; + + return FALSE; } void bhv_yellow_coin_init(void) { @@ -30,10 +41,14 @@ void bhv_yellow_coin_init(void) { obj_set_hitbox(o, &sYellowCoinHitbox); bhv_init_room(); cur_obj_update_floor_height(); - if (500.0f < absf(o->oPosY - o->oFloorHeight)) + + if (500.0f < absf(o->oPosY - o->oFloorHeight)) { cur_obj_set_model(MODEL_YELLOW_COIN_NO_SHADOW); - if (o->oFloorHeight < FLOOR_LOWER_LIMIT_MISC) + } + + if (o->oFloorHeight < FLOOR_LOWER_LIMIT_MISC) { obj_mark_for_deletion(o); + } } void bhv_yellow_coin_loop(void) { @@ -43,8 +58,11 @@ void bhv_yellow_coin_loop(void) { void bhv_temp_coin_loop(void) { o->oAnimState++; - if (cur_obj_wait_then_blink(200, 20)) + + if (cur_obj_wait_then_blink(200, 20)) { obj_mark_for_deletion(o); + } + bhv_coin_sparkles_init(); } @@ -52,6 +70,7 @@ void bhv_coin_init(void) { o->oVelY = random_float() * 10.0f + 30 + o->oCoinUnk110; o->oForwardVel = random_float() * 10.0f; o->oMoveAngleYaw = random_u16(); + cur_obj_set_behavior(bhvYellowCoin); obj_set_hitbox(o, &sYellowCoinHitbox); cur_obj_become_intangible(); @@ -59,51 +78,58 @@ void bhv_coin_init(void) { void bhv_coin_loop(void) { struct Surface *sp1C; - s16 sp1A; + cur_obj_update_floor_and_walls(); cur_obj_if_hit_wall_bounce_away(); cur_obj_move_standard(-62); + if ((sp1C = o->oFloor) != NULL) { - if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) + if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) { o->oSubAction = 1; + } if (o->oSubAction == 1) { o->oBounciness = 0; if (sp1C->normal.y < 0.9) { - sp1A = atan2s(sp1C->normal.z, sp1C->normal.x); + s16 sp1A = atan2s(sp1C->normal.z, sp1C->normal.x); cur_obj_rotate_yaw_toward(sp1A, 0x400); } } } - if (o->oTimer == 0) -#if defined(VERSION_US) - cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_2); -#elif defined(VERSION_EU) || defined(VERSION_SH) - cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_EU); -#else + + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT); -#endif - if (o->oVelY < 0) + } + + if (o->oVelY < 0) { cur_obj_become_tangible(); + } + if (o->oMoveFlags & OBJ_MOVE_LANDED) { #ifndef VERSION_JP if (o->oMoveFlags & (OBJ_MOVE_ABOVE_DEATH_BARRIER | OBJ_MOVE_ABOVE_LAVA)) #else if (o->oMoveFlags & OBJ_MOVE_ABOVE_LAVA) #endif + { obj_mark_for_deletion(o); + } } -#ifndef VERSION_JP + if (o->oMoveFlags & OBJ_MOVE_BOUNCE) { - if (o->oCoinUnk1B0 < 5) +#ifndef VERSION_JP + if (o->oCoinUnk1B0 < 5) { cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); + } o->oCoinUnk1B0++; - } #else - if (o->oMoveFlags & OBJ_MOVE_BOUNCE) cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); #endif - if (cur_obj_wait_then_blink(400, 20)) + } + + if (cur_obj_wait_then_blink(400, 20)) { obj_mark_for_deletion(o); + } + bhv_coin_sparkles_init(); } @@ -112,25 +138,33 @@ void bhv_coin_formation_spawn_loop(void) { cur_obj_set_behavior(bhvYellowCoin); obj_set_hitbox(o, &sYellowCoinHitbox); bhv_init_room(); + if (o->oCoinUnkF8) { o->oPosY += 300.0f; cur_obj_update_floor_height(); - if (o->oPosY < o->oFloorHeight || o->oFloorHeight < FLOOR_LOWER_LIMIT_MISC) + + if (o->oPosY < o->oFloorHeight || o->oFloorHeight < FLOOR_LOWER_LIMIT_MISC) { obj_mark_for_deletion(o); - else + } else { o->oPosY = o->oFloorHeight; + } } else { cur_obj_update_floor_height(); - if (absf(o->oPosY - o->oFloorHeight) > 250.0f) + + if (absf(o->oPosY - o->oFloorHeight) > 250.0f) { cur_obj_set_model(MODEL_YELLOW_COIN_NO_SHADOW); + } } } else { - if (bhv_coin_sparkles_init()) + if (bhv_coin_sparkles_init()) { o->parentObj->oCoinUnkF4 |= bit_shift_left(o->oBehParams2ndByte); + } o->oAnimState++; } - if (o->parentObj->oAction == 2) + + if (o->parentObj->oAction == 2) { obj_mark_for_deletion(o); + } } void spawn_coin_in_formation(s32 sp50, s32 sp54) { @@ -138,18 +172,22 @@ void spawn_coin_in_formation(s32 sp50, s32 sp54) { Vec3i sp40; s32 sp3C = 1; s32 sp38 = 1; + sp40[0] = sp40[1] = sp40[2] = 0; + switch (sp54 & 7) { case 0: sp40[2] = 160 * (sp50 - 2); - if (sp50 > 4) + if (sp50 > 4) { sp3C = 0; + } break; case 1: sp38 = 0; sp40[1] = 160 * sp50 * 0.8; // 128 * sp50 - if (sp50 > 4) + if (sp50 > 4) { sp3C = 0; + } break; case 2: sp40[0] = sins(sp50 << 13) * 300.0f; @@ -165,8 +203,11 @@ void spawn_coin_in_formation(s32 sp50, s32 sp54) { sp40[2] = sCoinArrowPositions[sp50][1]; break; } - if (sp54 & 0x10) + + if (sp54 & 0x10) { sp38 = 0; + } + if (sp3C) { sp4C = spawn_object_relative(sp50, sp40[0], sp40[1], sp40[2], o, MODEL_YELLOW_COIN, bhvCoinFormationSpawn); @@ -180,19 +221,22 @@ void bhv_coin_formation_init(void) { void bhv_coin_formation_loop(void) { s32 bitIndex; + switch (o->oAction) { case 0: if (o->oDistanceToMario < 2000.0f) { for (bitIndex = 0; bitIndex < 8; bitIndex++) { - if (!(o->oCoinUnkF4 & (1 << bitIndex))) + if (!(o->oCoinUnkF4 & (1 << bitIndex))) { spawn_coin_in_formation(bitIndex, o->oBehParams2ndByte); + } } o->oAction++; } break; case 1: - if (o->oDistanceToMario > 2100.0f) + if (o->oDistanceToMario > 2100.0f) { o->oAction++; + } break; case 2: o->oAction = 0; @@ -206,31 +250,43 @@ void bhv_coin_formation_loop(void) { void coin_inside_boo_act_1(void) { cur_obj_update_floor_and_walls(); cur_obj_if_hit_wall_bounce_away(); - if (o->oMoveFlags & OBJ_MOVE_BOUNCE) + + if (o->oMoveFlags & OBJ_MOVE_BOUNCE) { cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); + } + if (o->oTimer > 90 || (o->oMoveFlags & OBJ_MOVE_LANDED)) { obj_set_hitbox(o, &sYellowCoinHitbox); cur_obj_become_tangible(); cur_obj_set_behavior(bhvYellowCoin); } + cur_obj_move_standard(-30); bhv_coin_sparkles_init(); - if (cur_obj_has_model(MODEL_BLUE_COIN)) + + if (cur_obj_has_model(MODEL_BLUE_COIN)) { o->oDamageOrCoinValue = 5; - if (cur_obj_wait_then_blink(400, 20)) + } + + if (cur_obj_wait_then_blink(400, 20)) { obj_mark_for_deletion(o); + } } void coin_inside_boo_act_0(void) { s16 sp26; f32 sp20; struct Object *parent = o->parentObj; + cur_obj_become_intangible(); + if (o->oTimer == 0 && gCurrLevelNum == LEVEL_BBH) { cur_obj_set_model(MODEL_BLUE_COIN); - cur_obj_scale(0.7); + cur_obj_scale(0.7f); } + obj_copy_pos(o, parent); + if (parent->oBooDeathStatus == BOO_DEATH_STATUS_DYING) { o->oAction = 1; sp26 = gMarioObject->oMoveAngleYaw; @@ -241,7 +297,10 @@ void coin_inside_boo_act_0(void) { } } -void (*sCoinInsideBooActions[])(void) = { coin_inside_boo_act_0, coin_inside_boo_act_1 }; +void (*sCoinInsideBooActions[])(void) = { + coin_inside_boo_act_0, + coin_inside_boo_act_1, +}; void bhv_coin_inside_boo_loop(void) { cur_obj_call_action_function(sCoinInsideBooActions); @@ -253,8 +312,9 @@ void bhv_coin_sparkles_loop(void) { void bhv_golden_coin_sparkles_loop(void) { struct Object *sp2C; - UNUSED s32 unused; + UNUSED u8 filler[4]; f32 sp24 = 30.0f; + sp2C = spawn_object(o, MODEL_SPARKLES, bhvCoinSparkles); sp2C->oPosX += random_float() * sp24 - sp24 / 2; sp2C->oPosZ += random_float() * sp24 - sp24 / 2; diff --git a/src/game/behaviors/collide_particles.inc.c b/src/game/behaviors/collide_particles.inc.c index 9b013699..4f69d406 100644 --- a/src/game/behaviors/collide_particles.inc.c +++ b/src/game/behaviors/collide_particles.inc.c @@ -1,4 +1,4 @@ -// collide_particles.c.inc +// collide_particles.inc.c static s16 sTinyTriMovementParams[] = { 0xD000, 0, 0x3000, 0, 0xDE67, 0x2199, 0x2199, 0x2199, 0xDE67, 0xDE67, 0x2199, 0xDE67 }; @@ -7,27 +7,29 @@ static s16 sTinyStarMovementParams[] = { 0xE000, 0, 0, 0, 0x2000, 0x1666, 0x1666, 0x1666, 0xE99A, 0xE99A, 0x1666, 0xE99A }; void bhv_punch_tiny_triangle_loop(void) { - s16 sp1E; if (o->oTimer == 0) { - sp1E = o->oMoveAngleYaw; + s16 sp1E = o->oMoveAngleYaw; o->oCollisionParticleUnkF4 = 1.28f; cur_obj_set_pos_relative(gMarioObject, 0.0f, 60.0f, 100.0f); o->oMoveAngleYaw = sp1E; } + cur_obj_move_using_fvel_and_gravity(); o->oAnimState = 5; cur_obj_scale(o->oCollisionParticleUnkF4); o->oCollisionParticleUnkF4 -= 0.2f; - if (gDebugInfo[4][0] + 6 < o->oTimer) + + if (gDebugInfo[DEBUG_PAGE_EFFECTINFO][0] + 6 < o->oTimer) { obj_mark_for_deletion(o); + } } void bhv_punch_tiny_triangle_init(void) { s32 i; - UNUSED s32 unused; - struct Object *triangle; + UNUSED u8 filler[4]; + for (i = 0; i < 6; i++) { - triangle = spawn_object(o, MODEL_DIRT_ANIMATION, bhvPunchTinyTriangle); + struct Object *triangle = spawn_object(o, MODEL_DIRT_ANIMATION, bhvPunchTinyTriangle); triangle->oMoveAngleYaw = gMarioObject->oMoveAngleYaw + sTinyTriMovementParams[2 * i] + 0x8000; triangle->oVelY = sins(sTinyTriMovementParams[2 * i + 1]) * 25.0f; triangle->oForwardVel = coss(sTinyTriMovementParams[2 * i + 1]) * 25.0f; @@ -35,13 +37,13 @@ void bhv_punch_tiny_triangle_init(void) { } void bhv_wall_tiny_star_particle_loop(void) { - s16 sp1E; if (o->oTimer == 0) { - sp1E = o->oMoveAngleYaw; + s16 sp1E = o->oMoveAngleYaw; o->oCollisionParticleUnkF4 = 0.28f; cur_obj_set_pos_relative(gMarioObject, 0.0f, 30.0f, 110.0f); o->oMoveAngleYaw = sp1E; } + cur_obj_move_using_fvel_and_gravity(); o->oAnimState = 4; cur_obj_scale(o->oCollisionParticleUnkF4); @@ -50,10 +52,10 @@ void bhv_wall_tiny_star_particle_loop(void) { void bhv_tiny_star_particles_init(void) { s32 i; - UNUSED s32 unused; - struct Object *particle; + UNUSED u8 filler[4]; + for (i = 0; i < 7; i++) { - particle = spawn_object(o, MODEL_CARTOON_STAR, bhvWallTinyStarParticle); + struct Object *particle = spawn_object(o, MODEL_CARTOON_STAR, bhvWallTinyStarParticle); particle->oMoveAngleYaw = gMarioObject->oMoveAngleYaw + sTinyStarMovementParams[2 * i] + 0x8000; particle->oVelY = sins(sTinyStarMovementParams[2 * i + 1]) * 25.0f; particle->oForwardVel = coss(sTinyStarMovementParams[2 * i + 1]) * 25.0f; @@ -67,6 +69,7 @@ void bhv_pound_tiny_star_particle_loop(void) { o->oPosY -= 20.0f; o->oVelY = 14.0f; } + cur_obj_move_using_fvel_and_gravity(); o->oAnimState = 4; cur_obj_scale(o->oCollisionParticleUnkF4); @@ -76,9 +79,9 @@ void bhv_pound_tiny_star_particle_loop(void) { void bhv_pound_tiny_star_particle_init(void) { s32 sp24; s32 sp20 = 8; - struct Object *particle; + for (sp24 = 0; sp24 < sp20; sp24++) { - particle = spawn_object(o, MODEL_CARTOON_STAR, bhvPoundTinyStarParticle); + struct Object *particle = spawn_object(o, MODEL_CARTOON_STAR, bhvPoundTinyStarParticle); particle->oMoveAngleYaw = (sp24 * 65536) / sp20; } } diff --git a/src/game/behaviors/controllable_platform.inc.c b/src/game/behaviors/controllable_platform.inc.c index c22fe64d..ae03dc8a 100644 --- a/src/game/behaviors/controllable_platform.inc.c +++ b/src/game/behaviors/controllable_platform.inc.c @@ -1,4 +1,4 @@ -// controllable_platform.c.inc +// controllable_platform.inc.c static s8 D_80331694 = 0; @@ -11,8 +11,9 @@ void controllable_platform_act_1(void) { } void controllable_platform_act_2(void) { - if (o->oBehParams2ndByte == D_80331694) + if (o->oBehParams2ndByte == D_80331694) { return; + } o->oParentRelativePosY += 4.0f; if (o->oParentRelativePosY > 51.0f) { @@ -24,8 +25,9 @@ void controllable_platform_act_2(void) { void bhv_controllable_platform_sub_loop(void) { switch (o->oAction) { case 0: - if (o->oTimer < 30) + if (o->oTimer < 30) { break; + } if (gMarioObject->platform == o) { D_80331694 = o->oBehParams2ndByte; @@ -49,12 +51,14 @@ void bhv_controllable_platform_sub_loop(void) { o->oVelX = o->parentObj->oVelX; o->oVelZ = o->parentObj->oVelZ; - if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } void bhv_controllable_platform_init(void) { struct Object *sp34; + sp34 = spawn_object_rel_with_rot(o, MODEL_HMC_METAL_ARROW_PLATFORM, bhvControllablePlatformSub, 0, 51, 204, 0, 0, 0); sp34->oBehParams2ndByte = 1; @@ -85,9 +89,9 @@ void controllable_platform_hit_wall(s8 sp1B) { } void controllable_platform_check_walls(s8 sp1B, s8 sp1C[3], Vec3f sp20, UNUSED Vec3f sp24, Vec3f sp28) { - if (sp1C[1] == 1 || (sp1C[0] == 1 && sp1C[2] == 1)) + if (sp1C[1] == 1 || (sp1C[0] == 1 && sp1C[2] == 1)) { controllable_platform_hit_wall(sp1B); - else { + } else { if (sp1C[0] == 1) { if (((sp1B == 1 || sp1B == 2) && (s32) sp20[2] != 0) || ((sp1B == 3 || sp1B == 4) && (s32) sp20[0] != 0)) { @@ -209,15 +213,17 @@ void bhv_controllable_platform_loop(void) { break; case 6: - if (obj_flicker_and_disappear(o, 150)) + if (obj_flicker_and_disappear(o, 150)) { spawn_object_abs_with_rot(o, 0, MODEL_HMC_METAL_PLATFORM, bhvControllablePlatform, o->oHomeX, o->oHomeY, o->oHomeZ, 0, 0, 0); + } break; } controllable_platform_tilt_from_mario(); o->oPosX += o->oVelX; o->oPosZ += o->oVelZ; - if (D_80331694 != 0 && D_80331694 != 6) + if (D_80331694 != 0 && D_80331694 != 6) { cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2); + } } diff --git a/src/game/behaviors/corkbox.inc.c b/src/game/behaviors/corkbox.inc.c index e9316513..df2d7955 100644 --- a/src/game/behaviors/corkbox.inc.c +++ b/src/game/behaviors/corkbox.inc.c @@ -1,4 +1,4 @@ -// corkbox.c.inc +// corkbox.inc.c // TODO: This split seems weird. Investigate further? void bhv_bobomb_bully_death_smoke_init(void) { @@ -31,18 +31,18 @@ void bhv_bobomb_explosion_bubble_loop(void) { spawn_object(o, MODEL_SMALL_WATER_SPLASH, bhvObjectWaterSplash); } - if (o->oTimer >= 61) + if (o->oTimer > 60) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } o->oPosY += o->oVelY; o->oTimer++; } void bhv_respawner_loop(void) { - struct Object *spawnedObject; - if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, o->oRespawnerMinSpawnDist)) { - spawnedObject = spawn_object(o, o->oRespawnerModelToRespawn, o->oRespawnerBehaviorToRespawn); + struct Object *spawnedObject = spawn_object(o, o->oRespawnerModelToRespawn, + o->oRespawnerBehaviorToRespawn); spawnedObject->oBehParams = o->oBehParams; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/cruiser.inc.c b/src/game/behaviors/cruiser.inc.c index a705bb2c..71b22c03 100644 --- a/src/game/behaviors/cruiser.inc.c +++ b/src/game/behaviors/cruiser.inc.c @@ -1,4 +1,4 @@ -// cruiser.c.inc +// cruiser.inc.c void bhv_rr_cruiser_wing_init(void) { o->oRRCruiserWingUnkF4 = o->oFaceAngleYaw; diff --git a/src/game/behaviors/ddd_pole.inc.c b/src/game/behaviors/ddd_pole.inc.c index 58d7d616..86e5312a 100644 --- a/src/game/behaviors/ddd_pole.inc.c +++ b/src/game/behaviors/ddd_pole.inc.c @@ -1,3 +1,4 @@ +// ddd_pole.inc.c void bhv_ddd_pole_init(void) { if (!(save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR))) { diff --git a/src/game/behaviors/ddd_sub.inc.c b/src/game/behaviors/ddd_sub.inc.c index d8479c65..2d59a223 100644 --- a/src/game/behaviors/ddd_sub.inc.c +++ b/src/game/behaviors/ddd_sub.inc.c @@ -1,6 +1,7 @@ -// ddd_sub.c.inc +// ddd_sub.inc.c void bhv_bowsers_sub_loop(void) { - if (save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR)) + if (save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR)) { obj_mark_for_deletion(o); + } } diff --git a/src/game/behaviors/ddd_warp.inc.c b/src/game/behaviors/ddd_warp.inc.c index 617e850f..15b00be4 100644 --- a/src/game/behaviors/ddd_warp.inc.c +++ b/src/game/behaviors/ddd_warp.inc.c @@ -1,8 +1,9 @@ -// ddd_warp.c.inc +// ddd_warp.inc.c void bhv_ddd_warp_loop(void) { - if (gDddPaintingStatus & BOWSERS_SUB_BEATEN) + if (gDddPaintingStatus & BOWSERS_SUB_BEATEN) { o->collisionData = segmented_to_virtual(inside_castle_seg7_collision_ddd_warp_2); - else + } else { o->collisionData = segmented_to_virtual(inside_castle_seg7_collision_ddd_warp); + } } diff --git a/src/game/behaviors/decorative_pendulum.inc.c b/src/game/behaviors/decorative_pendulum.inc.c index 2aa9539f..9d0ca338 100644 --- a/src/game/behaviors/decorative_pendulum.inc.c +++ b/src/game/behaviors/decorative_pendulum.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvDecorativePendulum. * This controls the pendulum that lies underneath the Tick Tock Clock painting. @@ -13,10 +14,11 @@ void bhv_decorative_pendulum_init(void) { * acceleration. */ void bhv_decorative_pendulum_loop(void) { - if (o->oFaceAngleRoll > 0) + if (o->oFaceAngleRoll > 0) { o->oAngleVelRoll -= 0x08; - else + } else { o->oAngleVelRoll += 0x08; + } o->oFaceAngleRoll += o->oAngleVelRoll; @@ -26,6 +28,7 @@ void bhv_decorative_pendulum_loop(void) { * This means the sound we hear when the pendulum hits its upswing is * actually one sound played twice in rapid succession. */ - if (o->oAngleVelRoll == 0x10 || o->oAngleVelRoll == -0x10) + if (o->oAngleVelRoll == 0x10 || o->oAngleVelRoll == -0x10) { cur_obj_play_sound_2(SOUND_GENERAL_BIG_CLOCK); + } } diff --git a/src/game/behaviors/donut_platform.inc.c b/src/game/behaviors/donut_platform.inc.c index f1503a0e..4c0eefc5 100644 --- a/src/game/behaviors/donut_platform.inc.c +++ b/src/game/behaviors/donut_platform.inc.c @@ -1,3 +1,5 @@ +// donut_platform.inc.c + static Vec3s sDonutPlatformPositions[] = { { 0x0B4C, 0xF7D7, 0x19A4 }, { 0xF794, 0x08A3, 0xFFA9 }, { 0x069C, 0x09D8, 0xFFE0 }, { 0x05CF, 0x09D8, 0xFFE0 }, { 0x0502, 0x09D8, 0xFFE0 }, { 0x054C, 0xF7D7, 0x19A4 }, @@ -15,24 +17,19 @@ static Vec3s sDonutPlatformPositions[] = { void bhv_donut_platform_spawner_update(void) { s32 i; s32 platformFlag; - f32 dx; - f32 dy; - f32 dz; - f32 marioSqDist; - for (i = 0, platformFlag = 1; i < 31; i++, platformFlag = platformFlag << 1) { + for (i = 0, platformFlag = 1; i < ARRAY_COUNT(sDonutPlatformPositions); i++, platformFlag = platformFlag << 1) { if (!(o->oDonutPlatformSpawnerSpawnedPlatforms & platformFlag)) { - dx = gMarioObject->oPosX - sDonutPlatformPositions[i][0]; - dy = gMarioObject->oPosY - sDonutPlatformPositions[i][1]; - dz = gMarioObject->oPosZ - sDonutPlatformPositions[i][2]; - marioSqDist = dx * dx + dy * dy + dz * dz; + f32 dx = gMarioObject->oPosX - sDonutPlatformPositions[i][0]; + f32 dy = gMarioObject->oPosY - sDonutPlatformPositions[i][1]; + f32 dz = gMarioObject->oPosZ - sDonutPlatformPositions[i][2]; + f32 marioSqDist = dx * dx + dy * dy + dz * dz; // dist > 1000 and dist < 2000 if (marioSqDist > 1000000.0f && marioSqDist < 4000000.0f) { if (spawn_object_relative(i, sDonutPlatformPositions[i][0], sDonutPlatformPositions[i][1], sDonutPlatformPositions[i][2], - o, MODEL_RR_DONUT_PLATFORM, bhvDonutPlatform) - != NULL) { + o, MODEL_RR_DONUT_PLATFORM, bhvDonutPlatform) != NULL) { o->oDonutPlatformSpawnerSpawnedPlatforms |= platformFlag; } } diff --git a/src/game/behaviors/door.inc.c b/src/game/behaviors/door.inc.c index 695e5996..c25626c7 100644 --- a/src/game/behaviors/door.inc.c +++ b/src/game/behaviors/door.inc.c @@ -1,12 +1,11 @@ -// door.c.inc +// door.inc.c -struct DoorAction -{ +struct DoorAction { u32 flag; s32 action; }; -static struct DoorAction sDoorActions[] = { { 0x40000, 3 }, { 0x80000, 4 }, { 0x10000, 1 }, { 0x20000, 2 }, { -1, 0 }, }; +static struct DoorAction sDoorActions[] = { { 0x40000, 3 }, { 0x80000, 4 }, { 0x10000, 1 }, { 0x20000, 2 }, { 0xFFFFFFFF, 0 }, }; static s32 sDoorOpenSounds[] = { SOUND_GENERAL_OPEN_WOOD_DOOR, SOUND_GENERAL_OPEN_IRON_DOOR }; @@ -14,15 +13,17 @@ static s32 sDoorCloseSounds[] = { SOUND_GENERAL_CLOSE_WOOD_DOOR, SOUND_GENERAL_C void door_animation_and_reset(s32 sp18) { cur_obj_init_animation_with_sound(sp18); - if (cur_obj_check_if_near_animation_end()) + if (cur_obj_check_if_near_animation_end()) { o->oAction = 0; + } } void set_door_camera_event(void) { - if (segmented_to_virtual(bhvDoor) == o->behavior) + if (segmented_to_virtual(bhvDoor) == o->behavior) { gPlayerCameraState->cameraEvent = CAM_EVENT_DOOR; - else + } else { gPlayerCameraState->cameraEvent = CAM_EVENT_DOOR_WARP; + } gPlayerCameraState->usedObj = o; } @@ -39,14 +40,15 @@ void play_door_open_noise(void) { void play_warp_door_open_noise(void) { s32 sp1C = cur_obj_has_model(MODEL_HMC_METAL_DOOR); - if (o->oTimer == 30) + if (o->oTimer == 30) { cur_obj_play_sound_2(sDoorCloseSounds[sp1C]); + } } void bhv_door_loop(void) { s32 sp1C = 0; - - while (sDoorActions[sp1C].flag != (u32)~0) { + + while (sDoorActions[sp1C].flag != 0xFFFFFFFF) { if (cur_obj_clear_interact_status_flag(sDoorActions[sp1C].flag)) { set_door_camera_event(); cur_obj_change_action(sDoorActions[sp1C].action); @@ -75,15 +77,21 @@ void bhv_door_loop(void) { play_warp_door_open_noise(); break; } - if (o->oAction == 0) + + if (o->oAction == 0) { load_object_collision_model(); + } + bhv_star_door_loop_2(); } void bhv_door_init(void) { - f32 x = o->oPosX; - f32 z = o->oPosZ; + f32 x; + f32 z; struct Surface *floor; + + x = o->oPosX; + z = o->oPosZ; find_floor(x, o->oPosY, z, &floor); if (floor != NULL) { o->oDoorUnkF8 = floor->room; @@ -110,30 +118,36 @@ void bhv_door_init(void) { } void bhv_star_door_loop_2(void) { - s32 sp4 = 0; + s32 sp4 = FALSE; + if (gMarioCurrentRoom != 0) { - if (o->oDoorUnkF8 == gMarioCurrentRoom) - sp4 = 1; - else if (gMarioCurrentRoom == o->oDoorUnkFC) - sp4 = 1; - else if (gMarioCurrentRoom == o->oDoorUnk100) - sp4 = 1; - else if (gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oDoorUnkFC) - sp4 = 1; - else if (gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oDoorUnk100) - sp4 = 1; - else if (gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oDoorUnkFC) - sp4 = 1; - else if (gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oDoorUnk100) - sp4 = 1; - } else - sp4 = 1; - if (sp4 == 1) { + if (o->oDoorUnkF8 == gMarioCurrentRoom) { + sp4 = TRUE; + } else if (gMarioCurrentRoom == o->oDoorUnkFC) { + sp4 = TRUE; + } else if (gMarioCurrentRoom == o->oDoorUnk100) { + sp4 = TRUE; + } else if (gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oDoorUnkFC) { + sp4 = TRUE; + } else if (gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oDoorUnk100) { + sp4 = TRUE; + } else if (gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oDoorUnkFC) { + sp4 = TRUE; + } else if (gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oDoorUnk100) { + sp4 = TRUE; + } + } else { + sp4 = TRUE; + } + + if (sp4 == TRUE) { o->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; D_8035FEE4++; } - if (sp4 == 0) { + + if (!sp4) { o->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; } + o->oDoorUnk88 = sp4; } diff --git a/src/game/behaviors/dorrie.inc.c b/src/game/behaviors/dorrie.inc.c index d6d3c8c2..8919677b 100644 --- a/src/game/behaviors/dorrie.inc.c +++ b/src/game/behaviors/dorrie.inc.c @@ -1,11 +1,10 @@ +// dorrie.inc.c void dorrie_raise_head(void) { - s16 startAngle; + s16 startAngle = o->oDorrieNeckAngle; f32 xzDisp; f32 yDisp; - startAngle = o->oDorrieNeckAngle; - o->oDorrieNeckAngle -= (s16) absf(370.0f * sins(o->oDorrieHeadRaiseSpeed)); xzDisp = 440.0f * (coss(o->oDorrieNeckAngle) - coss(startAngle)); @@ -16,12 +15,10 @@ void dorrie_raise_head(void) { } void dorrie_act_move(void) { - s16 startYaw; + s16 startYaw = o->oMoveAngleYaw; s16 targetYaw; s16 targetSpeed; - s16 circularTurn; - startYaw = o->oMoveAngleYaw; o->oDorrieNeckAngle = -0x26F4; cur_obj_init_animation_with_sound(1); @@ -36,7 +33,7 @@ void dorrie_act_move(void) { targetYaw = gMarioObject->oFaceAngleYaw; targetSpeed = 10; } else { - circularTurn = 0x4000 - atan2s(2000.0f, o->oDorrieDistToHome - 2000.0f); + s16 circularTurn = 0x4000 - atan2s(2000.0f, o->oDorrieDistToHome - 2000.0f); if ((s16)(o->oMoveAngleYaw - o->oDorrieAngleToHome) < 0) { circularTurn = -circularTurn; } @@ -112,8 +109,7 @@ void dorrie_act_raise_head(void) { void bhv_dorrie_update(void) { f32 boundsShift; - UNUSED s32 unused1; - UNUSED s32 unused2; + UNUSED u8 filler[8]; f32 maxOffsetY; if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { diff --git a/src/game/behaviors/drawbridge.inc.c b/src/game/behaviors/drawbridge.inc.c index 0fd04905..6630b6b5 100644 --- a/src/game/behaviors/drawbridge.inc.c +++ b/src/game/behaviors/drawbridge.inc.c @@ -1,4 +1,4 @@ -// drawbridge.c.inc +// drawbridge.inc.c void bhv_lll_drawbridge_spawner_loop(void) { struct Object *drawbridge1, *drawbridge2; @@ -34,7 +34,7 @@ void bhv_lll_drawbridge_loop(void) { //! Because the global timer increments when the game is paused, pausing and unpausing // the game at regular intervals can leave the drawbridge raised indefinitely. - if (o->oTimer >= 51 && (globalTimer % 8) == 0) { + if (o->oTimer > 50 && (globalTimer % 8) == 0) { o->oAction = LLL_DRAWBRIDGE_ACT_LOWER; cur_obj_play_sound_2(SOUND_GENERAL_BOAT_TILT1); } @@ -45,7 +45,7 @@ void bhv_lll_drawbridge_loop(void) { //! Because the global timer increments when the game is paused, pausing and unpausing // the game at regular intervals can leave the drawbridge lowered indefinitely. - if (o->oTimer >= 51 && (globalTimer % 8) == 0) { + if (o->oTimer > 50 && (globalTimer % 8) == 0) { o->oAction = LLL_DRAWBRIDGE_ACT_RAISE; cur_obj_play_sound_2(SOUND_GENERAL_BOAT_TILT2); } diff --git a/src/game/behaviors/elevator.inc.c b/src/game/behaviors/elevator.inc.c index 34369071..7d2ec042 100644 --- a/src/game/behaviors/elevator.inc.c +++ b/src/game/behaviors/elevator.inc.c @@ -1,12 +1,14 @@ -// elevator.c.inc +// elevator.inc.c -static s16 sElevatorHeights[] = { -51, 0, 0, - -461, 0, 0, - -512, 0, 0, - -2611, 0, 0, - -2360, 0, 0, - 214, 0, 0, - -50, 1945, 1 }; +static s16 sElevatorHeights[] = { + -51, 0, 0, + -461, 0, 0, + -512, 0, 0, + -2611, 0, 0, + -2360, 0, 0, + 214, 0, 0, + -50, 1945, 1, +}; void elevator_starting_shake(void) { cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1); @@ -17,56 +19,62 @@ void elevator_act_0(void) { o->oVelY = 0; if (o->oElevatorUnk100 == 2) { if (gMarioObject->platform == o) { - if (o->oPosY > o->oElevatorUnkFC) + if (o->oPosY > o->oElevatorUnkFC) { o->oAction = 2; - else + } else { o->oAction = 1; + } } } else if (gMarioObject->oPosY > o->oElevatorUnkFC || o->oElevatorUnk100 == 1) { o->oPosY = o->oElevatorUnkF8; - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->oAction = 2; + } } else { o->oPosY = o->oElevatorUnkF4; - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->oAction = 1; + } } } void elevator_act_1(void) { cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); - if (o->oTimer == 0 && cur_obj_is_mario_on_platform()) + if (o->oTimer == 0 && cur_obj_is_mario_on_platform()) { elevator_starting_shake(); + } approach_f32_signed(&o->oVelY, 10.0f, 2.0f); o->oPosY += o->oVelY; if (o->oPosY > o->oElevatorUnkF8) { o->oPosY = o->oElevatorUnkF8; - if (o->oElevatorUnk100 == 2 || o->oElevatorUnk100 == 1) + if (o->oElevatorUnk100 == 2 || o->oElevatorUnk100 == 1) { o->oAction = 3; - else if (gMarioObject->oPosY < o->oElevatorUnkFC) + } else if (gMarioObject->oPosY < o->oElevatorUnkFC) { o->oAction = 2; - else + } else { o->oAction = 3; + } } } -void elevator_act_2(void) // Pretty similar code to action 1 -{ +void elevator_act_2(void) { cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); - if (o->oTimer == 0 && cur_obj_is_mario_on_platform()) + if (o->oTimer == 0 && cur_obj_is_mario_on_platform()) { elevator_starting_shake(); + } approach_f32_signed(&o->oVelY, -10.0f, -2.0f); o->oPosY += o->oVelY; if (o->oPosY < o->oElevatorUnkF4) { o->oPosY = o->oElevatorUnkF4; - if (o->oElevatorUnk100 == 1) + if (o->oElevatorUnk100 == 1) { o->oAction = 4; - else if (o->oElevatorUnk100 == 2) + } else if (o->oElevatorUnk100 == 2) { o->oAction = 3; - else if (gMarioObject->oPosY > o->oElevatorUnkFC) + } else if (gMarioObject->oPosY > o->oElevatorUnkFC) { o->oAction = 1; - else + } else { o->oAction = 3; + } } } @@ -76,19 +84,20 @@ void elevator_act_4(void) { cur_obj_shake_screen(SHAKE_POS_SMALL); cur_obj_play_sound_2(SOUND_GENERAL_METAL_POUND); } - if (!mario_is_in_air_action() && !cur_obj_is_mario_on_platform()) + if (!mario_is_in_air_action() && !cur_obj_is_mario_on_platform()) { o->oAction = 1; + } } -void elevator_act_3(void) // nearly identical to action 2 -{ +void elevator_act_3(void) { o->oVelY = 0; if (o->oTimer == 0) { cur_obj_shake_screen(SHAKE_POS_SMALL); cur_obj_play_sound_2(SOUND_GENERAL_METAL_POUND); } - if (!mario_is_in_air_action() && !cur_obj_is_mario_on_platform()) + if (!mario_is_in_air_action() && !cur_obj_is_mario_on_platform()) { o->oAction = 0; + } } void bhv_elevator_init(void) { @@ -106,8 +115,13 @@ void bhv_elevator_init(void) { } } -void (*sElevatorActions[])(void) = { elevator_act_0, elevator_act_1, elevator_act_2, elevator_act_3, - elevator_act_4 }; +void (*sElevatorActions[])(void) = { + elevator_act_0, + elevator_act_1, + elevator_act_2, + elevator_act_3, + elevator_act_4, +}; void bhv_elevator_loop(void) { cur_obj_call_action_function(sElevatorActions); diff --git a/src/game/behaviors/end_birds_1.inc.c b/src/game/behaviors/end_birds_1.inc.c index 532c2728..69889724 100644 --- a/src/game/behaviors/end_birds_1.inc.c +++ b/src/game/behaviors/end_birds_1.inc.c @@ -4,24 +4,28 @@ void bhv_end_birds_1_loop(void) { Vec3f sp34; UNUSED f32 sp30 = random_float(); - switch (gCurrentObject->oAction) { + switch (o->oAction) { case 0: cur_obj_scale(0.7f); - gCurrentObject->oIntroLakituUnk110 = -554.f; - gCurrentObject->oIntroLakituUnk10C = 3044.f; - gCurrentObject->oIntroLakituUnk108 = -1314.f; - gCurrentObject->oAction += 1; + o->oIntroLakituUnk110 = -554.0f; + o->oIntroLakituUnk10C = 3044.0f; + o->oIntroLakituUnk108 = -1314.0f; + o->oAction++; break; - case 1: - vec3f_set(sp34, gCurrentObject->oIntroLakituUnk110, gCurrentObject->oIntroLakituUnk10C, - gCurrentObject->oIntroLakituUnk108); - if (gCurrentObject->oTimer < 100) - obj_rotate_towards_point(gCurrentObject, sp34, 0, 0, 0x20, 0x20); - if ((gCurrentObject->oEndBirdUnk104 == 0.f) && (gCurrentObject->oTimer == 0)) + case 1: + vec3f_set(sp34, o->oIntroLakituUnk110, o->oIntroLakituUnk10C, + o->oIntroLakituUnk108); + + if (o->oTimer < 100) { + obj_rotate_towards_point(o, sp34, 0, 0, 0x20, 0x20); + } + if ((o->oEndBirdUnk104 == 0.0f) && (o->oTimer == 0)) { cur_obj_play_sound_2(SOUND_GENERAL_BIRDS_FLY_AWAY); - if (gCutsceneTimer == 0) - obj_mark_for_deletion(gCurrentObject); + } + if (gCutsceneTimer == 0) { + obj_mark_for_deletion(o); + } break; } diff --git a/src/game/behaviors/end_birds_2.inc.c b/src/game/behaviors/end_birds_2.inc.c index 9526448e..388a4781 100644 --- a/src/game/behaviors/end_birds_2.inc.c +++ b/src/game/behaviors/end_birds_2.inc.c @@ -2,28 +2,29 @@ void bhv_end_birds_2_loop(void) { Vec3f sp3C; - UNUSED f32 sp38; + UNUSED f32 sp38 = random_float(); f32 sp34; s16 sp32, sp30; - sp38 = random_float(); - gCurrentObject->oForwardVel = (random_float() * 10.f) + 25.f; + o->oForwardVel = (random_float() * 10.0f) + 25.0f; - switch (gCurrentObject->oAction) { + switch (o->oAction) { case 0: cur_obj_scale(0.7f); - gCurrentObject->oAction += 1; + o->oAction++; break; + case 1: vec3f_get_dist_and_angle(gCamera->pos, gCamera->focus, &sp34, &sp32, &sp30); sp30 += 0x1000; sp32 += 0; // nice work, Nintendo - vec3f_set_dist_and_angle(gCamera->pos, sp3C, 14000.f, sp32, sp30); - obj_rotate_towards_point(gCurrentObject, sp3C, 0, 0, 8, 8); + vec3f_set_dist_and_angle(gCamera->pos, sp3C, 14000.0f, sp32, sp30); + obj_rotate_towards_point(o, sp3C, 0, 0, 8, 8); - if ((gCurrentObject->oEndBirdUnk104 == 0.f) && (gCurrentObject->oTimer == 0)) + if ((o->oEndBirdUnk104 == 0.0f) && (o->oTimer == 0)) { cur_obj_play_sound_2(SOUND_GENERAL_BIRDS_FLY_AWAY); + } break; } diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index 056c3f13..b120d7dc 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -77,14 +77,14 @@ static void enemy_lakitu_update_speed_and_angle(void) { // Turn toward mario except right after throwing a spiny if (o->oEnemyLakituFaceForwardCountdown != 0) { - o->oEnemyLakituFaceForwardCountdown -= 1; + o->oEnemyLakituFaceForwardCountdown--; } else { obj_face_yaw_approach(o->oAngleToMario, 0x600); } // Change move angle toward mario faster when farther from mario turnSpeed = (s16)(distToMario * 2); - clamp_s16(&turnSpeed, 0xC8, 0xFA0); + clamp_s16(&turnSpeed, 200, 4000); cur_obj_rotate_yaw_toward(o->oAngleToMario, turnSpeed); } @@ -96,7 +96,7 @@ static void enemy_lakitu_sub_act_no_spiny(void) { cur_obj_init_animation_with_sound(1); if (o->oEnemyLakituSpinyCooldown != 0) { - o->oEnemyLakituSpinyCooldown -= 1; + o->oEnemyLakituSpinyCooldown--; } else if (o->oEnemyLakituNumSpinies < 3 && o->oDistanceToMario < 800.0f && abs_angle_diff(o->oAngleToMario, o->oFaceAngleYaw) < 0x4000) { struct Object *spiny = spawn_object(o, MODEL_SPINY_BALL, bhvSpiny); @@ -105,7 +105,7 @@ static void enemy_lakitu_sub_act_no_spiny(void) { spiny->oAction = SPINY_ACT_HELD_BY_LAKITU; obj_init_animation_with_sound(spiny, spiny_egg_seg5_anims_050157E4, 0); - o->oEnemyLakituNumSpinies += 1; + o->oEnemyLakituNumSpinies++; o->oSubAction = ENEMY_LAKITU_SUB_ACT_HOLD_SPINY; o->oEnemyLakituSpinyCooldown = 30; } @@ -120,7 +120,7 @@ static void enemy_lakitu_sub_act_hold_spiny(void) { cur_obj_init_anim_extend(3); if (o->oEnemyLakituSpinyCooldown != 0) { - o->oEnemyLakituSpinyCooldown -= 1; + o->oEnemyLakituSpinyCooldown--; } // TODO: Check if anything interesting happens if we bypass this with speed else if (o->oDistanceToMario > o->oDrawingDistance - 100.0f @@ -176,7 +176,7 @@ static void enemy_lakitu_act_main(void) { cur_obj_move_standard(78); // Die and drop held spiny when attacked by mario - if (obj_check_attacks(&sEnemyLakituHitbox, o->oAction)) { + if (obj_check_attacks(&sEnemyLakituHitbox, o->oAction) != 0) { // The spiny uses this as a signal to get thrown o->prevObj = NULL; } diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index eed6df0e..bc664769 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -1,48 +1,59 @@ -// exclamation_box.c.inc +// exclamation_box.inc.c struct ObjectHitbox sExclamationBoxHitbox = { - /* interactType: */ INTERACT_BREAKABLE, - /* downOffset: */ 5, + /* interactType: */ INTERACT_BREAKABLE, + /* downOffset: */ 5, /* damageOrCoinValue: */ 0, - /* health: */ 1, - /* numLootCoins: */ 0, - /* radius: */ 40, - /* height: */ 30, - /* hurtboxRadius: */ 40, - /* hurtboxHeight: */ 30, + /* health: */ 1, + /* numLootCoins: */ 0, + /* radius: */ 40, + /* height: */ 30, + /* hurtboxRadius: */ 40, + /* hurtboxHeight: */ 30, }; -struct Struct802C0DF0 sExclamationBoxContents[] = { { 0, 0, 0, MODEL_MARIOS_WING_CAP, bhvWingCap }, - { 1, 0, 0, MODEL_MARIOS_METAL_CAP, bhvMetalCap }, - { 2, 0, 0, MODEL_MARIOS_CAP, bhvVanishCap }, - { 3, 0, 0, MODEL_KOOPA_SHELL, bhvKoopaShell }, - { 4, 0, 0, MODEL_YELLOW_COIN, - bhvSingleCoinGetsSpawned }, - { 5, 0, 0, MODEL_NONE, bhvThreeCoinsSpawn }, - { 6, 0, 0, MODEL_NONE, bhvTenCoinsSpawn }, - { 7, 0, 0, MODEL_1UP, bhv1upWalking }, - { 8, 0, 0, MODEL_STAR, bhvSpawnedStar }, - { 9, 0, 0, MODEL_1UP, bhv1upRunningAway }, - { 10, 0, 1, MODEL_STAR, bhvSpawnedStar }, - { 11, 0, 2, MODEL_STAR, bhvSpawnedStar }, - { 12, 0, 3, MODEL_STAR, bhvSpawnedStar }, - { 13, 0, 4, MODEL_STAR, bhvSpawnedStar }, - { 14, 0, 5, MODEL_STAR, bhvSpawnedStar }, - { 99, 0, 0, 0, NULL } }; +struct Struct802C0DF0 { + u8 unk0; + u8 unk1; + u8 unk2; + u8 model; + const BehaviorScript *behavior; +}; + +struct Struct802C0DF0 sExclamationBoxContents[] = { + { 0, 0, 0, MODEL_MARIOS_WING_CAP, bhvWingCap }, + { 1, 0, 0, MODEL_MARIOS_METAL_CAP, bhvMetalCap }, + { 2, 0, 0, MODEL_MARIOS_CAP, bhvVanishCap }, + { 3, 0, 0, MODEL_KOOPA_SHELL, bhvKoopaShell }, + { 4, 0, 0, MODEL_YELLOW_COIN, bhvSingleCoinGetsSpawned }, + { 5, 0, 0, MODEL_NONE, bhvThreeCoinsSpawn }, + { 6, 0, 0, MODEL_NONE, bhvTenCoinsSpawn }, + { 7, 0, 0, MODEL_1UP, bhv1upWalking }, + { 8, 0, 0, MODEL_STAR, bhvSpawnedStar }, + { 9, 0, 0, MODEL_1UP, bhv1upRunningAway }, + { 10, 0, 1, MODEL_STAR, bhvSpawnedStar }, + { 11, 0, 2, MODEL_STAR, bhvSpawnedStar }, + { 12, 0, 3, MODEL_STAR, bhvSpawnedStar }, + { 13, 0, 4, MODEL_STAR, bhvSpawnedStar }, + { 14, 0, 5, MODEL_STAR, bhvSpawnedStar }, + { 99, 0, 0, 0, NULL } +}; void bhv_rotating_exclamation_box_loop(void) { - if (o->parentObj->oAction != 1) + if (o->parentObj->oAction != 1) { obj_mark_for_deletion(o); + } } void exclamation_box_act_0(void) { if (o->oBehParams2ndByte < 3) { o->oAnimState = o->oBehParams2ndByte; if ((save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte]) - || ((o->oBehParams >> 24) & 0xFF) != 0) + || ((o->oBehParams >> 24) & 0xFF)) { o->oAction = 2; - else + } else { o->oAction = 1; + } } else { o->oAnimState = 3; o->oAction = 2; @@ -56,7 +67,7 @@ void exclamation_box_act_1(void) { cur_obj_set_model(MODEL_EXCLAMATION_BOX_OUTLINE); } if ((save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte]) - || ((o->oBehParams >> 24) & 0xFF) != 0) { + || ((o->oBehParams >> 24) & 0xFF)) { o->oAction = 2; cur_obj_set_model(MODEL_EXCLAMATION_BOX); } @@ -86,7 +97,7 @@ void exclamation_box_act_2(void) { } void exclamation_box_act_3(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; cur_obj_move_using_fvel_and_gravity(); if (o->oVelY < 0.0f) { o->oVelY = 0.0f; @@ -99,8 +110,9 @@ void exclamation_box_act_3(void) { o->header.gfx.scale[0] = o->oExclamationBoxUnkF4 * 2.0f; o->header.gfx.scale[1] = o->oExclamationBoxUnkF8 * 2.0f; o->header.gfx.scale[2] = o->oExclamationBoxUnkF4 * 2.0f; - if (o->oTimer == 7) + if (o->oTimer == 7) { o->oAction = 4; + } } void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { @@ -113,8 +125,9 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { sp1C->oForwardVel = 3.0f; sp1C->oMoveAngleYaw = gMarioObject->oMoveAngleYaw; o->oBehParams |= a0->unk2 << 24; - if (a0->model == 122) - o->oFlags |= 0x4000; + if (a0->model == MODEL_STAR) { + o->oFlags |= OBJ_FLAG_PERSISTENT_RESPAWN; + } break; } a0++; @@ -129,18 +142,25 @@ void exclamation_box_act_4(void) { if (o->oBehParams2ndByte < 3) { o->oAction = 5; cur_obj_hide(); - } else + } else { obj_mark_for_deletion(o); + } } void exclamation_box_act_5(void) { - if (o->oTimer > 300) + if (o->oTimer > 300) { o->oAction = 2; + } } -void (*sExclamationBoxActions[])(void) = { exclamation_box_act_0, exclamation_box_act_1, - exclamation_box_act_2, exclamation_box_act_3, - exclamation_box_act_4, exclamation_box_act_5 }; +void (*sExclamationBoxActions[])(void) = { + exclamation_box_act_0, + exclamation_box_act_1, + exclamation_box_act_2, + exclamation_box_act_3, + exclamation_box_act_4, + exclamation_box_act_5, +}; void bhv_exclamation_box_loop(void) { cur_obj_scale(2.0f); diff --git a/src/game/behaviors/explosion.inc.c b/src/game/behaviors/explosion.inc.c index 75428d56..9122499c 100644 --- a/src/game/behaviors/explosion.inc.c +++ b/src/game/behaviors/explosion.inc.c @@ -1,4 +1,4 @@ -// explosion.c.inc +// explosion.inc.c void bhv_explosion_init(void) { create_sound_spawner(SOUND_GENERAL2_BOBOMB_EXPLOSION); @@ -12,10 +12,12 @@ void bhv_explosion_loop(void) { if (o->oTimer == 9) { if (find_water_level(o->oPosX, o->oPosZ) > o->oPosY) { - for (i = 0; i < 40; i++) + for (i = 0; i < 40; i++) { spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvBobombExplosionBubble); - } else + } + } else { spawn_object(o, MODEL_SMOKE, bhvBobombBullyDeathSmoke); + } o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/express_elevator.inc.c b/src/game/behaviors/express_elevator.inc.c index f3536384..eaadc393 100644 --- a/src/game/behaviors/express_elevator.inc.c +++ b/src/game/behaviors/express_elevator.inc.c @@ -1,19 +1,22 @@ -// express_elevator.c.inc +// express_elevator.inc.c void bhv_wdw_express_elevator_loop(void) { o->oVelY = 0.0f; if (o->oAction == 0) { - if (cur_obj_is_mario_on_platform()) + if (cur_obj_is_mario_on_platform()) { o->oAction++; + } } else if (o->oAction == 1) { o->oVelY = -20.0f; o->oPosY += o->oVelY; cur_obj_play_sound_1(SOUND_ENV_ELEVATOR4); - if (o->oTimer > 132) + if (o->oTimer > 132) { o->oAction++; + } } else if (o->oAction == 2) { - if (o->oTimer > 110) + if (o->oTimer > 110) { o->oAction++; + } } else if (o->oAction == 3) { o->oVelY = 10.0f; o->oPosY += o->oVelY; @@ -22,6 +25,7 @@ void bhv_wdw_express_elevator_loop(void) { o->oPosY = o->oHomeY; o->oAction++; } - } else if (!cur_obj_is_mario_on_platform()) + } else if (!cur_obj_is_mario_on_platform()) { o->oAction = 0; + } } diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c index b22cff34..89799afd 100644 --- a/src/game/behaviors/eyerok.inc.c +++ b/src/game/behaviors/eyerok.inc.c @@ -1,3 +1,5 @@ +// eyerok.inc.c + struct ObjectHitbox sEyerokHitbox = { /* interactType: */ INTERACT_BOUNCE_TOP, /* downOffset: */ 0, @@ -21,9 +23,8 @@ static s32 eyerok_check_mario_relative_z(s32 arg0) { } static void eyerok_spawn_hand(s16 side, s32 model, const BehaviorScript *behavior) { - struct Object *hand; - - hand = spawn_object_relative_with_scale(side, -500 * side, 0, 300, 1.5f, o, model, behavior); + struct Object *hand = spawn_object_relative_with_scale(side, -500 * side, 0, 300, 1.5f, + o, model, behavior); if (hand != NULL) { hand->oFaceAngleYaw -= 0x4000 * side; } @@ -44,17 +45,17 @@ static void eyerok_boss_act_wake_up(void) { if (o->oTimer > 5) { if (o->oSubAction == 0) { seq_player_lower_volume(SEQ_PLAYER_LEVEL, 60, 40); - o->oSubAction += 1; + o->oSubAction++; } - if (o->oEyerokBossUnk110 == 0.0f && mario_ready_to_speak() != 0) { + if (o->oEyerokBossUnk110 == 0.0f && mario_ready_to_speak()) { o->oAction = EYEROK_BOSS_ACT_SHOW_INTRO_TEXT; } else if (o->oTimer > 150) { if (approach_f32_ptr(&o->oEyerokBossUnk110, 0.0f, 10.0f)) { o->oTimer = 0; } } else if (o->oTimer > 90) { - approach_f32_ptr(&o->oEyerokBossUnk110, 300.f, 10.0f); + approach_f32_ptr(&o->oEyerokBossUnk110, 300.0f, 10.0f); } } } else { @@ -75,22 +76,22 @@ static void eyerok_boss_act_fight(void) { if (o->oEyerokBossUnk104 != 0) { if (approach_f32_ptr(&o->oEyerokBossUnk110, 1.0f, 0.02f)) { if (o->oEyerokBossUnk104 < 0) { - if (eyerok_check_mario_relative_z(400) == 0 && ++o->oEyerokBossUnk104 == 0) { + if (!eyerok_check_mario_relative_z(400) && ++o->oEyerokBossUnk104 == 0) { o->oEyerokBossUnk104 = 1; } } else { - o->oEyerokBossUnk104 -= 1; + o->oEyerokBossUnk104--; } if (o->oEyerokBossUnk104 != 0 && o->oEyerokBossUnk104 != 1) { - o->oEyerokBossUnkFC += 1; + o->oEyerokBossUnkFC++; if ((o->oEyerokBossActiveHand = o->oEyerokBossUnkFC & 0x1) == 0) { o->oEyerokBossActiveHand = -1; } } } } else { - o->oEyerokBossUnkFC += 1; + o->oEyerokBossUnkFC++; if (eyerok_check_mario_relative_z(400)) { o->oEyerokBossUnk104 = -8; @@ -120,7 +121,7 @@ static void eyerok_boss_act_die(void) { if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_NONE, CUTSCENE_DIALOG, DIALOG_118)) { spawn_default_star(0.0f, -900.0f, -3700.0f); } else { - o->oTimer -= 1; + o->oTimer--; } } else if (o->oTimer > 120) { stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); @@ -156,7 +157,7 @@ static s32 eyerok_hand_check_attacked(void) { o->oAction = EYEROK_HAND_ACT_ATTACKED; o->oVelY = 30.0f; } else { - o->parentObj->oEyerokBossNumHands -= 1; + o->parentObj->oEyerokBossNumHands--; o->oAction = EYEROK_HAND_ACT_DIE; o->oVelY = 50.0f; } @@ -183,7 +184,7 @@ static void eyerok_hand_act_sleep(void) { if (o->parentObj->oAction != EYEROK_BOSS_ACT_SLEEP && ++o->oEyerokHandWakeUpTimer > -3 * o->oBehParams2ndByte) { if (cur_obj_check_if_near_animation_end()) { - o->parentObj->oEyerokBossNumHands += 1; + o->parentObj->oEyerokBossNumHands++; o->oAction = EYEROK_HAND_ACT_IDLE; o->collisionData = segmented_to_virtual(&ssl_seg7_collision_07028274); } else { @@ -216,7 +217,7 @@ static void eyerok_hand_act_idle(void) { } } else if (o->parentObj->oEyerokBossUnk1AC == 0 && o->parentObj->oEyerokBossActiveHand != 0) { if (o->parentObj->oEyerokBossActiveHand == o->oBehParams2ndByte) { - if (eyerok_check_mario_relative_z(400) != 0 || random_u16() % 2 != 0) { + if (eyerok_check_mario_relative_z(400) || random_u16() % 2 != 0) { o->oAction = EYEROK_HAND_ACT_TARGET_MARIO; o->oMoveAngleYaw = o->oAngleToMario; o->oGravity = 0.0f; @@ -262,23 +263,21 @@ static void eyerok_hand_act_open(void) { } static void eyerok_hand_act_show_eye(void) { - UNUSED s16 val06; - cur_obj_init_animation_with_sound(5); cur_obj_play_sound_at_anim_range(0, 0, SOUND_OBJ_EYEROK_SHOW_EYE); if (!eyerok_hand_check_attacked()) { if (o->parentObj->oEyerokBossActiveHand == 0) { if (o->oAnimState < 3) { - o->oAnimState += 1; + o->oAnimState++; } else if (cur_obj_check_if_near_animation_end()) { - val06 = (s16)(o->oAngleToMario - o->oFaceAngleYaw) * o->oBehParams2ndByte; + UNUSED s16 val06 = (s16)(o->oAngleToMario - o->oFaceAngleYaw) * o->oBehParams2ndByte; o->oAction = EYEROK_HAND_ACT_CLOSE; } } else { if (o->oEyerokHandUnk100--) { if (o->oEyerokHandUnkFC != 0) { - o->oEyerokHandUnkFC -= 1; + o->oEyerokHandUnkFC--; } o->oAnimState = D_80331BA4[o->oEyerokHandUnkFC]; } else { @@ -373,7 +372,7 @@ static void eyerok_hand_act_retreat(void) { } static void eyerok_hand_act_target_mario(void) { - if (eyerok_check_mario_relative_z(400) != 0 || o->oPosZ - gMarioObject->oPosZ > 0.0f + if (eyerok_check_mario_relative_z(400) || o->oPosZ - gMarioObject->oPosZ > 0.0f || o->oPosZ - o->parentObj->oPosZ > 1700.0f || absf(o->oPosX - o->parentObj->oPosX) > 900.0f || (o->oMoveFlags & OBJ_MOVE_HIT_WALL)) { o->oForwardVel = 0.0f; @@ -388,15 +387,13 @@ static void eyerok_hand_act_target_mario(void) { } static void eyerok_hand_act_smash(void) { - s16 sp1E; - if (o->oTimer > 20) { if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { if (o->oGravity < -4.0f) { eyerok_hand_pound_ground(); o->oGravity = -4.0f; } else { - sp1E = abs_angle_diff(o->oFaceAngleYaw, o->oAngleToMario); + s16 sp1E = abs_angle_diff(o->oFaceAngleYaw, o->oAngleToMario); if (o->oDistanceToMario < 300.0f && sp1E > 0x2000 && sp1E < 0x6000) { o->oAction = EYEROK_HAND_ACT_FIST_SWEEP; if ((s16)(o->oFaceAngleYaw - o->oAngleToMario) < 0) { @@ -441,15 +438,13 @@ static void eyerok_hand_act_fist_sweep(void) { } static void eyerok_hand_act_begin_double_pound(void) { - f32 sp4; - if (o->parentObj->oEyerokBossUnk104 < 0 || o->parentObj->oEyerokBossActiveHand == o->oBehParams2ndByte) { o->oAction = EYEROK_HAND_ACT_DOUBLE_POUND; o->oMoveAngleYaw = (s32)(o->oFaceAngleYaw - 0x4000 * o->parentObj->oEyerokBossUnk108); } else { - sp4 = o->parentObj->oPosX + 400.0f * o->parentObj->oEyerokBossUnk108 - - 180.0f * o->oBehParams2ndByte; + f32 sp4 = o->parentObj->oPosX + 400.0f * o->parentObj->oEyerokBossUnk108 + - 180.0f * o->oBehParams2ndByte; o->oPosX = o->oHomeX + (sp4 - o->oHomeX) * o->parentObj->oEyerokBossUnk110; o->oPosY = o->oHomeY + 300.0f * o->parentObj->oEyerokBossUnk110; diff --git a/src/game/behaviors/falling_pillar.inc.c b/src/game/behaviors/falling_pillar.inc.c index 5c53b283..6d8fe380 100644 --- a/src/game/behaviors/falling_pillar.inc.c +++ b/src/game/behaviors/falling_pillar.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for the falling pillars inside the underwater cave area of * Jolly Roger Bay. @@ -42,13 +43,10 @@ void bhv_falling_pillar_spawn_hitboxes(void) { * Mario. */ s16 bhv_falling_pillar_calculate_angle_in_front_of_mario(void) { - f32 targetX; - f32 targetZ; - // Calculate target to be 500 units in front of Mario in // the direction he is facing (angle[1] is yaw). - targetX = sins(gMarioObject->header.gfx.angle[1]) * 500.0f + gMarioObject->header.gfx.pos[0]; - targetZ = coss(gMarioObject->header.gfx.angle[1]) * 500.0f + gMarioObject->header.gfx.pos[2]; + f32 targetX = sins(gMarioObject->header.gfx.angle[1]) * 500.0f + gMarioObject->header.gfx.pos[0]; + f32 targetZ = coss(gMarioObject->header.gfx.angle[1]) * 500.0f + gMarioObject->header.gfx.pos[2]; // Calculate the angle to the target from the pillar's current location. return atan2s(targetZ - o->oPosZ, targetX - o->oPosX); @@ -59,6 +57,7 @@ s16 bhv_falling_pillar_calculate_angle_in_front_of_mario(void) { */ void bhv_falling_pillar_loop(void) { s16 angleInFrontOfMario; + switch (o->oAction) { case FALLING_PILLAR_ACT_IDLE: // When Mario is within 1300 units of distance... @@ -86,8 +85,9 @@ void bhv_falling_pillar_loop(void) { o->oFaceAngleYaw = approach_s16_symmetric(o->oFaceAngleYaw, angleInFrontOfMario, 0x400); // After 10 ticks, start falling. - if (o->oTimer > 10) + if (o->oTimer > 10) { o->oAction = FALLING_PILLAR_ACT_FALLING; + } break; case FALLING_PILLAR_ACT_FALLING: @@ -139,6 +139,7 @@ void bhv_falling_pillar_hitbox_loop(void) { obj_set_hitbox(o, &sFallingPillarHitbox); // When the pillar goes inactive, the hitboxes also go inactive. - if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } diff --git a/src/game/behaviors/falling_rising_platform.inc.c b/src/game/behaviors/falling_rising_platform.inc.c index faddc2f4..38dd7192 100644 --- a/src/game/behaviors/falling_rising_platform.inc.c +++ b/src/game/behaviors/falling_rising_platform.inc.c @@ -1,4 +1,4 @@ -// falling_rising_platform.c.inc +// falling_rising_platform.inc.c void bhv_squishable_platform_loop(void) { o->header.gfx.scale[1] = (sins(o->oBitfsPlatformTimer) + 1.0) * 0.3 + 0.4; @@ -6,9 +6,8 @@ void bhv_squishable_platform_loop(void) { } void bhv_bitfs_sinking_platform_loop(void) { - o->oPosY -= - sins(o->oBitfsPlatformTimer) - * 0.58; //! f32 double conversion error accumulates on Wii VC causing the platform to rise up + //! f32 double conversion error accumulates on Wii VC causing the platform to rise up + o->oPosY -= sins(o->oBitfsPlatformTimer) * 0.58; o->oBitfsPlatformTimer += 0x100; } @@ -19,10 +18,13 @@ void bhv_ddd_moving_pole_loop(void) { void bhv_bitfs_sinking_cage_platform_loop(void) { if (o->oBehParams2ndByte != 0) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oPosY -= 300.0f; + } o->oPosY += sins(o->oBitfsPlatformTimer) * 7.0f; - } else + } else { o->oPosY -= sins(o->oBitfsPlatformTimer) * 3.0f; + } + o->oBitfsPlatformTimer += 0x100; } diff --git a/src/game/behaviors/ferris_wheel.inc.c b/src/game/behaviors/ferris_wheel.inc.c index 5eb12617..2fdaf047 100644 --- a/src/game/behaviors/ferris_wheel.inc.c +++ b/src/game/behaviors/ferris_wheel.inc.c @@ -9,8 +9,8 @@ * Properties for the ferris wheel axle and platforms. */ struct FerrisWheelProperties { - void const *axleCollision; - void const *platformCollision; + Collision const *axleCollision; + Collision const *platformCollision; s16 platformModel; }; @@ -31,7 +31,8 @@ void bhv_ferris_wheel_axle_init(void) { struct Object *platform; s32 i; - o->collisionData = segmented_to_virtual(sFerrisWheelProperties[o->oBehParams2ndByte].axleCollision); + o->collisionData = + segmented_to_virtual(sFerrisWheelProperties[o->oBehParams2ndByte].axleCollision); for (i = 0; i < 4; i++) { platform = spawn_object_relative(i, 0, 0, 0, o, diff --git a/src/game/behaviors/fire_piranha_plant.inc.c b/src/game/behaviors/fire_piranha_plant.inc.c index a6d867b2..be1ea9cb 100644 --- a/src/game/behaviors/fire_piranha_plant.inc.c +++ b/src/game/behaviors/fire_piranha_plant.inc.c @@ -1,3 +1,5 @@ +// fire_piranha_plant.inc.c + struct ObjectHitbox sFirePiranhaPlantHitbox = { /* interactType: */ INTERACT_BOUNCE_TOP, /* downOffset: */ 0, @@ -35,7 +37,7 @@ void bhv_fire_piranha_plant_init(void) { obj_set_hitbox(o, &sFirePiranhaPlantHitbox); if ((u16)(o->oBehParams >> 16) != 0) { - o->oFlags |= 0x00004000; + o->oFlags |= OBJ_FLAG_PERSISTENT_RESPAWN; o->oHealth = 1; if (o->oBehParams & 0x0000FF00) { @@ -44,6 +46,7 @@ void bhv_fire_piranha_plant_init(void) { o->oNumLootCoins = 2; } } + sNumActiveFirePiranhaPlants = sNumKilledFirePiranhaPlants = 0; } @@ -52,16 +55,16 @@ static void fire_piranha_plant_act_hide(void) { o->oMoveAngleYaw += (s32) o->oFirePiranhaPlantDeathSpinVel; approach_f32_ptr(&o->oFirePiranhaPlantDeathSpinVel, 0.0f, 200.0f); - if (cur_obj_check_if_near_animation_end()) { - if (--o->oFirePiranhaPlantDeathSpinTimer == 0) { - cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK); - } + if (cur_obj_check_if_near_animation_end() + && --o->oFirePiranhaPlantDeathSpinTimer == 0) { + cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK); } } else if (approach_f32_ptr(&o->oFirePiranhaPlantScale, 0.0f, 0.04f * o->oFirePiranhaPlantNeutralScale)) { cur_obj_become_intangible(); + if (o->oFirePiranhaPlantActive) { - sNumActiveFirePiranhaPlants -= 1; + sNumActiveFirePiranhaPlants--; o->oFirePiranhaPlantActive = FALSE; if ((u16)(o->oBehParams >> 16) != 0 && o->oHealth == 0) { @@ -72,12 +75,12 @@ static void fire_piranha_plant_act_hide(void) { obj_die_if_health_non_positive(); set_object_respawn_info_bits(o, 1); } - } else if (sNumActiveFirePiranhaPlants < 2 && o->oTimer > 100 && o->oDistanceToMario > 100.0f - && o->oDistanceToMario < 800.0f) { + } else if (sNumActiveFirePiranhaPlants < 2 && o->oTimer > 100 + && o->oDistanceToMario > 100.0f && o->oDistanceToMario < 800.0f) { cur_obj_play_sound_2(SOUND_OBJ_PIRANHA_PLANT_APPEAR); o->oFirePiranhaPlantActive = TRUE; - sNumActiveFirePiranhaPlants += 1; + sNumActiveFirePiranhaPlants++; cur_obj_unhide(); o->oAction = FIRE_PIRANHA_PLANT_ACT_GROW; @@ -101,16 +104,12 @@ static void fire_piranha_plant_act_grow(void) { cur_obj_init_animation_with_sound(0); } else if (o->oTimer < 50) { cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400); - } else { // TODO: Check if we can put these conditionals on same line - if (obj_is_rendering_enabled()) { - if (cur_obj_check_anim_frame(56)) { - cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN); - obj_spit_fire(0, (s32)(30.0f * o->oFirePiranhaPlantNeutralScale), - (s32)(140.0f * o->oFirePiranhaPlantNeutralScale), - 2.5f * o->oFirePiranhaPlantNeutralScale, MODEL_RED_FLAME_SHADOW, - 20.0f, 15.0f, 0x1000); - } - } + } else if (obj_is_rendering_enabled() && cur_obj_check_anim_frame(56)) { + cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN); + obj_spit_fire(0, (s32)(30.0f * o->oFirePiranhaPlantNeutralScale), + (s32)(140.0f * o->oFirePiranhaPlantNeutralScale), + 2.5f * o->oFirePiranhaPlantNeutralScale, MODEL_RED_FLAME_SHADOW, + 20.0f, 15.0f, 0x1000); } } else if (o->oFirePiranhaPlantScale > o->oFirePiranhaPlantNeutralScale / 2) { cur_obj_become_tangible(); @@ -129,10 +128,10 @@ void bhv_fire_piranha_plant_update(void) { break; } - if (obj_check_attacks(&sFirePiranhaPlantHitbox, o->oAction)) { + if (obj_check_attacks(&sFirePiranhaPlantHitbox, o->oAction) != 0) { if (--o->oHealth < 0) { if (o->oFirePiranhaPlantActive) { - sNumActiveFirePiranhaPlants -= 1; + sNumActiveFirePiranhaPlants--; } } else { cur_obj_init_animation_with_sound(2); diff --git a/src/game/behaviors/fire_spitter.inc.c b/src/game/behaviors/fire_spitter.inc.c index 2a59a803..ce6e5255 100644 --- a/src/game/behaviors/fire_spitter.inc.c +++ b/src/game/behaviors/fire_spitter.inc.c @@ -1,6 +1,8 @@ +// fire_spitter.inc.c static void fire_spitter_act_idle(void) { approach_f32_ptr(&o->header.gfx.scale[0], 0.2f, 0.002f); + if (o->oTimer > 150 && o->oDistanceToMario < 800.0f && !(o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER)) { o->oAction = FIRE_SPITTER_ACT_SPIT_FIRE; o->oFireSpitterScaleVel = 0.05f; @@ -16,6 +18,7 @@ static void fire_spitter_act_spit_fire(void) { // starting moving scale by 0.05 each frame toward 0.1. The first time // it becomes below 0.15 during this latter portion, shoot fire. scaleStatus = obj_grow_then_shrink(&o->oFireSpitterScaleVel, 0.15f, 0.1f); + if (scaleStatus != 0) { if (scaleStatus < 0) { o->oAction = FIRE_SPITTER_ACT_IDLE; diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index 33cc6028..7ef29699 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -1,3 +1,4 @@ + /** * @file fish.inc.c * Implements behaviour and spawning for fish located in the Secret Aquarium and other levels. @@ -13,10 +14,8 @@ static void fish_spawner_act_spawn(void) { s16 model; f32 minDistToMario; const struct Animation * const *fishAnimation; - struct Object *fishObject; switch (o->oBehParams2ndByte) { - // Cases need to be on one line to match with and without optimizations. case FISH_SPAWNER_BP_MANY_BLUE: model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; @@ -35,13 +34,12 @@ static void fish_spawner_act_spawn(void) { break; } - // Spawn and animate the schoolQuantity of fish if Mario enters render distance // or the stage is Secret Aquarium. // Fish moves randomly within a range of 700.0f. if (o->oDistanceToMario < minDistToMario || gCurrLevelNum == LEVEL_SA) { for (i = 0; i < schoolQuantity; i++) { - fishObject = spawn_object(o, model, bhvFish); + struct Object *fishObject = spawn_object(o, model, bhvFish); fishObject->oBehParams2ndByte = o->oBehParams2ndByte; obj_init_animation_with_sound(fishObject, fishAnimation, 0); obj_translate_xyz_random(fishObject, 700.0f); @@ -68,7 +66,9 @@ static void fish_spawner_act_respawn(void) { } static void (*sFishSpawnerActions[])(void) = { - fish_spawner_act_spawn, fish_spawner_act_idle, fish_spawner_act_respawn, + fish_spawner_act_spawn, + fish_spawner_act_idle, + fish_spawner_act_respawn, }; void bhv_fish_spawner_loop(void) { @@ -122,7 +122,7 @@ static void fish_act_roam(void) { } o->oFishGoalY = gMarioObject->oPosY + o->oFishHeightOffset; - + // Rotate the fish towards Mario. cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400); @@ -156,6 +156,7 @@ static void fish_act_roam(void) { static void fish_act_flee(void) { f32 fishY = o->oPosY - gMarioObject->oPosY; UNUSED s32 distance; + o->oFishGoalY = gMarioObject->oPosY + o->oFishHeightOffset; // Initialize some variables when the flee action first starts. @@ -163,12 +164,15 @@ static void fish_act_flee(void) { o->oFishActiveDistance = random_float() * 300.0f; o->oFishYawVel = random_float() * 1024.0f + 1024.0f; o->oFishGoalVel = random_float() * 4.0f + 8.0f + 5.0f; + if (o->oDistanceToMario < 600.0f) { distance = 1; } else { distance = (s32)(1.0 / (o->oDistanceToMario / 600.0)); } + distance *= 127; + cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER); } @@ -183,6 +187,7 @@ static void fish_act_flee(void) { if (o->oForwardVel < o->oFishGoalVel) { o->oForwardVel = o->oForwardVel + 0.5; } + o->oFishGoalY = gMarioObject->oPosY + o->oFishHeightOffset; // Rotate fish away from Mario. @@ -198,7 +203,7 @@ static void fish_act_flee(void) { } else { fish_vertical_roam(4); } - + // Don't let the fish leave the water vertically. } else { o->oPosY = o->oFishWaterLevel - 50.0f; @@ -225,15 +230,16 @@ static void fish_act_init(void) { } static void (*sFishActions[])(void) = { - fish_act_init, fish_act_roam, fish_act_flee, + fish_act_init, + fish_act_roam, + fish_act_flee, }; /** * Main loop for fish */ -void bhv_fish_loop(void) -{ - UNUSED s32 unused[4]; +void bhv_fish_loop(void) { + UNUSED u8 filler[16]; cur_obj_scale(1.0f); // oFishWaterLevel tracks if a fish has roamed out of water. diff --git a/src/game/behaviors/fishing_boo.inc.c b/src/game/behaviors/fishing_boo.inc.c index 12189464..dffe8d69 100644 --- a/src/game/behaviors/fishing_boo.inc.c +++ b/src/game/behaviors/fishing_boo.inc.c @@ -1,4 +1,4 @@ -// fishing_boo.c.inc +// fishing_boo.inc.c // Unused behavior file for the Fishing Boo enemy. // The fire circles around mario and would make it @@ -10,6 +10,7 @@ void bhv_beta_moving_flames_spawn_loop(void) { o->oDistanceToMario = lateral_dist_between_objects(o, gMarioObject); o->oPosY -= 100.0f; + switch (o->oAction) { case 0: case 1: @@ -32,6 +33,7 @@ void bhv_beta_moving_flames_spawn_loop(void) { void bhv_beta_moving_flames_loop(void) { cur_obj_scale(5.0f); + o->oForwardVel = sins(o->oMovingFlameTimer) * 70.0f; o->oMovingFlameTimer += 0x800; } diff --git a/src/game/behaviors/flame.inc.c b/src/game/behaviors/flame.inc.c index 2508ee55..801b1fa5 100644 --- a/src/game/behaviors/flame.inc.c +++ b/src/game/behaviors/flame.inc.c @@ -6,6 +6,7 @@ void bhv_small_piranha_flame_loop(void) { obj_mark_for_deletion(o); } else { f32 rnd = random_float() - 0.5f; + o->header.gfx.scale[1] = o->header.gfx.scale[2] * (1.0f + 0.7f * rnd); o->header.gfx.scale[0] = o->header.gfx.scale[2] * (0.9f - 0.5f * rnd); @@ -13,6 +14,7 @@ void bhv_small_piranha_flame_loop(void) { } } else { cur_obj_update_floor_and_walls(); + if (approach_f32_ptr(&o->oSmallPiranhaFlameStartSpeed, o->oSmallPiranhaFlameEndSpeed, 0.6f)) { cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200); } @@ -32,7 +34,8 @@ void bhv_small_piranha_flame_loop(void) { obj_check_attacks(&sPiranhaPlantFireHitbox, o->oAction); o->oSmallPiranhaFlameSpeed += o->oSmallPiranhaFlameStartSpeed; - if (o->oSmallPiranhaFlameSpeed > 1500.0f || (o->oMoveFlags & (OBJ_MOVE_HIT_WALL | OBJ_MOVE_MASK_IN_WATER))) { + if (o->oSmallPiranhaFlameSpeed > 1500.0f + || (o->oMoveFlags & (OBJ_MOVE_HIT_WALL | OBJ_MOVE_MASK_IN_WATER))) { obj_die_if_health_non_positive(); } } diff --git a/src/game/behaviors/flame_mario.inc.c b/src/game/behaviors/flame_mario.inc.c index 52e4bae6..c19da1e8 100644 --- a/src/game/behaviors/flame_mario.inc.c +++ b/src/game/behaviors/flame_mario.inc.c @@ -1,4 +1,4 @@ -// flame_mario.c.inc +// flame_mario.inc.c void bhv_black_smoke_upward_loop(void) { spawn_object_with_scale(o, MODEL_BURN_SMOKE, bhvBlackSmokeBowser, o->header.gfx.scale[0]); @@ -8,9 +8,11 @@ void bhv_black_smoke_bowser_loop(void) { if (o->oTimer == 0) { o->oForwardVel = random_float() * 2 + 0.5; o->oMoveAngleYaw = random_u16(); - o->oVelY = 8; + o->oVelY = 8.0f; + o->oBlackSmokeBowserUnkF4 = o->header.gfx.scale[0]; } + o->oMoveAngleYaw += o->oAngleVelYaw; o->oPosY += o->oVelY; } @@ -18,23 +20,30 @@ void bhv_black_smoke_bowser_loop(void) { void bhv_black_smoke_mario_loop(void) { if (o->oTimer == 0) { cur_obj_set_pos_relative(gMarioObject, 0, 0, -30.0f); + o->oForwardVel = random_float() * 2 + 0.5; o->oMoveAngleYaw = (gMarioObject->oMoveAngleYaw + 0x7000) + random_float() * 8192.0f; - o->oVelY = 8; + o->oVelY = 8.0f; } + o->oMoveAngleYaw += o->oAngleVelYaw; o->oPosY += o->oVelY; } void bhv_flame_mario_loop(void) { cur_obj_scale(2.0f); - if (o->oTimer != 0) - if (o->oTimer & 1) + + if (o->oTimer != 0) { + if (o->oTimer & 1) { spawn_object(o, MODEL_BURN_SMOKE, bhvBlackSmokeMario); + } + } + gMarioObject->prevObj = o; // weird? obj_set_parent_relative_pos(o, 40, -120, 0); - if (!(gMarioObject->oMarioParticleFlags & 0x800)) { - o->parentObj->oActiveParticleFlags &= ~0x800; + + if (!(gMarioObject->oMarioParticleFlags & ACTIVE_PARTICLE_FIRE)) { + o->parentObj->oActiveParticleFlags &= ~ACTIVE_PARTICLE_FIRE; obj_mark_for_deletion(o); gMarioObject->prevObj = NULL; } diff --git a/src/game/behaviors/flamethrower.inc.c b/src/game/behaviors/flamethrower.inc.c index 8d78349e..ae0922aa 100644 --- a/src/game/behaviors/flamethrower.inc.c +++ b/src/game/behaviors/flamethrower.inc.c @@ -1,35 +1,49 @@ -// flamethrower.c.inc +// flamethrower.inc.c void bhv_flamethrower_flame_loop(void) { - f32 size; + f32 scale; s32 sp18; + if (o->oTimer == 0) { o->oAnimState = (s32)(random_float() * 10.0f); obj_translate_xyz_random(o, 10.0f); } - if (o->oBehParams2ndByte == 2) - size = o->oTimer * (o->oForwardVel - 6.0f) / 100.0 + 2.0; - else - size = o->oTimer * (o->oForwardVel - 20.0) / 100.0 + 1.0; + + if (o->oBehParams2ndByte == 2) { + scale = o->oTimer * (o->oForwardVel - 6.0f) / 100.0 + 2.0; + } else { + scale = o->oTimer * (o->oForwardVel - 20.0) / 100.0 + 1.0; + } + if (o->oBehParams2ndByte == 3) { o->hitboxHeight = 200.0f; o->hitboxDownOffset = 150.0f; o->oVelY = -28.0f; + cur_obj_update_floor_height(); - if (o->oPosY - 25.0f * size < o->oFloorHeight) { + + if (o->oPosY - 25.0f * scale < o->oFloorHeight) { o->oVelY = 0; - o->oPosY = o->oFloorHeight + 25.0f * size; + o->oPosY = o->oFloorHeight + 25.0f * scale; } + sp18 = o->parentObj->oFlameThowerFlameUnk110 / 1.2; - } else + } else { sp18 = o->parentObj->oFlameThowerFlameUnk110; - cur_obj_scale(size); - if (o->oBehParams2ndByte == 4) + } + + cur_obj_scale(scale); + + if (o->oBehParams2ndByte == 4) { o->oPosY += o->oForwardVel; // weird? - else + } else { cur_obj_move_using_fvel_and_gravity(); - if (o->oTimer > sp18) + } + + if (o->oTimer > sp18) { obj_mark_for_deletion(o); + } + o->oInteractStatus = 0; } @@ -38,35 +52,49 @@ void bhv_flamethrower_loop(void) { f32 flameVel; s32 sp34; s32 model; - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; + if (o->oAction == 0) { - if (gCurrLevelNum != LEVEL_BBH || gMarioOnMerryGoRound == TRUE) - if (o->oDistanceToMario < 2000.0f) - o->oAction++; + if ((gCurrLevelNum != LEVEL_BBH || gMarioOnMerryGoRound == TRUE) + && o->oDistanceToMario < 2000.0f) { + o->oAction++; + } } else if (o->oAction == 1) { model = MODEL_RED_FLAME; flameVel = 95.0f; - if (o->oBehParams2ndByte == 1) + + if (o->oBehParams2ndByte == 1) { model = MODEL_BLUE_FLAME; - if (o->oBehParams2ndByte == 2) + } + + if (o->oBehParams2ndByte == 2) { flameVel = 50.0f; + } + sp34 = 1; - if (o->oTimer < 60) + + if (o->oTimer < 60) { sp34 = 15; - else if (o->oTimer < 74) + } else if (o->oTimer < 74) { sp34 = 75 - o->oTimer; // Range: [15..2] - else + } else { o->oAction++; + } + o->oFlameThowerUnk110 = sp34; + flame = spawn_object_relative(o->oBehParams2ndByte, 0, 0, 0, o, model, bhvFlamethrowerFlame); flame->oForwardVel = flameVel; + cur_obj_play_sound_1(SOUND_AIR_BLOW_FIRE); - } else if (o->oTimer > 60) + } else if (o->oTimer > 60) { o->oAction = 0; + } } void bhv_rr_rotating_bridge_platform_loop(void) { o->oMoveAngleYaw -= 0x80; o->oAngleVelYaw = -0x80; + bhv_flamethrower_loop(); } diff --git a/src/game/behaviors/floating_box.inc.c b/src/game/behaviors/floating_box.inc.c index 166ce6c9..dcfe9490 100644 --- a/src/game/behaviors/floating_box.inc.c +++ b/src/game/behaviors/floating_box.inc.c @@ -1,4 +1,4 @@ -// floating_box.c.inc +// floating_box.inc.c void bhv_jrb_floating_box_loop(void) { o->oPosY = o->oHomeY + sins(o->oTimer * 0x400) * 10.0f; diff --git a/src/game/behaviors/floating_platform.inc.c b/src/game/behaviors/floating_platform.inc.c index 79fe0edd..1dea8a68 100644 --- a/src/game/behaviors/floating_platform.inc.c +++ b/src/game/behaviors/floating_platform.inc.c @@ -1,12 +1,10 @@ -// floating_platform.c.inc +// floating_platform.inc.c f32 floating_platform_find_home_y(void) { struct Surface *sp24; - f32 sp20; - f32 sp1C; + f32 sp20 = find_water_level(o->oPosX, o->oPosZ); + f32 sp1C = find_floor(o->oPosX, o->oPosY, o->oPosZ, &sp24); - sp20 = find_water_level(o->oPosX, o->oPosZ); - sp1C = find_floor(o->oPosX, o->oPosY, o->oPosZ, &sp24); if (sp20 > sp1C + o->oFloatingPlatformUnkFC) { o->oFloatingPlatformUnkF4 = 0; return sp20 + o->oFloatingPlatformUnkFC; @@ -25,40 +23,53 @@ void floating_platform_act_0(void) { if (gMarioObject->platform == o) { o->oFaceAnglePitch = sp4 * 2; o->oFaceAngleRoll = -sp6 * 2; + o->oVelY -= 1.0f; - if (o->oVelY < 0.0f) + if (o->oVelY < 0.0f) { o->oVelY = 0.0f; + } o->oFloatingPlatformUnkF8 += o->oVelY; - if (o->oFloatingPlatformUnkF8 > 90.0f) + + if (o->oFloatingPlatformUnkF8 > 90.0f) { o->oFloatingPlatformUnkF8 = 90.0f; + } } else { o->oFaceAnglePitch /= 2; o->oFaceAngleRoll /= 2; + o->oFloatingPlatformUnkF8 -= 5.0; + o->oVelY = 10.0f; - if (o->oFloatingPlatformUnkF8 < 0.0f) + + if (o->oFloatingPlatformUnkF8 < 0.0f) { o->oFloatingPlatformUnkF8 = 0.0f; + } } - o->oPosY = o->oHomeY - 64.0f - o->oFloatingPlatformUnkF8 + sins(o->oFloatingPlatformUnk100 * 0x800) * 10.0f; + o->oPosY = o->oHomeY - 64.0f - o->oFloatingPlatformUnkF8 + + sins(o->oFloatingPlatformUnk100 * 0x800) * 10.0f; + o->oFloatingPlatformUnk100++; - if (o->oFloatingPlatformUnk100 == 32) + + if (o->oFloatingPlatformUnk100 == 32) { o->oFloatingPlatformUnk100 = 0; + } } void bhv_floating_platform_loop(void) { o->oHomeY = floating_platform_find_home_y(); - if (o->oFloatingPlatformUnkF4 == 0) + + if (o->oFloatingPlatformUnkF4 == 0) { o->oAction = 0; - else + } else { o->oAction = 1; + } switch (o->oAction) { case 0: floating_platform_act_0(); break; - case 1: o->oPosY = o->oHomeY; break; diff --git a/src/game/behaviors/fly_guy.inc.c b/src/game/behaviors/fly_guy.inc.c index 4ae1f844..d5911582 100644 --- a/src/game/behaviors/fly_guy.inc.c +++ b/src/game/behaviors/fly_guy.inc.c @@ -29,11 +29,13 @@ static s16 sFlyGuyJitterAmounts[] = { 0x1000, -0x2000, 0x2000 }; */ static void fly_guy_act_idle(void) { o->oForwardVel = 0.0f; + if (approach_f32_ptr(&o->header.gfx.scale[0], 1.5f, 0.02f)) { // If we are >2000 units from home or Mario is <2000 units from us if (o->oDistanceToMario >= 25000.0f || o->oDistanceToMario < 2000.0f) { // Turn toward home or Mario obj_face_yaw_approach(o->oAngleToMario, 0x300); + if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x300)) { o->oAction = FLY_GUY_ACT_APPROACH_MARIO; } @@ -45,7 +47,7 @@ static void fly_guy_act_idle(void) { o->oAction = FLY_GUY_ACT_APPROACH_MARIO; } else { o->oFlyGuyUnusedJitter = o->oMoveAngleYaw + sFlyGuyJitterAmounts[o->oFlyGuyIdleTimer]; - o->oFlyGuyIdleTimer += 1; + o->oFlyGuyIdleTimer++; } } } @@ -66,20 +68,19 @@ static void fly_guy_act_approach_mario(void) { // If facing toward mario and we are either near mario laterally or // far above him - if (abs_angle_diff(o->oAngleToMario, o->oFaceAngleYaw) < 0x2000) { - if (o->oPosY - gMarioObject->oPosY > 400.0f || o->oDistanceToMario < 400.0f) { - // Either shoot fire or lunge - if (o->oBehParams2ndByte != 0 && random_u16() % 2) { - o->oAction = FLY_GUY_ACT_SHOOT_FIRE; - o->oFlyGuyScaleVel = 0.06f; - } else { - o->oAction = FLY_GUY_ACT_LUNGE; - o->oFlyGuyLungeTargetPitch = obj_turn_pitch_toward_mario(-200.0f, 0); + if (abs_angle_diff(o->oAngleToMario, o->oFaceAngleYaw) < 0x2000 + && (o->oPosY - gMarioObject->oPosY > 400.0f || o->oDistanceToMario < 400.0f)) { + // Either shoot fire or lunge + if (o->oBehParams2ndByte != 0 && random_u16() % 2) { + o->oAction = FLY_GUY_ACT_SHOOT_FIRE; + o->oFlyGuyScaleVel = 0.06f; + } else { + o->oAction = FLY_GUY_ACT_LUNGE; + o->oFlyGuyLungeTargetPitch = obj_turn_pitch_toward_mario(-200.0f, 0); - o->oForwardVel = 25.0f * coss(o->oFlyGuyLungeTargetPitch); - o->oVelY = 25.0f * -sins(o->oFlyGuyLungeTargetPitch); - o->oFlyGuyLungeYDecel = -o->oVelY / 30.0f; - } + o->oForwardVel = 25.0f * coss(o->oFlyGuyLungeTargetPitch); + o->oVelY = 25.0f * -sins(o->oFlyGuyLungeTargetPitch); + o->oFlyGuyLungeYDecel = -o->oVelY / 30.0f; } } } else if (obj_forward_vel_approach(0.0f, 0.2f)) { @@ -107,7 +108,7 @@ static void fly_guy_act_lunge(void) { // Twirl back upward obj_face_pitch_approach(0, 0x100); - obj_face_roll_approach(o->oFlyGuyTargetRoll, 0x12C); + obj_face_roll_approach(o->oFlyGuyTargetRoll, 300); // Twirl in a spiral with curvature proportional to oFaceAngleRoll o->oMoveAngleYaw -= o->oFaceAngleRoll / 4; @@ -131,17 +132,18 @@ static void fly_guy_act_lunge(void) { * Turn toward mario, then shoot fire. Then enter the idle action. */ static void fly_guy_act_shoot_fire(void) { - s32 scaleStatus; - o->oForwardVel = 0.0f; if (obj_face_yaw_approach(o->oAngleToMario, 0x800)) { + s32 scaleStatus; + o->oMoveAngleYaw = o->oFaceAngleYaw; // Increase scale by 0.06, 0.05, ..., -0.03. Then wait ~8 frames, then // starting moving scale by 0.05 each frame toward 1.1. The first time // it becomes below 1.2 during this latter portion, shoot fire. scaleStatus = obj_grow_then_shrink(&o->oFlyGuyScaleVel, 1.2f, 1.1f); + if (scaleStatus != 0) { if (scaleStatus < 0) { // We have reached scale 1.1 @@ -149,6 +151,7 @@ static void fly_guy_act_shoot_fire(void) { } else { // We have reached below scale 1.2 in the shrinking portion s16 fireMovePitch = obj_turn_pitch_toward_mario(0.0f, 0); + cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN); clamp_s16(&fireMovePitch, 0x800, 0x3000); @@ -190,7 +193,7 @@ void bhv_fly_guy_update(void) { } // Oscillate up and down - o->oFlyGuyOscTimer += 1; + o->oFlyGuyOscTimer++; o->oPosY += coss(0x400 * o->oFlyGuyOscTimer) * 1.5f; switch (o->oAction) { diff --git a/src/game/behaviors/flying_bookend_switch.inc.c b/src/game/behaviors/flying_bookend_switch.inc.c index 370265de..91d7fdc9 100644 --- a/src/game/behaviors/flying_bookend_switch.inc.c +++ b/src/game/behaviors/flying_bookend_switch.inc.c @@ -38,9 +38,12 @@ struct ObjectHitbox sBookSwitchHitbox = { void flying_bookend_act_0(void) { if (obj_is_near_to_and_facing_mario(400.0f, 0x3000)) { cur_obj_play_sound_2(SOUND_OBJ_DEFAULT_DEATH); + o->oAction = 1; + o->oBookendUnkF4 = o->oFaceAnglePitch + 0x7FFF; o->oBookendUnkF8 = o->oFaceAngleRoll - 0x7FFF; + cur_obj_set_model(MODEL_BOOKEND_PART); } } @@ -52,6 +55,7 @@ void flying_bookend_act_1(void) { o->oForwardVel = 0.0f; } else { o->oForwardVel = 3.0f; + if (o->oTimer > 5) { obj_face_pitch_approach(o->oBookendUnkF4, 2000); if (o->oTimer >= 10) { @@ -88,7 +92,7 @@ void flying_bookend_act_3(void) { o->oDamageOrCoinValue = 1; o->oNumLootCoins = 0; - if (o->oTimer >= 4) { + if (o->oTimer > 3) { o->oAction = 2; o->oForwardVel = 50.0f; } @@ -118,6 +122,7 @@ void bhv_flying_bookend_loop(void) { } obj_check_attacks(&sFlyingBookendHitbox, -1); + if (o->oAction == -1 || (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_HIT_WALL))) { o->oNumLootCoins = 0; obj_die_if_health_non_positive(); @@ -128,26 +133,26 @@ void bhv_flying_bookend_loop(void) { } void bhv_bookend_spawn_loop(void) { - struct Object *sp1C; - if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { if (o->oTimer > 40 && obj_is_near_to_and_facing_mario(600.0f, 0x2000)) { - sp1C = spawn_object(o, MODEL_BOOKEND, bhvFlyingBookend); + struct Object *sp1C = spawn_object(o, MODEL_BOOKEND, bhvFlyingBookend); + if (sp1C != NULL) { sp1C->oAction = 3; cur_obj_play_sound_2(SOUND_OBJ_DEFAULT_DEATH); } + o->oTimer = 0; } } } void bookshelf_manager_act_0(void) { - s32 val04; + s32 i; if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { - for (val04 = 0; val04 < 3; val04++) { - spawn_object_relative(val04, D_80331B30[val04].unk00, D_80331B30[val04].unk02, 0, o, + for (i = 0; i < 3; i++) { + spawn_object_relative(i, D_80331B30[i].unk00, D_80331B30[i].unk02, 0, o, MODEL_BOOKEND, bhvBookSwitch); } @@ -231,18 +236,14 @@ void bhv_haunted_bookshelf_manager_loop(void) { } void bhv_book_switch_loop(void) { - s32 sp3C; - struct Object *sp38; - s16 sp36; - s16 sp34; - o->header.gfx.scale[0] = 2.0f; o->header.gfx.scale[1] = 0.9f; if (o->parentObj->oAction == 4) { obj_mark_for_deletion(o); } else { - sp3C = obj_check_attacks(&sBookSwitchHitbox, o->oAction); + s32 attackType = obj_check_attacks(&sBookSwitchHitbox, o->oAction); + if (o->parentObj->oBookSwitchManagerUnkF8 != 0 || o->oAction == 1) { if (o->oDistanceToMario < 100.0f) { cur_obj_become_tangible(); @@ -251,48 +252,50 @@ void bhv_book_switch_loop(void) { } o->oAction = 1; + if (o->oBookSwitchUnkF4 == 0.0f) { cur_obj_play_sound_2(SOUND_OBJ_DEFAULT_DEATH); } if (approach_f32_ptr(&o->oBookSwitchUnkF4, 50.0f, 20.0f)) { - if (o->parentObj->oBookSwitchManagerUnkF4 >= 0 && o->oTimer > 60) { - if (sp3C == 1 || sp3C == 2 || sp3C == 6) { - o->oAction = 2; - } + if (o->parentObj->oBookSwitchManagerUnkF4 >= 0 && o->oTimer > 60 + && (attackType == ATTACK_PUNCH || attackType == ATTACK_KICK_OR_TRIP + || attackType == ATTACK_FROM_BELOW)) { + o->oAction = 2; } } else { o->oTimer = 0; } } else { cur_obj_become_intangible(); - if (approach_f32_ptr(&o->oBookSwitchUnkF4, 0.0f, 20.0f)) { - if (o->oAction != 0) { - if (o->parentObj->oBookSwitchManagerUnkF4 == o->oBehParams2ndByte) { - play_sound(SOUND_GENERAL2_RIGHT_ANSWER, gGlobalSoundSource); - o->parentObj->oBookSwitchManagerUnkF4 += 1; - } else { - sp36 = random_u16() & 0x1; - sp34 = gMarioObject->oPosZ + 1.5f * gMarioStates[0].vel[2]; - play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); - if (sp34 > 0) { - sp34 = 0; - } + if (approach_f32_ptr(&o->oBookSwitchUnkF4, 0.0f, 20.0f) && o->oAction != 0) { + if (o->parentObj->oBookSwitchManagerUnkF4 == o->oBehParams2ndByte) { + play_sound(SOUND_GENERAL2_RIGHT_ANSWER, gGlobalSoundSource); + o->parentObj->oBookSwitchManagerUnkF4++; + } else { + struct Object *sp38; + s16 sp36 = random_u16() & 0x1; + s16 sp34 = gMarioObject->oPosZ + 1.5f * gMarioStates[0].vel[2]; - sp38 = spawn_object_abs_with_rot(o, 0, MODEL_BOOKEND, bhvFlyingBookend, - 0x1FC * sp36 - 0x8CA, 890, sp34, 0, - 0x8000 * sp36 + 0x4000, 0); + play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); - if (sp38 != NULL) { - sp38->oAction = 3; - } - - o->parentObj->oBookSwitchManagerUnkF4 = -1; + if (sp34 > 0) { + sp34 = 0; } - o->oAction = 0; + sp38 = spawn_object_abs_with_rot(o, 0, MODEL_BOOKEND, bhvFlyingBookend, + 0x1FC * sp36 - 0x8CA, 890, sp34, 0, + 0x8000 * sp36 + 0x4000, 0); + + if (sp38 != NULL) { + sp38->oAction = 3; + } + + o->parentObj->oBookSwitchManagerUnkF4 = -1; } + + o->oAction = 0; } } diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c index 2dab2fec..7089c34f 100644 --- a/src/game/behaviors/goomba.inc.c +++ b/src/game/behaviors/goomba.inc.c @@ -67,13 +67,10 @@ static u8 sGoombaAttackHandlers[][6] = { * Update function for goomba triplet spawner. */ void bhv_goomba_triplet_spawner_update(void) { - UNUSED s32 unused1; + UNUSED u8 filler1[4]; s16 goombaFlag; - UNUSED s16 unused2; + UNUSED u8 filler2[2]; s32 angle; - s32 dAngle; - s16 dx; - s16 dz; // If mario is close enough and the goombas aren't currently loaded, then // spawn them @@ -81,23 +78,22 @@ void bhv_goomba_triplet_spawner_update(void) { if (o->oDistanceToMario < 3000.0f) { // The spawner is capable of spawning more than 3 goombas, but this // is not used in the game - dAngle = + s32 dAngle = 0x10000 / (((o->oBehParams2ndByte & GOOMBA_TRIPLET_SPAWNER_BP_EXTRA_GOOMBAS_MASK) >> 2) + 3); for (angle = 0, goombaFlag = 1 << 8; angle < 0xFFFF; angle += dAngle, goombaFlag <<= 1) { // Only spawn goombas which haven't been killed yet if (!(o->oBehParams & goombaFlag)) { - dx = 500.0f * coss(angle); - dz = 500.0f * sins(angle); + s16 dx = 500.0f * coss(angle); + s16 dz = 500.0f * sins(angle); spawn_object_relative((o->oBehParams2ndByte & GOOMBA_TRIPLET_SPAWNER_BP_SIZE_MASK) - | (goombaFlag >> 6), - dx, 0, dz, o, MODEL_GOOMBA, bhvGoomba); + | (goombaFlag >> 6), dx, 0, dz, o, MODEL_GOOMBA, bhvGoomba); } } - o->oAction += 1; + o->oAction++; } } else if (o->oDistanceToMario > 4000.0f) { // If mario is too far away, enter the unloaded action. The goombas @@ -128,6 +124,7 @@ void bhv_goomba_init(void) { */ static void goomba_begin_jump(void) { cur_obj_play_sound_2(SOUND_OBJ_GOOMBA_ALERT); + o->oAction = GOOMBA_ACT_JUMP; o->oForwardVel = 0.0f; o->oVelY = 50.0f / 3.0f * o->oGoombaScale; @@ -140,8 +137,8 @@ static void goomba_begin_jump(void) { */ static void mark_goomba_as_dead(void) { if (o->parentObj != o) { - set_object_respawn_info_bits(o->parentObj, - (o->oBehParams2ndByte & GOOMBA_BP_TRIPLET_FLAG_MASK) >> 2); + set_object_respawn_info_bits( + o->parentObj, (o->oBehParams2ndByte & GOOMBA_BP_TRIPLET_FLAG_MASK) >> 2); o->parentObj->oBehParams = o->parentObj->oBehParams | (o->oBehParams2ndByte & GOOMBA_BP_TRIPLET_FLAG_MASK) << 6; @@ -195,8 +192,9 @@ static void goomba_act_walk(void) { // and occasionally jumping o->oGoombaRelativeSpeed = 4.0f / 3.0f; + if (o->oGoombaWalkTimer != 0) { - o->oGoombaWalkTimer -= 1; + o->oGoombaWalkTimer--; } else { if (random_u16() & 3) { o->oGoombaTargetYaw = obj_random_fixed_turn(0x2000); @@ -270,8 +268,7 @@ void bhv_goomba_update(void) { f32 animSpeed; if (obj_update_standard_actions(o->oGoombaScale)) { - // If this goomba has a spawner and mario moved away from the spawner, - // unload + // If this goomba has a spawner and mario moved away from the spawner, unload if (o->parentObj != o) { if (o->parentObj->oAction == GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED) { obj_mark_for_deletion(o); @@ -285,6 +282,7 @@ void bhv_goomba_update(void) { if ((animSpeed = o->oForwardVel / o->oGoombaScale * 0.4f) < 1.0f) { animSpeed = 1.0f; } + cur_obj_init_animation_with_accel_and_sound(0, animSpeed); switch (o->oAction) { @@ -312,6 +310,6 @@ void bhv_goomba_update(void) { cur_obj_move_standard(-78); } else { - o->oAnimState = TRUE; + o->oAnimState = 1; } } diff --git a/src/game/behaviors/grand_star.inc.c b/src/game/behaviors/grand_star.inc.c index 29c71c49..214b57d4 100644 --- a/src/game/behaviors/grand_star.inc.c +++ b/src/game/behaviors/grand_star.inc.c @@ -1,15 +1,19 @@ -// grand_star.c.inc +// grand_star.inc.c s32 arc_to_goal_pos(Vec3f a0, Vec3f a1, f32 yVel, f32 gravity) { f32 dx = a0[0] - a1[0]; f32 dz = a0[2] - a1[2]; f32 planarDist = sqrtf(dx * dx + dz * dz); s32 time; + o->oMoveAngleYaw = atan2s(dz, dx); o->oVelY = yVel; o->oGravity = gravity; + time = -2.0f / o->oGravity * yVel - 1.0f; + o->oForwardVel = planarDist / time; + return time; } @@ -20,52 +24,68 @@ void grand_star_zero_velocity(void) { } void bhv_grand_star_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; Vec3f sp28; + sp28[0] = sp28[1] = sp28[2] = 0.0f; + if (o->oAction == 0) { if (o->oTimer == 0) { obj_set_angle(o, 0, 0, 0); o->oAngleVelYaw = 0x400; + cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS); } - if (o->oTimer > 70) + + if (o->oTimer > 70) { o->oAction++; + } + spawn_sparkle_particles(3, 200, 80, -60); } else if (o->oAction == 1) { if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR); + cutscene_object(CUTSCENE_STAR_SPAWN, o); o->oGrandStarUnk108 = arc_to_goal_pos(sp28, &o->oPosX, 80.0f, -2.0f); } + cur_obj_move_using_fvel_and_gravity(); + if (o->oSubAction == 0) { if (o->oPosY < o->oHomeY) { o->oPosY = o->oHomeY; o->oVelY = 60.0f; o->oForwardVel = 0.0f; o->oSubAction++; + cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP); } } else if (o->oVelY < 0.0f && o->oPosY < o->oHomeY + 200.0f) { o->oPosY = o->oHomeY + 200.0f; grand_star_zero_velocity(); - gObjCutsceneDone = 1; + gObjCutsceneDone = TRUE; set_mario_npc_dialog(MARIO_DIALOG_STOP); o->oAction++; o->oInteractStatus = 0; + cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP); } + spawn_sparkle_particles(3, 200, 80, -60); } else { cur_obj_become_tangible(); + if (o->oInteractStatus & INT_STATUS_INTERACTED) { obj_mark_for_deletion(o); o->oInteractStatus = 0; } } - if (o->oAngleVelYaw > 0x400) + + if (o->oAngleVelYaw > 0x400) { o->oAngleVelYaw -= 0x100; + } + o->oFaceAngleYaw += o->oAngleVelYaw; cur_obj_scale(2.0f); o->oGraphYOffset = 110.0f; diff --git a/src/game/behaviors/grill_door.inc.c b/src/game/behaviors/grill_door.inc.c index 3cff966b..99ce3583 100644 --- a/src/game/behaviors/grill_door.inc.c +++ b/src/game/behaviors/grill_door.inc.c @@ -1,50 +1,71 @@ -// grill_door.c.inc +// grill_door.inc.c -struct OpenableGrill gOpenableGrills[] = { { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate }, - { 410, MODEL_HMC_RED_GRILLS, hmc_seg7_collision_0702B65C } }; +struct OpenableGrill { + s16 halfWidth; + s16 modelID; + const Collision *collision; +}; + +struct OpenableGrill gOpenableGrills[] = { + { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate }, + { 410, MODEL_HMC_RED_GRILLS, hmc_seg7_collision_0702B65C }, +}; void bhv_openable_cage_door_loop(void) { - if (gCurrentObject->oAction == 0) { - if (gCurrentObject->parentObj->oOpenableGrillUnk88 != 0) - gCurrentObject->oAction++; - } else if (gCurrentObject->oAction == 1) { - if (gCurrentObject->oTimer < 64) - gCurrentObject->oMoveAngleYaw -= gCurrentObject->oBehParams2ndByte * 0x100; - else - gCurrentObject->oAction++; + if (o->oAction == 0) { + if (o->parentObj->oOpenableGrillUnk88 != 0) { + o->oAction++; + } + } else if (o->oAction == 1) { + if (o->oTimer < 64) { + o->oMoveAngleYaw -= o->oBehParams2ndByte * 0x100; + } else { + o->oAction++; + } } } void bhv_openable_grill_loop(void) { struct Object *grillObj; s32 grillIdx; + switch (o->oAction) { case 0: grillIdx = o->oBehParams2ndByte; - grillObj = spawn_object_relative(-1, gOpenableGrills[grillIdx].halfWidth, 0, 0, o, gOpenableGrills[grillIdx].modelID, - bhvOpenableCageDoor); + + grillObj = spawn_object_relative(-1, gOpenableGrills[grillIdx].halfWidth, 0, 0, o, + gOpenableGrills[grillIdx].modelID, bhvOpenableCageDoor); grillObj->oMoveAngleYaw += 0x8000; obj_set_collision_data(grillObj, gOpenableGrills[grillIdx].collision); - grillObj = spawn_object_relative(1, -gOpenableGrills[grillIdx].halfWidth, 0, 0, o, gOpenableGrills[grillIdx].modelID, - bhvOpenableCageDoor); + + grillObj = spawn_object_relative(1, -gOpenableGrills[grillIdx].halfWidth, 0, 0, o, + gOpenableGrills[grillIdx].modelID, bhvOpenableCageDoor); obj_set_collision_data(grillObj, gOpenableGrills[grillIdx].collision); + o->oAction++; break; + case 1: - if ((o->oOpenableGrillUnkF4 = cur_obj_nearest_object_with_behavior(bhvFloorSwitchGrills)) - != NULL) + if ((o->oOpenableGrillUnkF4 = + cur_obj_nearest_object_with_behavior(bhvFloorSwitchGrills)) != NULL) { o->oAction++; + } break; + case 2: grillObj = o->oOpenableGrillUnkF4; + if (grillObj->oAction == 2) { o->oOpenableGrillUnk88 = 2; cur_obj_play_sound_2(SOUND_GENERAL_CAGE_OPEN); o->oAction++; - if (o->oBehParams2ndByte != 0) + + if (o->oBehParams2ndByte != 0) { play_puzzle_jingle(); + } } break; + case 3: break; } diff --git a/src/game/behaviors/ground_particles.inc.c b/src/game/behaviors/ground_particles.inc.c index c7259311..aff00af5 100644 --- a/src/game/behaviors/ground_particles.inc.c +++ b/src/game/behaviors/ground_particles.inc.c @@ -1,42 +1,82 @@ -// ground_particles.c.inc - -static struct SpawnParticlesInfo sGlobalMistParticles = { 3, 20, MODEL_MIST, 20, 10, 5, 0, 0, 0, 30, 30.0f, 1.5f }; - -static struct SpawnParticlesInfo sSandParticles = { 0, 5, MODEL_SAND_DUST, 0, 0, 20, 20, 0, 252, 30, 5.0f, 2.0f }; - -static s16 sSmokeMovementParams[] = { 2, -8, 1, 4 }; - -static struct SpawnParticlesInfo sSnowParticles = { 0, 5, MODEL_WHITE_PARTICLE_DL, 0, 0, 20, 20, 0, 252, 30, - 2.0f, 2.0f }; +// ground_particles.inc.c void bhv_pound_white_puffs_init(void) { - clear_particle_flags(0x8000); + clear_particle_flags(ACTIVE_PARTICLE_MIST_CIRCLE); spawn_mist_from_global(); } +static struct SpawnParticlesInfo sGlobalMistParticles = { + /* behParam: */ 3, + /* count: */ 20, + /* model: */ MODEL_MIST, + /* offsetY: */ 20, + /* forwardVelBase: */ 10, + /* forwardVelRange: */ 5, + /* velYBase: */ 0, + /* velYRange: */ 0, + /* gravity: */ 0, + /* dragStrength: */ 30, + /* sizeBase: */ 30.0f, + /* sizeRange: */ 1.5f, +}; + void spawn_mist_from_global(void) { cur_obj_spawn_particles(&sGlobalMistParticles); } +static struct SpawnParticlesInfo sSandParticles = { + /* behParam: */ 0, + /* count: */ 5, + /* model: */ MODEL_SAND_DUST, + /* offsetY: */ 0, + /* forwardVelBase: */ 0, + /* forwardVelRange: */ 20, + /* velYBase: */ 20, + /* velYRange: */ 0, + /* gravity: */ 252, + /* dragStrength: */ 30, + /* sizeBase: */ 5.0f, + /* sizeRange: */ 2.0f, +}; + void bhv_ground_sand_init(void) { - clear_particle_flags(0x4000); + clear_particle_flags(ACTIVE_PARTICLE_DIRT); cur_obj_spawn_particles(&sSandParticles); } +static s16 sSmokeMovementParams[] = { 2, -8, 1, 4 }; + void spawn_smoke_with_velocity(void) { struct Object *smoke = spawn_object_with_scale(o, MODEL_SMOKE, bhvWhitePuffSmoke2, 1.0f); + smoke->oForwardVel = sSmokeMovementParams[0]; smoke->oVelY = sSmokeMovementParams[1]; smoke->oGravity = sSmokeMovementParams[2]; + obj_translate_xyz_random(smoke, sSmokeMovementParams[3]); } // TODO Fix name void clear_particle_flags(u32 flags) { - o->parentObj->oActiveParticleFlags &= flags ^ -1; // Clear the flags given (could just be ~flags) + o->parentObj->oActiveParticleFlags &= flags ^ 0xFFFFFFFF; // Clear the flags given (could just be ~flags) } +static struct SpawnParticlesInfo sSnowParticles = { + /* behParam: */ 0, + /* count: */ 5, + /* model: */ MODEL_WHITE_PARTICLE_DL, + /* offsetY: */ 0, + /* forwardVelBase: */ 0, + /* forwardVelRange: */ 20, + /* velYBase: */ 20, + /* velYRange: */ 0, + /* gravity: */ 252, + /* dragStrength: */ 30, + /* sizeBase: */ 2.0f, + /* sizeRange: */ 2.0f, +}; + void bhv_ground_snow_init(void) { - clear_particle_flags(1 << 16); + clear_particle_flags(ACTIVE_PARTICLE_SNOW); cur_obj_spawn_particles(&sSnowParticles); } diff --git a/src/game/behaviors/haunted_chair.inc.c b/src/game/behaviors/haunted_chair.inc.c index 398d2283..d66b34c6 100644 --- a/src/game/behaviors/haunted_chair.inc.c +++ b/src/game/behaviors/haunted_chair.inc.c @@ -17,6 +17,7 @@ void bhv_haunted_chair_init(void) { f32 val00; val04 = cur_obj_find_nearest_object_with_behavior(bhvMadPiano, &val00); + if (val04 != NULL && val00 < 300.0f) { o->parentObj = val04; } else { @@ -25,14 +26,14 @@ void bhv_haunted_chair_init(void) { } void haunted_chair_act_0(void) { - s16 val0E; - if (o->parentObj != o) { if (o->oHauntedChairUnk104 == 0) { if (lateral_dist_between_objects(o, o->parentObj) < 250.0f) { - val0E = obj_angle_to_object(o, o->parentObj) - o->oFaceAngleYaw + 0x2000; + s16 val0E = obj_angle_to_object(o, o->parentObj) - o->oFaceAngleYaw + 0x2000; + if (val0E & 0x4000) { o->oHauntedChairUnk100 = &o->oFaceAngleRoll; + if (val0E > 0) { o->oHauntedChairUnk104 = 0x4000; } else { @@ -40,6 +41,7 @@ void haunted_chair_act_0(void) { } } else { o->oHauntedChairUnk100 = &o->oFaceAnglePitch; + if (val0E < 0) { o->oHauntedChairUnk104 = 0x5000; } else { @@ -59,11 +61,12 @@ void haunted_chair_act_0(void) { } } else if (o->oHauntedChairUnkF4 != 0) { if (o->oDistanceToMario < 500.0f) { - o->oHauntedChairUnkF4 -= 1; + o->oHauntedChairUnkF4--; } - o->oTimer = 0.0f; + + o->oTimer = 0; } else { - if ((o->oTimer & 0x8) != 0) { + if (o->oTimer & 0x8) { f32 val08; if (o->oFaceAnglePitch < 0) { @@ -83,6 +86,7 @@ void haunted_chair_act_0(void) { if (o->oTimer > 30) { o->oAction = 1; + o->oHauntedChairUnkF8 = 0.0f; o->oHauntedChairUnkFC = 200.0f; o->oHauntedChairUnkF4 = 40; @@ -103,20 +107,24 @@ void haunted_chair_act_1(void) { } o->oGravity = 0.0f; + oscillate_toward(&o->oFaceAnglePitch, &o->oHauntedChairUnkF8, -4000, 200.0f, 20.0f, 2.0f); oscillate_toward(&o->oFaceAngleRoll, &o->oHauntedChairUnkFC, 0, 0.0f, 20.0f, 1.0f); } else { if (o->oHauntedChairUnkF4 != 0) { if (--o->oHauntedChairUnkF4 == 0) { cur_obj_play_sound_2(SOUND_GENERAL_HAUNTED_CHAIR); + o->oMoveAnglePitch = obj_turn_pitch_toward_mario(120.0f, 0); o->oMoveAngleYaw = o->oAngleToMario; + obj_compute_vel_from_move_pitch(50.0f); } else if (o->oHauntedChairUnkF4 > 20) { if (gGlobalTimer % 4 == 0) { cur_obj_play_sound_2(SOUND_GENERAL_SWISH_AIR_2); } - o->oFaceAngleYaw += 0x2710; + + o->oFaceAngleYaw += 10000; } } else if (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_HIT_WALL)) { obj_die_if_health_non_positive(); @@ -137,6 +145,7 @@ void bhv_haunted_chair_loop(void) { haunted_chair_act_1(); break; } + cur_obj_spin_all_dimensions(30.0f, 30.0f); } } diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c index 74daefeb..2a8ab260 100644 --- a/src/game/behaviors/heave_ho.inc.c +++ b/src/game/behaviors/heave_ho.inc.c @@ -1,4 +1,4 @@ -// heave_ho.c.inc +// heave_ho.inc.c s16 D_8032F460[][2] = { { 30, 0 }, { 42, 1 }, { 52, 0 }, { 64, 1 }, { 74, 0 }, { 86, 1 }, { 96, 0 }, { 108, 1 }, { 118, 0 }, { -1, 0 }, }; @@ -7,7 +7,9 @@ void bhv_heave_ho_throw_mario_loop(void) { o->oParentRelativePosX = 200.0f; o->oParentRelativePosY = -50.0f; o->oParentRelativePosZ = 0.0f; + o->oMoveAngleYaw = o->parentObj->oMoveAngleYaw; + switch (o->parentObj->oHeaveHoUnk88) { case 0: break; @@ -25,35 +27,45 @@ void bhv_heave_ho_throw_mario_loop(void) { void heave_ho_act_1(void) { s32 sp1C = 0; + o->oForwardVel = 0.0f; cur_obj_reverse_animation(); + while (TRUE) { if (D_8032F460[sp1C][0] == -1) { o->oAction = 2; break; } + if (o->oTimer < D_8032F460[sp1C][0]) { cur_obj_init_animation_with_accel_and_sound(2, D_8032F460[sp1C][1]); break; } + sp1C++; } } void heave_ho_act_2(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; s16 angleVel; - if (1000.0f < cur_obj_lateral_dist_from_mario_to_home()) + + if (cur_obj_lateral_dist_from_mario_to_home() > 1000.0f) { o->oAngleToMario = cur_obj_angle_to_home(); + } + if (o->oTimer > 150) { o->oHeaveHoUnkF4 = (302 - o->oTimer) / 152.0f; if (o->oHeaveHoUnkF4 < 0.1) { - o->oHeaveHoUnkF4 = 0.1; + o->oHeaveHoUnkF4 = 0.1f; o->oAction = 1; } - } else + } else { o->oHeaveHoUnkF4 = 1.0f; + } + cur_obj_init_animation_with_accel_and_sound(0, o->oHeaveHoUnkF4); + o->oForwardVel = o->oHeaveHoUnkF4 * 10.0f; angleVel = o->oHeaveHoUnkF4 * 0x400; o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, angleVel); @@ -61,18 +73,24 @@ void heave_ho_act_2(void) { void heave_ho_act_3(void) { o->oForwardVel = 0.0f; - if (o->oTimer == 0) + + if (o->oTimer == 0) { o->oHeaveHoUnk88 = 2; + } + if (o->oTimer == 1) { cur_obj_init_animation_with_accel_and_sound(1, 1.0f); o->numCollidedObjs = 20; } - if (cur_obj_check_if_near_animation_end()) + + if (cur_obj_check_if_near_animation_end()) { o->oAction = 1; + } } void heave_ho_act_0(void) { cur_obj_set_pos_to_home(); + if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 4000.0f) { cur_obj_become_tangible(); cur_obj_unhide(); @@ -83,20 +101,32 @@ void heave_ho_act_0(void) { } } -void (*sHeaveHoActions[])(void) = { heave_ho_act_0, heave_ho_act_1, heave_ho_act_2, heave_ho_act_3 }; +void (*sHeaveHoActions[])(void) = { + heave_ho_act_0, + heave_ho_act_1, + heave_ho_act_2, + heave_ho_act_3, +}; void heave_ho_move(void) { cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sHeaveHoActions); cur_obj_move_standard(-78); - if (o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER) + + if (o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER) { o->oGraphYOffset = -15.0f; - else + } else { o->oGraphYOffset = 0.0f; - if (o->oForwardVel > 3.0f) + } + + if (o->oForwardVel > 3.0f) { cur_obj_play_sound_1(SOUND_AIR_HEAVEHO_MOVE); - if (o->oAction != 0 && o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER) + } + + if (o->oAction != 0 && o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER) { o->oAction = 0; + } + if (o->oInteractStatus & INT_STATUS_GRABBED_MARIO) { o->oInteractStatus = 0; o->oHeaveHoUnk88 = 1; @@ -106,6 +136,7 @@ void heave_ho_move(void) { void bhv_heave_ho_loop(void) { cur_obj_scale(2.0f); + switch (o->oHeldState) { case HELD_FREE: heave_ho_move(); @@ -120,5 +151,6 @@ void bhv_heave_ho_loop(void) { cur_obj_get_dropped(); break; } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/hidden_star.inc.c b/src/game/behaviors/hidden_star.inc.c index 344e8962..9dd2c1e3 100644 --- a/src/game/behaviors/hidden_star.inc.c +++ b/src/game/behaviors/hidden_star.inc.c @@ -1,25 +1,24 @@ -// hidden_star.c.inc +// hidden_star.inc.c void bhv_hidden_star_init(void) { - s16 sp36; - struct Object *sp30; + s16 count = count_objects_with_behavior(bhvHiddenStarTrigger); - sp36 = count_objects_with_behavior(bhvHiddenStarTrigger); - if (sp36 == 0) { - sp30 = - spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); - sp30->oBehParams = o->oBehParams; + if (count == 0) { + struct Object *star = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, + o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); + star->oBehParams = o->oBehParams; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - o->oHiddenStarTriggerCounter = 5 - sp36; + o->oHiddenStarTriggerCounter = 5 - count; } void bhv_hidden_star_loop(void) { switch (o->oAction) { case 0: - if (o->oHiddenStarTriggerCounter == 5) + if (o->oHiddenStarTriggerCounter == 5) { o->oAction = 1; + } break; case 1: @@ -32,13 +31,13 @@ void bhv_hidden_star_loop(void) { } } -/* TODO: this is likely not a checkpoint but a Secret */ void bhv_hidden_star_trigger_loop(void) { - struct Object *hiddenStar; - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { - hiddenStar = cur_obj_nearest_object_with_behavior(bhvHiddenStar); + if (obj_check_if_collided_with_object(o, gMarioObject) == TRUE) { + struct Object *hiddenStar = cur_obj_nearest_object_with_behavior(bhvHiddenStar); + if (hiddenStar != NULL) { hiddenStar->oHiddenStarTriggerCounter++; + if (hiddenStar->oHiddenStarTriggerCounter != 5) { spawn_orange_number(hiddenStar->oHiddenStarTriggerCounter, 0, 0, 0); } @@ -47,8 +46,7 @@ void bhv_hidden_star_trigger_loop(void) { play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); #else play_sound(SOUND_MENU_COLLECT_SECRET - + (((u8) hiddenStar->oHiddenStarTriggerCounter - 1) << 16), - gGlobalSoundSource); + + (((u8) hiddenStar->oHiddenStarTriggerCounter - 1) << 16), gGlobalSoundSource); #endif } @@ -58,10 +56,12 @@ void bhv_hidden_star_trigger_loop(void) { void bhv_bowser_course_red_coin_star_loop(void) { gRedCoinsCollected = o->oHiddenStarTriggerCounter; + switch (o->oAction) { case 0: - if (o->oHiddenStarTriggerCounter == 8) + if (o->oHiddenStarTriggerCounter == 8) { o->oAction = 1; + } break; case 1: diff --git a/src/game/behaviors/hoot.inc.c b/src/game/behaviors/hoot.inc.c index 95692e58..238d2754 100644 --- a/src/game/behaviors/hoot.inc.c +++ b/src/game/behaviors/hoot.inc.c @@ -1,4 +1,4 @@ -// hoot.c.inc +// hoot.inc.c void bhv_hoot_init(void) { cur_obj_init_animation(0); @@ -11,45 +11,44 @@ void bhv_hoot_init(void) { cur_obj_become_intangible(); } -// sp28 = arg0 -// sp2c = arg1 - -f32 hoot_find_next_floor(struct FloorGeometry **arg0, f32 arg1) { +f32 hoot_find_next_floor(struct FloorGeometry **floorGeo, f32 arg1) { f32 sp24 = arg1 * sins(o->oMoveAngleYaw) + o->oPosX; UNUSED f32 sp20 = o->oPosY; f32 sp1c = arg1 * coss(o->oMoveAngleYaw) + o->oPosZ; - f32 floorY = find_floor_height_and_data(sp24, 10000.0f, sp1c, arg0); + f32 floorY = find_floor_height_and_data(sp24, 10000.0f, sp1c, floorGeo); return floorY; } void hoot_floor_bounce(void) { - struct FloorGeometry *sp1c; + struct FloorGeometry *floorGeo; f32 floorY; - floorY = hoot_find_next_floor(&sp1c, 375.0f); - if (floorY + 75.0f > o->oPosY) + floorY = hoot_find_next_floor(&floorGeo, 375.0f); + if (floorY + 75.0f > o->oPosY) { o->oMoveAnglePitch -= 3640.8888; + } - floorY = hoot_find_next_floor(&sp1c, 200.0f); - if (floorY + 125.0f > o->oPosY) + floorY = hoot_find_next_floor(&floorGeo, 200.0f); + if (floorY + 125.0f > o->oPosY) { o->oMoveAnglePitch -= 7281.7776; + } - floorY = hoot_find_next_floor(&sp1c, 0); - if (floorY + 125.0f > o->oPosY) + floorY = hoot_find_next_floor(&floorGeo, 0); + if (floorY + 125.0f > o->oPosY) { o->oPosY = floorY + 125.0f; - if (o->oMoveAnglePitch < -21845.3328) + } + + if (o->oMoveAnglePitch < -21845.3328) { o->oMoveAnglePitch = -21845; + } } -// sp30 = fastOscY -// sp34 = speed - void hoot_free_step(s16 fastOscY, s32 speed) { - struct FloorGeometry *sp2c; + struct FloorGeometry *floorGeo; s16 yaw = o->oMoveAngleYaw; s16 pitch = o->oMoveAnglePitch; - s16 sp26 = o->header.gfx.animInfo.animFrame; + s16 animFrame = o->header.gfx.animInfo.animFrame; f32 xPrev = o->oPosX; f32 zPrev = o->oPosZ; f32 hSpeed; @@ -60,42 +59,44 @@ void hoot_free_step(s16 fastOscY, s32 speed) { o->oVelZ = coss(yaw) * hSpeed; o->oPosX += o->oVelX; - if (fastOscY == 0) - o->oPosY -= o->oVelY + coss((s32)(sp26 * 3276.8)) * 50.0f / 4; - else - o->oPosY -= o->oVelY + coss((s32)(sp26 * 6553.6)) * 50.0f / 4; + if (fastOscY == 0) { + o->oPosY -= o->oVelY + coss((s32)(animFrame * 3276.8)) * 50.0f / 4; + } else { + o->oPosY -= o->oVelY + coss((s32)(animFrame * 6553.6)) * 50.0f / 4; + } o->oPosZ += o->oVelZ; - find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp2c); - if (sp2c == NULL) { + find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &floorGeo); + if (floorGeo == NULL) { o->oPosX = xPrev; o->oPosZ = zPrev; } - if (sp26 == 0) + if (animFrame == 0) { cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER); + } } void hoot_player_set_yaw(void) { s16 stickX = gPlayer3Controller->rawStickX; s16 stickY = gPlayer3Controller->rawStickY; UNUSED s16 pitch = o->oMoveAnglePitch; - if (stickX < 10 && stickX >= -9) + + if (stickX < 10 && stickX >= -9) { stickX = 0; - if (stickY < 10 && stickY >= -9) + } + + if (stickY < 10 && stickY >= -9) { stickY = 0; + } o->oMoveAngleYaw -= 5 * stickX; } -// sp28 = speed -// sp2c = xPrev -// sp30 = zPrev - void hoot_carry_step(s32 speed, UNUSED f32 xPrev, UNUSED f32 zPrev) { s16 yaw = o->oMoveAngleYaw; s16 pitch = o->oMoveAnglePitch; - s16 sp22 = o->header.gfx.animInfo.animFrame; + s16 animFrame = o->header.gfx.animInfo.animFrame; f32 hSpeed; o->oVelY = sins(pitch) * speed; @@ -104,19 +105,16 @@ void hoot_carry_step(s32 speed, UNUSED f32 xPrev, UNUSED f32 zPrev) { o->oVelZ = coss(yaw) * hSpeed; o->oPosX += o->oVelX; - o->oPosY -= o->oVelY + coss((s32)(sp22 * 6553.6)) * 50.0f / 4; + o->oPosY -= o->oVelY + coss((s32)(animFrame * 6553.6)) * 50.0f / 4; o->oPosZ += o->oVelZ; - if (sp22 == 0) + if (animFrame == 0) { cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER); + } } -// sp48 = xPrev -// sp4c = yPrev -// sp50 = zPrev - void hoot_surface_collision(f32 xPrev, UNUSED f32 yPrev, f32 zPrev) { - struct FloorGeometry *sp44; + struct FloorGeometry *floorGeo; struct WallCollisionData hitbox; f32 floorY; @@ -130,26 +128,28 @@ void hoot_surface_collision(f32 xPrev, UNUSED f32 yPrev, f32 zPrev) { o->oPosX = hitbox.x; o->oPosY = hitbox.y; o->oPosZ = hitbox.z; - gMarioObject->oInteractStatus |= INT_STATUS_MARIO_UNK7; /* bit 7 */ + gMarioObject->oInteractStatus |= INT_STATUS_MARIO_UNK7; } - floorY = find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp44); - if (sp44 == NULL) { + floorY = find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &floorGeo); + if (floorGeo == NULL) { o->oPosX = xPrev; o->oPosZ = zPrev; return; } - if (absf_2(o->oPosX) > 8000.0f) + if (absf_2(o->oPosX) > 8000.0f) { o->oPosX = xPrev; - if (absf_2(o->oPosZ) > 8000.0f) - o->oPosZ = zPrev; - if (floorY + 125.0f > o->oPosY) - o->oPosY = floorY + 125.0f; -} + } -// sp28 = xPrev -// sp2c = zPrev + if (absf_2(o->oPosZ) > 8000.0f) { + o->oPosZ = zPrev; + } + + if (floorY + 125.0f > o->oPosY) { + o->oPosY = floorY + 125.0f; + } +} void hoot_act_ascent(f32 xPrev, f32 zPrev) { f32 negX = 0 - o->oPosX; @@ -164,8 +164,9 @@ void hoot_act_ascent(f32 xPrev, f32 zPrev) { o->header.gfx.animInfo.animFrame = 1; } - if (o->oPosY > 6500.0f) + if (o->oPosY > 6500.0f) { o->oAction = HOOT_ACT_CARRY; + } hoot_carry_step(60, xPrev, zPrev); } @@ -188,9 +189,8 @@ void hoot_action_loop(void) { if (o->oPosY < 2700.0f) { set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); - if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_045)) { + if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_045) != 0) { clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); - o->oAction = HOOT_ACT_TIRED; } } @@ -205,8 +205,9 @@ void hoot_action_loop(void) { hoot_carry_step(20, xPrev, zPrev); - if (o->oTimer >= 61) - gMarioObject->oInteractStatus |= INT_STATUS_MARIO_UNK7; /* bit 7 */ + if (o->oTimer > 60) { + gMarioObject->oInteractStatus |= INT_STATUS_MARIO_UNK7; + } break; } diff --git a/src/game/behaviors/horizontal_grindel.inc.c b/src/game/behaviors/horizontal_grindel.inc.c index c0b5fe15..e842443d 100644 --- a/src/game/behaviors/horizontal_grindel.inc.c +++ b/src/game/behaviors/horizontal_grindel.inc.c @@ -1,3 +1,4 @@ +// horizontal_grindel.inc.c void bhv_horizontal_grindel_init(void) { o->oHorizontalGrindelTargetYaw = o->oMoveAngleYaw; @@ -7,7 +8,9 @@ void bhv_horizontal_grindel_update(void) { if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { if (!o->oHorizontalGrindelOnGround) { cur_obj_play_sound_2(SOUND_OBJ_THWOMP); + o->oHorizontalGrindelOnGround = TRUE; + set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ); o->oHorizontalGrindelDistToHome = cur_obj_lateral_dist_to_home(); @@ -22,6 +25,7 @@ void bhv_horizontal_grindel_update(void) { o->oHorizontalGrindelDistToHome = 0.0f; } else { cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB_JUMP); + o->oForwardVel = 11.0f; o->oVelY = 70.0f; o->oGravity = -4.0f; @@ -33,11 +37,13 @@ void bhv_horizontal_grindel_update(void) { } } else { o->oHorizontalGrindelOnGround = FALSE; + if (o->oVelY < 0.0f) { o->oGravity = -16.0f; } } o->oFaceAngleYaw = o->oMoveAngleYaw + 0x4000; + cur_obj_move_standard(78); } diff --git a/src/game/behaviors/intro_lakitu.inc.c b/src/game/behaviors/intro_lakitu.inc.c index 7b12a651..7ca8055d 100644 --- a/src/game/behaviors/intro_lakitu.inc.c +++ b/src/game/behaviors/intro_lakitu.inc.c @@ -1,15 +1,15 @@ + /** * @file intro_lakitu.inc.c * This file implements lakitu's behvaior during the intro cutscene. * It's also used during the ending cutscene. */ - /** * Add the camera's position to `offset`, rotate the point to be relative to the camera's focus, then * set lakitu's location. */ -void intro_lakitu_set_offset_from_camera(struct Object *o, Vec3f offset) { +void intro_lakitu_set_offset_from_camera(struct Object *obj, Vec3f offset) { f32 dist; Vec3s focusAngles; s16 offsetPitch, offsetYaw; @@ -20,75 +20,96 @@ void intro_lakitu_set_offset_from_camera(struct Object *o, Vec3f offset) { vec3f_get_dist_and_angle(gCamera->pos, offset, &dist, &offsetPitch, &offsetYaw); vec3f_set_dist_and_angle(gCamera->pos, offset, dist, focusAngles[0] + offsetPitch, focusAngles[1] + offsetYaw); - vec3f_to_object_pos(o, offset); + vec3f_to_object_pos(obj, offset); } -void intro_lakitu_set_focus(struct Object *o, Vec3f newFocus) { - UNUSED Vec3f unusedVec3f; +void intro_lakitu_set_focus(struct Object *obj, Vec3f newFocus) { + UNUSED u8 filler1[12]; Vec3f origin; f32 dist; s16 pitch, yaw; - UNUSED u32 unused; + UNUSED u8 filler2[4]; // newFocus is an offset from lakitu's origin, not a point in the world. - vec3f_set(origin, 0.f, 0.f, 0.f); + vec3f_set(origin, 0.0f, 0.0f, 0.0f); vec3f_get_dist_and_angle(origin, newFocus, &dist, &pitch, &yaw); - o->oFaceAnglePitch = pitch; - o->oFaceAngleYaw = yaw; + + obj->oFaceAnglePitch = pitch; + obj->oFaceAngleYaw = yaw; } /** * Move lakitu along the spline `offset`, relative to the camera, and face him towards the corresponding * location along the spline `focus`. */ -s32 intro_lakitu_set_pos_and_focus(struct Object *o, struct CutsceneSplinePoint offset[], +s32 intro_lakitu_set_pos_and_focus(struct Object *obj, struct CutsceneSplinePoint offset[], struct CutsceneSplinePoint focus[]) { Vec3f newOffset, newFocus; s32 splineFinished = 0; - s16 splineSegment = o->oIntroLakituSplineSegment; + s16 splineSegment = obj->oIntroLakituSplineSegment; - if ((move_point_along_spline(newFocus, offset, &splineSegment, &(o->oIntroLakituSplineSegmentProgress)) == 1) - || (move_point_along_spline(newOffset, focus, &splineSegment, &(o->oIntroLakituSplineSegmentProgress)) == 1)) - splineFinished += 1; + if ((move_point_along_spline(newFocus, offset, &splineSegment, + &obj->oIntroLakituSplineSegmentProgress) == 1) + || (move_point_along_spline(newOffset, focus, &splineSegment, + &obj->oIntroLakituSplineSegmentProgress) == 1)) { + splineFinished++; + } + + obj->oIntroLakituSplineSegment = splineSegment; + + intro_lakitu_set_offset_from_camera(obj, newOffset); + intro_lakitu_set_focus(obj, newFocus); - o->oIntroLakituSplineSegment = splineSegment; - intro_lakitu_set_offset_from_camera(o, newOffset); - intro_lakitu_set_focus(o, newFocus); return splineFinished; } +#ifdef VERSION_EU +#define TIMER1 599 +#define TIMER2 74 +#else +#define TIMER1 720 +#define TIMER2 98 +#endif + void bhv_intro_lakitu_loop(void) { Vec3f sp64, sp58, sp4C; - UNUSED u32 pad[4]; + UNUSED u8 filler[16]; - switch (gCurrentObject->oAction) { + switch (o->oAction) { case 0: cur_obj_disable_rendering(); - gCurrentObject->oIntroLakituSplineSegment = 0.f; - gCurrentObject->oIntroLakituSplineSegmentProgress = 0.f; - gCurrentObject->oIntroLakituCloud = - spawn_object_relative_with_scale(1, 0, 0, 0, 2.f, gCurrentObject, MODEL_MIST, bhvCloud); - if (gCamera->cutscene == CUTSCENE_END_WAVING) - gCurrentObject->oAction = 100; - else - gCurrentObject->oAction += 1; + + o->oIntroLakituSplineSegment = 0.0f; + o->oIntroLakituSplineSegmentProgress = 0.0f; + o->oIntroLakituCloud = + spawn_object_relative_with_scale(1, 0, 0, 0, 2.0f, o, MODEL_MIST, bhvCloud); + + if (gCamera->cutscene == CUTSCENE_END_WAVING) { + o->oAction = 100; + } else { + o->oAction++; + } break; case 1: cur_obj_enable_rendering(); + if ((gCutsceneTimer > 350) && (gCutsceneTimer < 458)) { - gCurrentObject->oPosX = gCamera->pos[0]; - gCurrentObject->oPosY = gCamera->pos[1] + 500.f; - gCurrentObject->oPosZ = gCamera->pos[2]; + o->oPosX = gCamera->pos[0]; + o->oPosY = gCamera->pos[1] + 500.0f; + o->oPosZ = gCamera->pos[2]; } - if (gCutsceneTimer > 52) + + if (gCutsceneTimer > 52) { cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO); + } - if (intro_lakitu_set_pos_and_focus(gCurrentObject, gIntroLakituStartToPipeOffsetFromCamera, - gIntroLakituStartToPipeFocus) == 1) - gCurrentObject->oAction += 1; + if (intro_lakitu_set_pos_and_focus(o, gIntroLakituStartToPipeOffsetFromCamera, + gIntroLakituStartToPipeFocus) == 1) { + o->oAction++; + } - switch (gCurrentObject->oTimer) { + switch (o->oTimer) { #if defined(VERSION_US) || defined(VERSION_SH) case 534: cur_obj_play_sound_2(SOUND_ACTION_FLYING_FAST); @@ -98,129 +119,134 @@ void bhv_intro_lakitu_loop(void) { break; #endif case 73: - gCurrentObject->oAnimState += 1; + o->oAnimState++; break; case 74: - gCurrentObject->oAnimState -= 1; + o->oAnimState--; break; case 82: - gCurrentObject->oAnimState += 1; + o->oAnimState++; break; case 84: - gCurrentObject->oAnimState -= 1; + o->oAnimState--; break; } #ifdef VERSION_EU - if (gCurrentObject->oTimer == 446) + if (o->oTimer == 446) { cur_obj_play_sound_2(SOUND_ACTION_FLYING_FAST); - if (gCurrentObject->oTimer == 485) + } + if (o->oTimer == 485) { cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45E); + } #endif break; + case 2: -#ifdef VERSION_EU - if (gCutsceneTimer > 599) { -#else - if (gCutsceneTimer > 720) { -#endif - gCurrentObject->oAction += 1; - gCurrentObject->oIntroLakituUnk100 = 1400.f; - gCurrentObject->oIntroLakituUnk104 = -4096.f; - gCurrentObject->oIntroLakituUnk108 = 2048.f; - gCurrentObject->oIntroLakituUnk10C = -200.f; - gCurrentObject->oMoveAngleYaw = 0x8000; - gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw + 0x4000; - gCurrentObject->oMoveAnglePitch = 0x800; + if (gCutsceneTimer > TIMER1) { + o->oAction++; + + o->oIntroLakituUnk100 = 1400.0f; + o->oIntroLakituUnk104 = -4096.0f; + o->oIntroLakituUnk108 = 2048.0f; + o->oIntroLakituUnk10C = -200.0f; + + o->oMoveAngleYaw = 0x8000; + o->oFaceAngleYaw = o->oMoveAngleYaw + 0x4000; + o->oMoveAnglePitch = 0x800; } + cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO); break; case 3: cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO); - vec3f_set(sp58, -1128.f, 560.f, 4664.f); - gCurrentObject->oMoveAngleYaw += 0x200; - gCurrentObject->oIntroLakituUnk100 = - approach_f32_asymptotic(gCurrentObject->oIntroLakituUnk100, 100.f, 0.03f); - gCurrentObject->oFaceAnglePitch = atan2s(200.f, gCurrentObject->oPosY - 400.f); - gCurrentObject->oFaceAngleYaw = approach_s16_asymptotic( - gCurrentObject->oFaceAngleYaw, gCurrentObject->oMoveAngleYaw + 0x8000, 4); - vec3f_set_dist_and_angle(sp58, sp4C, gCurrentObject->oIntroLakituUnk100, 0, - gCurrentObject->oMoveAngleYaw); - sp4C[1] += 150.f * coss((s16) gCurrentObject->oIntroLakituUnk104); - gCurrentObject->oIntroLakituUnk104 += gCurrentObject->oIntroLakituUnk108; - gCurrentObject->oIntroLakituUnk108 = - approach_f32_asymptotic(gCurrentObject->oIntroLakituUnk108, 512.f, 0.05f); - sp4C[0] += gCurrentObject->oIntroLakituUnk10C; - gCurrentObject->oIntroLakituUnk10C = - approach_f32_asymptotic(gCurrentObject->oIntroLakituUnk10C, 0.f, 0.05f); - vec3f_to_object_pos(gCurrentObject, sp4C); - if (gCurrentObject->oTimer == 31) { - gCurrentObject->oPosY -= 158.f; + vec3f_set(sp58, -1128.0f, 560.0f, 4664.0f); + o->oMoveAngleYaw += 0x200; + o->oIntroLakituUnk100 = approach_f32_asymptotic(o->oIntroLakituUnk100, 100.0f, 0.03f); + o->oFaceAnglePitch = atan2s(200.0f, o->oPosY - 400.0f); + o->oFaceAngleYaw = approach_s16_asymptotic(o->oFaceAngleYaw, o->oMoveAngleYaw + 0x8000, 4); + vec3f_set_dist_and_angle(sp58, sp4C, o->oIntroLakituUnk100, 0, o->oMoveAngleYaw); + sp4C[1] += 150.0f * coss((s16) o->oIntroLakituUnk104); + o->oIntroLakituUnk104 += o->oIntroLakituUnk108; + o->oIntroLakituUnk108 = approach_f32_asymptotic(o->oIntroLakituUnk108, 512.0f, 0.05f); + sp4C[0] += o->oIntroLakituUnk10C; + o->oIntroLakituUnk10C = approach_f32_asymptotic(o->oIntroLakituUnk10C, 0.0f, 0.05f); + vec3f_to_object_pos(o, sp4C); + + if (o->oTimer == 31) { + o->oPosY -= 158.0f; // Spawn white ground particles spawn_mist_from_global(); - gCurrentObject->oPosY += 158.f; + o->oPosY += 158.0f; } -#ifdef VERSION_EU -#define TIMER 74 -#else -#define TIMER 98 -#endif - if (gCurrentObject->oTimer == TIMER) { - obj_mark_for_deletion(gCurrentObject); - obj_mark_for_deletion(gCurrentObject->oIntroLakituCloud); + if (o->oTimer == TIMER2) { + obj_mark_for_deletion(o); + obj_mark_for_deletion(o->oIntroLakituCloud); } + #ifndef VERSION_JP - if (gCurrentObject->oTimer == 14) + if (o->oTimer == 14) { cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45F); + } #endif break; + case 100: cur_obj_enable_rendering(); - vec3f_set(sp64, -100.f, 100.f, 300.f); + + vec3f_set(sp64, -100.0f, 100.0f, 300.0f); offset_rotated(sp4C, gCamera->pos, sp64, sMarioCamState->faceAngle); - vec3f_to_object_pos(gCurrentObject, sp4C); - gCurrentObject->oMoveAnglePitch = 0x1000; - gCurrentObject->oMoveAngleYaw = 0x9000; - gCurrentObject->oFaceAnglePitch = gCurrentObject->oMoveAnglePitch / 2; - gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw; - gCurrentObject->oAction += 1; + vec3f_to_object_pos(o, sp4C); + + o->oMoveAnglePitch = 0x1000; + o->oMoveAngleYaw = 0x9000; + o->oFaceAnglePitch = o->oMoveAnglePitch / 2; + o->oFaceAngleYaw = o->oMoveAngleYaw; + + o->oAction++; break; case 101: - object_pos_to_vec3f(sp4C, gCurrentObject); - if (gCurrentObject->oTimer > 60) { - gCurrentObject->oForwardVel = - approach_f32_asymptotic(gCurrentObject->oForwardVel, -10.f, 0.05f); - gCurrentObject->oMoveAngleYaw += 0x78; - gCurrentObject->oMoveAnglePitch += 0x40; - gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric( - gCurrentObject->oFaceAngleYaw, (s16) calculate_yaw(sp4C, gCamera->pos), - 0x200); + object_pos_to_vec3f(sp4C, o); + + if (o->oTimer > 60) { + o->oForwardVel = approach_f32_asymptotic(o->oForwardVel, -10.0f, 0.05f); + o->oMoveAngleYaw += 0x78; + o->oMoveAnglePitch += 0x40; + o->oFaceAngleYaw = camera_approach_s16_symmetric( + o->oFaceAngleYaw, calculate_yaw(sp4C, gCamera->pos), 0x200); } - if (gCurrentObject->oTimer > 105) { - gCurrentObject->oAction += 1; - gCurrentObject->oMoveAnglePitch = 0xE00; + + if (o->oTimer > 105) { + o->oAction++; + o->oMoveAnglePitch = 0xE00; } - gCurrentObject->oFaceAnglePitch = 0; + + o->oFaceAnglePitch = 0; + cur_obj_set_pos_via_transform(); break; case 102: - object_pos_to_vec3f(sp4C, gCurrentObject); - gCurrentObject->oForwardVel = - approach_f32_asymptotic(gCurrentObject->oForwardVel, 60.f, 0.05f); - gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric( - gCurrentObject->oFaceAngleYaw, (s16) calculate_yaw(sp4C, gCamera->pos), 0x200); - if (gCurrentObject->oTimer < 62) - gCurrentObject->oMoveAngleYaw = - approach_s16_asymptotic(gCurrentObject->oMoveAngleYaw, 0x1800, 0x1E); - gCurrentObject->oMoveAnglePitch = - camera_approach_s16_symmetric(gCurrentObject->oMoveAnglePitch, -0x2000, 0x5A); - gCurrentObject->oFaceAnglePitch = 0; + object_pos_to_vec3f(sp4C, o); + + o->oForwardVel = approach_f32_asymptotic(o->oForwardVel, 60.0f, 0.05f); + o->oFaceAngleYaw = camera_approach_s16_symmetric( + o->oFaceAngleYaw, calculate_yaw(sp4C, gCamera->pos), 0x200); + + if (o->oTimer < 62) { + o->oMoveAngleYaw = approach_s16_asymptotic(o->oMoveAngleYaw, 0x1800, 0x1E); + } + + o->oMoveAnglePitch = camera_approach_s16_symmetric(o->oMoveAnglePitch, -0x2000, 0x5A); + o->oFaceAnglePitch = 0; + cur_obj_set_pos_via_transform(); break; } } -#undef TIMER + +#undef TIMER1 +#undef TIMER2 diff --git a/src/game/behaviors/intro_peach.inc.c b/src/game/behaviors/intro_peach.inc.c index 37b40301..551b3108 100644 --- a/src/game/behaviors/intro_peach.inc.c +++ b/src/game/behaviors/intro_peach.inc.c @@ -4,50 +4,58 @@ * Set peach's location relative to the camera focus. * If nonzero, make peach's opacity approach targetOpacity by increment */ -void intro_peach_set_pos_and_opacity(struct Object *o, f32 targetOpacity, f32 increment) { +void intro_peach_set_pos_and_opacity(struct Object *obj, f32 targetOpacity, f32 increment) { Vec3f newPos; s16 focusPitch, focusYaw; f32 UNUSED dist, newOpacity; vec3f_get_dist_and_angle(gLakituState.pos, gLakituState.focus, &dist, &focusPitch, &focusYaw); - vec3f_set_dist_and_angle(gLakituState.pos, newPos, o->oIntroPeachDistToCamera, o->oIntroPeachPitchFromFocus + focusPitch, - o->oIntroPeachYawFromFocus + focusYaw); - vec3f_to_object_pos(o, newPos); - newOpacity = o->oOpacity; + vec3f_set_dist_and_angle(gLakituState.pos, newPos, obj->oIntroPeachDistToCamera, + obj->oIntroPeachPitchFromFocus + focusPitch, + obj->oIntroPeachYawFromFocus + focusYaw); + vec3f_to_object_pos(obj, newPos); + + newOpacity = obj->oOpacity; camera_approach_f32_symmetric_bool(&newOpacity, targetOpacity, increment); - o->oOpacity = newOpacity; + obj->oOpacity = newOpacity; } void bhv_intro_peach_loop(void) { - switch (gCurrentObject->oAction) { + switch (o->oAction) { case 0: - gCurrentObject->oAction += 1; - gCurrentObject->oFaceAnglePitch = 0x400; - gCurrentObject->oFaceAngleYaw = 0x7500; - gCurrentObject->oFaceAngleRoll = -0x3700; - gCurrentObject->oIntroPeachDistToCamera = 186.f; - gCurrentObject->oIntroPeachPitchFromFocus = -9984.f; - gCurrentObject->oIntroPeachYawFromFocus = -768.f; - gCurrentObject->oOpacity = 255; - gCurrentObject->header.gfx.animInfo.animFrame = 100; + o->oAction++; + o->oFaceAnglePitch = 0x400; + o->oFaceAngleYaw = 0x7500; + o->oFaceAngleRoll = -0x3700; + o->oIntroPeachDistToCamera = 186.0f; + o->oIntroPeachPitchFromFocus = -9984.0f; + o->oIntroPeachYawFromFocus = -768.0f; + o->oOpacity = 255; + o->header.gfx.animInfo.animFrame = 100; break; + case 1: - intro_peach_set_pos_and_opacity(gCurrentObject, 0.f, 0.f); + intro_peach_set_pos_and_opacity(o, 0.0f, 0.0f); - if (gCurrentObject->oTimer > 20) - gCurrentObject->oAction += 1; + if (o->oTimer > 20) { + o->oAction++; + } break; + case 2: - intro_peach_set_pos_and_opacity(gCurrentObject, 255.f, 3.f); + intro_peach_set_pos_and_opacity(o, 255.0f, 3.0f); - if ((gCurrentObject->oTimer > 100) && (get_dialog_id() == DIALOG_NONE)) - gCurrentObject->oAction += 1; + if ((o->oTimer > 100) && (get_dialog_id() == DIALOG_NONE)) { + o->oAction++; + } break; - case 3: - intro_peach_set_pos_and_opacity(gCurrentObject, 0.f, 8.f); - if (gCurrentObject->oTimer > 60) - obj_mark_for_deletion(gCurrentObject); + case 3: + intro_peach_set_pos_and_opacity(o, 0.0f, 8.0f); + + if (o->oTimer > 60) { + obj_mark_for_deletion(o); + } break; } } diff --git a/src/game/behaviors/intro_scene.inc.c b/src/game/behaviors/intro_scene.inc.c index 7b6a2475..42d5e806 100644 --- a/src/game/behaviors/intro_scene.inc.c +++ b/src/game/behaviors/intro_scene.inc.c @@ -1,73 +1,84 @@ // intro_scene.inc.c -void spawn_child_obj_relative(struct Object *parent, s16 xOffset, s16 yOffset, s16 zOffset, s16 pitchOffset, - s16 yawOffset, s16 rollOffset, s16 forwardVel, - s32 model, const BehaviorScript *behavior) { - struct Object *sp1C = spawn_object(parent, model, behavior); +void spawn_child_obj_relative(struct Object *parent, s16 xOffset, s16 yOffset, s16 zOffset, + s16 pitchOffset, s16 yawOffset, s16 rollOffset, + s16 forwardVel, s32 model, const BehaviorScript *behavior) { + struct Object *obj = spawn_object(parent, model, behavior); - sp1C->header.gfx.animInfo.animFrame = random_float() * 6.f; - sp1C->oEndBirdUnk104 = sCutsceneVars[9].point[0]; - sCutsceneVars[9].point[0] += 1.f; - sp1C->oPosX += xOffset; - sp1C->oPosY += yOffset; - if (gCutsceneTimer > 700) - sp1C->oPosY += -150.f; - sp1C->oPosZ += zOffset; - sp1C->oMoveAnglePitch += pitchOffset; - sp1C->oMoveAngleYaw += yawOffset; - sp1C->oMoveAngleRoll += rollOffset; - sp1C->oForwardVel = forwardVel; + obj->header.gfx.animInfo.animFrame = random_float() * 6.0f; + obj->oEndBirdUnk104 = sCutsceneVars[9].point[0]; + + sCutsceneVars[9].point[0] += 1.0f; + + obj->oPosX += xOffset; + obj->oPosY += yOffset; + + if (gCutsceneTimer > 700) { + obj->oPosY += -150.0f; + } + + obj->oPosZ += zOffset; + obj->oMoveAnglePitch += pitchOffset; + obj->oMoveAngleYaw += yawOffset; + obj->oMoveAngleRoll += rollOffset; + obj->oForwardVel = forwardVel; } void bhv_intro_scene_loop(void) { - UNUSED struct Object *sp34; + UNUSED struct Object *obj; if (gCutsceneObjSpawn != 0) { - gCurrentObject->oPosX = gCamera->pos[0]; - gCurrentObject->oPosY = gCamera->pos[1]; - gCurrentObject->oPosZ = gCamera->pos[2]; - gCurrentObject->oMoveAnglePitch = 0; - gCurrentObject->oMoveAngleYaw = 0; + o->oPosX = gCamera->pos[0]; + o->oPosY = gCamera->pos[1]; + o->oPosZ = gCamera->pos[2]; + + o->oMoveAnglePitch = 0; + o->oMoveAngleYaw = 0; switch (gCutsceneObjSpawn) { case 6: - sp34 = spawn_object(gCurrentObject, MODEL_LAKITU, bhvBeginningLakitu); + obj = spawn_object(o, MODEL_LAKITU, bhvBeginningLakitu); break; + case 5: - sp34 = spawn_object(gCurrentObject, MODEL_PEACH, bhvBeginningPeach); + obj = spawn_object(o, MODEL_PEACH, bhvBeginningPeach); break; + case 7: - spawn_child_obj_relative(gCurrentObject, 0, 205, 500, 0x1000, 0x6000, -0x1E00, 25, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, 0, 205, 800, 0x1800, 0x6000, -0x1400, 35, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, -100, 300, 500, 0x800, 0x6000, 0, 25, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, 100, -200, 800, 0, 0x4000, 0x1400, 45, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, -80, 300, 350, 0x1800, 0x5000, 0xA00, 35, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, -300, 300, 500, 0x800, 0x6000, 0x2800, 25, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, -400, -200, 800, 0, 0x4000, -0x1400, 45, MODEL_BIRDS, - bhvEndBirds1); + spawn_child_obj_relative( + o, 0, 205, 500, 0x1000, 0x6000, -0x1E00, 25, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, 0, 205, 800, 0x1800, 0x6000, -0x1400, 35, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, -100, 300, 500, 0x800, 0x6000, 0, 25, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, 100, -200, 800, 0, 0x4000, 0x1400, 45, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, -80, 300, 350, 0x1800, 0x5000, 0xA00, 35, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, -300, 300, 500, 0x800, 0x6000, 0x2800, 25, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, -400, -200, 800, 0, 0x4000, -0x1400, 45, MODEL_BIRDS, bhvEndBirds1); break; + case 9: - spawn_child_obj_relative(gCurrentObject, 50, 205, 500, 0x1000, 0x6000, 0, 35, MODEL_BIRDS, - bhvEndBirds1); - spawn_child_obj_relative(gCurrentObject, 0, 285, 800, 0x1800, 0x6000, 0, 35, MODEL_BIRDS, - bhvEndBirds1); + spawn_child_obj_relative( + o, 50, 205, 500, 0x1000, 0x6000, 0, 35, MODEL_BIRDS, bhvEndBirds1); + spawn_child_obj_relative( + o, 0, 285, 800, 0x1800, 0x6000, 0, 35, MODEL_BIRDS, bhvEndBirds1); break; + case 8: - spawn_child_obj_relative(gCurrentObject, -100, -100, -700, 0, 0, -0xF00, 25, MODEL_BIRDS, - bhvEndBirds2); - spawn_child_obj_relative(gCurrentObject, -250, 255, -200, 0, 0, -0x1400, 25, MODEL_BIRDS, - bhvEndBirds2); - spawn_child_obj_relative(gCurrentObject, -100, 155, -600, 0, 0, -0x500, 35, MODEL_BIRDS, - bhvEndBirds2); - spawn_child_obj_relative(gCurrentObject, 250, 200, -1200, 0, 0, -0x700, 25, MODEL_BIRDS, - bhvEndBirds2); - spawn_child_obj_relative(gCurrentObject, -250, 255, -700, 0, 0, 0, 25, MODEL_BIRDS, bhvEndBirds2); + spawn_child_obj_relative( + o, -100, -100, -700, 0, 0, -0xF00, 25, MODEL_BIRDS, bhvEndBirds2); + spawn_child_obj_relative( + o, -250, 255, -200, 0, 0, -0x1400, 25, MODEL_BIRDS, bhvEndBirds2); + spawn_child_obj_relative( + o, -100, 155, -600, 0, 0, -0x500, 35, MODEL_BIRDS, bhvEndBirds2); + spawn_child_obj_relative( + o, 250, 200, -1200, 0, 0, -0x700, 25, MODEL_BIRDS, bhvEndBirds2); + spawn_child_obj_relative( + o, -250, 255, -700, 0, 0, 0, 25, MODEL_BIRDS, bhvEndBirds2); break; } diff --git a/src/game/behaviors/jrb_ship.inc.c b/src/game/behaviors/jrb_ship.inc.c index 3b627da0..0918d8d0 100644 --- a/src/game/behaviors/jrb_ship.inc.c +++ b/src/game/behaviors/jrb_ship.inc.c @@ -1,36 +1,43 @@ -// jrb_ship.c.inc +// jrb_ship.inc.c struct ObjectHitbox sSkullSlidingBoxHitbox = { - /* interactType: */ INTERACT_DAMAGE, - /* downOffset: */ 0, + /* interactType: */ INTERACT_DAMAGE, + /* downOffset: */ 0, /* damageOrCoinValue: */ 1, - /* health: */ 1, - /* numLootCoins: */ 0, - /* radius: */ 130, - /* height: */ 100, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 1, + /* numLootCoins: */ 0, + /* radius: */ 130, + /* height: */ 100, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; void bhv_sunken_ship_part_loop(void) { - if (o->oDistanceToMario > 10000.0f) + if (o->oDistanceToMario > 10000.0f) { o->oOpacity = 140; - else + } else { o->oOpacity = o->oDistanceToMario * 140.0f / 10000.0; + } + cur_obj_disable_rendering(); } void bhv_ship_part_3_loop(void) { s16 sp1E = o->oFaceAnglePitch; s16 sp1C = o->oFaceAngleRoll; + cur_obj_set_pos_to_home_with_debug(); + o->oShipPart3UnkF4 += 0x100; - o->oFaceAnglePitch = sins(o->oShipPart3UnkF4) * 1024.0f; - o->oFaceAngleRoll = sins(o->oShipPart3UnkF8) * 1024.0f; + + o->oFaceAnglePitch = sins(o->oShipPart3UnkF4) * 0x400; + o->oFaceAngleRoll = sins(o->oShipPart3UnkF8) * 0x400; o->oAngleVelPitch = o->oFaceAnglePitch - sp1E; o->oAngleVelRoll = o->oFaceAngleRoll - sp1C; - if (gMarioObject->oPosY > 1000.0f) + + if (gMarioObject->oPosY > 1000.0f) { cur_obj_play_sound_1(SOUND_ENV_BOAT_ROCKING1); + } } void bhv_jrb_sliding_box_loop(void) { @@ -43,47 +50,66 @@ void bhv_jrb_sliding_box_loop(void) { UNUSED Vec3f sp2C; Vec3f sp20; s16 sp1E; + if (o->oJrbSlidingBoxUnkF4 == NULL) { sp3C = cur_obj_nearest_object_with_behavior(bhvInSunkenShip3); - if (sp3C != NULL) // NULL check only for assignment, not for dereference? + + if (sp3C != NULL) { // NULL check only for assignment, not for dereference? o->oJrbSlidingBoxUnkF4 = sp3C; + } + o->oParentRelativePosX = o->oPosX - sp3C->oPosX; o->oParentRelativePosY = o->oPosY - sp3C->oPosY; o->oParentRelativePosZ = o->oPosZ - sp3C->oPosZ; } else { sp3C = o->oJrbSlidingBoxUnkF4; + sp40[0] = sp3C->oFaceAnglePitch; sp40[1] = sp3C->oFaceAngleYaw; sp40[2] = sp3C->oFaceAngleRoll; + sp54[0] = o->oParentRelativePosX; sp54[1] = o->oParentRelativePosY; sp54[2] = o->oParentRelativePosZ; + mtxf_rotate_zxy_and_translate(sp60, sp54, sp40); linear_mtxf_mul_vec3f(sp60, sp48, sp54); + o->oPosX = sp3C->oPosX + sp48[0]; o->oPosY = sp3C->oPosY + sp48[1]; o->oPosZ = sp3C->oPosZ + sp48[2]; + sp1E = sp3C->oFaceAnglePitch; } + sp20[0] = o->oPosX; sp20[1] = o->oPosY; sp20[2] = o->oPosZ; + find_floor(sp20[0], sp20[1], sp20[2], &sp38); + if (sp38 != NULL) { sp2C[0] = sp38->normal.x; sp2C[1] = sp38->normal.y; sp2C[2] = sp38->normal.z; + o->oFaceAnglePitch = sp1E; } + o->oJrbSlidingBoxUnkFC = sins(o->oJrbSlidingBoxUnkF8) * 20.0f; o->oJrbSlidingBoxUnkF8 += 0x100; o->oParentRelativePosZ += o->oJrbSlidingBoxUnkFC; - if (gMarioObject->oPosY > 1000.0f) - if (absf(o->oJrbSlidingBoxUnkFC) > 3.0f) - cur_obj_play_sound_1(SOUND_AIR_ROUGH_SLIDE); + + if (gMarioObject->oPosY > 1000.0f && absf(o->oJrbSlidingBoxUnkFC) > 3.0f) { + cur_obj_play_sound_1(SOUND_AIR_ROUGH_SLIDE); + } + obj_set_hitbox(o, &sSkullSlidingBoxHitbox); - if (!(o->oJrbSlidingBoxUnkF8 & 0x7FFF)) + + if (!(o->oJrbSlidingBoxUnkF8 & 0x7FFF)) { cur_obj_become_tangible(); + } + if (obj_check_if_collided_with_object(o, gMarioObject)) { o->oInteractStatus = 0; cur_obj_become_intangible(); diff --git a/src/game/behaviors/jumping_box.inc.c b/src/game/behaviors/jumping_box.inc.c index 5c86169d..2a8fc9cd 100644 --- a/src/game/behaviors/jumping_box.inc.c +++ b/src/game/behaviors/jumping_box.inc.c @@ -1,21 +1,23 @@ -// jumping_box.c.inc +// jumping_box.inc.c struct ObjectHitbox sJumpingBoxHitbox = { - /* interactType: */ INTERACT_GRABBABLE, - /* downOffset: */ 20, + /* interactType: */ INTERACT_GRABBABLE, + /* downOffset: */ 20, /* damageOrCoinValue: */ 0, - /* health: */ 1, - /* numLootCoins: */ 5, - /* radius: */ 150, - /* height: */ 250, - /* hurtboxRadius: */ 150, - /* hurtboxHeight: */ 250, + /* health: */ 1, + /* numLootCoins: */ 5, + /* radius: */ 150, + /* height: */ 250, + /* hurtboxRadius: */ 150, + /* hurtboxHeight: */ 250, }; void jumping_box_act_0(void) { if (o->oSubAction == 0) { - if (o->oJumpingBoxUnkF8-- < 0) + if (o->oJumpingBoxUnkF8-- < 0) { o->oSubAction++; + } + if (o->oTimer > o->oJumpingBoxUnkF4) { o->oVelY = random_float() * 5.0f + 15.0f; o->oSubAction++; @@ -33,7 +35,10 @@ void jumping_box_act_1(void) { } } -void (*sJumpingBoxActions[])(void) = { jumping_box_act_0, jumping_box_act_1 }; +void (*sJumpingBoxActions[])(void) = { + jumping_box_act_0, + jumping_box_act_1, +}; void jumping_box_free_update(void) { cur_obj_set_model(MODEL_BREAKABLE_BOX); @@ -49,22 +54,27 @@ void bhv_jumping_box_loop(void) { case HELD_FREE: jumping_box_free_update(); break; + case HELD_HELD: obj_copy_pos(o, gMarioObject); cur_obj_set_model(MODEL_BREAKABLE_BOX_SMALL); cur_obj_unrender_set_action_and_anim(-1, 0); break; + case HELD_THROWN: cur_obj_get_thrown_or_placed(40.0f, 20.0f, 1); break; + case HELD_DROPPED: cur_obj_get_dropped(); o->oAction = 1; break; } + if (o->oInteractStatus & INT_STATUS_STOP_RIDING) { create_sound_spawner(SOUND_GENERAL_BREAK_BOX); obj_explode_and_spawn_coins(46.0f, 1); } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/kickable_board.inc.c b/src/game/behaviors/kickable_board.inc.c index 8ba05e54..87cf7466 100644 --- a/src/game/behaviors/kickable_board.inc.c +++ b/src/game/behaviors/kickable_board.inc.c @@ -1,22 +1,28 @@ -// kickable_board.c.inc +// kickable_board.inc.c -s32 check_mario_attacking(UNUSED s32 sp18) { - if (obj_check_if_collided_with_object(o, gMarioObject)) { - if (abs_angle_diff(o->oMoveAngleYaw, gMarioObject->oMoveAngleYaw) > 0x6000) { - if (gMarioStates[0].action == ACT_SLIDE_KICK) - return 1; - if (gMarioStates[0].action == ACT_PUNCHING) - return 1; - if (gMarioStates[0].action == ACT_MOVE_PUNCHING) - return 1; - if (gMarioStates[0].action == ACT_SLIDE_KICK_SLIDE) - return 1; - if (gMarioStates[0].action == ACT_JUMP_KICK) - return 2; - if (gMarioStates[0].action == ACT_WALL_KICK_AIR) - return 2; +s32 check_mario_attacking(UNUSED s32 unused) { + if (obj_check_if_collided_with_object(o, gMarioObject) + && abs_angle_diff(o->oMoveAngleYaw, gMarioObject->oMoveAngleYaw) > 0x6000) { + if (gMarioStates[0].action == ACT_SLIDE_KICK) { + return 1; + } + if (gMarioStates[0].action == ACT_PUNCHING) { + return 1; + } + if (gMarioStates[0].action == ACT_MOVE_PUNCHING) { + return 1; + } + if (gMarioStates[0].action == ACT_SLIDE_KICK_SLIDE) { + return 1; + } + if (gMarioStates[0].action == ACT_JUMP_KICK) { + return 2; + } + if (gMarioStates[0].action == ACT_WALL_KICK_AIR) { + return 2; } } + return 0; } @@ -27,53 +33,72 @@ void init_kickable_board_rock(void) { void bhv_kickable_board_loop(void) { s32 sp24; + switch (o->oAction) { case 0: o->oFaceAnglePitch = 0; - if (check_mario_attacking(0)) { + + if (check_mario_attacking(0) != 0) { init_kickable_board_rock(); o->oAction++; } + load_object_collision_model(); break; + case 1: o->oFaceAnglePitch = 0; load_object_collision_model(); o->oFaceAnglePitch = -sins(o->oKickableBoardF4) * o->oKickableBoardF8; + if (o->oTimer > 30 && (sp24 = check_mario_attacking(0))) { if (gMarioObject->oPosY > o->oPosY + 160.0f && sp24 == 2) { o->oAction++; cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2); - } else + } else { o->oTimer = 0; + } } + if (o->oTimer != 0) { o->oKickableBoardF8 -= 8; - if (o->oKickableBoardF8 < 0) + if (o->oKickableBoardF8 < 0) { o->oAction = 0; - } else + } + } else { init_kickable_board_rock(); - if (!(o->oKickableBoardF4 & 0x7FFF)) + } + + if (!(o->oKickableBoardF4 & 0x7FFF)) { cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2); + } + o->oKickableBoardF4 += 0x400; break; + case 2: cur_obj_become_intangible(); cur_obj_set_model(MODEL_WF_KICKABLE_BOARD_FELLED); + o->oAngleVelPitch -= 0x80; o->oFaceAnglePitch += o->oAngleVelPitch; + if (o->oFaceAnglePitch < -0x4000) { o->oFaceAnglePitch = -0x4000; o->oAngleVelPitch = 0; o->oAction++; + cur_obj_shake_screen(SHAKE_POS_SMALL); cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4); } + load_object_collision_model(); break; + case 3: load_object_collision_model(); break; } + o->header.gfx.throwMatrix = NULL; } diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index 7741c64b..3c35449d 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -1,23 +1,22 @@ -// king_bobomb.c.inc +// king_bobomb.inc.c // Copy of geo_update_projectile_pos_from_parent Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) { - Mat4 sp20; - struct Object *sp1C; - if (run == TRUE) { - sp1C = (struct Object *) gCurGraphNodeObject; + Mat4 sp20; + struct Object *sp1C = (struct Object *) gCurGraphNodeObject; if (sp1C->prevObj != NULL) { create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr); obj_update_pos_from_parent_transformation(sp20, sp1C->prevObj); obj_set_gfx_pos_from_pos(sp1C->prevObj); } } + return NULL; } void bhv_bobomb_anchor_mario_loop(void) { - common_anchor_mario_behavior(50.0f, 50.0f, 64); + common_anchor_mario_behavior(50.0f, 50.0f, INT_STATUS_MARIO_UNK6); } void king_bobomb_act_0(void) { @@ -25,12 +24,14 @@ void king_bobomb_act_0(void) { o->oForwardVel = 0.0f; o->oVelY = 0.0f; #endif + if (o->oSubAction == 0) { cur_obj_become_intangible(); gSecondCameraFocus = o; cur_obj_init_animation_with_sound(5); cur_obj_set_pos_to_home(); o->oHealth = 3; + if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) { o->oSubAction++; seq_player_lower_volume(SEQ_PLAYER_LEVEL, 60, 40); @@ -52,21 +53,28 @@ s32 mario_is_far_below_object(f32 arg0) { void king_bobomb_act_2(void) { cur_obj_become_tangible(); + if (o->oPosY - o->oHomeY < -100.0f) { // Thrown off hill o->oAction = 5; cur_obj_become_intangible(); } + if (o->oKingBobombUnk100 == 0) { - if (cur_obj_check_anim_frame(15)) + if (cur_obj_check_anim_frame(15)) { cur_obj_shake_screen(SHAKE_POS_SMALL); - if (cur_obj_init_animation_and_check_if_near_end(4)) + } + + if (cur_obj_init_animation_and_check_if_near_end(4)) { o->oKingBobombUnk100++; + } } else { if (o->oKingBobombUnk100 == 1) { cur_obj_init_animation_and_anim_frame(11, 7); o->oKingBobombUnk100 = 2; - } else + } else { cur_obj_init_animation_with_sound(11); + } + if (o->oKingBobombUnk108 == 0) { o->oForwardVel = 3.0f; cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x100); @@ -75,8 +83,11 @@ void king_bobomb_act_2(void) { o->oKingBobombUnk108--; } } - if (cur_obj_check_grabbed_mario()) + + if (cur_obj_check_grabbed_mario()) { o->oAction = 3; + } + if (mario_is_far_below_object(1200.0f)) { o->oAction = 0; stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); @@ -85,53 +96,64 @@ void king_bobomb_act_2(void) { void king_bobomb_act_3(void) { if (o->oSubAction == 0) { - o->oForwardVel = 0; + o->oForwardVel = 0.0f; o->oKingBobombUnk104 = 0; o->oKingBobombUnkFC = 0; - if (o->oTimer == 0) + + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN3); + } + if (cur_obj_init_animation_and_check_if_near_end(0)) { o->oSubAction++; cur_obj_init_animation_and_anim_frame(1, 0); } - } else { - if (o->oSubAction == 1) { - cur_obj_init_animation_with_sound(1); - o->oKingBobombUnkFC += player_performed_grab_escape_action(); - print_debug_bottom_up("%d", o->oKingBobombUnkFC); - if (o->oKingBobombUnkFC > 10) { - o->oKingBobombUnk88 = 3; - o->oAction = 2; - o->oKingBobombUnk108 = 35; - o->oInteractStatus &= ~(INT_STATUS_GRABBED_MARIO); - } else { - o->oForwardVel = 3.0f; - if (o->oKingBobombUnk104 > 20 && cur_obj_rotate_yaw_toward(0, 0x400)) { - o->oSubAction++; - cur_obj_init_animation_and_anim_frame(9, 22); - } - } - o->oKingBobombUnk104++; + } else if (o->oSubAction == 1) { + cur_obj_init_animation_with_sound(1); + o->oKingBobombUnkFC += player_performed_grab_escape_action(); + + print_debug_bottom_up("%d", o->oKingBobombUnkFC); + + if (o->oKingBobombUnkFC > 10) { + o->oKingBobombUnk88 = 3; + o->oAction = 2; + o->oKingBobombUnk108 = 35; + o->oInteractStatus &= ~INT_STATUS_GRABBED_MARIO; } else { - cur_obj_init_animation_with_sound(9); - if (cur_obj_check_anim_frame(31)) { - o->oKingBobombUnk88 = 2; - cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN4); - } else if (cur_obj_check_if_near_animation_end()) { - o->oAction = 1; - o->oInteractStatus &= ~(INT_STATUS_GRABBED_MARIO); + o->oForwardVel = 3.0f; + + if (o->oKingBobombUnk104 > 20 && cur_obj_rotate_yaw_toward(0, 0x400)) { + o->oSubAction++; + cur_obj_init_animation_and_anim_frame(9, 22); } } + + o->oKingBobombUnk104++; + } else { + cur_obj_init_animation_with_sound(9); + + if (cur_obj_check_anim_frame(31)) { + o->oKingBobombUnk88 = 2; + cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN4); + } else if (cur_obj_check_if_near_animation_end()) { + o->oAction = 1; + o->oInteractStatus &= ~INT_STATUS_GRABBED_MARIO; + } } } void king_bobomb_act_1(void) { - o->oForwardVel = 0; - o->oVelY = 0; + o->oForwardVel = 0.0f; + o->oVelY = 0.0f; + cur_obj_init_animation_with_sound(11); - o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, 512); - if (o->oDistanceToMario < 2500.0f) + + o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, 0x200); + + if (o->oDistanceToMario < 2500.0f) { o->oAction = 2; + } + if (mario_is_far_below_object(1200.0f)) { o->oAction = 0; stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); @@ -142,29 +164,36 @@ void king_bobomb_act_6(void) { if (o->oSubAction == 0) { if (o->oTimer == 0) { o->oKingBobombUnk104 = 0; + cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB); cur_obj_play_sound_2(SOUND_OBJ2_KING_BOBOMB_DAMAGE); cur_obj_shake_screen(SHAKE_POS_SMALL); spawn_mist_particles_variable(0, 0, 100.0f); - o->oInteractType = 8; + + o->oInteractType = INTERACT_DAMAGE; + cur_obj_become_tangible(); } - if (cur_obj_init_animation_and_check_if_near_end(2)) + + if (cur_obj_init_animation_and_check_if_near_end(2)) { o->oKingBobombUnk104++; + } + if (o->oKingBobombUnk104 > 3) { o->oSubAction++; } + } else if (o->oSubAction == 1) { + if (cur_obj_init_animation_and_check_if_near_end(10)) { + o->oSubAction++; + o->oInteractType = INTERACT_GRABBABLE; + + cur_obj_become_intangible(); + } } else { - if (o->oSubAction == 1) { - if (cur_obj_init_animation_and_check_if_near_end(10)) { - o->oSubAction++; - o->oInteractType = 2; - cur_obj_become_intangible(); - } - } else { - cur_obj_init_animation_with_sound(11); - if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x800) == 1) - o->oAction = 2; + cur_obj_init_animation_with_sound(11); + + if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x800) == TRUE) { + o->oAction = 2; } } } @@ -174,107 +203,142 @@ void king_bobomb_act_7(void) { if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TEXT_DEFAULT, CUTSCENE_DIALOG, DIALOG_116)) { create_sound_spawner(SOUND_OBJ_KING_WHOMP_DEATH); + cur_obj_hide(); cur_obj_become_intangible(); + spawn_mist_particles_variable(0, 0, 200.0f); spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4); cur_obj_shake_screen(SHAKE_POS_SMALL); + #ifndef VERSION_JP cur_obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f); #else o->oPosY += 100.0f; spawn_default_star(2000.0f, 4500.0f, -4500.0f); #endif + o->oAction = 8; } } void king_bobomb_act_8(void) { - if (o->oTimer == 60) + if (o->oTimer == 60) { stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); + } } void king_bobomb_act_4(void) { // bobomb been thrown if (o->oPosY - o->oHomeY > -100.0f) { // not thrown off hill if (o->oMoveFlags & OBJ_MOVE_LANDED) { o->oHealth--; - o->oForwardVel = 0; - o->oVelY = 0; + + o->oForwardVel = 0.0f; + o->oVelY = 0.0f; + cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB); - if (o->oHealth) + + if (o->oHealth != 0) { o->oAction = 6; - else + } else { o->oAction = 7; + } + } + } else if (o->oSubAction == 0) { + if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) { + o->oForwardVel = 0.0f; + o->oVelY = 0.0f; + + o->oSubAction++; + } else if (o->oMoveFlags & OBJ_MOVE_LANDED) { + cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB); } } else { - if (o->oSubAction == 0) { - if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) { - o->oForwardVel = 0; - o->oVelY = 0; - o->oSubAction++; - } else if (o->oMoveFlags & OBJ_MOVE_LANDED) - cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB); - } else { - if (cur_obj_init_animation_and_check_if_near_end(10)) - o->oAction = 5; // Go back to top of hill - o->oSubAction++; + if (cur_obj_init_animation_and_check_if_near_end(10)) { + o->oAction = 5; // Go back to top of hill } + + o->oSubAction++; } } void king_bobomb_act_5(void) { // bobomb returns home switch (o->oSubAction) { case 0: - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB_JUMP); + } + o->oKingBobombUnkF8 = 1; + cur_obj_init_animation_and_extend_if_at_end(8); - o->oMoveAngleYaw = cur_obj_angle_to_home(); - if (o->oPosY < o->oHomeY) + o->oMoveAngleYaw = cur_obj_angle_to_home(); + + if (o->oPosY < o->oHomeY) { o->oVelY = 100.0f; - else { + } else { arc_to_goal_pos(&o->oHomeX, &o->oPosX, 100.0f, -4.0f); o->oSubAction++; } break; + case 1: cur_obj_init_animation_and_extend_if_at_end(8); + if (o->oVelY < 0 && o->oPosY < o->oHomeY) { o->oPosY = o->oHomeY; o->oVelY = 0; o->oForwardVel = 0; o->oGravity = -4.0f; + o->oKingBobombUnkF8 = 0; + cur_obj_init_animation_with_sound(7); cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB); cur_obj_shake_screen(SHAKE_POS_SMALL); + o->oSubAction++; } break; + case 2: - if (cur_obj_init_animation_and_check_if_near_end(7)) + if (cur_obj_init_animation_and_check_if_near_end(7)) { o->oSubAction++; + } break; + case 3: if (mario_is_far_below_object(1200.0f)) { o->oAction = 0; stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); } - if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) + + if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) { o->oSubAction++; + } break; + case 4: if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, - DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_128)) + DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_128)) { o->oAction = 2; + } break; } } void (*sKingBobombActions[])(void) = { - king_bobomb_act_0, king_bobomb_act_1, king_bobomb_act_2, king_bobomb_act_3, king_bobomb_act_4, - king_bobomb_act_5, king_bobomb_act_6, king_bobomb_act_7, king_bobomb_act_8, + king_bobomb_act_0, + king_bobomb_act_1, + king_bobomb_act_2, + king_bobomb_act_3, + king_bobomb_act_4, + king_bobomb_act_5, + king_bobomb_act_6, + king_bobomb_act_7, + king_bobomb_act_8, }; + struct SoundState sKingBobombSoundStates[] = { { 0, 0, 0, NO_SOUND }, { 1, 1, 20, SOUND_OBJ_POUNDING1_HIGHPRIO }, @@ -292,23 +356,30 @@ struct SoundState sKingBobombSoundStates[] = { void king_bobomb_move(void) { cur_obj_update_floor_and_walls(); - if (o->oKingBobombUnkF8 == 0) + + if (o->oKingBobombUnkF8 == 0) { cur_obj_move_standard(-78); - else + } else { cur_obj_move_using_fvel_and_gravity(); + } + cur_obj_call_action_function(sKingBobombActions); exec_anim_sound_state(sKingBobombSoundStates); - if (o->oDistanceToMario < 5000.0f) + + if (o->oDistanceToMario < 5000.0f) { cur_obj_enable_rendering(); - else + } else { cur_obj_disable_rendering(); + } } void bhv_king_bobomb_loop(void) { f32 sp34 = 20.0f; f32 sp30 = 50.0f; - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; + o->oInteractionSubtype |= INT_SUBTYPE_GRABS_MARIO; + switch (o->oHeldState) { case HELD_FREE: king_bobomb_move(); @@ -323,5 +394,6 @@ void bhv_king_bobomb_loop(void) { o->oPosY += 20.0f; break; } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c index 46d7ffcc..9a1e10b3 100644 --- a/src/game/behaviors/klepto.inc.c +++ b/src/game/behaviors/klepto.inc.c @@ -1,3 +1,5 @@ +// klepto.inc.c + static struct ObjectHitbox sKleptoHitbox = { /* interactType: */ INTERACT_HIT_FROM_BELOW, /* downOffset: */ 0, @@ -61,9 +63,9 @@ static void klepto_anim_dive(void) { } } else { obj_move_pitch_approach(o->oKleptoUnk1B0, 600); - if (klepto_set_and_check_if_anim_at_end() != 0) { + if (klepto_set_and_check_if_anim_at_end()) { if (o->oKleptoUnk1AE != 0) { - o->oKleptoUnk1AE += 1; + o->oKleptoUnk1AE++; } else if (o->oKleptoUnk1B0 > -100) { o->oKleptoUnk1AE = random_linear_offset(60, 60); } @@ -91,14 +93,13 @@ void bhv_klepto_init(void) { static void klepto_change_target(void) { s32 newTarget = 0; - s32 i; - f32 dx; - f32 dz; - f32 targetDist; - f32 minTargetDist; if (o->oDistanceToMario > 2000.0f) { - minTargetDist = 99999.0f; + s32 i; + f32 dx; + f32 dz; + f32 targetDist; + f32 minTargetDist = 99999.0f; for (i = 0; i < 3; i++) { dx = gMarioObject->oPosX - sKleptoTargetPositions[i][0]; @@ -125,9 +126,6 @@ static void klepto_change_target(void) { } static void klepto_circle_target(f32 radius, f32 targetSpeed) { - s16 turnAmount; - f32 accel; - if (o->oAnimState != KLEPTO_ANIM_STATE_HOLDING_NOTHING && ((o->oTimer > 60 && o->oDistanceToMario > 2000.0f) || o->oTimer >= o->oKleptoTimeUntilTargetChange)) { @@ -135,8 +133,9 @@ static void klepto_circle_target(f32 radius, f32 targetSpeed) { o->oKleptoTimeUntilTargetChange = random_linear_offset(300, 300); o->oAction = KLEPTO_ACT_APPROACH_TARGET_HOLDING; } else { - turnAmount = 0x4000 - atan2s(radius, o->oKleptoDistanceToTarget - radius); - accel = 0.05f; + s16 turnAmount = 0x4000 - atan2s(radius, o->oKleptoDistanceToTarget - radius); + f32 accel = 0.05f; + if ((s16)(o->oMoveAngleYaw - o->oKleptoYawToTarget) < 0) { turnAmount = -turnAmount; } @@ -146,8 +145,8 @@ static void klepto_circle_target(f32 radius, f32 targetSpeed) { //! The multiplied value is sometimes out of range for an s16 during the s32 -> s16 cast, // which might invert sign. - turnAmount = - (s16)(s32)(abs_angle_diff(o->oKleptoYawToTarget, o->oMoveAngleYaw) * (0.03f * o->oKleptoSpeed)); + turnAmount = (s16)(s32)(abs_angle_diff(o->oKleptoYawToTarget, o->oMoveAngleYaw) + * (0.03f * o->oKleptoSpeed)); clamp_s16(&turnAmount, 400, 700); obj_rotate_yaw_and_bounce_off_walls(o->oKleptoYawToTarget, turnAmount); @@ -180,7 +179,7 @@ static void klepto_act_wait_for_mario(void) { klepto_target_mario(); if (o->oKleptoDistanceToTarget < 1000.0f) { o->oAction = KLEPTO_ACT_TURN_TOWARD_MARIO; - o->oFlags &= ~0x00000008; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; } } @@ -190,12 +189,13 @@ static void klepto_act_wait_for_mario(void) { static void klepto_act_turn_toward_mario(void) { klepto_target_mario(); - if (klepto_set_and_check_if_anim_at_end() && cur_obj_check_if_at_animation_end() && o->oKleptoDistanceToTarget > 800.0f + if (klepto_set_and_check_if_anim_at_end() && cur_obj_check_if_at_animation_end() + && o->oKleptoDistanceToTarget > 800.0f && abs_angle_diff(o->oAngleToMario, o->oFaceAngleYaw) < 0x800 && o->oKleptoUnk1B0 < 0x400) { cur_obj_play_sound_2(SOUND_OBJ_KLEPTO1); o->oAction = KLEPTO_ACT_DIVE_AT_MARIO; o->oMoveAngleYaw = o->oFaceAngleYaw; - o->oFlags |= 0x00000008; + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; cur_obj_init_animation_with_sound(3); } @@ -206,6 +206,7 @@ static void klepto_act_turn_toward_mario(void) { static void klepto_act_dive_at_mario(void) { approach_f32_ptr(&o->oKleptoSpeed, 60.0f, 10.0f); + if (o->oSoundStateID == 2) { if (cur_obj_check_anim_frame(11)) { cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER); @@ -221,6 +222,7 @@ static void klepto_act_dive_at_mario(void) { } } else { f32 dy = o->oPosY - gMarioObject->oPosY; + if (o->oSoundStateID == 3) { cur_obj_set_anim_if_at_end(4); } else if (o->oVelY > 0.0f && dy > 200.0f) { @@ -228,22 +230,22 @@ static void klepto_act_dive_at_mario(void) { } o->oKleptoUnk1B0 = -0x3000; + if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_NOTHING) { if (o->oSubAction == 0) { o->oKleptoUnk1B0 = obj_turn_pitch_toward_mario(0.0f, 0); o->oKleptoYawToTarget = o->oAngleToMario; if (dy < 160.0f) { - o->oSubAction += 1; + o->oSubAction++; } } if (gMarioStates[0].action != ACT_SLEEPING && !(gMarioStates[0].action & (ACT_FLAG_SHORT_HITBOX | ACT_FLAG_BUTT_OR_STOMACH_SLIDE)) - && o->oDistanceToMario < 200.0f && dy > 50.0f && dy < 90.0f) { - if (mario_lose_cap_to_enemy(1)) { - o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP; - } + && o->oDistanceToMario < 200.0f && dy > 50.0f && dy < 90.0f + && mario_lose_cap_to_enemy(1)) { + o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP; } } } @@ -282,14 +284,13 @@ static void klepto_act_retreat(void) { obj_face_pitch_approach(o->oMoveAnglePitch, 1000); obj_rotate_yaw_and_bounce_off_walls(o->oKleptoYawToTarget, 600); - if (obj_face_yaw_approach(o->oMoveAngleYaw, 1000)) { - if (abs_angle_diff(o->oFaceAnglePitch, o->oMoveAnglePitch) == 0) { - o->oAction = KLEPTO_ACT_RESET_POSITION; - o->oHomeY = 1500.0f; - o->oKleptoUnk1AE = -100; - o->oFlags |= 0x00000008; - cur_obj_become_tangible(); - } + if (obj_face_yaw_approach(o->oMoveAngleYaw, 1000) + && abs_angle_diff(o->oFaceAnglePitch, o->oMoveAnglePitch) == 0) { + o->oAction = KLEPTO_ACT_RESET_POSITION; + o->oHomeY = 1500.0f; + o->oKleptoUnk1AE = -100; + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; + cur_obj_become_tangible(); } } @@ -319,7 +320,7 @@ void obj_set_speed_to_zero(void) { } void bhv_klepto_update(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; cur_obj_update_floor_and_walls(); @@ -371,7 +372,8 @@ void bhv_klepto_update(void) { o->oGravity = -2.0f; o->oMoveAngleYaw = o->oAngleToMario + 0x8000; - o->oFlags &= ~0x00000008; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; + cur_obj_become_intangible(); } else if (gMarioStates[0].action == ACT_SLEEPING || (gMarioStates[0].action diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 8e3e8779..04b345c9 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -53,7 +53,7 @@ static u8 sKoopaShelledAttackHandlers[] = { struct KoopaTheQuickProperties { s16 initText; s16 winText; - void const *path; + Trajectory const *path; Vec3s starPos; }; @@ -62,7 +62,7 @@ struct KoopaTheQuickProperties { */ static struct KoopaTheQuickProperties sKoopaTheQuickProperties[] = { { DIALOG_005, DIALOG_007, bob_seg7_trajectory_koopa, { 3030, 4500, -4600 } }, - { DIALOG_009, DIALOG_031, thi_seg7_trajectory_koopa, { 7100, -1300, -6000 } } + { DIALOG_009, DIALOG_031, thi_seg7_trajectory_koopa, { 7100, -1300, -6000 } }, }; /** @@ -91,6 +91,7 @@ void bhv_koopa_init(void) { */ static void koopa_play_footstep_sound(s8 animFrame1, s8 animFrame2) { s32 sound; + if (o->header.gfx.scale[0] > 1.5f) { sound = SOUND_OBJ_KOOPA_THE_QUICK_WALK; } else { @@ -133,7 +134,7 @@ static void koopa_walk_start(void) { obj_forward_vel_approach(3.0f * o->oKoopaAgility, 0.3f * o->oKoopaAgility); if (cur_obj_init_anim_and_check_if_end(11)) { - o->oSubAction += 1; + o->oSubAction++; o->oKoopaCountdown = random_linear_offset(30, 100); } } @@ -146,9 +147,9 @@ static void koopa_walk(void) { koopa_play_footstep_sound(2, 17); if (o->oKoopaCountdown != 0) { - o->oKoopaCountdown -= 1; + o->oKoopaCountdown--; } else if (cur_obj_check_if_near_animation_end()) { - o->oSubAction += 1; + o->oSubAction++; } } @@ -244,7 +245,7 @@ static void koopa_shelled_act_lying(void) { cur_obj_init_anim_extend(5); koopa_dive_update_speed(0.3f); } else if (o->oKoopaCountdown != 0) { - o->oKoopaCountdown -= 1; + o->oKoopaCountdown--; cur_obj_extend_animation_if_at_end(); } else if (cur_obj_init_anim_and_check_if_end(6)) { o->oAction = KOOPA_SHELLED_ACT_STOPPED; @@ -350,7 +351,7 @@ static void koopa_unshelled_act_run(void) { obj_bounce_off_walls_edges_objects(&o->oKoopaTargetYaw))) { // Otherwise run around randomly if (o->oKoopaUnshelledTimeUntilTurn != 0) { - o->oKoopaUnshelledTimeUntilTurn -= 1; + o->oKoopaUnshelledTimeUntilTurn--; } else { o->oKoopaTargetYaw = obj_random_fixed_turn(0x2000); } @@ -424,7 +425,7 @@ static void koopa_unshelled_act_dive(void) { } koopa_dive_update_speed(0.5f); } else if (o->oKoopaCountdown != 0) { - o->oKoopaCountdown -= 1; + o->oKoopaCountdown--; cur_obj_extend_animation_if_at_end(); } else if (cur_obj_init_anim_and_check_if_end(6)) { o->oAction = KOOPA_UNSHELLED_ACT_RUN; @@ -498,7 +499,7 @@ static void koopa_the_quick_act_wait_before_race(void) { koopa_shelled_act_stopped(); if (o->oKoopaTheQuickInitTextboxCooldown != 0) { - o->oKoopaTheQuickInitTextboxCooldown -= 1; + o->oKoopaTheQuickInitTextboxCooldown--; } else if (cur_obj_can_mario_activate_textbox_2(400.0f, 400.0f)) { //! The next action doesn't execute until next frame, giving mario one // frame where he can jump, and thus no longer be ready to speak. @@ -519,7 +520,7 @@ static void koopa_the_quick_act_show_init_text(void) { sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].initText); if (response == DIALOG_RESPONSE_YES) { - UNUSED s32 unused; + UNUSED u8 filler[4]; gMarioShotFromCannon = FALSE; o->oAction = KOOPA_THE_QUICK_ACT_RACE; @@ -544,13 +545,12 @@ static void koopa_the_quick_act_show_init_text(void) { static s32 koopa_the_quick_detect_bowling_ball(void) { struct Object *ball; f32 distToBall; - s16 angleToBall; - f32 ballSpeedInKoopaRunDir; ball = cur_obj_find_nearest_object_with_behavior(bhvBowlingBall, &distToBall); + if (ball != NULL) { - angleToBall = obj_turn_toward_object(o, ball, O_MOVE_ANGLE_YAW_INDEX, 0); - ballSpeedInKoopaRunDir = ball->oForwardVel * coss(ball->oMoveAngleYaw - o->oMoveAngleYaw); + s16 angleToBall = obj_turn_toward_object(o, ball, O_MOVE_ANGLE_YAW_INDEX, 0); + f32 ballSpeedInKoopaRunDir = ball->oForwardVel * coss(ball->oMoveAngleYaw - o->oMoveAngleYaw); if (abs_angle_diff(o->oMoveAngleYaw, angleToBall) < 0x4000) { // The ball is in front of ktq @@ -593,9 +593,6 @@ static void koopa_the_quick_animate_footsteps(void) { * down or jumping. After finishing the race, enter the decelerate action. */ static void koopa_the_quick_act_race(void) { - f32 downhillSteepness; - s32 bowlingBallStatus; - if (obj_begin_race(FALSE)) { // Hitbox is slightly larger while racing cur_obj_push_mario_away_from_cylinder(180.0f, 300.0f); @@ -603,6 +600,9 @@ static void koopa_the_quick_act_race(void) { if (cur_obj_follow_path(0) == PATH_REACHED_END) { o->oAction = KOOPA_THE_QUICK_ACT_DECELERATE; } else { + f32 downhillSteepness; + s32 bowlingBallStatus; + downhillSteepness = 1.0f + sins((s16)(f32) o->oPathedTargetPitch); cur_obj_rotate_yaw_toward(o->oPathedTargetYaw, (s32)(o->oKoopaAgility * 150.0f)); @@ -663,7 +663,7 @@ static void koopa_the_quick_act_race(void) { // ktq if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { if (cur_obj_init_anim_and_check_if_end(13)) { - o->oSubAction -= 1; + o->oSubAction--; } koopa_the_quick_detect_bowling_ball(); @@ -739,8 +739,8 @@ static void koopa_the_quick_act_after_race(void) { } } else if (o->parentObj->oKoopaRaceEndpointRaceStatus != 0) { spawn_default_star(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[0], - sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[1], - sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[2]); + sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[1], + sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[2]); o->parentObj->oKoopaRaceEndpointRaceStatus = 0; } @@ -790,6 +790,7 @@ static void koopa_the_quick_update(void) { */ void bhv_koopa_update(void) { // PARTIAL_UPDATE + o->oDeathSound = SOUND_OBJ_KOOPA_FLYGUY_DEATH; if (o->oKoopaMovementType >= KOOPA_BP_KOOPA_THE_QUICK_BASE) { diff --git a/src/game/behaviors/koopa_shell.inc.c b/src/game/behaviors/koopa_shell.inc.c index 1fcbf406..dec89024 100644 --- a/src/game/behaviors/koopa_shell.inc.c +++ b/src/game/behaviors/koopa_shell.inc.c @@ -1,23 +1,25 @@ -// koopa_shell.c.inc +// koopa_shell.inc.c struct ObjectHitbox sKoopaShellHitbox = { - /* interactType: */ INTERACT_KOOPA_SHELL, - /* downOffset: */ 0, + /* interactType: */ INTERACT_KOOPA_SHELL, + /* downOffset: */ 0, /* damageOrCoinValue: */ 4, - /* health: */ 1, - /* numLootCoins: */ 1, - /* radius: */ 50, - /* height: */ 50, - /* hurtboxRadius: */ 50, - /* hurtboxHeight: */ 50, + /* health: */ 1, + /* numLootCoins: */ 1, + /* radius: */ 50, + /* height: */ 50, + /* hurtboxRadius: */ 50, + /* hurtboxHeight: */ 50, }; void koopa_shell_spawn_water_drop(void) { - UNUSED s32 unused; - struct Object *drop; + UNUSED u8 filler[4]; + spawn_object(o, MODEL_WAVE_TRAIL, bhvObjectWaveTrail); + if (gMarioStates[0].forwardVel > 10.0f) { - drop = spawn_object_with_scale(o, MODEL_WHITE_PARTICLE_SMALL, bhvWaterDroplet, 1.5f); + struct Object *drop = spawn_object_with_scale(o, MODEL_WHITE_PARTICLE_SMALL, + bhvWaterDroplet, 1.5f); drop->oVelY = random_float() * 30.0f; obj_translate_xz_random(drop, 110.0f); } @@ -30,20 +32,25 @@ void bhv_koopa_shell_flame_loop(void) { o->oGravity = -4.0f; o->oAnimState = random_float() * 10.0f; obj_translate_xz_random(o, 110.0f); - o->oKoopaShellFlameUnkF8 = 4.0f; + o->oKoopaShellFlameScale = 4.0f; } + cur_obj_update_floor_height(); cur_obj_move_using_fvel_and_gravity(); - if (o->oFloorHeight > o->oPosY || o->oTimer > 10) + + if (o->oFloorHeight > o->oPosY || o->oTimer > 10) { obj_mark_for_deletion(o); - o->oKoopaShellFlameUnkF8 += -0.3; - cur_obj_scale(o->oKoopaShellFlameUnkF8); + } + + o->oKoopaShellFlameScale += -0.3; + cur_obj_scale(o->oKoopaShellFlameScale); } void bhv_koopa_shell_flame_spawn(void) { s32 i; - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { spawn_object(o, MODEL_RED_FLAME, bhvKoopaShellFlame); + } } void koopa_shell_spawn_sparkles(f32 a) { @@ -53,31 +60,42 @@ void koopa_shell_spawn_sparkles(f32 a) { void bhv_koopa_shell_loop(void) { struct Surface *sp34; + obj_set_hitbox(o, &sKoopaShellHitbox); cur_obj_scale(1.0f); + switch (o->oAction) { case 0: cur_obj_update_floor_and_walls(); cur_obj_if_hit_wall_bounce_away(); - if (o->oInteractStatus & INT_STATUS_INTERACTED) + + if (o->oInteractStatus & INT_STATUS_INTERACTED) { o->oAction++; + } + o->oFaceAngleYaw += 0x1000; cur_obj_move_standard(-20); koopa_shell_spawn_sparkles(10.0f); break; + case 1: obj_copy_pos(o, gMarioObject); sp34 = cur_obj_update_floor_height_and_get_floor(); - if (absf(find_water_level(o->oPosX, o->oPosZ) - o->oPosY) < 10.0f) + + if (absf(find_water_level(o->oPosX, o->oPosZ) - o->oPosY) < 10.0f) { koopa_shell_spawn_water_drop(); - else if (5.0f > absf(o->oPosY - o->oFloorHeight)) { - if (sp34 != NULL && sp34->type == 1) + } else if (absf(o->oPosY - o->oFloorHeight) < 5.0f) { + if (sp34 != NULL && sp34->type == 1) { bhv_koopa_shell_flame_spawn(); - else + } else { koopa_shell_spawn_sparkles(10.0f); - } else + } + } else { koopa_shell_spawn_sparkles(10.0f); + } + o->oFaceAngleYaw = gMarioObject->oMoveAngleYaw; + if (o->oInteractStatus & INT_STATUS_STOP_RIDING) { obj_mark_for_deletion(o); spawn_mist_particles(); @@ -85,5 +103,6 @@ void bhv_koopa_shell_loop(void) { } break; } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/koopa_shell_underwater.inc.c b/src/game/behaviors/koopa_shell_underwater.inc.c index 7d670ab5..9b06618a 100644 --- a/src/game/behaviors/koopa_shell_underwater.inc.c +++ b/src/game/behaviors/koopa_shell_underwater.inc.c @@ -1,15 +1,15 @@ -// koopa_shell_underwater.c.inc +// koopa_shell_underwater.inc.c struct ObjectHitbox sKoopaShellUnderwaterHitbox = { - /* interactType: */ INTERACT_GRABBABLE, - /* downOffset: */ 0, + /* interactType: */ INTERACT_GRABBABLE, + /* downOffset: */ 0, /* damageOrCoinValue: */ 0, - /* health: */ 1, - /* numLootCoins: */ 0, - /* radius: */ 80, - /* height: */ 50, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 1, + /* numLootCoins: */ 0, + /* radius: */ 80, + /* height: */ 50, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; void set_koopa_shell_underwater_hitbox(void) { @@ -30,9 +30,11 @@ void bhv_koopa_shell_underwater_loop(void) { spawn_mist_particles(); break; } + if (o->oInteractStatus & INT_STATUS_STOP_RIDING) { obj_mark_for_deletion(o); spawn_mist_particles(); } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/lll_floating_wood_piece.inc.c b/src/game/behaviors/lll_floating_wood_piece.inc.c index cb4dad48..6abb42a1 100644 --- a/src/game/behaviors/lll_floating_wood_piece.inc.c +++ b/src/game/behaviors/lll_floating_wood_piece.inc.c @@ -1,32 +1,40 @@ -// lll_floating_wood_piece.c.inc +// lll_floating_wood_piece.inc.c void bhv_lll_wood_piece_loop(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oPosY -= 100.0f; + } + o->oPosY += sins(o->oLllWoodPieceOscillationTimer) * 3.0f; o->oLllWoodPieceOscillationTimer += 0x400; - if (o->parentObj->oAction == 2) + + if (o->parentObj->oAction == 2) { obj_mark_for_deletion(o); + } } void bhv_lll_floating_wood_bridge_loop(void) { struct Object *sp3C; s32 i; + switch (o->oAction) { case 0: if (o->oDistanceToMario < 2500.0f) { for (i = 1; i < 4; i++) { - sp3C = spawn_object_relative(0, (i - 2) * 300, 0, 0, o, MODEL_LLL_WOOD_BRIDGE, - bhvLllWoodPiece); - sp3C->oLllWoodPieceOscillationTimer = i * 4096; + sp3C = spawn_object_relative(0, (i - 2) * 300, 0, 0, o, + MODEL_LLL_WOOD_BRIDGE, bhvLllWoodPiece); + sp3C->oLllWoodPieceOscillationTimer = i * 0x1000; } o->oAction = 1; } break; + case 1: - if (o->oDistanceToMario > 2600.0f) + if (o->oDistanceToMario > 2600.0f) { o->oAction = 2; + } break; + case 2: o->oAction = 0; break; diff --git a/src/game/behaviors/lll_hexagonal_ring.inc.c b/src/game/behaviors/lll_hexagonal_ring.inc.c index a0a4d6b7..28a34565 100644 --- a/src/game/behaviors/lll_hexagonal_ring.inc.c +++ b/src/game/behaviors/lll_hexagonal_ring.inc.c @@ -1,51 +1,72 @@ -// lll_hexagonal_ring.c.inc +// lll_hexagonal_ring.inc.c void hexagonal_ring_spawn_flames(void) { - struct Object *sp1C; + struct Object *sp1C = spawn_object(o, MODEL_RED_FLAME, bhvVolcanoFlames); f32 size; - sp1C = spawn_object(o, MODEL_RED_FLAME, bhvVolcanoFlames); + sp1C->oPosY += 550.0f; - sp1C->oMoveAngleYaw = random_u16() << 0x10 >> 0x10; + sp1C->oMoveAngleYaw = (s16) random_u16(); sp1C->oForwardVel = random_float() * 40.0f + 20.0f; sp1C->oVelY = random_float() * 50.0f + 10.0f; + size = random_float() * 6.0 + 3.0; + obj_scale_xyz(sp1C, size, size, size); - if (random_float() < 0.1) + + if (random_float() < 0.1) { cur_obj_play_sound_2(SOUND_GENERAL_VOLCANO_EXPLOSION); + } } void bhv_lll_rotating_hexagonal_ring_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; + o->oCollisionDistance = 4000.0f; o->oDrawingDistance = 8000.0f; + switch (o->oAction) { case 0: - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->oAction++; + } + o->oAngleVelYaw = 0x100; break; + case 1: - o->oAngleVelYaw = 256.0f - sins(o->oTimer << 7) * 256.0f; - if (o->oTimer > 128) + o->oAngleVelYaw = 256.0f - sins(o->oTimer * 128) * 256.0f; + + if (o->oTimer > 128) { o->oAction++; + } break; + case 2: - if (gMarioObject->platform != o) + if (gMarioObject->platform != o) { o->oAction++; - if (o->oTimer > 128) + } + + if (o->oTimer > 128) { o->oAction++; + } + o->oAngleVelYaw = 0; hexagonal_ring_spawn_flames(); break; + case 3: - o->oAngleVelYaw = sins(o->oTimer << 7) * 256.0f; - if (o->oTimer > 128) + o->oAngleVelYaw = sins(o->oTimer * 128) * 256.0f; + + if (o->oTimer > 128) { o->oAction = 0; + } break; + case 4: o->oAction = 0; break; } + o->oAngleVelYaw = -o->oAngleVelYaw; o->oMoveAngleYaw += o->oAngleVelYaw; } diff --git a/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c b/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c index 7fc4936f..054723fd 100644 --- a/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c +++ b/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c @@ -1,4 +1,4 @@ -// lll_octagonal_rotating_mesh.c.inc +// lll_octagonal_rotating_mesh.inc.c s16 D_8032F860[] = { 2, 30, 0x4000, 0, 1, 220, 900, 30, 1, 30, 0, -30, 2, 30, -0x4000, 0, 1, 220, 900, 30, 1, 30, 0, -30, 3, 0 }; @@ -6,7 +6,6 @@ s16 D_8032F894[] = { 4, 0, 0, 0, 1, 475, 900, 30, 1, 30, 0, -30, 2, 30, 0x8000, 0, 1, 475, 900, 30, 1, 30, 0, -30, 3, 0 }; s16 *D_8032F8C8[] = { D_8032F860, D_8032F894 }; - s32 lll_octagonal_mesh_move(s16 *a0, s32 a1) { switch (a0[a1]) { case 4: @@ -17,6 +16,7 @@ s32 lll_octagonal_mesh_move(s16 *a0, s32 a1) { o->oTimer = 0; } break; + case 2: o->oMoveAngleYaw = a0[a1 + 2]; o->oForwardVel = a0[a1 + 3] / 100.0f; @@ -25,6 +25,7 @@ s32 lll_octagonal_mesh_move(s16 *a0, s32 a1) { o->oTimer = 0; } break; + case 1: approach_f32_signed(&o->oForwardVel, a0[a1 + 2] / 100.0f, a0[a1 + 3] / 100.0f); if (o->oTimer > a0[a1 + 1]) { @@ -32,45 +33,57 @@ s32 lll_octagonal_mesh_move(s16 *a0, s32 a1) { o->oTimer = 0; } break; + case 3: o->oForwardVel = 0.0f; a1 = 0; break; } + return a1; } s32 lll_octagonal_mesh_find_y_offset(s32 *a0, f32 *a1, s32 a2, s32 a3) { if (cur_obj_is_mario_on_platform()) { - if (a0[0] < 0x4000) + if (a0[0] < 0x4000) { a0[0] += a2; - else + } else { a0[0] = 0x4000; + } } else { - if (a0[0] > 0) + if (a0[0] > 0) { a0[0] -= a2; - else + } else { a0[0] = 0; + } } + a1[0] = sins(a0[0]) * a3; - if (a0[0] == 0 || a0[0] == 0x4000) - return 1; - else - return 0; + + if (a0[0] == 0 || a0[0] == 0x4000) { + return TRUE; + } else { + return FALSE; + } } void bhv_lll_moving_octagonal_mesh_platform_loop(void) { if (o->oAction == 0) { o->oHorizontalMovementUnkF8 = 0; o->oAction++; - } else + } else { o->oHorizontalMovementUnkF8 = lll_octagonal_mesh_move(D_8032F8C8[o->oBehParams2ndByte], o->oHorizontalMovementUnkF8); + } + print_debug_top_down_objectinfo("number %d\n", o->oHorizontalMovementUnkF8); cur_obj_move_using_fvel_and_gravity(); - if (lll_octagonal_mesh_find_y_offset(&o->oHorizontalMovementUnk104, &o->oHorizontalMovementUnk108, 0x400, -80)) { + + if (lll_octagonal_mesh_find_y_offset(&o->oHorizontalMovementUnk104, + &o->oHorizontalMovementUnk108, 0x400, -80)) { o->oHorizontalMovementUnkF4 += 0x800; o->oHorizontalMovementUnk100 -= sins(o->oHorizontalMovementUnkF4) * 2; } + o->oPosY = o->oHorizontalMovementUnk100 + o->oHomeY + o->oHorizontalMovementUnk108; } diff --git a/src/game/behaviors/lll_rotating_hex_flame.inc.c b/src/game/behaviors/lll_rotating_hex_flame.inc.c index efabfca8..4637f317 100644 --- a/src/game/behaviors/lll_rotating_hex_flame.inc.c +++ b/src/game/behaviors/lll_rotating_hex_flame.inc.c @@ -1,23 +1,28 @@ -// lll_rotating_hex_flame.c.inc +// lll_rotating_hex_flame.inc.c void bhv_lll_rotating_hex_flame_loop(void) { f32 sp24 = o->oLllRotatingHexFlameUnkF4; f32 sp20 = o->oLllRotatingHexFlameUnkF8; f32 sp1C = o->oLllRotatingHexFlameUnkFC; + cur_obj_set_pos_relative(o->parentObj, sp24, sp20, sp1C); o->oPosY = o->parentObj->oPosY + 100.0f; - if (o->parentObj->oAction == 3) + + if (o->parentObj->oAction == 3) { obj_mark_for_deletion(o); + } } void fire_bar_spawn_flames(s16 a0) { struct Object *sp2C; - UNUSED s32 unused; + UNUSED u8 filler[4]; s32 i; s32 sp20; f32 sp1C = sins(a0) * 200.0f; f32 sp18 = coss(a0) * 200.0f; - sp20 = (o->oBehParams2ndByte == 0) ? 4 : 3; + + sp20 = o->oBehParams2ndByte == 0 ? 4 : 3; + for (i = 0; i < sp20; i++) { sp2C = spawn_object(o, MODEL_RED_FLAME, bhvLllRotatingHexFlame); sp2C->oLllRotatingHexFlameUnkF4 += sp1C; @@ -30,8 +35,9 @@ void fire_bar_spawn_flames(s16 a0) { } void fire_bar_act_0(void) { - if (o->oDistanceToMario < 3000.0f) + if (o->oDistanceToMario < 3000.0f) { o->oAction = 1; + } } void fire_bar_act_1(void) { @@ -45,19 +51,25 @@ void fire_bar_act_1(void) { void fire_bar_act_2(void) { o->oAngleVelYaw = -0x100; o->oMoveAngleYaw += o->oAngleVelYaw; - if (o->oDistanceToMario > 3200.0f) + if (o->oDistanceToMario > 3200.0f) { o->oAction = 3; + } } void fire_bar_act_3(void) { o->oAction = 0; } -void (*sRotatingCwFireBarsActions[])(void) = { fire_bar_act_0, fire_bar_act_1, - fire_bar_act_2, fire_bar_act_3 }; +void (*sRotatingCwFireBarsActions[])(void) = { + fire_bar_act_0, + fire_bar_act_1, + fire_bar_act_2, + fire_bar_act_3, +}; void bhv_lll_rotating_block_fire_bars_loop(void) { cur_obj_call_action_function(sRotatingCwFireBarsActions); - if (o->oBehParams2ndByte == 0) + if (o->oBehParams2ndByte == 0) { load_object_collision_model(); + } } diff --git a/src/game/behaviors/lll_sinking_rectangle.inc.c b/src/game/behaviors/lll_sinking_rectangle.inc.c index bda4a844..22d8fd8a 100644 --- a/src/game/behaviors/lll_sinking_rectangle.inc.c +++ b/src/game/behaviors/lll_sinking_rectangle.inc.c @@ -1,14 +1,16 @@ -// lll_sinking_rectangle.c.inc +// lll_sinking_rectangle.inc.c void sinking_rectangular_plat_actions(f32 a0, s32 a1) { switch (o->oAction) { case 0: o->oAction++; break; + case 1: o->oPosY -= sins(o->oLllWoodPieceOscillationTimer) * a0; o->oLllWoodPieceOscillationTimer += a1; break; + case 2: break; break; // Two breaks needed? @@ -18,10 +20,11 @@ void sinking_rectangular_plat_actions(f32 a0, s32 a1) { void bhv_lll_sinking_rectangular_platform_loop(void) { f32 sp1C = 0.4f; s32 sp18 = 0x100; - if (o->oMoveAngleYaw != 0) + + if (o->oMoveAngleYaw != 0) { sinking_rectangular_plat_actions(sp1C, sp18); - else { - o->oFaceAnglePitch = sins(o->oLllWoodPieceOscillationTimer) * 512.0f; + } else { + o->oFaceAnglePitch = sins(o->oLllWoodPieceOscillationTimer) * 0x200; o->oLllWoodPieceOscillationTimer += 0x100; } } @@ -29,5 +32,6 @@ void bhv_lll_sinking_rectangular_platform_loop(void) { void bhv_lll_sinking_square_platforms_loop(void) { f32 sp1C = 0.5f; s32 sp18 = 0x100; + sinking_rectangular_plat_actions(sp1C, sp18); } diff --git a/src/game/behaviors/lll_sinking_rock_block.inc.c b/src/game/behaviors/lll_sinking_rock_block.inc.c index 056d0aaa..d057abe2 100644 --- a/src/game/behaviors/lll_sinking_rock_block.inc.c +++ b/src/game/behaviors/lll_sinking_rock_block.inc.c @@ -1,7 +1,8 @@ -// lll_sinking_rock_block.c.inc +// lll_sinking_rock_block.inc.c void bhv_lll_sinking_rock_block_loop(void) { - lll_octagonal_mesh_find_y_offset(&o->oSinkWhenSteppedOnUnk104, &o->oSinkWhenSteppedOnUnk108, 124, -110); + lll_octagonal_mesh_find_y_offset(&o->oSinkWhenSteppedOnUnk104, + &o->oSinkWhenSteppedOnUnk108, 124, -110); o->oGraphYOffset = 0.0f; o->oPosY = o->oHomeY + o->oSinkWhenSteppedOnUnk108; } diff --git a/src/game/behaviors/lll_volcano_flames.inc.c b/src/game/behaviors/lll_volcano_flames.inc.c index aa2fbc6f..204521b3 100644 --- a/src/game/behaviors/lll_volcano_flames.inc.c +++ b/src/game/behaviors/lll_volcano_flames.inc.c @@ -1,13 +1,16 @@ -// lll_volcano_flames.c.inc +// lll_volcano_flames.inc.c void bhv_volcano_flames_loop(void) { cur_obj_update_floor_height(); cur_obj_compute_vel_xz(); + o->oPosX += o->oVelX; o->oPosZ += o->oVelZ; + cur_obj_move_y(-4.0f, -0.7f, 2.0f); - if (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_AT_WATER_SURFACE - | OBJ_MOVE_UNDERWATER_OFF_GROUND)) + if (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_AT_WATER_SURFACE + | OBJ_MOVE_UNDERWATER_OFF_GROUND)) { obj_mark_for_deletion(o); + } } diff --git a/src/game/behaviors/mad_piano.inc.c b/src/game/behaviors/mad_piano.inc.c index efefaba4..70d816d1 100644 --- a/src/game/behaviors/mad_piano.inc.c +++ b/src/game/behaviors/mad_piano.inc.c @@ -1,3 +1,4 @@ +// mad_piano.inc.c static struct ObjectHitbox sMadPianoHitbox = { /* interactType: */ INTERACT_MR_BLIZZARD, @@ -15,11 +16,9 @@ static void mad_piano_act_wait(void) { cur_obj_init_animation_with_sound(0); if (o->oDistanceToMario < 500.0f) { - if (o->oTimer > 20) { - if (gMarioStates[0].forwardVel > 10.0f) { - o->oAction = MAD_PIANO_ACT_ATTACK; - cur_obj_become_tangible(); - } + if (o->oTimer > 20 && gMarioStates[0].forwardVel > 10.0f) { + o->oAction = MAD_PIANO_ACT_ATTACK; + cur_obj_become_tangible(); } } else { o->oTimer = 0; diff --git a/src/game/behaviors/manta_ray.inc.c b/src/game/behaviors/manta_ray.inc.c index 5e1c27ff..62224840 100644 --- a/src/game/behaviors/manta_ray.inc.c +++ b/src/game/behaviors/manta_ray.inc.c @@ -1,3 +1,4 @@ + /** * @file Behavior file for the manta ray in DDD. * @@ -33,28 +34,27 @@ static struct ObjectHitbox sMantaRayHitbox = { * Initializes the manta ray when spawned. */ void bhv_manta_ray_init(void) { - struct Object *ringManager; - ringManager = spawn_object(o, MODEL_NONE, bhvMantaRayRingManager); + struct Object *ringManager = spawn_object(o, MODEL_NONE, bhvMantaRayRingManager); o->parentObj = ringManager; obj_set_hitbox(o, &sMantaRayHitbox); cur_obj_scale(2.5f); } static void manta_ray_move(void) { - s16 animFrame; + s16 animFrame = o->header.gfx.animInfo.animFrame; s32 pathStatus; #ifdef AVOID_UB pathStatus = 0; #endif - animFrame = o->header.gfx.animInfo.animFrame; - gCurrentObject->oPathedStartWaypoint = (struct Waypoint *) sMantaRayTraj; + o->oPathedStartWaypoint = (struct Waypoint *) sMantaRayTraj; pathStatus = cur_obj_follow_path(pathStatus); + o->oMantaTargetYaw = o->oPathedTargetYaw; o->oMantaTargetPitch = o->oPathedTargetPitch; o->oForwardVel = 10.0f; - o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oMantaTargetYaw, 0x80); + o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oMantaTargetYaw, 0x80); o->oMoveAnglePitch = approach_s16_symmetric(o->oMoveAnglePitch, o->oMantaTargetPitch, 0x80); // This causes the ray to tilt as it turns. @@ -78,14 +78,13 @@ static void manta_ray_move(void) { static void manta_ray_act_spawn_ring(void) { struct Object *ringManager = o->parentObj; - struct Object *ring; if (o->oTimer == 300) { o->oTimer = 0; } if (o->oTimer == 0 || o->oTimer == 50 || o->oTimer == 150 || o->oTimer == 200 || o->oTimer == 250) { - ring = spawn_object(o, MODEL_WATER_RING, bhvMantaRayWaterRing); + struct Object *ring = spawn_object(o, MODEL_WATER_RING, bhvMantaRayWaterRing); ring->oFaceAngleYaw = o->oMoveAngleYaw; ring->oFaceAnglePitch = o->oMoveAnglePitch + 0x4000; diff --git a/src/game/behaviors/metal_box.inc.c b/src/game/behaviors/metal_box.inc.c index ce3957bf..c0dddc60 100644 --- a/src/game/behaviors/metal_box.inc.c +++ b/src/game/behaviors/metal_box.inc.c @@ -1,15 +1,15 @@ -// metal_box.c.inc +// metal_box.inc.c struct ObjectHitbox sMetalBoxHitbox = { - /* interactType: */ 0, - /* downOffset: */ 0, + /* interactType: */ 0, + /* downOffset: */ 0, /* damageOrCoinValue: */ 0, - /* health: */ 1, - /* numLootCoins: */ 0, - /* radius: */ 220, - /* height: */ 300, - /* hurtboxRadius: */ 220, - /* hurtboxHeight: */ 300, + /* health: */ 1, + /* numLootCoins: */ 0, + /* radius: */ 220, + /* height: */ 300, + /* hurtboxRadius: */ 220, + /* hurtboxHeight: */ 300, }; s32 check_if_moving_over_floor(f32 a0, f32 a1) { @@ -17,27 +17,33 @@ s32 check_if_moving_over_floor(f32 a0, f32 a1) { f32 sp20 = o->oPosX + sins(o->oMoveAngleYaw) * a1; f32 floorHeight; f32 sp18 = o->oPosZ + coss(o->oMoveAngleYaw) * a1; + floorHeight = find_floor(sp20, o->oPosY, sp18, &sp24); - if (absf(floorHeight - o->oPosY) < a0) // abs - return 1; - else - return 0; + + if (absf(floorHeight - o->oPosY) < a0) { + return TRUE; + } else { + return FALSE; + } } void bhv_pushable_loop(void) { UNUSED s16 unused; - s16 sp1C; + obj_set_hitbox(o, &sMetalBoxHitbox); o->oForwardVel = 0.0f; - if (obj_check_if_collided_with_object(o, gMarioObject) && gMarioStates[0].flags & MARIO_UNKNOWN_31) { - sp1C = obj_angle_to_object(o, gMarioObject); + + if (obj_check_if_collided_with_object(o, gMarioObject) + && (gMarioStates[0].flags & MARIO_UNKNOWN_31)) { + s16 sp1C = obj_angle_to_object(o, gMarioObject); if (abs_angle_diff(sp1C, gMarioObject->oMoveAngleYaw) > 0x4000) { - o->oMoveAngleYaw = (s16)((gMarioObject->oMoveAngleYaw + 0x2000) & 0xc000); + o->oMoveAngleYaw = (s16)((gMarioObject->oMoveAngleYaw + 0x2000) & 0xC000); if (check_if_moving_over_floor(8.0f, 150.0f)) { o->oForwardVel = 4.0f; cur_obj_play_sound_1(SOUND_ENV_METAL_BOX_PUSH); } } } + cur_obj_move_using_fvel_and_gravity(); } diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c index 461e9f2a..0aed1ec9 100644 --- a/src/game/behaviors/mips.inc.c +++ b/src/game/behaviors/mips.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for MIPS (everyone's favorite yellow rabbit). */ @@ -8,7 +9,7 @@ */ void bhv_mips_init(void) { // Retrieve star flags for Castle Secret Stars on current save file. - u8 starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, -1); + u8 starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_NONE)); // If the player has >= 15 stars and hasn't collected first MIPS star... if (save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 15 @@ -53,14 +54,11 @@ s16 bhv_mips_find_furthest_waypoint_to_mario(void) { s16 furthestWaypointIndex = -1; f32 furthestWaypointDistance = -10000.0f; f32 distanceToMario; - struct Waypoint **pathBase; - struct Waypoint *waypoint; - - pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips); + struct Waypoint **pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips); // For each waypoint in MIPS path... for (i = 0; i < 10; i++) { - waypoint = segmented_to_virtual(pathBase[i]); + struct Waypoint *waypoint = segmented_to_virtual(pathBase[i]); x = waypoint->pos[0]; y = waypoint->pos[1]; z = waypoint->pos[2]; @@ -111,15 +109,13 @@ void bhv_mips_act_wait_for_nearby_mario(void) { void bhv_mips_act_follow_path(void) { s16 collisionFlags = 0; s32 followStatus; - struct Waypoint **pathBase; - struct Waypoint *waypoint; #ifdef AVOID_UB followStatus = 0; #endif // Retrieve current waypoint. - pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips); - waypoint = segmented_to_virtual(*(pathBase + o->oMipsStartWaypointIndex)); + struct Waypoint **pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips); + struct Waypoint *waypoint = segmented_to_virtual(*(pathBase + o->oMipsStartWaypointIndex)); // Set start waypoint and follow the path from there. o->oPathedStartWaypoint = waypoint; @@ -141,10 +137,10 @@ void bhv_mips_act_follow_path(void) { } // Play sounds during walk animation. - if (cur_obj_check_if_near_animation_end() == 1 && (collisionFlags & OBJ_COL_FLAG_UNDERWATER)) { + if (cur_obj_check_if_near_animation_end() == TRUE && (collisionFlags & OBJ_COL_FLAG_UNDERWATER)) { cur_obj_play_sound_2(SOUND_OBJ_MIPS_RABBIT_WATER); spawn_object(o, MODEL_NONE, bhvShallowWaterSplash); - } else if (cur_obj_check_if_near_animation_end() == 1) { + } else if (cur_obj_check_if_near_animation_end() == TRUE) { cur_obj_play_sound_2(SOUND_OBJ_MIPS_RABBIT); } } @@ -153,7 +149,7 @@ void bhv_mips_act_follow_path(void) { * Seems to wait until the current animation is done, then go idle. */ void bhv_mips_act_wait_for_animation_done(void) { - if (cur_obj_check_if_near_animation_end() == 1) { + if (cur_obj_check_if_near_animation_end() == TRUE) { cur_obj_init_animation(0); o->oAction = MIPS_ACT_IDLE; } @@ -163,20 +159,20 @@ void bhv_mips_act_wait_for_animation_done(void) { * Handles MIPS falling down after being thrown. */ void bhv_mips_act_fall_down(void) { - s16 collisionFlags = 0; collisionFlags = object_step(); o->header.gfx.animInfo.animFrame = 0; - if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) == 1) { + if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) == OBJ_COL_FLAG_GROUNDED) { o->oAction = MIPS_ACT_WAIT_FOR_ANIMATION_DONE; o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oMoveAngleYaw = o->oFaceAngleYaw; - if (collisionFlags & OBJ_COL_FLAG_UNDERWATER) + if (collisionFlags & OBJ_COL_FLAG_UNDERWATER) { spawn_object(o, MODEL_NONE, bhvShallowWaterSplash); + } } } @@ -186,7 +182,7 @@ void bhv_mips_act_fall_down(void) { void bhv_mips_act_idle(void) { UNUSED s16 collisionFlags = 0; - o->oForwardVel = 0; + o->oForwardVel = 0.0f; collisionFlags = object_step(); // Spawn a star if he was just picked up for the first time. @@ -237,14 +233,15 @@ void bhv_mips_held(void) { // If MIPS hasn't spawned his star yet... if (o->oMipsStarStatus == MIPS_STAR_STATUS_HAVENT_SPAWNED_STAR) { // Choose dialog based on which MIPS encounter this is. - if (o->oBehParams2ndByte == 0) + if (o->oBehParams2ndByte == 0) { dialogID = DIALOG_084; - else + } else { dialogID = DIALOG_162; + } if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) { o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; - if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogID)) { + if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogID) != 0) { o->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY; o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oMipsStarStatus = MIPS_STAR_STATUS_SHOULD_SPAWN_STAR; diff --git a/src/game/behaviors/moat_drainer.inc.c b/src/game/behaviors/moat_drainer.inc.c index 0c719c83..68db956a 100644 --- a/src/game/behaviors/moat_drainer.inc.c +++ b/src/game/behaviors/moat_drainer.inc.c @@ -1,4 +1,4 @@ -// moat_drainer.c.inc +// moat_drainer.inc.c void bhv_invisible_objects_under_bridge_init(void) { if (save_file_get_flags() & SAVE_FLAG_MOAT_DRAINED) { diff --git a/src/game/behaviors/moat_grill.inc.c b/src/game/behaviors/moat_grill.inc.c index e2b4da82..7ccfa966 100644 --- a/src/game/behaviors/moat_grill.inc.c +++ b/src/game/behaviors/moat_grill.inc.c @@ -1,8 +1,9 @@ -// moat_grill.c.inc +// moat_grill.inc.c void bhv_moat_grills_loop(void) { - if (save_file_get_flags() & SAVE_FLAG_MOAT_DRAINED) + if (save_file_get_flags() & SAVE_FLAG_MOAT_DRAINED) { cur_obj_set_model(MODEL_NONE); - else + } else { load_object_collision_model(); + } } diff --git a/src/game/behaviors/moneybag.inc.c b/src/game/behaviors/moneybag.inc.c index 7c366632..9f819208 100644 --- a/src/game/behaviors/moneybag.inc.c +++ b/src/game/behaviors/moneybag.inc.c @@ -1,4 +1,4 @@ -// moneybag.c.inc +// moneybag.inc.c static struct ObjectHitbox sMoneybagHitbox = { /* interactType: */ INTERACT_BOUNCE_TOP, @@ -35,16 +35,13 @@ void bhv_moneybag_init(void) { void moneybag_check_mario_collision(void) { obj_set_hitbox(o, &sMoneybagHitbox); - if (o->oInteractStatus & INT_STATUS_INTERACTED) /* bit 15 */ - { - if (o->oInteractStatus & INT_STATUS_ATTACKED_MARIO) /* bit 13 */ - { + if (o->oInteractStatus & INT_STATUS_INTERACTED) { + if (o->oInteractStatus & INT_STATUS_ATTACKED_MARIO) { o->oMoveAngleYaw = o->oAngleToMario + 0x8000; o->oVelY = 30.0f; } - if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) /* bit 14 */ - { + if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) { o->oAction = MONEYBAG_ACT_DEATH; } @@ -52,8 +49,6 @@ void moneybag_check_mario_collision(void) { } } -// sp20 = collisionFlags - void moneybag_jump(s8 collisionFlags) { s16 animFrame = o->header.gfx.animInfo.animFrame; @@ -65,7 +60,7 @@ void moneybag_jump(s8 collisionFlags) { o->oVelY = 40.0f; } - if (cur_obj_check_if_near_animation_end() == 1) { + if (cur_obj_check_if_near_animation_end() == TRUE) { o->oMoneybagJumpState = MONEYBAG_JUMP_JUMP; cur_obj_play_sound_2(SOUND_GENERAL_BOING2_LOWPRIO); } @@ -74,8 +69,7 @@ void moneybag_jump(s8 collisionFlags) { case MONEYBAG_JUMP_JUMP: cur_obj_init_animation(2); - if ((collisionFlags & 1) == 1) /* bit 0 */ - { + if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) == OBJ_COL_FLAG_GROUNDED) { o->oForwardVel = 0; o->oVelY = 0; o->oMoneybagJumpState = MONEYBAG_JUMP_LANDING; @@ -85,15 +79,16 @@ void moneybag_jump(s8 collisionFlags) { case MONEYBAG_JUMP_JUMP_AND_BOUNCE: cur_obj_init_animation(3); - if (cur_obj_check_if_near_animation_end() == 1) + if (cur_obj_check_if_near_animation_end() == TRUE) { o->oMoneybagJumpState = MONEYBAG_JUMP_LANDING; + } break; case MONEYBAG_JUMP_WALK_AROUND: cur_obj_init_animation(4); o->oForwardVel = 10.0f; - if (o->oTimer >= 61) { + if (o->oTimer > 60) { o->oMoneybagJumpState = MONEYBAG_JUMP_LANDING; o->oForwardVel = 0; o->header.gfx.animInfo.animFrame = 0; @@ -119,16 +114,18 @@ void moneybag_act_move_around(void) { if ((s32)(random_float() * 6.0f) == 1) { o->oMoneybagJumpState = MONEYBAG_JUMP_WALK_AROUND; o->oTimer = 0; - } else + } else { o->oMoneybagJumpState = MONEYBAG_JUMP_PREPARE; + } } moneybag_jump(collisionFlags); moneybag_check_mario_collision(); if (!is_point_within_radius_of_mario(o->oHomeX, o->oHomeY, o->oHomeZ, 800) - && ((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAGS_LANDED)) + && ((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAGS_LANDED)) { o->oAction = MONEYBAG_ACT_RETURN_HOME; + } } void moneybag_act_return_home(void) { @@ -136,12 +133,14 @@ void moneybag_act_return_home(void) { f32 sp28 = o->oHomeX - o->oPosX; f32 sp24 = o->oHomeZ - o->oPosZ; s16 sp22 = atan2s(sp24, sp28); - o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, sp22, 0x800); + o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, sp22, 0x800); collisionFlags = object_step(); + if (((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAGS_LANDED) - && (o->oMoneybagJumpState == MONEYBAG_JUMP_LANDING)) + && (o->oMoneybagJumpState == MONEYBAG_JUMP_LANDING)) { o->oMoneybagJumpState = MONEYBAG_JUMP_WALK_HOME; + } moneybag_jump(collisionFlags); moneybag_check_mario_collision(); @@ -156,7 +155,7 @@ void moneybag_act_return_home(void) { o->oMoneybagJumpState = MONEYBAG_JUMP_LANDING; } - if (is_point_within_radius_of_mario(o->oHomeX, o->oHomeY, o->oHomeZ, 800) == 1) { + if (is_point_within_radius_of_mario(o->oHomeX, o->oHomeY, o->oHomeZ, 800) == TRUE) { o->oAction = MONEYBAG_ACT_MOVE_AROUND; o->oMoneybagJumpState = MONEYBAG_JUMP_LANDING; } @@ -184,7 +183,7 @@ void bhv_moneybag_loop(void) { case MONEYBAG_ACT_APPEAR: case MONEYBAG_ACT_UNUSED_APPEAR: o->oOpacity += 12; - if (o->oOpacity >= 256) { + if (o->oOpacity > 255) { o->oOpacity = 255; o->parentObj->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oAction = MONEYBAG_ACT_MOVE_AROUND; @@ -193,8 +192,9 @@ void bhv_moneybag_loop(void) { case MONEYBAG_ACT_MOVE_AROUND: moneybag_act_move_around(); - if (o->oTimer >= 31) + if (o->oTimer > 30) { cur_obj_become_tangible(); + } break; case MONEYBAG_ACT_RETURN_HOME: diff --git a/src/game/behaviors/monty_mole.inc.c b/src/game/behaviors/monty_mole.inc.c index 685f5aae..884774ad 100644 --- a/src/game/behaviors/monty_mole.inc.c +++ b/src/game/behaviors/monty_mole.inc.c @@ -30,15 +30,10 @@ f32 sMontyMoleLastKilledPosZ; * start of this list. */ static struct Object *link_objects_with_behavior(const BehaviorScript *behavior) { - const BehaviorScript *behaviorAddr; + const BehaviorScript *behaviorAddr = segmented_to_virtual(behavior); struct Object *obj; - struct Object *lastObject; - struct ObjectNode *listHead; - - behaviorAddr = segmented_to_virtual(behavior); - lastObject = NULL; - - listHead = &gObjectLists[get_object_list_from_behavior(behaviorAddr)]; + struct Object *lastObject = NULL; + struct ObjectNode *listHead = &gObjectLists[get_object_list_from_behavior(behaviorAddr)]; obj = (struct Object *) listHead->next; while (obj != (struct Object *) listHead) { @@ -104,7 +99,7 @@ void bhv_monty_mole_hole_update(void) { sMontyMoleHoleList = link_objects_with_behavior(bhvMontyMoleHole); sMontyMoleKillStreak = 0; } else if (o->oMontyMoleHoleCooldown > 0) { - o->oMontyMoleHoleCooldown -= 1; + o->oMontyMoleHoleCooldown--; } } @@ -112,7 +107,7 @@ void bhv_monty_mole_hole_update(void) { * Spawn dirt particles when rising out of the ground. */ void monty_mole_spawn_dirt_particles(s8 offsetY, s8 velYBase) { - static struct SpawnParticlesInfo sMontyMoleRiseFromGroundParticles = { + static struct SpawnParticlesInfo montyMoleRiseFromGroundParticles = { /* behParam: */ 0, /* count: */ 3, /* model: */ MODEL_SAND_DUST, @@ -127,9 +122,10 @@ void monty_mole_spawn_dirt_particles(s8 offsetY, s8 velYBase) { /* sizeRange: */ 7.0f, }; - sMontyMoleRiseFromGroundParticles.offsetY = offsetY; - sMontyMoleRiseFromGroundParticles.velYBase = velYBase; - cur_obj_spawn_particles(&sMontyMoleRiseFromGroundParticles); + montyMoleRiseFromGroundParticles.offsetY = offsetY; + montyMoleRiseFromGroundParticles.velYBase = velYBase; + + cur_obj_spawn_particles(&montyMoleRiseFromGroundParticles); } /** @@ -366,7 +362,7 @@ void bhv_monty_mole_update(void) { } // Spawn a 1-up if you kill 8 monty moles - if (obj_check_attacks(&sMontyMoleHitbox, o->oAction)) { + if (obj_check_attacks(&sMontyMoleHitbox, o->oAction) != 0) { if (sMontyMoleKillStreak != 0) { f32 dx = o->oPosX - sMontyMoleLastKilledPosX; f32 dy = o->oPosY - sMontyMoleLastKilledPosY; @@ -388,7 +384,7 @@ void bhv_monty_mole_update(void) { } //! No overflow check - sMontyMoleKillStreak += 1; + sMontyMoleKillStreak++; sMontyMoleLastKilledPosX = o->oPosX; sMontyMoleLastKilledPosY = o->oPosY; @@ -421,7 +417,7 @@ static void monty_mole_rock_act_held(void) { o->oAction = MONTY_MOLE_ROCK_ACT_MOVE; // The angle is adjusted to compensate for the start position offset - o->oMoveAngleYaw = (s32)(o->parentObj->oMoveAngleYaw + 0x1F4 - distToMario * 0.1f); + o->oMoveAngleYaw = (s32)(o->parentObj->oMoveAngleYaw + 500 - distToMario * 0.1f); o->oForwardVel = 40.0f; o->oVelY = distToMario * 0.08f + 8.0f; diff --git a/src/game/behaviors/moving_coin.inc.c b/src/game/behaviors/moving_coin.inc.c index d992b13e..63fea18d 100644 --- a/src/game/behaviors/moving_coin.inc.c +++ b/src/game/behaviors/moving_coin.inc.c @@ -1,6 +1,4 @@ -// coin.c.inc - -// sp18 = collisionFlagsPtr +// moving_coin.inc.c static struct ObjectHitbox sMovingYellowCoinHitbox = { /* interactType: */ INTERACT_COIN, @@ -31,13 +29,13 @@ s32 coin_step(s16 *collisionFlagsPtr) { obj_check_floor_death(*collisionFlagsPtr, sObjFloor); - if ((*collisionFlagsPtr & 0x1) != 0 && (*collisionFlagsPtr & 0x8) == 0) /* bit 0, bit 3 */ - { + if ((*collisionFlagsPtr & OBJ_COL_FLAG_GROUNDED) + && !(*collisionFlagsPtr & OBJ_COL_FLAG_NO_Y_VEL)) { cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); - return 1; + return TRUE; } - return 0; + return FALSE; } void moving_coin_flicker(void) { @@ -62,17 +60,20 @@ void bhv_moving_yellow_coin_init(void) { void bhv_moving_yellow_coin_loop(void) { s16 collisionFlags; + switch (o->oAction) { case MOV_YCOIN_ACT_IDLE: coin_step(&collisionFlags); - if (o->oTimer < 10) + if (o->oTimer < 10) { cur_obj_become_intangible(); - else + } else { cur_obj_become_tangible(); + } - if (o->oTimer >= 301) - o->oAction = 1; + if (o->oTimer > 300) { + o->oAction = MOV_YCOIN_ACT_BLINKING; + } break; case MOV_YCOIN_ACT_BLINKING: @@ -88,8 +89,7 @@ void bhv_moving_yellow_coin_loop(void) { break; } - if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */ - { + if (o->oInteractStatus & INT_STATUS_INTERACTED) { coin_collected(); o->oInteractStatus = 0; } @@ -108,29 +108,32 @@ void bhv_moving_blue_coin_loop(void) { switch (o->oAction) { case MOV_BCOIN_ACT_STILL: - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1500)) - o->oAction = 1; + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1500)) { + o->oAction = MOV_BCOIN_ACT_MOVING; + } break; case MOV_BCOIN_ACT_MOVING: collisionFlags = object_step(); - if ((collisionFlags & OBJ_COL_FLAG_GROUNDED)) /* bit 0 */ - { - o->oForwardVel += 25.0f; - if (!(collisionFlags & OBJ_COL_FLAG_NO_Y_VEL)) - cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); /* bit 3 */ - } else - o->oForwardVel *= 0.98; - if (o->oForwardVel > 75.0) + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { + o->oForwardVel += 25.0f; + if (!(collisionFlags & OBJ_COL_FLAG_NO_Y_VEL)) { + cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); + } + } else { + o->oForwardVel *= 0.98; + } + + if (o->oForwardVel > 75.0) { o->oForwardVel = 75.0f; + } obj_flicker_and_disappear(o, 600); break; } - if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */ - { + if (o->oInteractStatus & INT_STATUS_INTERACTED) { coin_collected(); o->oInteractStatus = 0; } @@ -150,13 +153,17 @@ void blue_coin_sliding_away_from_mario(void) { o->oForwardVel = 15.0; o->oMoveAngleYaw = o->oAngleToMario + 0x8000; - if (coin_step(&collisionFlags) != 0) + if (coin_step(&collisionFlags)) { o->oVelY += 18.0f; - if ((collisionFlags & 0x2) != 0) - o->oAction = 3; /* bit 1 */ + } - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000) == 0) + if (collisionFlags & OBJ_COL_FLAG_HIT_WALL) { + o->oAction = 3; + } + + if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000)) { o->oAction = 2; + } } void blue_coin_sliding_slow_down(void) { @@ -164,11 +171,13 @@ void blue_coin_sliding_slow_down(void) { coin_step(&collisionFlags); - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500) == 1) + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500) == TRUE) { o->oAction = 1; + } - if (o->oTimer >= 151) + if (o->oTimer > 150) { o->oAction = 3; + } } void bhv_blue_coin_sliding_loop(void) { @@ -176,8 +185,9 @@ void bhv_blue_coin_sliding_loop(void) { switch (o->oAction) { case 0: - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500) == 1) + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500) == TRUE) { o->oAction = 1; + } set_object_visibility(o, 3000); break; @@ -193,8 +203,9 @@ void bhv_blue_coin_sliding_loop(void) { case 3: coin_step(&collisionFlags); - if (o->oTimer >= 61) + if (o->oTimer > 60) { o->oAction = 4; + } break; case 4: @@ -210,8 +221,7 @@ void bhv_blue_coin_sliding_loop(void) { break; } - if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */ - { + if (o->oInteractStatus & INT_STATUS_INTERACTED) { coin_collected(); o->oInteractStatus = 0; } @@ -246,8 +256,9 @@ void bhv_blue_coin_jumping_loop(void) { case 3: coin_step(&collisionFlags); - if (o->oTimer >= 61) + if (o->oTimer > 60) { o->oAction = 4; + } break; case 4: @@ -255,8 +266,7 @@ void bhv_blue_coin_jumping_loop(void) { break; } - if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */ - { + if (o->oInteractStatus & INT_STATUS_INTERACTED) { coin_collected(); o->oInteractStatus = 0; } diff --git a/src/game/behaviors/mr_blizzard.inc.c b/src/game/behaviors/mr_blizzard.inc.c index c8630a69..019f85e3 100644 --- a/src/game/behaviors/mr_blizzard.inc.c +++ b/src/game/behaviors/mr_blizzard.inc.c @@ -1,3 +1,5 @@ +// mr_blizzard.inc.c + // Mr. Blizzard hitbox struct ObjectHitbox sMrBlizzardHitbox = { /* interactType: */ INTERACT_MR_BLIZZARD, @@ -34,13 +36,13 @@ void mr_blizzard_spawn_white_particles(s8 count, s8 offsetY, s8 forwardVelBase, D_80331A00.forwardVelBase = forwardVelBase; D_80331A00.velYBase = velYBase; D_80331A00.sizeBase = sizeBase; + cur_obj_spawn_particles(&D_80331A00); } /** * Mr. Blizzard initialization function. */ - void bhv_mr_blizzard_init(void) { if (o->oBehParams2ndByte == MR_BLIZZARD_STYPE_JUMPING) { // Jumping Mr. Blizzard. @@ -48,11 +50,10 @@ void bhv_mr_blizzard_init(void) { o->oMrBlizzardGraphYOffset = 24.0f; o->oMrBlizzardTargetMoveYaw = o->oMoveAngleYaw; } else { - if (o->oBehParams2ndByte != MR_BLIZZARD_STYPE_NO_CAP) { - // Cap wearing Mr. Blizzard from SL. - if (save_file_get_flags() & SAVE_FLAG_CAP_ON_MR_BLIZZARD) { - o->oAnimState = 1; - } + // Cap wearing Mr. Blizzard from SL. + if ((o->oBehParams2ndByte != MR_BLIZZARD_STYPE_NO_CAP) + && (save_file_get_flags() & SAVE_FLAG_CAP_ON_MR_BLIZZARD)) { + o->oAnimState = 1; } // Mr. Blizzard starts under the floor holding nothing. @@ -64,9 +65,7 @@ void bhv_mr_blizzard_init(void) { /** * Handler for spawning Mr. Blizzard's snowball. */ - static void mr_blizzard_act_spawn_snowball(void) { - // If Mr. Blizzard is not holding a snowball, and the animation reaches 5 frames // spawn the Mr. Blizzard snowball. if (o->oMrBlizzardHeldObj == NULL && cur_obj_init_anim_check_frame(0, 5)) { @@ -89,9 +88,7 @@ static void mr_blizzard_act_spawn_snowball(void) { /** * Handler for Mario entering or exiting Mr. Blizzard's range. */ - static void mr_blizzard_act_hide_unhide(void) { - if (o->oDistanceToMario < 1000.0f) { // If Mario is in range, move to rising action, make Mr. Blizzard visible, // make Mr. Blizzard tangible, and initialize GraphYVel. @@ -112,12 +109,10 @@ static void mr_blizzard_act_hide_unhide(void) { /** * Handler for Mr. Blizzard popping up out of the ground. */ - static void mr_blizzard_act_rise_from_ground(void) { - // If the timer is not 0, decrement by 1 until it reaches 0. if (o->oMrBlizzardTimer != 0) { - o->oMrBlizzardTimer -= 1; + o->oMrBlizzardTimer--; } else if ((o->oMrBlizzardGraphYOffset += o->oMrBlizzardGraphYVel) > 24.0f) { // Increments GraphYOffset by GraphYVel until it is greater than 24, // moving Mr. Blizzard's graphical position upward each frame. @@ -142,14 +137,11 @@ static void mr_blizzard_act_rise_from_ground(void) { /** * Handler for Mr. Blizzard's rotation. */ - static void mr_blizzard_act_rotate(void) { - - s16 angleDiff; - f32 prevDizziness; // While Mr. Blizzard is on the ground, rotate toward Mario at // 8.4375 degrees/frame. if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { + s16 angleDiff; cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x600); // Modify the ChangeInDizziness based on Mario's angle to Mr. Blizzard. @@ -164,7 +156,7 @@ static void mr_blizzard_act_rotate(void) { // Incremement Dizziness by value of ChangeInDizziness o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness; } else if (o->oMrBlizzardDizziness != 0.0f) { - prevDizziness = o->oMrBlizzardDizziness; + f32 prevDizziness = o->oMrBlizzardDizziness; // Slowly move Dizziness back to 0 by making ChangeInDizziness positive if Dizziness // is negative, and making ChangeInDizziness negative if Dizziness is positive. if (o->oMrBlizzardDizziness < 0.0f) { @@ -188,13 +180,15 @@ static void mr_blizzard_act_rotate(void) { o->prevObj = o->oMrBlizzardHeldObj = NULL; cur_obj_become_intangible(); } - // If Mario gets too far away, move to burrow action and delete the snowball. - } else if (o->oDistanceToMario > 1500.0f) { + } + // If Mario gets too far away, move to burrow action and delete the snowball. + else if (o->oDistanceToMario > 1500.0f) { o->oAction = MR_BLIZZARD_ACT_BURROW; o->oMrBlizzardChangeInDizziness = 300.0f; o->prevObj = o->oMrBlizzardHeldObj = NULL; - // After 60 frames, if Mario is within 11.25 degrees of Mr. Blizzard, throw snowball action. - } else if (o->oTimer > 60 && abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x800) { + } + // After 60 frames, if Mario is within 11.25 degrees of Mr. Blizzard, throw snowball action. + else if (o->oTimer > 60 && abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x800) { o->oAction = MR_BLIZZARD_ACT_THROW_SNOWBALL; } } @@ -203,17 +197,14 @@ static void mr_blizzard_act_rotate(void) { /** * Handler for Mr. Blizzard's death. */ - static void mr_blizzard_act_death(void) { - - struct Object *cap; - if (clamp_f32(&o->oMrBlizzardDizziness, -0x4000, 0x4000)) { if (o->oMrBlizzardChangeInDizziness != 0.0f) { cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1); // If Mr. Blizzard is wearing Mario's cap, clear // the save flag and spawn Mario's cap. - if (o->oAnimState) { + if (o->oAnimState != 0) { + struct Object *cap; save_file_clear_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD); cap = spawn_object_relative(0, 5, 105, 0, o, MODEL_MARIOS_CAP, bhvNormalCap); @@ -253,8 +244,9 @@ static void mr_blizzard_act_death(void) { set_object_respawn_info_bits(o, 1); } } - // Reset Mr. Blizzard if Mario leaves its radius. - } else if (o->oDistanceToMario > 1000.0f) { + } + // Reset Mr. Blizzard if Mario leaves its radius. + else if (o->oDistanceToMario > 1000.0f) { cur_obj_init_animation_with_sound(1); o->oAction = MR_BLIZZARD_ACT_SPAWN_SNOWBALL; @@ -269,9 +261,7 @@ static void mr_blizzard_act_death(void) { /** * Handler for snowball throw. */ - static void mr_blizzard_act_throw_snowball(void) { - // Play a sound and set HeldObj to NULL. Then set action to 0. if (cur_obj_init_anim_check_frame(1, 7)) { cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT); @@ -284,9 +274,7 @@ static void mr_blizzard_act_throw_snowball(void) { /** * Mr. Blizzard's going back into the ground function. */ - static void mr_blizzard_act_burrow(void) { - // Reset Dizziness by increasing ChangeInDizziness if // dizziness is negative and decreasing it if Dizziness o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness; @@ -307,9 +295,7 @@ static void mr_blizzard_act_burrow(void) { /** * Jumping Mr. Blizzard handler function. */ - static void mr_blizzard_act_jump(void) { - if (o->oMrBlizzardTimer != 0) { cur_obj_rotate_yaw_toward(o->oMrBlizzardTargetMoveYaw, 3400); @@ -323,8 +309,9 @@ static void mr_blizzard_act_jump(void) { o->oVelY = 25.0f; o->oMrBlizzardTimer = 30; o->oMrBlizzardDistFromHome = 0; - // Jump forward. - } else { + } + // Jump forward. + else { o->oForwardVel = 10.0f; o->oVelY = 50.0f; o->oMoveFlags = 0; @@ -350,7 +337,6 @@ static void mr_blizzard_act_jump(void) { /** * Mr. Blizzard update function. */ - void bhv_mr_blizzard_update(void) { cur_obj_update_floor_and_walls(); @@ -397,7 +383,6 @@ void bhv_mr_blizzard_update(void) { /** * Snowball initial takeoff position handler. */ - static void mr_blizzard_snowball_act_0(void) { cur_obj_move_using_fvel_and_gravity(); if (o->parentObj->prevObj == o) { @@ -410,13 +395,10 @@ static void mr_blizzard_snowball_act_0(void) { /** * Snowball launching action. */ - static void mr_blizzard_snowball_act_1(void) { - f32 marioDist; - if (o->parentObj->prevObj == NULL) { if (o->parentObj->oAction == MR_BLIZZARD_ACT_THROW_SNOWBALL) { - marioDist = o->oDistanceToMario; + f32 marioDist = o->oDistanceToMario; if (marioDist > 800.0f) { marioDist = 800.0f; } @@ -431,6 +413,7 @@ static void mr_blizzard_snowball_act_1(void) { o->oMoveFlags = 0; } } + // Snowball hitbox. struct ObjectHitbox sMrBlizzardSnowballHitbox = { /* interactType: */ INTERACT_MR_BLIZZARD, @@ -447,7 +430,6 @@ struct ObjectHitbox sMrBlizzardSnowballHitbox = { /** * Snowball collision function. */ - static void mr_blizzard_snowball_act_2(void) { // Set snowball to interact with walls, floors, and Mario. cur_obj_update_floor_and_walls(); @@ -466,7 +448,6 @@ static void mr_blizzard_snowball_act_2(void) { /** * Snowball behavior loop. */ - void bhv_mr_blizzard_snowball(void) { switch (o->oAction) { case 0: diff --git a/src/game/behaviors/mr_i.inc.c b/src/game/behaviors/mr_i.inc.c index 4d883ddf..cbf0a759 100644 --- a/src/game/behaviors/mr_i.inc.c +++ b/src/game/behaviors/mr_i.inc.c @@ -1,4 +1,4 @@ -// mr_i.c.inc +// mr_i.inc.c // this is actually the MrI particle loop function. piranha // plant code later on reuses this function. @@ -15,9 +15,11 @@ void mr_i_piranha_particle_act_0(void) { cur_obj_scale(3.0f); o->oForwardVel = 20.0f; cur_obj_update_floor_and_walls(); - if (0x8000 & o->oInteractStatus) + + if (o->oInteractStatus & INT_STATUS_INTERACTED) { o->oAction = 1; - else if ((o->oTimer >= 101) || (o->oMoveFlags & OBJ_MOVE_HIT_WALL) || o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) { + } else if ((o->oTimer > 100) || (o->oMoveFlags & OBJ_MOVE_HIT_WALL) + || (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { obj_mark_for_deletion(o); spawn_mist_particles(); } @@ -26,11 +28,15 @@ void mr_i_piranha_particle_act_0(void) { void mr_i_piranha_particle_act_1(void) { s32 i; obj_mark_for_deletion(o); - for (i = 0; i < 10; i++) + for (i = 0; i < 10; i++) { spawn_object(o, MODEL_PURPLE_MARBLE, bhvPurpleParticle); + } } -void (*sMrIParticleActions[])(void) = { mr_i_piranha_particle_act_0, mr_i_piranha_particle_act_1 }; +void (*sMrIParticleActions[])(void) = { + mr_i_piranha_particle_act_0, + mr_i_piranha_particle_act_1, +}; void bhv_mr_i_particle_loop(void) { cur_obj_call_action_function(sMrIParticleActions); @@ -39,32 +45,39 @@ void bhv_mr_i_particle_loop(void) { void spawn_mr_i_particle(void) { struct Object *particle; f32 sp18 = o->header.gfx.scale[1]; + particle = spawn_object(o, MODEL_PURPLE_MARBLE, bhvMrIParticle); particle->oPosY += 50.0f * sp18; particle->oPosX += sins(o->oMoveAngleYaw) * 90.0f * sp18; particle->oPosZ += coss(o->oMoveAngleYaw) * 90.0f * sp18; + cur_obj_play_sound_2(SOUND_OBJ_MRI_SHOOT); } void bhv_mr_i_body_loop(void) { obj_copy_pos_and_angle(o, o->parentObj); + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { obj_copy_scale(o, o->parentObj); obj_set_parent_relative_pos(o, 0, 0, o->header.gfx.scale[1] * 100.0f); obj_build_transform_from_pos_and_angle(o, 44, 15); obj_translate_local(o, 6, 44); o->oFaceAnglePitch = o->oMoveAnglePitch; - o->oGraphYOffset = o->header.gfx.scale[1] * 100.f; + o->oGraphYOffset = o->header.gfx.scale[1] * 100.0f; } - if (o->parentObj->oMrIUnk110 != 1) + + if (o->parentObj->oMrIUnk110 != 1) { o->oAnimState = -1; - else { + } else { o->oAnimState++; - if (o->oAnimState == 15) + if (o->oAnimState == 15) { o->parentObj->oMrIUnk110 = 0; + } } - if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { obj_mark_for_deletion(o); + } } void mr_i_act_3(void) { @@ -72,31 +85,43 @@ void mr_i_act_3(void) { s16 sp34; f32 sp30; f32 sp2C; - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; f32 sp20; f32 sp1C; - if (o->oBehParams2ndByte) + + if (o->oBehParams2ndByte != 0) { sp1C = 2.0f; - else + } else { sp1C = 1.0f; - if (o->oMrIUnk100 < 0) + } + + if (o->oMrIUnk100 < 0) { sp34 = 0x1000; - else + } else { sp34 = -0x1000; + } + sp2C = (o->oTimer + 1) / 96.0f; + if (o->oTimer < 64) { sp36 = o->oMoveAngleYaw; o->oMoveAngleYaw += sp34 * coss(0x4000 * sp2C); - if (sp36 < 0 && o->oMoveAngleYaw >= 0) + + if (sp36 < 0 && o->oMoveAngleYaw >= 0) { cur_obj_play_sound_2(SOUND_OBJ2_MRI_SPINNING); + } + o->oMoveAnglePitch = (1.0 - coss(0x4000 * sp2C)) * -0x4000; cur_obj_shake_y(4.0f); } else if (o->oTimer < 96) { - if (o->oTimer == 64) + if (o->oTimer == 64) { cur_obj_play_sound_2(SOUND_OBJ_MRI_DEATH); + } + sp30 = (f32)(o->oTimer - 63) / 32; o->oMoveAngleYaw += sp34 * coss(0x4000 * sp2C); o->oMoveAnglePitch = (1.0 - coss(0x4000 * sp2C)) * -0x4000; + cur_obj_shake_y((s32)((1.0f - sp30) * 4)); // trucating the f32? sp20 = coss(0x4000 * sp30) * 0.4 + 0.6; cur_obj_scale(sp20 * sp1C); @@ -106,66 +131,86 @@ void mr_i_act_3(void) { if (o->oTimer == 104) { cur_obj_become_intangible(); spawn_mist_particles(); - o->oMrISize = sp1C * 0.6; - if (o->oBehParams2ndByte) { + o->oMrIScale = sp1C * 0.6; + if (o->oBehParams2ndByte != 0) { o->oPosY += 100.0f; spawn_default_star(1370, 2000.0f, -320.0f); obj_mark_for_deletion(o); - } else + } else { cur_obj_spawn_loot_blue_coin(); + } } - o->oMrISize -= 0.2 * sp1C; - if (o->oMrISize < 0) - o->oMrISize = 0; - cur_obj_scale(o->oMrISize); - } else + + o->oMrIScale -= 0.2 * sp1C; + + if (o->oMrIScale < 0) { + o->oMrIScale = 0; + } + + cur_obj_scale(o->oMrIScale); + } else { obj_mark_for_deletion(o); + } } void mr_i_act_2(void) { - s16 sp1E; + s16 sp1E = o->oMoveAngleYaw; s16 sp1C; - sp1E = o->oMoveAngleYaw; + if (o->oTimer == 0) { - if (o->oBehParams2ndByte) + if (o->oBehParams2ndByte != 0) { o->oMrIUnkF4 = 200; - else + } else { o->oMrIUnkF4 = 120; + } o->oMrIUnkFC = 0; o->oMrIUnk100 = 0; o->oMrIUnk104 = 0; } + obj_turn_toward_object(o, gMarioObject, 0x10, 0x800); obj_turn_toward_object(o, gMarioObject, 0x0F, 0x400); + sp1C = sp1E - (s16)(o->oMoveAngleYaw); - if (!sp1C) { + + if (sp1C == 0) { o->oMrIUnkFC = 0; o->oMrIUnk100 = 0; } else if (sp1C > 0) { - if (o->oMrIUnk100 > 0) + if (o->oMrIUnk100 > 0) { o->oMrIUnkFC += sp1C; - else + } else { o->oMrIUnkFC = 0; + } o->oMrIUnk100 = 1; } else { - if (o->oMrIUnk100 < 0) + if (o->oMrIUnk100 < 0) { o->oMrIUnkFC -= sp1C; - else + } else { o->oMrIUnkFC = 0; + } o->oMrIUnk100 = -1; } - if (!o->oMrIUnkFC) + + if (o->oMrIUnkFC == 0) { o->oMrIUnkF4 = 120; - if (o->oMrIUnkFC > 1 << 16) + } + if (o->oMrIUnkFC > 65536) { o->oAction = 3; - o->oMrIUnkF4 -= 1; - if (!o->oMrIUnkF4) { + } + + o->oMrIUnkF4--; + + if (o->oMrIUnkF4 == 0) { o->oMrIUnkF4 = 120; o->oMrIUnkFC = 0; } + if (o->oMrIUnkFC < 5000) { - if (o->oMrIUnk104 == o->oMrIUnk108) + if (o->oMrIUnk104 == o->oMrIUnk108) { o->oMrIUnk110 = 1; + } + if (o->oMrIUnk104 == o->oMrIUnk108 + 20) { spawn_mr_i_particle(); o->oMrIUnk104 = 0; @@ -176,39 +221,45 @@ void mr_i_act_2(void) { o->oMrIUnk104 = 0; o->oMrIUnk108 = (s32)(random_float() * 50.0f + 50.0f); } - if (o->oDistanceToMario > 800.0f) + + if (o->oDistanceToMario > 800.0f) { o->oAction = 1; + } } void mr_i_act_1(void) { - s16 sp1E; - s16 sp1C; - s16 sp1A; - sp1E = obj_angle_to_object(o, gMarioObject); - sp1C = abs_angle_diff(o->oMoveAngleYaw, sp1E); - sp1A = abs_angle_diff(o->oMoveAngleYaw, gMarioObject->oFaceAngleYaw); + s16 sp1E = obj_angle_to_object(o, gMarioObject); + s16 sp1C = abs_angle_diff(o->oMoveAngleYaw, sp1E); + s16 sp1A = abs_angle_diff(o->oMoveAngleYaw, gMarioObject->oFaceAngleYaw); + if (o->oTimer == 0) { cur_obj_become_tangible(); o->oMoveAnglePitch = 0; o->oMrIUnk104 = 30; o->oMrIUnk108 = random_float() * 20.0f; - if (o->oMrIUnk108 & 1) + if (o->oMrIUnk108 & 1) { o->oAngleVelYaw = -256; - else + } else { o->oAngleVelYaw = 256; + } } + if (sp1C < 1024 && sp1A > 0x4000) { - if (o->oDistanceToMario < 700.0f) + if (o->oDistanceToMario < 700.0f) { o->oAction = 2; - else + } else { o->oMrIUnk104++; + } } else { o->oMoveAngleYaw += o->oAngleVelYaw; o->oMrIUnk104 = 30; } - if (o->oMrIUnk104 == o->oMrIUnk108 + 60) + + if (o->oMrIUnk104 == o->oMrIUnk108 + 60) { o->oMrIUnk110 = 1; - if (o->oMrIUnk108 + 80 < o->oMrIUnk104) { + } + + if (o->oMrIUnk104 > o->oMrIUnk108 + 80) { o->oMrIUnk104 = 0; o->oMrIUnk108 = random_float() * 80.0f; spawn_mr_i_particle(); @@ -224,31 +275,44 @@ void mr_i_act_0(void) { o->oMoveAngleRoll = 0; #endif cur_obj_scale(o->oBehParams2ndByte + 1); - if (o->oTimer == 0) + + if (o->oTimer == 0) { cur_obj_set_pos_to_home(); - if (o->oDistanceToMario < 1500.0f) + } + + if (o->oDistanceToMario < 1500.0f) { o->oAction = 1; + } } -void (*sMrIActions[])(void) = { mr_i_act_0, mr_i_act_1, mr_i_act_2, mr_i_act_3 }; +void (*sMrIActions[])(void) = { + mr_i_act_0, + mr_i_act_1, + mr_i_act_2, + mr_i_act_3, +}; struct ObjectHitbox sMrIHitbox = { - /* interactType: */ INTERACT_DAMAGE, - /* downOffset: */ 0, + /* interactType: */ INTERACT_DAMAGE, + /* downOffset: */ 0, /* damageOrCoinValue: */ 2, - /* health: */ 2, - /* numLootCoins: */ 5, - /* radius: */ 80, - /* height: */ 150, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 2, + /* numLootCoins: */ 5, + /* radius: */ 80, + /* height: */ 150, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; void bhv_mr_i_loop(void) { obj_set_hitbox(o, &sMrIHitbox); cur_obj_call_action_function(sMrIActions); - if (o->oAction != 3) - if (o->oDistanceToMario > 3000.0f || o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) + + if (o->oAction != 3) { + if ((o->oDistanceToMario > 3000.0f) || (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { o->oAction = 0; + } + } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/mushroom_1up.inc.c b/src/game/behaviors/mushroom_1up.inc.c index aac7c98d..ae0a7735 100644 --- a/src/game/behaviors/mushroom_1up.inc.c +++ b/src/game/behaviors/mushroom_1up.inc.c @@ -1,9 +1,9 @@ -// mushroom_1up.c.inc +// mushroom_1up.inc.c void bhv_1up_interact(void) { - UNUSED s32 sp1C; + UNUSED u8 filler[4]; - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { + if (obj_check_if_collided_with_object(o, gMarioObject) == TRUE) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); gMarioState->numLives++; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; @@ -51,21 +51,27 @@ void pole_1up_move_towards_mario(void) { s16 sp2A = atan2s(sqrtf(sqr(sp34) + sqr(sp2C)), sp30); obj_turn_toward_object(o, gMarioObject, 16, 0x1000); + o->oMoveAnglePitch = approach_s16_symmetric(o->oMoveAnglePitch, sp2A, 0x1000); o->oVelY = sins(o->oMoveAnglePitch) * 30.0f; o->oForwardVel = coss(o->oMoveAnglePitch) * 30.0f; + bhv_1up_interact(); } -void one_up_move_away_from_mario(s16 sp1A) { +void one_up_move_away_from_mario(s16 collisionFlags) { o->oForwardVel = 8.0f; o->oMoveAngleYaw = o->oAngleToMario + 0x8000; - bhv_1up_interact(); - if (sp1A & 0x02) - o->oAction = 2; - if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 3000)) + bhv_1up_interact(); + + if (collisionFlags & OBJ_COL_FLAG_HIT_WALL) { o->oAction = 2; + } + + if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 3000)) { + o->oAction = 2; + } } void bhv_1up_walking_loop(void) { @@ -73,11 +79,13 @@ void bhv_1up_walking_loop(void) { switch (o->oAction) { case 0: - if (o->oTimer >= 18) + if (o->oTimer > 17) { spawn_object(o, MODEL_NONE, bhvSparkleSpawn); + } - if (o->oTimer == 0) + if (o->oTimer == 0) { play_sound(SOUND_GENERAL2_1UP_APPEAR, gGlobalSoundSource); + } one_up_loop_in_air(); @@ -89,8 +97,9 @@ void bhv_1up_walking_loop(void) { break; case 1: - if (o->oTimer > 300) + if (o->oTimer > 300) { o->oAction = 2; + } bhv_1up_interact(); break; @@ -105,16 +114,17 @@ void bhv_1up_walking_loop(void) { } void bhv_1up_running_away_loop(void) { - s16 sp26; + s16 collisionFlags = object_step(); - sp26 = object_step(); switch (o->oAction) { case 0: - if (o->oTimer >= 18) + if (o->oTimer > 17) { spawn_object(o, MODEL_NONE, bhvSparkleSpawn); + } - if (o->oTimer == 0) + if (o->oTimer == 0) { play_sound(SOUND_GENERAL2_1UP_APPEAR, gGlobalSoundSource); + } one_up_loop_in_air(); @@ -127,7 +137,7 @@ void bhv_1up_running_away_loop(void) { case 1: spawn_object(o, MODEL_NONE, bhvSparkleSpawn); - one_up_move_away_from_mario(sp26); + one_up_move_away_from_mario(collisionFlags); break; case 2: @@ -140,29 +150,31 @@ void bhv_1up_running_away_loop(void) { } void sliding_1up_move(void) { - s16 sp1E; + s16 collisionFlags = object_step(); - sp1E = object_step(); - if (sp1E & 0x01) { + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { o->oForwardVel += 25.0f; - o->oVelY = 0; + o->oVelY = 0.0f; } else { o->oForwardVel *= 0.98; } - if (o->oForwardVel > 40.0) + if (o->oForwardVel > 40.0) { o->oForwardVel = 40.0f; + } - if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 5000)) + if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 5000)) { o->oAction = 2; + } } void bhv_1up_sliding_loop(void) { switch (o->oAction) { case 0: set_object_visibility(o, 3000); - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000)) + if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000)) { o->oAction = 1; + } break; case 1: @@ -185,7 +197,7 @@ void bhv_1up_loop(void) { } void bhv_1up_jump_on_approach_loop(void) { - s16 sp26; + s16 collisionFlags; switch (o->oAction) { case 0: @@ -196,13 +208,13 @@ void bhv_1up_jump_on_approach_loop(void) { break; case 1: - sp26 = object_step(); - one_up_move_away_from_mario(sp26); + collisionFlags = object_step(); + one_up_move_away_from_mario(collisionFlags); spawn_object(o, MODEL_NONE, bhvSparkleSpawn); break; case 2: - sp26 = object_step(); + collisionFlags = object_step(); bhv_1up_interact(); obj_flicker_and_disappear(o, 30); break; @@ -212,7 +224,8 @@ void bhv_1up_jump_on_approach_loop(void) { } void bhv_1up_hidden_loop(void) { - s16 sp26; + s16 collisionFlags; + switch (o->oAction) { case 0: o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; @@ -225,21 +238,22 @@ void bhv_1up_hidden_loop(void) { break; case 1: - sp26 = object_step(); - one_up_move_away_from_mario(sp26); + collisionFlags = object_step(); + one_up_move_away_from_mario(collisionFlags); spawn_object(o, MODEL_NONE, bhvSparkleSpawn); break; case 2: - sp26 = object_step(); + collisionFlags = object_step(); bhv_1up_interact(); obj_flicker_and_disappear(o, 30); break; case 3: - sp26 = object_step(); - if (o->oTimer >= 18) + collisionFlags = object_step(); + if (o->oTimer > 17) { spawn_object(o, MODEL_NONE, bhvSparkleSpawn); + } one_up_loop_in_air(); @@ -253,18 +267,19 @@ void bhv_1up_hidden_loop(void) { } void bhv_1up_hidden_trigger_loop(void) { - struct Object *sp1C; - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { - sp1C = cur_obj_nearest_object_with_behavior(bhvHidden1up); - if (sp1C != NULL) + if (obj_check_if_collided_with_object(o, gMarioObject) == TRUE) { + struct Object *sp1C = cur_obj_nearest_object_with_behavior(bhvHidden1up); + if (sp1C != NULL) { sp1C->o1UpHiddenUnkF4++; + } o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } void bhv_1up_hidden_in_pole_loop(void) { - UNUSED s16 sp26; + UNUSED s16 collisionFlags; + switch (o->oAction) { case 0: o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; @@ -278,13 +293,14 @@ void bhv_1up_hidden_in_pole_loop(void) { case 1: pole_1up_move_towards_mario(); - sp26 = object_step(); + collisionFlags = object_step(); break; case 3: - sp26 = object_step(); - if (o->oTimer >= 18) + collisionFlags = object_step(); + if (o->oTimer > 17) { spawn_object(o, MODEL_NONE, bhvSparkleSpawn); + } one_up_loop_in_air(); @@ -298,10 +314,8 @@ void bhv_1up_hidden_in_pole_loop(void) { } void bhv_1up_hidden_in_pole_trigger_loop(void) { - struct Object *sp1C; - - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { - sp1C = cur_obj_nearest_object_with_behavior(bhvHidden1upInPole); + if (obj_check_if_collided_with_object(o, gMarioObject) == TRUE) { + struct Object *sp1C = cur_obj_nearest_object_with_behavior(bhvHidden1upInPole); if (sp1C != NULL) { sp1C->o1UpHiddenUnkF4++; } @@ -311,12 +325,11 @@ void bhv_1up_hidden_in_pole_trigger_loop(void) { } void bhv_1up_hidden_in_pole_spawner_loop(void) { - s8 sp2F; - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 700)) { + s8 i; spawn_object_relative(2, 0, 50, 0, o, MODEL_1UP, bhvHidden1upInPole); - for (sp2F = 0; sp2F < 2; sp2F++) { - spawn_object_relative(0, 0, sp2F * -200, 0, o, MODEL_NONE, bhvHidden1upInPoleTrigger); + for (i = 0; i < 2; i++) { + spawn_object_relative(0, 0, i * -200, 0, o, MODEL_NONE, bhvHidden1upInPoleTrigger); } o->activeFlags = ACTIVE_FLAG_DEACTIVATED; diff --git a/src/game/behaviors/music_touch.inc.c b/src/game/behaviors/music_touch.inc.c index 5f3277d9..1597fb2e 100644 --- a/src/game/behaviors/music_touch.inc.c +++ b/src/game/behaviors/music_touch.inc.c @@ -1,4 +1,4 @@ -// music_touch.c.inc +// music_touch.inc.c void bhv_play_music_track_when_touched_loop(void) { if (o->oAction == 0) { diff --git a/src/game/behaviors/orange_number.inc.c b/src/game/behaviors/orange_number.inc.c index 84bf01e9..3b5554d8 100644 --- a/src/game/behaviors/orange_number.inc.c +++ b/src/game/behaviors/orange_number.inc.c @@ -1,4 +1,4 @@ -// orange_number.c.inc +// orange_number.inc.c void bhv_orange_number_init(void) { o->oAnimState = o->oBehParams2ndByte; @@ -6,15 +6,16 @@ void bhv_orange_number_init(void) { } void bhv_orange_number_loop(void) { - struct Object *sp1C; o->oPosY += o->oVelY; o->oVelY -= 2.0f; - if (o->oVelY < -21.0f) + + if (o->oVelY < -21.0f) { o->oVelY = 14.0; + } if (o->oTimer == 35) { - sp1C = spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles); - sp1C->oPosY -= 30.f; + struct Object *sp1C = spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles); + sp1C->oPosY -= 30.0f; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/piranha_bubbles.inc.c b/src/game/behaviors/piranha_bubbles.inc.c index 447c2751..21e01f66 100644 --- a/src/game/behaviors/piranha_bubbles.inc.c +++ b/src/game/behaviors/piranha_bubbles.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvPiranhaPlantBubble and bhvPiranhaPlantWakingBubbles. * @@ -30,12 +31,10 @@ void bhv_piranha_plant_bubble_loop(void) { struct Object *parent = o->parentObj; // the Piranha Plant f32 scale = 0; s32 i; - s32 frame = parent->header.gfx.animInfo.animFrame; + s32 animFrame = parent->header.gfx.animInfo.animFrame; // TODO: rename lastFrame if it is inaccurate s32 lastFrame = parent->header.gfx.animInfo.curAnim->loopEnd - 2; - s32 UNUSED unused; - f32 doneShrinkingFrame; // the first frame after shrinking is done - f32 beginGrowingFrame; // the frame just before growing begins + UNUSED u8 filler[4]; cur_obj_set_pos_relative(parent, 0, 72.0f, 180.0f); @@ -60,21 +59,21 @@ void bhv_piranha_plant_bubble_loop(void) { * slightly after halfway. This leaves about 8 frames during * which the bubble is at its smallest, where its scale is 1.0f. */ - doneShrinkingFrame = lastFrame / 2.0f - 4.0f; - beginGrowingFrame = lastFrame / 2.0f + 4.0f; + // the first frame after shrinking is done + f32 doneShrinkingFrame = lastFrame / 2.0f - 4.0f; + // the frame just before growing begins + f32 beginGrowingFrame = lastFrame / 2.0f + 4.0f; // Note that the bubble always starts this loop at its largest. - if (frame < doneShrinkingFrame) { + if (animFrame < doneShrinkingFrame) { // Shrink from 5.0f to 1.0f. - scale = coss(frame / doneShrinkingFrame * 0x4000) * 4.0f + 1.0; - } else if (frame > beginGrowingFrame) { + scale = coss(animFrame / doneShrinkingFrame * 0x4000) * 4.0f + 1.0; + } else if (animFrame > beginGrowingFrame) { // Grow from 1.0f to 5.0f. scale = sins(( - // they should have used beginGrowingFrame here: - (frame - (lastFrame / 2.0f + 4.0f)) / beginGrowingFrame) - * 0x4000) - * 4.0f - + 1.0; + // they should have used beginGrowingFrame here: + (animFrame - (lastFrame / 2.0f + 4.0f)) / beginGrowingFrame + ) * 0x4000) * 4.0f + 1.0; } else { // Stay at 1.0f for a few frames. scale = 1.0f; @@ -90,7 +89,7 @@ void bhv_piranha_plant_bubble_loop(void) { case PIRANHA_PLANT_BUBBLE_ACT_BURST: cur_obj_disable_rendering(); - scale = 0; + scale = 0.0f; // Spawn 15 small bubbles to make it look like this bubble burst. for (i = 0; i < 15; i++) { @@ -101,5 +100,6 @@ void bhv_piranha_plant_bubble_loop(void) { scale = 1.0f; // this has no effect; it is set to 0 in the idle state break; } + cur_obj_scale(scale); } diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index 17f298dd..9e97a8b6 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvPiranhaPlant. * This controls Piranha Plants, which alternate between sleeping, attacking, @@ -19,7 +20,7 @@ void piranha_plant_act_idle(void) { * with a scale below 1, which would cause it to appear shrunken. See * documentation for, and calls to, piranha_plant_reset_when_far(). */ - cur_obj_scale(1); + cur_obj_scale(1.0f); #endif if (o->oDistanceToMario < 1200.0f) { @@ -33,11 +34,12 @@ void piranha_plant_act_idle(void) { * with it through some other means (e.g. by running into it), move it to the * woken up state. * - * @return 1 if the player interacted with the Piranha Plant, 0 otherwise + * @return TRUE if the player interacted with the Piranha Plant, FALSE otherwise */ s32 piranha_plant_check_interactions(void) { s32 i; - s32 interacted = 1; + s32 interacted = TRUE; + if (o->oInteractStatus & INT_STATUS_INTERACTED) { func_80321080(50); if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) { @@ -53,13 +55,12 @@ s32 piranha_plant_check_interactions(void) { } o->oInteractStatus = 0; } else { - interacted = 0; + interacted = FALSE; } + return interacted; } -#define PIRANHA_PLANT_SLEEP_MUSIC_PLAYING 0 - /** * Make the Piranha Plant sleep. If Mario moves too quickly, move the Piranha * Plant to the woken up state. Otherwise, play the lullaby if Mario is close @@ -114,12 +115,13 @@ void piranha_plant_act_woken_up(void) { */ o->oDamageOrCoinValue = 3; #endif - if (o->oTimer == 0) + if (o->oTimer == 0) { func_80321080(50); + } - if (piranha_plant_check_interactions() == 0) - if (o->oTimer > 10) - o->oAction = PIRANHA_PLANT_ACT_BITING; + if (!piranha_plant_check_interactions() && o->oTimer > 10) { + o->oAction = PIRANHA_PLANT_ACT_BITING; + } } #if BUGFIX_PIRANHA_PLANT_STATE_RESET @@ -153,8 +155,9 @@ void piranha_plant_attacked(void) { cur_obj_become_intangible(); cur_obj_init_animation_with_sound(2); o->oInteractStatus = 0; - if (cur_obj_check_if_near_animation_end()) + if (cur_obj_check_if_near_animation_end()) { o->oAction = PIRANHA_PLANT_ACT_SHRINK_AND_DIE; + } #if BUGFIX_PIRANHA_PLANT_STATE_RESET piranha_plant_reset_when_far(); // see this function's comment #endif @@ -240,7 +243,7 @@ static s8 sPiranhaPlantBiteSoundFrames[] = { 12, 28, 50, 64, -1 }; * Piranha Plant will move to the attacked state. */ void piranha_plant_act_biting(void) { - s32 frame = o->header.gfx.animInfo.animFrame; + s32 animFrame = o->header.gfx.animInfo.animFrame; cur_obj_become_tangible(); @@ -252,22 +255,22 @@ void piranha_plant_act_biting(void) { cur_obj_set_hurtbox_radius_and_height(150.0f, 100.0f); // Play a bite sound effect on certain frames. - if (is_item_in_array(frame, sPiranhaPlantBiteSoundFrames)) { + if (is_item_in_array(animFrame, sPiranhaPlantBiteSoundFrames)) { cur_obj_play_sound_2(SOUND_OBJ2_PIRANHA_PLANT_BITE); } // Move to face the player. o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, 0x400); - if (o->oDistanceToMario > 500.0f) - if (cur_obj_check_if_near_animation_end()) - o->oAction = PIRANHA_PLANT_ACT_STOPPED_BITING; + if (o->oDistanceToMario > 500.0f && cur_obj_check_if_near_animation_end()) { + o->oAction = PIRANHA_PLANT_ACT_STOPPED_BITING; + } // If the player is wearing the Metal Cap and interacts with the Piranha // Plant, the Piranha Plant will die. - if (o->oInteractStatus & INT_STATUS_INTERACTED) - if (gMarioState->flags & MARIO_METAL_CAP) - o->oAction = PIRANHA_PLANT_ACT_ATTACKED; + if ((o->oInteractStatus & INT_STATUS_INTERACTED) && (gMarioState->flags & MARIO_METAL_CAP)) { + o->oAction = PIRANHA_PLANT_ACT_ATTACKED; + } } /** @@ -277,11 +280,13 @@ void piranha_plant_act_biting(void) { * This is called from both the "stopped biting" state and the "sleeping" state. */ s32 mario_moving_fast_enough_to_make_piranha_plant_bite(void) { - if (gMarioStates[0].vel[1] > 10.0f) - return 1; - if (gMarioStates[0].forwardVel > 10.0f) - return 1; - return 0; + if (gMarioStates[0].vel[1] > 10.0f) { + return TRUE; + } + if (gMarioStates[0].forwardVel > 10.0f) { + return TRUE; + } + return FALSE; } /** @@ -293,8 +298,9 @@ void piranha_plant_act_stopped_biting(void) { cur_obj_become_intangible(); cur_obj_init_animation_with_sound(6); - if (cur_obj_check_if_near_animation_end()) + if (cur_obj_check_if_near_animation_end()) { o->oAction = PIRANHA_PLANT_ACT_SLEEPING; + } /** * Note that this state only occurs initially when the player goes further @@ -303,9 +309,9 @@ void piranha_plant_act_stopped_biting(void) { * of the Piranha Plant during the short time the Piranha Plant's nod * animation plays. */ - if (o->oDistanceToMario < 400.0f) - if (mario_moving_fast_enough_to_make_piranha_plant_bite()) - o->oAction = PIRANHA_PLANT_ACT_BITING; + if (o->oDistanceToMario < 400.0f && mario_moving_fast_enough_to_make_piranha_plant_bite()) { + o->oAction = PIRANHA_PLANT_ACT_BITING; + } } /** @@ -320,7 +326,7 @@ void (*TablePiranhaPlantActions[])(void) = { piranha_plant_attacked, // PIRANHA_PLANT_ATTACKED, piranha_plant_act_shrink_and_die, // PIRANHA_PLANT_ACT_SHRINK_AND_DIE, piranha_plant_act_wait_to_respawn, // PIRANHA_PLANT_ACT_WAIT_TO_RESPAWN, - piranha_plant_act_respawn // PIRANHA_PLANT_ACT_RESPAWN + piranha_plant_act_respawn, // PIRANHA_PLANT_ACT_RESPAWN }; /** @@ -331,10 +337,12 @@ void bhv_piranha_plant_loop(void) { // In WF, hide all Piranha Plants once high enough up. if (gCurrLevelNum == LEVEL_WF) { - if (gMarioObject->oPosY > 3400.0f) + if (gMarioObject->oPosY > 3400.0f) { cur_obj_hide(); - else + } else { cur_obj_unhide(); + } } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c index f33a1656..51007e62 100644 --- a/src/game/behaviors/platform_on_track.inc.c +++ b/src/game/behaviors/platform_on_track.inc.c @@ -8,7 +8,7 @@ /** * Collision models for the different types of platforms. */ -static void const *sPlatformOnTrackCollisionModels[] = { +static Collision const *sPlatformOnTrackCollisionModels[] = { /* PLATFORM_ON_TRACK_TYPE_CARPET */ rr_seg7_collision_07029038, /* PLATFORM_ON_TRACK_TYPE_SKI_LIFT */ ccm_seg7_collision_070163F8, /* PLATFORM_ON_TRACK_TYPE_CHECKERED */ checkerboard_platform_seg8_collision_0800D710, @@ -18,10 +18,16 @@ static void const *sPlatformOnTrackCollisionModels[] = { /** * Paths for the different instances of these platforms. */ -static void const *sPlatformOnTrackPaths[] = { - rr_seg7_trajectory_0702EC3C, rr_seg7_trajectory_0702ECC0, ccm_seg7_trajectory_0701669C, - bitfs_seg7_trajectory_070159AC, hmc_seg7_trajectory_0702B86C, lll_seg7_trajectory_0702856C, - lll_seg7_trajectory_07028660, rr_seg7_trajectory_0702ED9C, rr_seg7_trajectory_0702EEE0, +static Trajectory const *sPlatformOnTrackPaths[] = { + rr_seg7_trajectory_0702EC3C, + rr_seg7_trajectory_0702ECC0, + ccm_seg7_trajectory_0701669C, + bitfs_seg7_trajectory_070159AC, + hmc_seg7_trajectory_0702B86C, + lll_seg7_trajectory_0702856C, + lll_seg7_trajectory_07028660, + rr_seg7_trajectory_0702ED9C, + rr_seg7_trajectory_0702EEE0, }; /** diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c index df5d11f5..9f870869 100644 --- a/src/game/behaviors/pokey.inc.c +++ b/src/game/behaviors/pokey.inc.c @@ -66,7 +66,7 @@ void bhv_pokey_body_part_update(void) { o->parentObj->oPokeyAliveBodyPartFlags = o->parentObj->oPokeyAliveBodyPartFlags & ((1 << o->oBehParams2ndByte) ^ ~0); - o->oBehParams2ndByte -= 1; + o->oBehParams2ndByte--; } // Set the bottom body part size, and gradually increase it. @@ -109,7 +109,7 @@ void bhv_pokey_body_part_update(void) { // then die after a delay. if (obj_handle_attacks(&sPokeyBodyPartHitbox, o->oAction, sPokeyBodyPartAttackHandlers)) { - o->parentObj->oPokeyNumAliveBodyParts -= 1; + o->parentObj->oPokeyNumAliveBodyParts--; if (o->oBehParams2ndByte == 0) { o->parentObj->oPokeyHeadWasKilled = TRUE; // Last minute change to blue coins - not sure why they didn't @@ -123,7 +123,7 @@ void bhv_pokey_body_part_update(void) { cur_obj_become_intangible(); if (--o->oPokeyBodyPartDeathDelayAfterHeadKilled < 0) { - o->parentObj->oPokeyNumAliveBodyParts -= 1; + o->parentObj->oPokeyNumAliveBodyParts--; obj_die_if_health_non_positive(); } } else { @@ -181,7 +181,6 @@ static void pokey_act_uninitialized(void) { */ static void pokey_act_wander(void) { s32 targetAngleOffset; - struct Object *bodyPart; if (o->oPokeyNumAliveBodyParts == 0) { obj_mark_for_deletion(o); @@ -204,13 +203,14 @@ static void pokey_act_wander(void) { // is killed, the new part's index is equal to the number // of living body parts - bodyPart = spawn_object_relative(o->oPokeyNumAliveBodyParts, 0, 0, 0, o, - MODEL_POKEY_BODY_PART, bhvPokeyBodyPart); + struct Object *bodyPart + = spawn_object_relative(o->oPokeyNumAliveBodyParts, 0, 0, 0, o, + MODEL_POKEY_BODY_PART, bhvPokeyBodyPart); if (bodyPart != NULL) { o->oPokeyAliveBodyPartFlags = o->oPokeyAliveBodyPartFlags | (1 << o->oPokeyNumAliveBodyParts); - o->oPokeyNumAliveBodyParts += 1; + o->oPokeyNumAliveBodyParts++; o->oPokeyBottomBodyPartSize = 0.0f; obj_scale(bodyPart, 0.0f); @@ -234,7 +234,7 @@ static void pokey_act_wander(void) { if (!(o->oPokeyTurningAwayFromWall = obj_bounce_off_walls_edges_objects(&o->oPokeyTargetYaw))) { if (o->oPokeyChangeTargetTimer != 0) { - o->oPokeyChangeTargetTimer -= 1; + o->oPokeyChangeTargetTimer--; } else if (o->oDistanceToMario > 2000.0f) { o->oPokeyTargetYaw = obj_random_fixed_turn(0x2000); o->oPokeyChangeTargetTimer = random_linear_offset(30, 50); diff --git a/src/game/behaviors/pole.inc.c b/src/game/behaviors/pole.inc.c index d727751c..1066e003 100644 --- a/src/game/behaviors/pole.inc.c +++ b/src/game/behaviors/pole.inc.c @@ -1,3 +1,4 @@ + /** * Behaviors for bhvPoleGrabbing and bhvGiantPole. * @@ -16,7 +17,7 @@ void bhv_pole_init(void) { * This is equivalent to using `o->oBehParams2ndByte` according to * `spawn_objects_from_info`. */ - s32 tenthHitboxHeight = o->oBehParams >> 0x10 & 0xFF; + s32 tenthHitboxHeight = (o->oBehParams >> 16) & 0xFF; o->hitboxHeight = tenthHitboxHeight * 10; } @@ -26,9 +27,8 @@ void bhv_pole_init(void) { * first frame. */ void bhv_giant_pole_loop(void) { - struct Object *topBall; if (o->oTimer == 0) { - topBall = spawn_object(o, MODEL_YELLOW_SPHERE, bhvYellowBall); + struct Object *topBall = spawn_object(o, MODEL_YELLOW_SPHERE, bhvYellowBall); topBall->oPosY += o->hitboxHeight + 50.0f; } bhv_pole_base_loop(); diff --git a/src/game/behaviors/pole_base.inc.c b/src/game/behaviors/pole_base.inc.c index 543fa28d..874c8704 100644 --- a/src/game/behaviors/pole_base.inc.c +++ b/src/game/behaviors/pole_base.inc.c @@ -2,8 +2,9 @@ void bhv_pole_base_loop(void) { if (o->oPosY - 10.0f < gMarioObject->oPosY - && gMarioObject->oPosY < o->oPosY + o->hitboxHeight + 30.0f) - if (o->oTimer > 10) - if (!(gMarioStates[0].action & MARIO_PUNCHING)) - cur_obj_push_mario_away(70.0f); + && gMarioObject->oPosY < o->oPosY + o->hitboxHeight + 30.0f) { + if (o->oTimer > 10 && !(gMarioStates[0].action & MARIO_PUNCHING)) { + cur_obj_push_mario_away(70.0f); + } + } } diff --git a/src/game/behaviors/purple_switch.inc.c b/src/game/behaviors/purple_switch.inc.c index a90483aa..a5157746 100644 --- a/src/game/behaviors/purple_switch.inc.c +++ b/src/game/behaviors/purple_switch.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvFloorSwitchHardcodedModel, bhvFloorSwitchGrills, and * bhvFloorSwitchAnimatesObject. @@ -7,7 +8,8 @@ */ void bhv_purple_switch_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; + switch (o->oAction) { /** * Set the switch's model and scale. If Mario is standing near the @@ -22,6 +24,7 @@ void bhv_purple_switch_loop(void) { } } break; + /** * Collapse the switch downward, play a sound, and shake the screen. * Immediately transition to the ticking state. @@ -37,6 +40,7 @@ void bhv_purple_switch_loop(void) { #endif } break; + /** * Play a continuous ticking sound that gets faster when time is almost * up. When time is up, move to a waiting-while-pressed state. @@ -57,6 +61,7 @@ void bhv_purple_switch_loop(void) { } } break; + /** * Make the switch look unpressed again, and transition back to the * idle state. @@ -67,6 +72,7 @@ void bhv_purple_switch_loop(void) { o->oAction = PURPLE_SWITCH_IDLE; } break; + /** * Mario is standing on the switch, but time has expired. Wait for * him to get off the switch, and when he does so, transition to the diff --git a/src/game/behaviors/pyramid_elevator.inc.c b/src/game/behaviors/pyramid_elevator.inc.c index 4379e70d..ac089de9 100644 --- a/src/game/behaviors/pyramid_elevator.inc.c +++ b/src/game/behaviors/pyramid_elevator.inc.c @@ -1,3 +1,4 @@ + /** * Behaviors for bhvPyramidElevator and bhvPyramidElevatorTrajectoryMarkerBall. * @@ -11,10 +12,10 @@ */ void bhv_pyramid_elevator_init(void) { s32 i; - struct Object *ball; for (i = 0; i < 10; i++) { - ball = spawn_object(o, MODEL_TRAJECTORY_MARKER_BALL, bhvPyramidElevatorTrajectoryMarkerBall); + struct Object *ball = spawn_object(o, MODEL_TRAJECTORY_MARKER_BALL, + bhvPyramidElevatorTrajectoryMarkerBall); ball->oPosY = 4600 - i * 460; } } @@ -26,8 +27,9 @@ void bhv_pyramid_elevator_loop(void) { * transition to the starting state. */ case PYRAMID_ELEVATOR_IDLE: - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->oAction = PYRAMID_ELEVATOR_START_MOVING; + } break; /** @@ -36,8 +38,9 @@ void bhv_pyramid_elevator_loop(void) { */ case PYRAMID_ELEVATOR_START_MOVING: o->oPosY = o->oHomeY - sins(o->oTimer * 0x1000) * 10.0f; - if (o->oTimer == 8) + if (o->oTimer == 8) { o->oAction = PYRAMID_ELEVATOR_CONSTANT_VELOCITY; + } break; /** diff --git a/src/game/behaviors/pyramid_top.inc.c b/src/game/behaviors/pyramid_top.inc.c index 824d24f2..14b6bc2f 100644 --- a/src/game/behaviors/pyramid_top.inc.c +++ b/src/game/behaviors/pyramid_top.inc.c @@ -1,3 +1,4 @@ + /** * Behaviors for bhvPyramidTop, bhvPyramidTopFragment, and * bhvPyramidPillarTouchDetector. @@ -14,14 +15,14 @@ * Spawn the four pillars' touch detectors. */ void bhv_pyramid_top_init(void) { - spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, 1789, 1024, 764, 0, 0, - 0); - spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, 1789, 896, -2579, 0, 0, - 0); - spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, -5883, 1024, -2579, 0, 0, - 0); - spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, -5883, 1024, 764, 0, 0, - 0); + spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, + 1789, 1024, 764, 0, 0, 0); + spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, + 1789, 896, -2579, 0, 0, 0); + spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, + -5883, 1024, -2579, 0, 0, 0); + spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvPyramidPillarTouchDetector, + -5883, 1024, 764, 0, 0, 0); } /** @@ -29,8 +30,6 @@ void bhv_pyramid_top_init(void) { * fragments in the process. */ void bhv_pyramid_top_spinning(void) { - struct Object *pyramidFragment; - // (TODO: What is this doing) o->oPosX = o->oHomeX + sins(o->oTimer * 0x4000) * 40.0f; @@ -52,7 +51,7 @@ void bhv_pyramid_top_spinning(void) { // Every frame until 90 frames have passed, generate a pyramid fragment // with a random velocity and angle. if (o->oTimer < 90) { - pyramidFragment = spawn_object(o, MODEL_DIRT_ANIMATION, bhvPyramidTopFragment); + struct Object *pyramidFragment = spawn_object(o, MODEL_DIRT_ANIMATION, bhvPyramidTopFragment); pyramidFragment->oForwardVel = random_float() * 10.0f + 20.0f; pyramidFragment->oMoveAngleYaw = random_u16(); pyramidFragment->oPyramidTopFragmentsScale = 0.8f; @@ -76,9 +75,7 @@ void bhv_pyramid_top_explode(void) { // Generate 30 pyramid fragments with random properties. for (i = 0; i < 30; i++) { - pyramidFragment = spawn_object( - o, MODEL_DIRT_ANIMATION, bhvPyramidTopFragment - ); + pyramidFragment = spawn_object(o, MODEL_DIRT_ANIMATION, bhvPyramidTopFragment); pyramidFragment->oForwardVel = random_float() * 50 + 80; pyramidFragment->oVelY = random_float() * 80 + 20; pyramidFragment->oMoveAngleYaw = random_u16(); @@ -147,7 +144,7 @@ void bhv_pyramid_top_fragment_loop(void) { */ void bhv_pyramid_pillar_touch_detector_loop(void) { cur_obj_become_tangible(); - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { + if (obj_check_if_collided_with_object(o, gMarioObject) == TRUE) { // Increase the pyramid top's count of pillars touched. o->parentObj->oPyramidTopPillarsTouched++; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; diff --git a/src/game/behaviors/pyramid_wall.inc.c b/src/game/behaviors/pyramid_wall.inc.c index 4e805f8d..8306aca6 100644 --- a/src/game/behaviors/pyramid_wall.inc.c +++ b/src/game/behaviors/pyramid_wall.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvSslMovingPyramidWall. * @@ -11,7 +12,6 @@ * positions. */ void bhv_ssl_moving_pyramid_wall_init(void) { - switch (o->oBehParams2ndByte) { case PYRAMID_WALL_BP_POSITION_HIGH: break; @@ -36,14 +36,16 @@ void bhv_ssl_moving_pyramid_wall_loop(void) { switch (o->oAction) { case PYRAMID_WALL_ACT_MOVING_DOWN: o->oVelY = -5.12f; - if (o->oTimer == 100) + if (o->oTimer == 100) { o->oAction = PYRAMID_WALL_ACT_MOVING_UP; + } break; case PYRAMID_WALL_ACT_MOVING_UP: o->oVelY = 5.12f; - if (o->oTimer == 100) + if (o->oTimer == 100) { o->oAction = PYRAMID_WALL_ACT_MOVING_DOWN; + } break; } diff --git a/src/game/behaviors/racing_penguin.inc.c b/src/game/behaviors/racing_penguin.inc.c index a287229d..21639ec1 100644 --- a/src/game/behaviors/racing_penguin.inc.c +++ b/src/game/behaviors/racing_penguin.inc.c @@ -1,3 +1,5 @@ +// racing_penguin.inc.c + struct RacingPenguinData { s16 text; f32 radius; @@ -58,15 +60,12 @@ static void racing_penguin_act_prepare_for_race(void) { } static void racing_penguin_act_race(void) { - f32 targetSpeed; - f32 minSpeed; - if (cur_obj_follow_path(0) == PATH_REACHED_END) { o->oRacingPenguinReachedBottom = TRUE; o->oAction = RACING_PENGUIN_ACT_FINISH_RACE; } else { - targetSpeed = o->oPosY - gMarioObject->oPosY; - minSpeed = 70.0f; + f32 targetSpeed = o->oPosY - gMarioObject->oPosY; + f32 minSpeed = 70.0f; cur_obj_play_sound_1(SOUND_AIR_ROUGH_SLIDE); @@ -108,14 +107,12 @@ static void racing_penguin_act_finish_race(void) { set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ); o->oForwardVel = 0.0f; } - } else if (cur_obj_init_anim_and_check_if_end(2) != 0) { + } else if (cur_obj_init_anim_and_check_if_end(2)) { o->oAction = RACING_PENGUIN_ACT_SHOW_FINAL_TEXT; } } static void racing_penguin_act_show_final_text(void) { - s32 textResult; - if (o->oRacingPenguinFinalTextbox == 0) { if (cur_obj_rotate_yaw_toward(0, 200)) { cur_obj_init_animation_with_sound(3); @@ -143,6 +140,7 @@ static void racing_penguin_act_show_final_text(void) { o->oForwardVel = 4.0f; } } else if (o->oRacingPenguinFinalTextbox > 0) { + s32 textResult; if ((textResult = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, o->oRacingPenguinFinalTextbox))) { o->oRacingPenguinFinalTextbox = -1; @@ -185,15 +183,14 @@ void bhv_racing_penguin_update(void) { cur_obj_move_standard(78); cur_obj_align_gfx_with_floor(); cur_obj_push_mario_away_from_cylinder(sRacingPenguinData[o->oBehParams2ndByte].radius, - sRacingPenguinData[o->oBehParams2ndByte].height); + sRacingPenguinData[o->oBehParams2ndByte].height); } void bhv_penguin_race_finish_line_update(void) { - if (o->parentObj->oRacingPenguinReachedBottom - || (o->oDistanceToMario < 1000.0f && gMarioObject->oPosZ - o->oPosZ < 0.0f)) { - if (!o->parentObj->oRacingPenguinReachedBottom) { - o->parentObj->oRacingPenguinMarioWon = TRUE; - } + if ((o->parentObj->oRacingPenguinReachedBottom + || (o->oDistanceToMario < 1000.0f && gMarioObject->oPosZ - o->oPosZ < 0.0f)) + && !o->parentObj->oRacingPenguinReachedBottom) { + o->parentObj->oRacingPenguinMarioWon = TRUE; } } diff --git a/src/game/behaviors/recovery_heart.inc.c b/src/game/behaviors/recovery_heart.inc.c index 6bebfaa3..83e082e5 100644 --- a/src/game/behaviors/recovery_heart.inc.c +++ b/src/game/behaviors/recovery_heart.inc.c @@ -1,3 +1,4 @@ +// recovery_heart.inc.c struct ObjectHitbox sRecoveryHeartHitbox = { /* interactType: */ 0, @@ -16,7 +17,7 @@ void bhv_recovery_heart_loop(void) { if (obj_check_if_collided_with_object(o, gMarioObject)) { if (o->oSpinningHeartPlayedSound == 0) { cur_obj_play_sound_2(SOUND_GENERAL_HEART_SPIN); - o->oSpinningHeartPlayedSound += 1; + o->oSpinningHeartPlayedSound++; } o->oAngleVelYaw = (s32)(200.0f * gMarioStates[0].forwardVel) + 1000; diff --git a/src/game/behaviors/red_coin.inc.c b/src/game/behaviors/red_coin.inc.c index 40d7d6da..6c4ef8ef 100644 --- a/src/game/behaviors/red_coin.inc.c +++ b/src/game/behaviors/red_coin.inc.c @@ -1,3 +1,4 @@ + /** * This file contains the initialization and behavior for red coins. * Behavior controls audio and the orange number spawned, as well as interacting with @@ -27,19 +28,17 @@ void bhv_red_coin_init(void) { struct Surface *dummyFloor; UNUSED f32 floorHeight = find_floor(o->oPosX, o->oPosY, o->oPosZ, &dummyFloor); + // Set the red coins to have a parent of the closest red coin star. struct Object *hiddenRedCoinStar; - // Set the red coins to have a parent of the closest red coin star. - hiddenRedCoinStar = cur_obj_nearest_object_with_behavior(bhvHiddenRedCoinStar); - if (hiddenRedCoinStar != NULL) + if ((hiddenRedCoinStar = + cur_obj_nearest_object_with_behavior(bhvHiddenRedCoinStar)) != NULL) { o->parentObj = hiddenRedCoinStar; - else { - hiddenRedCoinStar = cur_obj_nearest_object_with_behavior(bhvBowserCourseRedCoinStar); - if (hiddenRedCoinStar != NULL) { - o->parentObj = hiddenRedCoinStar; - } else { - o->parentObj = NULL; - } + } else if ((hiddenRedCoinStar = + cur_obj_nearest_object_with_behavior(bhvBowserCourseRedCoinStar)) != NULL) { + o->parentObj = hiddenRedCoinStar; + } else { + o->parentObj = NULL; } obj_set_hitbox(o, &sRedCoinHitbox); @@ -69,7 +68,7 @@ void bhv_red_coin_loop(void) { // On all versions but the JP version, each coin collected plays a higher noise. #ifndef VERSION_JP play_sound(SOUND_MENU_COLLECT_RED_COIN - + (((u8) o->parentObj->oHiddenStarTriggerCounter - 1) << 16), + + (((u8) o->parentObj->oHiddenStarTriggerCounter - 1) << 16), gGlobalSoundSource); #endif } diff --git a/src/game/behaviors/reds_star_marker.inc.c b/src/game/behaviors/reds_star_marker.inc.c index eab82d20..03298a64 100644 --- a/src/game/behaviors/reds_star_marker.inc.c +++ b/src/game/behaviors/reds_star_marker.inc.c @@ -1,4 +1,4 @@ - +// reds_star_marker.inc.c // Filename is abbreviated to prevent compiler seg fault void bhv_red_coin_star_marker_init(void) { diff --git a/src/game/behaviors/rolling_log.inc.c b/src/game/behaviors/rolling_log.inc.c index dd88e552..d77a3b5b 100644 --- a/src/game/behaviors/rolling_log.inc.c +++ b/src/game/behaviors/rolling_log.inc.c @@ -1,4 +1,4 @@ -// rolling_log.c.inc +// rolling_log.inc.c // why are the falling platforms and rolling logs grouped // together? seems strange, but it also cooresponds to the @@ -10,50 +10,56 @@ void bhv_ttm_rolling_log_init(void) { o->oPitouneUnkF8 = 3970.0f; o->oPitouneUnkFC = 3654.0f; o->oPitouneUnkF4 = 271037.0f; + o->oMoveAngleYaw = 8810; - o->oForwardVel = 0; - o->oVelX = 0; - o->oVelZ = 0; + o->oForwardVel = 0.0f; + o->oVelX = 0.0f; + o->oVelZ = 0.0f; o->oFaceAnglePitch = 0; o->oAngleVelPitch = 0; } void rolling_log_roll_log(void) { - f32 sp24; - if (gMarioObject->platform == o) { - sp24 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-1*o->oMoveAngleYaw) - - (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-1*o->oMoveAngleYaw); - if (sp24 > 0) + f32 sp24 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-1*o->oMoveAngleYaw) + - (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-1*o->oMoveAngleYaw); + if (sp24 > 0) { o->oAngleVelPitch += 0x10; - else + } else { o->oAngleVelPitch -= 0x10; + } - if (o->oAngleVelPitch > 0x200) + if (o->oAngleVelPitch > 0x200) { o->oAngleVelPitch = 0x200; + } - if (o->oAngleVelPitch < -0x200) + if (o->oAngleVelPitch < -0x200) { o->oAngleVelPitch = -0x200; + } } else { if (is_point_close_to_object(o, o->oHomeX, o->oHomeY, o->oHomeZ, 100)) { if (o->oAngleVelPitch != 0) { - if (o->oAngleVelPitch > 0) + if (o->oAngleVelPitch > 0) { o->oAngleVelPitch -= 0x10; - else + } else { o->oAngleVelPitch += 0x10; + } - if (o->oAngleVelPitch < 0x10 && o->oAngleVelPitch > -0x10) + if (o->oAngleVelPitch < 0x10 && o->oAngleVelPitch > -0x10) { o->oAngleVelPitch = 0; + } } } else { if (o->oAngleVelPitch != 0x100) { - if (o->oAngleVelPitch > 0x100) + if (o->oAngleVelPitch > 0x100) { o->oAngleVelPitch -= 0x10; - else + } else { o->oAngleVelPitch += 0x10; + } - if (o->oAngleVelPitch < 0x110 && o->oAngleVelPitch > 0xF0) + if (o->oAngleVelPitch < 0x110 && o->oAngleVelPitch > 0xF0) { o->oAngleVelPitch = 0x100; + } } } } @@ -73,11 +79,11 @@ void bhv_rolling_log_loop(void) { o->oPosZ += o->oVelZ; if (o->oPitouneUnkF4 < sqr(o->oPosX - o->oPitouneUnkF8) + sqr(o->oPosZ - o->oPitouneUnkFC)) { - o->oForwardVel = 0; + o->oForwardVel = 0.0f; o->oPosX = prevX; o->oPosZ = prevZ; - o->oVelX = 0; - o->oVelZ = 0; + o->oVelX = 0.0f; + o->oVelZ = 0.0f; } o->oFaceAnglePitch += o->oAngleVelPitch; @@ -104,11 +110,14 @@ void volcano_act_1(void) { void volcano_act_3(void) { o->oAngleVelPitch = 0x90; o->oFaceAnglePitch += o->oAngleVelPitch; - if (o->oFaceAnglePitch > 0) - o->oFaceAnglePitch = 0; - if (o->oTimer == 200) + if (o->oFaceAnglePitch > 0) { + o->oFaceAnglePitch = 0; + } + + if (o->oTimer == 200) { o->oAction = 0; + } } void bhv_volcano_trap_loop(void) { @@ -146,9 +155,9 @@ void bhv_lll_rolling_log_init(void) { o->oPitouneUnkF4 = 1048576.0f; o->oMoveAngleYaw = 0x3FFF; - o->oForwardVel = 0; - o->oVelX = 0; - o->oVelZ = 0; + o->oForwardVel = 0.0f; + o->oVelX = 0.0f; + o->oVelZ = 0.0f; o->oFaceAnglePitch = 0; o->oAngleVelPitch = 0; } diff --git a/src/game/behaviors/rotating_octagonal_plat.inc.c b/src/game/behaviors/rotating_octagonal_plat.inc.c index 2126c944..3e644848 100644 --- a/src/game/behaviors/rotating_octagonal_plat.inc.c +++ b/src/game/behaviors/rotating_octagonal_plat.inc.c @@ -8,8 +8,8 @@ static const Collision *sOctagonalPlatformCollision[] = { static s16 sOctagonalPlatformAngularVelocities[] = { 300, -300, 600, -600 }; void bhv_rotating_octagonal_plat_init(void) { - o->collisionData = segmented_to_virtual(sOctagonalPlatformCollision[(u8)(o->oBehParams >> 16)]); - o->oAngleVelYaw = sOctagonalPlatformAngularVelocities[(u8)(o->oBehParams >> 24)]; + o->collisionData = segmented_to_virtual(sOctagonalPlatformCollision[(o->oBehParams >> 16) & 0xFF]); + o->oAngleVelYaw = sOctagonalPlatformAngularVelocities[(o->oBehParams >> 24) & 0xFF]; } void bhv_rotating_octagonal_plat_loop(void) { diff --git a/src/game/behaviors/rotating_platform.inc.c b/src/game/behaviors/rotating_platform.inc.c index c81aaa80..9f381b8e 100644 --- a/src/game/behaviors/rotating_platform.inc.c +++ b/src/game/behaviors/rotating_platform.inc.c @@ -1,11 +1,18 @@ -// rotating_platform.c.inc +// rotating_platform.inc.c #include "levels/wf/header.h" #include "levels/wdw/header.h" +struct WFRotatingPlatformData { + s16 unused; + s16 scale; + const Collision *collisionData; + s16 collisionDistance; +}; + struct WFRotatingPlatformData sWFRotatingPlatformData[] = { { 0, 100, wf_seg7_collision_rotating_platform, 2000 }, - { 0, 150, wdw_seg7_collision_070186B4, 1000 } + { 0, 150, wdw_seg7_collision_070186B4, 1000 }, }; void bhv_wf_rotating_wooden_platform_loop(void) { @@ -16,8 +23,9 @@ void bhv_wf_rotating_wooden_platform_loop(void) { } } else { o->oAngleVelYaw = 0x100; - if (o->oTimer > 126) + if (o->oTimer > 126) { o->oAction = 0; + } cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2); } cur_obj_rotate_face_angle_using_vel(); diff --git a/src/game/behaviors/scuttlebug.inc.c b/src/game/behaviors/scuttlebug.inc.c index 16840e1c..6ec01555 100644 --- a/src/game/behaviors/scuttlebug.inc.c +++ b/src/game/behaviors/scuttlebug.inc.c @@ -1,15 +1,15 @@ -// scuttlebug.c.inc +// scuttlebug.inc.c struct ObjectHitbox sScuttlebugHitbox = { - /* interactType: */ INTERACT_BOUNCE_TOP, - /* downOffset: */ 0, + /* interactType: */ INTERACT_BOUNCE_TOP, + /* downOffset: */ 0, /* damageOrCoinValue: */ 1, - /* health: */ 1, - /* numLootCoins: */ 3, - /* radius: */ 130, - /* height: */ 70, - /* hurtboxRadius: */ 90, - /* hurtboxHeight: */ 60, + /* health: */ 1, + /* numLootCoins: */ 3, + /* radius: */ 130, + /* height: */ 70, + /* hurtboxRadius: */ 90, + /* hurtboxHeight: */ 60, }; s32 update_angle_from_move_flags(s32 *angle) { @@ -24,19 +24,26 @@ s32 update_angle_from_move_flags(s32 *angle) { } void bhv_scuttlebug_loop(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; f32 sp18; + cur_obj_update_floor_and_walls(); + if (o->oSubAction != 0 && cur_obj_set_hitbox_and_die_if_attacked(&sScuttlebugHitbox, SOUND_OBJ_DYING_ENEMY1, - o->oScuttlebugUnkF4)) + o->oScuttlebugUnkF4)) { o->oSubAction = 3; - if (o->oSubAction != 1) + } + + if (o->oSubAction != 1) { o->oScuttlebugUnkF8 = 0; + } + switch (o->oSubAction) { case 0: - if (o->oMoveFlags & OBJ_MOVE_LANDED) + if (o->oMoveFlags & OBJ_MOVE_LANDED) { cur_obj_play_sound_2(SOUND_OBJ_GOOMBA_ALERT); + } if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { o->oHomeX = o->oPosX; o->oHomeY = o->oPosY; @@ -44,11 +51,12 @@ void bhv_scuttlebug_loop(void) { o->oSubAction++; } break; + case 1: o->oForwardVel = 5.0f; - if (cur_obj_lateral_dist_from_mario_to_home() > 1000.0f) + if (cur_obj_lateral_dist_from_mario_to_home() > 1000.0f) { o->oAngleToMario = cur_obj_angle_to_home(); - else { + } else { if (o->oScuttlebugUnkF8 == 0) { o->oScuttlebugUnkFC = 0; o->oAngleToMario = obj_angle_to_object(o, gMarioObject); @@ -60,66 +68,84 @@ void bhv_scuttlebug_loop(void) { } else if (o->oScuttlebugUnkF8 == 1) { o->oForwardVel = 15.0f; o->oScuttlebugUnkFC++; - if (o->oScuttlebugUnkFC > 50) + if (o->oScuttlebugUnkFC > 50) { o->oScuttlebugUnkF8 = 0; + } } } - if (update_angle_from_move_flags(&o->oAngleToMario)) + if (update_angle_from_move_flags(&o->oAngleToMario)) { o->oSubAction = 2; + } cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200); break; + case 2: o->oForwardVel = 5.0f; - if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario) + if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario) { o->oSubAction = 1; - if (o->oPosY - o->oHomeY < -200.0f) + } + if (o->oPosY - o->oHomeY < -200.0f) { obj_mark_for_deletion(o); + } cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400); break; + case 3: - o->oFlags &= ~8; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oForwardVel = -10.0f; o->oVelY = 30.0f; cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT); o->oSubAction++; break; + case 4: o->oForwardVel = -10.0f; if (o->oMoveFlags & OBJ_MOVE_LANDED) { o->oSubAction++; o->oVelY = 0.0f; o->oScuttlebugUnkFC = 0; - o->oFlags |= 8; + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oInteractStatus = 0; } break; + case 5: o->oForwardVel = 2.0f; o->oScuttlebugUnkFC++; - if (o->oScuttlebugUnkFC > 30) + if (o->oScuttlebugUnkFC > 30) { o->oSubAction = 0; + } break; } - if (o->oForwardVel < 10.0f) + + if (o->oForwardVel < 10.0f) { sp18 = 1.0f; - else + } else { sp18 = 3.0f; - cur_obj_init_animation_with_accel_and_sound(0, sp18); - if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) - set_obj_anim_with_accel_and_sound(1, 23, SOUND_OBJ2_SCUTTLEBUG_WALK); - if (o->parentObj != o) { - if (obj_is_hidden(o)) - obj_mark_for_deletion(o); - if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) - o->parentObj->oScuttlebugSpawnerUnk88 = 1; } + + cur_obj_init_animation_with_accel_and_sound(0, sp18); + + if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { + set_obj_anim_with_accel_and_sound(1, 23, SOUND_OBJ2_SCUTTLEBUG_WALK); + } + + if (o->parentObj != o) { + if (obj_is_hidden(o)) { + obj_mark_for_deletion(o); + } + if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) { + o->parentObj->oScuttlebugSpawnerUnk88 = 1; + } + } + cur_obj_move_standard(-50); } void bhv_scuttlebug_spawn_loop(void) { - struct Object *scuttlebug; if (o->oAction == 0) { if (o->oTimer > 30 && 500.0f < o->oDistanceToMario && o->oDistanceToMario < 1500.0f) { + struct Object *scuttlebug; cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT); scuttlebug = spawn_object(o, MODEL_SCUTTLEBUG, bhvScuttlebug); scuttlebug->oScuttlebugUnkF4 = o->oScuttlebugSpawnerUnkF4; diff --git a/src/game/behaviors/seaweed.inc.c b/src/game/behaviors/seaweed.inc.c index 4a9528d2..4399d029 100644 --- a/src/game/behaviors/seaweed.inc.c +++ b/src/game/behaviors/seaweed.inc.c @@ -1,4 +1,4 @@ -// seaweed.c.inc +// seaweed.inc.c void bhv_seaweed_init(void) { o->header.gfx.animInfo.animFrame = random_float() * 80.0f; diff --git a/src/game/behaviors/seesaw_platform.inc.c b/src/game/behaviors/seesaw_platform.inc.c index 81a47e76..5b2e4bc1 100644 --- a/src/game/behaviors/seesaw_platform.inc.c +++ b/src/game/behaviors/seesaw_platform.inc.c @@ -6,10 +6,15 @@ /** * Collision models for the different seesaw platforms. */ -static void const *sSeesawPlatformCollisionModels[] = { - bitdw_seg7_collision_0700F70C, bits_seg7_collision_0701ADD8, bits_seg7_collision_0701AE5C, - bob_seg7_collision_bridge, bitfs_seg7_collision_07015928, rr_seg7_collision_07029750, - rr_seg7_collision_07029858, vcutm_seg7_collision_0700AC44, +static Collision const *sSeesawPlatformCollisionModels[] = { + bitdw_seg7_collision_0700F70C, + bits_seg7_collision_0701ADD8, + bits_seg7_collision_0701AE5C, + bob_seg7_collision_bridge, + bitfs_seg7_collision_07015928, + rr_seg7_collision_07029750, + rr_seg7_collision_07029858, + vcutm_seg7_collision_0700AC44, }; /** @@ -39,7 +44,7 @@ void bhv_seesaw_platform_update(void) { if (gMarioObject->platform == o) { // Rotate toward mario f32 rotation = o->oDistanceToMario * coss(o->oAngleToMario - o->oMoveAngleYaw); - UNUSED s32 unused; + UNUSED u8 filler[4]; // Deceleration is faster than acceleration if (o->oSeesawPlatformPitchVel * rotation < 0) { diff --git a/src/game/behaviors/shock_wave.inc.c b/src/game/behaviors/shock_wave.inc.c index 9665f997..a580baa2 100644 --- a/src/game/behaviors/shock_wave.inc.c +++ b/src/game/behaviors/shock_wave.inc.c @@ -1,4 +1,4 @@ -// shock_wave.c.inc +// shock_wave.inc.c /** * Shockwave scale distance hit points @@ -11,20 +11,25 @@ f32 sBowserShockwaveHitPoints[] = { 1.9f, 2.4f, 4.0f, 4.8f }; void bhv_bowser_shock_wave_loop(void) { f32 distMin1, distMax1, distMin2, distMax2; s16 fadeFrames = 70; + // Scale shockwave as the timer goes on o->oBowserShockWaveScale = o->oTimer * 10; cur_obj_scale(o->oBowserShockWaveScale); + // Slightly reduce opacity each 3 frames - if (gGlobalTimer % 3) - o->oOpacity -= 1; + if (gGlobalTimer % 3 != 0) { + o->oOpacity--; + } // Reduce opacity faster after 70 frames have passed - if (o->oTimer > fadeFrames) + if (o->oTimer > fadeFrames) { o->oOpacity -= 5; + } // Delete object when it's fully transparent - if (o->oOpacity <= 0) + if (o->oOpacity <= 0) { obj_mark_for_deletion(o); + } // If object times is less than 70 frame and Mario is not in the air... - if (o->oTimer < fadeFrames && mario_is_in_air_action() == 0) { + if (o->oTimer < fadeFrames && !mario_is_in_air_action()) { // ..define distance values depending of the scale multiplied by hit points distMin1 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[0]; distMax1 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[1]; @@ -32,7 +37,8 @@ void bhv_bowser_shock_wave_loop(void) { distMax2 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[3]; // If Mario is in between distMin and distMax values, shock him if ((distMin1 < o->oDistanceToMario && o->oDistanceToMario < distMax1) - || (distMin2 < o->oDistanceToMario && o->oDistanceToMario < distMax2)) + || (distMin2 < o->oDistanceToMario && o->oDistanceToMario < distMax2)) { gMarioObject->oInteractStatus |= INT_STATUS_MARIO_SHOCKWAVE; + } } } diff --git a/src/game/behaviors/skeeter.inc.c b/src/game/behaviors/skeeter.inc.c index a726760f..522d38d1 100644 --- a/src/game/behaviors/skeeter.inc.c +++ b/src/game/behaviors/skeeter.inc.c @@ -1,3 +1,5 @@ +// skeeter.inc.c + struct Struct80331C38 { s16 unk00; s16 unk02; @@ -45,10 +47,10 @@ static void skeeter_act_idle(void) { if (o->oMoveFlags & OBJ_MOVE_AT_WATER_SURFACE) { skeeter_spawn_waves(); if (o->oTimer > 60 - && obj_smooth_turn(&o->oSkeeterUnk1AC, &o->oMoveAngleYaw, o->oSkeeterTargetAngle, 0.02f, - 5, 50, 200)) { + && obj_smooth_turn(&o->oSkeeterUnk1AC, &o->oMoveAngleYaw, o->oSkeeterTargetAngle, + 0.02f, 5, 50, 200)) { if (o->oSkeeterWaitTime != 0) { - o->oSkeeterWaitTime -= 1; + o->oSkeeterWaitTime--; } else if (cur_obj_check_if_near_animation_end()) { cur_obj_play_sound_2(SOUND_OBJ_WALKING_WATER); o->oAction = SKEETER_ACT_LUNGE; @@ -70,7 +72,7 @@ static void skeeter_act_lunge(void) { if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) { o->oMoveAngleYaw = cur_obj_reflect_move_angle_off_wall(); o->oForwardVel *= 0.3f; - o->oFlags &= ~0x00000008; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; } if (obj_forward_vel_approach(0.0f, 0.8f) && cur_obj_check_if_at_animation_end()) { @@ -84,7 +86,7 @@ static void skeeter_act_lunge(void) { o->oAction = SKEETER_ACT_IDLE; o->oSkeeterWaitTime = random_linear_offset(0, 30); - o->oFlags |= 0x00000008; + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; } } } @@ -101,23 +103,23 @@ static void skeeter_act_walk(void) { cur_obj_init_animation_with_accel_and_sound(2, sp24); cur_obj_play_sound_at_anim_range(3, 13, SOUND_OBJ_SKEETER_WALK); - if (o->oSkeeterUnkF8 != 0) { - o->oSkeeterUnkF8 = obj_resolve_collisions_and_turn(o->oSkeeterTargetAngle, 0x400); + if (o->oSkeeterTurningAwayFromWall) { + o->oSkeeterTurningAwayFromWall = obj_resolve_collisions_and_turn(o->oSkeeterTargetAngle, 0x400); } else { if (o->oDistanceToMario >= 25000.0f) { o->oSkeeterTargetAngle = o->oAngleToMario; o->oSkeeterWaitTime = random_linear_offset(20, 30); } - if ((o->oSkeeterUnkF8 = obj_bounce_off_walls_edges_objects(&o->oSkeeterTargetAngle)) == 0) { + if (!(o->oSkeeterTurningAwayFromWall = obj_bounce_off_walls_edges_objects(&o->oSkeeterTargetAngle))) { if (o->oDistanceToMario < 500.0f) { o->oSkeeterTargetAngle = o->oAngleToMario; o->oSkeeterUnkFC = 20.0f; } else { o->oSkeeterUnkFC = 10.0f; if (o->oSkeeterWaitTime != 0) { - o->oSkeeterWaitTime -= 1; - } else if (cur_obj_check_if_near_animation_end() != 0) { + o->oSkeeterWaitTime--; + } else if (cur_obj_check_if_near_animation_end()) { if (random_u16() & 0x0003) { o->oSkeeterTargetAngle = obj_random_fixed_turn(0x2000); o->oSkeeterWaitTime = random_linear_offset(100, 100); diff --git a/src/game/behaviors/sl_snowman_wind.inc.c b/src/game/behaviors/sl_snowman_wind.inc.c index 508615ab..2bdc5ca2 100644 --- a/src/game/behaviors/sl_snowman_wind.inc.c +++ b/src/game/behaviors/sl_snowman_wind.inc.c @@ -1,42 +1,47 @@ -// sl_snowman_wind.c.inc +// sl_snowman_wind.inc.c void bhv_sl_snowman_wind_loop(void) { - UNUSED s32 unusedVar = 0; + UNUSED s32 unused = 0; s16 marioAngleFromWindSource; Vec3f tempPos; - - if (o->oTimer == 0) + + if (o->oTimer == 0) { o->oSLSnowmanWindOriginalYaw = o->oMoveAngleYaw; - + } + // Waiting for Mario to approach. if (o->oSubAction == SL_SNOWMAN_WIND_ACT_IDLE) { o->oDistanceToMario = 0; - + // Check if Mario is within 1000 units of the center of the bridge, and ready to speak. vec3f_copy_2(tempPos, &o->oPosX); obj_set_pos(o, 1100, 3328, 1164); // Position is in the middle of the ice bridge - if (cur_obj_can_mario_activate_textbox(1000.0f, 30.0f, 0x7FFF)) + if (cur_obj_can_mario_activate_textbox(1000.0f, 30.0f, 0x7FFF)) { o->oSubAction++; + } vec3f_copy_2(&o->oPosX, tempPos); - + // Mario has come close, begin dialog. } else if (o->oSubAction == SL_SNOWMAN_WIND_ACT_TALKING) { - if (cur_obj_update_dialog(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TEXT_DEFAULT, DIALOG_153, 0)) + if (cur_obj_update_dialog(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TEXT_DEFAULT, DIALOG_153, 0)) { o->oSubAction++; - + } + // Blowing, spawn wind particles (SL_SNOWMAN_WIND_ACT_BLOWING) } else if (o->oDistanceToMario < 1500.0f && absf(gMarioObject->oPosY - o->oHomeY) < 500.0f) { // Point towards Mario, but only within 0x1500 angle units of the original angle. if ((marioAngleFromWindSource = o->oAngleToMario - o->oSLSnowmanWindOriginalYaw) > 0) { - if (marioAngleFromWindSource < 0x1500) + if (marioAngleFromWindSource < 0x1500) { o->oMoveAngleYaw = o->oAngleToMario; - else + } else { o->oMoveAngleYaw = o->oSLSnowmanWindOriginalYaw + 0x1500; + } } else { - if (marioAngleFromWindSource > -0x1500) + if (marioAngleFromWindSource > -0x1500) { o->oMoveAngleYaw = o->oAngleToMario; - else + } else { o->oMoveAngleYaw = o->oSLSnowmanWindOriginalYaw - 0x1500; + } } // Spawn wind and play wind sound cur_obj_spawn_strong_wind_particles(12, 3.0f, 0, 0, 0); diff --git a/src/game/behaviors/sl_walking_penguin.inc.c b/src/game/behaviors/sl_walking_penguin.inc.c index f5b60a8a..11273ebc 100644 --- a/src/game/behaviors/sl_walking_penguin.inc.c +++ b/src/game/behaviors/sl_walking_penguin.inc.c @@ -1,4 +1,4 @@ -// sl_walking_penguin.c.inc +// sl_walking_penguin.inc.c struct SLWalkingPenguinStep { s32 stepLength; @@ -15,31 +15,32 @@ struct SLWalkingPenguinStep sSLWalkingPenguinErraticSteps[] = { { 30, PENGUIN_ANIM_IDLE, 0.0f, 1.0f }, // Stop for 1 second { 30, PENGUIN_ANIM_WALK, -6.0f, 1.0f }, // Walk backwards for 1 second { 30, PENGUIN_ANIM_IDLE, 0.0f, 1.0f }, // Stop for 1 second - { -1, 0, 0.0f, 0.0f } }; // Repeat - + { -1, 0, 0.0f, 0.0f }, // Repeat +}; static s32 sl_walking_penguin_turn(void) { // Stay still and use walking animation for the turn. o->oForwardVel = 0.0f; cur_obj_init_animation_with_accel_and_sound(PENGUIN_ANIM_WALK, 1.0f); - + // Turn around. o->oAngleVelYaw = 0x400; o->oMoveAngleYaw += o->oAngleVelYaw; - - if (o->oTimer == 31) + + if (o->oTimer == 31) { return TRUE; // Finished turning - else + } else { return FALSE; + } } void bhv_sl_walking_penguin_loop(void) { f32 adjustedXPos, adjustedZPos; f32 perpendicularOffset = 100.0f; - + o->oAngleVelYaw = 0; cur_obj_update_floor_and_walls(); - + switch (o->oAction) { // Walk erratically across the ice bridge using preset steps. case SL_WALKING_PENGUIN_ACT_MOVING_FORWARDS: @@ -48,68 +49,74 @@ void bhv_sl_walking_penguin_loop(void) { o->oSLWalkingPenguinCurStep = 0; o->oSLWalkingPenguinCurStepTimer = 0; } - - if (o->oSLWalkingPenguinCurStepTimer < sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].stepLength) + + if (o->oSLWalkingPenguinCurStepTimer < + sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].stepLength) { o->oSLWalkingPenguinCurStepTimer++; - else { + } else { // Move to next step o->oSLWalkingPenguinCurStepTimer = 0; o->oSLWalkingPenguinCurStep++; - if (sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].stepLength < 0) + if (sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].stepLength < 0) { // Reached the end of the list, go back to the start o->oSLWalkingPenguinCurStep = 0; + } } - - if (o->oPosX < 300.0f) + + if (o->oPosX < 300.0f) { o->oAction++; // If reached the end of the bridge, turn around and head back. - else { + } else { // Move and animate the penguin o->oForwardVel = sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].speed; - + cur_obj_init_animation_with_accel_and_sound( sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].anim, sSLWalkingPenguinErraticSteps[o->oSLWalkingPenguinCurStep].animSpeed ); } break; - + // At the end, turn around and prepare to head back across the bridge. case SL_WALKING_PENGUIN_ACT_TURNING_BACK: - if (sl_walking_penguin_turn()) + if (sl_walking_penguin_turn()) { o->oAction++; // Finished turning + } break; - + // Walk back across the bridge at a constant speed. case SL_WALKING_PENGUIN_ACT_RETURNING: // Move and animate the penguin o->oForwardVel = 12.0f; cur_obj_init_animation_with_accel_and_sound(PENGUIN_ANIM_WALK, 2.0f); - - if (o->oPosX > 1700.0f) + + if (o->oPosX > 1700.0f) { o->oAction++; // If reached the start of the bridge, turn around. + } break; - + // At the start, turn around and prepare to walk erratically across the bridge. case SL_WALKING_PENGUIN_ACT_TURNING_FORWARDS: - if (sl_walking_penguin_turn()) + if (sl_walking_penguin_turn()) { o->oAction = SL_WALKING_PENGUIN_ACT_MOVING_FORWARDS; // Finished turning + } break; } - + cur_obj_move_standard(-78); - if (!cur_obj_hide_if_mario_far_away_y(1000.0f)) + if (!cur_obj_hide_if_mario_far_away_y(1000.0f)) { play_penguin_walking_sound(PENGUIN_WALK_BIG); - + } + // Adjust the position to get a point better lined up with the visual model, for stopping the wind. // The new point is 60 units behind the penguin and 100 units perpedicularly, away from the snowman. - + adjustedXPos = o->oPosX + sins(0xDBB0) * 60.0f; // 0xDBB0 = -51 degrees, the angle the penguin is facing adjustedZPos = o->oPosZ + coss(0xDBB0) * 60.0f; adjustedXPos += perpendicularOffset * sins(0x1BB0); // 0x1BB0 = 39 degrees, perpendicular to the penguin adjustedZPos += perpendicularOffset * coss(0x1BB0); o->oSLWalkingPenguinWindCollisionXPos = adjustedXPos; o->oSLWalkingPenguinWindCollisionZPos = adjustedZPos; - + print_debug_bottom_up("x %d", o->oPosX); print_debug_bottom_up("z %d", o->oPosZ); } diff --git a/src/game/behaviors/sliding_platform.inc.c b/src/game/behaviors/sliding_platform.inc.c index 0e2087e1..1b8f73ce 100644 --- a/src/game/behaviors/sliding_platform.inc.c +++ b/src/game/behaviors/sliding_platform.inc.c @@ -1,4 +1,4 @@ -// sliding_platform.c.inc +// sliding_platform.inc.c void bhv_wf_sliding_platform_init(void) { o->oFaceAngleYaw -= 0x4000; @@ -25,7 +25,7 @@ void bhv_wf_sliding_platform_init(void) { void bhv_wf_sliding_platform_loop(void) { switch (o->oAction) { case WF_SLID_BRICK_PTFM_ACT_WAIT: - if (o->oTimer >= 101) { + if (o->oTimer > 100) { o->oAction = WF_SLID_BRICK_PTFM_ACT_EXTEND; o->oForwardVel = o->oWFSlidBrickPtfmMovVel; } @@ -33,7 +33,7 @@ void bhv_wf_sliding_platform_loop(void) { case WF_SLID_BRICK_PTFM_ACT_EXTEND: if (o->oTimer >= 500.0f / o->oWFSlidBrickPtfmMovVel) { - o->oForwardVel = 0; + o->oForwardVel = 0.0f; o->oPosX = o->oHomeX + 510.0f; } @@ -46,7 +46,7 @@ void bhv_wf_sliding_platform_loop(void) { case WF_SLID_BRICK_PTFM_ACT_RETRACT: if (o->oTimer >= 500.0f / o->oWFSlidBrickPtfmMovVel) { - o->oForwardVel = 0; + o->oForwardVel = 0.0f; o->oPosX = o->oHomeX; } diff --git a/src/game/behaviors/sliding_platform_2.inc.c b/src/game/behaviors/sliding_platform_2.inc.c index 55946e7d..853bc409 100644 --- a/src/game/behaviors/sliding_platform_2.inc.c +++ b/src/game/behaviors/sliding_platform_2.inc.c @@ -1,6 +1,6 @@ // sliding_platform_2.inc.c -static void const *sSlidingPlatform2CollisionData[] = { +static Collision const *sSlidingPlatform2CollisionData[] = { bits_seg7_collision_0701A9A0, bits_seg7_collision_0701AA0C, bitfs_seg7_collision_07015714, @@ -12,9 +12,8 @@ static void const *sSlidingPlatform2CollisionData[] = { }; void bhv_sliding_plat_2_init(void) { - s32 collisionDataIndex; + s32 collisionDataIndex = ((u16)(o->oBehParams >> 16) & 0x0380) >> 7; - collisionDataIndex = ((u16)(o->oBehParams >> 16) & 0x0380) >> 7; o->collisionData = segmented_to_virtual(sSlidingPlatform2CollisionData[collisionDataIndex]); o->oBackAndForthPlatformPathLength = 50.0f * ((u16)(o->oBehParams >> 16) & 0x003F); diff --git a/src/game/behaviors/snow_mound.inc.c b/src/game/behaviors/snow_mound.inc.c index f8fcc539..3710f86e 100644 --- a/src/game/behaviors/snow_mound.inc.c +++ b/src/game/behaviors/snow_mound.inc.c @@ -1,13 +1,13 @@ -// snow_mound.c.inc +// snow_mound.inc.c void bhv_sliding_snow_mound_loop(void) { switch (o->oAction) { case 0: o->oVelX = -40.0f; o->oPosX += o->oVelX; - if (o->oTimer >= 118) + if (o->oTimer > 117) { o->oAction = 1; - + } cur_obj_play_sound_1(SOUND_ENV_SINK_QUICKSAND); break; @@ -17,8 +17,9 @@ void bhv_sliding_snow_mound_loop(void) { o->oVelY = -10.0f; o->oPosY += o->oVelY; o->oPosZ = o->oHomeZ - 2.0f; - if (o->oTimer > 50) + if (o->oTimer > 50) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } break; } } @@ -27,17 +28,20 @@ void bhv_snow_mound_spawn_loop(void) { struct Object *sp1C; if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 6000) - || o->oPosY + 1000.0f < gMarioObject->header.gfx.pos[1]) + || o->oPosY + 1000.0f < gMarioObject->header.gfx.pos[1]) { return; + } - if (o->oTimer == 64 || o->oTimer == 128 || o->oTimer == 192 || o->oTimer == 224 || o->oTimer == 256) + if (o->oTimer == 64 || o->oTimer == 128 || o->oTimer == 192 || o->oTimer == 224 || o->oTimer == 256) { sp1C = spawn_object(o, MODEL_SL_SNOW_TRIANGLE, bhvSlidingSnowMound); + } if (o->oTimer == 256) { sp1C->header.gfx.scale[0] = 2.0f; sp1C->header.gfx.scale[1] = 2.0f; } - if (o->oTimer >= 256) + if (o->oTimer >= 256) { o->oTimer = 0; + } } diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c index 2d532efe..93ed9dfd 100644 --- a/src/game/behaviors/snowman.inc.c +++ b/src/game/behaviors/snowman.inc.c @@ -1,4 +1,4 @@ -// snowman.c.inc +// snowman.inc.c static struct ObjectHitbox sRollingSphereHitbox = { /* interactType: */ INTERACT_DAMAGE, @@ -13,7 +13,7 @@ static struct ObjectHitbox sRollingSphereHitbox = { }; void bhv_snowmans_bottom_init(void) { - struct Object *sp34; + struct Object *snowmansHead; o->oHomeX = o->oPosX; o->oHomeY = o->oPosY; @@ -25,11 +25,11 @@ void bhv_snowmans_bottom_init(void) { o->oVelY = 0; o->oForwardVel = 0; - o->oSnowmansBottomUnkF4 = 0.4f; + o->oSnowmansBottomScale = 0.4f; - sp34 = cur_obj_nearest_object_with_behavior(bhvSnowmansHead); - if (sp34 != NULL) { - o->parentObj = sp34; + snowmansHead = cur_obj_nearest_object_with_behavior(bhvSnowmansHead); + if (snowmansHead != NULL) { + o->parentObj = snowmansHead; } spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvSnowmansBodyCheckpoint, -402, 461, -2898, 0, 0, 0); } @@ -37,38 +37,39 @@ void bhv_snowmans_bottom_init(void) { void set_rolling_sphere_hitbox(void) { obj_set_hitbox(o, &sRollingSphereHitbox); - if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) { + if (o->oInteractStatus & INT_STATUS_INTERACTED) { o->oInteractStatus = 0; } } void adjust_rolling_face_pitch(f32 f12) { o->oFaceAnglePitch += (s16)(o->oForwardVel * (100.0f / f12)); - o->oSnowmansBottomUnkF4 += o->oForwardVel * 1e-4; + o->oSnowmansBottomScale += o->oForwardVel * 0.0001; - if (o->oSnowmansBottomUnkF4 > 1.0) - o->oSnowmansBottomUnkF4 = 1.0f; + if (o->oSnowmansBottomScale > 1.0) { + o->oSnowmansBottomScale = 1.0f; + } } void snowmans_bottom_act_1(void) { - UNUSED s16 sp26; - s32 sp20; - UNUSED s16 sp1E; + UNUSED s16 collisionFlags; + s32 followStatus; #ifdef AVOID_UB - sp20 = 0; + followStatus = 0; #endif o->oPathedStartWaypoint = segmented_to_virtual(&ccm_seg7_trajectory_snowman); - sp26 = object_step_without_floor_orient(); - sp20 = cur_obj_follow_path(sp20); + collisionFlags = object_step_without_floor_orient(); + followStatus = cur_obj_follow_path(followStatus); o->oSnowmansBottomUnkF8 = o->oPathedTargetYaw; o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oSnowmansBottomUnkF8, 0x400); - if (o->oForwardVel > 70.0) + if (o->oForwardVel > 70.0) { o->oForwardVel = 70.0f; + } - if (sp20 == -1) { - sp1E = (u16) o->oAngleToMario - (u16) o->oMoveAngleYaw; + if (followStatus == PATH_REACHED_END) { + UNUSED s16 sp1E = (u16) o->oAngleToMario - (u16) o->oMoveAngleYaw; if (obj_check_if_facing_toward_angle(o->oMoveAngleYaw, o->oAngleToMario, 0x2000) == TRUE && o->oSnowmansBottomUnk1AC == 1) { o->oSnowmansBottomUnkF8 = o->oAngleToMario; @@ -80,11 +81,11 @@ void snowmans_bottom_act_1(void) { } void snowmans_bottom_act_2(void) { - UNUSED s16 sp26; + UNUSED s16 collisionFlags = object_step_without_floor_orient(); - sp26 = object_step_without_floor_orient(); - if (o->oForwardVel > 70.0) + if (o->oForwardVel > 70.0) { o->oForwardVel = 70.0f; + } o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oSnowmansBottomUnkF8, 0x400); if (is_point_close_to_object(o, -4230.0f, -1344.0f, 1813.0f, 300)) { @@ -106,15 +107,14 @@ void snowmans_bottom_act_2(void) { } void snowmans_bottom_act_3(void) { - UNUSED s16 sp1E; + s16 collisionFlags = object_step_without_floor_orient(); - sp1E = object_step_without_floor_orient(); - if ((sp1E & 0x09) == 0x09) { + if ((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAGS_LANDED) { o->oAction = 4; cur_obj_become_intangible(); } - if ((sp1E & 0x01) != 0) { + if (collisionFlags & OBJ_COL_FLAG_GROUNDED) { spawn_mist_particles_variable(0, 0, 70.0f); o->oPosX = -4230.0f; o->oPosZ = 1813.0f; @@ -123,14 +123,12 @@ void snowmans_bottom_act_3(void) { } void bhv_snowmans_bottom_loop(void) { - s16 sp1E; - switch (o->oAction) { case 0: if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 400) == 1 && set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) { - sp1E = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_110); - if (sp1E) { + s16 response = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_110); + if (response != DIALOG_RESPONSE_NONE) { o->oForwardVel = 10.0f; o->oAction = 1; set_mario_npc_dialog(MARIO_DIALOG_STOP); @@ -140,13 +138,13 @@ void bhv_snowmans_bottom_loop(void) { case 1: snowmans_bottom_act_1(); - adjust_rolling_face_pitch(o->oSnowmansBottomUnkF4); + adjust_rolling_face_pitch(o->oSnowmansBottomScale); cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2); break; case 2: snowmans_bottom_act_2(); - adjust_rolling_face_pitch(o->oSnowmansBottomUnkF4); + adjust_rolling_face_pitch(o->oSnowmansBottomScale); cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2); break; @@ -161,16 +159,13 @@ void bhv_snowmans_bottom_loop(void) { set_rolling_sphere_hitbox(); set_object_visibility(o, 8000); - cur_obj_scale(o->oSnowmansBottomUnkF4); - o->oGraphYOffset = o->oSnowmansBottomUnkF4 * 180.0f; + cur_obj_scale(o->oSnowmansBottomScale); + o->oGraphYOffset = o->oSnowmansBottomScale * 180.0f; } void bhv_snowmans_head_init(void) { - u8 sp37; - s8 sp36; - - sp37 = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); - sp36 = (o->oBehParams >> 24) & 0xFF; + u8 starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); + s8 sp36 = (o->oBehParams >> 24) & 0xFF; cur_obj_scale(0.7f); @@ -178,7 +173,7 @@ void bhv_snowmans_head_init(void) { o->oFriction = 0.999f; o->oBuoyancy = 2.0f; - if ((sp37 & (1 << sp36)) && gCurrActNum != sp36 + 1) { + if ((starFlags & (1 << sp36)) && gCurrActNum != sp36 + 1) { spawn_object_abs_with_rot(o, 0, MODEL_CCM_SNOWMAN_BASE, bhvBigSnowmanWhole, -4230, -1344, 1813, 0, 0, 0); o->oPosX = -4230.0f; @@ -189,22 +184,24 @@ void bhv_snowmans_head_init(void) { } void bhv_snowmans_head_loop(void) { - UNUSED s16 sp1E; - s16 sp1C; + UNUSED s16 unused; + s16 collisionFlags; switch (o->oAction) { case 0: - if (trigger_obj_dialog_when_facing(&o->oSnowmansHeadDialogActive, DIALOG_109, 400.0f, MARIO_DIALOG_LOOK_FRONT)) + if (trigger_obj_dialog_when_facing(&o->oSnowmansHeadDialogActive, DIALOG_109, 400.0f, MARIO_DIALOG_LOOK_FRONT)) { o->oAction = 1; + } break; case 1: break; case 2: - sp1C = object_step_without_floor_orient(); - if (sp1C & 0x08) + collisionFlags = object_step_without_floor_orient(); + if (collisionFlags & OBJ_COL_FLAG_NO_Y_VEL) { o->oAction = 3; + } break; case 3: @@ -235,6 +232,7 @@ void bhv_snowmans_body_checkpoint_loop(void) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c index f3a0c9ef..d3a9fc59 100644 --- a/src/game/behaviors/snufit.inc.c +++ b/src/game/behaviors/snufit.inc.c @@ -1,3 +1,4 @@ + /** * Behavior file for bhvSnufit and bhvSnufitBalls. * Snufits are present in HMC and CotMC, and are the fly guy @@ -34,12 +35,10 @@ struct ObjectHitbox sSnufitBulletHitbox = { * since the parts move independently. */ Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) { - struct Object *obj; - struct GraphNodeTranslationRotation *transNode; - if (callContext == GEO_CONTEXT_RENDER) { - obj = (struct Object *) gCurGraphNodeObject; - transNode = (struct GraphNodeTranslationRotation *) node->next; + struct Object *obj = (struct Object *) gCurGraphNodeObject; + struct GraphNodeTranslationRotation *transNode + = (struct GraphNodeTranslationRotation *) node->next; transNode->translation[0] = obj->oSnufitXOffset; transNode->translation[1] = obj->oSnufitYOffset; @@ -53,12 +52,9 @@ Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 * * This function scales the body of snufit, which needs done seperately from its mask. */ Gfx *geo_snufit_scale_body(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) { - struct Object *obj; - struct GraphNodeScale *scaleNode; - if (callContext == GEO_CONTEXT_RENDER) { - obj = (struct Object *) gCurGraphNodeObject; - scaleNode = (struct GraphNodeScale *) node->next; + struct Object *obj = (struct Object *) gCurGraphNodeObject; + struct GraphNodeScale *scaleNode = (struct GraphNodeScale *) node->next; scaleNode->scale = obj->oSnufitBodyScale / 1000.0f; } @@ -71,13 +67,12 @@ Gfx *geo_snufit_scale_body(s32 callContext, struct GraphNode *node, UNUSED Mat4 * then prepares to shoot after a period. */ void snufit_act_idle(void) { - s32 marioDist; - // This line would could cause a crash in certain PU situations, // if the game would not have already crashed. - marioDist = (s32)(o->oDistanceToMario / 10.0f); + s32 marioDist = (s32)(o->oDistanceToMario / 10.0f); + if (o->oTimer > marioDist && o->oDistanceToMario < 800.0f) { - + // Controls an alternating scaling factor in a cos. o->oSnufitBodyScalePeriod = approach_s16_symmetric(o->oSnufitBodyScalePeriod, 0, 1500); @@ -105,7 +100,7 @@ void snufit_act_shoot(void) { if ((u16) o->oSnufitBodyScalePeriod == 0x8000 && o->oSnufitBodyBaseScale == 167) { o->oAction = SNUFIT_ACT_IDLE; } else if (o->oSnufitBullets < 3 && o->oTimer >= 3) { - o->oSnufitBullets += 1; + o->oSnufitBullets++; cur_obj_play_sound_2(SOUND_OBJ_SNUFIT_SHOOT); spawn_object_relative(0, 0, -20, 40, o, MODEL_BOWLING_BALL, bhvSnufitBalls); o->oSnufitRecoil = -30; @@ -121,7 +116,7 @@ void bhv_snufit_loop(void) { // Only update if Mario is in the current room. if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { o->oDeathSound = SOUND_OBJ_SNUFIT_SKEETER_DEATH; - + // Face Mario if he is within range. if (o->oDistanceToMario < 800.0f) { obj_turn_pitch_toward_mario(120.0f, 2000); @@ -189,7 +184,7 @@ void bhv_snufit_balls_loop(void) { cur_obj_update_floor_and_walls(); obj_compute_vel_from_move_pitch(40.0f); - if (obj_check_attacks(&sSnufitBulletHitbox, 1)) { + if (obj_check_attacks(&sSnufitBulletHitbox, 1) != 0) { // We hit Mario while he is metal! // Bounce off, and fall until the first check is true. o->oMoveAngleYaw += 0x8000; @@ -199,7 +194,7 @@ void bhv_snufit_balls_loop(void) { cur_obj_become_intangible(); } else if (o->oAction == 1 - || (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_HIT_WALL))) { + || (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_HIT_WALL))) { // The Snufit shot Mario and has fulfilled its lonely existance. //! The above check could theoretically be avoided by finding a geometric //! situation that does not trigger those flags (Water?). If found, diff --git a/src/game/behaviors/sound_ambient.inc.c b/src/game/behaviors/sound_ambient.inc.c index bf5765da..73a1de7a 100644 --- a/src/game/behaviors/sound_ambient.inc.c +++ b/src/game/behaviors/sound_ambient.inc.c @@ -1,8 +1,9 @@ // sound_ambient.inc.c void bhv_ambient_sounds_init(void) { - if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO) + if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO) { return; + } play_sound(SOUND_AIR_CASTLE_OUTDOORS_AMBIENT, gGlobalSoundSource); } diff --git a/src/game/behaviors/sound_birds.inc.c b/src/game/behaviors/sound_birds.inc.c index db7ea534..214c0c40 100644 --- a/src/game/behaviors/sound_birds.inc.c +++ b/src/game/behaviors/sound_birds.inc.c @@ -1,8 +1,9 @@ // sound_birds.inc.c void bhv_birds_sound_loop(void) { - if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO) + if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO) { return; + } switch (o->oBehParams2ndByte) { case 0: diff --git a/src/game/behaviors/sound_sand.inc.c b/src/game/behaviors/sound_sand.inc.c index 95535b68..9a5c3bb3 100644 --- a/src/game/behaviors/sound_sand.inc.c +++ b/src/game/behaviors/sound_sand.inc.c @@ -1,8 +1,9 @@ // sound_sand.inc.c void bhv_sand_sound_loop(void) { - if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO) + if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO) { return; + } cur_obj_play_sound_1(SOUND_ENV_MOVINGSAND); } diff --git a/src/game/behaviors/sound_spawner.inc.c b/src/game/behaviors/sound_spawner.inc.c index 7f0b27ed..6f40d2be 100644 --- a/src/game/behaviors/sound_spawner.inc.c +++ b/src/game/behaviors/sound_spawner.inc.c @@ -1,4 +1,4 @@ -// sound_spawner.c.inc +// sound_spawner.inc.c void bhv_sound_spawner_init(void) { s32 sp1C = o->oSoundEffectUnkF4; diff --git a/src/game/behaviors/sparkle_spawn.inc.c b/src/game/behaviors/sparkle_spawn.inc.c index b5f2a418..90b1ac2e 100644 --- a/src/game/behaviors/sparkle_spawn.inc.c +++ b/src/game/behaviors/sparkle_spawn.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvSparkleSpawn. * @@ -5,6 +6,7 @@ * random local position and scale, each sparkle's behavior is thereafter * controlled by bhvSparkle. This spawner is deleted after 1 frame. */ + void bhv_sparkle_spawn_loop(void) { struct Object *sparkle = try_to_spawn_object(0, 1.0f, o, MODEL_SPARKLES_ANIMATION, bhvSparkle); if (sparkle != NULL) { diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c index b6608708..f9d7510b 100644 --- a/src/game/behaviors/sparkle_spawn_star.inc.c +++ b/src/game/behaviors/sparkle_spawn_star.inc.c @@ -1,24 +1,29 @@ -// sparkle_spawn_star.c.inc +// sparkle_spawn_star.inc.c struct ObjectHitbox sSparkleSpawnStarHitbox = { - /* interactType: */ INTERACT_STAR_OR_KEY, - /* downOffset: */ 0, + /* interactType: */ INTERACT_STAR_OR_KEY, + /* downOffset: */ 0, /* damageOrCoinValue: */ 0, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 80, - /* height: */ 50, - /* hurtboxRadius: */ 0, - /* hurtboxHeight: */ 0, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 80, + /* height: */ 50, + /* hurtboxRadius: */ 0, + /* hurtboxHeight: */ 0, }; void bhv_spawned_star_init(void) { s32 sp24; - if (!(o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT)) + + if (!(o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT)) { o->oBehParams = o->parentObj->oBehParams; + } sp24 = (o->oBehParams >> 24) & 0xFF; - if (bit_shift_left(sp24) & save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1)) + + if (bit_shift_left(sp24) & save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum))) { cur_obj_set_model(MODEL_TRANSPARENT_STAR); + } + cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS); } @@ -33,24 +38,28 @@ void set_sparkle_spawn_star_hitbox(void) { void set_home_to_mario(void) { f32 sp1C; f32 sp18; + o->oHomeX = gMarioObject->oPosX; o->oHomeZ = gMarioObject->oPosZ; o->oHomeY = gMarioObject->oPosY; o->oHomeY += 250.0f; o->oPosY = o->oHomeY; + sp1C = o->oHomeX - o->oPosX; sp18 = o->oHomeZ - o->oPosZ; + o->oForwardVel = sqrtf(sp1C * sp1C + sp18 * sp18) / 23.0f; } void set_y_home_to_pos(void) { - o->oForwardVel = 0; + o->oForwardVel = 0.0f; o->oHomeY = o->oPosY; } void slow_star_rotation(void) { - if (o->oAngleVelYaw > 0x400) + if (o->oAngleVelYaw > 0x400) { o->oAngleVelYaw -= 0x40; + } } void bhv_spawned_star_loop(void) { @@ -60,10 +69,11 @@ void bhv_spawned_star_loop(void) { set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; o->oAngleVelYaw = 0x800; - if (o->oBehParams2ndByte == 0) + if (o->oBehParams2ndByte == 0) { set_home_to_mario(); - else + } else { set_y_home_to_pos(); + } o->oMoveAngleYaw = cur_obj_angle_to_home(); o->oVelY = 50.0f; o->oGravity = -4.0f; @@ -76,18 +86,20 @@ void bhv_spawned_star_loop(void) { o->oForwardVel = 0; o->oVelY = 20.0f; o->oGravity = -1.0f; - if (o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) + if (o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) { #ifdef VERSION_JP play_power_star_jingle(FALSE); #else play_power_star_jingle(TRUE); #endif - else + } else { play_power_star_jingle(TRUE); + } } } else if (o->oAction == 1) { - if (o->oVelY < -4.0f) + if (o->oVelY < -4.0f) { o->oVelY = -4.0f; + } if (o->oVelY < 0 && o->oPosY < o->oHomeY) { gObjCutsceneDone = TRUE; o->oVelY = 0; @@ -105,6 +117,7 @@ void bhv_spawned_star_loop(void) { set_sparkle_spawn_star_hitbox(); slow_star_rotation(); } + cur_obj_move_using_fvel_and_gravity(); o->oFaceAngleYaw += o->oAngleVelYaw; o->oInteractStatus = 0; diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index b48c3e47..96f71a63 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -1,4 +1,4 @@ -// spawn_default_star.c.inc +// spawn_star.inc.c static struct ObjectHitbox sCollectStarHitbox = { /* interactType: */ INTERACT_STAR_OR_KEY, @@ -13,11 +13,9 @@ static struct ObjectHitbox sCollectStarHitbox = { }; void bhv_collect_star_init(void) { - s8 starId; - u8 currentLevelStarFlags; + s8 starId = (o->oBehParams >> 24) & 0xFF; + u8 currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); - starId = (o->oBehParams >> 24) & 0xFF; - currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); if (currentLevelStarFlags & (1 << starId)) { o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_TRANSPARENT_STAR]; } else { @@ -42,10 +40,12 @@ void bhv_star_spawn_init(void) { o->oVelY = (o->oHomeY - o->oPosY) / 30.0f; o->oForwardVel = o->oStarSpawnDisFromHome / 30.0f; o->oStarSpawnUnkFC = o->oPosY; - if (o->oBehParams2ndByte == 0 || gCurrCourseNum == COURSE_BBH) + + if (o->oBehParams2ndByte == 0 || gCurrCourseNum == COURSE_BBH) { cutscene_object(CUTSCENE_STAR_SPAWN, o); - else + } else { cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o); + } set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; @@ -56,8 +56,9 @@ void bhv_star_spawn_loop(void) { switch (o->oAction) { case 0: o->oFaceAngleYaw += 0x1000; - if (o->oTimer > 20) + if (o->oTimer > 20) { o->oAction = 1; + } break; case 1: @@ -75,10 +76,11 @@ void bhv_star_spawn_loop(void) { break; case 2: - if (o->oTimer < 20) + if (o->oTimer < 20) { o->oVelY = 20 - o->oTimer; - else + } else { o->oVelY = -10.0f; + } spawn_object(o, MODEL_NONE, bhvSparkleSpawn); obj_move_xyz_using_fvel_and_yaw(o); @@ -122,57 +124,47 @@ struct Object *spawn_star(struct Object *sp30, f32 sp34, f32 sp38, f32 sp3C) { } void spawn_default_star(f32 sp20, f32 sp24, f32 sp28) { - struct Object *sp1C; -#ifdef AVOID_UB - sp1C = 0; -#endif - sp1C = spawn_star(sp1C, sp20, sp24, sp28); + struct Object *sp1C = spawn_star(sp1C, sp20, sp24, sp28); sp1C->oBehParams2ndByte = 0; } void spawn_red_coin_cutscene_star(f32 sp20, f32 sp24, f32 sp28) { - struct Object *sp1C; -#ifdef AVOID_UB - sp1C = 0; -#endif - sp1C = spawn_star(sp1C, sp20, sp24, sp28); + struct Object *sp1C = spawn_star(sp1C, sp20, sp24, sp28); sp1C->oBehParams2ndByte = 1; } void spawn_no_exit_star(f32 sp20, f32 sp24, f32 sp28) { - struct Object *sp1C; -#ifdef AVOID_UB - sp1C = 0; -#endif - sp1C = spawn_star(sp1C, sp20, sp24, sp28); + struct Object *sp1C = spawn_star(sp1C, sp20, sp24, sp28); sp1C->oBehParams2ndByte = 1; sp1C->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT; } void bhv_hidden_red_coin_star_init(void) { - s16 sp36; - struct Object *sp30; + s16 count; - if (gCurrCourseNum != COURSE_JRB) + if (gCurrCourseNum != COURSE_JRB) { spawn_object(o, MODEL_TRANSPARENT_STAR, bhvRedCoinStarMarker); + } - sp36 = count_objects_with_behavior(bhvRedCoin); - if (sp36 == 0) { - sp30 = - spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); - sp30->oBehParams = o->oBehParams; + count = count_objects_with_behavior(bhvRedCoin); + if (count == 0) { + struct Object *star = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, + o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); + star->oBehParams = o->oBehParams; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - o->oHiddenStarTriggerCounter = 8 - sp36; + o->oHiddenStarTriggerCounter = 8 - count; } void bhv_hidden_red_coin_star_loop(void) { gRedCoinsCollected = o->oHiddenStarTriggerCounter; + switch (o->oAction) { case 0: - if (o->oHiddenStarTriggerCounter == 8) + if (o->oHiddenStarTriggerCounter == 8) { o->oAction = 1; + } break; case 1: diff --git a/src/game/behaviors/spawn_star_exit.inc.c b/src/game/behaviors/spawn_star_exit.inc.c index 8c5515a3..aab63b2a 100644 --- a/src/game/behaviors/spawn_star_exit.inc.c +++ b/src/game/behaviors/spawn_star_exit.inc.c @@ -1,4 +1,4 @@ -// spawn_star_exit.c.inc +// spawn_star_exit.inc.c void bhv_ccm_touched_star_spawn_loop(void) { if (gCCMEnteredSlide & 1) { diff --git a/src/game/behaviors/spindel.inc.c b/src/game/behaviors/spindel.inc.c index 6cbe3ced..b3c4ebf7 100644 --- a/src/game/behaviors/spindel.inc.c +++ b/src/game/behaviors/spindel.inc.c @@ -1,4 +1,4 @@ -// spindel.c.inc +// spindel.inc.c void bhv_spindel_init(void) { o->oHomeY = o->oPosY; @@ -23,12 +23,14 @@ void bhv_spindel_loop(void) { sp18 = 10 - o->oSpindelUnkF4; - if (sp18 < 0) + if (sp18 < 0) { sp18 *= -1; + } sp18 -= 6; - if (sp18 < 0) + if (sp18 < 0) { sp18 = 0; + } if (o->oTimer == sp18 + 8) { o->oTimer = 0; @@ -44,12 +46,13 @@ void bhv_spindel_loop(void) { } } - if (sp18 == 4 || sp18 == 3) + if (sp18 == 4 || sp18 == 3) { sp18 = 4; - else if (sp18 == 2 || sp18 == 1) + } else if (sp18 == 2 || sp18 == 1) { sp18 = 2; - else if (sp18 == 0) + } else if (sp18 == 0) { sp18 = 1; + } if (o->oTimer < sp18 * 8) { if (o->oSpindelUnkF8 == 0) { @@ -68,12 +71,14 @@ void bhv_spindel_loop(void) { } sp1C = sins(o->oMoveAnglePitch * 4) * 23.0; - if (sp1C < 0.0f) + if (sp1C < 0.0f) { sp1C *= -1.0f; + } o->oPosY = o->oHomeY + sp1C; - if (o->oTimer + 1 == sp18 * 8) + if (o->oTimer + 1 == sp18 * 8) { set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ); + } } } diff --git a/src/game/behaviors/spindrift.inc.c b/src/game/behaviors/spindrift.inc.c index bc04018e..8651ad1c 100644 --- a/src/game/behaviors/spindrift.inc.c +++ b/src/game/behaviors/spindrift.inc.c @@ -1,40 +1,46 @@ -// spindrift.c.inc +// spindrift.inc.c struct ObjectHitbox sSpindriftHitbox = { - /* interactType: */ INTERACT_BOUNCE_TOP, - /* downOffset: */ 0, + /* interactType: */ INTERACT_BOUNCE_TOP, + /* downOffset: */ 0, /* damageOrCoinValue: */ 2, - /* health: */ 1, - /* numLootCoins: */ 3, - /* radius: */ 90, - /* height: */ 80, - /* hurtboxRadius: */ 80, - /* hurtboxHeight: */ 70, + /* health: */ 1, + /* numLootCoins: */ 3, + /* radius: */ 90, + /* height: */ 80, + /* hurtboxRadius: */ 80, + /* hurtboxHeight: */ 70, }; void bhv_spindrift_loop(void) { o->activeFlags |= ACTIVE_FLAG_UNK10; - if (cur_obj_set_hitbox_and_die_if_attacked(&sSpindriftHitbox, SOUND_OBJ_DYING_ENEMY1, 0)) + + if (cur_obj_set_hitbox_and_die_if_attacked(&sSpindriftHitbox, SOUND_OBJ_DYING_ENEMY1, 0)) { cur_obj_change_action(1); + } cur_obj_update_floor_and_walls(); + switch (o->oAction) { case 0: approach_forward_vel(&o->oForwardVel, 4.0f, 1.0f); - if (cur_obj_lateral_dist_from_mario_to_home() > 1000.0f) + if (cur_obj_lateral_dist_from_mario_to_home() > 1000.0f) { o->oAngleToMario = cur_obj_angle_to_home(); - else if (o->oDistanceToMario > 300.0f) + } else if (o->oDistanceToMario > 300.0f) { o->oAngleToMario = obj_angle_to_object(o, gMarioObject); + } cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400); break; + case 1: - o->oFlags &= ~8; + o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; o->oForwardVel = -10.0f; if (o->oTimer > 20) { o->oAction = 0; o->oInteractStatus = 0; - o->oFlags |= 8; + o->oFlags |= OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW; } break; } + cur_obj_move_standard(-60); } diff --git a/src/game/behaviors/spiny.inc.c b/src/game/behaviors/spiny.inc.c index 3d894bfc..b62eda74 100644 --- a/src/game/behaviors/spiny.inc.c +++ b/src/game/behaviors/spiny.inc.c @@ -46,7 +46,7 @@ static s32 spiny_check_active(void) { // behave similar to a regular goomba. // It can also be used on a bob-omb respawner to change its model // to a butterfly or fish. - o->parentObj->oEnemyLakituNumSpinies -= 1; + o->parentObj->oEnemyLakituNumSpinies--; obj_mark_for_deletion(o); return FALSE; } @@ -85,7 +85,7 @@ static void spiny_act_walk(void) { obj_bounce_off_walls_edges_objects(&o->oSpinyTargetYaw))) { // Walk and occasionally randomly change direction if (o->oSpinyTimeUntilTurn != 0) { - o->oSpinyTimeUntilTurn -= 1; + o->oSpinyTimeUntilTurn--; } else { o->oSpinyTargetYaw = o->oMoveAngleYaw + (s16) random_sign() * 0x2000; o->oSpinyTimeUntilTurn = random_linear_offset(100, 100); @@ -169,10 +169,8 @@ static void spiny_act_thrown_by_lakitu(void) { cur_obj_move_standard(-78); - if (obj_check_attacks(&sSpinyHitbox, o->oAction)) { - if (o->parentObj != o) { - o->parentObj->oEnemyLakituNumSpinies -= 1; - } + if (obj_check_attacks(&sSpinyHitbox, o->oAction) != 0 && o->parentObj != o) { + o->parentObj->oEnemyLakituNumSpinies--; } } } diff --git a/src/game/behaviors/square_platform_cycle.inc.c b/src/game/behaviors/square_platform_cycle.inc.c index 24eacb02..a3525a82 100644 --- a/src/game/behaviors/square_platform_cycle.inc.c +++ b/src/game/behaviors/square_platform_cycle.inc.c @@ -1,38 +1,45 @@ -// square_platform_cycle.c.inc +// square_platform_cycle.inc.c s32 square_plat_set_yaw_until_timer(u16 yaw, s32 a) { o->oMoveAngleYaw = yaw; - if (a < o->oTimer) - return 1; - else - return 0; + if (a < o->oTimer) { + return TRUE; + } else { + return FALSE; + } } void bhv_squarish_path_moving_loop(void) { o->oForwardVel = 10.0f; + switch (o->oAction) { case 0: o->oAction = (o->oBehParams2ndByte & 3) + 1; break; case 1: - if (square_plat_set_yaw_until_timer(0, 60)) + if (square_plat_set_yaw_until_timer(0, 60)) { o->oAction++; + } break; case 2: - if (square_plat_set_yaw_until_timer(0x4000, 60)) + if (square_plat_set_yaw_until_timer(0x4000, 60)) { o->oAction++; + } break; case 3: - if (square_plat_set_yaw_until_timer(0x8000, 60)) + if (square_plat_set_yaw_until_timer(0x8000, 60)) { o->oAction++; + } break; case 4: - if (square_plat_set_yaw_until_timer(0xc000, 60)) + if (square_plat_set_yaw_until_timer(0xc000, 60)) { o->oAction = 1; + } break; default: break; } + cur_obj_move_using_fvel_and_gravity(); load_object_collision_model(); } diff --git a/src/game/behaviors/star_door.inc.c b/src/game/behaviors/star_door.inc.c index 67f52701..23faf8b4 100644 --- a/src/game/behaviors/star_door.inc.c +++ b/src/game/behaviors/star_door.inc.c @@ -1,4 +1,4 @@ -// star_door.c.inc +// star_door.inc.c void star_door_update_pos(void) { o->oVelX = (o->oLeftVel) * coss(o->oMoveAngleYaw); @@ -8,19 +8,22 @@ void star_door_update_pos(void) { } void bhv_star_door_loop(void) { - UNUSED u8 pad[4]; - struct Object *sp18; - sp18 = cur_obj_nearest_object_with_behavior(bhvStarDoor); + UNUSED u8 filler[4]; + struct Object *sp18 = cur_obj_nearest_object_with_behavior(bhvStarDoor); + switch (o->oAction) { case 0: cur_obj_become_tangible(); - if (0x30000 & o->oInteractStatus) + if (o->oInteractStatus & (INT_STATUS_UNK16 | INT_STATUS_UNK17)) { o->oAction = 1; - if (sp18 != NULL && sp18->oAction != 0) + } + if (sp18 != NULL && sp18->oAction != 0) { o->oAction = 1; + } break; + case 1: - if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) { + if (o->oTimer == 0 && (s16) o->oMoveAngleYaw >= 0) { cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_OPEN); #if ENABLE_RUMBLE queue_rumble_data(35, 30); @@ -29,15 +32,19 @@ void bhv_star_door_loop(void) { cur_obj_become_intangible(); o->oLeftVel = -8.0f; star_door_update_pos(); - if (o->oTimer >= 16) + if (o->oTimer > 15) { o->oAction++; + } break; + case 2: - if (o->oTimer >= 31) + if (o->oTimer > 30) { o->oAction++; + } break; + case 3: - if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) { + if (o->oTimer == 0 && (s16) o->oMoveAngleYaw >= 0) { cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_CLOSE); #if ENABLE_RUMBLE queue_rumble_data(35, 30); @@ -45,9 +52,11 @@ void bhv_star_door_loop(void) { } o->oLeftVel = 8.0f; star_door_update_pos(); - if (o->oTimer >= 16) + if (o->oTimer > 15) { o->oAction++; + } break; + case 4: o->oInteractStatus = 0; o->oAction = 0; diff --git a/src/game/behaviors/static_checkered_platform.inc.c b/src/game/behaviors/static_checkered_platform.inc.c index 0537489b..a9e27cee 100644 --- a/src/game/behaviors/static_checkered_platform.inc.c +++ b/src/game/behaviors/static_checkered_platform.inc.c @@ -1,21 +1,24 @@ -// static_checkered_platform.c.inc +// static_checkered_platform.inc.c void bhv_static_checkered_platform_loop(void) { - if (gDebugInfo[5][0] == 1) { + if (gDebugInfo[DEBUG_PAGE_ENEMYINFO][0] == 1) { obj_set_angle(o, 0, 0, 0); o->oAngleVelPitch = 0; o->oAngleVelYaw = 0; o->oAngleVelRoll = 0; } - if (gDebugInfo[5][0] == 2) { - o->oFaceAnglePitch = gDebugInfo[5][1] << 12; - o->oFaceAngleYaw = gDebugInfo[5][2] << 12; - o->oFaceAngleRoll = gDebugInfo[5][3] << 12; + + if (gDebugInfo[DEBUG_PAGE_ENEMYINFO][0] == 2) { + o->oFaceAnglePitch = gDebugInfo[DEBUG_PAGE_ENEMYINFO][1] << 12; + o->oFaceAngleYaw = gDebugInfo[DEBUG_PAGE_ENEMYINFO][2] << 12; + o->oFaceAngleRoll = gDebugInfo[DEBUG_PAGE_ENEMYINFO][3] << 12; } - o->oAngleVelPitch = gDebugInfo[5][4]; - o->oAngleVelYaw = gDebugInfo[5][5]; - o->oAngleVelRoll = gDebugInfo[5][6]; - if (gDebugInfo[5][0] == 3) { + + o->oAngleVelPitch = gDebugInfo[DEBUG_PAGE_ENEMYINFO][4]; + o->oAngleVelYaw = gDebugInfo[DEBUG_PAGE_ENEMYINFO][5]; + o->oAngleVelRoll = gDebugInfo[DEBUG_PAGE_ENEMYINFO][6]; + + if (gDebugInfo[DEBUG_PAGE_ENEMYINFO][0] == 3) { o->oFaceAnglePitch += o->oAngleVelPitch; o->oFaceAngleYaw += o->oAngleVelYaw; o->oFaceAngleRoll += o->oAngleVelRoll; diff --git a/src/game/behaviors/strong_wind_particle.inc.c b/src/game/behaviors/strong_wind_particle.inc.c index 50cd04be..993c22a7 100644 --- a/src/game/behaviors/strong_wind_particle.inc.c +++ b/src/game/behaviors/strong_wind_particle.inc.c @@ -1,39 +1,40 @@ -// strong_wind_particle.c.inc +// strong_wind_particle.inc.c struct ObjectHitbox sStrongWindParticleHitbox = { - /* interactType: */ INTERACT_STRONG_WIND, - /* downOffset: */ 0, + /* interactType: */ INTERACT_STRONG_WIND, + /* downOffset: */ 0, /* damageOrCoinValue: */ 0, - /* health: */ 0, - /* numLootCoins: */ 0, - /* radius: */ 20, - /* height: */ 70, - /* hurtboxRadius: */ 20, - /* hurtboxHeight: */ 70, + /* health: */ 0, + /* numLootCoins: */ 0, + /* radius: */ 20, + /* height: */ 70, + /* hurtboxRadius: */ 20, + /* hurtboxHeight: */ 70, }; void bhv_strong_wind_particle_loop(void) { struct Object *penguinObj; f32 distanceFromPenguin; f32 penguinXDist, penguinZDist; - + obj_set_hitbox(o, &sStrongWindParticleHitbox); - + if (o->oTimer == 0) { o->oStrongWindParticlePenguinObj = cur_obj_nearest_object_with_behavior(bhvSLWalkingPenguin); obj_translate_xyz_random(o, 100.0f); - + o->oForwardVel = coss(o->oMoveAnglePitch) * 100.0f; o->oVelY = sins(o->oMoveAnglePitch) * -100.0f; - + o->oMoveAngleYaw += random_f32_around_zero(o->oBehParams2ndByte * 500); // Wind spread o->oOpacity = 100; } - + cur_obj_move_using_fvel_and_gravity(); - if (o->oTimer > 15) // Deactivate after 15 frames + if (o->oTimer > 15) { // Deactivate after 15 frames obj_mark_for_deletion(o); - + } + // If collided with the SL walking penguin, deactivate. penguinObj = o->oStrongWindParticlePenguinObj; if (penguinObj != NULL) { @@ -51,13 +52,14 @@ void bhv_strong_wind_particle_loop(void) { // Used for the Snowman in SL and Fwoosh. void cur_obj_spawn_strong_wind_particles(s32 windSpread, f32 scale, f32 relPosX, f32 relPosY, f32 relPosZ) { // Alternate between tiny particles and regular particles each frame. - if ((gGlobalTimer & 1) != 0) { + if (gGlobalTimer & 1) { // Because the tiny particles are unimportant objects, invisible wind particles are spawned to provide collision. // There was absolutely no reason to make the smaller particles unimportant, though... spawn_object_relative_with_scale(windSpread, relPosX, relPosY, relPosZ, 0.5f, o, MODEL_WHITE_PARTICLE_DL, bhvTinyStrongWindParticle); spawn_object_relative_with_scale(windSpread, relPosX, relPosY, relPosZ, scale, o, MODEL_NONE, bhvStrongWindParticle); - } else + } else { spawn_object_relative_with_scale(windSpread, relPosX, relPosY, relPosZ, scale, o, MODEL_MIST, bhvStrongWindParticle); + } // There is also no need to spawn additional invisible wind particles here. // If the devs were worried about object overload when making small particles unimportant, why spawn these? // It isn't to ensure collision, as even 1 particle every 2 frames is enough to ensure this reliably. diff --git a/src/game/behaviors/sushi.inc.c b/src/game/behaviors/sushi.inc.c index 52282c64..48fff5ea 100644 --- a/src/game/behaviors/sushi.inc.c +++ b/src/game/behaviors/sushi.inc.c @@ -1,19 +1,26 @@ -// sushi.c.inc +// sushi.inc.c void bhv_sushi_shark_collision_loop(void) { } void bhv_sushi_shark_loop(void) { f32 sp1C = find_water_level(o->oPosX, o->oPosZ); + o->oPosX = o->oHomeX + sins(o->oSushiSharkUnkF4) * 1700.0f; o->oPosZ = o->oHomeZ + coss(o->oSushiSharkUnkF4) * 1700.0f; o->oPosY = sp1C + o->oHomeY + sins(o->oSushiSharkUnkF4) * 200.0f; + o->oMoveAngleYaw = o->oSushiSharkUnkF4 + 0x4000; o->oSushiSharkUnkF4 += 0x80; - if (gMarioObject->oPosY - sp1C > -500.0f) - if (o->oPosY - sp1C > -200.0f) + + if (gMarioObject->oPosY - sp1C > -500.0f) { + if (o->oPosY - sp1C > -200.0f) { spawn_object_with_scale(o, MODEL_WAVE_TRAIL, bhvObjectWaveTrail, 4.0f); - if ((o->oTimer & 0xF) == 0) + } + } + if (!(o->oTimer & 0x0F)) { cur_obj_play_sound_2(SOUND_OBJ_SUSHI_SHARK_WATER_SOUND); + } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/swing_platform.inc.c b/src/game/behaviors/swing_platform.inc.c index e3fb2911..b51cee97 100644 --- a/src/game/behaviors/swing_platform.inc.c +++ b/src/game/behaviors/swing_platform.inc.c @@ -1,3 +1,4 @@ +// swing_platform.inc.c void bhv_swing_platform_init(void) { o->oSwingPlatformAngle = 0x2000; diff --git a/src/game/behaviors/switch_hidden_objects.inc.c b/src/game/behaviors/switch_hidden_objects.inc.c index 09875866..0dc44789 100644 --- a/src/game/behaviors/switch_hidden_objects.inc.c +++ b/src/game/behaviors/switch_hidden_objects.inc.c @@ -1,20 +1,21 @@ -// switch_hidden_objects.c.inc +// switch_hidden_objects.inc.c struct ObjectHitbox sBreakableBoxHitbox = { - /* interactType: */ INTERACT_BREAKABLE, - /* downOffset: */ 20, + /* interactType: */ INTERACT_BREAKABLE, + /* downOffset: */ 20, /* damageOrCoinValue: */ 0, - /* health: */ 1, - /* numLootCoins: */ 0, - /* radius: */ 150, - /* height: */ 200, - /* hurtboxRadius: */ 150, - /* hurtboxHeight: */ 200, + /* health: */ 1, + /* numLootCoins: */ 0, + /* radius: */ 150, + /* height: */ 200, + /* hurtboxRadius: */ 150, + /* hurtboxHeight: */ 200, }; void breakable_box_init(void) { o->oHiddenObjectUnkF4 = NULL; o->oAnimState = 1; + switch (o->oBehParams2ndByte) { case 0: o->oNumLootCoins = 0; @@ -33,25 +34,31 @@ void breakable_box_init(void) { void hidden_breakable_box_actions(void) { struct Object *sp1C; + obj_set_hitbox(o, &sBreakableBoxHitbox); cur_obj_set_model(MODEL_BREAKABLE_BOX_SMALL); + if (o->oAction == 0) { cur_obj_disable_rendering(); cur_obj_become_intangible(); - if (o->oTimer == 0) + if (o->oTimer == 0) { breakable_box_init(); - if (o->oHiddenObjectUnkF4 == NULL) + } + if (o->oHiddenObjectUnkF4 == NULL) { o->oHiddenObjectUnkF4 = cur_obj_nearest_object_with_behavior(bhvFloorSwitchHiddenObjects); - if ((sp1C = o->oHiddenObjectUnkF4) != NULL) + } + if ((sp1C = o->oHiddenObjectUnkF4) != NULL) { if (sp1C->oAction == 2) { o->oAction++; cur_obj_enable_rendering(); cur_obj_unhide(); } + } } else if (o->oAction == 1) { cur_obj_become_tangible(); - if (cur_obj_wait_then_blink(360, 20)) + if (cur_obj_wait_then_blink(360, 20)) { o->oAction = 0; + } if (cur_obj_was_attacked_or_ground_pounded()) { spawn_mist_particles(); spawn_triangle_break_particles(30, MODEL_DIRT_ANIMATION, 3.0f, 4); @@ -63,37 +70,45 @@ void hidden_breakable_box_actions(void) { cur_obj_become_intangible(); cur_obj_disable_rendering(); o->oInteractStatus = 0; - if ((sp1C = o->oHiddenObjectUnkF4) != NULL) - if (sp1C->oAction == 0) + if ((sp1C = o->oHiddenObjectUnkF4) != NULL) { + if (sp1C->oAction == 0) { o->oAction = 0; + } + } } } void hidden_unbreakable_box_actions(void) { struct Object *sp1C; + obj_set_collision_data(o, wdw_seg7_collision_07018528); + if (o->oAction == 0) { cur_obj_disable_rendering(); cur_obj_become_intangible(); - if (o->oHiddenObjectUnkF4 == NULL) + if (o->oHiddenObjectUnkF4 == NULL) { o->oHiddenObjectUnkF4 = cur_obj_nearest_object_with_behavior(bhvFloorSwitchHiddenObjects); - if ((sp1C = o->oHiddenObjectUnkF4) != NULL) + } + if ((sp1C = o->oHiddenObjectUnkF4) != NULL) { if (sp1C->oAction == 2) { o->oAction++; cur_obj_enable_rendering(); cur_obj_unhide(); } + } } else { cur_obj_become_tangible(); - if (cur_obj_wait_then_blink(360, 20)) + if (cur_obj_wait_then_blink(360, 20)) { o->oAction = 0; + } load_object_collision_model(); } } void bhv_hidden_object_loop(void) { - if (o->oBehParams2ndByte == 0) + if (o->oBehParams2ndByte == 0) { hidden_breakable_box_actions(); // Confused, that function has code depending on the action - else + } else { hidden_unbreakable_box_actions(); + } } diff --git a/src/game/behaviors/swoop.inc.c b/src/game/behaviors/swoop.inc.c index 8e628cf4..84f0473d 100644 --- a/src/game/behaviors/swoop.inc.c +++ b/src/game/behaviors/swoop.inc.c @@ -61,7 +61,7 @@ static void swoop_act_move(void) { o->oFaceAngleRoll = 0; } else { if (o->oSwoopBonkCountdown != 0) { - o->oSwoopBonkCountdown -= 1; + o->oSwoopBonkCountdown--; } else if (o->oVelY != 0.0f) { // If we're not done swooping, turn toward mario. When between // 0 and 200 units above mario, increase speed and stop swooping diff --git a/src/game/behaviors/thi_top.inc.c b/src/game/behaviors/thi_top.inc.c index 727020d0..8b5a9bca 100644 --- a/src/game/behaviors/thi_top.inc.c +++ b/src/game/behaviors/thi_top.inc.c @@ -1,22 +1,35 @@ -// thi_top.c.inc +// thi_top.inc.c -struct SpawnParticlesInfo sThiTopPuffs = { - 0, 30, MODEL_WHITE_PARTICLE_SMALL, 0, 40, 0, 20, 40, 252, 30, 20.0f, 0.0f +static struct SpawnParticlesInfo sThiTopPuffs = { + /* behParam: */ 0, + /* count: */ 30, + /* model: */ MODEL_WHITE_PARTICLE_SMALL, + /* offsetY: */ 0, + /* forwardVelBase: */ 40, + /* forwardVelRange: */ 0, + /* velYBase: */ 20, + /* velYRange: */ 40, + /* gravity: */ 252, + /* dragStrength: */ 30, + /* sizeBase: */ 20.0f, + /* sizeRange: */ 0.0f, }; void bhv_thi_huge_island_top_loop(void) { if (gTHIWaterDrained & 1) { - if (o->oTimer == 0) + if (o->oTimer == 0) { gEnvironmentRegions[18] = 3000; + } cur_obj_hide(); - } else + } else { load_object_collision_model(); + } } void bhv_thi_tiny_island_top_loop(void) { if (!(gTHIWaterDrained & 1)) { if (o->oAction == 0) { - if (o->oDistanceToMario < 500.0f) + if (o->oDistanceToMario < 500.0f) { if (gMarioStates[0].action == ACT_GROUND_POUND_LAND) { o->oAction++; cur_obj_spawn_particles(&sThiTopPuffs); @@ -24,6 +37,7 @@ void bhv_thi_tiny_island_top_loop(void) { cur_obj_play_sound_2(SOUND_GENERAL_ACTIVATE_CAP_SWITCH); cur_obj_hide(); } + } } else { if (o->oTimer < 50) { gEnvironmentRegions[18]--; @@ -31,12 +45,13 @@ void bhv_thi_tiny_island_top_loop(void) { } else { gTHIWaterDrained |= 1; play_puzzle_jingle(); - o->oAction += 1; + o->oAction++; } } } else { - if (o->oTimer == 0) + if (o->oTimer == 0) { gEnvironmentRegions[18] = 700; + } cur_obj_hide(); } } diff --git a/src/game/behaviors/thwomp.inc.c b/src/game/behaviors/thwomp.inc.c index fdb3345b..00093c9d 100644 --- a/src/game/behaviors/thwomp.inc.c +++ b/src/game/behaviors/thwomp.inc.c @@ -1,10 +1,12 @@ -// thwomp.c.inc +// thwomp.inc.c void grindel_thwomp_act_4(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oThwompRandomTimer = random_float() * 10.0f + 20.0f; - if (o->oTimer > o->oThwompRandomTimer) + } + if (o->oTimer > o->oThwompRandomTimer) { o->oAction = 0; + } } void grindel_thwomp_act_2(void) { @@ -12,39 +14,48 @@ void grindel_thwomp_act_2(void) { o->oPosY += o->oVelY; if (o->oPosY < o->oHomeY) { o->oPosY = o->oHomeY; - o->oVelY = 0; + o->oVelY = 0.0f; o->oAction = 3; } } void grindel_thwomp_act_3(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { if (o->oDistanceToMario < 1500.0f) { cur_obj_shake_screen(SHAKE_POS_SMALL); cur_obj_play_sound_2(SOUND_OBJ_THWOMP); } - if (o->oTimer > 9) + } + if (o->oTimer >= 10) { o->oAction = 4; + } } void grindel_thwomp_act_1(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oThwompRandomTimer = random_float() * 30.0f + 10.0f; - if (o->oTimer > o->oThwompRandomTimer) + } + if (o->oTimer > o->oThwompRandomTimer) { o->oAction = 2; + } } void grindel_thwomp_act_0(void) { if (o->oBehParams2ndByte + 40 < o->oTimer) { o->oAction = 1; o->oPosY += 5.0f; - } else + } else { o->oPosY += 10.0f; + } } -void (*sGrindelThwompActions[])(void) = { grindel_thwomp_act_0, grindel_thwomp_act_1, - grindel_thwomp_act_2, grindel_thwomp_act_3, - grindel_thwomp_act_4 }; +void (*sGrindelThwompActions[])(void) = { + grindel_thwomp_act_0, + grindel_thwomp_act_1, + grindel_thwomp_act_2, + grindel_thwomp_act_3, + grindel_thwomp_act_4, +}; void bhv_grindel_thwomp_loop(void) { cur_obj_call_action_function(sGrindelThwompActions); diff --git a/src/game/behaviors/tilting_inverted_pyramid.inc.c b/src/game/behaviors/tilting_inverted_pyramid.inc.c index ebce64fc..77193dc7 100644 --- a/src/game/behaviors/tilting_inverted_pyramid.inc.c +++ b/src/game/behaviors/tilting_inverted_pyramid.inc.c @@ -1,3 +1,4 @@ + /** * This is the behavior file for the tilting inverted pyramids in BitFS/LLL. * The object essentially just tilts and moves Mario with it. @@ -77,9 +78,9 @@ void bhv_tilting_inverted_pyramid_loop(void) { f32 mz; s32 marioOnPlatform = FALSE; - UNUSED s32 unused; + UNUSED u8 filler1[4]; Mat4 *transform = &o->transform; - UNUSED s32 unused2[7]; + UNUSED u8 filler2[28]; if (gMarioObject->platform == o) { get_mario_pos(&mx, &my, &mz); @@ -107,8 +108,9 @@ void bhv_tilting_inverted_pyramid_loop(void) { dz = 0.0f; } - if (o->oTiltingPyramidMarioOnPlatform == TRUE) + if (o->oTiltingPyramidMarioOnPlatform == TRUE) { marioOnPlatform++; + } o->oTiltingPyramidMarioOnPlatform = TRUE; } else { @@ -126,7 +128,7 @@ void bhv_tilting_inverted_pyramid_loop(void) { create_transform_from_normals(*transform, o->oTiltingPyramidNormalX, o->oTiltingPyramidNormalY, o->oTiltingPyramidNormalZ); // If Mario is on the platform, adjust his position for the platform tilt. - if (marioOnPlatform != FALSE) { + if (marioOnPlatform) { linear_mtxf_mul_vec3f(*transform, posAfterRotation, dist); mx += posAfterRotation[0] - posBeforeRotation[0]; my += posAfterRotation[1] - posBeforeRotation[1]; diff --git a/src/game/behaviors/tower_door.inc.c b/src/game/behaviors/tower_door.inc.c index 70bdf31c..513a9a45 100644 --- a/src/game/behaviors/tower_door.inc.c +++ b/src/game/behaviors/tower_door.inc.c @@ -1,9 +1,11 @@ -// tower_door.c.inc +// tower_door.inc.c void bhv_tower_door_loop(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oMoveAngleYaw -= 0x4000; - if (check_mario_attacking(0)) { + } + + if (check_mario_attacking(0) != 0) { obj_explode_and_spawn_coins(80.0f, 0); create_sound_spawner(SOUND_GENERAL_WALL_EXPLOSION); } diff --git a/src/game/behaviors/tower_platform.inc.c b/src/game/behaviors/tower_platform.inc.c index 8103fa5d..aca5c371 100644 --- a/src/game/behaviors/tower_platform.inc.c +++ b/src/game/behaviors/tower_platform.inc.c @@ -1,81 +1,104 @@ -// tower_platform.c.inc +// tower_platform.inc.c void bhv_wf_solid_tower_platform_loop(void) { - if (o->parentObj->oAction == 3) + if (o->parentObj->oAction == 3) { obj_mark_for_deletion(o); + } } void bhv_wf_elevator_tower_platform_loop(void) { switch (o->oAction) { case 0: - if (gMarioObject->platform == o) + if (gMarioObject->platform == o) { o->oAction++; + } break; + case 1: cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); - if (o->oTimer > 140) + if (o->oTimer > 140) { o->oAction++; - else + } else { o->oPosY += 5.0f; + } break; + case 2: - if (o->oTimer > 60) + if (o->oTimer > 60) { o->oAction++; + } break; + case 3: cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); - if (o->oTimer > 140) + if (o->oTimer > 140) { o->oAction = 0; - else + } else { o->oPosY -= 5.0f; + } break; } - if (o->parentObj->oAction == 3) + + if (o->parentObj->oAction == 3) { obj_mark_for_deletion(o); + } } void bhv_wf_sliding_tower_platform_loop(void) { s32 sp24 = o->oPlatformUnk110 / o->oPlatformUnk10C; + switch (o->oAction) { case 0: - if (o->oTimer > sp24) + if (o->oTimer > sp24) { o->oAction++; + } o->oForwardVel = -o->oPlatformUnk10C; break; + case 1: - if (o->oTimer > sp24) + if (o->oTimer > sp24) { o->oAction = 0; + } o->oForwardVel = o->oPlatformUnk10C; break; } + cur_obj_compute_vel_xz(); + o->oPosX += o->oVelX; o->oPosZ += o->oVelZ; - if (o->parentObj->oAction == 3) + + if (o->parentObj->oAction == 3) { obj_mark_for_deletion(o); + } } void spawn_and_init_wf_platforms(s16 a, const BehaviorScript *bhv) { s16 yaw; struct Object *platform = spawn_object(o, a, bhv); + yaw = o->oPlatformSpawnerUnkF4 * o->oPlatformSpawnerUnkFC + o->oPlatformSpawnerUnkF8; + platform->oMoveAngleYaw = yaw; platform->oPosX += o->oPlatformSpawnerUnk100 * sins(yaw); platform->oPosY += 100 * o->oPlatformSpawnerUnkF4; platform->oPosZ += o->oPlatformSpawnerUnk100 * coss(yaw); platform->oPlatformUnk110 = o->oPlatformSpawnerUnk104; platform->oPlatformUnk10C = o->oPlatformSpawnerUnk108; + o->oPlatformSpawnerUnkF4++; } void spawn_wf_platform_group(void) { UNUSED s32 unused = 8; + o->oPlatformSpawnerUnkF4 = 0; o->oPlatformSpawnerUnkF8 = 0; o->oPlatformSpawnerUnkFC = 0x2000; o->oPlatformSpawnerUnk100 = 704.0f; o->oPlatformSpawnerUnk104 = 380.0f; o->oPlatformSpawnerUnk108 = 3.0f; + spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWfSolidTowerPlatform); spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWfSlidingTowerPlatform); spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWfSolidTowerPlatform); @@ -88,20 +111,27 @@ void spawn_wf_platform_group(void) { void bhv_tower_platform_group_loop(void) { f32 marioY = gMarioObject->oPosY; + o->oDistanceToMario = dist_between_objects(o, gMarioObject); + switch (o->oAction) { case 0: - if (marioY > o->oHomeY - 1000.0f) + if (marioY > o->oHomeY - 1000.0f) { o->oAction++; + } break; + case 1: spawn_wf_platform_group(); o->oAction++; break; + case 2: - if (marioY < o->oHomeY - 1000.0f) + if (marioY < o->oHomeY - 1000.0f) { o->oAction++; + } break; + case 3: o->oAction = 0; break; diff --git a/src/game/behaviors/tox_box.inc.c b/src/game/behaviors/tox_box.inc.c index 1b50d26e..47c25b20 100644 --- a/src/game/behaviors/tox_box.inc.c +++ b/src/game/behaviors/tox_box.inc.c @@ -1,4 +1,4 @@ -// tox_box.c.inc +// tox_box.inc.c s8 D_8032F8F0[] = { 4, 1, 4, 1, 6, 1, 6, 1, 5, 1, 5, 1, 6, 1, 6, 1, 5, 1, 2, 4, 1, 4, 1, 4, 1, 2, 5, 1, 5, 1, 7, 1, 7, 1, 4, 1, 4, 1, 7, 1, 7, 1, 5, 1, 5, 1, 5, 1, 2, 4, 1, -1 }; @@ -9,60 +9,70 @@ s8 D_8032F948[] = { 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 2, 5, 1, 5, 1, 5, 1, 5, s8 *D_8032F96C[] = { D_8032F8F0, D_8032F924, D_8032F948 }; void tox_box_shake_screen(void) { - if (o->oDistanceToMario < 3000.0f) + if (o->oDistanceToMario < 3000.0f) { cur_obj_shake_screen(SHAKE_POS_SMALL); + } } -void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll) -{ +void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll) { o->oPosY = 99.41124 * sins((f32)(o->oTimer + 1) / 8 * 0x8000) + o->oHomeY + 3.0f; o->oForwardVel = forwardVel; o->oUpVel = a1; o->oFaceAnglePitch += deltaPitch; - if ((s16) o->oFaceAnglePitch < 0) + + if ((s16) o->oFaceAnglePitch < 0) { deltaRoll = -deltaRoll; + } + o->oFaceAngleRoll += deltaRoll; cur_obj_set_pos_via_transform(); + if (o->oTimer == 7) { o->oAction = cur_obj_progress_direction_table(); -#ifndef VERSION_JP cur_obj_play_sound_2(SOUND_GENERAL_UNK46); -#else - cur_obj_play_sound_2(SOUND_GENERAL_UNK46_LOWPRIO); -#endif } } void tox_box_act_4(void) { tox_box_move(64.0f, 0.0f, 0x800, 0); } + void tox_box_act_5(void) { tox_box_move(-64.0f, 0.0f, -0x800, 0); } + void tox_box_act_6(void) { tox_box_move(0.0f, -64.0f, 0, 0x800); } + void tox_box_act_7(void) { tox_box_move(0.0f, 64.0f, 0, -0x800); } void tox_box_act_1(void) { o->oForwardVel = 0.0f; - if (o->oTimer == 0) + + if (o->oTimer == 0) { tox_box_shake_screen(); + } + o->oPosY = o->oHomeY + 3.0f; - if (o->oTimer == 20) + + if (o->oTimer == 20) { o->oAction = cur_obj_progress_direction_table(); + } } void tox_box_act_2(void) { - if (o->oTimer == 20) + if (o->oTimer == 20) { o->oAction = cur_obj_progress_direction_table(); + } } void tox_box_act_3(void) { - if (o->oTimer == 20) + if (o->oTimer == 20) { o->oAction = cur_obj_progress_direction_table(); + } } void tox_box_act_0(void) { @@ -70,8 +80,16 @@ void tox_box_act_0(void) { o->oAction = cur_obj_set_direction_table(sp1C); } -void (*sToxBoxActions[])(void) = { tox_box_act_0, tox_box_act_1, tox_box_act_2, tox_box_act_3, - tox_box_act_4, tox_box_act_5, tox_box_act_6, tox_box_act_7 }; +void (*sToxBoxActions[])(void) = { + tox_box_act_0, + tox_box_act_1, + tox_box_act_2, + tox_box_act_3, + tox_box_act_4, + tox_box_act_5, + tox_box_act_6, + tox_box_act_7, +}; void bhv_tox_box_loop(void) { cur_obj_call_action_function(sToxBoxActions); diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c index 34b855e9..55a6b0cc 100644 --- a/src/game/behaviors/treasure_chest.inc.c +++ b/src/game/behaviors/treasure_chest.inc.c @@ -1,4 +1,4 @@ -// treasure_chest.c.inc +// treasure_chest.inc.c /** * Hitbox for treasure chest bottom. @@ -20,8 +20,9 @@ void bhv_treasure_chest_top_loop(void) { switch (o->oAction) { case 0: - if (o->parentObj->oAction == 1) + if (o->parentObj->oAction == 1) { o->oAction = 1; + } break; case 1: @@ -34,18 +35,20 @@ void bhv_treasure_chest_top_loop(void) { } } - o->oFaceAnglePitch += -0x200; + o->oFaceAnglePitch -= 0x200; if (o->oFaceAnglePitch < -0x4000) { o->oFaceAnglePitch = -0x4000; o->oAction++; - if (o->parentObj->oBehParams2ndByte != 4) + if (o->parentObj->oBehParams2ndByte != 4) { spawn_orange_number(o->parentObj->oBehParams2ndByte, 0, -40, 0); + } } break; case 2: - if (o->parentObj->oAction == 0) + if (o->parentObj->oAction == 0) { o->oAction = 3; + } break; case 3: @@ -65,34 +68,33 @@ void bhv_treasure_chest_bottom_init(void) { void bhv_treasure_chest_bottom_loop(void) { switch (o->oAction) { case 0: - if (obj_check_if_facing_toward_angle(o->oMoveAngleYaw, gMarioObject->header.gfx.angle[1] + 0x8000, 0x3000)) { - if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 150)) { - if (!o->parentObj->oTreasureChestUnkF8) { - if (o->parentObj->oTreasureChestUnkF4 == o->oBehParams2ndByte) { - play_sound(SOUND_GENERAL2_RIGHT_ANSWER, gGlobalSoundSource); - o->parentObj->oTreasureChestUnkF4++; - o->oAction = 1; - } else { - o->parentObj->oTreasureChestUnkF4 = 1; - o->parentObj->oTreasureChestUnkF8 = 1; - o->oAction = 2; - cur_obj_become_tangible(); - play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); - } - } + if (obj_check_if_facing_toward_angle(o->oMoveAngleYaw, gMarioObject->header.gfx.angle[1] + 0x8000, 0x3000) + && is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 150) + && !o->parentObj->oTreasureChestUnkF8) { + if (o->parentObj->oTreasureChestUnkF4 == o->oBehParams2ndByte) { + play_sound(SOUND_GENERAL2_RIGHT_ANSWER, gGlobalSoundSource); + o->parentObj->oTreasureChestUnkF4++; + o->oAction = 1; + } else { + o->parentObj->oTreasureChestUnkF4 = 1; + o->parentObj->oTreasureChestUnkF8 = TRUE; + o->oAction = 2; + cur_obj_become_tangible(); + play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); } } break; case 1: - if (o->parentObj->oTreasureChestUnkF8 == 1) + if (o->parentObj->oTreasureChestUnkF8 == TRUE) { o->oAction = 0; + } break; case 2: cur_obj_become_intangible(); if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500)) { - o->parentObj->oTreasureChestUnkF8 = 0; + o->parentObj->oTreasureChestUnkF8 = FALSE; o->oAction = 0; } } @@ -101,10 +103,9 @@ void bhv_treasure_chest_bottom_loop(void) { o->oInteractStatus = 0; } -void spawn_treasure_chest(s8 sp3B, s32 sp3C, s32 sp40, s32 sp44, s16 sp4A) { - struct Object *sp34; - sp34 = spawn_object_abs_with_rot(o, 0, MODEL_TREASURE_CHEST_BASE, bhvTreasureChestBottom, sp3C, - sp40, sp44, 0, sp4A, 0); +void spawn_treasure_chest(s8 sp3B, s32 x, s32 y, s32 z, s16 yaw) { + struct Object *sp34 = spawn_object_abs_with_rot(o, 0, MODEL_TREASURE_CHEST_BASE, + bhvTreasureChestBottom, x, y, z, 0, yaw, 0); sp34->oBehParams2ndByte = sp3B; } @@ -129,7 +130,7 @@ void bhv_treasure_chest_ship_loop(void) { case 1: if (gEnvironmentRegions != NULL) { - gEnvironmentRegions[6] += -5; + gEnvironmentRegions[6] -= 5; play_sound(SOUND_ENV_WATER_DRAIN, gGlobalSoundSource); set_environmental_camera_shake(SHAKE_ENV_JRB_SHIP_DRAIN); if (gEnvironmentRegions[6] < -335) { diff --git a/src/game/behaviors/tree_particles.inc.c b/src/game/behaviors/tree_particles.inc.c index 31ae803a..7fca3654 100644 --- a/src/game/behaviors/tree_particles.inc.c +++ b/src/game/behaviors/tree_particles.inc.c @@ -1,30 +1,42 @@ -// tree_particles.c.inc +// tree_particles.inc.c void bhv_tree_snow_or_leaf_loop(void) { cur_obj_update_floor_height(); + if (o->oTimer == 0) { o->oAngleVelPitch = (random_float() - 0.5) * 0x1000; o->oAngleVelRoll = (random_float() - 0.5) * 0x1000; o->oTreeSnowOrLeafUnkF8 = 4; o->oTreeSnowOrLeafUnkFC = random_float() * 0x400 + 0x600; } - if (o->oPosY < o->oFloorHeight) + + if (o->oPosY < o->oFloorHeight) { obj_mark_for_deletion(o); - if (o->oFloorHeight < FLOOR_LOWER_LIMIT) + } + if (o->oFloorHeight < FLOOR_LOWER_LIMIT) { obj_mark_for_deletion(o); - if (o->oTimer > 100) + } + if (o->oTimer > 100) { obj_mark_for_deletion(o); - if (gPrevFrameObjectCount > (OBJECT_POOL_CAPACITY - 28)) + } + if (gPrevFrameObjectCount > (OBJECT_POOL_CAPACITY - 28)) { obj_mark_for_deletion(o); + } + o->oFaceAnglePitch += o->oAngleVelPitch; o->oFaceAngleRoll += o->oAngleVelRoll; o->oVelY += -3.0f; - if (o->oVelY < -8.0f) + + if (o->oVelY < -8.0f) { o->oVelY = -8.0f; - if (o->oForwardVel > 0) + } + + if (o->oForwardVel > 0) { o->oForwardVel -= 0.3; - else + } else { o->oForwardVel = 0; + } + o->oPosX += sins(o->oMoveAngleYaw) * sins(o->oTreeSnowOrLeafUnkF4) * o->oTreeSnowOrLeafUnkF8; o->oPosZ += coss(o->oMoveAngleYaw) * sins(o->oTreeSnowOrLeafUnkF4) * o->oTreeSnowOrLeafUnkF8; o->oTreeSnowOrLeafUnkF4 += o->oTreeSnowOrLeafUnkFC; @@ -33,15 +45,19 @@ void bhv_tree_snow_or_leaf_loop(void) { void bhv_snow_leaf_particle_spawn_init(void) { struct Object *obj; // Either snow or leaf - UNUSED s32 unused; + UNUSED u8 filler1[4]; s32 isSnow; f32 scale; - UNUSED s32 unused2; - gMarioObject->oActiveParticleFlags &= ~0x2000; - if (gCurrLevelNum == LEVEL_CCM || gCurrLevelNum == LEVEL_SL) - isSnow = 1; - else - isSnow = 0; + UNUSED u8 filler2[4]; + + gMarioObject->oActiveParticleFlags &= ~ACTIVE_PARTICLE_LEAF; + + if (gCurrLevelNum == LEVEL_CCM || gCurrLevelNum == LEVEL_SL) { + isSnow = TRUE; + } else { + isSnow = FALSE; + } + if (isSnow) { if (random_float() < 0.5) { obj = spawn_object(o, MODEL_WHITE_PARTICLE_DL, bhvTreeSnow); diff --git a/src/game/behaviors/triplet_butterfly.inc.c b/src/game/behaviors/triplet_butterfly.inc.c index 3da4f574..d39a3164 100644 --- a/src/game/behaviors/triplet_butterfly.inc.c +++ b/src/game/behaviors/triplet_butterfly.inc.c @@ -1,3 +1,5 @@ +// triplet_butterfly.inc.c + struct TripletButterflyActivationData { s32 model; const BehaviorScript *behavior; @@ -22,10 +24,9 @@ static struct TripletButterflyActivationData sTripletButterflyActivationData[] = }; static void triplet_butterfly_act_init(void) { - s32 butterflyNum; + s32 butterflyNum = o->oBehParams2ndByte & TRIPLET_BUTTERFLY_BP_BUTTERFLY_NUM; s32 i; - butterflyNum = o->oBehParams2ndByte & TRIPLET_BUTTERFLY_BP_BUTTERFLY_NUM; if (butterflyNum != 0 || o->oDistanceToMario < 200.0f) { if (butterflyNum == 0) { for (i = 1; i <= 2; i++) { @@ -116,8 +117,6 @@ static void triplet_butterfly_act_activate(void) { } static void triplet_butterfly_act_explode(void) { - f32 scaleIncrease; - obj_check_attacks(&sTripletButterflyExplodeHitbox, -1); if (o->oAction == -1 || (o->oMoveFlags & OBJ_MOVE_HIT_WALL) || o->oTimer >= 158) { @@ -126,7 +125,7 @@ static void triplet_butterfly_act_explode(void) { obj_mark_for_deletion(o); } else { if (o->oTimer > 120) { - scaleIncrease = 0.04f * coss(o->oTripletButterflyScalePhase); + f32 scaleIncrease = 0.04f * coss(o->oTripletButterflyScalePhase); if (scaleIncrease > 0.0f) { scaleIncrease *= 4.5f; o->oTripletButterflyScalePhase += 10000; diff --git a/src/game/behaviors/ttc_2d_rotator.inc.c b/src/game/behaviors/ttc_2d_rotator.inc.c index 46c7603e..a403381c 100644 --- a/src/game/behaviors/ttc_2d_rotator.inc.c +++ b/src/game/behaviors/ttc_2d_rotator.inc.c @@ -51,7 +51,7 @@ void bhv_ttc_2d_rotator_update(void) { s32 startYaw = o->oFaceAngleYaw; if (o->oTTC2DRotatorRandomDirTimer != 0) { - o->oTTC2DRotatorRandomDirTimer -= 1; + o->oTTC2DRotatorRandomDirTimer--; } // Wait until rotated to target yaw @@ -67,7 +67,7 @@ void bhv_ttc_2d_rotator_update(void) { // If ready for a change in direction, then pick a new // direction if (o->oTTC2DRotatorRandomDirTimer == 0) { - if (random_u16() & 0x3) { + if (random_u16() & 0x03) { o->oTTC2DRotatorIncrement = o->oTTC2DRotatorSpeed; o->oTTC2DRotatorRandomDirTimer = random_mod_offset(90, 60, 4); } else { diff --git a/src/game/behaviors/ttc_elevator.inc.c b/src/game/behaviors/ttc_elevator.inc.c index a4debfc2..f0f4fe12 100644 --- a/src/game/behaviors/ttc_elevator.inc.c +++ b/src/game/behaviors/ttc_elevator.inc.c @@ -20,7 +20,7 @@ void bhv_ttc_elevator_init(void) { // If behParam is nonzero, then move 100 * behParam units. Otherwise default // to 500 f32 peakOffset = - ((o->oBehParams >> 16) & 0xFFFF) != 0 ? 100.0f * ((o->oBehParams >> 16) & 0xFFFF) : 500.0f; + ((o->oBehParams >> 16) & 0xFFFF) ? 100.0f * ((o->oBehParams >> 16) & 0xFFFF) : 500.0f; o->oTTCElevatorPeakY = o->oPosY + peakOffset; } diff --git a/src/game/behaviors/ttc_moving_bar.inc.c b/src/game/behaviors/ttc_moving_bar.inc.c index e54e3c42..fb6efe05 100644 --- a/src/game/behaviors/ttc_moving_bar.inc.c +++ b/src/game/behaviors/ttc_moving_bar.inc.c @@ -43,11 +43,11 @@ static void ttc_moving_bar_act_wait(void) { // This is zero except on the first cycle, and is used to desync the // bars from each other at the very beginning if (o->oTTCMovingBarStoppedTimer != 0) { - o->oTTCMovingBarStoppedTimer -= 1; + o->oTTCMovingBarStoppedTimer--; } else { if (gTTCSpeedSetting == TTC_SPEED_RANDOM) { // Set the delay for the next cycle - o->oTTCMovingBarDelay = sTTCMovingBarRandomDelays[random_u16() & 0x3]; + o->oTTCMovingBarDelay = sTTCMovingBarRandomDelays[random_u16() & 0x03]; // With 50% probability, pause after pulling back if (random_u16() % 2 == 0) { @@ -70,7 +70,7 @@ static void ttc_moving_bar_act_pull_back(void) { if ((o->oTTCMovingBarSpeed += 0.73f) > 0.0f) { // Possibly pause after pulling back if (o->oTTCMovingBarStoppedTimer != 0) { - o->oTTCMovingBarStoppedTimer -= 1; + o->oTTCMovingBarStoppedTimer--; o->oTTCMovingBarSpeed = 0.0f; } else { // Begin extending diff --git a/src/game/behaviors/ttc_pendulum.inc.c b/src/game/behaviors/ttc_pendulum.inc.c index b63282e2..a492a4ce 100644 --- a/src/game/behaviors/ttc_pendulum.inc.c +++ b/src/game/behaviors/ttc_pendulum.inc.c @@ -42,7 +42,7 @@ void bhv_ttc_pendulum_update(void) { // Stay still for a while if (o->oTTCPendulumDelay != 0) { - o->oTTCPendulumDelay -= 1; + o->oTTCPendulumDelay--; } else { // Accelerate in the direction that moves angle to zero if (o->oTTCPendulumAngle * o->oTTCPendulumAccelDir > 0.0f) { diff --git a/src/game/behaviors/ttc_pit_block.inc.c b/src/game/behaviors/ttc_pit_block.inc.c index 1f3c221f..ccc45f58 100644 --- a/src/game/behaviors/ttc_pit_block.inc.c +++ b/src/game/behaviors/ttc_pit_block.inc.c @@ -56,10 +56,10 @@ void bhv_ttc_pit_block_update(void) { cur_obj_move_using_fvel_and_gravity(); if (clamp_f32(&o->oPosY, o->oHomeY, o->oTTCPitBlockPeakY)) { - o->oTTCPitBlockDir = o->oTTCPitBlockDir ^ 0x1; + o->oTTCPitBlockDir = o->oTTCPitBlockDir ^ 0x01; if ((o->oTTCPitBlockWaitTime = - sTTCPitBlockProperties[gTTCSpeedSetting][o->oTTCPitBlockDir & 0x1].waitTime) + sTTCPitBlockProperties[gTTCSpeedSetting][o->oTTCPitBlockDir & 0x01].waitTime) < 0) { o->oTTCPitBlockWaitTime = random_mod_offset(10, 20, 6); } diff --git a/src/game/behaviors/ttc_rotating_solid.inc.c b/src/game/behaviors/ttc_rotating_solid.inc.c index 238a8835..6a7a5a5b 100644 --- a/src/game/behaviors/ttc_rotating_solid.inc.c +++ b/src/game/behaviors/ttc_rotating_solid.inc.c @@ -7,7 +7,7 @@ /** * The collision models for cube and triangular prism, respectively. */ -static void const *sTTCRotatingSolidCollisionModels[] = { +static Collision const *sTTCRotatingSolidCollisionModels[] = { ttc_seg7_collision_07014F70, ttc_seg7_collision_07015008, }; @@ -51,7 +51,7 @@ void bhv_ttc_rotating_solid_update(void) { (s32)((f32) o->oTTCRotatingSolidNumTurns / o->oTTCRotatingSolidNumSides * 0x10000); s32 startRoll = o->oFaceAngleRoll; - obj_face_roll_approach(targetRoll, 0x4B0); + obj_face_roll_approach(targetRoll, 1200); o->oAngleVelRoll = o->oFaceAngleRoll - startRoll; if (o->oAngleVelRoll == 0) { diff --git a/src/game/behaviors/ttc_treadmill.inc.c b/src/game/behaviors/ttc_treadmill.inc.c index 537540b1..4a6c210b 100644 --- a/src/game/behaviors/ttc_treadmill.inc.c +++ b/src/game/behaviors/ttc_treadmill.inc.c @@ -25,7 +25,7 @@ extern s16 ttc_movtex_tris_big_surface_treadmill[]; extern s16 ttc_movtex_tris_small_surface_treadmill[]; void bhv_ttc_treadmill_init(void) { - o->collisionData = segmented_to_virtual(sTTCTreadmillCollisionModels[o->oBehParams2ndByte & 0x1]); + o->collisionData = segmented_to_virtual(sTTCTreadmillCollisionModels[o->oBehParams2ndByte & 0x01]); o->oTTCTreadmillBigSurface = segmented_to_virtual(ttc_movtex_tris_big_surface_treadmill); o->oTTCTreadmillSmallSurface = segmented_to_virtual(ttc_movtex_tris_small_surface_treadmill); diff --git a/src/game/behaviors/tumbling_bridge.inc.c b/src/game/behaviors/tumbling_bridge.inc.c index 0879e7c4..8caf618c 100644 --- a/src/game/behaviors/tumbling_bridge.inc.c +++ b/src/game/behaviors/tumbling_bridge.inc.c @@ -1,15 +1,23 @@ -// tumbling_bridge.c.inc +// tumbling_bridge.inc.c #include "levels/wf/header.h" #include "levels/bbh/header.h" #include "levels/lll/header.h" #include "levels/bitfs/header.h" +struct Struct8032F34C { + s16 numBridgeSections; + s16 bridgeRelativeStartingXorZ; + s16 platformWidth; + s16 model; + const Collision *collision; +}; + struct Struct8032F34C sTumblingBridgeParams[] = { { 9, -512, 0x80, MODEL_WF_TUMBLING_BRIDGE_PART, wf_seg7_collision_tumbling_bridge }, { 9, -412, 103, MODEL_BBH_TUMBLING_PLATFORM_PART, bbh_seg7_collision_07026B1C }, { 9, -512, 0x80, MODEL_LLL_FALLING_PLATFORM, lll_seg7_collision_0701D21C }, - { 9, -512, 0x80, MODEL_BITFS_TUMBLING_PLATFORM_PART, bitfs_seg7_collision_07015288 } + { 9, -512, 0x80, MODEL_BITFS_TUMBLING_PLATFORM_PART, bitfs_seg7_collision_07015288 }, }; void bhv_tumbling_bridge_platform_loop(void) { @@ -20,6 +28,7 @@ void bhv_tumbling_bridge_platform_loop(void) { o->oTumblingBridgeUnkF4 = random_sign() * 0x80; } break; + case 1: cur_obj_update_floor_height(); if (o->oTimer > 5) { @@ -27,22 +36,29 @@ void bhv_tumbling_bridge_platform_loop(void) { cur_obj_play_sound_2(SOUND_GENERAL_PLATFORM); } break; + case 2: - if (o->oAngleVelPitch < 0x400) + if (o->oAngleVelPitch < 0x400) { o->oAngleVelPitch += 0x80; - if (o->oAngleVelRoll > -0x400 && o->oAngleVelRoll < 0x400) + } + if (o->oAngleVelRoll > -0x400 && o->oAngleVelRoll < 0x400) { o->oAngleVelRoll += o->oTumblingBridgeUnkF4; // acceleration? + } o->oGravity = -3.0f; cur_obj_rotate_face_angle_using_vel(); cur_obj_move_using_fvel_and_gravity(); - if (o->oPosY < o->oFloorHeight - 300.0f) + if (o->oPosY < o->oFloorHeight - 300.0f) { o->oAction++; + } break; + case 3: break; } - if (o->parentObj->oAction == 3) + + if (o->parentObj->oAction == 3) { obj_mark_for_deletion(o); + } } void tumbling_bridge_act_1(void) { @@ -58,16 +74,18 @@ void tumbling_bridge_act_1(void) { relativePlatformX = 0; relativePlatformZ = 0; - if (bridgeID == 3) + if (bridgeID == 3) { relativePlatformX = sTumblingBridgeParams[bridgeID].bridgeRelativeStartingXorZ + sTumblingBridgeParams[bridgeID].platformWidth * i; - else + } else { relativePlatformZ = sTumblingBridgeParams[bridgeID].bridgeRelativeStartingXorZ + sTumblingBridgeParams[bridgeID].platformWidth * i; + } if (cur_obj_has_behavior(bhvLllTumblingBridge)) { - if (i % 3 == 0) + if (i % 3 == 0) { relativePlatformY -= 150; + } relativeInitialPlatformY = 450; } @@ -75,7 +93,7 @@ void tumbling_bridge_act_1(void) { 0, relativePlatformX, relativePlatformY + relativeInitialPlatformY, relativePlatformZ, o, sTumblingBridgeParams[bridgeID].model, bhvTumblingBridgePlatform); - obj_set_collision_data(platformObj, sTumblingBridgeParams[bridgeID].segAddr); + obj_set_collision_data(platformObj, sTumblingBridgeParams[bridgeID].collision); } o->oAction = 2; @@ -83,9 +101,9 @@ void tumbling_bridge_act_1(void) { void tumbling_bridge_act_2(void) { cur_obj_hide(); - if (cur_obj_has_behavior(bhvLllTumblingBridge)) + if (cur_obj_has_behavior(bhvLllTumblingBridge)) { cur_obj_unhide(); - else if (o->oDistanceToMario > 1200.0f) { + } else if (o->oDistanceToMario > 1200.0f) { o->oAction = 3; cur_obj_unhide(); } @@ -97,12 +115,17 @@ void tumbling_bridge_act_3(void) { } void tumbling_bridge_act_0(void) { - if (cur_obj_has_behavior(bhvLllTumblingBridge) || o->oDistanceToMario < 1000.0f) + if (cur_obj_has_behavior(bhvLllTumblingBridge) || o->oDistanceToMario < 1000.0f) { o->oAction = 1; + } } -void (*sTumblingBridgeActions[])(void) = { tumbling_bridge_act_0, tumbling_bridge_act_1, - tumbling_bridge_act_2, tumbling_bridge_act_3 }; +void (*sTumblingBridgeActions[])(void) = { + tumbling_bridge_act_0, + tumbling_bridge_act_1, + tumbling_bridge_act_2, + tumbling_bridge_act_3, +}; void bhv_tumbling_bridge_loop(void) { cur_obj_call_action_function(sTumblingBridgeActions); diff --git a/src/game/behaviors/tuxie.inc.c b/src/game/behaviors/tuxie.inc.c index d0713644..c3c98f98 100644 --- a/src/game/behaviors/tuxie.inc.c +++ b/src/game/behaviors/tuxie.inc.c @@ -1,70 +1,78 @@ -// tuxie.c.inc +// tuxie.inc.c void play_penguin_walking_sound(s32 walk) { s32 sound; + if (o->oSoundStateID == 0) { - if (walk == PENGUIN_WALK_BABY) + if (walk == PENGUIN_WALK_BABY) { sound = SOUND_OBJ_BABY_PENGUIN_WALK; - else // PENGUIN_WALK_BIG + } else { // PENGUIN_WALK_BIG sound = SOUND_OBJ_BIG_PENGUIN_WALK; + } set_obj_anim_with_accel_and_sound(1, 11, sound); } } void tuxies_mother_act_2(void) { f32 sp24; - UNUSED s32 unused; + UNUSED u8 filler[4]; struct Object *sp1C = cur_obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp24); if (cur_obj_find_nearby_held_actor(bhvUnused20E0, 1000.0f) != NULL) { if (o->oSubAction == 0) { cur_obj_init_animation_with_sound(0); o->oForwardVel = 10.0f; - if (800.0f < cur_obj_lateral_dist_from_mario_to_home()) + if (cur_obj_lateral_dist_from_mario_to_home() > 800.0f) { o->oSubAction = 1; + } cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400); } else { o->oForwardVel = 0.0f; cur_obj_init_animation_with_sound(3); - if (cur_obj_lateral_dist_from_mario_to_home() < 700.0f) + if (cur_obj_lateral_dist_from_mario_to_home() < 700.0f) { o->oSubAction = 0; + } } } else { o->oForwardVel = 0.0f; cur_obj_init_animation_with_sound(3); } + if (sp1C != NULL && sp24 < 300.0f && sp1C->oHeldState != HELD_FREE) { o->oAction = 1; - sp1C->oSmallPenguinUnk88 = 1; + sp1C->oSmallPenguinUnk88 = TRUE; o->prevObj = sp1C; } } void tuxies_mother_act_1(void) { - s32 sp2C; - s32 sp28; - s32 dialogID; switch (o->oSubAction) { case 0: cur_obj_init_animation_with_sound(3); if (!cur_obj_is_mario_on_platform()) { - sp2C = (o->oBehParams >> 0x10) & 0xFF; - sp28 = (o->prevObj->oBehParams >> 0x10) & 0xFF; - if (sp2C == sp28) + s32 sp2C = (o->oBehParams >> 16) & 0xFF; + s32 sp28 = (o->prevObj->oBehParams >> 16) & 0xFF; + s32 dialogID; + + if (sp2C == sp28) { dialogID = DIALOG_058; - else + } else { dialogID = DIALOG_059; + } if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, dialogID)) { - if (dialogID == DIALOG_058) + if (dialogID == DIALOG_058) { o->oSubAction = 1; - else + } else { o->oSubAction = 2; + } o->prevObj->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY; } - } else + } else { cur_obj_init_animation_with_sound(0); + } break; + case 1: if (o->prevObj->oHeldState == HELD_FREE) { //! This line is was almost certainly supposed to be something @@ -85,6 +93,7 @@ void tuxies_mother_act_1(void) { o->oAction = 2; } break; + case 2: if (o->prevObj->oHeldState == HELD_FREE) { //! Same bug as above @@ -97,43 +106,52 @@ void tuxies_mother_act_1(void) { } void tuxies_mother_act_0(void) { - s32 sp2C; + s32 sp2C = FALSE; f32 sp28; - struct Object *sp24; - sp2C = 0; - sp24 = cur_obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp28); + struct Object *sp24 = cur_obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp28); + cur_obj_scale(4.0f); cur_obj_init_animation_with_sound(3); - if (sp28 < 500.0f) - sp2C = 1; + + if (sp28 < 500.0f) { + sp2C = TRUE; + } + if (sp24 != NULL && sp28 < 300.0f && sp24->oHeldState != HELD_FREE) { o->oAction = 1; - sp24->oSmallPenguinUnk88 = 1; + sp24->oSmallPenguinUnk88 = TRUE; o->prevObj = sp24; } else { switch (o->oSubAction) { case 0: - if (cur_obj_can_mario_activate_textbox_2(300.0f, 100.0f)) - if (sp2C == 0) - o->oSubAction++; + if (cur_obj_can_mario_activate_textbox_2(300.0f, 100.0f) && !sp2C) { + o->oSubAction++; + } break; case 1: if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, - DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_057)) + DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_057)) { o->oSubAction++; + } break; case 2: - if (o->oDistanceToMario > 450.0f) + if (o->oDistanceToMario > 450.0f) { o->oSubAction = 0; + } break; } } - if (cur_obj_check_anim_frame(1)) + + if (cur_obj_check_anim_frame(1)) { cur_obj_play_sound_2(SOUND_OBJ_BIG_PENGUIN_YELL); + } } -void (*sTuxiesMotherActions[])(void) = { tuxies_mother_act_0, tuxies_mother_act_1, - tuxies_mother_act_2 }; +void (*sTuxiesMotherActions[])(void) = { + tuxies_mother_act_0, + tuxies_mother_act_1, + tuxies_mother_act_2, +}; void bhv_tuxies_mother_loop(void) { o->activeFlags |= ACTIVE_FLAG_UNK10; @@ -152,39 +170,46 @@ void small_penguin_dive_with_mario(void) { } void small_penguin_act_2(void) { - s32 sp1C = 0; - if (o->oTimer == 0) - if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f) - sp1C = 1; + s32 sp1C = FALSE; + + if (o->oTimer == 0 + && cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f) { + sp1C = TRUE; + } cur_obj_init_animation_with_sound(0); o->oForwardVel = o->oSmallPenguinUnk104 + 3.0f; cur_obj_rotate_yaw_toward(o->oAngleToMario + 0x8000, o->oSmallPenguinUnk110 + 0x600); - if (o->oDistanceToMario > o->oSmallPenguinUnk108 + 500.0f) + if (o->oDistanceToMario > o->oSmallPenguinUnk108 + 500.0f) { o->oAction = 0; + } small_penguin_dive_with_mario(); - if (sp1C) + if (sp1C) { o->oAction = 5; + } } void small_penguin_act_1(void) { cur_obj_init_animation_with_sound(0); o->oForwardVel = o->oSmallPenguinUnk104 + 3.0f; cur_obj_rotate_yaw_toward(o->oAngleToMario, o->oSmallPenguinUnk110 + 0x600); - if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f) + if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f) { o->oAction = 0; - if (o->oDistanceToMario > 1100.0f) + } + if (o->oDistanceToMario > 1100.0f) { o->oAction = 0; + } small_penguin_dive_with_mario(); } void small_penguin_act_3(void) { if (o->oTimer > 5) { - if (o->oTimer == 6) + if (o->oTimer == 6) { cur_obj_play_sound_2(SOUND_OBJ_BABY_PENGUIN_DIVE); + } cur_obj_init_animation_with_sound(1); - if (o->oTimer > 25) - if (!mario_is_dive_sliding()) - o->oAction = 4; + if (o->oTimer > 25 && !mario_is_dive_sliding()) { + o->oAction = 4; + } } } @@ -192,63 +217,78 @@ void small_penguin_act_4(void) { if (o->oTimer > 20) { o->oForwardVel = 0.0f; cur_obj_init_animation_with_sound(2); - if (o->oTimer > 40) + if (o->oTimer > 40) { o->oAction = o->oSmallPenguinUnk100; + } } } void small_penguin_act_0(void) { - s32 sp1C; + s32 sp1C = FALSE; - sp1C = 0; cur_obj_init_animation_with_sound(3); if (o->oTimer == 0) { o->oSmallPenguinUnk110 = (s32)(random_float() * 0x400); o->oSmallPenguinUnk108 = random_float() * 100.0f; o->oSmallPenguinUnk104 = random_float(); o->oForwardVel = 0.0f; - if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f) - sp1C = 1; + if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f) { + sp1C = TRUE; + } } - if (o->oDistanceToMario < 1000.0f && o->oSmallPenguinUnk108 + 600.0f < o->oDistanceToMario) + if (o->oDistanceToMario < 1000.0f && o->oDistanceToMario > o->oSmallPenguinUnk108 + 600.0f) { o->oAction = 1; - else if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f) + } else if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f) { o->oAction = 2; - if (sp1C) + } + if (sp1C) { o->oAction = 5; - if (cur_obj_mario_far_away()) + } + if (cur_obj_mario_far_away()) { cur_obj_set_pos_to_home(); + } } void small_penguin_act_5(void) { f32 sp24; s16 sp22; struct Object *sp1C = cur_obj_nearest_object_with_behavior(bhvTuxiesMother); + if (sp1C != NULL) { - if (o->oDistanceToMario < 1000.0f) + if (o->oDistanceToMario < 1000.0f) { o->oForwardVel = 2.0f; - else + } else { o->oForwardVel = 0.0f; + } + sp24 = dist_between_objects(o, sp1C); sp22 = obj_angle_to_object(o, sp1C); - if (sp24 > 200.0f) + + if (sp24 > 200.0f) { cur_obj_rotate_yaw_toward(sp22, 0x400); - else + } else { cur_obj_rotate_yaw_toward(sp22 + 0x8000, 0x400); + } + cur_obj_init_animation_with_sound(0); } + small_penguin_dive_with_mario(); } void (*sSmallPenguinActions[])(void) = { - small_penguin_act_0, small_penguin_act_1, small_penguin_act_2, - small_penguin_act_3, small_penguin_act_4, small_penguin_act_5 + small_penguin_act_0, + small_penguin_act_1, + small_penguin_act_2, + small_penguin_act_3, + small_penguin_act_4, + small_penguin_act_5, }; void small_penguin_free_actions(void) { - if (o->oSmallPenguinUnk88 != 0) { + if (o->oSmallPenguinUnk88) { o->oAction = 5; - o->oSmallPenguinUnk88 = 0; + o->oSmallPenguinUnk88 = FALSE; } cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sSmallPenguinActions); @@ -263,15 +303,17 @@ void bhv_small_penguin_loop(void) { break; case HELD_HELD: cur_obj_unrender_set_action_and_anim(0, 0); - if (cur_obj_has_behavior(bhvPenguinBaby)) + if (cur_obj_has_behavior(bhvPenguinBaby)) { obj_set_behavior(o, bhvSmallPenguin); + } obj_copy_pos(o, gMarioObject); - if (gGlobalTimer % 30 == 0) + if (gGlobalTimer % 30 == 0) { #ifndef VERSION_JP play_sound(SOUND_OBJ2_BABY_PENGUIN_YELL, gMarioObject->header.gfx.cameraToObject); #else play_sound(SOUND_OBJ2_BABY_PENGUIN_YELL, o->header.gfx.cameraToObject); #endif + } break; case HELD_THROWN: cur_obj_get_thrown_or_placed(0, 0, 0); @@ -286,33 +328,34 @@ void bhv_small_penguin_loop(void) { * 4 is unused, and is the eye state seen in Shoshinkai 1995 footage. */ Gfx *geo_switch_tuxie_mother_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) { - struct Object *obj; - struct GraphNodeSwitchCase *switchCase; - s32 timer; - if (run == TRUE) { - obj = (struct Object *) gCurGraphNodeObject; - switchCase = (struct GraphNodeSwitchCase *) node; + struct Object *obj = (struct Object *) gCurGraphNodeObject; + struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node; + s32 timer; + switchCase->selectedCase = 0; // timer logic for blinking. uses cases 0-2. timer = gGlobalTimer % 50; - if (timer < 43) + if (timer < 43) { switchCase->selectedCase = 0; - else if (timer < 45) + } else if (timer < 45) { switchCase->selectedCase = 1; - else if (timer < 47) + } else if (timer < 47) { switchCase->selectedCase = 2; - else + } else { switchCase->selectedCase = 1; + } /** make Tuxie's Mother have angry eyes if Mario takes the correct baby * after giving it back. The easiest way to check this is to see if she's * moving, since she only does when she's chasing Mario. */ - if (segmented_to_virtual(bhvTuxiesMother) == obj->behavior) - if (obj->oForwardVel > 5.0f) + if (obj->behavior == segmented_to_virtual(bhvTuxiesMother)) { + if (obj->oForwardVel > 5.0f) { switchCase->selectedCase = 3; + } + } } return NULL; } diff --git a/src/game/behaviors/tweester.inc.c b/src/game/behaviors/tweester.inc.c index 67ad5f2d..8bd28c63 100644 --- a/src/game/behaviors/tweester.inc.c +++ b/src/game/behaviors/tweester.inc.c @@ -1,3 +1,4 @@ + /** * Behavior file for bhvTweester and bhvTweesterSandParticle * Tweester swaps between twhree action- an idle action, a chasing @@ -25,11 +26,11 @@ void tweester_scale_and_move(f32 preScale) { s16 dYaw = 0x2C00; f32 scale = preScale * 0.4; - o->header.gfx.scale[0] + o->header.gfx.scale[0] = (( coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.3 + 1.0) * scale; - o->header.gfx.scale[1] + o->header.gfx.scale[1] = ((-coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.5 + 0.5) * scale; - o->header.gfx.scale[2] + o->header.gfx.scale[2] = (( coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.3 + 1.0) * scale; o->oTweesterScaleTimer += 0x200; @@ -46,21 +47,23 @@ void tweester_act_idle(void) { if (o->oSubAction == TWEESTER_SUB_ACT_WAIT) { cur_obj_become_tangible(); cur_obj_set_pos_to_home(); - cur_obj_scale(0); + cur_obj_scale(0.0f); // Hard to have any idea of this purpose, only set here. o->oTweesterUnused = 0; // If Mario is within range, change to the growth sub-action. - if (o->oDistanceToMario < 1500.0f) + if (o->oDistanceToMario < 1500.0f) { o->oSubAction++; + } o->oTimer = 0; } else { cur_obj_play_sound_1(SOUND_ENV_WIND1); tweester_scale_and_move(o->oTimer / 60.0f); - if (o->oTimer > 59) + if (o->oTimer >= 60) { o->oAction = TWEESTER_ACT_CHASE; + } } } @@ -81,22 +84,26 @@ void tweester_act_chase(void) { cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200); print_debug_top_down_objectinfo("off ", 0); - if (gMarioStates[0].action == ACT_TWIRLING) + if (gMarioStates[0].action == ACT_TWIRLING) { o->oSubAction++; + } } else { o->oForwardVel = 20.0f; cur_obj_rotate_yaw_toward(o->oAngleToHome, 0x200); - if (cur_obj_lateral_dist_to_home() < 200.0f) + if (cur_obj_lateral_dist_to_home() < 200.0f) { o->oAction = TWEESTER_ACT_HIDE; + } } - if (o->oDistanceToMario > 3000.0f) + if (o->oDistanceToMario > 3000.0f) { o->oAction = TWEESTER_ACT_HIDE; + } cur_obj_update_floor_and_walls(); - if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) + if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) { o->oMoveAngleYaw = o->oWallAngle; + } cur_obj_move_standard(60); tweester_scale_and_move(1.0f); @@ -110,19 +117,25 @@ void tweester_act_chase(void) { void tweester_act_hide(void) { f32 shrinkTimer = 60.0f - o->oTimer; - if (shrinkTimer >= 0.0f) + if (shrinkTimer >= 0.0f) { tweester_scale_and_move(shrinkTimer / 60.0f); - else { + } else { cur_obj_become_intangible(); - if (cur_obj_lateral_dist_from_mario_to_home() > 2500.0f) + if (cur_obj_lateral_dist_from_mario_to_home() > 2500.0f) { o->oAction = TWEESTER_ACT_IDLE; - if (o->oTimer > 360) + } + if (o->oTimer > 360) { o->oAction = TWEESTER_ACT_IDLE; + } } } // Array of Tweester action functions. -void (*sTweesterActions[])(void) = { tweester_act_idle, tweester_act_chase, tweester_act_hide }; +void (*sTweesterActions[])(void) = { + tweester_act_idle, + tweester_act_chase, + tweester_act_hide, +}; /** * Loop behavior for Tweester. @@ -151,6 +164,7 @@ void bhv_tweester_sand_particle_loop(void) { o->oFaceAngleYaw = random_u16(); } - if (o->oTimer > 15) + if (o->oTimer > 15) { obj_mark_for_deletion(o); + } } diff --git a/src/game/behaviors/ukiki.inc.c b/src/game/behaviors/ukiki.inc.c index fc5d00c9..ffc3e2d5 100644 --- a/src/game/behaviors/ukiki.inc.c +++ b/src/game/behaviors/ukiki.inc.c @@ -1,4 +1,3 @@ -// ukiki.c.inc /** * @file Contains behavior for the ukiki objects. @@ -27,10 +26,9 @@ void handle_cap_ukiki_reset(void) { * the cap ukiki. */ s32 is_cap_ukiki_and_mario_has_normal_cap_on_head(void) { - if (o->oBehParams2ndByte == UKIKI_CAP) { - if (does_mario_have_normal_cap_on_head(gMarioState)) { - return TRUE; - } + if (o->oBehParams2ndByte == UKIKI_CAP + && does_mario_have_normal_cap_on_head(gMarioState)) { + return TRUE; } return FALSE; @@ -41,11 +39,10 @@ s32 is_cap_ukiki_and_mario_has_normal_cap_on_head(void) { */ Gfx *geo_update_projectile_pos_from_parent_copy(s32 run,UNUSED struct GraphNode *node, Mat4 mtx) { Mat4 mtx2; - struct Object* obj; if (run == TRUE) { // TODO: change global type to Object pointer - obj = (struct Object*)gCurGraphNodeObject; + struct Object *obj = (struct Object *) gCurGraphNodeObject; if (obj->prevObj != NULL) { create_transformation_from_matrices(mtx2, mtx, *gCurGraphNodeCamera->matrixPtr); @@ -74,7 +71,7 @@ void idle_ukiki_taunt(void) { } // Switch goes from 1-4. - switch(o->oSubAction) { + switch (o->oSubAction) { case UKIKI_SUB_ACT_TAUNT_ITCH: cur_obj_init_animation_with_sound(UKIKI_ANIM_ITCH); @@ -127,8 +124,8 @@ void ukiki_act_idle(void) { if (is_cap_ukiki_and_mario_has_normal_cap_on_head()) { if (o->oDistanceToMario > 700.0f && o->oDistanceToMario < 1000.0f) { o->oAction = UKIKI_ACT_RUN; - } else if (o->oDistanceToMario <= 700.0f && 200.0f < o->oDistanceToMario) { - if (abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) > 0x1000) { + } else if (o->oDistanceToMario <= 700.0f && o->oDistanceToMario > 200.0f) { + if (abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) > 0x1000) { o->oAction = UKIKI_ACT_TURN_TO_MARIO; } } @@ -174,7 +171,7 @@ void ukiki_act_idle(void) { * Only used for the cap ukiki. */ void ukiki_act_return_home(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; cur_obj_init_animation_with_sound(UKIKI_ANIM_RUN); o->oMoveAngleYaw = cur_obj_angle_to_home(); @@ -232,7 +229,7 @@ void ukiki_act_turn_to_mario(void) { o->oAction = UKIKI_ACT_IDLE; } - if (is_cap_ukiki_and_mario_has_normal_cap_on_head()){ + if (is_cap_ukiki_and_mario_has_normal_cap_on_head()) { if (o->oDistanceToMario > 500.0f) { o->oAction = UKIKI_ACT_RUN; } @@ -272,18 +269,15 @@ void ukiki_act_run(void) { o->oAction = UKIKI_ACT_TURN_TO_MARIO; } - if (fleeMario) { - if (o->oDistanceToMario < 200.0f) { - if((o->oMoveFlags & OBJ_MOVE_HIT_WALL) && - is_mario_moving_fast_or_in_air(10)) { - o->oAction = UKIKI_ACT_JUMP; - o->oMoveAngleYaw = o->oWallAngle; - } else if((o->oMoveFlags & OBJ_MOVE_HIT_EDGE)) { - if (is_mario_moving_fast_or_in_air(10)) { - o->oAction = UKIKI_ACT_JUMP; - o->oMoveAngleYaw += 0x8000; - } - } + if (fleeMario && o->oDistanceToMario < 200.0f) { + if ((o->oMoveFlags & OBJ_MOVE_HIT_WALL) + && is_mario_moving_fast_or_in_air(10)) { + o->oAction = UKIKI_ACT_JUMP; + o->oMoveAngleYaw = o->oWallAngle; + } else if ((o->oMoveFlags & OBJ_MOVE_HIT_EDGE) + && is_mario_moving_fast_or_in_air(10)) { + o->oAction = UKIKI_ACT_JUMP; + o->oMoveAngleYaw += 0x8000; } } } @@ -300,7 +294,7 @@ void ukiki_act_jump(void) { if (o->oTimer == 0) { cur_obj_set_y_vel_and_animation(random_float() * 10.0f + 45.0f, UKIKI_ANIM_JUMP); } else if (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_AT_WATER_SURFACE - | OBJ_MOVE_UNDERWATER_ON_GROUND)) { + | OBJ_MOVE_UNDERWATER_ON_GROUND)) { o->oSubAction++; o->oVelY = 0.0f; } @@ -338,7 +332,7 @@ static Trajectory sCageUkikiPath[] = { * our death. Ukiki is a tad suicidal. */ void ukiki_act_go_to_cage(void) { - struct Object* obj; + struct Object *obj; f32 latDistToCage = 0.0f; s16 yawToCage = 0; obj = cur_obj_nearest_object_with_behavior(bhvUkikiCageChild); @@ -354,7 +348,7 @@ void ukiki_act_go_to_cage(void) { o->oFlags |= OBJ_FLAG_ACTIVE_FROM_AFAR; // Switch goes from 0-7 in order. - switch(o->oSubAction) { + switch (o->oSubAction) { case UKIKI_SUB_ACT_CAGE_RUN_TO_CAGE: cur_obj_init_animation_with_sound(UKIKI_ANIM_RUN); @@ -377,7 +371,7 @@ void ukiki_act_go_to_cage(void) { if (cur_obj_can_mario_activate_textbox(200.0f, 30.0f, 0x7FFF)) { o->oSubAction++; // fallthrough } else { - break; + break; } case UKIKI_SUB_ACT_CAGE_TALK_TO_MARIO: @@ -491,7 +485,7 @@ void ukiki_free_loop(void) { cur_obj_move_standard(steepSlopeAngleDegrees); handle_cap_ukiki_reset(); - if(!(o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER)) { + if (!(o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER)) { exec_anim_sound_state(sUkikiSoundStates); } } @@ -515,7 +509,7 @@ UNUSED static void ukiki_blink_timer(void) { */ void cage_ukiki_held_loop(void) { if (o->oPosY - o->oHomeY > -100.0f) { - switch(o->oUkikiTextState) { + switch (o->oUkikiTextState) { case UKIKI_TEXT_DEFAULT: if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_SPEAK) { create_dialog_box_with_response(DIALOG_079); @@ -559,12 +553,13 @@ void cage_ukiki_held_loop(void) { * Called by the main behavior function for the cap ukiki whenever it is held. */ void cap_ukiki_held_loop(void) { - switch(o->oUkikiTextState) { + switch (o->oUkikiTextState) { case UKIKI_TEXT_DEFAULT: if (mario_lose_cap_to_enemy(2)) { o->oUkikiTextState = UKIKI_TEXT_STEAL_CAP; o->oUkikiHasCap |= UKIKI_CAP_ON; - } else {} + } else { + } break; case UKIKI_TEXT_STEAL_CAP: @@ -598,11 +593,10 @@ void cap_ukiki_held_loop(void) { * Initializatation for ukiki, determines if it has Mario's cap. */ void bhv_ukiki_init(void) { - if (o->oBehParams2ndByte == UKIKI_CAP) { - if (save_file_get_flags() & SAVE_FLAG_CAP_ON_UKIKI) { - o->oUkikiTextState = UKIKI_TEXT_HAS_CAP; - o->oUkikiHasCap |= UKIKI_CAP_ON; - } + if ((o->oBehParams2ndByte == UKIKI_CAP) + && (save_file_get_flags() & SAVE_FLAG_CAP_ON_UKIKI)) { + o->oUkikiTextState = UKIKI_TEXT_HAS_CAP; + o->oUkikiHasCap |= UKIKI_CAP_ON; } } @@ -611,7 +605,7 @@ void bhv_ukiki_init(void) { * dependent on the held state and whick ukiki it is (cage or cap). */ void bhv_ukiki_loop(void) { - switch(o->oHeldState) { + switch (o->oHeldState) { case HELD_FREE: //! @bug (PARTIAL_UPDATE) o->oUkikiTextboxTimer = 0; @@ -642,6 +636,7 @@ void bhv_ukiki_loop(void) { } o->oInteractStatus = 0; + print_debug_bottom_up("mode %d\n", o->oAction); print_debug_bottom_up("action %d\n", o->oHeldState); } diff --git a/src/game/behaviors/ukiki_cage.inc.c b/src/game/behaviors/ukiki_cage.inc.c index 2acce450..206268d1 100644 --- a/src/game/behaviors/ukiki_cage.inc.c +++ b/src/game/behaviors/ukiki_cage.inc.c @@ -1,4 +1,3 @@ -// ukiki_cage.c.inc /** * @file Contains behavior for the ukiki's cage @@ -20,9 +19,9 @@ void bhv_ukiki_cage_star_loop(void) { // Initialization to see if the star is collected (blue) or not (yellow). if (o->oTimer == 0) { if (bit_shift_left(1) - & save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1)) { - cur_obj_set_model(MODEL_TRANSPARENT_STAR); - } + & save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum))) { + cur_obj_set_model(MODEL_TRANSPARENT_STAR); + } } obj_copy_pos(o, o->parentObj); @@ -33,10 +32,11 @@ void bhv_ukiki_cage_star_loop(void) { o->oAction++; } break; + case UKIKI_CAGE_STAR_ACT_SPAWN_STAR: obj_mark_for_deletion(o); spawn_mist_particles(); - spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 0.7, 3); + spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 0.7f, 3); spawn_default_star(2500.0f, -1200.0f, 1300.0f); break; } @@ -94,8 +94,10 @@ void ukiki_cage_act_hide(void) { * An array of the cage's actions. */ void (*sUkikiCageActions[])(void) = { - ukiki_cage_act_wait_for_ukiki, ukiki_cage_act_spin, - ukiki_cage_act_fall, ukiki_cage_act_hide, + ukiki_cage_act_wait_for_ukiki, + ukiki_cage_act_spin, + ukiki_cage_act_fall, + ukiki_cage_act_hide, }; /** diff --git a/src/game/behaviors/unagi.inc.c b/src/game/behaviors/unagi.inc.c index df9041e9..33f37609 100644 --- a/src/game/behaviors/unagi.inc.c +++ b/src/game/behaviors/unagi.inc.c @@ -47,13 +47,11 @@ void unagi_act_1_4(s32 arg0) { if (cur_obj_check_anim_frame(30)) { o->oForwardVel = 40.0f; } - } else { - if (cur_obj_check_if_at_animation_end()) { - if (o->oAction != arg0 && (o->oPathedPrevWaypointFlags & 0xFF) >= 7) { - cur_obj_init_animation_with_sound(3); - } else { - cur_obj_init_animation_with_sound(2); - } + } else if (cur_obj_check_if_at_animation_end()) { + if (o->oAction != arg0 && (o->oPathedPrevWaypointFlags & 0xFF) >= 7) { + cur_obj_init_animation_with_sound(3); + } else { + cur_obj_init_animation_with_sound(2); } } @@ -61,7 +59,7 @@ void unagi_act_1_4(s32 arg0) { cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER); } - if (cur_obj_follow_path(0) == -1) { + if (cur_obj_follow_path(0) == PATH_REACHED_END) { o->oAction = arg0; } @@ -140,13 +138,13 @@ void unagi_act_3(void) { } void bhv_unagi_loop(void) { - s32 val04; + s32 i; if (o->oUnagiUnk1B2 == 0) { o->oUnagiUnk1AC = 99999.0f; if (o->oDistanceToMario < 3000.0f) { - for (val04 = -4; val04 < 4; val04++) { - spawn_object_relative(val04, 0, 0, 0, o, MODEL_NONE, bhvUnagiSubobject); + for (i = -4; i < 4; i++) { + spawn_object_relative(i, 0, 0, 0, o, MODEL_NONE, bhvUnagiSubobject); } o->oUnagiUnk1B2 = 1; } @@ -173,12 +171,10 @@ void bhv_unagi_loop(void) { } void bhv_unagi_subobject_loop(void) { - f32 val04; - if (o->parentObj->oUnagiUnk1B2 == 0) { obj_mark_for_deletion(o); } else { - val04 = 300.0f * o->oBehParams2ndByte; + f32 val04 = 300.0f * o->oBehParams2ndByte; o->oPosY = o->parentObj->oPosY - val04 * sins(o->parentObj->oFaceAnglePitch) * 1.13f; diff --git a/src/game/behaviors/unused_particle_spawn.inc.c b/src/game/behaviors/unused_particle_spawn.inc.c index 2e22855d..0370e2da 100644 --- a/src/game/behaviors/unused_particle_spawn.inc.c +++ b/src/game/behaviors/unused_particle_spawn.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvUnusedParticleSpawn. * diff --git a/src/game/behaviors/unused_poundable_platform.inc.c b/src/game/behaviors/unused_poundable_platform.inc.c index 0e2feb08..f4c96442 100644 --- a/src/game/behaviors/unused_poundable_platform.inc.c +++ b/src/game/behaviors/unused_poundable_platform.inc.c @@ -1,3 +1,4 @@ + /** * Behavior for bhvUnusedPoundablePlatform. * @@ -24,5 +25,6 @@ void bhv_unused_poundable_platform(void) { } else if (o->oTimer > 7) { obj_mark_for_deletion(o); } + load_object_collision_model(); } diff --git a/src/game/behaviors/warp.inc.c b/src/game/behaviors/warp.inc.c index 107af849..0e910186 100644 --- a/src/game/behaviors/warp.inc.c +++ b/src/game/behaviors/warp.inc.c @@ -1,32 +1,36 @@ -// warp.c.inc +// warp.inc.c void bhv_warp_loop(void) { - u16 sp6; if (o->oTimer == 0) { - sp6 = (o->oBehParams >> 24) & 0xFF; - if (sp6 == 0) + u16 sp6 = (o->oBehParams >> 24) & 0xFF; + + if (sp6 == 0) { o->hitboxRadius = 50.0f; - else if (sp6 == 0xFF) + } else if (sp6 == 0xFF) { o->hitboxRadius = 10000.0f; - else + } else { o->hitboxRadius = sp6 * 10.0; + } o->hitboxHeight = 50.0f; } + o->oInteractStatus = 0; } -void bhv_fading_warp_loop() // identical to the above function except for o->hitboxRadius -{ - u16 sp6; +// identical to the above function except for o->hitboxRadius +void bhv_fading_warp_loop() { if (o->oTimer == 0) { - sp6 = (o->oBehParams >> 24) & 0xFF; - if (sp6 == 0) + u16 sp6 = (o->oBehParams >> 24) & 0xFF; + + if (sp6 == 0) { o->hitboxRadius = 85.0f; - else if (sp6 == 0xFF) + } else if (sp6 == 0xFF) { o->hitboxRadius = 10000.0f; - else + } else { o->hitboxRadius = sp6 * 10.0; + } o->hitboxHeight = 50.0f; } + o->oInteractStatus = 0; } diff --git a/src/game/behaviors/water_bomb.inc.c b/src/game/behaviors/water_bomb.inc.c index 41333803..889ca462 100644 --- a/src/game/behaviors/water_bomb.inc.c +++ b/src/game/behaviors/water_bomb.inc.c @@ -30,16 +30,15 @@ static struct ObjectHitbox sWaterBombHitbox = { */ void bhv_water_bomb_spawner_update(void) { f32 latDistToMario; - f32 spawnerRadius; + f32 spawnerRadius = 50 * (u16)(o->oBehParams >> 16) + 200.0f; - spawnerRadius = 50 * (u16)(o->oBehParams >> 16) + 200.0f; latDistToMario = lateral_dist_between_objects(o, gMarioObject); // When mario is in range and a water bomb isn't already active if (!o->oWaterBombSpawnerBombActive && latDistToMario < spawnerRadius && gMarioObject->oPosY - o->oPosY < 1000.0f) { if (o->oWaterBombSpawnerTimeToSpawn != 0) { - o->oWaterBombSpawnerTimeToSpawn -= 1; + o->oWaterBombSpawnerTimeToSpawn--; } else { struct Object *waterBomb = spawn_object_relative(0, 0, 2000, 0, o, MODEL_WATER_BOMB, bhvWaterBomb); @@ -68,7 +67,7 @@ void bhv_water_bomb_spawner_update(void) { * Spawn particles when the water bomb explodes. */ void water_bomb_spawn_explode_particles(s8 offsetY, s8 forwardVelRange, s8 velYBase) { - static struct SpawnParticlesInfo sWaterBombExplodeParticles = { + static struct SpawnParticlesInfo waterBombExplodeParticles = { /* behParam: */ 0, /* count: */ 5, /* model: */ MODEL_BUBBLE, @@ -83,10 +82,11 @@ void water_bomb_spawn_explode_particles(s8 offsetY, s8 forwardVelRange, s8 velYB /* sizeRange: */ 10.0f, }; - sWaterBombExplodeParticles.offsetY = offsetY; - sWaterBombExplodeParticles.forwardVelRange = forwardVelRange; - sWaterBombExplodeParticles.velYBase = velYBase; - cur_obj_spawn_particles(&sWaterBombExplodeParticles); + waterBombExplodeParticles.offsetY = offsetY; + waterBombExplodeParticles.forwardVelRange = forwardVelRange; + waterBombExplodeParticles.velYBase = velYBase; + + cur_obj_spawn_particles(&waterBombExplodeParticles); } /** @@ -175,8 +175,7 @@ static void water_bomb_act_explode(void) { * Despawn after 100 frames. */ static void water_bomb_act_shot_from_cannon(void) { - - static struct SpawnParticlesInfo sWaterBombCannonParticle = { + static struct SpawnParticlesInfo waterBombCannonParticle = { /* behParam: */ 0, /* count: */ 1, /* model: */ MODEL_BUBBLE, @@ -198,7 +197,7 @@ static void water_bomb_act_shot_from_cannon(void) { if (o->oTimer == 1) { water_bomb_spawn_explode_particles(-20, 10, 30); } - cur_obj_spawn_particles(&sWaterBombCannonParticle); + cur_obj_spawn_particles(&waterBombCannonParticle); } if (o->header.gfx.scale[1] > 1.2f) { diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c index 8e9ba33b..a2134821 100644 --- a/src/game/behaviors/water_bomb_cannon.inc.c +++ b/src/game/behaviors/water_bomb_cannon.inc.c @@ -1,8 +1,6 @@ // water_bomb_cannon.inc.c void bhv_bubble_cannon_barrel_loop(void) { - struct Object *val04; - if (o->parentObj->oAction == 2) { obj_mark_for_deletion(o); } else { @@ -20,12 +18,14 @@ void bhv_bubble_cannon_barrel_loop(void) { // check this if (o->parentObj->oWaterCannonUnkF4 != 0) { if (o->oForwardVel == 0.0f) { + struct Object *waterBomb; + o->oForwardVel = 35.0f; - val04 = spawn_object(o, MODEL_WATER_BOMB, bhvWaterBomb); - if (val04 != NULL) { - val04->oForwardVel = -100.0f; - val04->header.gfx.scale[1] = 1.7f; + waterBomb = spawn_object(o, MODEL_WATER_BOMB, bhvWaterBomb); + if (waterBomb != NULL) { + waterBomb->oForwardVel = -100.0f; + waterBomb->header.gfx.scale[1] = 1.7f; } set_camera_shake_from_point(SHAKE_POS_MEDIUM, o->oPosX, o->oPosY, o->oPosZ); @@ -52,18 +52,18 @@ void water_bomb_cannon_act_1(void) { o->oAction = 2; } else if (o->oBehParams2ndByte == 0) { if (o->oWaterCannonUnkF4 != 0) { - o->oWaterCannonUnkF4 -= 1; + o->oWaterCannonUnkF4--; } else { obj_move_pitch_approach(o->oWaterCannonUnkFC, 0x80); obj_face_yaw_approach(o->oWaterCannonUnk100, 0x100); if ((s16) o->oFaceAngleYaw == (s16) o->oWaterCannonUnk100) { if (o->oWaterCannonUnkF8 != 0) { - o->oWaterCannonUnkF8 -= 1; + o->oWaterCannonUnkF8--; } else { cur_obj_play_sound_2(SOUND_OBJ_CANNON4); o->oWaterCannonUnkF4 = 70; - o->oWaterCannonUnkFC = 0x1000 + 0x400 * (random_u16() & 0x3); + o->oWaterCannonUnkFC = 0x1000 + 0x400 * (random_u16() & 0x03); o->oWaterCannonUnk100 = -0x2000 + o->oMoveAngleYaw + 0x1000 * (random_u16() % 5); o->oWaterCannonUnkF8 = 60; } diff --git a/src/game/behaviors/water_mist.inc.c b/src/game/behaviors/water_mist.inc.c index 64d25c77..a11fd24a 100644 --- a/src/game/behaviors/water_mist.inc.c +++ b/src/game/behaviors/water_mist.inc.c @@ -1,4 +1,4 @@ -// water_mist.c.inc +// water_mist.inc.c // TODO: there is confusion with the earlier mist file. Clarify? void bhv_water_mist_2_loop(void) { diff --git a/src/game/behaviors/water_mist_particle.inc.c b/src/game/behaviors/water_mist_particle.inc.c index cb9243ae..d3b10ddf 100644 --- a/src/game/behaviors/water_mist_particle.inc.c +++ b/src/game/behaviors/water_mist_particle.inc.c @@ -1,21 +1,25 @@ -// water_mist_particle.c.inc +// water_mist_particle.inc.c // TODO: Is this really "mist"? void bhv_water_mist_spawn_loop(void) { - clear_particle_flags(0x20000); + clear_particle_flags(ACTIVE_PARTICLE_BREATH); spawn_object(o, MODEL_MIST, bhvWaterMist); } void bhv_water_mist_loop(void) { - f32 sp1C; + f32 scale; + if (o->oTimer == 0) { o->oMoveAngleYaw = gMarioObject->oMoveAngleYaw; obj_translate_xz_random(o, 10.0f); } + cur_obj_move_using_fvel_and_gravity(); o->oOpacity -= 42; - sp1C = (254 - o->oOpacity) / 254.0 * 1.0 + 0.5; // seen this before - cur_obj_scale(sp1C); - if (o->oOpacity < 2) + scale = (254 - o->oOpacity) / 254.0 * 1.0 + 0.5; // seen this before + cur_obj_scale(scale); + + if (o->oOpacity < 2) { obj_mark_for_deletion(o); + } } diff --git a/src/game/behaviors/water_objs.inc.c b/src/game/behaviors/water_objs.inc.c index e907e93e..67128100 100644 --- a/src/game/behaviors/water_objs.inc.c +++ b/src/game/behaviors/water_objs.inc.c @@ -1,4 +1,4 @@ -// water_objs.c.inc +// water_objs.inc.c // TODO: Better name, please void bhv_water_air_bubble_init(void) { @@ -9,9 +9,11 @@ void bhv_water_air_bubble_init(void) { void bhv_water_air_bubble_loop(void) { s32 i; + o->header.gfx.scale[0] = sins(o->oWaterObjUnkF4) * 0.5 + 4.0; o->header.gfx.scale[1] = -sins(o->oWaterObjUnkF4) * 0.5 + 4.0; o->oWaterObjUnkF4 += 0x400; + if (o->oTimer < 30) { cur_obj_become_intangible(); o->oPosY += 3.0f; @@ -21,16 +23,22 @@ void bhv_water_air_bubble_loop(void) { o->oMoveAngleYaw = obj_angle_to_object(o, gMarioObject); cur_obj_move_using_fvel_and_gravity(); } + o->oPosX += random_float() * 4.0f - 2.0f; o->oPosZ += random_float() * 4.0f - 2.0f; + if (o->oInteractStatus & INT_STATUS_INTERACTED || o->oTimer > 200) { cur_obj_play_sound_2(SOUND_GENERAL_QUIET_BUBBLE); obj_mark_for_deletion(o); - for (i = 0; i < 30; i++) + for (i = 0; i < 30; i++) { spawn_object(o, MODEL_BUBBLE, bhvBubbleMaybe); + } } - if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY) + + if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY) { obj_mark_for_deletion(o); + } + o->oInteractStatus = 0; } @@ -48,6 +56,7 @@ void bhv_bubble_maybe_loop(void) { o->oPosY += random_float() * 3.0f + 6.0f; o->oPosX += random_float() * 10.0f - 5.0f; o->oPosZ += random_float() * 10.0f - 5.0f; + o->header.gfx.scale[0] = sins(o->oWaterObjUnkF4) * 0.2 + 1.0; o->oWaterObjUnkF4 += o->oWaterObjUnkFC; o->header.gfx.scale[1] = sins(o->oWaterObjUnkF8) * 0.2 + 1.0; @@ -56,18 +65,23 @@ void bhv_bubble_maybe_loop(void) { void bhv_small_water_wave_loop(void) { f32 sp1C = find_water_level(o->oPosX, o->oPosZ); + o->header.gfx.scale[0] = sins(o->oWaterObjUnkF4) * 0.2 + 1.0; o->oWaterObjUnkF4 += o->oWaterObjUnkFC; o->header.gfx.scale[1] = sins(o->oWaterObjUnkF8) * 0.2 + 1.0; o->oWaterObjUnkF8 += o->oWaterObjUnk100; + if (o->oPosY > sp1C) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oPosY += 5.0f; - if (gFreeObjectList.next != NULL) + if (gFreeObjectList.next != NULL) { spawn_object(o, MODEL_SMALL_WATER_SPLASH, bhvObjectWaterSplash); + } } - if (o->oInteractStatus & INT_STATUS_INTERACTED) + + if (o->oInteractStatus & INT_STATUS_INTERACTED) { obj_mark_for_deletion(o); + } } void scale_bubble_sin(void) { @@ -89,7 +103,7 @@ void bhv_particle_loop() { o->oPosY += 5.0f; obj_translate_xz_random(o, 4.0f); scale_bubble_sin(); - if (o->oPosY > sp24 && o->oTimer) { + if (o->oPosY > sp24 && o->oTimer != 0) { obj_mark_for_deletion(o); try_to_spawn_object(5, 0, o, MODEL_SMALL_WATER_SPLASH, bhvObjectWaterSplash); } @@ -102,13 +116,14 @@ void bhv_small_bubbles_loop(void) { } void bhv_fish_group_loop(void) { - if (gMarioCurrentRoom == 15 || gMarioCurrentRoom == 7) - if (gGlobalTimer & 1) - spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticleBubbles); + if ((gMarioCurrentRoom == 15 || gMarioCurrentRoom == 7) && (gGlobalTimer & 1)) { + spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticleBubbles); + } } void bhv_water_waves_init(void) { - s32 sp1C; - for (sp1C = 0; sp1C < 3; sp1C++) + s32 i; + for (i = 0; i < 3; i++) { spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticle); + } } diff --git a/src/game/behaviors/water_pillar.inc.c b/src/game/behaviors/water_pillar.inc.c index bd414724..2cb9f464 100644 --- a/src/game/behaviors/water_pillar.inc.c +++ b/src/game/behaviors/water_pillar.inc.c @@ -1,7 +1,8 @@ -// water_pillar.c.inc +// water_pillar.inc.c void water_level_pillar_undrained(void) { struct Object *otherWaterPillar; + switch (o->oAction) { case 0: if (cur_obj_is_mario_ground_pounding_platform()) { @@ -9,30 +10,35 @@ void water_level_pillar_undrained(void) { spawn_mist_particles(); } break; + case 1: - if (o->oTimer < 4) + if (o->oTimer < 4) { o->oPosY -= 20.0f; - else + } else { o->oAction++; + } break; + case 2: otherWaterPillar = cur_obj_nearest_object_with_behavior(bhvWaterLevelPillar); if (otherWaterPillar != NULL) { - if (otherWaterPillar->oAction < 2) + if (otherWaterPillar->oAction < 2) { o->oAction++; + } } break; + case 3: otherWaterPillar = cur_obj_nearest_object_with_behavior(bhvWaterLevelPillar); if (otherWaterPillar != NULL) { if (otherWaterPillar->oAction > 1) { o->oAction++; - save_file_set_flags(SAVE_FLAG_MOAT_DRAINED); play_puzzle_jingle(); } } break; + case 4: cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN); if (o->oTimer < 300) { @@ -43,9 +49,11 @@ void water_level_pillar_undrained(void) { #if ENABLE_RUMBLE reset_rumble_timers_2(2); #endif - } else + } else { o->oAction++; + } break; + case 5: break; } @@ -60,15 +68,17 @@ void water_level_pillar_drained(void) { } void bhv_water_level_pillar_init(void) { - if (save_file_get_flags() & SAVE_FLAG_MOAT_DRAINED) - o->oWaterLevelPillarDrained = 1; + if (save_file_get_flags() & SAVE_FLAG_MOAT_DRAINED) { + o->oWaterLevelPillarDrained = TRUE; + } } void bhv_water_level_pillar_loop(void) { - if (o->oWaterLevelPillarDrained) + if (o->oWaterLevelPillarDrained) { water_level_pillar_drained(); - else + } else { water_level_pillar_undrained(); + } gEnvironmentRegions[18] = gEnvironmentLevels[2]; gEnvironmentRegions[6] = gEnvironmentLevels[0]; } diff --git a/src/game/behaviors/water_ring.inc.c b/src/game/behaviors/water_ring.inc.c index 68aab7b6..22dcce74 100644 --- a/src/game/behaviors/water_ring.inc.c +++ b/src/game/behaviors/water_ring.inc.c @@ -1,4 +1,4 @@ -// water_ring.c.inc +// water_ring.inc.c f32 water_ring_calc_mario_dist(void) { f32 marioDistX = o->oPosX - gMarioObject->header.gfx.pos[0]; @@ -41,23 +41,20 @@ void bhv_jet_stream_water_ring_init(void) { o->oFaceAnglePitch = 0x8000; } -// sp28 = arg0 -// sp2c = ringManager - void water_ring_check_collection(f32 avgScale, struct Object *ringManager) { f32 marioDistInFront = water_ring_calc_mario_dist(); - struct Object *ringSpawner; if (!is_point_close_to_object(o, gMarioObject->header.gfx.pos[0], - gMarioObject->header.gfx.pos[1] + 80.0f, gMarioObject->header.gfx.pos[2], - (avgScale + 0.2) * 120.0)) { + gMarioObject->header.gfx.pos[1] + 80.0f, + gMarioObject->header.gfx.pos[2], (avgScale + 0.2) * 120.0)) { o->oWaterRingMarioDistInFront = marioDistInFront; return; } - if (o->oWaterRingMarioDistInFront * marioDistInFront < 0) { - ringSpawner = o->parentObj; - if (ringSpawner) { + if (o->oWaterRingMarioDistInFront * marioDistInFront < 0.0f) { + struct Object *ringSpawner = o->parentObj; + + if (ringSpawner != NULL) { if ((o->oWaterRingIndex == ringManager->oWaterRingMgrLastRingCollected + 1) || (ringSpawner->oWaterRingSpawnerRingsCollected == 0)) { ringSpawner->oWaterRingSpawnerRingsCollected++; @@ -67,14 +64,14 @@ void water_ring_check_collection(f32 avgScale, struct Object *ringManager) { play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); #else play_sound(SOUND_MENU_COLLECT_SECRET - + (((u8) ringSpawner->oWaterRingSpawnerRingsCollected - 1) << 16), + + (((u8) ringSpawner->oWaterRingSpawnerRingsCollected - 1) << 16), gGlobalSoundSource); #endif } - ringManager->oWaterRingMgrLastRingCollected = o->oWaterRingIndex; - } else + } else { ringSpawner->oWaterRingSpawnerRingsCollected = 0; + } } o->oAction = WATER_RING_ACT_COLLECTED; @@ -95,12 +92,14 @@ void water_ring_set_scale(f32 avgScale) { void water_ring_act_collected(void) { f32 avgScale = (f32) o->oTimer * 0.2 + o->oWaterRingAvgScale; - if (o->oTimer >= 21) + if (o->oTimer > 20) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } o->oOpacity -= 10; - if (o->oOpacity < 0) + if (o->oOpacity < 0) { o->oOpacity = 0; + } water_ring_set_scale(avgScale); } @@ -113,10 +112,11 @@ void water_ring_act_not_collected(void) { struct Object *ringSpawner = o->parentObj; struct Object *ringManager = ringSpawner->parentObj; - if (o->oTimer >= 226) { + if (o->oTimer > 225) { o->oOpacity -= 2; - if (o->oOpacity < 3) + if (o->oOpacity < 3) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } water_ring_check_collection(avgScale, ringManager); @@ -127,8 +127,9 @@ void water_ring_act_not_collected(void) { set_object_visibility(o, 5000); if (ringSpawner->oWaterRingSpawnerRingsCollected == 4 - && o->oWaterRingIndex == ringManager->oWaterRingMgrLastRingCollected + 1) + && o->oWaterRingIndex == ringManager->oWaterRingMgrLastRingCollected + 1) { o->oOpacity = sins(o->oTimer * 0x1000) * 200.0f + 50.0f; + } o->oWaterRingAvgScale = avgScale; } @@ -155,20 +156,22 @@ void water_ring_spawner_act_inactive(void) { // from the Manta Ray, which spawns rings but also has a Ring Manager object as its // parent. The Jet Stream Ring Spawner functions as both a spawner and a Ring Manager. struct Object *currentObj = o->parentObj; - struct Object *waterRing; //! Because the index counter overflows at 10000, it's possible to wait // for about 4 hours and 38 minutes if you miss a ring, and the index will // come around again. - if (o->oTimer == 300) + if (o->oTimer == 300) { o->oTimer = 0; + } + if ((o->oTimer == 0) || (o->oTimer == 50) || (o->oTimer == 150) || (o->oTimer == 200) || (o->oTimer == 250)) { - waterRing = spawn_object(o, MODEL_WATER_RING, bhvJetStreamWaterRing); + struct Object *waterRing = spawn_object(o, MODEL_WATER_RING, bhvJetStreamWaterRing); waterRing->oWaterRingIndex = currentObj->oWaterRingMgrNextRingIndex; currentObj->oWaterRingMgrNextRingIndex++; - if (currentObj->oWaterRingMgrNextRingIndex >= 10001) + if (currentObj->oWaterRingMgrNextRingIndex > 10000) { currentObj->oWaterRingMgrNextRingIndex = 0; + } } } @@ -179,9 +182,7 @@ void bhv_jet_stream_ring_spawner_loop(void) { if (o->oWaterRingSpawnerRingsCollected == 5) { spawn_mist_particles(); - spawn_default_star(3400.0f, -3200.0f, -500.0f); - o->oAction = JS_RING_SPAWNER_ACT_INACTIVE; } break; @@ -197,17 +198,19 @@ void bhv_manta_ray_water_ring_init(void) { } void manta_water_ring_act_not_collected(void) { - f32 avgScale = (f32) o->oTimer / 50.0f * 1.3 + 0.1; + f32 avgScale = (f32) o->oTimer / 50 * 1.3 + 0.1; struct Object *ringSpawner = o->parentObj; struct Object *ringManager = ringSpawner->parentObj; - if (avgScale > 1.3) + if (avgScale > 1.3) { avgScale = 1.3; + } - if (o->oTimer >= 151) { + if (o->oTimer > 150) { o->oOpacity -= 2; - if (o->oOpacity < 3) + if (o->oOpacity < 3) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } water_ring_check_collection(avgScale, ringManager); @@ -215,8 +218,9 @@ void manta_water_ring_act_not_collected(void) { set_object_visibility(o, 5000); if (ringSpawner->oWaterRingSpawnerRingsCollected == 4 - && o->oWaterRingIndex == ringManager->oWaterRingMgrLastRingCollected + 1) + && o->oWaterRingIndex == ringManager->oWaterRingMgrLastRingCollected + 1) { o->oOpacity = sins(o->oTimer * 0x1000) * 200.0f + 50.0f; + } o->oWaterRingAvgScale = avgScale; } diff --git a/src/game/behaviors/water_splashes_and_waves.inc.c b/src/game/behaviors/water_splashes_and_waves.inc.c index de512d51..89948910 100644 --- a/src/game/behaviors/water_splashes_and_waves.inc.c +++ b/src/game/behaviors/water_splashes_and_waves.inc.c @@ -1,4 +1,4 @@ -// water_splashes_and_waves.c.inc +// water_splashes_and_waves.inc.c // Water droplets from Mario jumping in a pool of water. struct WaterDropletParams sWaterSplashDropletParams = { @@ -48,23 +48,27 @@ struct WaterDropletParams gShallowWaterWaveDropletParams = { void bhv_water_splash_spawn_droplets(void) { s32 i; - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oPosY = find_water_level(o->oPosX, o->oPosZ); + } - if (o->oPosY > FLOOR_LOWER_LIMIT_MISC) // Make sure it is not at the default water level - for (i = 0; i < 3; i++) + if (o->oPosY > FLOOR_LOWER_LIMIT_MISC) { // Make sure it is not at the default water level + for (i = 0; i < 3; i++) { spawn_water_droplet(o, &sWaterSplashDropletParams); + } + } } void bhv_water_droplet_loop(void) { - UNUSED u32 unusedVar; + UNUSED u8 filler[4]; f32 waterLevel = find_water_level(o->oPosX, o->oPosZ); if (o->oTimer == 0) { - if (cur_obj_has_model(MODEL_FISH)) + if (cur_obj_has_model(MODEL_FISH)) { o->header.gfx.node.flags &= ~GRAPH_RENDER_BILLBOARD; - else + } else { o->header.gfx.node.flags |= GRAPH_RENDER_BILLBOARD; + } o->oFaceAngleYaw = random_u16(); } // Apply gravity @@ -76,18 +80,20 @@ void bhv_water_droplet_loop(void) { // Create the smaller splash try_to_spawn_object(0, 1.0f, o, MODEL_SMALL_WATER_SPLASH, bhvWaterDropletSplash); obj_mark_for_deletion(o); - } else if (o->oTimer > 20) + } else if (o->oTimer > 20) { obj_mark_for_deletion(o); + } } - if (waterLevel < FLOOR_LOWER_LIMIT_MISC) + if (waterLevel < FLOOR_LOWER_LIMIT_MISC) { obj_mark_for_deletion(o); + } } void bhv_idle_water_wave_loop(void) { obj_copy_pos(o, gMarioObject); o->oPosY = gMarioStates[0].waterLevel + 5; if (!(gMarioObject->oMarioParticleFlags & ACTIVE_PARTICLE_IDLE_WATER_WAVE)) { - gMarioObject->oActiveParticleFlags &= (u16)~ACTIVE_PARTICLE_IDLE_WATER_WAVE; + gMarioObject->oActiveParticleFlags &= (u16) ~ACTIVE_PARTICLE_IDLE_WATER_WAVE; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -103,11 +109,9 @@ void bhv_bubble_splash_init(void) { } void bhv_shallow_water_splash_init(void) { - struct Object *fishObj; // Have a 1 in 256 chance to spawn the fish particle easter egg. - if ((random_u16() & 0xFF) <= 0) // Strange - { - fishObj = spawn_water_droplet(o, &sWaterDropletFishParams); + if ((random_u16() & 0xFF) <= 0) { // Strange + struct Object *fishObj = spawn_water_droplet(o, &sWaterDropletFishParams); obj_init_animation_with_sound(fishObj, blue_fish_seg3_anims_0301C2B0, 0); } } @@ -115,18 +119,20 @@ void bhv_shallow_water_splash_init(void) { void bhv_wave_trail_shrink(void) { f32 waterLevel = find_water_level(o->oPosX, o->oPosZ); // Destroy every other water wave to space them out (this is a terrible way of doing it) - if (o->oTimer == 0) - if (gGlobalTimer & 1) - obj_mark_for_deletion(o); + if ((o->oTimer == 0) && (gGlobalTimer & 1)) { + obj_mark_for_deletion(o); + } o->oPosY = waterLevel + 5.0f; - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oWaveTrailSize = o->header.gfx.scale[0]; + } if (o->oAnimState > 3) { o->oWaveTrailSize = o->oWaveTrailSize - 0.1; // Shrink the wave - if (o->oWaveTrailSize < 0.0f) + if (o->oWaveTrailSize < 0.0f) { o->oWaveTrailSize = 0.0f; + } o->header.gfx.scale[0] = o->oWaveTrailSize; o->header.gfx.scale[2] = o->oWaveTrailSize; } diff --git a/src/game/behaviors/water_wave.inc.c b/src/game/behaviors/water_wave.inc.c index 4fae68d9..cc4b4e04 100644 --- a/src/game/behaviors/water_wave.inc.c +++ b/src/game/behaviors/water_wave.inc.c @@ -1,4 +1,4 @@ -// water_wave.c.inc +// water_wave.inc.c // TODO: Rename to avoid confusion with water_splashes_and_waves void bhv_object_water_wave_init(void) { @@ -7,6 +7,7 @@ void bhv_object_water_wave_init(void) { void bhv_object_water_wave_loop(void) { s32 globalTimer = gGlobalTimer; - if ((globalTimer % 16) == 0) + if (globalTimer % 16 == 0) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } diff --git a/src/game/behaviors/wdw_water_level.inc.c b/src/game/behaviors/wdw_water_level.inc.c index c077ee2c..3b43a793 100644 --- a/src/game/behaviors/wdw_water_level.inc.c +++ b/src/game/behaviors/wdw_water_level.inc.c @@ -1,15 +1,16 @@ -// wdw_water_level.c.inc +// wdw_water_level.inc.c // called when WDW is loaded. void bhv_init_changing_water_level_loop(void) { - if (gCurrentObject->oAction == 0) { - if (gEnvironmentRegions != NULL) - gCurrentObject->oAction++; - } else if (gCurrentObject->oTimer < 10) - *gEnvironmentLevels = gEnvironmentRegions[6]; - else { - gEnvironmentRegions[6] = *gEnvironmentLevels + sins(o->oWaterLevelTriggerUnkF4) * 20.0f; - gCurrentObject->oWaterLevelTriggerUnkF4 += 0x200; + if (o->oAction == 0) { + if (gEnvironmentRegions != NULL) { + o->oAction++; + } + } else if (o->oTimer < 10) { + gEnvironmentLevels[0] = gEnvironmentRegions[6]; + } else { + gEnvironmentRegions[6] = gEnvironmentLevels[0] + sins(o->oWaterLevelTriggerUnkF4) * 20.0f; + o->oWaterLevelTriggerUnkF4 += 0x200; } } @@ -19,34 +20,37 @@ void bhv_water_level_diamond_loop(void) { case WATER_LEVEL_DIAMOND_ACT_INIT: o->oFaceAngleYaw = 0; o->oWaterLevelTriggerTargetWaterLevel = (s32) o->oPosY; - if (o->oTimer > 10) + if (o->oTimer > 10) { o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_IDLE - break; - case WATER_LEVEL_DIAMOND_ACT_IDLE: - if (obj_check_if_collided_with_object(o, gMarioObject)) { - if (gWDWWaterLevelChanging == 0) { - o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL - gWDWWaterLevelChanging = 1; - } } break; + + case WATER_LEVEL_DIAMOND_ACT_IDLE: + if (obj_check_if_collided_with_object(o, gMarioObject) && !gWDWWaterLevelChanging) { + o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL + gWDWWaterLevelChanging = TRUE; + } + break; + case WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL: o->oAngleVelYaw = 0; - *gEnvironmentLevels = (s32) approach_f32_symmetric( - (f32) *gEnvironmentLevels, (f32) o->oWaterLevelTriggerTargetWaterLevel, 10.0f); - if (*gEnvironmentLevels == o->oWaterLevelTriggerTargetWaterLevel) { - if ((s16) o->oFaceAngleYaw == 0) + gEnvironmentLevels[0] = (s32) approach_f32_symmetric( + (f32) gEnvironmentLevels[0], (f32) o->oWaterLevelTriggerTargetWaterLevel, 10.0f); + if (gEnvironmentLevels[0] == o->oWaterLevelTriggerTargetWaterLevel) { + if ((s16) o->oFaceAngleYaw == 0) { o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING - else + } else { o->oAngleVelYaw = 0x800; + } } else { - if (o->oTimer == 0) + if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_WATER_LEVEL_TRIG); - else { - if (*gEnvironmentLevels > o->oWaterLevelTriggerTargetWaterLevel) + } else { + if (gEnvironmentLevels[0] > o->oWaterLevelTriggerTargetWaterLevel) { cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN); - else + } else { cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN); // same as above + } } o->oAngleVelYaw = 0x800; #if ENABLE_RUMBLE @@ -54,14 +58,16 @@ void bhv_water_level_diamond_loop(void) { #endif } break; + case WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING: if (!obj_check_if_collided_with_object(o, gMarioObject)) { - gWDWWaterLevelChanging = 0; + gWDWWaterLevelChanging = FALSE; o->oAction = WATER_LEVEL_DIAMOND_ACT_IDLE; o->oAngleVelYaw = 0; } break; } + o->oFaceAngleYaw += o->oAngleVelYaw; } } diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c index 405e0518..84a5105d 100644 --- a/src/game/behaviors/whirlpool.inc.c +++ b/src/game/behaviors/whirlpool.inc.c @@ -1,4 +1,4 @@ -// whirlpool.c.inc +// whirlpool.inc.c static struct ObjectHitbox sWhirlpoolHitbox = { /* interactType: */ INTERACT_WHIRLPOOL, @@ -51,7 +51,7 @@ void bhv_whirlpool_loop(void) { whirpool_orient_graph(); - o->oFaceAngleYaw += 0x1F40; + o->oFaceAngleYaw += 8000; } else { o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; gEnvFxBubbleConfig[ENVFX_STATE_PARTICLECOUNT] = 0; @@ -68,8 +68,9 @@ void bhv_jet_stream_loop(void) { gEnvFxBubbleConfig[ENVFX_STATE_SRC_X] = o->oPosX; gEnvFxBubbleConfig[ENVFX_STATE_SRC_Y] = o->oPosY; gEnvFxBubbleConfig[ENVFX_STATE_SRC_Z] = o->oPosZ; - } else + } else { gEnvFxBubbleConfig[ENVFX_STATE_PARTICLECOUNT] = 0; + } cur_obj_play_sound_1(SOUND_ENV_WATER); } diff --git a/src/game/behaviors/white_puff.inc.c b/src/game/behaviors/white_puff.inc.c index 5bd7872d..55512ea3 100644 --- a/src/game/behaviors/white_puff.inc.c +++ b/src/game/behaviors/white_puff.inc.c @@ -1,20 +1,25 @@ -// white_puff.c.inc +// white_puff.inc.c void bhv_white_puff_1_loop(void) { f32 sp1C = 0.1f; f32 sp18 = 0.5f; + if (o->oTimer == 0) { obj_translate_xz_random(o, 40.0f); o->oPosY += 30.0f; } + cur_obj_scale(o->oTimer * sp18 + sp1C); o->oOpacity = 50; cur_obj_move_using_fvel_and_gravity(); - if (o->oTimer > 4) + + if (o->oTimer > 4) { obj_mark_for_deletion(o); + } } void bhv_white_puff_2_loop(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { obj_translate_xz_random(o, 40.0f); + } } diff --git a/src/game/behaviors/white_puff_explode.inc.c b/src/game/behaviors/white_puff_explode.inc.c index 510058ad..8b153da5 100644 --- a/src/game/behaviors/white_puff_explode.inc.c +++ b/src/game/behaviors/white_puff_explode.inc.c @@ -1,7 +1,6 @@ -// white_puff_explode.c.inc +// white_puff_explode.inc.c void bhv_white_puff_exploding_loop(void) { - f32 sp24; if (o->oTimer == 0) { cur_obj_compute_vel_xz(); o->oWhitePuffUnkF4 = o->header.gfx.scale[0]; @@ -18,20 +17,29 @@ void bhv_white_puff_exploding_loop(void) { break; } } + cur_obj_move_using_vel_and_gravity(); cur_obj_apply_drag_xz(o->oDragStrength); - if (o->oVelY > 100.0f) + + if (o->oVelY > 100.0f) { o->oVelY = 100.0f; - if (o->oTimer > 20) + } + + if (o->oTimer > 20) { obj_mark_for_deletion(o); + } + if (o->oOpacity) { + f32 scale; o->oOpacity += o->oWhitePuffUnkF8; - if (o->oOpacity < 2) + if (o->oOpacity < 2) { obj_mark_for_deletion(o); - if (o->oWhitePuffUnkFC) - sp24 = o->oWhitePuffUnkF4 * ((254 - o->oOpacity) / 254.0); - else - sp24 = o->oWhitePuffUnkF4 * (o->oOpacity / 254.0); - cur_obj_scale(sp24); + } + if (o->oWhitePuffUnkFC) { + scale = o->oWhitePuffUnkF4 * ((254 - o->oOpacity) / 254.0); + } else { + scale = o->oWhitePuffUnkF4 * (o->oOpacity / 254.0); + } + cur_obj_scale(scale); } } diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index b8ab613a..fe39da7c 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -1,8 +1,9 @@ -// whomp.c.inc +// whomp.inc.c void whomp_play_sfx_from_pound_animation(void) { UNUSED s32 animFrame = o->header.gfx.animInfo.animFrame; - s32 playSound = 0; + s32 playSound = FALSE; + if (o->oForwardVel < 5.0f) { playSound = cur_obj_check_anim_frame(0); playSound |= cur_obj_check_anim_frame(23); @@ -10,13 +11,16 @@ void whomp_play_sfx_from_pound_animation(void) { playSound = cur_obj_check_anim_frame_in_range(0, 3); playSound |= cur_obj_check_anim_frame_in_range(23, 3); } - if (playSound) + + if (playSound) { cur_obj_play_sound_2(SOUND_OBJ_POUNDING1); + } } void whomp_init(void) { cur_obj_init_animation_with_accel_and_sound(0, 1.0f); cur_obj_set_pos_to_home(); + if (o->oBehParams2ndByte != 0) { gSecondCameraFocus = o; cur_obj_scale(2.0f); @@ -29,10 +33,13 @@ void whomp_init(void) { o->oHealth = 3; } } else if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, - DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_114)) + DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_114)) { o->oAction = 2; - } else if (o->oDistanceToMario < 500.0f) + } + } else if (o->oDistanceToMario < 500.0f) { o->oAction = 1; + } + whomp_play_sfx_from_pound_animation(); } @@ -40,65 +47,70 @@ void whomp_turn(void) { if (o->oSubAction == 0) { o->oForwardVel = 0.0f; cur_obj_init_animation_with_accel_and_sound(0, 1.0f); - if (o->oTimer > 31) + if (o->oTimer > 31) { o->oSubAction++; - else + } else { o->oMoveAngleYaw += 0x400; + } } else { o->oForwardVel = 3.0f; - if (o->oTimer > 42) + if (o->oTimer > 42) { o->oAction = 1; + } } + whomp_play_sfx_from_pound_animation(); } void whomp_patrol(void) { - s16 marioAngle; - f32 distWalked; + s16 marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); + f32 distWalked = cur_obj_lateral_dist_to_home(); f32 patrolDist; - marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); - distWalked = cur_obj_lateral_dist_to_home(); - if (gCurrLevelNum == LEVEL_BITS) + if (gCurrLevelNum == LEVEL_BITS) { patrolDist = 200.0f; - else + } else { patrolDist = 700.0f; + } cur_obj_init_animation_with_accel_and_sound(0, 1.0f); o->oForwardVel = 3.0f; - if (distWalked > patrolDist) + if (distWalked > patrolDist) { o->oAction = 7; - else if (marioAngle < 0x2000) { + } else if (marioAngle < 0x2000) { if (o->oDistanceToMario < 1500.0f) { o->oForwardVel = 9.0f; cur_obj_init_animation_with_accel_and_sound(0, 3.0f); } - if (o->oDistanceToMario < 300.0f) + if (o->oDistanceToMario < 300.0f) { o->oAction = 3; + } } + whomp_play_sfx_from_pound_animation(); } void king_whomp_chase(void) { - s16 marioAngle; cur_obj_init_animation_with_accel_and_sound(0, 1.0f); o->oForwardVel = 3.0f; cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200); if (o->oTimer > 30) { - marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); + s16 marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw); if (marioAngle < 0x2000) { if (o->oDistanceToMario < 1500.0f) { o->oForwardVel = 9.0f; cur_obj_init_animation_with_accel_and_sound(0, 3.0f); } - if (o->oDistanceToMario < 300.0f) + if (o->oDistanceToMario < 300.0f) { o->oAction = 3; + } } } whomp_play_sfx_from_pound_animation(); + if (mario_is_far_below_object(1000.0f)) { o->oAction = 0; stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); @@ -108,13 +120,16 @@ void king_whomp_chase(void) { void whomp_prepare_jump(void) { o->oForwardVel = 0.0f; cur_obj_init_animation_with_accel_and_sound(1, 1.0f); - if (cur_obj_check_if_near_animation_end()) + if (cur_obj_check_if_near_animation_end()) { o->oAction = 4; + } } void whomp_jump(void) { - if (o->oTimer == 0) + if (o->oTimer == 0) { o->oVelY = 40.0f; + } + if (o->oTimer < 8) { } else { o->oAngleVelPitch += 0x100; @@ -129,25 +144,27 @@ void whomp_jump(void) { void whomp_land(void) { if (o->oSubAction == 0 && o->oMoveFlags & OBJ_MOVE_LANDED) { - cur_obj_play_sound_2(SOUND_OBJ_WHOMP_LOWPRIO); + cur_obj_play_sound_2(SOUND_OBJ_WHOMP); cur_obj_shake_screen(SHAKE_POS_SMALL); o->oVelY = 0.0f; o->oSubAction++; } - if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) + + if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) { o->oAction = 6; + } } void king_whomp_on_ground(void) { - Vec3f pos; if (o->oSubAction == 0) { if (cur_obj_is_mario_ground_pounding_platform()) { + Vec3f pos; o->oHealth--; cur_obj_play_sound_2(SOUND_OBJ2_WHOMP_SOUND_SHORT); cur_obj_play_sound_2(SOUND_OBJ_KING_WHOMP_DEATH); - if (o->oHealth == 0) + if (o->oHealth == 0) { o->oAction = 8; - else { + } else { vec3f_copy_2(pos, &o->oPosX); vec3f_copy_2(&o->oPosX, &gMarioObject->oPosX); spawn_mist_particles_variable(0, 0, 100.0f); @@ -160,12 +177,14 @@ void king_whomp_on_ground(void) { o->oWhompShakeVal = 0; } else { if (o->oWhompShakeVal < 10) { - if (o->oWhompShakeVal % 2) + if (o->oWhompShakeVal % 2) { o->oPosY += 8.0f; - else + } else { o->oPosY -= 8.0f; - } else + } + } else { o->oSubAction = 10; + } o->oWhompShakeVal++; } } @@ -182,8 +201,9 @@ void whomp_on_ground(void) { o->oSubAction++; } } - } else if (!cur_obj_is_mario_on_platform()) + } else if (!cur_obj_is_mario_on_platform()) { o->oSubAction = 0; + } } void whomp_on_ground_general(void) { @@ -193,23 +213,24 @@ void whomp_on_ground_general(void) { o->oAngleVelYaw = 0; o->oAngleVelRoll = 0; - if (o->oBehParams2ndByte != 0) + if (o->oBehParams2ndByte != 0) { king_whomp_on_ground(); - else - whomp_on_ground(); - if (o->oTimer > 100 || (gMarioState->action == ACT_SQUISHED && o->oTimer > 30)) - o->oSubAction = 10; - } else { - if (o->oFaceAnglePitch > 0) { - o->oAngleVelPitch = -0x200; - o->oFaceAnglePitch += o->oAngleVelPitch; } else { - o->oAngleVelPitch = 0; - o->oFaceAnglePitch = 0; - if (o->oBehParams2ndByte != 0) - o->oAction = 2; - else - o->oAction = 1; + whomp_on_ground(); + } + if (o->oTimer > 100 || (gMarioState->action == ACT_SQUISHED && o->oTimer > 30)) { + o->oSubAction = 10; + } + } else if (o->oFaceAnglePitch > 0) { + o->oAngleVelPitch = -0x200; + o->oFaceAnglePitch += o->oAngleVelPitch; + } else { + o->oAngleVelPitch = 0; + o->oFaceAnglePitch = 0; + if (o->oBehParams2ndByte != 0) { + o->oAction = 2; + } else { + o->oAction = 1; } } } @@ -239,25 +260,33 @@ void whomp_die(void) { } void king_whomp_stop_music(void) { - if (o->oTimer == 60) + if (o->oTimer == 60) { stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); + } } void (*sWhompActions[])(void) = { - whomp_init, whomp_patrol, king_whomp_chase, whomp_prepare_jump, whomp_jump, - whomp_land, whomp_on_ground_general, whomp_turn, whomp_die, king_whomp_stop_music + whomp_init, + whomp_patrol, + king_whomp_chase, + whomp_prepare_jump, + whomp_jump, + whomp_land, + whomp_on_ground_general, + whomp_turn, whomp_die, + king_whomp_stop_music, }; -// MM void bhv_whomp_loop(void) { cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sWhompActions); cur_obj_move_standard(-20); if (o->oAction != 9) { - if (o->oBehParams2ndByte != 0) + if (o->oBehParams2ndByte != 0) { cur_obj_hide_if_mario_far_away_y(2000.0f); - else + } else { cur_obj_hide_if_mario_far_away_y(1000.0f); + } load_object_collision_model(); } } diff --git a/src/game/behaviors/wiggler.inc.c b/src/game/behaviors/wiggler.inc.c index 9bdc0e1e..5ba10254 100644 --- a/src/game/behaviors/wiggler.inc.c +++ b/src/game/behaviors/wiggler.inc.c @@ -91,8 +91,7 @@ void bhv_wiggler_body_part_update(void) { // the floor o->oPosY += -30.0f; cur_obj_update_floor_height(); - if (o->oFloorHeight > o->oPosY) // TODO: Check ineq swap - { + if (o->oFloorHeight > o->oPosY) { // TODO: Check ineq swap o->oPosY = o->oFloorHeight; } } @@ -117,10 +116,8 @@ void bhv_wiggler_body_part_update(void) { */ void wiggler_init_segments(void) { s32 i; - struct ChainSegment *segments; - struct Object *bodyPart; + struct ChainSegment *segments = mem_pool_alloc(gObjectMemoryPool, 4 * sizeof(struct ChainSegment)); - segments = mem_pool_alloc(gObjectMemoryPool, 4 * sizeof(struct ChainSegment)); if (segments != NULL) { // Each segment represents the global position and orientation of each // object. Segment 0 represents the wiggler's head, and segment i>0 @@ -141,7 +138,7 @@ void wiggler_init_segments(void) { // Spawn each body part for (i = 1; i <= 3; i++) { - bodyPart = + struct Object *bodyPart = spawn_object_relative(i, 0, 0, 0, o, MODEL_WIGGLER_BODY, bhvWigglerBody); if (bodyPart != NULL) { obj_init_animation_with_sound(bodyPart, wiggler_seg5_anims_0500C874, 0); @@ -175,9 +172,7 @@ void wiggler_init_segments(void) { s16 dyaw; f32 dxz; s32 i; - f32 segmentLength; - - segmentLength = 35.0f * o->header.gfx.scale[0]; + f32 segmentLength = 35.0f * o->header.gfx.scale[0]; for (i = 1; i <= 3; i++) { prevBodyPart = &o->oWigglerSegments[i - 1]; @@ -240,7 +235,7 @@ static void wiggler_act_walk(void) { obj_forward_vel_approach(sWigglerSpeeds[o->oHealth - 1], 1.0f); if (o->oWigglerWalkAwayFromWallTimer != 0) { - o->oWigglerWalkAwayFromWallTimer -= 1; + o->oWigglerWalkAwayFromWallTimer--; } else { if (o->oDistanceToMario >= 25000.0f) { // If >1200 away from home, turn to home @@ -256,7 +251,7 @@ static void wiggler_act_walk(void) { if (o->oHealth < 4) { o->oWigglerTargetYaw = o->oAngleToMario; } else if (o->oWigglerTimeUntilRandomTurn != 0) { - o->oWigglerTimeUntilRandomTurn -= 1; + o->oWigglerTimeUntilRandomTurn--; } else { o->oWigglerTargetYaw = o->oMoveAngleYaw + 0x4000 * (s16) random_sign(); o->oWigglerTimeUntilRandomTurn = random_linear_offset(30, 50); diff --git a/src/game/behaviors/wind.inc.c b/src/game/behaviors/wind.inc.c index a1c58dd4..e95acffa 100644 --- a/src/game/behaviors/wind.inc.c +++ b/src/game/behaviors/wind.inc.c @@ -1,4 +1,4 @@ -// wind.c.inc +// wind.inc.c void spawn_wind_particles(s16 pitch, s16 yaw) { s32 i; @@ -11,7 +11,8 @@ void spawn_wind_particles(s16 pitch, s16 yaw) { void bhv_wind_loop(void) { s16 sp2E = 500; - f32 sp28 = 1.0f; + f32 scale = 1.0f; + if (o->oTimer == 0) { o->oOpacity = 100; if (o->oMoveAnglePitch == 0) { @@ -29,10 +30,13 @@ void bhv_wind_loop(void) { o->oForwardVel = 10.0f; } obj_set_billboard(o); - cur_obj_scale(sp28); + cur_obj_scale(scale); } - if (o->oTimer > 8) + + if (o->oTimer > 8) { obj_mark_for_deletion(o); + } + o->oFaceAnglePitch += 4000.0f + 2000.0f * random_float(); o->oFaceAngleYaw += 4000.0f + 2000.0f * random_float(); cur_obj_move_using_fvel_and_gravity(); diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c index 3a56cf8b..461a5a68 100644 --- a/src/game/behaviors/yoshi.inc.c +++ b/src/game/behaviors/yoshi.inc.c @@ -1,4 +1,4 @@ -// yoshi.c.inc +// yoshi.inc.c // X/Z coordinates of Yoshi's homes that he switches between. // Note that this doesn't contain the Y coordinate since the castle roof is flat, @@ -18,21 +18,26 @@ void bhv_yoshi_init(void) { } void yoshi_walk_loop(void) { - UNUSED s16 sp26; - s16 sp24 = o->header.gfx.animInfo.animFrame; + UNUSED s16 collisionFlags; + s16 animFrame = o->header.gfx.animInfo.animFrame; o->oForwardVel = 10.0f; - sp26 = object_step(); + collisionFlags = object_step(); o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oYoshiTargetYaw, 0x500); - if (is_point_close_to_object(o, o->oHomeX, 3174.0f, o->oHomeZ, 200)) + + if (is_point_close_to_object(o, o->oHomeX, 3174.0f, o->oHomeZ, 200)) { o->oAction = YOSHI_ACT_IDLE; + } cur_obj_init_animation(1); - if (sp24 == 0 || sp24 == 15) - cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK); - if (o->oInteractStatus == INT_STATUS_INTERACTED) + if (animFrame == 0 || animFrame == 15) { + cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK); + } + + if (o->oInteractStatus == INT_STATUS_INTERACTED) { o->oAction = YOSHI_ACT_TALK; + } if (o->oPosY < 2100.0f) { create_respawner(MODEL_YOSHI, bhvYoshi, 3000); @@ -42,7 +47,7 @@ void yoshi_walk_loop(void) { void yoshi_idle_loop(void) { s16 chosenHome; - UNUSED s16 sp1C = o->header.gfx.animInfo.animFrame; + UNUSED s16 animFrame = o->header.gfx.animInfo.animFrame; if (o->oTimer > 90) { chosenHome = random_float() * 3.99; @@ -60,8 +65,10 @@ void yoshi_idle_loop(void) { } cur_obj_init_animation(0); - if (o->oInteractStatus == INT_STATUS_INTERACTED) + + if (o->oInteractStatus == INT_STATUS_INTERACTED) { o->oAction = YOSHI_ACT_TALK; + } // Credits; Yoshi appears at this position overlooking the castle near the end of the credits if (gPlayerCameraState->cameraEvent == CAM_EVENT_START_ENDING || @@ -78,7 +85,7 @@ void yoshi_talk_loop(void) { cur_obj_init_animation(0); if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) { o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; - if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_161)) { + if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_161) != 0) { o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oInteractStatus = 0; o->oHomeX = sYoshiHomeLocations[2]; @@ -95,15 +102,18 @@ void yoshi_talk_loop(void) { } void yoshi_walk_and_jump_off_roof_loop(void) { - s16 sp26 = o->header.gfx.animInfo.animFrame; + s16 animFrame = o->header.gfx.animInfo.animFrame; o->oForwardVel = 10.0f; object_step(); cur_obj_init_animation(1); - if (o->oTimer == 0) + + if (o->oTimer == 0) { cutscene_object(CUTSCENE_STAR_SPAWN, o); + } o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oYoshiTargetYaw, 0x500); + if (is_point_close_to_object(o, o->oHomeX, 3174.0f, o->oHomeZ, 200)) { cur_obj_init_animation(2); cur_obj_play_sound_2(SOUND_GENERAL_ENEMY_ALERT1); @@ -113,7 +123,7 @@ void yoshi_walk_and_jump_off_roof_loop(void) { o->oAction = YOSHI_ACT_FINISH_JUMPING_AND_DESPAWN; } - if (sp26 == 0 || sp26 == 15) { + if (animFrame == 0 || animFrame == 15) { cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK); } } @@ -121,7 +131,9 @@ void yoshi_walk_and_jump_off_roof_loop(void) { void yoshi_finish_jumping_and_despawn_loop(void) { cur_obj_extend_animation_if_at_end(); obj_move_xyz_using_fvel_and_yaw(o); + o->oVelY -= 2.0; + if (o->oPosY < 2100.0f) { set_mario_npc_dialog(MARIO_DIALOG_STOP); gObjCutsceneDone = TRUE; @@ -131,7 +143,7 @@ void yoshi_finish_jumping_and_despawn_loop(void) { } void yoshi_give_present_loop(void) { - s32 sp1C = gGlobalTimer; + s32 globalTimer = gGlobalTimer; if (gHudDisplay.lives == 100) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); @@ -140,7 +152,7 @@ void yoshi_give_present_loop(void) { return; } - if ((sp1C & 0x03) == 0) { + if (!(globalTimer & 3)) { play_sound(SOUND_MENU_YOSHI_GAIN_LIVES, gGlobalSoundSource); gMarioState->numLives++; } diff --git a/src/game/camera.c b/src/game/camera.c index e2fb1754..216fe0e3 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -668,7 +668,7 @@ void unused_set_camera_pitch_shake_env(s16 shake) { BAD_RETURN(f32) calc_y_to_curr_floor(f32 *posOff, f32 posMul, f32 posBound, f32 *focOff, f32 focMul, f32 focBound) { f32 floorHeight = sMarioGeometry.currFloorHeight; f32 waterHeight; - UNUSED s32 filler; + UNUSED u8 filler[4]; if (!(sMarioCamState->action & ACT_FLAG_METAL_WATER)) { //! @bug this should use sMarioGeometry.waterHeight @@ -904,11 +904,10 @@ s32 update_radial_camera(struct Camera *c, Vec3f focus, Vec3f pos) { f32 cenDistZ = sMarioCamState->pos[2] - c->areaCenZ; s16 camYaw = atan2s(cenDistZ, cenDistX) + sModeOffsetYaw; s16 pitch = look_down_slopes(camYaw); - UNUSED f32 unused1; + UNUSED u8 filler1[4]; f32 posY; f32 focusY; - UNUSED f32 unused2; - UNUSED f32 unused3; + UNUSED u8 filler2[8]; f32 yOff = 125.f; f32 baseDist = 1000.f; @@ -930,9 +929,7 @@ s32 update_8_directions_camera(struct Camera *c, Vec3f focus, Vec3f pos) { s16 pitch = look_down_slopes(camYaw); f32 posY; f32 focusY; - UNUSED f32 unused1; - UNUSED f32 unused2; - UNUSED f32 unused3; + UNUSED u8 filler[12]; f32 yOff = 125.f; f32 baseDist = 1000.f; @@ -962,7 +959,7 @@ void radial_camera_move(struct Camera *c) { UNUSED s32 unused2 = 0; f32 areaDistX = sMarioCamState->pos[0] - c->areaCenX; f32 areaDistZ = sMarioCamState->pos[2] - c->areaCenZ; - UNUSED s32 filler; + UNUSED u8 filler[4]; // How much the camera's yaw changed s16 yawOffset = calculate_yaw(sMarioCamState->pos, c->pos) - atan2s(areaDistZ, areaDistX); @@ -1144,9 +1141,9 @@ void update_yaw_and_dist_from_c_up(UNUSED struct Camera *c) { */ void mode_radial_camera(struct Camera *c) { Vec3f pos; - UNUSED u8 unused1[8]; + UNUSED u8 filler1[8]; s16 oldAreaYaw = sAreaYaw; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; if (gCameraMovementFlags & CAM_MOVING_INTO_MODE) { update_yaw_and_dist_from_c_up(c); @@ -1174,7 +1171,7 @@ void mode_radial_camera(struct Camera *c) { */ void mode_8_directions_camera(struct Camera *c) { Vec3f pos; - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; s16 oldAreaYaw = sAreaYaw; radial_camera_input(c, 0.f); @@ -1272,7 +1269,7 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { f32 marioFloorDist; Vec3f marioPos; UNUSED u8 filler4[12]; - UNUSED Vec3f unused4; + UNUSED Vec3f unused; Vec3s pathAngle; // Variables for changing to the next/prev path in the list Vec3f oldPos; @@ -1285,9 +1282,9 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { s16 prevYaw; s16 nextYaw; - unused4[0] = 0.f; - unused4[1] = 0.f; - unused4[2] = 0.f; + unused[0] = 0.f; + unused[1] = 0.f; + unused[2] = 0.f; // Store camera pos, for changing between paths vec3f_copy(oldPos, pos); @@ -1682,18 +1679,14 @@ struct UnusedDanceInfo { }; struct UnusedDanceInfo unusedDanceInfo1 = { - {-3026.0f, 912.0f, -2148.0f}, - 600.0f, - 0.3f + { -3026.0f, 912.0f, -2148.0f }, 600.0f, 0.3f }; u32 unusedDanceType = 0; -struct UnusedDanceInfo unusedDanceInfo2 = { - {-4676.0f, 917.0f, -3802.0f}, - 600.0f, - 0.3f -}; +struct UnusedDanceInfo unusedDanceInfo2 = { + { -4676.0f, 917.0f, -3802.0f }, 600.0f, 0.3f +}; /** * Table that dictates camera movement in bookend room. @@ -1737,7 +1730,7 @@ void mode_parallel_tracking_camera(struct Camera *c) { * Fixed camera mode, the camera rotates around a point and looks and zooms toward Mario. */ void mode_fixed_camera(struct Camera *c) { - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; if (gCurrLevelNum == LEVEL_BBH) { set_fov_function(CAM_FOV_BBH); @@ -1756,9 +1749,9 @@ void mode_fixed_camera(struct Camera *c) { * The C-Buttons rotate the camera 90 degrees left/right and 67.5 degrees up/down. */ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) { - UNUSED u8 unused2[12]; + UNUSED u8 filler1[12]; f32 dist; - UNUSED u8 unused3[4]; + UNUSED u8 filler2[4]; s16 absPitch; s16 pitch; s16 yaw; @@ -1767,7 +1760,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) { s16 goalYawOff = 0; s16 yawSpeed; s16 pitchInc = 32; - UNUSED u8 unused[12]; + UNUSED u8 filler3[12]; f32 maxDist = 800.f; f32 focYOff = 125.f; @@ -2065,7 +2058,7 @@ s32 update_mario_camera(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { s16 update_default_camera(struct Camera *c) { Vec3f tempPos; Vec3f cPos; - UNUSED u8 unused1[12]; + UNUSED u8 filler1[12]; struct Surface *marioFloor; struct Surface *cFloor; struct Surface *tempFloor; @@ -2073,7 +2066,7 @@ s16 update_default_camera(struct Camera *c) { f32 camFloorHeight; f32 tempFloorHeight; f32 marioFloorHeight; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; f32 dist; f32 zoomDist; f32 waterHeight; @@ -2088,7 +2081,7 @@ s16 update_default_camera(struct Camera *c) { s16 tempPitch; s16 tempYaw; f32 xzDist; - UNUSED u8 unused4[4]; + UNUSED u8 filler3[4]; s16 nextYawVel; s16 yawVel = 0; f32 scale; @@ -2415,7 +2408,7 @@ void mode_mario_camera(struct Camera *c) { * Rotates the camera around the spiral staircase. */ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { - UNUSED s16 unused1; + UNUSED s16 unused; /// The returned yaw s16 camYaw; // unused @@ -2426,7 +2419,7 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { s16 posPitch; /// The camera's yaw around the stairs s16 posYaw; - UNUSED s32 unused2; + UNUSED u8 filler[4]; Vec3f cPos; Vec3f checkPos; struct Surface *floor; @@ -2731,7 +2724,7 @@ void move_into_c_up(struct Camera *c) { * The main update function for C-Up mode */ s32 mode_c_up_camera(struct Camera *c) { - UNUSED u8 unused[12]; + UNUSED u8 filler[12]; // Play a sound when entering C-Up mode if (!(sCameraSoundFlags & CAM_SOUND_C_UP_PLAYED)) { @@ -2789,7 +2782,7 @@ s32 update_in_cannon(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { * sCannonYOffset is used to make the camera rotate down when Mario has just entered the cannon */ void mode_cannon_camera(struct Camera *c) { - UNUSED u8 unused[24]; + UNUSED u8 filler[24]; sLakituPitch = 0; gCameraMovementFlags &= ~CAM_MOVING_INTO_MODE; @@ -2914,10 +2907,10 @@ void update_lakitu(struct Camera *c) { struct Surface *floor = NULL; Vec3f newPos; Vec3f newFoc; - UNUSED Vec3f unusedVec3f; + UNUSED u8 filler1[12]; f32 distToFloor; s16 newYaw; - UNUSED u8 unused1[8]; + UNUSED u8 filler2[8]; if (gCameraMovementFlags & CAM_MOVE_PAUSE_SCREEN) { } else { @@ -3016,7 +3009,7 @@ void update_lakitu(struct Camera *c) { * Gets controller input, checks for cutscenes, handles mode changes, and moves the camera */ void update_camera(struct Camera *c) { - UNUSED u8 unused[24]; + UNUSED u8 filler[24]; gCamera = c; update_camera_hud_status(c); @@ -3213,7 +3206,7 @@ void update_camera(struct Camera *c) { */ void reset_camera(struct Camera *c) { UNUSED s32 unused = 0; - UNUSED u8 unused1[16]; + UNUSED u8 filler[16]; UNUSED struct LinearTransitionPoint *start = &sModeInfo.transitionStart; UNUSED struct LinearTransitionPoint *end = &sModeInfo.transitionEnd; @@ -3458,11 +3451,11 @@ void init_camera(struct Camera *c) { * modulo-4's the result, because each 8-bit mask only has 4 area bits for each level */ void zoom_out_if_paused_and_outside(struct GraphNodeCamera *camera) { - UNUSED u8 unused1[8]; + UNUSED u8 filler1[8]; UNUSED f32 dist; UNUSED s16 pitch; s16 yaw; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; s32 areaMaskIndex = gCurrLevelArea / 32; s32 areaBit = 1 << (((gCurrLevelArea & 0x10) / 4) + (((gCurrLevelArea & 0xF) - 1) & 3)); @@ -3519,7 +3512,7 @@ void create_camera(struct GraphNodeCamera *gc, struct AllocOnlyPool *pool) { * Copy Lakitu's pos and foc into `gc` */ void update_graph_node_camera(struct GraphNodeCamera *gc) { - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; UNUSED struct Camera *c = gc->config.camera; gc->rollScreen = gLakituState.roll; @@ -3585,7 +3578,7 @@ void evaluate_cubic_spline(f32 u, Vec3f Q, Vec3f a0, Vec3f a1, Vec3f a2, Vec3f a f32 x; f32 y; f32 z; - UNUSED u8 unused[16]; + UNUSED u8 filler[16]; if (u > 1.f) { u = 1.f; @@ -3686,7 +3679,7 @@ s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *s *splineSegment = 0; finished = 1; } - *progress -= 1; + (*progress)--; } return finished; } @@ -3811,7 +3804,7 @@ void shake_camera_handheld(Vec3f pos, Vec3f focus) { f32 dist; s16 pitch; s16 yaw; - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; if (sHandheldShakeMag == 0) { vec3f_set(shakeOffset, 0.f, 0.f, 0.f); @@ -4248,7 +4241,7 @@ f32 camera_approach_f32_symmetric(f32 current, f32 target, f32 increment) { */ void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange) { f32 randomFloat; - UNUSED u8 unused[4]; + UNUSED u8 filler[4]; f32 tempXRange; f32 tempYRange; f32 tempZRange; @@ -4344,7 +4337,7 @@ s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f3 */ s32 calc_avoid_yaw(s16 yawFromMario, s16 wallYaw) { s16 yawDiff; - UNUSED u8 unused[34]; // Debug print buffer? ;) + UNUSED u8 filler[34]; // Debug print buffer? ;) UNUSED s32 unused1 = 0; UNUSED s32 unused2 = 0; @@ -4382,7 +4375,7 @@ s32 is_surf_within_bounding_box(struct Surface *surf, f32 xMax, f32 yMax, f32 zM f32 dx; f32 dy; f32 dz; - UNUSED u8 unused[4]; + UNUSED u8 filler[4]; s32 i; s32 j; // result @@ -4460,7 +4453,7 @@ s32 is_range_behind_surface(Vec3f from, Vec3f to, struct Surface *surf, s16 rang s32 behindSurface = TRUE; s32 leftBehind = 0; s32 rightBehind = 0; - UNUSED u8 unused[20]; + UNUSED u8 filler[20]; f32 checkDist; s16 checkPitch; s16 checkYaw; @@ -4729,7 +4722,7 @@ void shake_camera_yaw(Vec3f pos, Vec3f focus) { * Apply a rotational shake to the camera by adjusting its roll */ void shake_camera_roll(s16 *roll) { - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; if (gLakituState.shakeMagnitude[2] != 0) { increment_shake_offset(&gLakituState.shakeRollPhase, gLakituState.shakeRollVel); @@ -5084,15 +5077,15 @@ s32 determine_dance_cutscene(UNUSED struct Camera *c) { u8 cutscene = 0; u8 cutsceneIndex = 0; u8 starIndex = (gLastCompletedStarNum - 1) / 2; - u8 courseIndex = gCurrCourseNum; + u8 courseNum = gCurrCourseNum; if (starIndex > 3) { starIndex = 0; } - if (courseIndex > COURSE_MAX) { - courseIndex = COURSE_NONE; + if (courseNum > COURSE_MAX) { + courseNum = COURSE_NONE; } - cutsceneIndex = sDanceCutsceneIndexTable[courseIndex][starIndex]; + cutsceneIndex = sDanceCutsceneIndexTable[courseNum][starIndex]; if (gLastCompletedStarNum & 1) { // Odd stars take the lower four bytes @@ -5127,9 +5120,9 @@ u8 open_door_cutscene(u8 pullResult, u8 pushResult) { * @return the cutscene that should start, 0 if none */ u8 get_cutscene_from_mario_status(struct Camera *c) { - UNUSED u8 unused1[4]; + UNUSED u8 filler1[4]; u8 cutscene = c->cutscene; - UNUSED u8 unused2[12]; + UNUSED u8 filler2[12]; if (cutscene == 0) { // A cutscene started by an object, if any, will start if nothing else happened @@ -5408,14 +5401,13 @@ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, s16 pitchVelocity; f32 distVelocity; f32 goalDist; - UNUSED f32 unusedDist; + UNUSED u8 filler1[4]; s16 goalPitch; s16 goalYaw; - UNUSED s16 unusedPitch; - UNUSED s16 unusedYaw; + UNUSED u8 filler2[4]; f32 distTimer = sModeTransition.framesLeft; s16 angleTimer = sModeTransition.framesLeft; - UNUSED s16 inTransition = 0; + UNUSED s16 inTransition = FALSE; Vec3f nextPos; Vec3f nextFoc; Vec3f startPos; @@ -5446,7 +5438,7 @@ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, // Transition from the last mode to the current one if (sModeTransition.framesLeft > 0) { - inTransition = 1; + inTransition = TRUE; vec3f_get_dist_and_angle(curFoc, curPos, &goalDist, &goalPitch, &goalYaw); distVelocity = ABS(goalDist - sModeTransition.posDist) / distTimer; @@ -5703,7 +5695,7 @@ BAD_RETURN(s32) cam_sl_free_roam(struct Camera *c) { * Warps the camera underneath the floor, used in HMC to move under the elevator platforms */ void move_camera_through_floor_while_descending(struct Camera *c, f32 height) { - UNUSED f32 pad; + UNUSED u8 filler[4]; if ((sMarioGeometry.currFloorHeight < height - 100.f) && (sMarioGeometry.prevFloorHeight > sMarioGeometry.currFloorHeight)) { @@ -6089,17 +6081,17 @@ u32 surface_type_modes(struct Camera *c) { switch (sMarioGeometry.currFloorType) { case SURFACE_CLOSE_CAMERA: transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 90); - modeChanged += 1; + modeChanged++; break; case SURFACE_CAMERA_FREE_ROAM: transition_to_camera_mode(c, CAMERA_MODE_FREE_ROAM, 90); - modeChanged += 1; + modeChanged++; break; case SURFACE_NO_CAM_COL_SLIPPERY: transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 90); - modeChanged += 1; + modeChanged++; break; } return modeChanged; @@ -6568,7 +6560,7 @@ s16 camera_course_processing(struct Camera *c) { } } - b += 1; + b++; } } @@ -6600,8 +6592,7 @@ s16 camera_course_processing(struct Camera *c) { case AREA_BBH: // if camera is fixed at bbh_room_13_balcony_camera (but as floats) - if (vec3f_compare(sFixedModeBasePosition, 210.f, 420.f, 3109.f) == 1) - { + if (vec3f_compare(sFixedModeBasePosition, 210.f, 420.f, 3109.f) == TRUE) { if (sMarioCamState->pos[1] < 1800.f) { transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 30); } @@ -6742,24 +6733,24 @@ void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood) { * @return 3 if a wall is covering Mario, 1 if a wall is only near the camera. */ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 yawRange) { - UNUSED f32 unused1; + UNUSED u8 filler1[4]; struct WallCollisionData colData; struct Surface *wall; - UNUSED Vec3f unused2; + UNUSED u8 filler2[12]; f32 dummyDist, checkDist; - UNUSED f32 unused3; + UNUSED u8 filler3[4]; f32 coarseRadius; f32 fineRadius; s16 wallYaw, horWallNorm; - UNUSED s16 unused4; + UNUSED s16 unused; s16 dummyPitch; // The yaw of the vector from Mario to the camera. s16 yawFromMario; - UNUSED s16 unused5; + UNUSED u8 filler4[2]; s32 status = 0; /// The current iteration. The algorithm takes 8 equal steps from Mario back to the camera. s32 step = 0; - UNUSED s32 unused6; + UNUSED u8 filler5[4]; vec3f_get_dist_and_angle(sMarioCamState->pos, cPos, &dummyDist, &dummyPitch, &yawFromMario); sStatusFlags &= ~CAM_FLAG_CAM_NEAR_WALL; @@ -6977,15 +6968,15 @@ void init_spline_point(struct CutsceneSplinePoint *splinePoint, s8 index, u8 spe void copy_spline_segment(struct CutsceneSplinePoint dst[], struct CutsceneSplinePoint src[]) { s32 j = 0; s32 i = 0; - UNUSED s32 pad[2]; + UNUSED u8 filler[8]; init_spline_point(&dst[i], src[j].index, src[j].speed, src[j].point); - i += 1; + i++; do { do { init_spline_point(&dst[i], src[j].index, src[j].speed, src[j].point); - i += 1; - j += 1; + i++; + j++; } while ((src[j].index != -1) && (src[j].index != -1)); //! same comparison performed twice } while (j > 16); @@ -7167,7 +7158,7 @@ static UNUSED void unused_vec3f_to_vec3s(Vec3s dst, Vec3f src) { * Rotate the camera's focus around the camera's position by incYaw and incPitch */ void pan_camera(struct Camera *c, s16 incPitch, s16 incYaw) { - UNUSED Vec3f unused1; + UNUSED u8 filler[12]; f32 distCamToFocus; s16 pitch, yaw; @@ -7782,7 +7773,7 @@ BAD_RETURN(s32) star_dance_bound_yaw(struct Camera *c, s16 absYaw, s16 yawMax) { * Store the camera's focus in cvar9. */ BAD_RETURN(s32) cutscene_dance_closeup_start(struct Camera *c) { - UNUSED s32 pad[2]; + UNUSED u8 filler[8]; if ((gLastCompletedStarNum == 4) && (gCurrCourseNum == COURSE_JRB)) { star_dance_bound_yaw(c, 0x0, 0x4000); @@ -8219,9 +8210,9 @@ BAD_RETURN(s32) cutscene_star_spawn_store_info(struct Camera *c) { * Focus on the top of the star. */ BAD_RETURN(s32) cutscene_star_spawn_focus_star(struct Camera *c) { - UNUSED f32 hMul; + UNUSED u8 filler1[4]; // hMul? Vec3f starPos; - UNUSED f32 vMul; + UNUSED u8 filler2[4]; // vMul? if (gCutsceneFocus != NULL) { object_pos_to_vec3f(starPos, gCutsceneFocus); @@ -8428,7 +8419,7 @@ BAD_RETURN(s32) cutscene_red_coin_star_end(struct Camera *c) { * @param rotYaw constant yaw offset to add to the camera's focus */ void cutscene_goto_cvar_pos(struct Camera *c, f32 goalDist, s16 goalPitch, s16 rotPitch, s16 rotYaw) { - UNUSED f32 unused1; + UNUSED u8 filler[4]; f32 nextDist; s16 nextPitch, nextYaw; // The next 2 polar coord points are only used in CUTSCENE_PREPARE_CANNON @@ -8436,8 +8427,10 @@ void cutscene_goto_cvar_pos(struct Camera *c, f32 goalDist, s16 goalPitch, s16 r s16 cannonPitch, cannonYaw; f32 curDist; s16 curPitch, curYaw; - UNUSED f64 unused2; + UNUSED f64 unused; + vec3f_get_dist_and_angle(sCutsceneVars[3].point, c->pos, &nextDist, &nextPitch, &nextYaw); + // If over 8000 units away from the cannon, just teleport there if ((nextDist > 8000.f) && (c->cutscene == CUTSCENE_PREPARE_CANNON)) { nextDist = goalDist * 4.f; @@ -8696,9 +8689,9 @@ BAD_RETURN(s32) cutscene_suffocation_fly_away(UNUSED struct Camera *c) { * Keep Lakitu above the gas level. */ BAD_RETURN(s32) cutscene_suffocation_stay_above_gas(struct Camera *c) { - UNUSED f32 unused1; + UNUSED u8 filler1[4]; f32 gasLevel; - UNUSED f32 unused2; + UNUSED u8 filler2[4]; cutscene_goto_cvar_pos(c, 400.f, 0x2800, 0x200, 0); gasLevel = find_poison_gas_level(sMarioCamState->pos[0], sMarioCamState->pos[2]); @@ -8748,7 +8741,7 @@ BAD_RETURN(s32) cutscene_enter_pool_start(struct Camera *c) { } BAD_RETURN(s32) cutscene_enter_pool_loop(struct Camera *c) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; cutscene_goto_cvar_pos(c, 1200.f, 0x2000, 0x200, 0); } @@ -8833,7 +8826,7 @@ BAD_RETURN(s32) cutscene_pyramid_top_explode_cam_shake(UNUSED struct Camera *c) * Warp back to the old position, and start a heavy camera shake. */ BAD_RETURN(s32) cutscene_pyramid_top_explode_warp_back(struct Camera *c) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; vec3f_copy(c->pos, sCutsceneVars[4].point); vec3f_copy(c->focus, sCutsceneVars[5].point); @@ -8903,11 +8896,10 @@ UNUSED static void unused_cutscene_goto_cvar(struct Camera *c) { * cvar9.angle[1] is the yaw between Mario and the gCutsceneFocus */ BAD_RETURN(s32) cutscene_dialog_start(struct Camera *c) { - UNUSED f32 unused1; - UNUSED s16 unused2; + UNUSED u8 filler[4]; + UNUSED s16 unused; s16 yaw; - cutscene_soften_music(c); set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG); @@ -9061,7 +9053,7 @@ UNUSED static void unused_cam_to_mario(struct Camera *c) { * Cutscene that plays when Mario is reading a message (a sign or message on the wall) */ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; cutscene_event(cutscene_read_message_start, c, 0, 0); sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -9070,7 +9062,7 @@ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) { // Do nothing until message is gone. case 0: if (get_dialog_id() != DIALOG_NONE) { - sCutsceneVars[0].angle[0] += 1; + sCutsceneVars[0].angle[0]++; set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG); } break; @@ -9128,9 +9120,9 @@ BAD_RETURN(s32) cutscene_exit_succ_start(UNUSED struct Camera *c) { * Set the camera pos depending on which level Mario exited. */ BAD_RETURN(s32) cutscene_non_painting_set_cam_pos(struct Camera *c) { - UNUSED u32 unused1; + UNUSED u8 filler1[4]; struct Surface *floor; - UNUSED Vec3f unused2; + UNUSED u8 filler2[12]; switch (gPrevLevel) { case LEVEL_HMC: @@ -9312,9 +9304,9 @@ BAD_RETURN(s32) cutscene_non_painting_death(struct Camera *c) { * because cvar1 rotates until is reaches 0, so it's important that it's a multiple of 0x100. */ BAD_RETURN(s32) cutscene_cap_switch_press_start(struct Camera *c) { - UNUSED s16 unused1; + UNUSED s16 unused; s16 yaw; - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; store_info_star(c); yaw = calculate_yaw(sMarioCamState->pos, c->pos); @@ -9331,7 +9323,7 @@ BAD_RETURN(s32) cutscene_cap_switch_press_rotate_around_mario(struct Camera *c) f32 dist; s16 pitch, yaw; UNUSED s16 unusedYaw = sMarioCamState->faceAngle[1] + 0x1000; - UNUSED s16 unused; + UNUSED u8 filler[2]; UNUSED s32 cvar1Yaw = sCutsceneVars[1].angle[1]; vec3f_get_dist_and_angle(sMarioCamState->pos, c->pos, &dist, &pitch, &yaw); @@ -9631,7 +9623,7 @@ BAD_RETURN(s32) cutscene_intro_peach_fly_to_pipe(struct Camera *c) { * Lakitu flies around the warp pipe, then Mario jumps out. */ BAD_RETURN(s32) cutscene_intro_peach_mario_appears(struct Camera *c) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; sMarioCamState->cameraEvent = 0; cutscene_event(cutscene_intro_peach_reset_spline, c, 0, 0); @@ -9875,7 +9867,7 @@ BAD_RETURN(s32) cutscene_credits(struct Camera *c) { //! Checks if the "Snowman's Lost His Head" star was collected. The credits likely would //! have avoided the snowman if the player didn't collect that star, but in the end the //! developers decided against it. - if (save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1) & 0x10) { + if (save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)) & (1 << 4)) { pos = sCcmOutsideCreditsSplinePositions; focus = sCcmOutsideCreditsSplineFocus; } else { @@ -9945,7 +9937,7 @@ BAD_RETURN(s32) cutscene_sliding_doors_fly_back_up(UNUSED struct Camera *c) { */ BAD_RETURN(s32) cutscene_sliding_doors_follow_mario(struct Camera *c) { Vec3f pos; - UNUSED u32 pad[5]; + UNUSED u8 filler[20]; vec3f_copy(pos, c->pos); // Update cvar1 with Mario's position (the y value doesn't change) @@ -9971,7 +9963,7 @@ BAD_RETURN(s32) cutscene_sliding_doors_follow_mario(struct Camera *c) { * Note: the star door unlocking event is not a cutscene, it's handled by Mario separately. */ BAD_RETURN(s32) cutscene_sliding_doors_open(struct Camera *c) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; reset_pan_distance(c); cutscene_event(cutscene_sliding_doors_open_start, c, 0, 8); @@ -10142,8 +10134,7 @@ BAD_RETURN(s32) cutscene_exit_painting(struct Camera *c) { * Unused. Warp the camera to Mario. */ BAD_RETURN(s32) cutscene_unused_exit_start(struct Camera *c) { - UNUSED Vec3f unused1; - UNUSED Vec3s unused2; + UNUSED u8 filler[18]; Vec3f offset; Vec3s marioAngle; @@ -10193,7 +10184,7 @@ BAD_RETURN(s32) cutscene_enter_cannon_end(struct Camera *c) { */ BAD_RETURN(s32) cutscene_enter_cannon_raise(struct Camera *c) { struct Object *o; - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; f32 floorHeight; struct Surface *floor; Vec3f cannonFocus; @@ -10237,8 +10228,7 @@ BAD_RETURN(s32) cutscene_enter_cannon_raise(struct Camera *c) { * Start the cannon entering cutscene */ BAD_RETURN(s32) cutscene_enter_cannon_start(struct Camera *c) { - UNUSED u32 cvar3Start; - UNUSED u32 cvar4Start; + UNUSED u8 filler[8]; // cvar3Start, cvar4Start? struct Object *o; sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -10347,7 +10337,7 @@ BAD_RETURN(s32) cutscene_door_end(struct Camera *c) { * Used for entering a room that uses a specific camera mode, like the castle lobby or BBH */ BAD_RETURN(s32) cutscene_door_mode(struct Camera *c) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; reset_pan_distance(c); camera_course_processing(c); @@ -11171,7 +11161,7 @@ struct CutsceneSplinePoint sCcmOutsideCreditsSplineFocus[] = { * the duration they want the flag to be active. */ void play_cutscene(struct Camera *c) { - UNUSED u32 pad[3]; + UNUSED u8 filler[12]; UNUSED s16 unusedYawFocToMario; s16 cutsceneDuration; u8 oldCutscene; @@ -11241,12 +11231,12 @@ void play_cutscene(struct Camera *c) { //! @bug This should check for 0x7FFF (CUTSCENE_LOOP) //! instead, cutscenes that last longer than 0x3FFF frames will never end on their own if (gCutsceneTimer < 0x3FFF) { - gCutsceneTimer += 1; + gCutsceneTimer++; } //! Because gCutsceneTimer is often set to 0x7FFF (CUTSCENE_LOOP), this conditional can only //! check for == due to overflow if (gCutsceneTimer == cutsceneDuration) { - sCutsceneShot += 1; + sCutsceneShot++; gCutsceneTimer = 0; } } else { @@ -11554,6 +11544,8 @@ void obj_rotate_towards_point(struct Object *o, Vec3f point, s16 pitchOff, s16 y o->oMoveAngleYaw = approach_s16_asymptotic(o->oMoveAngleYaw, yaw + yawOff, yawDiv); } +#define o gCurrentObject + #include "behaviors/intro_peach.inc.c" #include "behaviors/intro_lakitu.inc.c" #include "behaviors/end_birds_1.inc.c" diff --git a/src/game/camera.h b/src/game/camera.h index f56ed027..dc729270 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -295,8 +295,7 @@ /** * A copy of player information that is relevant to the camera. */ -struct PlayerCameraState -{ +struct PlayerCameraState { /** * Mario's action on this frame. */ @@ -317,8 +316,7 @@ struct PlayerCameraState * Struct containing info that is used when transition_next_state() is called. Stores the intermediate * distances and angular displacements from lakitu's goal position and focus. */ -struct TransitionInfo -{ +struct TransitionInfo { /*0x00*/ s16 posPitch; /*0x02*/ s16 posYaw; /*0x04*/ f32 posDist; @@ -327,17 +325,16 @@ struct TransitionInfo /*0x0C*/ f32 focDist; /*0x10*/ s32 framesLeft; /*0x14*/ Vec3f marioPos; - /*0x20*/ u8 pad; // for the structs to align, there has to be an extra unused variable here. type is unknown. + /*0x20*/ u8 unused; // for the structs to align, there has to be an extra unused variable here. type is unknown. }; /** * A point that's used in a spline, controls the direction to move the camera in * during the shake effect. */ -struct HandheldShakePoint -{ +struct HandheldShakePoint { /*0x00*/ s8 index; // only set to -1 - /*0x04 (aligned)*/ u32 pad; + /*0x04 (aligned)*/ u32 unused; /*0x08*/ Vec3s point; }; // size = 0x10 @@ -359,8 +356,7 @@ typedef CameraEvent CutsceneShot; /** * Defines a bounding box which activates an event while Mario is inside */ -struct CameraTrigger -{ +struct CameraTrigger { /** * The area this should be checked in, or -1 if it should run in every area of the level. * @@ -388,8 +384,7 @@ struct CameraTrigger * A camera shot that is active for a number of frames. * Together, a sequence of shots makes up a cutscene. */ -struct Cutscene -{ +struct Cutscene { /// The function that gets called. CutsceneShot shot; /// How long the shot lasts. @@ -399,8 +394,7 @@ struct Cutscene /** * Info for the camera's field of view and the FOV shake effect. */ -struct CameraFOVStatus -{ +struct CameraFOVStatus { /// The current function being used to set the camera's field of view (before any fov shake is applied). /*0x00*/ u8 fovFunc; /// The current field of view in degrees @@ -425,8 +419,7 @@ struct CameraFOVStatus /** * Information for a control point in a spline segment. */ -struct CutsceneSplinePoint -{ +struct CutsceneSplinePoint { /* The index of this point in the spline. Ignored except for -1, which ends the spline. An index of -1 should come four points after the start of the last segment. */ s8 index; @@ -440,8 +433,7 @@ struct CutsceneSplinePoint * Struct containing the nearest floor and ceiling to the player, as well as the previous floor and * ceiling. It also stores their distances from the player's position. */ -struct PlayerGeometry -{ +struct PlayerGeometry { /*0x00*/ struct Surface *currFloor; /*0x04*/ f32 currFloorHeight; /*0x08*/ s16 currFloorType; @@ -461,8 +453,7 @@ struct PlayerGeometry /** * Point used in transitioning between camera modes and C-Up. */ -struct LinearTransitionPoint -{ +struct LinearTransitionPoint { Vec3f focus; Vec3f pos; f32 dist; @@ -473,8 +464,7 @@ struct LinearTransitionPoint /** * Info about transitioning between camera modes. */ -struct ModeTransitionInfo -{ +struct ModeTransitionInfo { s16 newMode; s16 lastMode; s16 max; @@ -486,8 +476,7 @@ struct ModeTransitionInfo /** * A point in a path used by update_parallel_tracking_camera */ -struct ParallelTrackingPoint -{ +struct ParallelTrackingPoint { /// Whether this point is the start of a path s16 startOfPath; /// Point used to define a line segment to follow @@ -501,8 +490,7 @@ struct ParallelTrackingPoint /** * Stores the camera's info */ -struct CameraStoredInfo -{ +struct CameraStoredInfo { /*0x00*/ Vec3f pos; /*0x0C*/ Vec3f focus; /*0x18*/ f32 panDist; @@ -514,8 +502,7 @@ struct CameraStoredInfo * * See the sCutsceneVars[] array in camera.c for more details. */ -struct CutsceneVariable -{ +struct CutsceneVariable { /// Perhaps an index s32 unused1; Vec3f point; @@ -530,8 +517,7 @@ struct CutsceneVariable * update_lakitu, its pos and focus are used to calculate lakitu's next position and focus, which are * then used to render the game. */ -struct Camera -{ +struct Camera { /*0x00*/ u8 mode; // What type of mode the camera uses (see defines above) /*0x01*/ u8 defMode; /** @@ -553,9 +539,9 @@ struct Camera /// For example, this is what makes the camera rotate around the hill in BoB /*0x2C*/ f32 areaCenZ; /*0x30*/ u8 cutscene; - /*0x31*/ u8 filler31[0x8]; + /*0x31*/ u8 filler1[8]; /*0x3A*/ s16 nextYaw; - /*0x3C*/ u8 filler3C[0x28]; + /*0x3C*/ u8 filler2[40]; /*0x64*/ u8 doorStatus; /// The y coordinate of the "center" of the area. Unlike areaCenX and areaCenZ, this is only used /// when paused. See zoom_out_if_paused_and_outside @@ -570,8 +556,7 @@ struct Camera * * @see update_lakitu() */ -struct LakituState -{ +struct LakituState { /** * Lakitu's position, which (when CAM_FLAG_SMOOTH_MOVEMENT is set), approaches his goalPos every frame. */ @@ -591,14 +576,14 @@ struct LakituState */ /*0x24*/ Vec3f goalPos; - /*0x30*/ u8 filler30[12]; // extra unused Vec3f? + /*0x30*/ u8 filler1[12]; // extra unused Vec3f? /// Copy of the active camera mode /*0x3C*/ u8 mode; /// Copy of the default camera mode /*0x3D*/ u8 defMode; - /*0x3E*/ u8 filler3E[10]; + /*0x3E*/ u8 filler2[10]; /*0x48*/ f32 focusDistance; // unused /*0x4C*/ s16 oldPitch; // unused @@ -617,7 +602,7 @@ struct LakituState /*0x60*/ Vec3f unusedVec1; /*0x6C*/ Vec3s unusedVec2; - /*0x72*/ u8 filler72[8]; + /*0x72*/ u8 filler3[8]; /// Used to rotate the screen when rendering. /*0x7A*/ s16 roll; diff --git a/src/game/crash_screen.c b/src/game/crash_screen.c index 5f384de4..64a0f81a 100644 --- a/src/game/crash_screen.c +++ b/src/game/crash_screen.c @@ -17,6 +17,7 @@ u8 gCrashScreenCharToGlyph[128] = { 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, }; +// A height of seven pixels for each Character * nine rows of characters + one row unused. u32 gCrashScreenFont[7 * 9 + 1] = { #include "textures/crash_screen/crash_screen_font.ia1.inc.c" }; @@ -181,12 +182,10 @@ void draw_crash_screen(OSThread *thread) { __OSThreadContext *tc = &thread->context; cause = (tc->cause >> 2) & 0x1f; - if (cause == 23) // EXC_WATCH - { + if (cause == 23) { // EXC_WATCH cause = 16; } - if (cause == 31) // EXC_VCED - { + if (cause == 31) { // EXC_VCED cause = 17; } @@ -300,14 +299,15 @@ void crash_screen_init(void) { gCrashScreen.height = 0x10; #endif osCreateMesgQueue(&gCrashScreen.mesgQueue, &gCrashScreen.mesg, 1); - osCreateThread(&gCrashScreen.thread, 2, thread2_crash_screen, NULL, - (u8 *) gCrashScreen.stack + sizeof(gCrashScreen.stack), + osCreateThread( + &gCrashScreen.thread, 2, thread2_crash_screen, NULL, + (u8 *) gCrashScreen.stack + sizeof(gCrashScreen.stack), #ifdef VERSION_EU - OS_PRIORITY_APPMAX + OS_PRIORITY_APPMAX #else - OS_PRIORITY_RMON + OS_PRIORITY_RMON #endif - ); + ); osStartThread(&gCrashScreen.thread); } diff --git a/src/game/debug.c b/src/game/debug.c index 060002bb..c2b71720 100644 --- a/src/game/debug.c +++ b/src/game/debug.c @@ -81,7 +81,7 @@ s64 get_current_clock(void) { return wtf; } -s64 get_clock_difference(UNUSED s64 arg0) { +s64 get_clock_difference(UNUSED s64 cycles) { s64 wtf = 0; return wtf; @@ -113,7 +113,7 @@ void print_text_array_info(s16 *printState, const char *str, s32 number) { || (printState[DEBUG_PSTATE_MAX_X_CURSOR] < printState[DEBUG_PSTATE_Y_CURSOR])) { print_text(printState[DEBUG_PSTATE_X_CURSOR], printState[DEBUG_PSTATE_Y_CURSOR], "DPRINT OVER"); - printState[DEBUG_PSTATE_DISABLED] += 1; // why not just = TRUE... + printState[DEBUG_PSTATE_DISABLED]++; // why not just = TRUE... } else { print_text_fmt_int(printState[DEBUG_PSTATE_X_CURSOR], printState[DEBUG_PSTATE_Y_CURSOR], str, number); @@ -162,13 +162,13 @@ void print_debug_top_down_normal(const char *str, s32 number) { } } -#ifndef VERSION_EU void print_mapinfo(void) { + // EU mostly stubbed this function out. struct Surface *pfloor; - f32 bgY; - f32 water; - s32 area; - s32 angY; + UNUSED f32 bgY; // unused in EU + UNUSED f32 water; // unused in EU + UNUSED s32 area; // unused in EU + UNUSED s32 angY; // unused in EU angY = gCurrentObject->oMoveAngleYaw / 182.044000; area = ((s32) gCurrentObject->oPosX + 0x2000) / 1024 @@ -178,6 +178,7 @@ void print_mapinfo(void) { water = find_water_level(gCurrentObject->oPosX, gCurrentObject->oPosZ); print_debug_top_down_normal("mapinfo", 0); +#ifndef VERSION_EU print_debug_top_down_mapinfo("area %x", area); print_debug_top_down_mapinfo("wx %d", gCurrentObject->oPosX); //! Fat finger: programmer hit tab instead of space. Japanese @@ -188,8 +189,7 @@ void print_mapinfo(void) { print_debug_top_down_mapinfo("bgY %d", bgY); print_debug_top_down_mapinfo("angY %d", angY); - if (pfloor) // not null - { + if (pfloor != NULL) { print_debug_top_down_mapinfo("bgcode %d", pfloor->type); print_debug_top_down_mapinfo("bgstatus %d", pfloor->flags); print_debug_top_down_mapinfo("bgarea %d", pfloor->room); @@ -198,42 +198,8 @@ void print_mapinfo(void) { if (gCurrentObject->oPosY < water) { print_debug_top_down_mapinfo("water %d", water); } -} -#else -void print_mapinfo(void) { - // EU mostly stubbed this function out. - struct Surface *pfloor; - UNUSED f32 bgY; - UNUSED f32 water; - UNUSED s32 area; - // s32 angY; - // - // angY = gCurrentObject->oMoveAngleYaw / 182.044000; - // area = ((s32)gCurrentObject->oPosX + 0x2000) / 1024 - // + ((s32)gCurrentObject->oPosZ + 0x2000) / 1024 * 16; - // - bgY = find_floor(gCurrentObject->oPosX, gCurrentObject->oPosY, gCurrentObject->oPosZ, &pfloor); - water = find_water_level(gCurrentObject->oPosX, gCurrentObject->oPosZ); - - print_debug_top_down_normal("mapinfo", 0); - // print_debug_top_down_mapinfo("area %x", area); - // print_debug_top_down_mapinfo("wx %d", gCurrentObject->oPosX); - // print_debug_top_down_mapinfo("wy\t %d", gCurrentObject->oPosY); - // print_debug_top_down_mapinfo("wz %d", gCurrentObject->oPosZ); - // print_debug_top_down_mapinfo("bgY %d", bgY); - // print_debug_top_down_mapinfo("angY %d", angY); - // - // if(pfloor) // not null - //{ - // print_debug_top_down_mapinfo("bgcode %d", pfloor->type); - // print_debug_top_down_mapinfo("bgstatus %d", pfloor->flags); - // print_debug_top_down_mapinfo("bgarea %d", pfloor->room); - //} - // - // if(gCurrentObject->oPosY < water) - // print_debug_top_down_mapinfo("water %d", water); -} #endif +} void print_checkinfo(void) { print_debug_top_down_normal("checkinfo", 0); @@ -257,7 +223,7 @@ void print_string_array_info(const char **strArr) { s32 i; if (!sDebugStringArrPrinted) { - sDebugStringArrPrinted += 1; // again, why not = TRUE... + sDebugStringArrPrinted++; // again, why not = TRUE... for (i = 0; i < 8; i++) { // sDebugPage is assumed to be 4 or 5 here. print_debug_top_down_mapinfo(strArr[i], gDebugInfo[sDebugPage][i]); @@ -296,7 +262,7 @@ void update_debug_dpadmask(void) { } else { sDebugInfoDPadMask = 0; } - sDebugInfoDPadUpdID += 1; + sDebugInfoDPadUpdID++; if (sDebugInfoDPadUpdID >= 8) { sDebugInfoDPadUpdID = 6; // rapidly set to 6 from 8 as long as dPadMask is being set. } @@ -305,7 +271,7 @@ void update_debug_dpadmask(void) { void debug_unknown_level_select_check(void) { if (!sDebugLvSelectCheckFlag) { - sDebugLvSelectCheckFlag += 1; // again, just do = TRUE... + sDebugLvSelectCheckFlag++; // again, just do = TRUE... if (!gDebugLevelSelect) { gDebugInfoFlags = DEBUG_INFO_NOFLAGS; @@ -338,17 +304,15 @@ void reset_debug_objectinfo(void) { * despite so this has no effect, being called. (unused) */ UNUSED static void check_debug_button_seq(void) { - s16 *buttonArr; + s16 *buttonArr = sDebugInfoButtonSeq; s16 cButtonMask; - buttonArr = sDebugInfoButtonSeq; - if (!(gPlayer1Controller->buttonDown & L_TRIG)) { sDebugInfoButtonSeqID = 0; } else { if ((s16)(cButtonMask = (gPlayer1Controller->buttonPressed & C_BUTTONS))) { if (buttonArr[sDebugInfoButtonSeqID] == cButtonMask) { - sDebugInfoButtonSeqID += 1; + sDebugInfoButtonSeqID++; if (buttonArr[sDebugInfoButtonSeqID] == -1) { if (gDebugInfoFlags == DEBUG_INFO_FLAG_ALL) { gDebugInfoFlags = DEBUG_INFO_FLAG_LSELECT; @@ -371,11 +335,11 @@ UNUSED static void try_change_debug_page(void) { if (gDebugInfoFlags & DEBUG_INFO_FLAG_DPRINT) { if ((gPlayer1Controller->buttonPressed & L_JPAD) && (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) { - sDebugPage += 1; + sDebugPage++; } if ((gPlayer1Controller->buttonPressed & R_JPAD) && (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) { - sDebugPage -= 1; + sDebugPage--; } if (sDebugPage >= (DEBUG_PAGE_MAX + 1)) { sDebugPage = DEBUG_PAGE_MIN; @@ -408,14 +372,14 @@ void try_modify_debug_controls(void) { } if (sDebugInfoDPadMask & U_JPAD) { - sDebugSysCursor -= 1; + sDebugSysCursor--; if (sDebugSysCursor < 0) { sDebugSysCursor = 0; } } if (sDebugInfoDPadMask & D_JPAD) { - sDebugSysCursor += 1; + sDebugSysCursor++; if (sDebugSysCursor >= 8) { sDebugSysCursor = 7; } @@ -467,11 +431,11 @@ void try_print_debug_mario_object_info(void) { print_debug_top_down_mapinfo("obj %d", gObjectCounter); - if (gNumFindFloorMisses) { + if (gNumFindFloorMisses != 0) { print_debug_bottom_up("NULLBG %d", gNumFindFloorMisses); } - if (gUnknownWallCount) { + if (gUnknownWallCount != 0) { print_debug_bottom_up("WALL %d", gUnknownWallCount); } } @@ -507,7 +471,7 @@ void try_print_debug_mario_level_info(void) { * [5][7] (b7 in the string array) to 1 to enable debug spawn. */ void try_do_mario_debug_object_spawn(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; if (sDebugPage == DEBUG_PAGE_STAGEINFO && gDebugInfo[DEBUG_PAGE_ENEMYINFO][7] == 1) { if (gPlayer1Controller->buttonPressed & R_JPAD) { diff --git a/src/game/envfx_bubbles.c b/src/game/envfx_bubbles.c index 9bc0e6e9..3c1d672a 100644 --- a/src/game/envfx_bubbles.c +++ b/src/game/envfx_bubbles.c @@ -45,10 +45,10 @@ s32 particle_is_laterally_close(s32 index, s32 x, s32 z, s32 distance) { s32 zPos = (gEnvFxBuffer + index)->zPos; if (sqr(xPos - x) + sqr(zPos - z) > sqr(distance)) { - return 0; + return FALSE; } - return 1; + return TRUE; } /** @@ -73,7 +73,7 @@ s32 random_flower_offset(void) { void envfx_update_flower(Vec3s centerPos) { s32 i; struct FloorGeometry *floorGeo; // unused - s32 timer = gGlobalTimer; + s32 globalTimer = gGlobalTimer; s16 centerX = centerPos[0]; UNUSED s16 centerY = centerPos[1]; @@ -81,14 +81,14 @@ void envfx_update_flower(Vec3s centerPos) { for (i = 0; i < sBubbleParticleMaxCount; i++) { (gEnvFxBuffer + i)->isAlive = particle_is_laterally_close(i, centerX, centerZ, 3000); - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { (gEnvFxBuffer + i)->xPos = random_flower_offset() + centerX; (gEnvFxBuffer + i)->zPos = random_flower_offset() + centerZ; (gEnvFxBuffer + i)->yPos = find_floor_height_and_data((gEnvFxBuffer + i)->xPos, 10000.0f, (gEnvFxBuffer + i)->zPos, &floorGeo); - (gEnvFxBuffer + i)->isAlive = 1; + (gEnvFxBuffer + i)->isAlive = TRUE; (gEnvFxBuffer + i)->animFrame = random_float() * 5.0f; - } else if ((timer & 0x03) == 0) { + } else if (!(globalTimer & 3)) { (gEnvFxBuffer + i)->animFrame += 1; if ((gEnvFxBuffer + i)->animFrame > 5) { (gEnvFxBuffer + i)->animFrame = 0; @@ -109,11 +109,10 @@ void envfx_update_flower(Vec3s centerPos) { void envfx_set_lava_bubble_position(s32 index, Vec3s centerPos) { struct Surface *surface; s16 floorY; - s16 centerX, centerY, centerZ; - centerX = centerPos[0]; - centerY = centerPos[1]; - centerZ = centerPos[2]; + s16 centerX = centerPos[0]; + s16 centerY = centerPos[1]; + s16 centerZ = centerPos[2]; (gEnvFxBuffer + index)->xPos = random_float() * 6000.0f - 3000.0f + centerX; (gEnvFxBuffer + index)->zPos = random_float() * 6000.0f - 3000.0f + centerZ; @@ -152,22 +151,21 @@ void envfx_set_lava_bubble_position(s32 index, Vec3s centerPos) { */ void envfx_update_lava(Vec3s centerPos) { s32 i; - s32 timer = gGlobalTimer; + s32 globalTimer = gGlobalTimer; s8 chance; - UNUSED s16 centerX, centerY, centerZ; - centerX = centerPos[0]; - centerY = centerPos[1]; - centerZ = centerPos[2]; + UNUSED s16 centerX = centerPos[0]; + UNUSED s16 centerY = centerPos[1]; + UNUSED s16 centerZ = centerPos[2]; for (i = 0; i < sBubbleParticleMaxCount; i++) { - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { envfx_set_lava_bubble_position(i, centerPos); - (gEnvFxBuffer + i)->isAlive = 1; - } else if ((timer & 0x01) == 0) { + (gEnvFxBuffer + i)->isAlive = TRUE; + } else if (!(globalTimer & 1)) { (gEnvFxBuffer + i)->animFrame += 1; if ((gEnvFxBuffer + i)->animFrame > 8) { - (gEnvFxBuffer + i)->isAlive = 0; + (gEnvFxBuffer + i)->isAlive = FALSE; (gEnvFxBuffer + i)->animFrame = 0; } } @@ -205,17 +203,17 @@ void envfx_rotate_around_whirlpool(s32 *x, s32 *y, s32 *z) { * low or close to the center. */ s32 envfx_is_whirlpool_bubble_alive(s32 index) { - s32 UNUSED sp4; + UNUSED u8 filler[4]; if ((gEnvFxBuffer + index)->bubbleY < gEnvFxBubbleConfig[ENVFX_STATE_DEST_Y] - 100) { - return 0; + return FALSE; } if ((gEnvFxBuffer + index)->angleAndDist[1] < 10) { - return 0; + return FALSE; } - return 1; + return TRUE; } /** @@ -227,7 +225,7 @@ void envfx_update_whirlpool(void) { for (i = 0; i < sBubbleParticleMaxCount; i++) { (gEnvFxBuffer + i)->isAlive = envfx_is_whirlpool_bubble_alive(i); - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { (gEnvFxBuffer + i)->angleAndDist[1] = random_float() * 1000.0f; (gEnvFxBuffer + i)->angleAndDist[0] = random_float() * 65536.0f; (gEnvFxBuffer + i)->xPos = @@ -240,7 +238,7 @@ void envfx_update_whirlpool(void) { gEnvFxBubbleConfig[ENVFX_STATE_SRC_Y] + (random_float() * 100.0f - 50.0f); (gEnvFxBuffer + i)->yPos = (i + gEnvFxBuffer)->bubbleY; (gEnvFxBuffer + i)->unusedBubbleVar = 0; - (gEnvFxBuffer + i)->isAlive = 1; + (gEnvFxBuffer + i)->isAlive = TRUE; envfx_rotate_around_whirlpool(&(gEnvFxBuffer + i)->xPos, &(gEnvFxBuffer + i)->yPos, &(gEnvFxBuffer + i)->zPos); @@ -268,15 +266,15 @@ void envfx_update_whirlpool(void) { * 1000 units away from the source or 1500 units above it. */ s32 envfx_is_jestream_bubble_alive(s32 index) { - UNUSED s32 unk; + UNUSED u8 filler[4]; if (!particle_is_laterally_close(index, gEnvFxBubbleConfig[ENVFX_STATE_SRC_X], gEnvFxBubbleConfig[ENVFX_STATE_SRC_Z], 1000) || gEnvFxBubbleConfig[ENVFX_STATE_SRC_Y] + 1500 < (gEnvFxBuffer + index)->yPos) { - return 0; + return FALSE; } - return 1; + return TRUE; } /** @@ -288,7 +286,7 @@ void envfx_update_jetstream(void) { for (i = 0; i < sBubbleParticleMaxCount; i++) { (gEnvFxBuffer + i)->isAlive = envfx_is_jestream_bubble_alive(i); - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { (gEnvFxBuffer + i)->angleAndDist[1] = random_float() * 300.0f; (gEnvFxBuffer + i)->angleAndDist[0] = random_u16(); (gEnvFxBuffer + i)->xPos = @@ -318,7 +316,7 @@ s32 envfx_init_bubble(s32 mode) { switch (mode) { case ENVFX_MODE_NONE: - return 0; + return FALSE; case ENVFX_FLOWERS: sBubbleParticleCount = 30; @@ -339,9 +337,10 @@ s32 envfx_init_bubble(s32 mode) { break; } - gEnvFxBuffer = mem_pool_alloc(gEffectsMemoryPool, sBubbleParticleCount * sizeof(struct EnvFxParticle)); - if (!gEnvFxBuffer) { - return 0; + gEnvFxBuffer = mem_pool_alloc(gEffectsMemoryPool, + sBubbleParticleCount * sizeof(struct EnvFxParticle)); + if (gEnvFxBuffer == NULL) { + return FALSE; } bzero(gEnvFxBuffer, sBubbleParticleCount * sizeof(struct EnvFxParticle)); @@ -356,7 +355,7 @@ s32 envfx_init_bubble(s32 mode) { } gEnvFxMode = mode; - return 1; + return TRUE; } /** @@ -473,10 +472,8 @@ Gfx *envfx_update_bubble_particles(s32 mode, UNUSED Vec3s marioPos, Vec3s camFro Vec3s vertex2; Vec3s vertex3; - Gfx *gfxStart; - - gfxStart = alloc_display_list(((sBubbleParticleMaxCount / 5) * 10 + sBubbleParticleMaxCount + 3) - * sizeof(Gfx)); + Gfx *gfxStart = alloc_display_list(((sBubbleParticleMaxCount / 5) * 10 + sBubbleParticleMaxCount + 3) + * sizeof(Gfx)); if (gfxStart == NULL) { return NULL; } @@ -529,7 +526,7 @@ void envfx_set_max_bubble_particles(s32 mode) { Gfx *envfx_update_bubbles(s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom) { Gfx *gfx; - if (gEnvFxMode == 0 && !envfx_init_bubble(mode)) { + if (gEnvFxMode == ENVFX_MODE_NONE && !envfx_init_bubble(mode)) { return NULL; } diff --git a/src/game/envfx_snow.c b/src/game/envfx_snow.c index 5686da78..3b55ced8 100644 --- a/src/game/envfx_snow.c +++ b/src/game/envfx_snow.c @@ -38,7 +38,7 @@ s16 gSnowParticleCount; s16 gSnowParticleMaxCount; /* DATA */ -s8 gEnvFxMode = 0; +s8 gEnvFxMode = ENVFX_MODE_NONE; UNUSED s32 D_80330644 = 0; /// Template for a snow particle triangle @@ -62,7 +62,7 @@ extern void *tiny_bubble_dl_0B006CD8; s32 envfx_init_snow(s32 mode) { switch (mode) { case ENVFX_MODE_NONE: - return 0; + return FALSE; case ENVFX_SNOW_NORMAL: gSnowParticleMaxCount = 140; @@ -80,15 +80,16 @@ s32 envfx_init_snow(s32 mode) { break; } - gEnvFxBuffer = mem_pool_alloc(gEffectsMemoryPool, gSnowParticleMaxCount * sizeof(struct EnvFxParticle)); - if (!gEnvFxBuffer) { - return 0; + gEnvFxBuffer = mem_pool_alloc(gEffectsMemoryPool, + gSnowParticleMaxCount * sizeof(struct EnvFxParticle)); + if (gEnvFxBuffer == NULL) { + return FALSE; } bzero(gEnvFxBuffer, gSnowParticleMaxCount * sizeof(struct EnvFxParticle)); gEnvFxMode = mode; - return 1; + return TRUE; } /** @@ -98,12 +99,13 @@ s32 envfx_init_snow(s32 mode) { * Blizzard snows starts at the maximum amount and doesn't change. */ void envfx_update_snowflake_count(s32 mode, Vec3s marioPos) { - s32 timer = gGlobalTimer; + s32 globalTimer = gGlobalTimer; f32 waterLevel; + switch (mode) { case ENVFX_SNOW_NORMAL: if (gSnowParticleMaxCount > gSnowParticleCount) { - if ((timer & 0x3F) == 0) { + if (!(globalTimer & 63)) { gSnowParticleCount += 5; } } @@ -113,7 +115,7 @@ void envfx_update_snowflake_count(s32 mode, Vec3s marioPos) { waterLevel = find_water_level(marioPos[0], marioPos[2]); gSnowParticleCount = - (((s32)((waterLevel - 400.f - (f32) marioPos[1]) * 1.0e-3) << 0x10) >> 0x10) * 5; + (((s32)((waterLevel - 400.0f - (f32) marioPos[1]) * 0.001) << 0x10) >> 0x10) * 5; if (gSnowParticleCount < 0) { gSnowParticleCount = 0; @@ -135,7 +137,7 @@ void envfx_update_snowflake_count(s32 mode, Vec3s marioPos) { * to none. */ void envfx_cleanup_snow(void *snowParticleArray) { - if (gEnvFxMode) { + if (gEnvFxMode != ENVFX_MODE_NONE) { if (snowParticleArray) { mem_pool_free(gEffectsMemoryPool, snowParticleArray); } @@ -178,14 +180,14 @@ s32 envfx_is_snowflake_alive(s32 index, s32 snowCylinderX, s32 snowCylinderY, s3 s32 z = (gEnvFxBuffer + index)->zPos; if (sqr(x - snowCylinderX) + sqr(z - snowCylinderZ) > sqr(300)) { - return 0; + return FALSE; } if ((y < snowCylinderY - 201) || (snowCylinderY + 201 < y)) { - return 0; + return FALSE; } - return 1; + return TRUE; } /** @@ -211,13 +213,13 @@ void envfx_update_snow_normal(s32 snowCylinderX, s32 snowCylinderY, s32 snowCyli for (i = 0; i < gSnowParticleCount; i++) { (gEnvFxBuffer + i)->isAlive = envfx_is_snowflake_alive(i, snowCylinderX, snowCylinderY, snowCylinderZ); - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { (gEnvFxBuffer + i)->xPos = 400.0f * random_float() - 200.0f + snowCylinderX + (s16)(deltaX * 2); (gEnvFxBuffer + i)->zPos = 400.0f * random_float() - 200.0f + snowCylinderZ + (s16)(deltaZ * 2); (gEnvFxBuffer + i)->yPos = 200.0f * random_float() + snowCylinderY; - (gEnvFxBuffer + i)->isAlive = 1; + (gEnvFxBuffer + i)->isAlive = TRUE; } else { (gEnvFxBuffer + i)->xPos += random_float() * 2 - 1.0f + (s16)(deltaX / 1.2); (gEnvFxBuffer + i)->yPos -= 2 -(s16)(deltaY * 0.8); @@ -245,13 +247,13 @@ void envfx_update_snow_blizzard(s32 snowCylinderX, s32 snowCylinderY, s32 snowCy for (i = 0; i < gSnowParticleCount; i++) { (gEnvFxBuffer + i)->isAlive = envfx_is_snowflake_alive(i, snowCylinderX, snowCylinderY, snowCylinderZ); - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { (gEnvFxBuffer + i)->xPos = 400.0f * random_float() - 200.0f + snowCylinderX + (s16)(deltaX * 2); (gEnvFxBuffer + i)->zPos = 400.0f * random_float() - 200.0f + snowCylinderZ + (s16)(deltaZ * 2); (gEnvFxBuffer + i)->yPos = 400.0f * random_float() - 200.0f + snowCylinderY; - (gEnvFxBuffer + i)->isAlive = 1; + (gEnvFxBuffer + i)->isAlive = TRUE; } else { (gEnvFxBuffer + i)->xPos += random_float() * 2 - 1.0f + (s16)(deltaX / 1.2) + 20.0f; (gEnvFxBuffer + i)->yPos -= 5 -(s16)(deltaY * 0.8); @@ -275,9 +277,9 @@ void envfx_update_snow_blizzard(s32 snowCylinderX, s32 snowCylinderY, s32 snowCy */ UNUSED static s32 is_in_mystery_snow_area(s32 x, UNUSED s32 y, s32 z) { if (sqr(x - 3380) + sqr(z + 520) < sqr(3000)) { - return 1; + return TRUE; } - return 0; + return FALSE; } /** @@ -290,11 +292,11 @@ void envfx_update_snow_water(s32 snowCylinderX, s32 snowCylinderY, s32 snowCylin for (i = 0; i < gSnowParticleCount; i++) { (gEnvFxBuffer + i)->isAlive = envfx_is_snowflake_alive(i, snowCylinderX, snowCylinderY, snowCylinderZ); - if ((gEnvFxBuffer + i)->isAlive == 0) { + if (!(gEnvFxBuffer + i)->isAlive) { (gEnvFxBuffer + i)->xPos = 400.0f * random_float() - 200.0f + snowCylinderX; (gEnvFxBuffer + i)->zPos = 400.0f * random_float() - 200.0f + snowCylinderZ; (gEnvFxBuffer + i)->yPos = 400.0f * random_float() - 200.0f + snowCylinderY; - (gEnvFxBuffer + i)->isAlive = 1; + (gEnvFxBuffer + i)->isAlive = TRUE; } } } @@ -468,8 +470,8 @@ Gfx *envfx_update_particles(s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom return NULL; } - if (gEnvFxMode != 0 && mode != gEnvFxMode) { - mode = 0; + if (gEnvFxMode != ENVFX_MODE_NONE && gEnvFxMode != mode) { + mode = ENVFX_MODE_NONE; } if (mode >= ENVFX_BUBBLE_START) { @@ -477,7 +479,7 @@ Gfx *envfx_update_particles(s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom return gfx; } - if (gEnvFxMode == 0 && envfx_init_snow(mode) == 0) { + if (gEnvFxMode == ENVFX_MODE_NONE && !envfx_init_snow(mode)) { return NULL; } diff --git a/src/game/envfx_snow.h b/src/game/envfx_snow.h index 7a83b536..378dae9a 100644 --- a/src/game/envfx_snow.h +++ b/src/game/envfx_snow.h @@ -25,7 +25,7 @@ struct EnvFxParticle { s32 angleAndDist[2]; // for whirpools, [0] = angle from center, [1] = distance from center s32 unusedBubbleVar; // set to zero for bubbles when respawning, never used elsewhere s32 bubbleY; // for Bubbles, yPos is always set to this - s8 filler20[56 - 0x20]; + u8 filler[24]; }; extern s8 gEnvFxMode; @@ -35,7 +35,7 @@ extern struct EnvFxParticle *gEnvFxBuffer; extern Vec3i gSnowCylinderLastPos; extern s16 gSnowParticleCount; -Gfx *envfx_update_particles(s32 snowMode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom); +Gfx *envfx_update_particles(s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom); void orbit_from_positions(Vec3s from, Vec3s to, s16 *radius, s16 *pitch, s16 *yaw); void rotate_triangle_vertices(Vec3s vertex1, Vec3s vertex2, Vec3s vertex3, s16 pitch, s16 yaw); diff --git a/src/game/game_init.c b/src/game/game_init.c index 72c2fb8e..4be1c7b5 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -19,7 +19,6 @@ #include "segment2.h" #include "segment_symbols.h" #include "rumble_init.h" -#include // First 3 controller slots struct Controller gControllers[3]; @@ -46,7 +45,7 @@ OSMesg gGfxMesgBuf[1]; struct VblankHandler gGameVblankHandler; // Buffers -uintptr_t gPhysicalFrameBuffers[3]; +uintptr_t gPhysicalFramebuffers[3]; uintptr_t gPhysicalZBuffer; // Mario Anims and Demo allocation @@ -64,7 +63,7 @@ u32 gGlobalTimer = 0; // Framebuffer rendering values (max 3) u16 sRenderedFramebuffer = 0; -u16 sRenderingFrameBuffer = 0; +u16 sRenderingFramebuffer = 0; // Goddard Vblank Function Caller void (*gGoddardVblankCallback)(void) = NULL; @@ -150,12 +149,12 @@ void init_z_buffer(void) { /** * Tells the RDP which of the three framebuffers it shall draw to. */ -void select_frame_buffer(void) { +void select_framebuffer(void) { gDPPipeSync(gDisplayListHead++); gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, - gPhysicalFrameBuffers[sRenderingFrameBuffer]); + gPhysicalFramebuffers[sRenderingFramebuffer]); gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT); } @@ -164,7 +163,7 @@ void select_frame_buffer(void) { * Clear the framebuffer and fill it with a 32-bit color. * Information about the color argument: https://jrra.zone/n64/doc/n64man/gdp/gDPSetFillColor.htm */ -void clear_frame_buffer(s32 color) { +void clear_framebuffer(s32 color) { gDPPipeSync(gDisplayListHead++); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); @@ -277,7 +276,7 @@ void init_rcp(void) { init_rdp(); init_rsp(); init_z_buffer(); - select_frame_buffer(); + select_framebuffer(); } /** @@ -310,7 +309,7 @@ void draw_reset_bars(void) { fbNum = sRenderedFramebuffer - 1; } - fbPtr = (u64 *) PHYSICAL_TO_VIRTUAL(gPhysicalFrameBuffers[fbNum]); + fbPtr = (u64 *) PHYSICAL_TO_VIRTUAL(gPhysicalFramebuffers[fbNum]); fbPtr += gNmiResetBarsTimer++ * (SCREEN_WIDTH / 4); for (width = 0; width < ((SCREEN_HEIGHT / 16) + 1); width++) { @@ -335,11 +334,11 @@ void render_init(void) { gDisplayListHead = gGfxPool->buffer; gGfxPoolEnd = (u8 *)(gGfxPool->buffer + GFX_POOL_SIZE); init_rcp(); - clear_frame_buffer(0); + clear_framebuffer(0); end_master_display_list(); exec_display_list(&gGfxPool->spTask); - sRenderingFrameBuffer++; + sRenderingFramebuffer++; gGlobalTimer++; } @@ -371,14 +370,14 @@ void display_and_vsync(void) { exec_display_list(&gGfxPool->spTask); profiler_log_thread5_time(AFTER_DISPLAY_LISTS); osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK); - osViSwapBuffer((void *) PHYSICAL_TO_VIRTUAL(gPhysicalFrameBuffers[sRenderedFramebuffer])); + osViSwapBuffer((void *) PHYSICAL_TO_VIRTUAL(gPhysicalFramebuffers[sRenderedFramebuffer])); profiler_log_thread5_time(THREAD5_END); osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK); if (++sRenderedFramebuffer == 3) { sRenderedFramebuffer = 0; } - if (++sRenderingFrameBuffer == 3) { - sRenderingFrameBuffer = 0; + if (++sRenderingFramebuffer == 3) { + sRenderingFramebuffer = 0; } gGlobalTimer++; } @@ -424,7 +423,7 @@ UNUSED static void record_demo(void) { * Take the updated controller struct and calculate the new x, y, and distance floats. */ void adjust_analog_stick(struct Controller *controller) { - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; // Reset the controller's x and y floats. controller->stickX = 0; @@ -545,8 +544,7 @@ void read_controller_inputs(void) { // 0.5x A presses are a good meme controller->buttonDown = controller->controllerData->button; adjust_analog_stick(controller); - } else // otherwise, if the controllerData is NULL, 0 out all of the inputs. - { + } else { // otherwise, if the controllerData is NULL, 0 out all of the inputs. controller->rawStickX = 0; controller->rawStickY = 0; controller->buttonPressed = 0; @@ -613,7 +611,7 @@ void init_controllers(void) { * Setup main segments and framebuffers. */ void setup_game_memory(void) { - UNUSED u64 padding; + UNUSED u8 filler[8]; // Setup general Segment 0 set_segment_base_addr(0, (void *) 0x80000000); @@ -622,9 +620,9 @@ void setup_game_memory(void) { osCreateMesgQueue(&gGameVblankQueue, gGameMesgBuf, ARRAY_COUNT(gGameMesgBuf)); // Setup z buffer and framebuffer gPhysicalZBuffer = VIRTUAL_TO_PHYSICAL(gZBuffer); - gPhysicalFrameBuffers[0] = VIRTUAL_TO_PHYSICAL(gFrameBuffer0); - gPhysicalFrameBuffers[1] = VIRTUAL_TO_PHYSICAL(gFrameBuffer1); - gPhysicalFrameBuffers[2] = VIRTUAL_TO_PHYSICAL(gFrameBuffer2); + gPhysicalFramebuffers[0] = VIRTUAL_TO_PHYSICAL(gFramebuffer0); + gPhysicalFramebuffers[1] = VIRTUAL_TO_PHYSICAL(gFramebuffer1); + gPhysicalFramebuffers[2] = VIRTUAL_TO_PHYSICAL(gFramebuffer2); // Setup Mario Animations gMarioAnimsMemAlloc = main_pool_alloc(0x4000, MEMORY_POOL_LEFT); set_segment_base_addr(17, (void *) gMarioAnimsMemAlloc); @@ -666,7 +664,7 @@ void thread5_game_loop(UNUSED void *arg) { while (TRUE) { // If the reset timer is active, run the process to reset the game. - if (gResetTimer) { + if (gResetTimer != 0) { draw_reset_bars(); continue; } diff --git a/src/game/game_init.h b/src/game/game_init.h index 1640723b..4ab929e0 100644 --- a/src/game/game_init.h +++ b/src/game/game_init.h @@ -16,8 +16,7 @@ struct GfxPool { struct SPTask spTask; }; -struct DemoInput -{ +struct DemoInput { u8 timer; // time until next input. if this value is 0, it means the demo is over s8 rawStickX; s8 rawStickY; @@ -32,7 +31,7 @@ extern OSMesgQueue gGfxVblankQueue; extern OSMesg gGameMesgBuf[1]; extern OSMesg gGfxMesgBuf[1]; extern struct VblankHandler gGameVblankHandler; -extern uintptr_t gPhysicalFrameBuffers[3]; +extern uintptr_t gPhysicalFramebuffers[3]; extern uintptr_t gPhysicalZBuffer; extern void *gMarioAnimsMemAlloc; extern void *gDemoInputsMemAlloc; @@ -59,12 +58,12 @@ extern struct DmaHandlerList gDemoInputsBuf; extern u8 gMarioAnims[]; extern u8 gDemoInputs[]; -extern u16 sRenderingFrameBuffer; +extern u16 sRenderingFramebuffer; extern u32 gGlobalTimer; void setup_game_memory(void); void thread5_game_loop(UNUSED void *arg); -void clear_frame_buffer(s32 color); +void clear_framebuffer(s32 color); void clear_viewport(Vp *viewport, s32 color); void make_viewport_clip_rect(Vp *viewport); void init_rcp(void); diff --git a/src/game/geo_misc.h b/src/game/geo_misc.h index 904633af..c43b4305 100644 --- a/src/game/geo_misc.h +++ b/src/game/geo_misc.h @@ -4,8 +4,7 @@ #include #include -enum FlyingCarpetState -{ +enum FlyingCarpetState { FLYING_CARPET_IDLE = 0, FLYING_CARPET_MOVING_WITHOUT_MARIO = 1, FLYING_CARPET_MOVING_WITH_MARIO = 2 diff --git a/src/game/hud.c b/src/game/hud.c index 8c7de524..5a0f6806 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -90,9 +90,7 @@ void render_hud_small_tex_lut(s32 x, s32 y, u8 *texture) { * Renders power meter health segment texture using a table list. */ void render_power_meter_health_segment(s16 numHealthWedges) { - u8 *(*healthLUT)[]; - - healthLUT = segmented_to_virtual(&power_meter_health_segments_lut); + u8 *(*healthLUT)[] = segmented_to_virtual(&power_meter_health_segments_lut); gDPPipeSync(gDisplayListHead++); gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, @@ -108,9 +106,7 @@ void render_power_meter_health_segment(s16 numHealthWedges) { * That includes the "POWER" base and the colored health segment textures. */ void render_dl_power_meter(s16 numHealthWedges) { - Mtx *mtx; - - mtx = alloc_display_list(sizeof(Mtx)); + Mtx *mtx = alloc_display_list(sizeof(Mtx)); if (mtx == NULL) { return; @@ -136,8 +132,7 @@ void render_dl_power_meter(s16 numHealthWedges) { * Checks its timer to later change into deemphasizing mode. */ void animate_power_meter_emphasized(void) { - s16 hudDisplayFlags; - hudDisplayFlags = gHudDisplay.flags; + s16 hudDisplayFlags = gHudDisplay.flags; if (!(hudDisplayFlags & HUD_DISPLAY_FLAG_EMPHASIZE_POWER)) { if (sPowerMeterVisibleTimer == 45.0) { @@ -155,21 +150,21 @@ void animate_power_meter_emphasized(void) { static void animate_power_meter_deemphasizing(void) { s16 speed = 5; - if (sPowerMeterHUD.y >= 181) { + if (sPowerMeterHUD.y > 180) { speed = 3; } - if (sPowerMeterHUD.y >= 191) { + if (sPowerMeterHUD.y > 190) { speed = 2; } - if (sPowerMeterHUD.y >= 196) { + if (sPowerMeterHUD.y > 195) { speed = 1; } sPowerMeterHUD.y += speed; - if (sPowerMeterHUD.y >= 201) { + if (sPowerMeterHUD.y > 200) { sPowerMeterHUD.y = 200; sPowerMeterHUD.animation = POWER_METER_VISIBLE; } @@ -181,7 +176,7 @@ static void animate_power_meter_deemphasizing(void) { */ static void animate_power_meter_hiding(void) { sPowerMeterHUD.y += 20; - if (sPowerMeterHUD.y >= 301) { + if (sPowerMeterHUD.y > 300) { sPowerMeterHUD.animation = POWER_METER_HIDDEN; sPowerMeterVisibleTimer = 0; } @@ -192,7 +187,8 @@ static void animate_power_meter_hiding(void) { */ void handle_power_meter_actions(s16 numHealthWedges) { // Show power meter if health is not full, less than 8 - if (numHealthWedges < 8 && sPowerMeterStoredHealth == 8 && sPowerMeterHUD.animation == POWER_METER_HIDDEN) { + if (numHealthWedges < 8 && sPowerMeterStoredHealth == 8 + && sPowerMeterHUD.animation == POWER_METER_HIDDEN) { sPowerMeterHUD.animation = POWER_METER_EMPHASIZED; sPowerMeterHUD.y = 166; } @@ -253,7 +249,7 @@ void render_hud_power_meter(void) { render_dl_power_meter(shownHealthWedges); - sPowerMeterVisibleTimer += 1; + sPowerMeterVisibleTimer++; } #ifdef VERSION_JP @@ -293,7 +289,7 @@ void render_hud_coins(void) { void render_hud_stars(void) { s8 showX = 0; - if (gHudFlash == 1 && gGlobalTimer & 0x08) { + if (gHudFlash == 1 && gGlobalTimer & 8) { return; } @@ -325,14 +321,12 @@ void render_hud_keys(void) { * Renders the timer when Mario start sliding in PSS. */ void render_hud_timer(void) { - u8 *(*hudLUT)[58]; - u16 timerValFrames; - u16 timerMins; - u16 timerSecs; - u16 timerFracSecs; + u8 *(*hudLUT)[58] = segmented_to_virtual(&main_hud_lut); + u16 timerValFrames = gHudDisplay.timer; + u16 timerMins = timerValFrames / (30 * 60); + u16 timerSecs = (timerValFrames - (timerMins * 1800)) / 30; + u16 timerFracSecs = ((timerValFrames - (timerMins * 1800) - (timerSecs * 30)) & 0xFFFF) / 3; - hudLUT = segmented_to_virtual(&main_hud_lut); - timerValFrames = gHudDisplay.timer; #ifdef VERSION_EU switch (eu_get_language()) { case LANGUAGE_ENGLISH: @@ -345,17 +339,14 @@ void render_hud_timer(void) { print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "ZEIT"); break; } -#endif - timerMins = timerValFrames / (30 * 60); - timerSecs = (timerValFrames - (timerMins * 1800)) / 30; - - timerFracSecs = ((timerValFrames - (timerMins * 1800) - (timerSecs * 30)) & 0xFFFF) / 3; -#ifndef VERSION_EU +#else print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "TIME"); #endif + print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(91), 185, "%0d", timerMins); print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(71), 185, "%02d", timerSecs); print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(37), 185, "%d", timerFracSecs); + gSPDisplayList(gDisplayListHead++, dl_hud_img_begin); render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(81), 32, (*hudLUT)[GLYPH_APOSTROPHE]); render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(46), 32, (*hudLUT)[GLYPH_DOUBLE_QUOTE]); @@ -375,13 +366,9 @@ void set_hud_camera_status(s16 status) { * the camera status called, a defined glyph is rendered. */ void render_hud_camera_status(void) { - u8 *(*cameraLUT)[6]; - s32 x; - s32 y; - - cameraLUT = segmented_to_virtual(&main_hud_camera_lut); - x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(54); - y = 205; + u8 *(*cameraLUT)[6] = segmented_to_virtual(&main_hud_camera_lut); + s32 x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(54); + s32 y = 205; if (sCameraHUD.status == CAM_STATUS_NONE) { return; @@ -419,12 +406,7 @@ void render_hud_camera_status(void) { * excluding the cannon reticle which detects a camera preset for it. */ void render_hud(void) { - s16 hudDisplayFlags; -#ifdef VERSION_EU - Mtx *mtx; -#endif - - hudDisplayFlags = gHudDisplay.flags; + s16 hudDisplayFlags = gHudDisplay.flags; if (hudDisplayFlags == HUD_DISPLAY_NONE) { sPowerMeterHUD.animation = POWER_METER_HIDDEN; @@ -433,16 +415,17 @@ void render_hud(void) { } else { #ifdef VERSION_EU // basically create_dl_ortho_matrix but guOrtho screen width is different + Mtx *mtx = alloc_display_list(sizeof(*mtx)); - mtx = alloc_display_list(sizeof(*mtx)); if (mtx == NULL) { return; } + create_dl_identity_matrix(); guOrtho(mtx, -16.0f, SCREEN_WIDTH + 16, 0, SCREEN_HEIGHT, -10.0f, 10.0f, 1.0f); gSPPerspNormalize(gDisplayListHead++, 0xFFFF); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), - G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH); + G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH); #else create_dl_ortho_matrix(); #endif diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 6bf16738..5c74037f 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -23,13 +23,18 @@ #include "text_strings.h" #include "types.h" +#ifdef VERSION_EU +#undef LANGUAGE_FUNCTION +#define LANGUAGE_FUNCTION gInGameLanguage +#endif + u16 gDialogColorFadeTimer; s8 gLastDialogLineNum; s32 gDialogVariable; u16 gDialogTextAlpha; #if defined(VERSION_EU) -s16 gDialogX; // D_8032F69A -s16 gDialogY; // D_8032F69C +s16 gDialogX; +s16 gDialogY; #endif s16 gCutsceneMsgXOffset; s16 gCutsceneMsgYOffset; @@ -56,8 +61,6 @@ enum DialogBoxType { DIALOG_TYPE_ZOOM // used in signposts and wall signs and etc }; -enum DialogMark { DIALOG_MARK_NONE = 0, DIALOG_MARK_DAKUTEN = 1, DIALOG_MARK_HANDAKUTEN = 2 }; - #define DEFAULT_DIALOG_BOX_ANGLE 90.0f #define DEFAULT_DIALOG_BOX_SCALE 19.0f @@ -103,7 +106,7 @@ s16 gDialogID = DIALOG_NONE; s16 gLastDialogPageStrPos = 0; s16 gDialogTextPos = 0; #ifdef VERSION_EU -s32 gInGameLanguage = 0; +s32 gInGameLanguage = LANGUAGE_ENGLISH; #endif s8 gDialogLineNum = 1; s8 gLastDialogResponse = 0; @@ -141,11 +144,13 @@ void create_dl_translation_matrix(s8 pushOp, f32 x, f32 y, f32 z) { guTranslate(matrix, x, y, z); - if (pushOp == MENU_MTX_PUSH) + if (pushOp == MENU_MTX_PUSH) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH); + } - if (pushOp == MENU_MTX_NOPUSH) + if (pushOp == MENU_MTX_NOPUSH) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); + } } void create_dl_rotation_matrix(s8 pushOp, f32 a, f32 x, f32 y, f32 z) { @@ -157,11 +162,13 @@ void create_dl_rotation_matrix(s8 pushOp, f32 a, f32 x, f32 y, f32 z) { guRotate(matrix, a, x, y, z); - if (pushOp == MENU_MTX_PUSH) + if (pushOp == MENU_MTX_PUSH) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH); + } - if (pushOp == MENU_MTX_NOPUSH) + if (pushOp == MENU_MTX_NOPUSH) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); + } } void create_dl_scale_matrix(s8 pushOp, f32 x, f32 y, f32 z) { @@ -173,11 +180,13 @@ void create_dl_scale_matrix(s8 pushOp, f32 x, f32 y, f32 z) { guScale(matrix, x, y, z); - if (pushOp == MENU_MTX_PUSH) + if (pushOp == MENU_MTX_PUSH) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH); + } - if (pushOp == MENU_MTX_NOPUSH) + if (pushOp == MENU_MTX_NOPUSH) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); + } } void create_dl_ortho_matrix(void) { @@ -197,7 +206,7 @@ void create_dl_ortho_matrix(void) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH) } -#if !defined(VERSION_JP) && !defined(VERSION_SH) +#if defined(VERSION_US) || defined(VERSION_EU) UNUSED #endif static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) { @@ -206,7 +215,7 @@ static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) { u8 *out; s16 outPos = 0; - out = alloc_display_list((u32) width * (u32) height); + out = (u8 *) alloc_display_list((u32) width * (u32) height); if (out == NULL) { return NULL; @@ -231,24 +240,18 @@ static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) { } void render_generic_char(u8 c) { - void **fontLUT; - void *packedTexture; + void **fontLUT = segmented_to_virtual(main_font_lut); + void *packedTexture = segmented_to_virtual(fontLUT[c]); #if defined(VERSION_JP) || defined(VERSION_SH) - void *unpackedTexture; + void *unpackedTexture = alloc_ia8_text_from_i1(packedTexture, 8, 16); #endif - fontLUT = segmented_to_virtual(main_font_lut); - packedTexture = segmented_to_virtual(fontLUT[c]); - -#if defined(VERSION_JP) || defined(VERSION_SH) - unpackedTexture = alloc_ia8_text_from_i1(packedTexture, 8, 16); - +#ifndef VERSION_EU gDPPipeSync(gDisplayListHead++); +#endif +#if defined(VERSION_JP) || defined(VERSION_SH) gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, VIRTUAL_TO_PHYSICAL(unpackedTexture)); #else -#ifdef VERSION_US - gDPPipeSync(gDisplayListHead++); -#endif gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, VIRTUAL_TO_PHYSICAL(packedTexture)); #endif gSPDisplayList(gDisplayListHead++, dl_ia_text_tex_settings); @@ -263,10 +266,9 @@ u8 *alloc_ia4_tex_from_i1(u8 *in, s16 width, s16 height) { u32 size = (u32) width * (u32) height; u8 *out; s32 inPos; - s16 outPos; + s16 outPos = 0; u8 bitMask; - outPos = 0; out = (u8 *) alloc_display_list(size); if (out == NULL) { @@ -275,6 +277,7 @@ u8 *alloc_ia4_tex_from_i1(u8 *in, s16 width, s16 height) { for (inPos = 0; inPos < (width * height) / 4; inPos++) { bitMask = 0x80; + while (bitMask != 0) { out[outPos] = (in[inPos] & bitMask) ? 0xF0 : 0x00; bitMask /= 2; @@ -288,13 +291,9 @@ u8 *alloc_ia4_tex_from_i1(u8 *in, s16 width, s16 height) { } void render_generic_char_at_pos(s16 xPos, s16 yPos, u8 c) { - void **fontLUT; - void *packedTexture; - void *unpackedTexture; - - fontLUT = segmented_to_virtual(main_font_lut); - packedTexture = segmented_to_virtual(fontLUT[c]); - unpackedTexture = alloc_ia4_tex_from_i1(packedTexture, 8, 8); + void **fontLUT = segmented_to_virtual(main_font_lut); + void *packedTexture = segmented_to_virtual(fontLUT[c]); + void *unpackedTexture = alloc_ia4_tex_from_i1(packedTexture, 8, 8); gDPPipeSync(gDisplayListHead++); gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, VIRTUAL_TO_PHYSICAL(unpackedTexture)); @@ -316,7 +315,7 @@ void render_uppercase_diacritic(s16 *xPos, s16 *yPos, u8 letter, u8 diacritic) { } #endif // VERSION_EU -#if !defined(VERSION_JP) && !defined(VERSION_SH) +#if defined(VERSION_US) || defined(VERSION_EU) struct MultiTextEntry { u8 length; u8 str[4]; @@ -332,7 +331,7 @@ enum MultiStringIDs { STRING_THE, STRING_YOU }; * 0: 'the' * 1: 'you' */ -#ifdef VERSION_US +#if defined(VERSION_US) void render_multi_text_string(s8 multiTextID) #elif defined(VERSION_EU) void render_multi_text_string(s16 *xPos, s16 *yPos, s8 multiTextID) @@ -345,9 +344,10 @@ void render_multi_text_string(s16 *xPos, s16 *yPos, s8 multiTextID) }; for (i = 0; i < textLengths[multiTextID].length; i++) { -#ifdef VERSION_US +#if defined(VERSION_US) render_generic_char(textLengths[multiTextID].str[i]); - create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[textLengths[multiTextID].str[i]]), 0.0f, 0.0f); + create_dl_translation_matrix( + MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[textLengths[multiTextID].str[i]]), 0.0f, 0.0f); #elif defined(VERSION_EU) render_generic_char_at_pos(*xPos, *yPos, textLengths[multiTextID].str[i]); *xPos += gDialogCharWidths[textLengths[multiTextID].str[i]]; @@ -357,9 +357,13 @@ void render_multi_text_string(s16 *xPos, s16 *yPos, s8 multiTextID) #endif #if defined(VERSION_JP) || defined(VERSION_SH) -#define MAX_STRING_WIDTH 18 + #define MAX_STRING_WIDTH 18 + #define CHAR_WIDTH_SPACE 5.0f + #define CHAR_WIDTH_DEFAULT 10.0f #else -#define MAX_STRING_WIDTH 16 + #define MAX_STRING_WIDTH 16 + #define CHAR_WIDTH_SPACE (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE]) + #define CHAR_WIDTH_DEFAULT (f32)(gDialogCharWidths[str[strPos]]) #endif /** @@ -447,12 +451,14 @@ void print_generic_string(s16 x, s16 y, const u8 *str) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); break; #endif -#if !defined(VERSION_JP) && !defined(VERSION_SH) + +#if defined(VERSION_US) || defined(VERSION_EU) case DIALOG_CHAR_SLASH: -#ifdef VERSION_US - create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * 2), 0.0f, 0.0f); -#elif defined(VERSION_EU) +#ifdef VERSION_EU xCoord += gDialogCharWidths[DIALOG_CHAR_SPACE] * 2; +#else + create_dl_translation_matrix( + MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * 2), 0.0f, 0.0f); #endif break; case DIALOG_CHAR_MULTI_THE: @@ -470,36 +476,33 @@ void print_generic_string(s16 x, s16 y, const u8 *str) { #endif break; #endif + #ifndef VERSION_EU case DIALOG_CHAR_SPACE: -#if defined(VERSION_JP) || defined(VERSION_SH) - create_dl_translation_matrix(MENU_MTX_NOPUSH, 5.0f, 0.0f, 0.0f); + create_dl_translation_matrix(MENU_MTX_NOPUSH, CHAR_WIDTH_SPACE, 0.0f, 0.0f); break; -#else - create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE]), 0.0f, 0.0f); -#endif -#endif +#ifdef VERSION_JP break; // ? needed to match +#endif +#endif + default: #ifdef VERSION_EU render_generic_char_at_pos(xCoord, yCoord, str[strPos]); xCoord += gDialogCharWidths[str[strPos]]; - break; #else render_generic_char(str[strPos]); if (mark != DIALOG_MARK_NONE) { create_dl_translation_matrix(MENU_MTX_PUSH, 5.0f, 5.0f, 0.0f); - render_generic_char(mark + 0xEF); + render_generic_char(DIALOG_CHAR_MARK_START + mark); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); mark = DIALOG_MARK_NONE; } -#if defined(VERSION_JP) || defined(VERSION_SH) - create_dl_translation_matrix(MENU_MTX_NOPUSH, 10.0f, 0.0f, 0.0f); -#else - create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[str[strPos]]), 0.0f, 0.0f); - break; // what an odd difference. US added a useless break here. + create_dl_translation_matrix(MENU_MTX_NOPUSH, CHAR_WIDTH_DEFAULT, 0.0f, 0.0f); #endif +#ifndef VERSION_JP + break; // what an odd difference. US (and probably later) versions added a useless break here. #endif } @@ -654,7 +657,7 @@ void print_menu_generic_string(s16 x, s16 y, const u8 *str) { #ifndef VERSION_EU if (mark != DIALOG_MARK_NONE) { - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, fontLUT[mark + 0xEF]); + gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, fontLUT[DIALOG_CHAR_MARK_START + mark]); gDPLoadSync(gDisplayListHead++); gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 8 * 8 - 1, CALC_DXT(8, G_IM_SIZ_8b_BYTES)); gSPTextureRectangle(gDisplayListHead++, (curX + 6) << 2, (curY - 7) << 2, @@ -727,21 +730,21 @@ void handle_menu_scrolling(s8 scrollDirection, s8 *currentIndex, s8 minIndex, s8 } if (((index ^ gMenuHoldKeyIndex) & index) == 2) { - if (currentIndex[0] == maxIndex) { + if (*currentIndex == maxIndex) { //! Probably originally a >=, but later replaced with an == and an else statement. - currentIndex[0] = maxIndex; + *currentIndex = maxIndex; } else { play_sound(SOUND_MENU_CHANGE_SELECT, gGlobalSoundSource); - currentIndex[0]++; + (*currentIndex)++; } } if (((index ^ gMenuHoldKeyIndex) & index) == 1) { - if (currentIndex[0] == minIndex) { + if (*currentIndex == minIndex) { // Same applies to here as above } else { play_sound(SOUND_MENU_CHANGE_SELECT, gGlobalSoundSource); - currentIndex[0]--; + (*currentIndex)--; } } @@ -759,7 +762,7 @@ void handle_menu_scrolling(s8 scrollDirection, s8 *currentIndex, s8 minIndex, s8 } // EU has both get_str_x_pos_from_center and get_str_x_pos_from_center_scale -// US and JP only implement one or the other +// JP, US and Shindou only implement one or the other #if defined(VERSION_US) || defined(VERSION_EU) s16 get_str_x_pos_from_center(s16 centerPos, u8 *str, UNUSED f32 scale) { s16 strPos = 0; @@ -797,7 +800,7 @@ s16 get_str_x_pos_from_center_scale(s16 centerPos, u8 *str, f32 scale) { } #endif -#if !defined(VERSION_JP) && !defined(VERSION_SH) +#if defined(VERSION_US) || defined(VERSION_EU) s16 get_string_width(u8 *str) { s16 strPos = 0; s16 width = 0; @@ -813,14 +816,14 @@ s16 get_string_width(u8 *str) { u8 gHudSymCoin[] = { GLYPH_COIN, GLYPH_SPACE }; u8 gHudSymX[] = { GLYPH_MULTIPLY, GLYPH_SPACE }; -void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileNum, s8 courseNum, s16 x, s16 y) { +void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileIndex, s8 courseIndex, s16 x, s16 y) { u8 strNumCoins[4]; s16 numCoins; if (!useCourseCoinScore) { - numCoins = (u16)(save_file_get_max_coin_score(courseNum) & 0xFFFF); + numCoins = (u16)(save_file_get_max_coin_score(courseIndex) & 0xFFFF); } else { - numCoins = save_file_get_course_coin_score(fileNum, courseNum); + numCoins = save_file_get_course_coin_score(fileIndex, courseIndex); } if (numCoins != 0) { @@ -831,14 +834,14 @@ void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileNum, s8 courseNum, } } -void print_hud_my_score_stars(s8 fileNum, s8 courseNum, s16 x, s16 y) { +void print_hud_my_score_stars(s8 fileIndex, s8 courseIndex, s16 x, s16 y) { u8 strStarCount[4]; s16 starCount; u8 textSymStar[] = { GLYPH_STAR, GLYPH_SPACE }; UNUSED u16 unused; u8 textSymX[] = { GLYPH_MULTIPLY, GLYPH_SPACE }; - starCount = save_file_get_course_star_count(fileNum, courseNum); + starCount = save_file_get_course_star_count(fileIndex, courseIndex); if (starCount != 0) { print_hud_lut_string(HUD_LUT_GLOBAL, x, y, textSymStar); @@ -928,17 +931,17 @@ void reset_dialog_render_state(void) { } #if defined(VERSION_JP) || defined(VERSION_SH) -#define X_VAL1 -5.0f -#define Y_VAL1 2.0 -#define Y_VAL2 4 + #define X_VAL1 -5.0f + #define Y_VAL1 2.0 + #define Y_VAL2 4 #else -#define X_VAL1 -7.0f -#define Y_VAL1 5.0 -#define Y_VAL2 5.0f + #define X_VAL1 -7.0f + #define Y_VAL1 5.0 + #define Y_VAL2 5.0f #endif void render_dialog_box_type(struct DialogEntry *dialog, s8 linesPerBox) { - UNUSED s32 unused; + UNUSED u8 filler[4]; create_dl_translation_matrix(MENU_MTX_NOPUSH, dialog->leftOffset, dialog->width, 0); @@ -995,26 +998,16 @@ void change_and_flash_dialog_text_color_lines(s8 colorMode, s8 lineNum) { #ifdef VERSION_EU void render_generic_dialog_char_at_pos(struct DialogEntry *dialog, s16 x, s16 y, u8 c) { - s16 width; - s16 height; - s16 tmpX; - s16 tmpY; - s16 xCoord; - s16 yCoord; - void **fontLUT; - void *packedTexture; - void *unpackedTexture; + s16 width = (8.0 - (gDialogBoxScale * 0.8)); + s16 height = (16.0 - (gDialogBoxScale * 0.8)); + s16 tmpX = (dialog->leftOffset + (65.0 - (65.0 / gDialogBoxScale))); + s16 tmpY = ((240 - dialog->width) - ((40.0 / gDialogBoxScale) - 40)); + s16 xCoord = (tmpX + (x / gDialogBoxScale)); + s16 yCoord = (tmpY + (y / gDialogBoxScale)); - width = (8.0 - (gDialogBoxScale * 0.8)); - height = (16.0 - (gDialogBoxScale * 0.8)); - tmpX = (dialog->leftOffset + (65.0 - (65.0 / gDialogBoxScale))); - tmpY = ((240 - dialog->width) - ((40.0 / gDialogBoxScale) - 40)); - xCoord = (tmpX + (x / gDialogBoxScale)); - yCoord = (tmpY + (y / gDialogBoxScale)); - - fontLUT = segmented_to_virtual(main_font_lut); - packedTexture = segmented_to_virtual(fontLUT[c]); - unpackedTexture = alloc_ia4_tex_from_i1(packedTexture, 8, 8); + void **fontLUT = segmented_to_virtual(main_font_lut); + void *packedTexture = segmented_to_virtual(fontLUT[c]); + void *unpackedTexture = alloc_ia4_tex_from_i1(packedTexture, 8, 8); gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, VIRTUAL_TO_PHYSICAL(unpackedTexture)); gSPDisplayList(gDisplayListHead++, dl_ia_text_tex_settings); @@ -1024,11 +1017,11 @@ void render_generic_dialog_char_at_pos(struct DialogEntry *dialog, s16 x, s16 y, #endif #if defined(VERSION_JP) || defined(VERSION_SH) -#define X_VAL3 5.0f -#define Y_VAL3 20 + #define X_VAL3 5.0f + #define Y_VAL3 20 #else -#define X_VAL3 0.0f -#define Y_VAL3 16 + #define X_VAL3 0.0f + #define Y_VAL3 16 #endif #ifdef VERSION_EU @@ -1042,7 +1035,7 @@ void handle_dialog_scroll_page_state(s8 lineNum, s8 totalLines, s8 *pageState, s #endif if (lineNum == totalLines) { - pageState[0] = DIALOG_PAGE_STATE_SCROLL; + *pageState = DIALOG_PAGE_STATE_SCROLL; return; } #ifdef VERSION_EU @@ -1050,15 +1043,15 @@ void handle_dialog_scroll_page_state(s8 lineNum, s8 totalLines, s8 *pageState, s #else create_dl_translation_matrix(MENU_MTX_PUSH, X_VAL3, 2 - (lineNum * Y_VAL3), 0); - linePos[0] = 0; + *linePos = 0; #endif - xMatrix[0] = 1; + *xMatrix = 1; } #if defined(VERSION_JP) || defined(VERSION_SH) void adjust_pos_and_print_period_char(s8 *xMatrix, s16 *linePos) { - if (linePos[0] != 0) { - create_dl_translation_matrix(MENU_MTX_NOPUSH, xMatrix[0] * 10, 0, 0); + if (*linePos != 0) { + create_dl_translation_matrix(MENU_MTX_NOPUSH, 10 * *xMatrix, 0, 0); } create_dl_translation_matrix(MENU_MTX_PUSH, -2.0f, -5.0f, 0); @@ -1066,8 +1059,8 @@ void adjust_pos_and_print_period_char(s8 *xMatrix, s16 *linePos) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - linePos[0]++; - xMatrix[0] = 1; + (*linePos)++; + *xMatrix = 1; } #endif @@ -1082,57 +1075,57 @@ void render_star_count_dialog_text(s8 *xMatrix, s16 *linePos) if (tensDigit != 0) { #if defined(VERSION_JP) || defined(VERSION_SH) - create_dl_translation_matrix(MENU_MTX_NOPUSH, xMatrix[0] * 10, 0, 0); + create_dl_translation_matrix(MENU_MTX_NOPUSH, 10 * *xMatrix, 0, 0); render_generic_char(tensDigit); -#elif defined(VERSION_EU) - render_generic_dialog_char_at_pos(dialog, gDialogX, gDialogY, tensDigit); - gDialogX += gDialogCharWidths[tensDigit]; - linePos[0] = 1; -#else - if (xMatrix[0] != 1) { - create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * xMatrix[0]), 0, 0); +#elif defined(VERSION_US) + if (*xMatrix != 1) { + create_dl_translation_matrix( + MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * *xMatrix), 0, 0); } render_generic_char(tensDigit); create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32) gDialogCharWidths[tensDigit], 0, 0); - xMatrix[0] = 1; - linePos[0]++; + *xMatrix = 1; + (*linePos)++; +#elif defined(VERSION_EU) + render_generic_dialog_char_at_pos(dialog, gDialogX, gDialogY, tensDigit); + gDialogX += gDialogCharWidths[tensDigit]; + *linePos = 1; #endif } #ifndef VERSION_EU else { #if defined(VERSION_JP) || defined(VERSION_SH) - xMatrix[0]++; + (*xMatrix)++; #endif } #endif -#ifdef VERSION_EU - render_generic_dialog_char_at_pos(dialog, gDialogX, gDialogY, onesDigit); - gDialogX += gDialogCharWidths[onesDigit]; - linePos[0] = 1; -#else - +#ifndef VERSION_EU #if defined(VERSION_JP) || defined(VERSION_SH) - create_dl_translation_matrix(MENU_MTX_NOPUSH, xMatrix[0] * 10, 0, 0); + create_dl_translation_matrix(MENU_MTX_NOPUSH, 10 * *xMatrix, 0, 0); render_generic_char(onesDigit); -#else - if (xMatrix[0] != 1) { - create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * (xMatrix[0] - 1)), 0, 0); +#elif defined(VERSION_US) + if (*xMatrix != 1) { + create_dl_translation_matrix( + MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * (*xMatrix - 1)), 0, 0); } render_generic_char(onesDigit); create_dl_translation_matrix(MENU_MTX_NOPUSH, (f32) gDialogCharWidths[onesDigit], 0, 0); #endif - - linePos[0]++; - xMatrix[0] = 1; + (*linePos)++; + *xMatrix = 1; +#else // VERSION_EU + render_generic_dialog_char_at_pos(dialog, gDialogX, gDialogY, onesDigit); + gDialogX += gDialogCharWidths[onesDigit]; + *linePos = 1; #endif } -#if !defined(VERSION_JP) && !defined(VERSION_SH) +#if defined(VERSION_US) || defined(VERSION_EU) #ifdef VERSION_EU -void render_multi_text_string_lines(s8 multiTextId, s8 lineNum, s8 linesPerBox, UNUSED s16 linePos, s8 lowerBound, struct DialogEntry *dialog) +void render_multi_text_string_lines(s8 multiTextId, s8 lineNum, s8 linesPerBox, UNUSED s8 xMatrix, s8 lowerBound, struct DialogEntry *dialog) #else void render_multi_text_string_lines(s8 multiTextId, s8 lineNum, s16 *linePos, s8 linesPerBox, s8 xMatrix, s8 lowerBound) #endif @@ -1145,8 +1138,9 @@ void render_multi_text_string_lines(s8 multiTextId, s8 lineNum, s16 *linePos, s8 if (lineNum >= lowerBound && lineNum <= (lowerBound + linesPerBox)) { #ifdef VERSION_US - if (linePos[0] != 0 || (xMatrix != 1)) { - create_dl_translation_matrix(MENU_MTX_NOPUSH, (gDialogCharWidths[DIALOG_CHAR_SPACE] * (xMatrix - 1)), 0, 0); + if (*linePos != 0 || xMatrix != 1) { + create_dl_translation_matrix( + MENU_MTX_NOPUSH, (gDialogCharWidths[DIALOG_CHAR_SPACE] * (xMatrix - 1)), 0, 0); } #endif for (i = 0; i < textLengths[multiTextId].length; i++) { @@ -1155,10 +1149,12 @@ void render_multi_text_string_lines(s8 multiTextId, s8 lineNum, s16 *linePos, s8 gDialogX += gDialogCharWidths[textLengths[multiTextId].str[i]]; #else render_generic_char(textLengths[multiTextId].str[i]); - create_dl_translation_matrix(MENU_MTX_NOPUSH, (gDialogCharWidths[textLengths[multiTextId].str[i]]), 0, 0); + create_dl_translation_matrix( + MENU_MTX_NOPUSH, (gDialogCharWidths[textLengths[multiTextId].str[i]]), 0, 0); #endif } } + #ifdef VERSION_US linePos += textLengths[multiTextId].length; #endif @@ -1187,30 +1183,24 @@ u32 ensure_nonnegative(s16 value) { return value; } -#if defined(VERSION_JP) +#ifdef VERSION_JP void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog) #else void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 lowerBound) #endif { - UNUSED s32 pad[2]; + UNUSED u8 filler[8]; #ifdef VERSION_EU s16 startY = 14; #endif - u8 strChar; - u8 *str = segmented_to_virtual(dialog->str); s8 lineNum = 1; - s8 totalLines; - s8 pageState = DIALOG_PAGE_STATE_NONE; - UNUSED s8 mark = DIALOG_MARK_NONE; // unused in US, EU + UNUSED s8 mark = DIALOG_MARK_NONE; // unused in US and EU s8 xMatrix = 1; - s8 linesPerBox = dialog->linesPerBox; - s16 strIdx; #ifndef VERSION_EU s16 linePos = 0; @@ -1225,7 +1215,9 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l } gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); + strIdx = gDialogTextPos; + #ifdef VERSION_EU gDialogX = 0; gDialogY = startY; @@ -1262,10 +1254,11 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l #else handle_dialog_scroll_page_state(lineNum, totalLines, &pageState, &xMatrix, &linePos); #ifdef VERSION_SH - mark = 0; + mark = DIALOG_MARK_NONE; #endif #endif break; + #ifdef VERSION_EU case DIALOG_CHAR_LOWER_A_GRAVE: case DIALOG_CHAR_LOWER_A_CIRCUMFLEX: @@ -1319,6 +1312,7 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l mark = DIALOG_MARK_HANDAKUTEN; break; #endif + case DIALOG_CHAR_SPACE: #ifdef VERSION_EU gDialogX += gDialogCharWidths[DIALOG_CHAR_SPACE]; @@ -1331,9 +1325,9 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l } #endif linePos++; - #endif break; + #if defined(VERSION_JP) || defined(VERSION_SH) case DIALOG_CHAR_PERIOD: adjust_pos_and_print_period_char(&xMatrix, &linePos); @@ -1364,6 +1358,7 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l xMatrix = 1; break; #endif + case DIALOG_CHAR_STAR_COUNT: #ifdef VERSION_EU render_star_count_dialog_text(dialog, &xMatrix); @@ -1371,37 +1366,39 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l render_star_count_dialog_text(&xMatrix, &linePos); #endif break; + #ifdef VERSION_EU case DIALOG_CHAR_DOUBLE_LOW_QUOTE: render_generic_dialog_char_at_pos(dialog, gDialogX, gDialogY + 8, 0xF6); gDialogX += gDialogCharWidths[0xF6]; break; #endif + default: // any other character #if defined(VERSION_JP) || defined(VERSION_SH) #ifdef VERSION_SH - if (lineNum >= lowerBound && lineNum <= lowerBound + linesPerBox) { + if (lineNum >= lowerBound && lineNum <= (lowerBound + linesPerBox)) { #endif if (linePos != 0) { - create_dl_translation_matrix(MENU_MTX_NOPUSH, xMatrix * 10, 0, 0); + create_dl_translation_matrix(MENU_MTX_NOPUSH, 10 * xMatrix, 0, 0); } render_generic_char(strChar); xMatrix = 1; linePos++; - if (mark != 0) { + if (mark != DIALOG_MARK_NONE) { create_dl_translation_matrix(MENU_MTX_PUSH, 5.0f, 7.0f, 0); - render_generic_char(mark + 0xEF); + render_generic_char(DIALOG_CHAR_MARK_START + mark); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mark = 0; + mark = DIALOG_MARK_NONE; } #ifdef VERSION_SH } #endif #elif defined(VERSION_US) - if (lineNum >= lowerBound && lineNum <= lowerBound + linesPerBox) { - if (linePos || xMatrix != 1) { + if (lineNum >= lowerBound && lineNum <= (lowerBound + linesPerBox)) { + if (linePos != 0 || xMatrix != 1) { create_dl_translation_matrix( MENU_MTX_NOPUSH, (f32)(gDialogCharWidths[DIALOG_CHAR_SPACE] * (xMatrix - 1)), 0, 0); } @@ -1412,14 +1409,14 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l linePos++; } #else // VERSION_EU - if (lineNum >= lowerBound && lineNum <= lowerBound + linesPerBox) { + if (lineNum >= lowerBound && lineNum <= (lowerBound + linesPerBox)) { render_generic_dialog_char_at_pos(dialog, gDialogX, gDialogY, strChar); } gDialogX += gDialogCharWidths[strChar]; #endif } -#if defined(VERSION_JP) +#ifdef VERSION_JP if (linePos == 12) { if (str[strIdx + 1] == DIALOG_CHAR_PERIOD) { adjust_pos_and_print_period_char(&xMatrix, &linePos); @@ -1427,7 +1424,7 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l } if (str[strIdx + 1] == DIALOG_CHAR_COMMA) { - create_dl_translation_matrix(MENU_MTX_NOPUSH, xMatrix * 10, 0, 0); + create_dl_translation_matrix(MENU_MTX_NOPUSH, 10 * xMatrix, 0, 0); render_generic_char(DIALOG_CHAR_COMMA); strIdx++; } @@ -1449,6 +1446,7 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l strIdx++; } + gSPDisplayList(gDisplayListHead++, dl_ia_text_end); if (gDialogBoxState == DIALOG_STATE_VERTICAL) { @@ -1463,15 +1461,15 @@ void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 l } #if defined(VERSION_JP) || defined(VERSION_SH) -#define X_VAL4_1 50 -#define X_VAL4_2 25 -#define Y_VAL4_1 1 -#define Y_VAL4_2 20 + #define X_VAL4_1 50 + #define X_VAL4_2 25 + #define Y_VAL4_1 1 + #define Y_VAL4_2 20 #else -#define X_VAL4_1 56 -#define X_VAL4_2 47 -#define Y_VAL4_1 2 -#define Y_VAL4_2 16 + #define X_VAL4_1 56 + #define X_VAL4_2 47 + #define Y_VAL4_1 2 + #define Y_VAL4_2 16 #endif void render_dialog_triangle_choice(void) { @@ -1490,27 +1488,27 @@ void render_dialog_triangle_choice(void) { gSPDisplayList(gDisplayListHead++, dl_draw_triangle); } -#ifdef VERSION_EU -#define X_VAL5 122.0f -#define Y_VAL5_1 -16 -#define Y_VAL5_2 3 -#define X_Y_VAL6 0.5f +#if defined(VERSION_JP) || defined(VERSION_SH) + #define X_VAL5 123.0f + #define Y_VAL5_1 -20 + #define Y_VAL5_2 2 + #define X_Y_VAL6 0.8f #elif defined(VERSION_US) -#define X_VAL5 118.0f -#define Y_VAL5_1 -16 -#define Y_VAL5_2 5 -#define X_Y_VAL6 0.8f -#elif defined(VERSION_JP) || defined(VERSION_SH) -#define X_VAL5 123.0f -#define Y_VAL5_1 -20 -#define Y_VAL5_2 2 -#define X_Y_VAL6 0.8f + #define X_VAL5 118.0f + #define Y_VAL5_1 -16 + #define Y_VAL5_2 5 + #define X_Y_VAL6 0.8f +#elif defined(VERSION_EU) + #define X_VAL5 122.0f + #define Y_VAL5_1 -16 + #define Y_VAL5_2 3 + #define X_Y_VAL6 0.5f #endif -void render_dialog_string_color(s8 linesPerBox) { - s32 timer = gGlobalTimer; +void render_dialog_triangle_next(s8 linesPerBox) { + s32 globalTimer = gGlobalTimer; - if (timer & 0x08) { + if (globalTimer & 8) { return; } @@ -1531,7 +1529,7 @@ void render_dialog_string_color(s8 linesPerBox) { void handle_special_dialog_text(s16 dialogID) { // dialog ID tables, in order // King Bob-omb (Start), Whomp (Start), King Bob-omb (throw him out), Eyerock (Start), Wiggler (Start) s16 dialogBossStart[] = { DIALOG_017, DIALOG_114, DIALOG_128, DIALOG_117, DIALOG_150 }; - // Koopa the Quick (BOB), Koopa the Quick (THI), Penguin Race, Fat Penguin Race (120 stars) + // Koopa the Quick (BoB), Koopa the Quick (THI), Penguin Race, Fat Penguin Race (120 stars) s16 dialogRaceSound[] = { DIALOG_005, DIALOG_009, DIALOG_055, DIALOG_164 }; // Red Switch, Green Switch, Blue Switch, 100 coins star, Bowser Red Coin Star s16 dialogStarSound[] = { DIALOG_010, DIALOG_011, DIALOG_012, DIALOG_013, DIALOG_014 }; @@ -1540,7 +1538,7 @@ void handle_special_dialog_text(s16 dialogID) { // dialog ID tables, in order s16 dialogBossStop[] = { DIALOG_017, DIALOG_115, DIALOG_116, DIALOG_118, DIALOG_152 }; #else //! @bug JP misses King Bob-omb defeated DIALOG_116, meaning that the boss music will still - //! play after King Bob-omb is defeated until BOB loads it's music after the star cutscene + //! play after King Bob-omb is defeated until BoB loads it's music after the star cutscene s16 dialogBossStop[] = { DIALOG_017, DIALOG_115, DIALOG_118, DIALOG_152 }; #endif s16 i; @@ -1661,18 +1659,19 @@ s8 gDialogCameraAngleIndex = CAM_SELECTION_MARIO; s8 gDialogCourseActNum = 1; #if defined(VERSION_JP) || defined(VERSION_SH) -#define DIAG_VAL1 20 -#define DIAG_VAL3 130 -#define DIAG_VAL4 4 + #define DIAG_VAL1 20 + #define DIAG_VAL2 240 + #define DIAG_VAL3 130 + #define DIAG_VAL4 4 #else -#define DIAG_VAL1 16 -#define DIAG_VAL3 132 // US & EU -#define DIAG_VAL4 5 + #define DIAG_VAL1 16 +#ifdef VERSION_US + #define DIAG_VAL2 240 +#else + #define DIAG_VAL2 238 #endif -#ifdef VERSION_EU -#define DIAG_VAL2 238 -#else -#define DIAG_VAL2 240 // JP & US + #define DIAG_VAL3 132 + #define DIAG_VAL4 5 #endif void render_dialog_entries(void) { @@ -1684,6 +1683,7 @@ void render_dialog_entries(void) { #if defined(VERSION_US) || defined(VERSION_SH) s8 lowerBound; #endif + #ifdef VERSION_EU gInGameLanguage = eu_get_language(); switch (gInGameLanguage) { @@ -1702,7 +1702,7 @@ void render_dialog_entries(void) { #endif dialog = segmented_to_virtual(dialogTable[gDialogID]); - // if the dialog entry is invalid, set the ID to -1. + // if the dialog entry is invalid, set the ID to DIALOG_NONE. if (segmented_to_virtual(NULL) == dialog) { gDialogID = DIALOG_NONE; return; @@ -1732,10 +1732,11 @@ void render_dialog_entries(void) { gDialogBoxState = DIALOG_STATE_VERTICAL; gDialogLineNum = 1; } -#if !defined(VERSION_JP) +#ifndef VERSION_JP lowerBound = 1; #endif break; + case DIALOG_STATE_VERTICAL: gDialogBoxOpenTimer = 0.0f; @@ -1749,10 +1750,11 @@ void render_dialog_entries(void) { play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, gGlobalSoundSource); } } -#if !defined(VERSION_JP) +#ifndef VERSION_JP lowerBound = 1; #endif break; + case DIALOG_STATE_HORIZONTAL: gDialogScrollOffsetY += dialog->linesPerBox * 2; @@ -1761,10 +1763,11 @@ void render_dialog_entries(void) { gDialogBoxState = DIALOG_STATE_VERTICAL; gDialogScrollOffsetY = 0; } -#if !defined(VERSION_JP) +#ifndef VERSION_JP lowerBound = (gDialogScrollOffsetY / DIAG_VAL1) + 1; #endif break; + case DIALOG_STATE_CLOSING: if (gDialogBoxOpenTimer == 20.0f) { level_set_transition(0, NULL); @@ -1788,7 +1791,7 @@ void render_dialog_entries(void) { gLastDialogPageStrPos = 0; gDialogResponse = DIALOG_RESPONSE_NONE; } -#if !defined(VERSION_JP) +#ifndef VERSION_JP lowerBound = 1; #endif break; @@ -1796,30 +1799,33 @@ void render_dialog_entries(void) { render_dialog_box_type(dialog, dialog->linesPerBox); - gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, - // Horizontal scissoring isn't really required and can potentially mess up widescreen enhancements. + gDPSetScissor( + gDisplayListHead++, G_SC_NON_INTERLACE, + // Horizontal scissoring isn't really required and can potentially mess up widescreen enhancements. #ifdef WIDESCREEN - 0, + 0, #else - ensure_nonnegative(dialog->leftOffset), + ensure_nonnegative(dialog->leftOffset), #endif - ensure_nonnegative(DIAG_VAL2 - dialog->width), + ensure_nonnegative(DIAG_VAL2 - dialog->width), #ifdef VERSION_EU #ifdef WIDESCREEN - SCREEN_WIDTH, + SCREEN_WIDTH, #else - ensure_nonnegative(dialog->leftOffset + DIAG_VAL3 / gDialogBoxScale), + ensure_nonnegative(dialog->leftOffset + (DIAG_VAL3 / gDialogBoxScale)), #endif - ensure_nonnegative((240 - dialog->width) + ((dialog->linesPerBox * 80) / DIAG_VAL4) / gDialogBoxScale)); + ensure_nonnegative((240 - dialog->width) + (dialog->linesPerBox * 80 / DIAG_VAL4 / gDialogBoxScale)) #else #ifdef WIDESCREEN - SCREEN_WIDTH, + SCREEN_WIDTH, #else - ensure_nonnegative(DIAG_VAL3 + dialog->leftOffset), + ensure_nonnegative(dialog->leftOffset + DIAG_VAL3), #endif - ensure_nonnegative(240 + ((dialog->linesPerBox * 80) / DIAG_VAL4) - dialog->width)); + ensure_nonnegative((240 - dialog->width) + (dialog->linesPerBox * 80 / DIAG_VAL4)) #endif -#if defined(VERSION_JP) + ); + +#ifdef VERSION_JP handle_dialog_text_and_pages(0, dialog); #else handle_dialog_text_and_pages(0, dialog, lowerBound); @@ -1828,17 +1834,19 @@ void render_dialog_entries(void) { if (gLastDialogPageStrPos == -1 && gLastDialogResponse == 1) { render_dialog_triangle_choice(); } + #ifdef VERSION_EU #undef BORDER_HEIGHT #define BORDER_HEIGHT 8 #endif - gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 2, 2, SCREEN_WIDTH - BORDER_HEIGHT/2, SCREEN_HEIGHT - BORDER_HEIGHT/2); + gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 2, 2, SCREEN_WIDTH - BORDER_HEIGHT / 2, SCREEN_HEIGHT - BORDER_HEIGHT / 2); #ifdef VERSION_EU #undef BORDER_HEIGHT #define BORDER_HEIGHT 1 #endif + if (gLastDialogPageStrPos != -1 && gDialogBoxState == DIALOG_STATE_VERTICAL) { - render_dialog_string_color(dialog->linesPerBox); + render_dialog_triangle_next(dialog->linesPerBox); } } @@ -1880,15 +1888,19 @@ u8 ascii_to_credits_char(u8 c) { if (c == ' ') { return GLOBAL_CHAR_SPACE; } + if (c == '.') { return 0x24; } + if (c == '3') { return ASCII_TO_DIALOG('3'); } + if (c == '4') { return ASCII_TO_DIALOG('4'); } + if (c == '6') { return ASCII_TO_DIALOG('6'); } @@ -1988,17 +2000,17 @@ void do_cutscene_handler(void) { } #ifdef VERSION_JP -#define PEACH_MESSAGE_TIMER 170 + #define PEACH_MESSAGE_TIMER 170 #else -#define PEACH_MESSAGE_TIMER 250 + #define PEACH_MESSAGE_TIMER 250 #endif #if defined(VERSION_JP) || defined(VERSION_SH) -#define STR_X 53 -#define STR_Y 136 + #define STR_X 53 + #define STR_Y 136 #else -#define STR_X 38 -#define STR_Y 142 + #define STR_X 38 + #define STR_Y 142 #endif // "Dear Mario" message handler @@ -2006,6 +2018,7 @@ void print_peach_letter_message(void) { void **dialogTable; struct DialogEntry *dialog; u8 *str; + #ifdef VERSION_EU gInGameLanguage = eu_get_language(); switch (gInGameLanguage) { @@ -2023,7 +2036,6 @@ void print_peach_letter_message(void) { dialogTable = segmented_to_virtual(seg2_dialog_table); #endif dialog = segmented_to_virtual(dialogTable[gDialogID]); - str = segmented_to_virtual(dialog->str); create_dl_translation_matrix(MENU_MTX_PUSH, 97.0f, 118.0f, 0); @@ -2120,11 +2132,11 @@ void shade_screen(void) { // This is a bit weird. It reuses the dialog text box (width 130, height -80), // so scale to at least fit the screen. -#ifndef WIDESCREEN - create_dl_scale_matrix(MENU_MTX_NOPUSH, 2.6f, 3.4f, 1.0f); -#else +#ifdef WIDESCREEN create_dl_scale_matrix(MENU_MTX_NOPUSH, GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT / 130.0f, 3.0f, 1.0f); +#else + create_dl_scale_matrix(MENU_MTX_NOPUSH, 2.6f, 3.4f, 1.0f); #endif gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 110); @@ -2133,13 +2145,13 @@ void shade_screen(void) { } void print_animated_red_coin(s16 x, s16 y) { - s32 timer = gGlobalTimer; + s32 globalTimer = gGlobalTimer; create_dl_translation_matrix(MENU_MTX_PUSH, x, y, 0); create_dl_scale_matrix(MENU_MTX_NOPUSH, 0.2f, 0.2f, 1.0f); gDPSetRenderMode(gDisplayListHead++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2); - switch (timer & 6) { + switch (globalTimer & 6) { case 0: gSPDisplayList(gDisplayListHead++, coin_seg3_dl_03007940); break; @@ -2167,28 +2179,36 @@ void render_pause_red_coins(void) { } #ifdef VERSION_EU -u8 gTextCourseArr[][7] = { +u8 gTextCourse[][7] = { { TEXT_COURSE }, { TEXT_COURSE_FR }, { TEXT_COURSE_DE } }; +#define textCourse gTextCourse #endif #if defined(VERSION_JP) || defined(VERSION_SH) -#define CRS_NUM_X1 93 -#else -#define CRS_NUM_X1 100 + #define CRS_NUM_X1 93 +#elif defined(VERSION_US) + #define CRS_NUM_X1 100 +#elif defined(VERSION_EU) + #define CRS_NUM_X1 get_string_width(LANGUAGE_ARRAY(textCourse)) + 51 #endif + #ifdef VERSION_EU -#define TXT_STAR_X 89 -#define ACT_NAME_X 107 -#define LVL_NAME_X 108 -#define MYSCORE_X 48 + #define TXT_COURSE_X 48 + #define TXT_STAR_X 89 + #define ACT_NAME_X 107 + #define LVL_NAME_X 108 + #define SECRET_LVL_NAME_X get_str_x_pos_from_center(159, &courseName[3], 10.0f) + #define MYSCORE_X 48 #else -#define TXT_STAR_X 98 -#define ACT_NAME_X 116 -#define LVL_NAME_X 117 -#define MYSCORE_X 62 + #define TXT_COURSE_X 63 + #define TXT_STAR_X 98 + #define ACT_NAME_X 116 + #define LVL_NAME_X 117 + #define SECRET_LVL_NAME_X 94 + #define MYSCORE_X 62 #endif void render_pause_my_score_coins(void) { @@ -2198,7 +2218,6 @@ void render_pause_my_score_coins(void) { { TEXT_MY_SCORE_FR }, { TEXT_MY_SCORE_DE } }; -#define textMyScore textMyScore[gInGameLanguage] #else u8 textCourse[] = { TEXT_COURSE }; u8 textMyScore[] = { TEXT_MY_SCORE }; @@ -2219,8 +2238,8 @@ void render_pause_my_score_coins(void) { actNameTbl = segmented_to_virtual(seg2_act_name_table); #endif - courseIndex = gCurrCourseNum - 1; - starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + courseIndex = COURSE_NUM_TO_INDEX(gCurrCourseNum); + starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); #ifdef VERSION_EU switch (gInGameLanguage) { @@ -2242,7 +2261,7 @@ void render_pause_my_score_coins(void) { gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); - if (courseIndex < COURSE_STAGES_COUNT) { + if (courseIndex <= COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX)) { print_hud_my_score_coins(1, gCurrSaveFileNum - 1, courseIndex, 178, 103); print_hud_my_score_stars(gCurrSaveFileNum - 1, courseIndex, 118, 103); } @@ -2252,59 +2271,49 @@ void render_pause_my_score_coins(void) { gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); - if (courseIndex < COURSE_STAGES_COUNT && save_file_get_course_star_count(gCurrSaveFileNum - 1, courseIndex) != 0) { - print_generic_string(MYSCORE_X, 121, textMyScore); + if (courseIndex <= COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX) + && save_file_get_course_star_count(gCurrSaveFileNum - 1, courseIndex) != 0) { + print_generic_string(MYSCORE_X, 121, LANGUAGE_ARRAY(textMyScore)); } courseName = segmented_to_virtual(courseNameTbl[courseIndex]); - if (courseIndex < COURSE_STAGES_COUNT) { -#ifdef VERSION_EU - print_generic_string(48, 157, gTextCourseArr[gInGameLanguage]); -#else - print_generic_string(63, 157, textCourse); -#endif + if (courseIndex <= COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX)) { + print_generic_string(TXT_COURSE_X, 157, LANGUAGE_ARRAY(textCourse)); int_to_str(gCurrCourseNum, strCourseNum); -#ifdef VERSION_EU - print_generic_string(get_string_width(gTextCourseArr[gInGameLanguage]) + 51, 157, strCourseNum); -#else print_generic_string(CRS_NUM_X1, 157, strCourseNum); -#endif - actName = segmented_to_virtual(actNameTbl[(gCurrCourseNum - 1) * 6 + gDialogCourseActNum - 1]); + actName = segmented_to_virtual(actNameTbl[COURSE_NUM_TO_INDEX(gCurrCourseNum) * 6 + gDialogCourseActNum - 1]); if (starFlags & (1 << (gDialogCourseActNum - 1))) { print_generic_string(TXT_STAR_X, 140, textStar); } else { print_generic_string(TXT_STAR_X, 140, textUnfilledStar); } + print_generic_string(ACT_NAME_X, 140, actName); #ifndef VERSION_JP print_generic_string(LVL_NAME_X, 157, &courseName[3]); + } else { + print_generic_string(SECRET_LVL_NAME_X, 157, &courseName[3]); #endif } -#ifndef VERSION_JP - else { -#if defined(VERSION_US) || defined(VERSION_SH) - print_generic_string(94, 157, &courseName[3]); -#elif defined(VERSION_EU) - print_generic_string(get_str_x_pos_from_center(159, &courseName[3], 10.0f), 157, &courseName[3]); -#endif - } -#else - print_generic_string(117, 157, &courseName[3]); + +#ifdef VERSION_JP + print_generic_string(LVL_NAME_X, 157, &courseName[3]); #endif + gSPDisplayList(gDisplayListHead++, dl_ia_text_end); } #if defined(VERSION_JP) || defined(VERSION_SH) -#define TXT1_X 4 -#define TXT2_X 116 -#define Y_VAL7 0 + #define TXT1_X 4 + #define TXT2_X 116 + #define Y_VAL7 0 #else -#define TXT1_X 3 -#define TXT2_X 119 -#define Y_VAL7 2 + #define TXT1_X 3 + #define TXT2_X 119 + #define Y_VAL7 2 #endif void render_pause_camera_options(s16 x, s16 y, s8 *index, s16 xIndex) { @@ -2321,8 +2330,6 @@ void render_pause_camera_options(s16 x, s16 y, s8 *index, s16 xIndex) { { TEXT_NORMAL_FIXED_FR }, { TEXT_NORMAL_FIXED_DE }, }; -#define textNormalUpClose textNormalUpClose[gInGameLanguage] -#define textNormalFixed textNormalFixed[gInGameLanguage] #else u8 textNormalUpClose[] = { TEXT_NORMAL_UPCLOSE }; u8 textNormalFixed[] = { TEXT_NORMAL_FIXED }; @@ -2334,9 +2341,9 @@ void render_pause_camera_options(s16 x, s16 y, s8 *index, s16 xIndex) { gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); print_generic_string(x + 14, y + 2, textLakituMario); - print_generic_string(x + TXT1_X, y - 13, textNormalUpClose); + print_generic_string(x + TXT1_X, y - 13, LANGUAGE_ARRAY(textNormalUpClose)); print_generic_string(x + 124, y + 2, textLakituStop); - print_generic_string(x + TXT2_X, y - 13, textNormalFixed); + print_generic_string(x + TXT2_X, y - 13, LANGUAGE_ARRAY(textNormalFixed)); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); create_dl_translation_matrix(MENU_MTX_PUSH, ((*index - 1) * xIndex) + x, y + Y_VAL7, 0); @@ -2355,11 +2362,11 @@ void render_pause_camera_options(s16 x, s16 y, s8 *index, s16 xIndex) { } #if defined(VERSION_JP) || defined(VERSION_SH) -#define X_VAL8 0 -#define Y_VAL8 4 + #define X_VAL8 0 + #define Y_VAL8 4 #else -#define X_VAL8 4 -#define Y_VAL8 2 + #define X_VAL8 4 + #define Y_VAL8 2 #endif void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) { @@ -2379,9 +2386,6 @@ void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) { { TEXT_CAMERA_ANGLE_R_FR }, { TEXT_CAMERA_ANGLE_R_DE } }; -#define textContinue textContinue[gInGameLanguage] -#define textExitCourse textExitCourse[gInGameLanguage] -#define textCameraAngleR textCameraAngleR[gInGameLanguage] #else u8 textContinue[] = { TEXT_CONTINUE }; u8 textExitCourse[] = { TEXT_EXIT_COURSE }; @@ -2393,11 +2397,11 @@ void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) { gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); - print_generic_string(x + 10, y - 2, textContinue); - print_generic_string(x + 10, y - 17, textExitCourse); + print_generic_string(x + 10, y - 2, LANGUAGE_ARRAY(textContinue)); + print_generic_string(x + 10, y - 17, LANGUAGE_ARRAY(textExitCourse)); if (*index != MENU_OPT_CAMERA_ANGLE_R) { - print_generic_string(x + 10, y - 33, textCameraAngleR); + print_generic_string(x + 10, y - 33, LANGUAGE_ARRAY(textCameraAngleR)); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); create_dl_translation_matrix(MENU_MTX_PUSH, x - X_VAL8, (y - ((*index - 1) * yIndex)) - Y_VAL8, 0); @@ -2432,50 +2436,51 @@ void render_pause_castle_menu_box(s16 x, s16 y) { } void highlight_last_course_complete_stars(void) { - u8 courseDone; + u8 doneCourseIndex; if (gLastCompletedCourseNum == COURSE_NONE) { - courseDone = 0; + doneCourseIndex = 0; } else { - courseDone = gLastCompletedCourseNum - 1; + doneCourseIndex = COURSE_NUM_TO_INDEX(gLastCompletedCourseNum); - if (courseDone >= COURSE_STAGES_COUNT) { - courseDone = COURSE_STAGES_COUNT; + if (doneCourseIndex >= COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES)) { + doneCourseIndex = COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES); } } - gDialogLineNum = courseDone; + gDialogLineNum = doneCourseIndex; } +#ifdef VERSION_EU + #define PAUSE_X get_str_x_pos_from_center_scale(SCREEN_WIDTH / 2, textPause, 12.0f) +#else + #define PAUSE_X 123 +#endif + void print_hud_pause_colorful_str(void) { u8 textPause[] = { TEXT_PAUSE }; gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); -#ifdef VERSION_EU - print_hud_lut_string(HUD_LUT_GLOBAL, get_str_x_pos_from_center_scale( - SCREEN_WIDTH / 2, textPause, 12.0f), 81, textPause); -#else - print_hud_lut_string(HUD_LUT_GLOBAL, 123, 81, textPause); -#endif + print_hud_lut_string(HUD_LUT_GLOBAL, PAUSE_X, 81, textPause); gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end); } -void render_pause_castle_course_stars(s16 x, s16 y, s16 fileNum, s16 courseNum) { +void render_pause_castle_course_stars(s16 x, s16 y, s16 fileIndex, s16 courseIndex) { s16 hasStar = 0; u8 str[COURSE_STAGES_COUNT * 2]; u8 textStar[] = { TEXT_STAR }; - u8 starFlags = save_file_get_star_flags(fileNum, courseNum); - u16 starCount = save_file_get_course_star_count(fileNum, courseNum); + u8 starFlags = save_file_get_star_flags(fileIndex, courseIndex); + u16 starCount = save_file_get_course_star_count(fileIndex, courseIndex); u16 nextStar = 0; - if (starFlags & 0x40) { + if (starFlags & (1 << 6)) { starCount--; print_generic_string(x + 89, y - 5, textStar); } @@ -2520,7 +2525,7 @@ void render_pause_castle_main_strings(s16 x, s16 y) { void *courseName; u8 strVal[8]; - s16 starNum = gDialogLineNum; + s16 prevCourseIndex = gDialogLineNum; #ifdef VERSION_EU switch (gInGameLanguage) { @@ -2536,26 +2541,30 @@ void render_pause_castle_main_strings(s16 x, s16 y) { } #endif - handle_menu_scrolling(MENU_SCROLL_VERTICAL, &gDialogLineNum, -1, COURSE_STAGES_COUNT + 1); + handle_menu_scrolling( + MENU_SCROLL_VERTICAL, &gDialogLineNum, + COURSE_NUM_TO_INDEX(COURSE_MIN) - 1, COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES) + 1 + ); - if (gDialogLineNum == COURSE_STAGES_COUNT + 1) { - gDialogLineNum = 0; + if (gDialogLineNum == COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES) + 1) { + gDialogLineNum = COURSE_NUM_TO_INDEX(COURSE_MIN); // Exceeded max, set to min } - if (gDialogLineNum == -1) { - gDialogLineNum = COURSE_STAGES_COUNT; + if (gDialogLineNum == COURSE_NUM_TO_INDEX(COURSE_MIN) - 1) { + gDialogLineNum = COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES); // Exceeded min, set to max } - if (gDialogLineNum != COURSE_STAGES_COUNT) { + if (gDialogLineNum != COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES)) { while (save_file_get_course_star_count(gCurrSaveFileNum - 1, gDialogLineNum) == 0) { - if (gDialogLineNum >= starNum) { + if (gDialogLineNum >= prevCourseIndex) { gDialogLineNum++; } else { gDialogLineNum--; } - if (gDialogLineNum == COURSE_STAGES_COUNT || gDialogLineNum == -1) { - gDialogLineNum = COURSE_STAGES_COUNT; + if (gDialogLineNum == COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX) + 1 + || gDialogLineNum == COURSE_NUM_TO_INDEX(COURSE_MIN) - 1) { + gDialogLineNum = COURSE_NUM_TO_INDEX(COURSE_BONUS_STAGES); break; } } @@ -2564,7 +2573,7 @@ void render_pause_castle_main_strings(s16 x, s16 y) { gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); - if (gDialogLineNum < COURSE_STAGES_COUNT) { + if (gDialogLineNum <= COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX)) { // Main courses courseName = segmented_to_virtual(courseNameTbl[gDialogLineNum]); render_pause_castle_course_stars(x, y, gCurrSaveFileNum - 1, gDialogLineNum); print_generic_string(x + 34, y - 5, textCoin); @@ -2576,7 +2585,7 @@ void render_pause_castle_main_strings(s16 x, s16 y) { #ifdef VERSION_EU print_generic_string(x - 17, y + 30, courseName); #endif - } else { + } else { // Castle secret stars u8 textStarX[] = { TEXT_STAR_X }; courseName = segmented_to_virtual(courseNameTbl[COURSE_MAX]); print_generic_string(x + 40, y + 13, textStarX); @@ -2594,7 +2603,7 @@ void render_pause_castle_main_strings(s16 x, s16 y) { gSPDisplayList(gDisplayListHead++, dl_ia_text_end); } -s8 gCourseCompleteCoinsEqual = 0; +s8 gCourseCompleteCoinsEqual = FALSE; s32 gCourseDoneMenuTimer = 0; s32 gCourseCompleteCoins = 0; s8 gHudFlash = 0; @@ -2611,11 +2620,7 @@ s16 render_pause_courses_and_castle(void) { gDialogLineNum = MENU_OPT_DEFAULT; gDialogTextAlpha = 0; level_set_transition(-1, NULL); -#ifdef VERSION_JP play_sound(SOUND_MENU_PAUSE, gGlobalSoundSource); -#else - play_sound(SOUND_MENU_PAUSE_HIGHPRIO, gGlobalSoundSource); -#endif if (gCurrCourseNum >= COURSE_MIN && gCurrCourseNum <= COURSE_MAX) { change_dialog_camera_angle(); @@ -2625,6 +2630,7 @@ s16 render_pause_courses_and_castle(void) { gDialogBoxState = DIALOG_STATE_HORIZONTAL; } break; + case DIALOG_STATE_VERTICAL: shade_screen(); render_pause_my_score_coins(); @@ -2638,7 +2644,7 @@ s16 render_pause_courses_and_castle(void) { if (gPlayer3Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON)) #else if (gPlayer3Controller->buttonPressed & A_BUTTON - || gPlayer3Controller->buttonPressed & START_BUTTON) + || gPlayer3Controller->buttonPressed & START_BUTTON) #endif { level_set_transition(0, NULL); @@ -2655,6 +2661,7 @@ s16 render_pause_courses_and_castle(void) { return index; } break; + case DIALOG_STATE_HORIZONTAL: shade_screen(); print_hud_pause_colorful_str(); @@ -2665,7 +2672,7 @@ s16 render_pause_courses_and_castle(void) { if (gPlayer3Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON)) #else if (gPlayer3Controller->buttonPressed & A_BUTTON - || gPlayer3Controller->buttonPressed & START_BUTTON) + || gPlayer3Controller->buttonPressed & START_BUTTON) #endif { level_set_transition(0, NULL); @@ -2686,17 +2693,21 @@ s16 render_pause_courses_and_castle(void) { } #if defined(VERSION_JP) -#define TXT_HISCORE_X 112 -#define TXT_HISCORE_Y 48 -#define TXT_CONGRATS_X 60 + #define TXT_HISCORE_X 112 + #define TXT_HISCORE_Y 48 + #define TXT_CONGRATS_X 60 +#elif defined(VERSION_US) + #define TXT_HISCORE_X 109 + #define TXT_HISCORE_Y 36 + #define TXT_CONGRATS_X 70 +#elif defined(VERSION_EU) + #define TXT_HISCORE_X get_str_x_pos_from_center_scale(160, LANGUAGE_ARRAY(textHiScore), 12.0f) + #define TXT_HISCORE_Y 36 + #define TXT_CONGRATS_X get_str_x_pos_from_center_scale(160, LANGUAGE_ARRAY(textCongratulations), 12.0f) #elif defined(VERSION_SH) -#define TXT_HISCORE_X 118 -#define TXT_HISCORE_Y 48 -#define TXT_CONGRATS_X 70 -#else -#define TXT_HISCORE_X 109 -#define TXT_HISCORE_Y 36 -#define TXT_CONGRATS_X 70 + #define TXT_HISCORE_X 118 + #define TXT_HISCORE_Y 48 + #define TXT_CONGRATS_X 70 #endif #define HUD_PRINT_HISCORE 0 @@ -2725,19 +2736,9 @@ void print_hud_course_complete_string(s8 str) { gDPSetEnvColor(gDisplayListHead++, colorFade, colorFade, colorFade, 255); if (str == HUD_PRINT_HISCORE) { -#ifdef VERSION_EU - print_hud_lut_string(HUD_LUT_GLOBAL, get_str_x_pos_from_center_scale(160, textHiScore[gInGameLanguage], 12.0f), - 36, textHiScore[gInGameLanguage]); -#else - print_hud_lut_string(HUD_LUT_GLOBAL, TXT_HISCORE_X, TXT_HISCORE_Y, textHiScore); -#endif + print_hud_lut_string(HUD_LUT_GLOBAL, TXT_HISCORE_X, TXT_HISCORE_Y, LANGUAGE_ARRAY(textHiScore)); } else { // HUD_PRINT_CONGRATULATIONS -#ifdef VERSION_EU - print_hud_lut_string(HUD_LUT_GLOBAL, get_str_x_pos_from_center_scale(160, textCongratulations[gInGameLanguage], 12.0f), - 67, textCongratulations[gInGameLanguage]); -#else - print_hud_lut_string(HUD_LUT_GLOBAL, TXT_CONGRATS_X, 67, textCongratulations); -#endif + print_hud_lut_string(HUD_LUT_GLOBAL, TXT_CONGRATS_X, 67, LANGUAGE_ARRAY(textCongratulations)); } gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end); @@ -2760,7 +2761,7 @@ void print_hud_course_complete_coins(s16 x, s16 y) { gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end); if (gCourseCompleteCoins >= gHudDisplay.coins) { - gCourseCompleteCoinsEqual = 1; + gCourseCompleteCoinsEqual = TRUE; gCourseCompleteCoins = gHudDisplay.coins; if (gGotFileCoinHiScore) { @@ -2791,22 +2792,23 @@ void play_star_fanfare_and_flash_hud(s32 arg, u8 starNum) { } #ifdef VERSION_EU -#define TXT_NAME_X1 centerX -#define TXT_NAME_X2 centerX - 1 + #define TXT_NAME_X1 centerX + #define TXT_NAME_X2 centerX - 1 #else -#define TXT_NAME_X1 71 -#define TXT_NAME_X2 69 + #define TXT_NAME_X1 71 + #define TXT_NAME_X2 TXT_NAME_X1 - 2 #endif + #if defined(VERSION_JP) || defined(VERSION_SH) -#define CRS_NUM_X2 95 -#define CRS_NUM_X3 93 -#define TXT_CLEAR_X1 205 -#define TXT_CLEAR_X2 203 + #define CRS_NUM_X2 95 + #define CRS_NUM_X3 CRS_NUM_X2 - 2 + #define TXT_CLEAR_X1 205 + #define TXT_CLEAR_X2 TXT_CLEAR_X1 - 2 #else -#define CRS_NUM_X2 104 -#define CRS_NUM_X3 102 -#define TXT_CLEAR_X1 get_string_width(name) + 81 -#define TXT_CLEAR_X2 get_string_width(name) + 79 + #define CRS_NUM_X2 104 + #define CRS_NUM_X3 CRS_NUM_X2 - 2 + #define TXT_CLEAR_X1 get_string_width(name) + 81 + #define TXT_CLEAR_X2 TXT_CLEAR_X1 - 2 #endif void render_course_complete_lvl_info_and_hud_str(void) { @@ -2818,7 +2820,6 @@ void render_course_complete_lvl_info_and_hud_str(void) { #elif defined(VERSION_EU) UNUSED u8 textCatch[] = { TEXT_CATCH }; // unused in EU u8 textSymStar[] = { GLYPH_STAR, GLYPH_SPACE }; -#define textCourse gTextCourseArr[gInGameLanguage] #else u8 textCourse[] = { TEXT_COURSE }; UNUSED u8 textCatch[] = { TEXT_CATCH }; // unused in US @@ -2853,28 +2854,36 @@ void render_course_complete_lvl_info_and_hud_str(void) { courseNameTbl = segmented_to_virtual(seg2_course_name_table); #endif - if (gLastCompletedCourseNum <= COURSE_STAGES_MAX) { + if (gLastCompletedCourseNum <= COURSE_STAGES_MAX) { // Main courses print_hud_course_complete_coins(118, 103); play_star_fanfare_and_flash_hud(1, 1 << (gLastCompletedStarNum - 1)); if (gLastCompletedStarNum == 7) { name = segmented_to_virtual(actNameTbl[COURSE_STAGES_MAX * 6 + 1]); } else { - name = segmented_to_virtual(actNameTbl[(gLastCompletedCourseNum - 1) * 6 + gLastCompletedStarNum - 1]); + name = segmented_to_virtual(actNameTbl[COURSE_NUM_TO_INDEX(gLastCompletedCourseNum) * 6 + gLastCompletedStarNum - 1]); } + // Print course number gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); + int_to_str(gLastCompletedCourseNum, strCourseNum); + gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha); - print_generic_string(65, 165, textCourse); + print_generic_string(65, 165, LANGUAGE_ARRAY(textCourse)); print_generic_string(CRS_NUM_X2, 165, strCourseNum); + gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); - print_generic_string(63, 167, textCourse); + print_generic_string(63, 167, LANGUAGE_ARRAY(textCourse)); print_generic_string(CRS_NUM_X3, 167, strCourseNum); + gSPDisplayList(gDisplayListHead++, dl_ia_text_end); - } else if (gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) { - name = segmented_to_virtual(courseNameTbl[gLastCompletedCourseNum - 1]); + } else if (gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) { // Bowser courses + name = segmented_to_virtual(courseNameTbl[COURSE_NUM_TO_INDEX(gLastCompletedCourseNum)]); + + // Print course name and clear text gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); + gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha); #ifdef VERSION_EU centerX = get_str_x_pos_from_center(153, name, 12.0f); @@ -2883,85 +2892,95 @@ void render_course_complete_lvl_info_and_hud_str(void) { #ifndef VERSION_EU print_generic_string(TXT_CLEAR_X1, 130, textClear); #endif + gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); print_generic_string(TXT_NAME_X2, 132, name); #ifndef VERSION_EU print_generic_string(TXT_CLEAR_X2, 132, textClear); #endif + gSPDisplayList(gDisplayListHead++, dl_ia_text_end); + print_hud_course_complete_string(HUD_PRINT_CONGRATULATIONS); print_hud_course_complete_coins(118, 111); play_star_fanfare_and_flash_hud(2, 0); //! 2 isn't defined, originally for key hud? + return; - } else { + } else { // Castle secret stars name = segmented_to_virtual(actNameTbl[COURSE_STAGES_MAX * 6]); + print_hud_course_complete_coins(118, 103); play_star_fanfare_and_flash_hud(1, 1 << (gLastCompletedStarNum - 1)); } + // Print star glyph gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin); + gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); print_hud_lut_string(HUD_LUT_GLOBAL, 55, 77, textSymStar); + gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end); + + // Print act name and catch text gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); + gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha); print_generic_string(76, 145, name); #if defined(VERSION_JP) || defined(VERSION_SH) print_generic_string(220, 145, textCatch); #endif + gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); print_generic_string(74, 147, name); #if defined(VERSION_JP) || defined(VERSION_SH) print_generic_string(218, 147, textCatch); #endif + gSPDisplayList(gDisplayListHead++, dl_ia_text_end); } #if defined(VERSION_JP) || defined(VERSION_SH) -#define TXT_SAVEOPTIONS_X x + 10 -#elif defined(VERSION_US) -#define TXT_SAVEOPTIONS_X x + 12 -#elif defined(VERSION_EU) -#define TXT_SAVEOPTIONS_X xOffset -#endif -#if defined(VERSION_JP) || defined(VERSION_SH) -#define TXT_SAVECONT_Y 2 -#define TXT_SAVEQUIT_Y 18 -#define TXT_CONTNOSAVE_Y 38 + #define X_VAL9 x + #define TXT_SAVEOPTIONS_X x + 10 + #define TXT_SAVECONT_Y 2 + #define TXT_SAVEQUIT_Y 18 + #define TXT_CONTNOSAVE_Y 38 #else -#define TXT_SAVECONT_Y 0 -#define TXT_SAVEQUIT_Y 20 -#define TXT_CONTNOSAVE_Y 40 +#ifdef VERSION_EU + #define X_VAL9 xOffset - 12 + #define TXT_SAVEOPTIONS_X xOffset +#else + #define X_VAL9 x + #define TXT_SAVEOPTIONS_X x + 12 +#endif + #define TXT_SAVECONT_Y 0 + #define TXT_SAVEQUIT_Y 20 + #define TXT_CONTNOSAVE_Y 40 #endif #ifdef VERSION_EU -#define X_VAL9 xOffset - 12 void render_save_confirmation(s16 y, s8 *index, s16 sp6e) #else -#define X_VAL9 x void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e) #endif { #ifdef VERSION_EU - u8 textSaveAndContinueArr[][24] = { + u8 textSaveAndContinue[][24] = { { TEXT_SAVE_AND_CONTINUE }, { TEXT_SAVE_AND_CONTINUE_FR }, { TEXT_SAVE_AND_CONTINUE_DE } }; - u8 textSaveAndQuitArr[][22] = { + u8 textSaveAndQuit[][22] = { { TEXT_SAVE_AND_QUIT }, { TEXT_SAVE_AND_QUIT_FR }, { TEXT_SAVE_AND_QUIT_DE } }; - u8 textContinueWithoutSaveArr[][27] = { + u8 textContinueWithoutSave[][27] = { { TEXT_CONTINUE_WITHOUT_SAVING }, { TEXT_CONTINUE_WITHOUT_SAVING_FR }, { TEXT_CONTINUE_WITHOUT_SAVING_DE } }; -#define textSaveAndContinue textSaveAndContinueArr[gInGameLanguage] -#define textSaveAndQuit textSaveAndQuitArr[gInGameLanguage] -#define textContinueWithoutSave textContinueWithoutSaveArr[gInGameLanguage] - s16 xOffset = get_str_x_pos_from_center(160, textContinueWithoutSaveArr[gInGameLanguage], 12.0f); + s16 xOffset = get_str_x_pos_from_center(160, LANGUAGE_ARRAY(textContinueWithoutSave), 12.0f); #else u8 textSaveAndContinue[] = { TEXT_SAVE_AND_CONTINUE }; u8 textSaveAndQuit[] = { TEXT_SAVE_AND_QUIT }; @@ -2973,9 +2992,9 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e) gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); - print_generic_string(TXT_SAVEOPTIONS_X, y + TXT_SAVECONT_Y, textSaveAndContinue); - print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_SAVEQUIT_Y, textSaveAndQuit); - print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_CONTNOSAVE_Y, textContinueWithoutSave); + print_generic_string(TXT_SAVEOPTIONS_X, y + TXT_SAVECONT_Y, LANGUAGE_ARRAY(textSaveAndContinue)); + print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_SAVEQUIT_Y, LANGUAGE_ARRAY(textSaveAndQuit)); + print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_CONTNOSAVE_Y, LANGUAGE_ARRAY(textContinueWithoutSave)); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); @@ -2996,13 +3015,14 @@ s16 render_course_complete_screen(void) { switch (gDialogBoxState) { case DIALOG_STATE_OPENING: render_course_complete_lvl_info_and_hud_str(); - if (gCourseDoneMenuTimer > 100 && gCourseCompleteCoinsEqual == 1) { + if (gCourseDoneMenuTimer > 100 && gCourseCompleteCoinsEqual == TRUE) { gDialogBoxState = DIALOG_STATE_VERTICAL; level_set_transition(-1, NULL); gDialogTextAlpha = 0; gDialogLineNum = MENU_OPT_DEFAULT; } break; + case DIALOG_STATE_VERTICAL: shade_screen(); render_course_complete_lvl_info_and_hud_str(); @@ -3026,7 +3046,7 @@ s16 render_course_complete_screen(void) { index = gDialogLineNum; gCourseDoneMenuTimer = 0; gCourseCompleteCoins = 0; - gCourseCompleteCoinsEqual = 0; + gCourseCompleteCoinsEqual = FALSE; gHudFlash = 0; return index; @@ -3075,5 +3095,6 @@ s16 render_menus_and_dialogs(void) { render_dialog_entries(); gDialogColorFadeTimer = (s16) gDialogColorFadeTimer + 0x1000; } + return index; } diff --git a/src/game/ingame_menu.h b/src/game/ingame_menu.h index 63920c8e..d341855e 100644 --- a/src/game/ingame_menu.h +++ b/src/game/ingame_menu.h @@ -38,13 +38,12 @@ enum MenuMode { extern s8 gDialogCourseActNum; extern s8 gHudFlash; -struct DialogEntry -{ - /*0x00*/ u32 unused; - /*0x04*/ s8 linesPerBox; - /*0x06*/ s16 leftOffset; - /*0x08*/ s16 width; - /*0x0C*/ const u8 *str; +struct DialogEntry { + /*0x00*/ u32 unused; + /*0x04*/ s8 linesPerBox; + /*0x06*/ s16 leftOffset; + /*0x08*/ s16 width; + /*0x0C*/ const u8 *str; }; // EU only @@ -59,6 +58,12 @@ enum SpecialFontChars { GLOBAR_CHAR_TERMINATOR = 0xFF }; +enum DialogMark { + DIALOG_MARK_NONE, + DIALOG_MARK_DAKUTEN, + DIALOG_MARK_HANDAKUTEN +}; + // definitions for some of the special characters defined in charmap.txt enum DialogSpecialChars { #ifdef VERSION_EU @@ -101,8 +106,9 @@ enum DialogSpecialChars { DIALOG_CHAR_SPACE = 0x9E, DIALOG_CHAR_STAR_COUNT = 0xE0, // number of stars DIALOG_CHAR_UMLAUT = 0xE9, - DIALOG_CHAR_DAKUTEN = 0xF0, - DIALOG_CHAR_PERIOD_OR_HANDAKUTEN = 0xF1, + DIALOG_CHAR_MARK_START = 0xEF, + DIALOG_CHAR_DAKUTEN = DIALOG_CHAR_MARK_START + DIALOG_MARK_DAKUTEN, + DIALOG_CHAR_PERIOD_OR_HANDAKUTEN = DIALOG_CHAR_MARK_START + DIALOG_MARK_HANDAKUTEN, DIALOG_CHAR_STAR_FILLED = 0xFA, DIALOG_CHAR_STAR_OPEN = 0xFD, DIALOG_CHAR_NEWLINE = 0xFE, @@ -142,7 +148,7 @@ s16 get_str_x_pos_from_center(s16 centerPos, u8 *str, f32 scale); #if defined(VERSION_JP) || defined(VERSION_EU) || defined(VERSION_SH) s16 get_str_x_pos_from_center_scale(s16 centerPos, u8 *str, f32 scale); #endif -void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileNum, s8 courseNum, s16 x, s16 y); +void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileIndex, s8 courseIndex, s16 x, s16 y); void int_to_str(s32 num, u8 *dst); s16 get_dialog_id(void); void create_dialog_box(s16 dialog); diff --git a/src/game/interaction.c b/src/game/interaction.c index 0d00061d..c35d1b3e 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1226,7 +1226,7 @@ u32 interact_clam_or_bubba(struct MarioState *m, UNUSED u32 interactType, struct } u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { - UNUSED u32 unused; + UNUSED u8 filler[4]; u32 interaction; if (m->flags & MARIO_METAL_CAP) { @@ -1321,7 +1321,7 @@ u32 interact_mr_blizzard(struct MarioState *m, UNUSED u32 interactType, struct O } u32 interact_hit_from_below(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { - UNUSED u32 unused; + UNUSED u8 filler[4]; u32 interaction; if (m->flags & MARIO_METAL_CAP) { @@ -1799,7 +1799,7 @@ void mario_process_interactions(struct MarioState *m) { } if (m->invincTimer > 0 && !sDelayInvincTimer) { - m->invincTimer -= 1; + m->invincTimer--; } //! If the kick/punch flags are set and an object collision changes Mario's diff --git a/src/game/interaction.h b/src/game/interaction.h index 3f9e5b9b..9d063a81 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -95,6 +95,10 @@ #define INT_STATUS_ATTACKED_MARIO (1 << 13) /* 0x00002000 */ #define INT_STATUS_WAS_ATTACKED (1 << 14) /* 0x00004000 */ #define INT_STATUS_INTERACTED (1 << 15) /* 0x00008000 */ +#define INT_STATUS_UNK16 (1 << 16) /* 0x00010000 */ +#define INT_STATUS_UNK17 (1 << 17) /* 0x00020000 */ +#define INT_STATUS_UNK18 (1 << 18) /* 0x00040000 */ +#define INT_STATUS_UNK19 (1 << 19) /* 0x00080000 */ #define INT_STATUS_TRAP_TURN (1 << 20) /* 0x00100000 */ #define INT_STATUS_HIT_MINE (1 << 21) /* 0x00200000 */ #define INT_STATUS_STOP_RIDING (1 << 22) /* 0x00400000 */ diff --git a/src/game/level_geo.h b/src/game/level_geo.h index a99f9ddd..e4b4016c 100644 --- a/src/game/level_geo.h +++ b/src/game/level_geo.h @@ -4,13 +4,6 @@ #include #include -struct Struct802761D0 -{ - u16 unk0; - s16 unk2; - u8 filler4[0x18-0x4]; -}; - Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, Mat4 mtxf); Gfx *geo_skybox_main(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx); diff --git a/src/game/level_update.c b/src/game/level_update.c index 907a0120..03d44077 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -55,28 +55,17 @@ const char *credits01[] = { "1GAME DIRECTOR", "SHIGERU MIYAMOTO" }; const char *credits02[] = { "2ASSISTANT DIRECTORS", "YOSHIAKI KOIZUMI", "TAKASHI TEZUKA" }; const char *credits03[] = { "2SYSTEM PROGRAMMERS", "YASUNARI NISHIDA", "YOSHINORI TANIMOTO" }; const char *credits04[] = { "3PROGRAMMERS", "HAJIME YAJIMA", "DAIKI IWAMOTO", "TOSHIO IWAWAKI" }; + #if defined(VERSION_JP) || defined(VERSION_SH) + const char *credits05[] = { "1CAMERA PROGRAMMER", "TAKUMI KAWAGOE" }; const char *credits06[] = { "1MARIO FACE PROGRAMMER", "GILES GODDARD" }; const char *credits07[] = { "2COURSE DIRECTORS", "YOICHI YAMADA", "YASUHISA YAMAMURA" }; const char *credits08[] = { "2COURSE DESIGNERS", "KENTA USUI", "NAOKI MORI" }; -const char *credits09[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", - "KATSUHIKO KANNO" }; +const char *credits09[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", "KATSUHIKO KANNO" }; const char *credits10[] = { "1SOUND COMPOSER", "KOJI KONDO" }; -#ifdef VERSION_SH -const char *credits11[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; -const char *credits12[] = { "23D ANIMATORS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA" }; -const char *credits13[] = { "1CG DESIGNER", "MASANAO ARIMOTO" }; -const char *credits14[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" }; -const char *credits15[] = { "1TECHNICAL SUPPORT", "SGI. 64PROJECT STAFF" }; -const char *credits16[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" }; -const char *credits17[] = { "4MARIO VOICE", "PEACH VOICE", "CHARLES MARTINET", "LESLIE SWAN" }; -const char *credits18[] = { "3SPECIAL THANKS TO", "JYOHO KAIHATUBU", "ALL NINTENDO", - "MARIO CLUB STAFF" }; -const char *credits19[] = { "1PRODUCER", "SHIGERU MIYAMOTO" }; -const char *credits20[] = { "1EXECUTIVE PRODUCER", "HIROSHI YAMAUCHI" }; -#else // VERSION_JP +#ifdef VERSION_JP const char *credits11[] = { "1SOUND EFFECTS", "YOJI INAGAKI" }; const char *credits12[] = { "1SOUND PROGRAMMER", "HIDEAKI SHIMIZU" }; const char *credits13[] = { "23D ANIMATORS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA" }; @@ -84,55 +73,63 @@ const char *credits14[] = { "1CG DESIGNER", "MASANAO ARIMOTO" }; const char *credits15[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" }; const char *credits16[] = { "1TECHNICAL SUPPORT", "SGI. 64PROJECT STAFF" }; const char *credits17[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" }; -const char *credits18[] = { "3SPECIAL THANKS TO", "JYOHO KAIHATUBU", "ALL NINTENDO", - "MARIO CLUB STAFF" }; -const char *credits19[] = { "1PRODUCER", "SHIGERU MIYAMOTO" }; -const char *credits20[] = { "1EXECUTIVE PRODUCER", "HIROSHI YAMAUCHI" }; +#else // VERSION_SH +// Shindou combines sound effects and sound programmer in order to make room for Mario voice and Peach voice +const char *credits11[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; +const char *credits12[] = { "23D ANIMATORS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA" }; +const char *credits13[] = { "1CG DESIGNER", "MASANAO ARIMOTO" }; +const char *credits14[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" }; +const char *credits15[] = { "1TECHNICAL SUPPORT", "SGI. 64PROJECT STAFF" }; +const char *credits16[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" }; #endif + #else // VERSION_US || VERSION_EU -const char *credits05[] = { - "4CAMERA PROGRAMMER", "MARIO FACE PROGRAMMER", "TAKUMI KAWAGOE", "GILES GODDARD" -}; // US combines camera programmer and Mario face programmer + +// US and EU combine camera programmer and Mario face programmer... +const char *credits05[] = { "4CAMERA PROGRAMMER", "MARIO FACE PROGRAMMER", "TAKUMI KAWAGOE", "GILES GODDARD" }; const char *credits06[] = { "2COURSE DIRECTORS", "YOICHI YAMADA", "YASUHISA YAMAMURA" }; const char *credits07[] = { "2COURSE DESIGNERS", "KENTA USUI", "NAOKI MORI" }; -const char *credits08[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", - "KATSUHIKO KANNO" }; +const char *credits08[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", "KATSUHIKO KANNO" }; + #ifdef VERSION_US const char *credits09[] = { "1SOUND COMPOSER", "KOJI KONDO" }; -const char *credits10[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI", - "HIDEAKI SHIMIZU" }; // as well as sound effects and sound programmer +// ...as well as sound effects and sound programmer in order to make room for screen text writer, Mario voice, and Peach voice +const char *credits10[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; const char *credits11[] = { "23-D ANIMATORS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA" }; const char *credits12[] = { "1ADDITIONAL GRAPHICS", "MASANAO ARIMOTO" }; const char *credits13[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" }; const char *credits14[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" }; const char *credits15[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" }; -const char *credits16[] = { "5SCREEN TEXT WRITER", "TRANSLATION", "LESLIE SWAN", "MINA AKINO", - "HIRO YAMADA" }; // ...in order to make room for these 2 new lines +const char *credits16[] = { "5SCREEN TEXT WRITER", "TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" }; #else // VERSION_EU -const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO", - "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; -const char *credits10[] = { "63-D ANIMATORS", "ADDITIONAL GRAPHICS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA", - "MASANAO ARIMOTO" }; +// ...as well as sound composer, sound effects, and sound programmer, and... +const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO", "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; +// ...3D animators and additional graphics in order to make room for screen text writer(s), Mario voice, and Peach voice +const char *credits10[] = { "63-D ANIMATORS", "ADDITIONAL GRAPHICS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA", "MASANAO ARIMOTO" }; const char *credits11[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" }; const char *credits12[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" }; const char *credits13[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" }; -const char *credits14[] = { "5SCREEN TEXT WRITER", "ENGLISH TRANSLATION", "LESLIE SWAN", "MINA AKINO", - "HIRO YAMADA" }; -const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF", - "KENJI HARAGUCHI" }; -const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG", - "THOMAS SPINDLER" }; +const char *credits14[] = { "5SCREEN TEXT WRITER", "ENGLISH TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" }; +const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF", "KENJI HARAGUCHI" }; +const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG", "THOMAS SPINDLER" }; #endif + +#endif + +#ifndef VERSION_JP const char *credits17[] = { "4MARIO VOICE", "PEACH VOICE", "CHARLES MARTINET", "LESLIE SWAN" }; -const char *credits18[] = { "3SPECIAL THANKS TO", "EAD STAFF", "ALL NINTENDO PERSONNEL", -#ifdef VERSION_US - "MARIO CLUB STAFF" }; -#else // VERSION_EU - "SUPER MARIO CLUB STAFF" }; #endif + +#if defined(VERSION_JP) || defined(VERSION_SH) +const char *credits18[] = { "3SPECIAL THANKS TO", "JYOHO KAIHATUBU", "ALL NINTENDO", "MARIO CLUB STAFF" }; +#elif defined(VERSION_US) +const char *credits18[] = { "3SPECIAL THANKS TO", "EAD STAFF", "ALL NINTENDO PERSONNEL", "MARIO CLUB STAFF" }; +#else // VERSION_EU +const char *credits18[] = { "3SPECIAL THANKS TO", "EAD STAFF", "ALL NINTENDO PERSONNEL", "SUPER MARIO CLUB STAFF" }; +#endif + const char *credits19[] = { "1PRODUCER", "SHIGERU MIYAMOTO" }; const char *credits20[] = { "1EXECUTIVE PRODUCER", "HIROSHI YAMAUCHI" }; -#endif struct CreditsEntry sCreditsSequence[] = { @@ -182,8 +179,8 @@ s8 gNeverEnteredCastle; struct MarioState *gMarioState = &gMarioStates[0]; u8 unused1[4] = { 0 }; s8 sWarpCheckpointActive = FALSE; -u8 unused3[4]; -u8 unused4[2]; +u8 unused2[4]; +u8 unused3[2]; u16 level_control_timer(s32 timerOp) { switch (timerOp) { @@ -271,7 +268,8 @@ void load_level_init_text(u32 arg) { break; default: - gotAchievement = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + gotAchievement = + save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); break; } @@ -440,10 +438,9 @@ void init_mario_after_warp(void) { play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); } -#ifndef VERSION_JP +#if BUGFIX_KOOPA_RACE_MUSIC if (gCurrLevelNum == LEVEL_BOB - && get_current_background_music() != SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE) - && sTimerRunning) { + && get_current_background_music() != SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE) && sTimerRunning) { play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE), 0); } #endif @@ -454,8 +451,10 @@ void init_mario_after_warp(void) { #else && sWarpDest.nodeId == 31 #endif - ) + ) { play_sound(SOUND_MENU_MARIO_CASTLE_WARP, gGlobalSoundSource); + } + #ifndef VERSION_JP if (sWarpDest.levelNum == LEVEL_CASTLE_GROUNDS && sWarpDest.areaIdx == 1 && (sWarpDest.nodeId == 7 || sWarpDest.nodeId == 10 || sWarpDest.nodeId == 20 @@ -585,7 +584,7 @@ s16 music_changed_through_warp(s16 arg) { sp2C = get_current_background_music(); if (sp2C == SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION) || sp2C == SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)) { - val4 = 0; + val4 = FALSE; } } else { u16 val8 = gAreas[destArea].musicParam; @@ -864,7 +863,7 @@ void initiate_delayed_warp(void) { case WARP_OP_CREDITS_NEXT: sound_banks_disable(SEQ_PLAYER_SFX, SOUND_BANKS_ALL); - gCurrCreditsEntry += 1; + gCurrCreditsEntry++; gCurrActNum = gCurrCreditsEntry->unk02 & 0x07; if ((gCurrCreditsEntry + 1)->levelNum == LEVEL_NONE) { destWarpNode = WARP_NODE_CREDITS_END; @@ -903,7 +902,7 @@ void update_hud_values(void) { } if (gHudDisplay.coins < gMarioState->numCoins) { - if (gGlobalTimer & 0x00000001) { + if (gGlobalTimer & 1) { u32 coinSound; if (gMarioState->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) { coinSound = SOUND_GENERAL_COIN_WATER; @@ -911,7 +910,7 @@ void update_hud_values(void) { coinSound = SOUND_GENERAL_COIN; } - gHudDisplay.coins += 1; + gHudDisplay.coins++; play_sound(coinSound, gMarioState->marioObj->header.gfx.cameraToObject); } } @@ -982,7 +981,7 @@ s32 play_mode_normal(void) { check_instant_warp(); if (sTimerRunning && gHudDisplay.timer < 17999) { - gHudDisplay.timer += 1; + gHudDisplay.timer++; } area_update_objects(); @@ -1072,14 +1071,14 @@ void level_set_transition(s16 length, void (*updateFunction)(s16 *)) { s32 play_mode_change_area(void) { //! This maybe was supposed to be sTransitionTimer == -1? sTransitionUpdate // is never set to -1. - if (sTransitionUpdate == (void (*)(s16 *)) - 1) { + if (sTransitionUpdate == (void (*)(s16 *)) -1) { update_camera(gCurrentArea->camera); } else if (sTransitionUpdate != NULL) { sTransitionUpdate(&sTransitionTimer); } if (sTransitionTimer > 0) { - sTransitionTimer -= 1; + sTransitionTimer--; } if (sTransitionTimer == 0) { @@ -1160,7 +1159,7 @@ s32 update_level(void) { } s32 init_level(void) { - s32 val4 = 0; + s32 val4 = FALSE; set_play_mode(PLAY_MODE_NORMAL); @@ -1199,13 +1198,13 @@ s32 init_level(void) { set_mario_action(gMarioState, ACT_IDLE, 0); } else { set_mario_action(gMarioState, ACT_INTRO_CUTSCENE, 0); - val4 = 1; + val4 = TRUE; } } } } - if (val4 != 0) { + if (val4) { play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x5A, 0xFF, 0xFF, 0xFF); } else { play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0xFF, 0xFF, 0xFF); @@ -1248,8 +1247,8 @@ s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused) { s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum) { #ifdef VERSION_EU - s16 var = eu_get_language(); - switch (var) { + s16 language = eu_get_language(); + switch (language) { case LANGUAGE_ENGLISH: load_segment_decompress(0x19, _translation_en_mio0SegmentRomStart, _translation_en_mio0SegmentRomEnd); @@ -1298,7 +1297,8 @@ s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum) { && gCurrLevelNum != LEVEL_BOWSER_3) { gMarioState->numCoins = 0; gHudDisplay.coins = 0; - gCurrCourseStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + gCurrCourseStarFlags = + save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); } if (gSavedCourseNum != gCurrCourseNum) { diff --git a/src/game/level_update.h b/src/game/level_update.h index 521b4efe..b55d2737 100644 --- a/src/game/level_update.h +++ b/src/game/level_update.h @@ -50,8 +50,7 @@ #define MARIO_SPAWN_UNKNOWN_27 0x27 -struct CreditsEntry -{ +struct CreditsEntry { /*0x00*/ u8 levelNum; /*0x01*/ u8 areaIndex; /*0x02*/ u8 unk02; @@ -69,7 +68,7 @@ extern s16 sCurrPlayMode; extern u16 D_80339ECA; extern s16 sTransitionTimer; extern void (*sTransitionUpdate)(s16 *); -extern u8 unused3[4]; +extern u8 unused2[4]; struct WarpDest { u8 type; @@ -86,7 +85,7 @@ extern s16 sDelayedWarpOp; extern s16 sDelayedWarpTimer; extern s16 sSourceWarpNodeId; extern s32 sDelayedWarpArg; -extern u8 unused4[2]; +extern u8 unused3[2]; extern s8 sTimerRunning; struct HudDisplay { diff --git a/src/game/macro_special_objects.c b/src/game/macro_special_objects.c index cdb5e378..bd02e19c 100644 --- a/src/game/macro_special_objects.c +++ b/src/game/macro_special_objects.c @@ -105,7 +105,7 @@ struct LoadedPreset { #define MACRO_OBJ_PARAMS 4 void spawn_macro_objects(s16 areaIndex, s16 *macroObjList) { - UNUSED u32 pad5C; + UNUSED u8 filler[4]; s32 presetID; s16 macroObject[5]; // see the 5 #define statements above @@ -147,18 +147,18 @@ void spawn_macro_objects(s16 areaIndex, s16 *macroObjList) { if (((macroObject[MACRO_OBJ_PARAMS] >> 8) & RESPAWN_INFO_DONT_RESPAWN) != RESPAWN_INFO_DONT_RESPAWN) { // Spawn the new macro object. - newObj = - spawn_object_abs_with_rot(&gMacroObjectDefaultParent, // Parent object - 0, // Unused - preset.model, // Model ID - preset.behavior, // Behavior address - macroObject[MACRO_OBJ_X], // X-position - macroObject[MACRO_OBJ_Y], // Y-position - macroObject[MACRO_OBJ_Z], // Z-position - 0, // X-rotation - convert_rotation(macroObject[MACRO_OBJ_Y_ROT]), // Y-rotation - 0 // Z-rotation - ); + newObj = spawn_object_abs_with_rot( + &gMacroObjectDefaultParent, // Parent object + 0, // Unused + preset.model, // Model ID + preset.behavior, // Behavior address + macroObject[MACRO_OBJ_X], // X-position + macroObject[MACRO_OBJ_Y], // Y-position + macroObject[MACRO_OBJ_Z], // Z-position + 0, // X-rotation + convert_rotation(macroObject[MACRO_OBJ_Y_ROT]), // Y-rotation + 0 // Z-rotation + ); newObj->oUnk1A8 = macroObject[MACRO_OBJ_PARAMS]; newObj->oBehParams = ((macroObject[MACRO_OBJ_PARAMS] & 0x00FF) << 16) @@ -172,7 +172,7 @@ void spawn_macro_objects(s16 areaIndex, s16 *macroObjList) { } void spawn_macro_objects_hardcoded(s16 areaIndex, s16 *macroObjList) { - UNUSED u8 pad[8]; + UNUSED u8 filler1[8]; // This version of macroObjList has the preset and Y-Rotation separated, // and lacks behavior params. Might be an early version of the macro object list? @@ -182,7 +182,7 @@ void spawn_macro_objects_hardcoded(s16 areaIndex, s16 *macroObjList) { s16 macroObjPreset; s16 macroObjRY; // Y Rotation - UNUSED u8 pad2[10]; + UNUSED u8 filler2[10]; gMacroObjectDefaultParent.header.gfx.areaIndex = areaIndex; gMacroObjectDefaultParent.header.gfx.activeAreaIndex = areaIndex; diff --git a/src/game/main.c b/src/game/main.c index 1a9d9e7e..3d6de1fe 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -183,7 +183,7 @@ void receive_new_tasks(void) { } void start_sptask(s32 taskType) { - UNUSED s32 pad; // needed to pad the stack + UNUSED u8 filler[4]; if (taskType == M_AUDTASK) { gActiveSPTask = sCurrentAudioSPTask; @@ -218,7 +218,7 @@ void pretend_audio_sptask_done(void) { } void handle_vblank(void) { - UNUSED s32 pad; // needed to pad the stack + UNUSED u8 filler[4]; stub_main_3(); gNumVblanks++; @@ -452,7 +452,7 @@ void thread1_idle(UNUSED void *arg) { } void main_func(void) { - UNUSED u8 pad[64]; // needed to pad the stack + UNUSED u8 filler[64]; osInitialize(); stub_main_1(); diff --git a/src/game/mario.c b/src/game/mario.c index 634d3ecc..cc5e8646 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -34,7 +34,7 @@ #include "rumble_init.h" u32 unused80339F10; -s8 filler80339F1C[20]; +u8 unused80339F1C[20]; /************************************************** * ANIMATIONS * @@ -133,7 +133,7 @@ void set_anim_to_frame(struct MarioState *m, s16 animFrame) { struct AnimInfo *animInfo = &m->marioObj->header.gfx.animInfo; struct Animation *curAnim = animInfo->curAnim; - if (animInfo->animAccel) { + if (animInfo->animAccel != 0) { if (curAnim->flags & ANIM_FLAG_FORWARD) { animInfo->animFrameAccelAssist = (animFrame << 0x10) + animInfo->animAccel; } else { @@ -154,7 +154,7 @@ s32 is_anim_past_frame(struct MarioState *m, s16 animFrame) { struct AnimInfo *animInfo = &m->marioObj->header.gfx.animInfo; struct Animation *curAnim = animInfo->curAnim; - if (animInfo->animAccel) { + if (animInfo->animAccel != 0) { if (curAnim->flags & ANIM_FLAG_FORWARD) { isPastFrame = (animInfo->animFrameAccelAssist > acceleratedFrame) @@ -545,7 +545,7 @@ struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 ra * Finds the ceiling from a vec3f horizontally and a height (with 80 vertical buffer). */ f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil) { - UNUSED f32 unused; + UNUSED u8 filler[4]; return find_ceil(pos[0], height + 80.0f, pos[2], ceil); } @@ -774,7 +774,7 @@ static void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVel * Transitions for a variety of airborne actions. */ static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actionArg) { - f32 fowardVel; + f32 forwardVel; if ((m->squishTimer != 0 || m->quicksandDepth >= 1.0f) && (action == ACT_DOUBLE_JUMP || action == ACT_TWIRLING)) { @@ -854,10 +854,10 @@ static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actio break; case ACT_DIVE: - if ((fowardVel = m->forwardVel + 15.0f) > 48.0f) { - fowardVel = 48.0f; + if ((forwardVel = m->forwardVel + 15.0f) > 48.0f) { + forwardVel = 48.0f; } - mario_set_forward_vel(m, fowardVel); + mario_set_forward_vel(m, forwardVel); break; case ACT_LONG_JUMP: @@ -1277,13 +1277,13 @@ void update_mario_button_inputs(struct MarioState *m) { if (m->input & INPUT_A_PRESSED) { m->framesSinceA = 0; } else if (m->framesSinceA < 0xFF) { - m->framesSinceA += 1; + m->framesSinceA++; } if (m->input & INPUT_B_PRESSED) { m->framesSinceB = 0; } else if (m->framesSinceB < 0xFF) { - m->framesSinceB += 1; + m->framesSinceB++; } } diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 387e202c..60c7c091 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -331,7 +331,7 @@ void update_flying_pitch(struct MarioState *m) { } void update_flying(struct MarioState *m) { - UNUSED u32 unused; + UNUSED u8 filler[4]; update_flying_pitch(m); update_flying_yaw(m); @@ -1541,7 +1541,7 @@ s32 act_lava_boost(struct MarioState *m) { if (m->actionState < 2 && m->vel[1] < 0.0f) { m->vel[1] = -m->vel[1] * 0.4f; mario_set_forward_vel(m, m->forwardVel * 0.5f); - m->actionState += 1; + m->actionState++; } else { set_mario_action(m, ACT_LAVA_BOOST_LAND, 0); } diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 35460063..40235766 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -56,9 +56,7 @@ void play_climbing_sounds(struct MarioState *m, s32 b) { } s32 set_pole_position(struct MarioState *m, f32 offsetY) { - UNUSED s32 unused1; - UNUSED s32 unused2; - UNUSED s32 unused3; + UNUSED u8 filler[12]; struct Surface *floor; struct Surface *ceil; f32 floorHeight; @@ -299,7 +297,7 @@ s32 act_top_of_pole(struct MarioState *m) { } s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) { - UNUSED s32 unused; + UNUSED u8 filler[4]; struct Surface *ceil; struct Surface *floor; f32 ceilHeight; diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index ad95b9a8..ab797405 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -610,7 +610,7 @@ void general_star_dance_handler(struct MarioState *m, s32 isInWater) { break; case 80: - if ((m->actionArg & 1) == 0) { + if (!(m->actionArg & 1)) { level_trigger_warp(m, WARP_OP_STAR_EXIT); } else { enable_time_stop(); @@ -861,7 +861,7 @@ s32 act_entering_star_door(struct MarioState *m) { s16 targetAngle; if (m->actionTimer++ == 0) { - m->interactObj->oInteractStatus = 0x00010000; + m->interactObj->oInteractStatus = INT_STATUS_UNK16; // ~30 degrees / 1/12 rot targetAngle = m->usedObj->oMoveAngleYaw + 0x1555; @@ -919,10 +919,10 @@ s32 act_entering_star_door(struct MarioState *m) { s32 act_going_through_door(struct MarioState *m) { if (m->actionTimer == 0) { if (m->actionArg & 1) { - m->interactObj->oInteractStatus = 0x00010000; + m->interactObj->oInteractStatus = INT_STATUS_UNK16; set_mario_animation(m, MARIO_ANIM_PULL_DOOR_WALK_IN); } else { - m->interactObj->oInteractStatus = 0x00020000; + m->interactObj->oInteractStatus = INT_STATUS_UNK17; set_mario_animation(m, MARIO_ANIM_PUSH_DOOR_WALK_IN); } } @@ -952,9 +952,9 @@ s32 act_warp_door_spawn(struct MarioState *m) { if (m->actionState == 0) { m->actionState = 1; if (m->actionArg & 1) { - m->usedObj->oInteractStatus = 0x00040000; + m->usedObj->oInteractStatus = INT_STATUS_UNK18; } else { - m->usedObj->oInteractStatus = 0x00080000; + m->usedObj->oInteractStatus = INT_STATUS_UNK19; } } else if (m->usedObj->oAction == 0) { if (gNeverEnteredCastle == TRUE && gCurrLevelNum == LEVEL_CASTLE) { @@ -1104,13 +1104,13 @@ s32 act_exit_land_save_dialog(struct MarioState *m) { switch (animFrame) { case -1: spawn_obj_at_mario_rel_yaw(m, MODEL_BOWSER_KEY_CUTSCENE, bhvBowserKeyCourseExit, -32768); - //! fall through + //! fallthrough case 67: play_sound(SOUND_ACTION_KEY_SWISH, m->marioObj->header.gfx.cameraToObject); - //! fall through + //! fallthrough case 83: play_sound(SOUND_ACTION_PAT_BACK, m->marioObj->header.gfx.cameraToObject); - //! fall through + //! fallthrough case 111: play_sound(SOUND_ACTION_UNKNOWN45C, m->marioObj->header.gfx.cameraToObject); // no break @@ -1137,7 +1137,7 @@ s32 act_exit_land_save_dialog(struct MarioState *m) { cutscene_take_cap_off(m); break; case 37: - // fall through + // fallthrough case 53: play_sound(SOUND_ACTION_BRUSH_HAIR, m->marioObj->header.gfx.cameraToObject); break; @@ -1304,7 +1304,7 @@ s32 act_bbh_enter_spin(struct MarioState *m) { m->actionState = 1; m->actionTimer = 100; - // fall through + // fallthrough case 1: m->faceAngle[1] = atan2s(cageDZ, cageDX); @@ -1322,7 +1322,7 @@ s32 act_bbh_enter_spin(struct MarioState *m) { break; case 2: - // fall through + // fallthrough case 3: m->faceAngle[1] = atan2s(cageDZ, cageDX); mario_set_forward_vel(m, forwardVel); @@ -1482,7 +1482,7 @@ s32 act_shocked(struct MarioState *m) { } s32 act_squished(struct MarioState *m) { - UNUSED s32 pad; + UNUSED u8 filler[4]; f32 squishAmount; f32 spaceUnderCeil; s16 surfAngle; @@ -1718,9 +1718,9 @@ static void intro_cutscene_jump_out_of_pipe(struct MarioState *m) { play_sound_if_no_flag(m, SOUND_MARIO_YAHOO, MARIO_MARIO_SOUND_PLAYED); #else play_sound_if_no_flag(m, SOUND_MARIO_YAHOO, MARIO_MARIO_SOUND_PLAYED); - #ifndef VERSION_JP +#ifndef VERSION_JP play_sound_if_no_flag(m, SOUND_ACTION_HIT_3, MARIO_ACTION_SOUND_PLAYED); - #endif +#endif #endif set_mario_animation(m, MARIO_ANIM_SINGLE_JUMP); @@ -1902,7 +1902,7 @@ static s32 jumbo_star_cutscene_flying(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_WING_CAP_FLY); anim_spline_init(sJumboStarKeyframes); m->actionState++; - // fall through + // fallthrough case 1: if (anim_spline_poll(targetPos)) { // does this twice @@ -2045,7 +2045,7 @@ static void end_peach_cutscene_summon_jumbo_star(struct MarioState *m) { advance_cutscene_step(m); } - sEndJumboStarObj->oFaceAngleYaw += 0x0400; + sEndJumboStarObj->oFaceAngleYaw += 0x400; generate_yellow_sparkles(0, 2528, -1800, 250.0f); play_sound(SOUND_AIR_PEACH_TWINKLE, sEndJumboStarObj->header.gfx.cameraToObject); } diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index be7dd107..071ea66c 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -483,7 +483,7 @@ s32 analog_stick_held_back(struct MarioState *m) { } s32 check_ground_dive_or_punch(struct MarioState *m) { - UNUSED s32 unused; + UNUSED u8 filler[4]; if (m->input & INPUT_B_PRESSED) { //! Speed kick (shoutouts to SimpleFlips) diff --git a/src/game/mario_actions_object.c b/src/game/mario_actions_object.c index 82c49c1d..99f40bc6 100644 --- a/src/game/mario_actions_object.c +++ b/src/game/mario_actions_object.c @@ -37,7 +37,7 @@ s32 mario_update_punch_sequence(struct MarioState *m) { switch (m->actionArg) { case 0: play_sound(SOUND_MARIO_PUNCH_YAH, m->marioObj->header.gfx.cameraToObject); - // Fall-through: + // fallthrough case 1: set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH); if (is_anim_past_end(m)) { @@ -77,7 +77,7 @@ s32 mario_update_punch_sequence(struct MarioState *m) { case 3: play_sound(SOUND_MARIO_PUNCH_WAH, m->marioObj->header.gfx.cameraToObject); - // Fall-through: + // fallthrough case 4: set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH); if (is_anim_past_end(m)) { diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 9aef4caa..4fc919f7 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -165,7 +165,7 @@ static void apply_water_current(struct MarioState *m, Vec3f step) { } static u32 perform_water_step(struct MarioState *m) { - UNUSED u32 unused; + UNUSED u8 filler[4]; u32 stepResult; Vec3f nextPos; Vec3f step; diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 56e1a0a1..b2eb7ddb 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -238,9 +238,9 @@ void bhv_unlock_door_star_init(void) { } void bhv_unlock_door_star_loop(void) { - UNUSED u8 unused1[4]; + UNUSED u8 filler1[4]; s16 prevYaw = gCurrentObject->oMoveAngleYaw; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; // Speed up the star every frame if (gCurrentObject->oUnlockDoorStarYawVel < 0x2400) { @@ -321,12 +321,12 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) { * Sets the correct blend mode and color for mirror Mario. */ Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) { - UNUSED u8 unused1[4]; + UNUSED u8 filler1[4]; Gfx *gfx = NULL; struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node; struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter]; s16 alpha; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; if (callContext == GEO_CONTEXT_RENDER) { alpha = (bodyState->modelState & 0x100) ? (bodyState->modelState & 0xFF) : 255; @@ -613,9 +613,9 @@ Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat gMirrorMario.pos[0] = mirroredX + MIRROR_X; gMirrorMario.angle[1] = -gMirrorMario.angle[1]; gMirrorMario.scale[0] *= -1.0f; - ((struct GraphNode *) &gMirrorMario)->flags |= 1; + ((struct GraphNode *) &gMirrorMario)->flags |= GRAPH_RENDER_ACTIVE; } else { - ((struct GraphNode *) &gMirrorMario)->flags &= ~1; + ((struct GraphNode *) &gMirrorMario)->flags &= ~GRAPH_RENDER_ACTIVE; } break; } diff --git a/src/game/memory.h b/src/game/memory.h index 1c2da465..0d958b8e 100644 --- a/src/game/memory.h +++ b/src/game/memory.h @@ -8,8 +8,7 @@ #define MEMORY_POOL_LEFT 0 #define MEMORY_POOL_RIGHT 1 -struct AllocOnlyPool -{ +struct AllocOnlyPool { s32 totalSpace; s32 usedSpace; u8 *startPtr; @@ -18,21 +17,18 @@ struct AllocOnlyPool struct MemoryPool; -struct OffsetSizePair -{ +struct OffsetSizePair { u32 offset; u32 size; }; -struct DmaTable -{ +struct DmaTable { u32 count; u8 *srcAddr; struct OffsetSizePair anim[1]; // dynamic size }; -struct DmaHandlerList -{ +struct DmaHandlerList { struct DmaTable *dmaTable; void *currentAddr; void *bufTarget; diff --git a/src/game/moving_texture.c b/src/game/moving_texture.c index 268d7efd..175b854a 100644 --- a/src/game/moving_texture.c +++ b/src/game/moving_texture.c @@ -523,8 +523,8 @@ extern u8 sl_movtex_water[]; extern u8 wdw_movtex_area1_water[]; extern u8 wdw_movtex_area2_water[]; extern u8 jrb_movtex_water[]; -extern u8 jrb_movtex_intial_mist[]; -extern u8 jrb_movtex_sinked_boat_water[]; +extern u8 jrb_movtex_initial_mist[]; +extern u8 jrb_movtex_sunken_ship_water[]; extern u8 thi_movtex_area1_water[]; extern u8 thi_movtex_area2_water[]; extern u8 castle_grounds_movtex_water[]; @@ -566,10 +566,10 @@ void *get_quad_collection_from_id(u32 id) { return wdw_movtex_area2_water; case JRB_MOVTEX_WATER: return jrb_movtex_water; - case JRB_MOVTEX_INTIAL_MIST: - return jrb_movtex_intial_mist; - case JRB_MOVTEX_SINKED_BOAT_WATER: - return jrb_movtex_sinked_boat_water; + case JRB_MOVTEX_INITIAL_MIST: + return jrb_movtex_initial_mist; + case JRB_MOVTEX_SUNKEN_SHIP_WATER: + return jrb_movtex_sunken_ship_water; case THI_MOVTEX_AREA1_WATER: return thi_movtex_area1_water; case THI_MOVTEX_AREA2_WATER: @@ -605,7 +605,7 @@ void movtex_change_texture_format(u32 quadCollectionId, Gfx **gfx) { case SSL_MOVTEX_TOXBOX_QUICKSAND_MIST: gSPDisplayList((*gfx)++, dl_waterbox_ia16_begin); break; - case JRB_MOVTEX_INTIAL_MIST: + case JRB_MOVTEX_INITIAL_MIST: gSPDisplayList((*gfx)++, dl_waterbox_ia16_begin); break; default: @@ -643,11 +643,12 @@ Gfx *geo_movtex_draw_water_regions(s32 callContext, struct GraphNode *node, UNUS gfx = gfxHead; } asGenerated = (struct GraphNodeGenerated *) node; - if (asGenerated->parameter == JRB_MOVTEX_INTIAL_MIST) { + if (asGenerated->parameter == JRB_MOVTEX_INITIAL_MIST) { if (gLakituState.goalPos[1] < 1024.0) { // if camera under water return NULL; } - if (save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_JRB - 1) & 1) { // first star in JRB complete + if (save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_JRB)) + & (1 << 0)) { // the "Plunder in the Sunken Ship" star in JRB is collected return NULL; } } else if (asGenerated->parameter == HMC_MOVTEX_TOXIC_MAZE_MIST) { diff --git a/src/game/moving_texture.h b/src/game/moving_texture.h index 9d2e3db1..05858a99 100644 --- a/src/game/moving_texture.h +++ b/src/game/moving_texture.h @@ -10,8 +10,7 @@ #define ROTATE_COUNTER_CLOCKWISE 1 /// Ids for textures used for moving textures -enum MovtexRectTextureId -{ +enum MovtexRectTextureId { TEXTURE_WATER, TEXTURE_MIST, TEXTURE_JRB_WATER, @@ -71,8 +70,8 @@ extern f32 gPaintingMarioYEntry; #define WDW_MOVTEX_AREA1_WATER ( 1 | MOVTEX_AREA_WDW) #define WDW_MOVTEX_AREA2_WATER ( 2 | MOVTEX_AREA_WDW) #define JRB_MOVTEX_WATER ( 1 | MOVTEX_AREA_JRB) -#define JRB_MOVTEX_INTIAL_MIST ( 5 | MOVTEX_AREA_JRB) -#define JRB_MOVTEX_SINKED_BOAT_WATER ( 2 | MOVTEX_AREA_JRB) +#define JRB_MOVTEX_INITIAL_MIST ( 5 | MOVTEX_AREA_JRB) +#define JRB_MOVTEX_SUNKEN_SHIP_WATER ( 2 | MOVTEX_AREA_JRB) #define THI_MOVTEX_AREA1_WATER ( 1 | MOVTEX_AREA_THI) #define THI_MOVTEX_AREA2_WATER ( 2 | MOVTEX_AREA_THI) #define CASTLE_GROUNDS_MOVTEX_WATER ( 1 | MOVTEX_AREA_CASTLE_GROUNDS) diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index fdfc70fa..68c78e23 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -91,7 +91,7 @@ Gfx UNUSED *geo_obj_transparency_something(s32 callContext, struct GraphNode *no struct Object *heldObject; struct Object *obj; UNUSED struct Object *unusedObject; - UNUSED s32 pad; + UNUSED u8 filler[4]; gfxHead = NULL; @@ -406,7 +406,7 @@ void obj_splash(s32 waterY, s32 objY) { } // Spawns bubbles if underwater. - if ((objY + 50) < waterY && (globalTimer & 0x1F) == 0) { + if ((objY + 50) < waterY && !(globalTimer & 31)) { spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvObjectBubble); } } @@ -593,7 +593,7 @@ s8 obj_check_if_facing_toward_angle(u32 base, u32 goal, s16 range) { */ s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius) { struct WallCollisionData hitbox; - UNUSED u8 filler[0x20]; + UNUSED u8 filler[32]; hitbox.x = x; hitbox.y = y; @@ -680,8 +680,6 @@ s8 current_mario_room_check(s16 room) { * Triggers dialog when Mario is facing an object and controls it while in the dialog. */ s16 trigger_obj_dialog_when_facing(s32 *inDialog, s16 dialogID, f32 dist, s32 actionArg) { - s16 dialogueResponse; - if ((is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, (s32) dist) == TRUE && obj_check_if_facing_toward_angle(o->oFaceAngleYaw, gMarioObject->header.gfx.angle[1] + 0x8000, 0x1000) == TRUE && obj_check_if_facing_toward_angle(o->oMoveAngleYaw, o->oAngleToMario, 0x1000) == TRUE) @@ -689,11 +687,11 @@ s16 trigger_obj_dialog_when_facing(s32 *inDialog, s16 dialogID, f32 dist, s32 ac *inDialog = TRUE; if (set_mario_npc_dialog(actionArg) == MARIO_DIALOG_STATUS_SPEAK) { //If Mario is speaking. - dialogueResponse = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogID); - if (dialogueResponse) { + s16 dialogResponse = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogID); + if (dialogResponse != DIALOG_RESPONSE_NONE) { set_mario_npc_dialog(MARIO_DIALOG_STOP); *inDialog = FALSE; - return dialogueResponse; + return dialogResponse; } return 0; } @@ -732,7 +730,7 @@ void obj_check_floor_death(s16 collisionFlags, struct Surface *floor) { s8 obj_lava_death(void) { struct Object *deathSmoke; - if (o->oTimer >= 31) { + if (o->oTimer > 30) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; return TRUE; } else { @@ -775,7 +773,7 @@ s8 sDebugTimer = 0; /** * Unused presumably debug function that tracks for a sequence of inputs. */ -s8 UNUSED debug_sequence_tracker(s16 debugInputSequence[]) { +UNUSED s8 debug_sequence_tracker(s16 debugInputSequence[]) { // If end of sequence reached, return true. if (debugInputSequence[sDebugSequenceTracker] == 0) { sDebugSequenceTracker = 0; diff --git a/src/game/obj_behaviors.h b/src/game/obj_behaviors.h index 02a0567f..9755984f 100644 --- a/src/game/obj_behaviors.h +++ b/src/game/obj_behaviors.h @@ -107,7 +107,7 @@ void bhv_big_bully_with_minions_loop(void); f32 water_ring_calc_mario_dist(void); void water_ring_init(void); void bhv_jet_stream_water_ring_init(void); -void water_ring_check_collection(f32 avgScale, struct Object* ringManager); +void water_ring_check_collection(f32 avgScale, struct Object *ringManager); void water_ring_set_scale(f32 avgScale); void water_ring_act_collected(void); void water_ring_act_not_collected(void); @@ -148,7 +148,7 @@ void bhv_bowling_ball_init(void); void bowling_ball_set_hitbox(void); void bowling_ball_set_waypoints(void); void bhv_bowling_ball_roll_loop(void); -void bhv_bowling_ball_initializeLoop(void); +void bhv_bowling_ball_initialize_loop(void); void bhv_bowling_ball_loop(void); void bhv_generic_bowling_ball_spawner_init(void); void bhv_generic_bowling_ball_spawner_loop(void); diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index ae01edce..3715a137 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -152,7 +152,7 @@ static void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 struct Waypoint *initialPrevWaypoint; struct Waypoint *nextWaypoint; struct Waypoint *prevWaypoint; - UNUSED s32 unused; + UNUSED u8 filler[4]; f32 amountToMove; f32 dx; f32 dy; @@ -174,7 +174,7 @@ static void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 do { prevWaypoint = nextWaypoint; - nextWaypoint += 1; + nextWaypoint++; if (nextWaypoint->flags == WAYPOINT_FLAGS_END) { if (ballIndex == 0) { o->oPlatformOnTrackPrevWaypointFlags = WAYPOINT_FLAGS_END; @@ -535,7 +535,7 @@ static s32 oscillate_toward(s32 *value, f32 *vel, s32 target, f32 velCloseToZero static void obj_update_blinking(s32 *blinkTimer, s16 baseCycleLength, s16 cycleLengthRange, s16 blinkLength) { if (*blinkTimer != 0) { - *blinkTimer -= 1; + (*blinkTimer)--; } else { *blinkTimer = random_linear_offset(baseCycleLength, cycleLengthRange); } diff --git a/src/game/object_collision.c b/src/game/object_collision.c index cf77768a..59ae99b5 100644 --- a/src/game/object_collision.c +++ b/src/game/object_collision.c @@ -9,7 +9,7 @@ struct Object *debug_print_obj_collision(struct Object *a) { struct Object *sp24; - UNUSED s32 unused; + UNUSED u8 filler[4]; s32 i; for (i = 0; i < a->numCollidedObjs; i++) { diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 0f0c707b..338d5263 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -64,7 +64,7 @@ Gfx *geo_update_layer_transparency(s32 callContext, struct GraphNode *node, UNUS currentGraphNode = (struct GraphNodeGenerated *) node; sp2C = (struct GraphNodeGenerated *) node; - if (gCurGraphNodeHeldObject) { + if (gCurGraphNodeHeldObject != NULL) { objectGraphNode = gCurGraphNodeHeldObject->objNode; } @@ -393,7 +393,7 @@ s16 obj_angle_to_object(struct Object *obj1, struct Object *obj2) { s16 obj_turn_toward_object(struct Object *obj, struct Object *target, s16 angleIndex, s16 turnAmount) { f32 a, b, c, d; - UNUSED s32 unused; + UNUSED u8 filler[4]; s16 targetAngle, startAngle; switch (angleIndex) { @@ -452,26 +452,26 @@ void obj_set_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) { */ struct Object *spawn_object_abs_with_rot(struct Object *parent, s16 uselessArg, u32 model, const BehaviorScript *behavior, - s16 x, s16 y, s16 z, s16 rx, s16 ry, s16 rz) { + s16 x, s16 y, s16 z, s16 pitch, s16 yaw, s16 roll) { // 'uselessArg' is unused in the function spawn_object_at_origin() struct Object *newObj = spawn_object_at_origin(parent, uselessArg, model, behavior); obj_set_pos(newObj, x, y, z); - obj_set_angle(newObj, rx, ry, rz); + obj_set_angle(newObj, pitch, yaw, roll); return newObj; } /* * Spawns an object relative to the parent with a specified angle... is what it is supposed to do. - * The rz argument is never used, and the z offset is used for z-rotation instead. This is most likely + * The roll argument is never used, and the z offset is used for z-rotation instead. This is most likely * a copy-paste typo by one of the programmers. */ struct Object *spawn_object_rel_with_rot(struct Object *parent, u32 model, const BehaviorScript *behavior, - s16 xOff, s16 yOff, s16 zOff, s16 rx, s16 ry, UNUSED s16 rz) { + s16 xOff, s16 yOff, s16 zOff, s16 pitch, s16 yaw, UNUSED s16 roll) { struct Object *newObj = spawn_object_at_origin(parent, 0, model, behavior); newObj->oFlags |= OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT; obj_set_parent_relative_pos(newObj, xOff, yOff, zOff); - obj_set_angle(newObj, rx, ry, zOff); // Nice typo you got there Nintendo. + obj_set_angle(newObj, pitch, yaw, zOff); // Nice typo you got there Nintendo. return newObj; } @@ -1124,7 +1124,7 @@ void mario_set_flag(s32 flag) { s32 cur_obj_clear_interact_status_flag(s32 flag) { if (o->oInteractStatus & flag) { - o->oInteractStatus &= flag ^ ~(0); + o->oInteractStatus &= flag ^ 0xFFFFFFFF; return TRUE; } return FALSE; @@ -1207,7 +1207,7 @@ static s32 cur_obj_move_xz(f32 steepSlopeNormalY, s32 careAboutEdgesAndSteepSlop f32 intendedFloorHeight = find_floor(intendedX, o->oPosY, intendedZ, &intendedFloor); f32 deltaFloorHeight = intendedFloorHeight - o->oFloorHeight; - UNUSED f32 unused; + UNUSED u8 filler[4]; UNUSED f32 ny; o->oMoveFlags &= ~OBJ_MOVE_HIT_EDGE; @@ -1984,7 +1984,7 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) { struct Waypoint *lastWaypoint; struct Waypoint *targetWaypoint; f32 prevToNextX, prevToNextY, prevToNextZ; - UNUSED s32 sp2C; + UNUSED u8 filler[4]; f32 objToNextXZ; f32 objToNextX, objToNextY, objToNextZ; @@ -2282,10 +2282,10 @@ void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14) { } void cur_obj_set_pos_to_home_with_debug(void) { - o->oPosX = o->oHomeX + gDebugInfo[5][0]; - o->oPosY = o->oHomeY + gDebugInfo[5][1]; - o->oPosZ = o->oHomeZ + gDebugInfo[5][2]; - cur_obj_scale(gDebugInfo[5][3] / 100.0f + 1.0l); + o->oPosX = o->oHomeX + gDebugInfo[DEBUG_PAGE_ENEMYINFO][0]; + o->oPosY = o->oHomeY + gDebugInfo[DEBUG_PAGE_ENEMYINFO][1]; + o->oPosZ = o->oHomeZ + gDebugInfo[DEBUG_PAGE_ENEMYINFO][2]; + cur_obj_scale(gDebugInfo[DEBUG_PAGE_ENEMYINFO][3] / 100.0f + 1.0l); } void stub_obj_helpers_4(void) { @@ -2504,17 +2504,17 @@ Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUS return NULL; } -s32 geo_offset_klepto_debug(s32 callContext, struct GraphNode *a1, UNUSED s32 sp8) { +Gfx *geo_offset_klepto_debug(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { if (callContext == GEO_CONTEXT_RENDER) { - ((struct GraphNode_802A45E4 *) a1->next)->unk18 = gDebugInfo[4][0]; - ((struct GraphNode_802A45E4 *) a1->next)->unk1A = gDebugInfo[4][1]; - ((struct GraphNode_802A45E4 *) a1->next)->unk1C = gDebugInfo[4][2]; - ((struct GraphNode_802A45E4 *) a1->next)->unk1E = gDebugInfo[4][3]; - ((struct GraphNode_802A45E4 *) a1->next)->unk20 = gDebugInfo[4][4]; - ((struct GraphNode_802A45E4 *) a1->next)->unk22 = gDebugInfo[4][5]; + ((struct GraphNodeTranslationRotation *) node->next)->translation[0] = gDebugInfo[DEBUG_PAGE_EFFECTINFO][0]; + ((struct GraphNodeTranslationRotation *) node->next)->translation[1] = gDebugInfo[DEBUG_PAGE_EFFECTINFO][1]; + ((struct GraphNodeTranslationRotation *) node->next)->translation[2] = gDebugInfo[DEBUG_PAGE_EFFECTINFO][2]; + ((struct GraphNodeTranslationRotation *) node->next)->rotation[0] = gDebugInfo[DEBUG_PAGE_EFFECTINFO][3]; + ((struct GraphNodeTranslationRotation *) node->next)->rotation[1] = gDebugInfo[DEBUG_PAGE_EFFECTINFO][4]; + ((struct GraphNodeTranslationRotation *) node->next)->rotation[2] = gDebugInfo[DEBUG_PAGE_EFFECTINFO][5]; } - return 0; + return NULL; } s32 obj_is_hidden(struct Object *obj) { @@ -2908,7 +2908,7 @@ void cur_obj_spawn_loot_blue_coin(void) { #ifndef VERSION_JP void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY) { f32 objectPosY = o->oPosY; - o->oPosY += offsetY + gDebugInfo[5][0]; + o->oPosY += offsetY + gDebugInfo[DEBUG_PAGE_ENEMYINFO][0]; spawn_default_star(targetX, targetY, targetZ); o->oPosY = objectPosY; } diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index 6ae66dc1..fcd985b4 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -7,8 +7,7 @@ #include "types.h" // used for chain chomp and wiggler -struct ChainSegment -{ +struct ChainSegment { f32 posX; f32 posY; f32 posZ; @@ -25,8 +24,7 @@ struct ChainSegment #define WATER_DROPLET_FLAG_RAND_ANGLE_INCR 0x80 // Unused // Call spawn_water_droplet with this struct to spawn an object. -struct WaterDropletParams -{ +struct WaterDropletParams { s16 flags; // Droplet spawn flags, see defines above s16 model; const BehaviorScript *behavior; @@ -50,9 +48,7 @@ struct Struct802A272C { Vec3s vecS; }; -// TODO: Field names -struct SpawnParticlesInfo -{ +struct SpawnParticlesInfo { /*0x00*/ s8 behParam; /*0x01*/ s8 count; /*0x02*/ u8 model; @@ -94,9 +90,9 @@ void obj_set_pos(struct Object *obj, s16 x, s16 y, s16 z); void obj_set_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll); struct Object *spawn_object_abs_with_rot(struct Object *parent, s16 uselessArg, u32 model, const BehaviorScript *behavior, - s16 x, s16 y, s16 z, s16 rx, s16 ry, s16 rz); + s16 x, s16 y, s16 z, s16 pitch, s16 yaw, s16 roll); struct Object *spawn_object_rel_with_rot(struct Object *parent, u32 model, const BehaviorScript *behavior, - s16 xOff, s16 yOff, s16 zOff, s16 rx, s16 ry, UNUSED s16 rz); + s16 xOff, s16 yOff, s16 zOff, s16 pitch, s16 yaw, UNUSED s16 roll); struct Object *spawn_obj_with_transform_flags(struct Object *sp20, s32 model, const BehaviorScript *sp28); struct Object *spawn_water_droplet(struct Object *parent, struct WaterDropletParams *params); struct Object *spawn_object_at_origin(struct Object *, s32, u32, const BehaviorScript *); @@ -119,7 +115,7 @@ void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); void obj_apply_scale_to_transform(struct Object *obj); void obj_copy_scale(struct Object *dst, struct Object *src); -void obj_scale_xyz(struct Object* obj, f32 xScale, f32 yScale, f32 zScale); +void obj_scale_xyz(struct Object *obj, f32 xScale, f32 yScale, f32 zScale); void obj_scale(struct Object *obj, f32 scale); void cur_obj_scale(f32 scale); void cur_obj_init_animation_with_sound(s32 animIndex); @@ -226,16 +222,6 @@ s16 cur_obj_reflect_move_angle_off_wall(void); #define PATH_REACHED_END -1 #define PATH_REACHED_WAYPOINT 1 -struct GraphNode_802A45E4 { - /*0x00*/ s8 filler0[0x18 - 0x00]; - /*0x18*/ s16 unk18; - /*0x1A*/ s16 unk1A; - /*0x1C*/ s16 unk1C; - /*0x1E*/ s16 unk1E; - /*0x20*/ s16 unk20; - /*0x22*/ s16 unk22; -}; - void obj_set_hitbox(struct Object *obj, struct ObjectHitbox *hitbox); s32 signum_positive(s32 x); f32 absf(f32 x); @@ -266,7 +252,7 @@ void obj_set_collision_data(struct Object *obj, const void *segAddr); void cur_obj_if_hit_wall_bounce_away(void); s32 cur_obj_hide_if_mario_far_away_y(f32 distY); Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); -s32 geo_offset_klepto_debug(s32 a0, struct GraphNode *a1, UNUSED s32 sp8); +Gfx *geo_offset_klepto_debug(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); s32 obj_is_hidden(struct Object *obj); void enable_time_stop(void); void disable_time_stop(void); diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 3e970c02..80a49fb6 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -225,7 +225,7 @@ void copy_mario_state_to_object(void) { s32 i = 0; // L is real if (gCurrentObject != gMarioObject) { - i += 1; + i++; } gCurrentObject->oVelX = gMarioStates[i].vel[0]; @@ -300,7 +300,7 @@ s32 update_objects_starting_at(struct ObjectNode *objList, struct ObjectNode *fi cur_obj_update(); firstObj = firstObj->next; - count += 1; + count++; } return count; @@ -470,7 +470,7 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { while (spawnInfo != NULL) { struct Object *object; - UNUSED s32 unused; + UNUSED u8 filler[4]; const BehaviorScript *script; UNUSED s16 arg16 = (s16)(spawnInfo->behaviorArg & 0xFFFF); @@ -571,13 +571,13 @@ void update_terrain_objects(void) { * the order specified by sObjectListUpdateOrder. */ void update_non_terrain_objects(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; s32 listIndex; s32 i = 2; while ((listIndex = sObjectListUpdateOrder[i]) != -1) { gObjectCounter += update_objects_in_list(&gObjectLists[listIndex]); - i += 1; + i++; } } @@ -585,13 +585,13 @@ void update_non_terrain_objects(void) { * Unload deactivated objects in any object list. */ void unload_deactivated_objects(void) { - UNUSED s32 unused; + UNUSED u8 filler[4]; s32 listIndex; s32 i = 0; while ((listIndex = sObjectListUpdateOrder[i]) != -1) { unload_deactivated_objects_in_list(&gObjectLists[listIndex]); - i += 1; + i++; } // TIME_STOP_UNKNOWN_0 was most likely intended to be used to track whether diff --git a/src/game/object_list_processor.h b/src/game/object_list_processor.h index e3884f34..aed11fb9 100644 --- a/src/game/object_list_processor.h +++ b/src/game/object_list_processor.h @@ -29,8 +29,7 @@ * Every object is categorized into an object list, which controls the order * they are processed and which objects they can collide with. */ -enum ObjectList -{ +enum ObjectList { OBJ_LIST_PLAYER, // (0) Mario OBJ_LIST_UNUSED_1, // (1) (unused) OBJ_LIST_DESTRUCTIVE, // (2) things that can be used to destroy other objects, like diff --git a/src/game/paintings.c b/src/game/paintings.c index d98ea9aa..481db8f3 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -1109,7 +1109,7 @@ void reset_painting(struct Painting *painting) { */ void move_ddd_painting(struct Painting *painting, f32 frontPos, f32 backPos, f32 speed) { // Obtain the DDD star flags - u32 dddFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_DDD - 1); + u32 dddFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_DDD)); // Get the other save file flags u32 saveFileFlags = save_file_get_flags(); // Find out whether Board Bowser's Sub was collected diff --git a/src/game/paintings.h b/src/game/paintings.h index 3f4334b4..8c930331 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -15,7 +15,7 @@ #define PAINTING_ID_DDD 7 -#define BOARD_BOWSERS_SUB 1 +#define BOARD_BOWSERS_SUB (1 << 0) #define BOWSERS_SUB_BEATEN 0x2 #define DDD_BACK 0x1 @@ -32,8 +32,7 @@ /// Painting that has one texture used for an environment map effect #define PAINTING_ENV_MAP 1 -struct Painting -{ +struct Painting { s16 id; /// How many images should be drawn when the painting is rippling. s8 imageCount; diff --git a/src/game/platform_displacement.c b/src/game/platform_displacement.c index 9153bc4d..40a19940 100644 --- a/src/game/platform_displacement.c +++ b/src/game/platform_displacement.c @@ -21,7 +21,7 @@ struct Object *gMarioPlatform = NULL; */ void update_mario_platform(void) { struct Surface *floor; - UNUSED u32 unused; + UNUSED u8 filler[4]; f32 marioX; f32 marioY; f32 marioZ; @@ -99,9 +99,9 @@ void apply_platform_displacement(u32 isMario, struct Object *platform) { Vec3f relativeOffset; Vec3f newObjectOffset; Vec3s rotation; - UNUSED s16 unused1; - UNUSED s16 unused2; - UNUSED s16 unused3; + UNUSED s16 unusedPitch; + UNUSED s16 unusedRoll; + UNUSED s16 unusedYaw; f32 displaceMatrix[4][4]; rotation[0] = platform->oAngleVelPitch; @@ -121,9 +121,9 @@ void apply_platform_displacement(u32 isMario, struct Object *platform) { z += platform->oVelZ; if (rotation[0] != 0 || rotation[1] != 0 || rotation[2] != 0) { - unused1 = rotation[0]; - unused2 = rotation[2]; - unused3 = platform->oFaceAngleYaw; + unusedPitch = rotation[0]; + unusedRoll = rotation[2]; + unusedYaw = platform->oFaceAngleYaw; if (isMario) { gMarioStates[0].faceAngle[1] += rotation[1]; diff --git a/src/game/print.c b/src/game/print.c index e5972271..c804cb4a 100644 --- a/src/game/print.c +++ b/src/game/print.c @@ -107,8 +107,7 @@ void format_integer(s32 n, s32 base, char *dest, s32 *totalLength, u8 width, s8 n -= digit * powBase; } - } else // n is zero. - { + } else { // n is zero. numDigits = 1; if (width > numDigits) { for (len = 0; len < width - numDigits; len++) dest[len] = pad; @@ -138,8 +137,7 @@ void parse_width_field(const char *str, s32 *srcIndex, u8 *width, s8 *zeroPad) { while (str[*srcIndex] != 'd' && str[*srcIndex] != 'x') { digits[digitsLen] = str[*srcIndex] - '0'; - if (digits[digitsLen] < 0 || digits[digitsLen] >= 10) // not a valid digit - { + if (digits[digitsLen] < 0 || digits[digitsLen] >= 10) { // not a valid digit *width = 0; return; } @@ -206,8 +204,7 @@ void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n) { srcIndex++; format_integer(n, base, sTextLabels[sTextLabelsCount]->buffer + len, &len, width, zeroPad); - } else // straight copy - { + } else { // straight copy sTextLabels[sTextLabelsCount]->buffer[len] = c; len++; srcIndex++; diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 58238e83..8ea0d399 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -58,12 +58,12 @@ struct GeoAnimState { // of separate global variables. It won't match EU otherwise. struct GeoAnimState gGeoTempState; -u8 gCurAnimType; -u8 gCurAnimEnabled; +u8 gCurrAnimType; +u8 gCurrAnimEnabled; s16 gCurrAnimFrame; -f32 gCurAnimTranslationMultiplier; +f32 gCurrAnimTranslationMultiplier; u16 *gCurrAnimAttribute; -s16 *gCurAnimData; +s16 *gCurrAnimData; struct AllocOnlyPool *gDisplayListHeap; @@ -200,7 +200,7 @@ static void geo_append_display_list(void *displayList, s16 layer) { */ static void geo_process_master_list(struct GraphNodeMasterList *node) { s32 i; - UNUSED s32 sp1C; + UNUSED u8 filler[4]; if (gCurGraphNodeMasterList == NULL && node->node.children != NULL) { gCurGraphNodeMasterList = node; @@ -546,43 +546,43 @@ static void geo_process_animated_part(struct GraphNodeAnimatedPart *node) { vec3s_copy(rotation, gVec3sZero); vec3f_set(translation, node->translation[0], node->translation[1], node->translation[2]); - if (gCurAnimType == ANIM_TYPE_TRANSLATION) { - translation[0] += gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier; - translation[1] += gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier; - translation[2] += gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier; - gCurAnimType = ANIM_TYPE_ROTATION; + if (gCurrAnimType == ANIM_TYPE_TRANSLATION) { + translation[0] += gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier; + translation[1] += gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier; + translation[2] += gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier; + gCurrAnimType = ANIM_TYPE_ROTATION; } else { - if (gCurAnimType == ANIM_TYPE_LATERAL_TRANSLATION) { + if (gCurrAnimType == ANIM_TYPE_LATERAL_TRANSLATION) { translation[0] += - gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier; + gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier; gCurrAnimAttribute += 2; translation[2] += - gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier; - gCurAnimType = ANIM_TYPE_ROTATION; + gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier; + gCurrAnimType = ANIM_TYPE_ROTATION; } else { - if (gCurAnimType == ANIM_TYPE_VERTICAL_TRANSLATION) { + if (gCurrAnimType == ANIM_TYPE_VERTICAL_TRANSLATION) { gCurrAnimAttribute += 2; translation[1] += - gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier; + gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier; gCurrAnimAttribute += 2; - gCurAnimType = ANIM_TYPE_ROTATION; - } else if (gCurAnimType == ANIM_TYPE_NO_TRANSLATION) { + gCurrAnimType = ANIM_TYPE_ROTATION; + } else if (gCurrAnimType == ANIM_TYPE_NO_TRANSLATION) { gCurrAnimAttribute += 6; - gCurAnimType = ANIM_TYPE_ROTATION; + gCurrAnimType = ANIM_TYPE_ROTATION; } } } - if (gCurAnimType == ANIM_TYPE_ROTATION) { - rotation[0] = gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)]; - rotation[1] = gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)]; - rotation[2] = gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)]; + if (gCurrAnimType == ANIM_TYPE_ROTATION) { + rotation[0] = gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)]; + rotation[1] = gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)]; + rotation[2] = gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)]; } mtxf_rotate_xyz_and_translate(matrix, translation, rotation); mtxf_mul(gMatStack[gMatStackIndex + 1], matrix, gMatStack[gMatStackIndex]); @@ -610,24 +610,24 @@ void geo_set_animation_globals(struct AnimInfo *node, s32 hasAnimation) { } node->animTimer = gAreaUpdateCounter; if (anim->flags & ANIM_FLAG_HOR_TRANS) { - gCurAnimType = ANIM_TYPE_VERTICAL_TRANSLATION; + gCurrAnimType = ANIM_TYPE_VERTICAL_TRANSLATION; } else if (anim->flags & ANIM_FLAG_VERT_TRANS) { - gCurAnimType = ANIM_TYPE_LATERAL_TRANSLATION; + gCurrAnimType = ANIM_TYPE_LATERAL_TRANSLATION; } else if (anim->flags & ANIM_FLAG_6) { - gCurAnimType = ANIM_TYPE_NO_TRANSLATION; + gCurrAnimType = ANIM_TYPE_NO_TRANSLATION; } else { - gCurAnimType = ANIM_TYPE_TRANSLATION; + gCurrAnimType = ANIM_TYPE_TRANSLATION; } gCurrAnimFrame = node->animFrame; - gCurAnimEnabled = (anim->flags & ANIM_FLAG_5) == 0; + gCurrAnimEnabled = (anim->flags & ANIM_FLAG_5) == 0; gCurrAnimAttribute = segmented_to_virtual((void *) anim->index); - gCurAnimData = segmented_to_virtual((void *) anim->values); + gCurrAnimData = segmented_to_virtual((void *) anim->values); if (anim->animYTransDivisor == 0) { - gCurAnimTranslationMultiplier = 1.0f; + gCurrAnimTranslationMultiplier = 1.0f; } else { - gCurAnimTranslationMultiplier = (f32) node->animYTrans / (f32) anim->animYTransDivisor; + gCurrAnimTranslationMultiplier = (f32) node->animYTrans / (f32) anim->animYTransDivisor; } } @@ -659,21 +659,21 @@ static void geo_process_shadow(struct GraphNodeShadow *node) { } objScale = 1.0f; - if (gCurAnimEnabled) { - if (gCurAnimType == ANIM_TYPE_TRANSLATION - || gCurAnimType == ANIM_TYPE_LATERAL_TRANSLATION) { + if (gCurrAnimEnabled) { + if (gCurrAnimType == ANIM_TYPE_TRANSLATION + || gCurrAnimType == ANIM_TYPE_LATERAL_TRANSLATION) { geo = node->node.children; if (geo != NULL && geo->type == GRAPH_NODE_TYPE_SCALE) { objScale = ((struct GraphNodeScale *) geo)->scale; } animOffset[0] = - gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier * objScale; + gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier * objScale; animOffset[1] = 0.0f; gCurrAnimAttribute += 2; animOffset[2] = - gCurAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] - * gCurAnimTranslationMultiplier * objScale; + gCurrAnimData[retrieve_animation_index(gCurrAnimFrame, &gCurrAnimAttribute)] + * gCurrAnimTranslationMultiplier * objScale; gCurrAnimAttribute -= 6; // simple matrix rotation so the shadow offset rotates along with the object @@ -846,7 +846,7 @@ static void geo_process_object(struct Object *node) { } gMatStackIndex--; - gCurAnimType = ANIM_TYPE_NONE; + gCurrAnimType = ANIM_TYPE_NONE; node->header.gfx.throwMatrix = NULL; } } @@ -904,13 +904,13 @@ void geo_process_held_object(struct GraphNodeHeldObject *node) { gMatStackIndex++; mtxf_to_mtx(mtx, gMatStack[gMatStackIndex]); gMatStackFixed[gMatStackIndex] = mtx; - gGeoTempState.type = gCurAnimType; - gGeoTempState.enabled = gCurAnimEnabled; + gGeoTempState.type = gCurrAnimType; + gGeoTempState.enabled = gCurrAnimEnabled; gGeoTempState.frame = gCurrAnimFrame; - gGeoTempState.translationMultiplier = gCurAnimTranslationMultiplier; + gGeoTempState.translationMultiplier = gCurrAnimTranslationMultiplier; gGeoTempState.attribute = gCurrAnimAttribute; - gGeoTempState.data = gCurAnimData; - gCurAnimType = 0; + gGeoTempState.data = gCurrAnimData; + gCurrAnimType = 0; gCurGraphNodeHeldObject = (void *) node; if (node->objNode->header.gfx.animInfo.curAnim != NULL) { geo_set_animation_globals(&node->objNode->header.gfx.animInfo, hasAnimation); @@ -918,12 +918,12 @@ void geo_process_held_object(struct GraphNodeHeldObject *node) { geo_process_node_and_siblings(node->objNode->header.gfx.sharedChild); gCurGraphNodeHeldObject = NULL; - gCurAnimType = gGeoTempState.type; - gCurAnimEnabled = gGeoTempState.enabled; + gCurrAnimType = gGeoTempState.type; + gCurrAnimEnabled = gGeoTempState.enabled; gCurrAnimFrame = gGeoTempState.frame; - gCurAnimTranslationMultiplier = gGeoTempState.translationMultiplier; + gCurrAnimTranslationMultiplier = gGeoTempState.translationMultiplier; gCurrAnimAttribute = gGeoTempState.attribute; - gCurAnimData = gGeoTempState.data; + gCurrAnimData = gGeoTempState.data; gMatStackIndex--; } @@ -1040,7 +1040,7 @@ void geo_process_node_and_siblings(struct GraphNode *firstNode) { * to set up the projection and draw display lists. */ void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor) { - UNUSED s32 unused; + UNUSED u8 filler[4]; if (node->node.flags & GRAPH_RENDER_ACTIVE) { Mtx *initialMatrix; @@ -1050,17 +1050,17 @@ void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor) MEMORY_POOL_LEFT); initialMatrix = alloc_display_list(sizeof(*initialMatrix)); gMatStackIndex = 0; - gCurAnimType = 0; + gCurrAnimType = 0; vec3s_set(viewport->vp.vtrans, node->x * 4, node->y * 4, 511); vec3s_set(viewport->vp.vscale, node->width * 4, node->height * 4, 511); if (b != NULL) { - clear_frame_buffer(clearColor); + clear_framebuffer(clearColor); make_viewport_clip_rect(b); *viewport = *b; } else if (c != NULL) { - clear_frame_buffer(clearColor); + clear_framebuffer(clearColor); make_viewport_clip_rect(c); } diff --git a/src/game/save_file.c b/src/game/save_file.c index 02e5bdc8..85e5df18 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -26,7 +26,7 @@ s8 gSaveFileModified; u8 gLastCompletedCourseNum = COURSE_NONE; u8 gLastCompletedStarNum = 0; -s8 sUnusedGotGlobalCoinHiScore = 0; +s8 sUnusedGotGlobalCoinHiScore = FALSE; u8 gGotFileCoinHiScore = FALSE; u8 gCurrCourseStarFlags = 0; @@ -47,7 +47,7 @@ STATIC_ASSERT(ARRAY_COUNT(gLevelToCourseNumTable) == LEVEL_COUNT - 1, // This was probably used to set progress to 100% for debugging, but // it was removed from the release ROM. static void stub_save_file_1(void) { - UNUSED s32 pad; + UNUSED u8 filler[4]; } /** @@ -225,7 +225,7 @@ static void touch_coin_score_age(s32 fileIndex, s32 courseIndex) { static void touch_high_score_ages(s32 fileIndex) { s32 i; - for (i = 0; i < 15; i++) { + for (i = COURSE_NUM_TO_INDEX(COURSE_MIN); i <= COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX); i++) { touch_coin_score_age(fileIndex, i); } } @@ -278,7 +278,7 @@ void save_file_erase(s32 fileIndex) { //! Needs to be s32 to match on -O2, despite no return value. BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex) { - UNUSED s32 pad; + UNUSED u8 filler[4]; touch_high_score_ages(destFileIndex); bcopy(&gSaveBuffer.files[srcFileIndex][0], &gSaveBuffer.files[destFileIndex][0], @@ -356,22 +356,23 @@ void save_file_reload(void) { */ void save_file_collect_star_or_key(s16 coinScore, s16 starIndex) { s32 fileIndex = gCurrSaveFileNum - 1; - s32 courseIndex = gCurrCourseNum - 1; + s32 courseIndex = COURSE_NUM_TO_INDEX(gCurrCourseNum); s32 starFlag = 1 << starIndex; UNUSED s32 flags = save_file_get_flags(); gLastCompletedCourseNum = courseIndex + 1; gLastCompletedStarNum = starIndex + 1; - sUnusedGotGlobalCoinHiScore = 0; + sUnusedGotGlobalCoinHiScore = FALSE; gGotFileCoinHiScore = FALSE; - if (courseIndex >= 0 && courseIndex < COURSE_STAGES_COUNT) { + if (courseIndex >= COURSE_NUM_TO_INDEX(COURSE_MIN) + && courseIndex <= COURSE_NUM_TO_INDEX(COURSE_STAGES_MAX)) { //! Compares the coin score as a 16 bit value, but only writes the 8 bit // truncation. This can allow a high score to decrease. if (coinScore > ((u16) save_file_get_max_coin_score(courseIndex) & 0xFFFF)) { - sUnusedGotGlobalCoinHiScore = 1; + sUnusedGotGlobalCoinHiScore = TRUE; } if (coinScore > save_file_get_course_coin_score(fileIndex, courseIndex)) { @@ -460,7 +461,7 @@ s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse) } // Add castle secret star count. - return save_file_get_course_star_count(fileIndex, -1) + count; + return save_file_get_course_star_count(fileIndex, COURSE_NUM_TO_INDEX(COURSE_NONE)) + count; } void save_file_set_flags(u32 flags) { @@ -483,12 +484,12 @@ u32 save_file_get_flags(void) { /** * Return the bitset of obtained stars in the specified course. - * If course is -1, return the bitset of obtained castle secret stars. + * If course is COURSE_NONE, return the bitset of obtained castle secret stars. */ u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) { u32 starFlags; - if (courseIndex == -1) { + if (courseIndex == COURSE_NUM_TO_INDEX(COURSE_NONE)) { starFlags = SAVE_FLAG_TO_STAR_FLAG(gSaveBuffer.files[fileIndex][0].flags); } else { starFlags = gSaveBuffer.files[fileIndex][0].courseStars[courseIndex] & 0x7F; @@ -499,10 +500,10 @@ u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) { /** * Add to the bitset of obtained stars in the specified course. - * If course is -1, add to the bitset of obtained castle secret stars. + * If course is COURSE_NONE, add to the bitset of obtained castle secret stars. */ void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags) { - if (courseIndex == -1) { + if (courseIndex == COURSE_NUM_TO_INDEX(COURSE_NONE)) { gSaveBuffer.files[fileIndex][0].flags |= STAR_FLAG_TO_SAVE_FLAG(starFlags); } else { gSaveBuffer.files[fileIndex][0].courseStars[courseIndex] |= starFlags; @@ -520,14 +521,14 @@ s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex) { * Return TRUE if the cannon is unlocked in the current course. */ s32 save_file_is_cannon_unlocked(void) { - return (gSaveBuffer.files[gCurrSaveFileNum - 1][0].courseStars[gCurrCourseNum] & 0x80) != 0; + return (gSaveBuffer.files[gCurrSaveFileNum - 1][0].courseStars[gCurrCourseNum] & (1 << 7)) != 0; } /** * Sets the cannon status to unlocked in the current course. */ void save_file_set_cannon_unlocked(void) { - gSaveBuffer.files[gCurrSaveFileNum - 1][0].courseStars[gCurrCourseNum] |= 0x80; + gSaveBuffer.files[gCurrSaveFileNum - 1][0].courseStars[gCurrCourseNum] |= (1 << 7); gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags |= SAVE_FLAG_FILE_EXISTS; gSaveFileModified = TRUE; } diff --git a/src/game/save_file.h b/src/game/save_file.h index ae6fcf35..ad1b62a9 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -11,14 +11,12 @@ #define EEPROM_SIZE 0x200 #define NUM_SAVE_FILES 4 -struct SaveBlockSignature -{ +struct SaveBlockSignature { u16 magic; u16 chksum; }; -struct SaveFile -{ +struct SaveFile { // Location of lost cap. // Note: the coordinates get set, but are never actually used, since the // cap can always be found in a fixed spot within the course @@ -45,8 +43,7 @@ enum SaveFileIndex { SAVE_FILE_D }; -struct MainMenuSaveData -{ +struct MainMenuSaveData { // Each save file has a 2 bit "age" for each course. The higher this value, // the older the high score is. This is used for tie-breaking when displaying // on the high score screen. @@ -66,8 +63,7 @@ struct MainMenuSaveData struct SaveBlockSignature signature; }; -struct SaveBuffer -{ +struct SaveBuffer { // Each of the four save files has two copies. If one is bad, the other is used as a backup. struct SaveFile files[NUM_SAVE_FILES][2]; // The main menu data has two copies. If one is bad, the other is used as a backup. diff --git a/src/game/screen_transition.h b/src/game/screen_transition.h index 70b3c21a..43fa0510 100644 --- a/src/game/screen_transition.h +++ b/src/game/screen_transition.h @@ -7,16 +7,14 @@ #include "macros.h" #include "types.h" -enum TextureTransitionID -{ +enum TextureTransitionID { TEX_TRANS_STAR, TEX_TRANS_CIRCLE, TEX_TRANS_MARIO, TEX_TRANS_BOWSER }; -enum TextureTransitionType -{ +enum TextureTransitionType { TRANS_TYPE_MIRROR, TRANS_TYPE_CLAMP }; diff --git a/src/game/shadow.c b/src/game/shadow.c index 69145cff..5856272d 100644 --- a/src/game/shadow.c +++ b/src/game/shadow.c @@ -211,7 +211,7 @@ s8 init_shadow(struct Shadow *s, f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, s->floorHeight = find_floor_height_and_data(s->parentX, s->parentY, s->parentZ, &floorGeometry); - if (gEnvironmentRegions != 0) { + if (gEnvironmentRegions != NULL) { waterLevel = get_water_level_below_shadow(s); } if (gShadowAboveWaterOrLava) { @@ -309,8 +309,8 @@ void make_shadow_vertex_at_xyz(Vtx *vertices, s8 index, f32 relX, f32 relY, f32 vtxY += 5; vtxZ += 5; } - make_vertex(vertices, index, vtxX, vtxY, vtxZ, textureX << 5, textureY << 5, 255, 255, 255, - alpha // shadows are black + make_vertex( // shadows are black + vertices, index, vtxX, vtxY, vtxZ, textureX << 5, textureY << 5, 255, 255, 255, alpha ); } diff --git a/src/game/shadow.h b/src/game/shadow.h index 36b3ef06..d527260a 100644 --- a/src/game/shadow.h +++ b/src/game/shadow.h @@ -8,8 +8,7 @@ * Shadow types. Shadows are circles, squares, or hardcoded rectangles, and * can be composed of either 4 or 9 vertices. */ -enum ShadowType -{ +enum ShadowType { SHADOW_CIRCLE_9_VERTS = 0, SHADOW_CIRCLE_4_VERTS = 1, SHADOW_CIRCLE_4_VERTS_FLAT_UNUSED = 2, diff --git a/src/game/skybox.c b/src/game/skybox.c index 1cf58f5c..055d1ce9 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -302,8 +302,9 @@ Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov, f32 cameraFaceZ = focZ - posZ; s8 colorIndex = 1; - // If the first star is collected in JRB, make the sky darker and slightly green - if (background == 8 && !(save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_JRB - 1) & 1)) { + // If the "Plunder in the Sunken Ship" star in JRB is collected, make the sky darker and slightly green + if (background == 8 + && !(save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_JRB)) & (1 << 0))) { colorIndex = 0; } diff --git a/src/game/spawn_sound.c b/src/game/spawn_sound.c index 18168b59..abca0d81 100644 --- a/src/game/spawn_sound.c +++ b/src/game/spawn_sound.c @@ -75,7 +75,7 @@ void cur_obj_play_sound_2(s32 soundMagic) { if (soundMagic == SOUND_OBJ_POUNDING_LOUD) { queue_rumble_data(3, 60); } - if (soundMagic == SOUND_OBJ_WHOMP_LOWPRIO) { + if (soundMagic == SOUND_OBJ_WHOMP) { queue_rumble_data(5, 80); } #endif @@ -93,8 +93,7 @@ void cur_obj_play_sound_2(s32 soundMagic) { * Technically, these functions are only educated guesses. Trust these * interpretations at your own discretion. */ -s32 calc_dist_to_volume_range_1(f32 distance) // range from 60-124 -{ +s32 calc_dist_to_volume_range_1(f32 distance) { // range from 60-124 s32 volume; if (distance < 500.0f) { @@ -108,8 +107,7 @@ s32 calc_dist_to_volume_range_1(f32 distance) // range from 60-124 return volume; } -s32 calc_dist_to_volume_range_2(f32 distance) // range from 79.2-143.2 -{ +s32 calc_dist_to_volume_range_2(f32 distance) { // range from 79.2-143.2 s32 volume; if (distance < 1300.0f) { diff --git a/src/game/spawn_sound.h b/src/game/spawn_sound.h index c00a13be..b4652978 100644 --- a/src/game/spawn_sound.h +++ b/src/game/spawn_sound.h @@ -3,8 +3,7 @@ #include -struct SoundState -{ +struct SoundState { s16 playSound; // if this is 1, the info below will // be used to determine the sound behavior // for the object. if 0, this is skipped. diff --git a/src/goddard/debug_utils.c b/src/goddard/debug_utils.c index 6e957539..08783004 100644 --- a/src/goddard/debug_utils.c +++ b/src/goddard/debug_utils.c @@ -220,7 +220,7 @@ void remove_all_timers(void) { for (i = 0; i < ARRAY_COUNT(sTimers); i++) { sTimers[i].name = NULL; sTimers[i].total = 0; - sTimers[i].unused0C = 0.0f; + sTimers[i].unused = 0.0f; sTimers[i].scaledTotal = 0.0f; sTimers[i].prevScaledTotal = 0.0f; sTimers[i].gadgetColourNum = sTimerGadgetColours[(u32) i % 7]; @@ -470,7 +470,7 @@ void print_stack_trace(void) { */ void fatal_printf(const char *fmt, ...) { char cur; - UNUSED u8 pad[4]; + UNUSED u8 filler[4]; va_list vl; va_start(vl, fmt); @@ -704,7 +704,7 @@ char *sprint_val_withspecifiers(char *str, union PrintVal val, char *specifiers) s32 intPart; // sp38 s32 intPrec; // sp34 s32 fracPrec; // sp30 - UNUSED u8 pad[4]; + UNUSED u8 filler[4]; char cur; // sp2B fracPrec = 6; @@ -840,7 +840,7 @@ struct GdFile *gd_fopen(const char *filename, const char *mode) { struct GdFile *f; // sp74 char *loadedname; // sp70 u32 i; // sp6C - UNUSED u32 pad68; + UNUSED u8 filler[4]; struct UnkBufThing buf; // sp24 u8 *bufbytes; // sp20 u8 *fileposptr; // sp1C @@ -932,7 +932,7 @@ s32 is_newline(char c) { s32 gd_fread_line(char *buf, u32 size, struct GdFile *f) { signed char c; u32 pos = 0; - UNUSED u32 pad1c; + UNUSED u8 filler[4]; do { if (gd_fread(&c, 1, 1, f) == -1) { diff --git a/src/goddard/debug_utils.h b/src/goddard/debug_utils.h index 4c2bcafb..036d0f73 100644 --- a/src/goddard/debug_utils.h +++ b/src/goddard/debug_utils.h @@ -21,7 +21,7 @@ struct GdTimer { /* 0x00 */ s32 start; // in cycles /* 0x04 */ s32 end; // in cycles /* 0x08 */ s32 total; // in cycles - /* 0x0C */ f32 unused0C; + /* 0x0C */ f32 unused; /* 0x10 */ f32 scaledTotal; // total / sTimeScaleFactor (1.0f) Unused function modified value /* 0x14 */ f32 prevScaledTotal; /* 0x18 */ const char *name; @@ -37,7 +37,7 @@ union PrintVal { /* based on fields set in gd_fopen; gd_malloc_perm(84) for size */ struct GdFile { - /* 0x00 */ u8 pad00[4]; + /* 0x00 */ u8 filler1[4]; /* 0x04 */ u32 pos; /* 0x08 */ s8 *stream; /* Known Flags for +0xC field: @@ -45,7 +45,7 @@ struct GdFile { ** 2 : binary mode ** 4 : eof */ /* 0x0C */ u32 flags; - /* 0x10 */ u8 pad10[0x50-0x10]; + /* 0x10 */ u8 filler2[64]; /* 0x50 */ u32 size; }; /* sizeof() = 0x54 */ diff --git a/src/goddard/draw_objects.c b/src/goddard/draw_objects.c index abb7bcd3..85974d50 100644 --- a/src/goddard/draw_objects.c +++ b/src/goddard/draw_objects.c @@ -40,7 +40,7 @@ enum SceneType { * texture S,T coordinates. */ struct BetaVtx { - /* 0x00 */ u8 pad[0x44 - 0]; + /* 0x00 */ u8 filler[68]; /* 0x44 */ f32 s; /* 0x48 */ f32 t; }; @@ -91,12 +91,12 @@ static f32 sPickObjDistance; ///< distance between object position a static struct GdObj *sPickedObject; ///< object selected with cursor /// Various counters and pointers set in update_view() and used in various `draw_XXX` functions static struct { - u32 pad00; // @ 801B9CE0 + u8 filler1[4]; // @ 801B9CE0 struct ObjView *view; // @ 801B9CE4 s32 unreadCounter; // @ 801B9CE8 s32 mtlDlNum; // @ 801B9CEC; name is a big guess s32 shapesDrawn; // @ 801B9CF0 - s32 unused18; // @ 801B9CF4 + s32 unused; // @ 801B9CF4 } sUpdateViewState; static struct ObjLight *sPhongLight; // material light? phong light? static struct GdVec3f sPhongLightPosition; //@ 801B9D00; guess; light source unit position for light @@ -168,7 +168,7 @@ void draw_shape(struct ObjShape *shape, s32 flag, f32 c, f32 d, f32 e, // "sweep f32 i, f32 j, f32 k, // translate shape f32 l, f32 m, f32 n, // rotate x, y, z s32 colorIdx, Mat4f *rotMtx) { - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; struct GdVec3f sp1C; restart_timer("drawshape"); @@ -245,7 +245,7 @@ void draw_shape(struct ObjShape *shape, s32 flag, f32 c, f32 d, f32 e, // "sweep void draw_shape_2d(struct ObjShape *shape, s32 flag, UNUSED f32 c, UNUSED f32 d, UNUSED f32 e, f32 f, f32 g, f32 h, UNUSED f32 i, UNUSED f32 j, UNUSED f32 k, UNUSED f32 l, UNUSED f32 m, UNUSED f32 n, UNUSED s32 color, UNUSED s32 p) { - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; struct GdVec3f sp1C; restart_timer("drawshape2d"); @@ -437,15 +437,14 @@ void draw_face(struct ObjFace *face) { f32 z; // 38 f32 y; // 34 f32 x; // 30 - UNUSED u8 pad[12]; + UNUSED u8 filler[12]; s32 i; // 20; also used to store mtl's gddl number s32 hasTextCoords; // 1c Vtx *gbiVtx; // 18 imin("draw_face"); hasTextCoords = FALSE; - if (sUseSelectedColor == FALSE && face->mtlId >= 0) // -1 == colored face - { + if (sUseSelectedColor == FALSE && face->mtlId >= 0) { // -1 == colored face if (face->mtl != NULL) { if ((i = face->mtl->gddlNumber) != 0) { if (i != sUpdateViewState.mtlDlNum) { @@ -536,7 +535,7 @@ void Unknown801792F0(struct GdObj *obj) { void draw_label(struct ObjLabel *label) { struct GdVec3f position; char strbuf[0x100]; - UNUSED u8 unused[16]; + UNUSED u8 filler[16]; struct ObjValPtr *valptr; union ObjVarVal varval; valptrproc_t valfn = label->valfn; @@ -594,7 +593,7 @@ void draw_label(struct ObjLabel *label) { void draw_net(struct ObjNet *self) { struct ObjNet *net = self; s32 netColor; - UNUSED u8 unused[80]; + UNUSED u8 filler[80]; if (sSceneProcessType == FIND_PICKS) { return; @@ -728,9 +727,9 @@ void world_pos_to_screen_coords(struct GdVec3f *pos, struct ObjCamera *cam, stru * @param input `GdObj` to check position of * @return void */ -void check_grabable_click(struct GdObj *input) { +void check_grabbable_click(struct GdObj *input) { struct GdVec3f objPos; - UNUSED u8 unused[12]; + UNUSED u8 filler[12]; struct GdObj *obj; Mat4f *mtx; @@ -738,7 +737,7 @@ void check_grabable_click(struct GdObj *input) { return; } obj = input; - if (!(obj->drawFlags & OBJ_IS_GRABBALE)) { + if (!(obj->drawFlags & OBJ_IS_GRABBABLE)) { return; } @@ -773,7 +772,7 @@ void check_grabable_click(struct GdObj *input) { * @param lightgrp lights of `ObjView */ void drawscene(enum SceneType process, struct ObjGroup *interactables, struct ObjGroup *lightgrp) { - UNUSED u8 unused[16]; + UNUSED u8 filler[16]; restart_timer("drawscene"); imin("draw_scene()"); @@ -820,7 +819,7 @@ void drawscene(enum SceneType process, struct ObjGroup *interactables, struct Ob restart_timer("drawobj"); imin("process_group"); if (sSceneProcessType == FIND_PICKS) { - apply_to_obj_types_in_group(OBJ_TYPE_ALL, (applyproc_t) check_grabable_click, interactables); + apply_to_obj_types_in_group(OBJ_TYPE_ALL, (applyproc_t) check_grabbable_click, interactables); } else { apply_to_obj_types_in_group(OBJ_TYPE_LIGHTS | OBJ_TYPE_GADGETS | OBJ_TYPE_NETS | OBJ_TYPE_PARTICLES, @@ -869,11 +868,11 @@ void draw_shape_faces(struct ObjShape *shape) { */ void draw_particle(struct GdObj *obj) { struct ObjParticle *ptc = (struct ObjParticle *) obj; - UNUSED u8 unused1[16]; + UNUSED u8 filler1[16]; struct GdColour *white; struct GdColour *black; f32 brightness; - UNUSED u8 unused2[16]; + UNUSED u8 filler2[16]; if (ptc->timeout > 0) { white = sColourPalette[0]; @@ -909,9 +908,9 @@ void draw_particle(struct GdObj *obj) { */ void draw_bone(struct GdObj *obj) { struct ObjBone *bone = (struct ObjBone *) obj; - UNUSED u8 unused1[4]; + UNUSED u8 filler1[4]; s32 colour; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; struct GdVec3f scale; // guess return; @@ -940,14 +939,14 @@ void draw_bone(struct GdObj *obj) { */ void draw_joint(struct GdObj *obj) { struct ObjJoint *joint = (struct ObjJoint *) obj; - UNUSED u8 unused1[4]; + UNUSED u8 filler1[4]; UNUSED f32 sp7C = 70.0f; - UNUSED u8 unused2[4]; + UNUSED u8 filler2[4]; UNUSED s32 sp74 = 1; s32 colour; - UNUSED u8 unused[8]; + UNUSED u8 filler3[8]; struct ObjShape *boneShape; - UNUSED u8 unused3[28]; + UNUSED u8 filler4[28]; if ((boneShape = joint->shapePtr) == NULL) { return; @@ -1341,7 +1340,7 @@ void map_vertices(struct ObjGroup *facegrp, struct ObjGroup *vtxgrp) { */ void unpick_obj(struct GdObj *obj) { struct GdObj *why = obj; - if (why->drawFlags & OBJ_IS_GRABBALE) { + if (why->drawFlags & OBJ_IS_GRABBABLE) { why->drawFlags &= ~(OBJ_PICKED | OBJ_HIGHLIGHTED); } } @@ -1357,10 +1356,10 @@ void unpick_obj(struct GdObj *obj) { */ void find_closest_pickable_obj(struct GdObj *input) { struct GdObj *obj = input; - UNUSED u8 unused[12]; + UNUSED u8 filler[12]; f32 distance; - if (obj->drawFlags & OBJ_IS_GRABBALE) { + if (obj->drawFlags & OBJ_IS_GRABBABLE) { if (obj->index == sPickDataTemp) { if (gViewUpdateCamera != NULL) { distance = d_calc_world_dist_btwn(&gViewUpdateCamera->header, obj); @@ -1412,7 +1411,7 @@ void update_view(struct ObjView *view) { char objTypeAbbr[0x100]; sUpdateViewState.shapesDrawn = 0; - sUpdateViewState.unused18 = 0; + sUpdateViewState.unused = 0; if (!(view->flags & VIEW_UPDATE)) { view->flags &= ~VIEW_WAS_UPDATED; @@ -1517,8 +1516,7 @@ void update_view(struct ObjView *view) { } find_and_drag_picked_object(sUpdateViewState.view->components); - } else // check for any previously picked objects, and turn off? - { + } else { // check for any previously picked objects, and turn off? if (sUpdateViewState.view->pickedObj != NULL) { sUpdateViewState.view->pickedObj->drawFlags &= ~OBJ_PICKED; sUpdateViewState.view->pickedObj->drawFlags &= ~OBJ_HIGHLIGHTED; diff --git a/src/goddard/dynlist_proc.c b/src/goddard/dynlist_proc.c index 4b9f21c4..82ddae28 100644 --- a/src/goddard/dynlist_proc.c +++ b/src/goddard/dynlist_proc.c @@ -159,7 +159,7 @@ void reset_dynlist(void) { * Normally the dynlist specifically sets an object for return. */ struct GdObj *proc_dynlist(struct DynList *dylist) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; if (dylist++->cmd != 0xD1D4) { fatal_printf("proc_dynlist() not a valid dyn list"); @@ -416,8 +416,7 @@ static struct DynObjInfo *get_dynobj_info(DynObjName name) { gd_strcat(buf, sDynNameSuffix); foundDynobj = NULL; for (i = 0; i < sLoadedDynObjs; i++) { - if (gd_str_not_equal(sGdDynObjList[i].name, buf) == 0) - { + if (gd_str_not_equal(sGdDynObjList[i].name, buf) == 0) { foundDynobj = &sGdDynObjList[i]; break; } @@ -434,7 +433,7 @@ static struct DynObjInfo *get_dynobj_info(DynObjName name) { * @note Not called */ void reset_dynamic_objs(void) { - UNUSED s32 pad; + UNUSED u8 filler[4]; if (sLoadedDynObjs == 0) { return; @@ -486,7 +485,7 @@ void d_end_net_with_subgroup(DynObjName name) { */ void d_attach_joint_to_net(UNUSED s32 arg0, DynObjName name) { UNUSED struct DynObjInfo *curInfo = sDynListCurInfo; - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; d_makeobj(D_JOINT, name); d_set_type(3); @@ -517,7 +516,7 @@ void d_make_netfromshapeid(DynObjName name) { * the shape is not moved into the dynamic list. */ void d_make_netfromshape_ptrptr(struct ObjShape **shapePtr) { - UNUSED u32 pad; + UNUSED u8 filler[4]; struct ObjNet *net = make_netfromshape(*shapePtr); printf("dMakeNetFromShapePtrPtr\n"); @@ -531,7 +530,7 @@ void d_make_netfromshape_ptrptr(struct ObjShape **shapePtr) { * needed later. */ void add_to_dynobj_list(struct GdObj *newobj, DynObjName name) { - UNUSED u32 pad; + UNUSED u8 filler[4]; char idbuf[0x100]; start_memtracker("dynlist"); @@ -719,9 +718,9 @@ void d_attach(DynObjName name) { * the "attach flags" of the current dynamic object to `flag` */ void d_attach_to(s32 flag, struct GdObj *obj) { - UNUSED u32 pad4C; + UNUSED u8 filler1[4]; struct ObjGroup *attgrp; - UNUSED u32 pad[2]; + UNUSED u8 filler2[8]; UNUSED struct DynObjInfo *curInfo = sDynListCurInfo; struct GdVec3f currObjPos; // transformed into attach offset struct GdVec3f objPos; @@ -843,7 +842,7 @@ void copy_bytes(u8 *src, u8 *dst, s32 num) { * rather than solely byted copied like the other types. */ void alloc_animdata(struct ObjAnimator *animator) { - UNUSED u32 pad5C; + UNUSED u8 filler1[4]; // probably should be three GdVec3fs, not triangle... // vec0 = position; vec1 = scale? rotation?; vec2 = translation struct GdTriangleF tri; //+58; temp float for converting half to f32? @@ -859,7 +858,7 @@ void alloc_animdata(struct ObjAnimator *animator) { void *allocSpace; //+30; allocated animdata space f32 allocMtxScale = 0.1f; //+2C; scale postion/rotation of GD_ANIM_SCALE3S_POS3S_ROT3S data struct AnimMtxVec *curMtxVec; //+28 - UNUSED u32 pad20; + UNUSED u8 filler2[4]; start_memtracker("animdata"); @@ -975,7 +974,7 @@ void chk_shapegen(struct ObjShape *shape) { struct ObjGroup *shapeMtls; // sp50 struct ObjGroup *shapeFaces; // sp4C struct ObjGroup *shapeVtx; // sp48 - UNUSED u32 pad44; + UNUSED u8 filler[4]; struct ObjGroup *madeFaces; // sp40 struct ObjGroup *madeVtx; // sp3C u32 i; // sp38 @@ -990,8 +989,7 @@ void chk_shapegen(struct ObjShape *shape) { shapeVtx = shape->vtxGroup; if (shapeVtx != NULL && shapeFaces != NULL) { - if ((shapeVtx->linkType & 1) && (shapeFaces->linkType & 1)) //? needs the double if - { + if ((shapeVtx->linkType & 1) && (shapeFaces->linkType & 1)) { //? needs the double if // These ListNodes point to special, compressed data structures vtxdata = (struct GdVtxData *) shapeVtx->firstMember->obj; facedata = (struct GdFaceData *) shapeFaces->firstMember->obj; @@ -1082,7 +1080,7 @@ void chk_shapegen(struct ObjShape *shape) { */ void d_set_nodegroup(DynObjName name) { struct DynObjInfo *info; // sp2C - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); @@ -1148,7 +1146,7 @@ void d_set_matgroup(DynObjName name) { * ST coordinates. */ void d_set_texture_st(UNUSED f32 s, UNUSED f32 t) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); @@ -1259,7 +1257,7 @@ void d_map_vertices(DynObjName name) { */ void d_set_planegroup(DynObjName name) { struct DynObjInfo *info; - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); @@ -1400,7 +1398,7 @@ void d_start_group(DynObjName name) { * and this call. */ void d_end_group(DynObjName name) { - UNUSED u32 pad; + UNUSED u8 filler[4]; struct DynObjInfo *info = get_dynobj_info(name); struct ObjGroup *dynGrp; s32 i; @@ -1421,7 +1419,7 @@ void d_end_group(DynObjName name) { * Add the current dynamic object to the dynamic `ObjGroup` `name`. */ void d_addto_group(DynObjName name) { - UNUSED u32 pad; + UNUSED u8 filler[4]; struct DynObjInfo *info = get_dynobj_info(name); struct ObjGroup *targetGrp; @@ -1448,9 +1446,9 @@ void d_use_integer_names(s32 isIntBool) { * to `(x, y, z)`. */ void d_set_init_pos(f32 x, f32 y, f32 z) { - UNUSED u32 pad2c[3]; + UNUSED u8 filler1[12]; struct GdObj *dynobj = sDynListCurObj; // sp28 - UNUSED u32 pad[1]; + UNUSED u8 filler2[4]; if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); @@ -1907,7 +1905,7 @@ void d_set_att_offset(const struct GdVec3f *off) { */ void d_set_att_to_offset(UNUSED u32 a) { struct GdObj *dynobj; // sp3c - UNUSED u8 pad[24]; + UNUSED u8 filler[24]; if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); @@ -2246,7 +2244,7 @@ void d_set_scale(f32 x, f32 y, f32 z) { */ void d_set_rotation(f32 x, f32 y, f32 z) { struct GdObj *dynobj; // sp2C - UNUSED u32 pad; + UNUSED u8 filler[4]; if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); diff --git a/src/goddard/gd_main.c b/src/goddard/gd_main.c index 225eb319..77f7c0d5 100644 --- a/src/goddard/gd_main.c +++ b/src/goddard/gd_main.c @@ -28,7 +28,7 @@ struct GdControl gGdCtrlPrev; // @ 801B9A18; previous frame's controller info * Unused main function possibly from when this was a standalone demo */ u32 __main__(void) { - UNUSED u32 pad1C; + UNUSED u8 filler[4]; gd_printf("%x, %x\n", (u32) (uintptr_t) &D_801A8058, (u32) (uintptr_t) &gGdMoveScene); imin("main"); diff --git a/src/goddard/gd_main.h b/src/goddard/gd_main.h index 2fa0c3ec..58226ad3 100644 --- a/src/goddard/gd_main.h +++ b/src/goddard/gd_main.h @@ -23,7 +23,7 @@ // structs struct GdControl { // gGdCtrl /* 0x00 */ s32 unk00; // set but never used - /* 0x04 */ u8 pad04[4]; + /* 0x04 */ u8 filler1[4]; /* 0x08 */ s32 dleft; // Dpad-left (mask) /* 0x0C */ s32 dright; // Dpad-right (mask) /* 0x10 */ s32 dup; // Dpad-up (mask) @@ -37,22 +37,22 @@ struct GdControl { // gGdCtrl /* 0x30 */ void * unk30; // null-checked ptr? symbol not deref-ed in extant code? /* 0x34 */ s32 btnA; // bool A button /* 0x38 */ s32 btnB; // bool B button - /* 0x3C */ u8 pad3C[0x44-0x3C]; + /* 0x3C */ u8 filler2[8]; /* 0x44 */ s32 trgL; // bool L trigger pressed /* 0x48 */ s32 trgR; // bool R trigger pressed /* 0x4C */ s32 unk4C; /* 0x50 */ s32 unk50; /* 0x54 */ s32 newStartPress; // toggle bit? start pressed? - /* 0x58 */ u8 pad58[0x7C-0x58]; + /* 0x58 */ u8 filler3[36]; /* 0x7C */ f32 stickXf; /* 0x80 */ f32 stickYf; - /* 0x84 */ u8 pad84[4]; + /* 0x84 */ u8 filler4[4]; /* 0x88 */ f32 unk88; // set but never used - /* 0x8C */ u8 pad8c[0xA0-0x8C]; + /* 0x8C */ u8 filler5[20]; /* 0xA0 */ f32 unkA0; // set but never used - /* 0xA4 */ u8 padA4[0xAC-0xA4]; + /* 0xA4 */ u8 filler6[8]; /* 0xAC */ f32 unkAC; - /* 0xB0 */ u8 padB0[0xB8-0xB0]; + /* 0xB0 */ u8 filler7[8]; /* 0xB8 */ s32 dragStartX; // cursor x position when there was a new (A) press? /* 0xBC */ s32 dragStartY; // cursor y position when there was a new (A) press? /* 0xC0 */ s32 stickDeltaX; @@ -70,9 +70,9 @@ struct GdControl { // gGdCtrl /* b04 */ u8 unkD8b04 : 1; /* b02 */ u8 AbtnPressWait : 1; // bool 10 frames between (A) presses (cursor cool down?) /* 0xDC */ u32 dragStartFrame; // first frame of new a press - /* 0xE0 */ u8 padE0[0xE8-0xE0]; + /* 0xE0 */ u8 filler8[8]; /* 0xE8 */ u32 currFrame; // frame count? - /* 0xEC */ u8 padEC[0xF0-0xEC]; + /* 0xEC */ u8 filler9[4]; /* 0xF0 */ struct GdControl *prevFrame; // previous frame data }; diff --git a/src/goddard/gd_math.c b/src/goddard/gd_math.c index bc155f6c..baf43dd8 100644 --- a/src/goddard/gd_math.c +++ b/src/goddard/gd_math.c @@ -397,8 +397,7 @@ void gd_inverse_mat4f(Mat4f *src, Mat4f *dst) { gd_adjunct_mat4f(src, dst); determinant = gd_mat4f_det(dst); - if (ABS(determinant) < 1e-5) //? 1e-5f - { + if (ABS(determinant) < 1e-5) { //? 1e-5f fatal_print("Non-singular matrix, no inverse!\n"); } @@ -602,7 +601,7 @@ void UNUSED gd_quat_rotation(f32 quat[4], UNUSED s32 unused, f32 c, f32 s, s32 i s32 j; s32 k; f32 quatVal; - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; if ((j = i + 1) >= 4) { j = 1; @@ -876,7 +875,7 @@ void gd_mult_mat4f(const Mat4f *mA, const Mat4f *mB, Mat4f *dst) { * Printed the prefix at some point, as shown by how the function is used. */ void gd_print_vec(UNUSED const char *prefix, const struct GdVec3f *vec) { - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; printf("%f,%f,%f\n", vec->x, vec->y, vec->z); printf("\n"); @@ -888,7 +887,7 @@ void gd_print_vec(UNUSED const char *prefix, const struct GdVec3f *vec) { * Printed a prefix at some point, as shone by how the function is used. */ void gd_print_bounding_box(UNUSED const char *prefix, UNUSED const struct GdBoundingBox *p) { - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; printf("Min X = %f, Max X = %f \n", p->minX, p->maxX); printf("Min Y = %f, Max Y = %f \n", p->minY, p->maxY); diff --git a/src/goddard/gd_types.h b/src/goddard/gd_types.h index a0213d44..cff1fff6 100644 --- a/src/goddard/gd_types.h +++ b/src/goddard/gd_types.h @@ -4,8 +4,7 @@ #include /* Vector Types */ -struct GdVec3f -{ +struct GdVec3f { f32 x, y, z; }; @@ -78,11 +77,11 @@ enum ObjTypeFlag { typedef void (*drawmethod_t)(void *); /// Flags for the drawFlags field of an GdObj enum ObjDrawingFlags { - OBJ_DRAW_UNK01 = 0x01, - OBJ_INVISIBLE = 0x02, ///< This `GdObj` shouldn't be drawn when updating a scene - OBJ_PICKED = 0x04, ///< This `GdObj` is held by the cursor - OBJ_IS_GRABBALE = 0x08, ///< This `GdObj` can be grabbed/picked by the cursor - OBJ_HIGHLIGHTED = 0x10 + OBJ_DRAW_UNK01 = 0x01, + OBJ_INVISIBLE = 0x02, ///< This `GdObj` shouldn't be drawn when updating a scene + OBJ_PICKED = 0x04, ///< This `GdObj` is held by the cursor + OBJ_IS_GRABBABLE = 0x08, ///< This `GdObj` can be grabbed/picked by the cursor + OBJ_HIGHLIGHTED = 0x10 }; /** @@ -160,9 +159,9 @@ struct ObjBone { /* 0x020 */ struct ObjBone *prev; // maybe, based on make_bone /* 0x024 */ struct ObjBone *next; // maybe, based on make_bone /* 0x028 */ struct GdVec3f unk28; // "rotation"?? from dead code in draw_bone - /* 0x034 */ u8 pad34[0x40-0x34]; + /* 0x034 */ u8 filler1[12]; /* 0x040 */ struct GdVec3f unk40; - /* 0x04C */ u8 pad4C[0x58-0x4C]; + /* 0x04C */ u8 filler2[12]; /* 0x058 */ struct GdVec3f unk58; // orientation? /* 0x064 */ struct GdVec3f unk64; /* 0x070 */ Mat4f mat70; @@ -178,7 +177,7 @@ struct ObjBone { /* 0x110 */ f32 spring; /* 0x114 */ f32 unk114; /* 0x118 */ f32 unk118; - /* 0x11C */ u8 pad11C[0x124-0x11C]; + /* 0x11C */ u8 filler3[8]; }; /* sizeof = 0x124 */ struct ObjJoint { @@ -192,7 +191,7 @@ struct ObjJoint { /* 0x03C */ struct GdVec3f unk3C; // relative position? /* 0x048 */ struct GdVec3f unk48; /* 0x054 */ struct GdVec3f initPos; // attached offset? (with +200 as well) - /* 0x060 */ u8 pad60[0x6C-0x60]; + /* 0x060 */ u8 filler1[12]; /* 0x06C */ struct GdVec3f unk6C; // initial rotation vec /* 0x078 */ struct GdVec3f velocity; /* 0x084 */ struct GdVec3f unk84; @@ -202,27 +201,27 @@ struct ObjJoint { /* 0x0B4 */ struct GdVec3f unkB4; /* 0x0C0 */ struct GdVec3f shapeOffset; /* 0x0CC */ struct GdVec3f unkCC; - /* 0x0D8 */ u8 padD8[4]; + /* 0x0D8 */ u8 filler2[4]; /* 0x0DC */ struct GdVec3f friction; /* 0x0E8 */ Mat4f matE8; //matrix4x4 /* 0x128 */ Mat4f mat128; // "rot matrix" /* 0x168 */ Mat4f mat168; // "id matrix" /* 0x1A8 */ struct GdVec3f unk1A8; /* 0x1B4 */ s32 id; - /* 0x1B8 */ u8 pad1B8[4]; + /* 0x1B8 */ u8 filler3[4]; /* 0x1BC */ s32 flags; // "flags" - 0x2000 = grabbed /* 0x1C0 */ s32 unk1C0; /* 0x1C4 */ struct ObjGroup *unk1C4; // bone group? /* 0x1C8 */ s32 colourNum; /* 0x1CC */ s32 type; // 0 = normal joint, 5 = grabbable joint. seems to be set, but never used /* 0x1D0 */ struct ObjAnimator *rootAnimator; // root animator? used by eye_joint_update_func - /* 0x1D4 */ u8 pad1D4[0x1f4-0x1d4]; + /* 0x1D4 */ u8 filler4[32]; /* 0x1F4 */ struct ObjGroup *weightGrp; //Group of ObjWeights, only? skin weights? /* 0x1F8 */ struct ObjGroup *attachedObjsGrp; //attach object group /* 0x1FC */ s32 attachFlags; //d_attach_to arg 0; "AttFlag" /* 0x200 */ struct GdVec3f attachOffset; /* 0x20C */ struct GdObj *attachedToObj; // object that this object is attached to - /* 0x210 */ u8 pad210[0x228-0x210]; + /* 0x210 */ u8 filler5[24]; /* 0x228 */ f32 unk228; }; /* sizeof = 0x22C */ @@ -232,30 +231,30 @@ struct ObjJoint { struct ObjParticle { /* 0x00 */ struct GdObj header; - /* 0x14 */ u8 pad14[0x1C-0x14]; + /* 0x14 */ u8 filler1[8]; /* 0x1C */ struct ObjShape *shapePtr; // looks like a shape... /* 0x20 */ struct GdVec3f pos; // some kind of position - relative? world? - /* 0x2C */ u8 pad2C[0x30-0x2C]; + /* 0x2C */ u8 filler2[4]; /* 0x30 */ f32 unk30; - /* 0x34 */ u8 pad34[0x38-0x34]; + /* 0x34 */ u8 filler3[4]; /* 0x38 */ struct GdVec3f unk38; /* 0x44 */ f32 unk44; //not vec? /* 0x48 */ f32 unk48; //not vec? - /* 0x4C */ u8 pad4C[0x50-0x4C]; + /* 0x4C */ u8 filler4[4]; /* 0x50 */ s32 id; /* 0x54 */ u32 flags; // "dflags"? /* 0x58 */ s32 colourNum; /* 0x5C */ s32 timeout; // when this reaches zero, the particle disappears /* 0x60 */ s32 unk60; //type? /* 0x64 */ s32 unk64; //type? (1 = has 50 sub-particles, 2,3 = has 30 sub-particles - /* 0x68 */ u8 pad68[0x6C-0x68]; + /* 0x68 */ u8 filler5[4]; /* 0x6C */ struct ObjGroup *subParticlesGrp; // group of other Particles ? - /* 0x70 */ u8 pad70[4]; + /* 0x70 */ u8 filler6[4]; /* 0x74 */ s32 unk74; /* 0x78 */ u8 unk78[4]; /* 0x7C */ struct ObjAnimator *unk7C; // guessing on type; doesn't seem to be used in final code /* 0x80 */ struct ObjLight *unk80; // could be a Net or Light; not seen as non-null in running code - /* 0x84 */ u8 pad84[0xB0-0x84]; + /* 0x84 */ u8 filler7[44]; /* 0xB0 */ s32 unkB0; //state? /* 0xB4 */ struct ObjGroup *attachedObjsGrp; // attach group? unused group of particles /* 0xB8 */ s32 attachFlags; //attached arg0; "AttFlag" @@ -272,7 +271,7 @@ struct ObjShape { /* 0x1C */ struct ObjGroup *faceGroup; /* face group; based on get_3DG1_shape */ /* 0x20 */ struct ObjGroup *vtxGroup; /* vtx group; based on get_3DG1_shape */ /* 0x24 */ struct ObjGroup *scaledVtxGroup; /* group for type 2 shapenets only ? vertices whose scaleFactor is not 1 get put into this group. */ - /* 0x28 */ u8 pad28[4]; + /* 0x28 */ u8 filler1[4]; /* 0x2C */ struct ObjGroup *mtlGroup; /* what does this group do? materials? */ /* 0x30 */ s32 unk30; /* 0x34 */ s32 faceCount; /* face count? based on get_3DG1_shape */ @@ -282,7 +281,7 @@ struct ObjShape { /* 0x44 */ s32 flag; // what are the flag values? only from dynlists? /* 0x48 */ s32 dlNums[2]; // gd dl number for each frame buffer (??) [0, 1] s32 unk50; // frame number (index into dlNums)? - /* 0x54 */ u8 pad54[0x58-0x54]; // part of above array?? + /* 0x54 */ u8 filler2[4]; // part of above array?? /* 0x58 */ f32 alpha; // paramF? opacitiy? something with rendertype /* 0x5C */ char name[0x40]; }; /* sizeof = 0x9C */ @@ -307,7 +306,7 @@ struct ObjNet { /* 0x000 */ struct GdObj header; /* 0x014 */ struct GdVec3f worldPos; // position? d_set_initpos + d_set_world_pos; print_net says world /* 0x020 */ struct GdVec3f initPos; // position? d_set_initpos? attached offset? dynamic? scratch? - /* 0x02C */ u8 pad2c[0x34-0x2C]; + /* 0x02C */ u8 filler1[8]; /* 0x034 */ s32 flags; // "dflags"? /* 0x038 */ u32 id; // some sort of id? from move_net /* 0x03C */ s32 unk3C; // state flags? vertex info flags? @@ -348,7 +347,7 @@ struct ObjNet { /* 0x200 */ struct GdVec3f unk200; /* 0x20C */ struct ObjGroup *unk20C; /* 0x210 */ s32 ctrlType; // has no purpose - /* 0x214 */ u8 pad214[0x21C-0x214]; + /* 0x214 */ u8 filler2[8]; /* 0x21C */ struct ObjGroup *unk21C; }; /* sizeof = 0x220 */ @@ -402,7 +401,7 @@ struct ObjCamera { /* 0x040 */ struct GdVec3f unk40; // relative position related? /* 0x04C */ struct GdVec3f unk4C; /* 0x058 */ f32 unk58; // GdVec3f ? - /* 0x05C */ u8 pad5C[0x4]; + /* 0x05C */ u8 filler[4]; /* 0x060 */ f32 unk60; /* 0x064 */ Mat4f unk64; //matrix4x4 /* 0x0A4 */ f32 unkA4; @@ -429,24 +428,24 @@ enum GdMtlTypes { struct ObjMaterial { /* 0x00 */ struct GdObj header; - /* 0x14 */ u8 pad14[0x1c-0x14]; + /* 0x14 */ u8 filler1[8]; /* 0x1C */ s32 id; /* 0x20 */ char name[8]; /* 0x28 */ s32 type; - /* 0x2C */ u8 pad2C[4]; + /* 0x2C */ u8 filler2[4]; /* 0x30 */ struct GdColour Ka; // ambient color /* 0x3C */ struct GdColour Kd; // diffuse color - /* 0x48 */ u8 pad48[0x58-0x48]; + /* 0x48 */ u8 filler3[16]; /* 0x58 */ void *texture; //set by d_usetexture; never seems to be non-null though. /* 0x5C */ s32 gddlNumber; }; /* sizeof = 0x60 */ struct ObjWeight { /* 0x00 */ struct GdObj header; - /* 0x14 */ u8 pad14[0x8]; + /* 0x14 */ u8 filler1[8]; /* 0x1C */ s32 vtxId; // ID of vertex that this weight applies to /* 0x20 */ struct GdVec3f vec20; // based on func_80181894? maybe a GdBoundingBox? - /* 0x2C */ u8 pad2C[0x38-0x2c]; + /* 0x2C */ u8 filler2[12]; /* 0x38 */ f32 weightVal; // weight (unit?) /* 0x3C */ struct ObjVertex* vtx; }; /* sizeof = 0x40 */ @@ -468,7 +467,7 @@ struct ObjGadget { /* 0x20 */ s32 unk20; // unused; only ever set to 0 /* 0x24 */ s32 type; /* 0x28 */ f32 sliderPos; // position of the slider (from 0 to 1) - /* 0x2C */ u8 pad2C[4]; + /* 0x2C */ u8 filler1[4]; /* 0x30 */ union ObjVarVal varval; //retype and rename varval30 /* 0x38 */ f32 rangeMin; /* 0x3C */ f32 rangeMax; @@ -476,7 +475,7 @@ struct ObjGadget { /* 0x4C */ struct ObjGroup *valueGrp; // group containing `ObjValPtr`s controlled by this gadget /* 0x50 */ struct ObjShape *shapePtr; /* 0x54 */ struct ObjGroup *unk54; //node group? - /* 0x58 */ u8 pad58[4]; + /* 0x58 */ u8 filler2[4]; /* 0x5C */ s32 colourNum; }; /* sizeof = 0x60 */ @@ -501,7 +500,7 @@ enum GdViewFlags { struct ObjView { /* 0x00 */ struct GdObj header; - /* 0x14 */ u8 pad14[0x8]; + /* 0x14 */ u8 filler1[8]; /* 0x1C */ s32 unk1C; // set as nonexistent return of `setup_view_buffers` /* 0x20 */ s32 id; /* 0x24 */ struct ObjCamera *activeCam; // is this really active? @@ -513,7 +512,7 @@ struct ObjView { /* 0x3C */ struct GdVec3f upperLeft; // position vec? /* 0x48 */ f32 unk48; // what are these? are they another vec? /* 0x4C */ f32 unk4C; - /* 0x50 */ u8 pad50[0x4]; + /* 0x50 */ u8 filler2[4]; /* 0x54 */ struct GdVec3f lowerRight; /* 0x60 */ struct GdVec3f clipping; // z-coordinate of (x: near, y: far) clipping plane? /* 0x6C */ const char *namePtr; @@ -549,14 +548,14 @@ struct ObjAnimator { /* 0x00 */ struct GdObj header; /* 0x14 */ struct ObjGroup* animatedPartsGrp; // group containing objects animated by this animator. I think all of them are joints. /* 0x18 */ struct ObjGroup* animdataGrp; //animation data? a group, but the link points to something weird.. - /* 0x1C */ u8 pad1C[0x4]; + /* 0x1C */ u8 filler1[4]; /* 0x20 */ s32 animSeqNum; // which entry in the AnimDataInfo array to use /* 0x24 */ f32 unk24; /* 0x28 */ f32 frame; // key frame number. This is a float so that it can interpolate between key frames, though I think in practice, it's always a whole number. - /* 0x2C */ u8 pad2C[4]; + /* 0x2C */ u8 filler2[4]; /* 0x30 */ struct ObjGroup *attachedObjsGrp; /* 0x34 */ s32 attachFlags; //attach arg0, not used - /* 0x38 */ u8 pad38[0x44-0x38]; + /* 0x38 */ u8 filler3[12]; /* 0x44 */ struct GdObj* attachedToObj; // object that this object is attached to. Normally another Objanimator? /* 0x48 */ void (*controlFunc) (struct ObjAnimator *); // function that "controls" the animation sequence by choosing the frame number /* 0x4C */ s32 state; //state enum? @@ -616,17 +615,17 @@ enum GdLightFlags { struct ObjLight { /* 0x00 */ struct GdObj header; - /* 0x14 */ u8 pad0[0x8]; + /* 0x14 */ u8 filler1[8]; /* 0x1C */ s32 id; /* 0x20 */ char name[8]; - /* 0x28 */ u8 pad28[4]; + /* 0x28 */ u8 filler2[4]; /* 0x2C */ s32 flags; /* 0x30 */ f32 unk30; // color (5C) = Kd (50) * 30 - /* 0x34 */ u8 pad34[4]; + /* 0x34 */ u8 filler3[4]; /* 0x38 */ f32 unk38; // calculated diffuse theta (in degrees?) /* 0x3C */ s32 unk3C; /* 0x40 */ s32 unk40; - /* 0x44 */ u8 pad3[0x8]; + /* 0x44 */ u8 filler4[8]; /* 0x4C */ s32 unk4C; /* 0x50 */ struct GdColour diffuse; /* 0x5C */ struct GdColour colour; @@ -643,12 +642,12 @@ struct ObjZone { /* 0x14 */ struct GdBoundingBox boundingBox; /* 0x2C */ struct ObjGroup *unk2C; // plane group? /* 0x30 */ struct ObjGroup *unk30; // guess based on Unknown801781DC; might have to change later - /* 0x34 */ u8 pad[4]; + /* 0x34 */ u8 filler[4]; }; /* sizeof = 0x38*/ struct ObjUnk200000 { /* 0x00 */ struct GdObj header; - /* 0x14 */ u8 pad14[0x30-0x14]; + /* 0x14 */ u8 filler[28]; /* 0x30 */ struct ObjVertex *unk30; //not sure; guessing for Unknown801781DC; 30 and 34 could switch with ObjZone /* 0x34 */ struct ObjFace *unk34; //not sure; guessing for Unknown801781DC }; /* sizeof = 0x38*/ diff --git a/src/goddard/joints.c b/src/goddard/joints.c index e48eea27..00178efb 100644 --- a/src/goddard/joints.c +++ b/src/goddard/joints.c @@ -47,13 +47,13 @@ void set_joint_vecs(struct ObjJoint *, f32, f32, f32); * Controls movement of grabbable joints */ void grabbable_joint_update_func(struct ObjJoint *self) { - UNUSED u8 pad78[0xC8 - 0x78]; + UNUSED u8 filler1[80]; Mat4f *attObjMtx; - UNUSED u8 pad70[4]; + UNUSED u8 filler2[4]; struct GdVec3f offset; // difference between current position and initial position - UNUSED u8 pad50[0x10]; + UNUSED u8 filler3[16]; register struct ListNode *att; - UNUSED u8 pad48[0x8]; + UNUSED u8 filler4[8]; struct GdObj *attobj; // The joint acts somewhat like a spring in that the further it is moved @@ -71,8 +71,7 @@ void grabbable_joint_update_func(struct ObjJoint *self) { self->flags |= 0x2000; ; // needed to match } else { - if (gGdCtrl.trgR == FALSE) // R trigger is released - { + if (gGdCtrl.trgR == FALSE) { // R trigger is released // Set velocity so that the joint approaches its initial position self->velocity.x -= offset.x * 0.5; //? 0.5f self->velocity.y -= offset.y * 0.5; //? 0.5f @@ -85,10 +84,8 @@ void grabbable_joint_update_func(struct ObjJoint *self) { // If the joint's velocity has decayed enough and it is very close // to its original position, stop its movement altogether - if (ABS(self->velocity.x) + ABS(self->velocity.y) + ABS(self->velocity.z) < 1.0) - { - if (ABS(offset.x) + ABS(offset.y) + ABS(offset.z) < 1.0) - { + if (ABS(self->velocity.x) + ABS(self->velocity.y) + ABS(self->velocity.z) < 1.0) { + if (ABS(offset.x) + ABS(offset.y) + ABS(offset.z) < 1.0) { self->velocity.x = self->velocity.y = self->velocity.z = 0.0f; self->mat128[3][0] -= offset.x; self->mat128[3][1] -= offset.y; @@ -137,7 +134,7 @@ void eye_joint_update_func(struct ObjJoint *self) { Mat4f *sp5C; struct GdVec3f sp50; struct GdVec3f sp44; - UNUSED u8 pad2c[0x18]; + UNUSED u8 filler[24]; register struct ListNode *att; struct GdObj *attobj; @@ -230,7 +227,7 @@ void set_joint_vecs(struct ObjJoint *j, f32 x, f32 y, f32 z) { struct ObjJoint *make_joint(s32 flags, f32 x, f32 y, f32 z) { struct ObjJoint *j; // sp24 struct ObjJoint *oldhead; - UNUSED u32 pad1C; + UNUSED u8 filler[4]; j = (struct ObjJoint *) make_object(OBJ_TYPE_JOINTS); sJointCount++; @@ -284,7 +281,7 @@ struct ObjJoint *make_grabber_joint(struct ObjShape *shape, s32 flags, f32 x, f3 j->type = 5; j->flags |= flags; j->colourNum = COLOUR_PINK; - j->header.drawFlags |= OBJ_IS_GRABBALE; + j->header.drawFlags |= OBJ_IS_GRABBABLE; j->header.drawFlags |= OBJ_INVISIBLE; j->updateFunc = grabbable_joint_update_func; j->rootAnimator = NULL; @@ -331,7 +328,7 @@ void func_8018F4CC(struct ObjJoint *j) { void func_8018F520(struct ObjBone *b) { struct ObjJoint *joint1; struct ObjJoint *joint2; - UNUSED u32 pad[3]; + UNUSED u8 filler[12]; struct GdVec3f sp90; struct GdVec3f sp84; struct GdVec3f sp78; @@ -397,7 +394,7 @@ void func_8018F520(struct ObjBone *b) { void func_8018F89C(struct ObjBone *b) { struct ObjJoint *spAC; struct ObjJoint *spA8; - UNUSED u8 pad64[0x44]; + UNUSED u8 filler[68]; struct ObjGroup *grp; // sp60 struct ListNode *link; // sp5c Mat4f mtx; // sp1c @@ -494,7 +491,7 @@ void add_joint2bone(struct ObjBone *b, struct ObjJoint *j) { struct ObjBone *make_bone(s32 a0, struct ObjJoint *j1, struct ObjJoint *j2, UNUSED s32 a3) { struct ObjBone *b; // sp34 struct ObjBone *oldhead; - UNUSED u32 pad1C[5]; + UNUSED u8 filler[20]; b = (struct ObjBone *) make_object(OBJ_TYPE_BONES); sBoneCount++; @@ -596,11 +593,11 @@ s32 func_8018FFE8(struct ObjBone **a0, struct ObjJoint **a1, struct ObjJoint *a2 void func_80190168(struct ObjBone *b, UNUSED struct ObjJoint *a1, UNUSED struct ObjJoint *a2, struct GdVec3f *a3) { struct GdVec3f sp7C; - UNUSED u8 pad64[0x7c - 0x64]; + UNUSED u8 filler1[24]; f32 sp60; f32 sp5C; f32 sp58; - UNUSED u8 pad1C[0x58 - 0x1C]; + UNUSED u8 filler2[60]; return; @@ -672,21 +669,20 @@ void func_801903E8(struct ObjJoint *j, struct GdVec3f *a1, f32 x, f32 y, f32 z) } /* 23EBB8 -> 23F184 */ -void func_80190574(s32 a0, struct ObjJoint *a1, struct ObjJoint *a2, f32 x, f32 y, f32 z) // sp278 -{ +void func_80190574(s32 a0, struct ObjJoint *a1, struct ObjJoint *a2, f32 x, f32 y, f32 z) { // sp278 struct ObjJoint *sp274; // = a2? struct ObjJoint *sp270; // mid-point of stack array? struct ObjJoint *sp26C; // jointstackarr[i]? curjoint? - UNUSED u32 pad268; - UNUSED u32 sp264 = 0; - UNUSED u32 sp258[3]; // unused vec? + UNUSED u8 filler1[4]; + UNUSED u32 unused = 0; + UNUSED u8 filler2[12]; // unused vec? struct GdVec3f sp24C; struct GdVec3f sp240; - UNUSED u32 pad238[2]; + UNUSED u8 filler3[8]; s32 sp234; // i? s32 sp230; s32 sp22C = 1; - UNUSED u32 pad228; + UNUSED u8 filler4[4]; s32 sp224; s32 sp220; struct ObjJoint *sp120[0x40]; @@ -788,7 +784,7 @@ void func_801909B4(void) { /* 23F1F0 -> 23F324; not called */ void func_80190A20(void) { struct ObjJoint *j; // sp3c - UNUSED u32 pad38; + UNUSED u8 filler[4]; struct GdVec3f vec; // sp2C struct ObjGroup *grp; struct ListNode *link; @@ -812,16 +808,15 @@ void func_80190A20(void) { } /* 23F324 -> 23F638 */ -void func_80190B54(struct ObjJoint *a0, struct ObjJoint *a1, struct GdVec3f *a2) // b0 -{ +void func_80190B54(struct ObjJoint *a0, struct ObjJoint *a1, struct GdVec3f *a2) { // b0 struct GdVec3f spA4; - UNUSED struct GdVec3f pad98; + UNUSED u8 filler1[12]; struct GdVec3f sp8C; struct GdVec3f sp80; f32 sp7C; f32 sp78; Mat4f sp38; - UNUSED u8 pad1C[0x1C]; + UNUSED u8 filler2[28]; if (a1 != NULL) { spA4.x = a1->unk3C.x; @@ -878,7 +873,7 @@ void func_80190E68(struct GdObj *obj, f32 x, f32 y, f32 z) { struct ObjJoint *sp44; struct GdObj *sp40; struct GdVec3f vec; - UNUSED u32 pad1C[6]; + UNUSED u8 filler[24]; vec.x = x; vec.y = y; @@ -968,7 +963,7 @@ void func_80191220(struct ObjJoint *j) { /* 23FB90 -> 23FBC0 */ void func_801913C0(struct ObjJoint *j) { - UNUSED u32 pad[4]; + UNUSED u8 filler[16]; func_80181894(j); } @@ -1040,7 +1035,7 @@ void reset_joint(struct ObjJoint *j) { /* 23FFF4 -> 2400C4 */ void func_80191824(struct ObjJoint *j) { UNUSED struct ObjNet *sp14; - UNUSED u32 pad00[4]; + UNUSED u8 filler[16]; sp14 = gGdSkinNet->unk1F0; if (j->flags & 0x1) { diff --git a/src/goddard/objects.c b/src/goddard/objects.c index f8504b1a..b1d136cd 100644 --- a/src/goddard/objects.c +++ b/src/goddard/objects.c @@ -23,11 +23,11 @@ // structs struct Unk801B9E68 { /* 0x00 */ s32 count; - /* 0x04 */ u8 pad[0x14]; + /* 0x04 */ u8 filler[20]; }; /* sizeof() = 0x18 */ struct Unk8017F3CC { - /*0x00*/ u8 pad[0x20]; + /*0x00*/ u8 filler[32]; /*0x20*/ struct GdVec3f unk20; }; @@ -434,9 +434,7 @@ void reset_plane(struct ObjPlane *plane) { struct ObjFace *sp4C; f32 sp48; f32 sp44; - UNUSED u32 sp40; - UNUSED u32 sp3C; - UNUSED u32 sp38; + UNUSED u8 filler[12]; s32 i; s32 sp30; register f32 sp28; @@ -513,7 +511,7 @@ void reset_plane(struct ObjPlane *plane) { /* @ 22B60C for 0x94; orig name: func_8017CE3C */ struct ObjPlane *make_plane(s32 inZone, struct ObjFace *a1) { - UNUSED u32 pad1C; + UNUSED u8 filler[4]; struct ObjPlane *newPlane = (struct ObjPlane *) make_object(OBJ_TYPE_PLANES); gGdPlaneCount++; @@ -754,11 +752,9 @@ void format_object_id(char *str, struct GdObj *obj) { struct ObjGroup *make_group(s32 count, ...) { va_list args; s32 i; - UNUSED u32 sp5C; + UNUSED u8 filler1[4]; struct GdObj *curObj; - UNUSED u32 sp54; - UNUSED u32 sp50; - UNUSED u32 sp4C; + UNUSED u8 filler2[12]; struct ObjGroup *newGroup; struct ObjGroup *oldGroupListHead; struct GdObj *vargObj; @@ -818,7 +814,7 @@ struct ObjGroup *make_group(s32 count, ...) { */ void addto_group(struct ObjGroup *group, struct GdObj *obj) { char strbuf[0x20]; - UNUSED u8 pad[0x8]; + UNUSED u8 filler[8]; imin("addto_group"); @@ -1031,7 +1027,7 @@ void menu_cb_reset_positions(void) { * Unused (not called) - does nothing useful */ struct GdObj *func_8017E2F0(struct GdObj *obj, enum ObjTypeFlag type) { - UNUSED u32 sp2C; + UNUSED u8 filler[4]; enum ObjTypeFlag curObjType; struct ListNode *node; @@ -1071,7 +1067,7 @@ s32 apply_to_obj_types_in_group(s32 types, applyproc_t func, struct ObjGroup *gr struct GdObj *linkedObj; enum ObjTypeFlag linkedObjType; applyproc_t objFn; - UNUSED u8 pad2C[0x20]; + UNUSED u8 filler[32]; s32 fnAppliedCount; fnAppliedCount = 0; @@ -1122,9 +1118,9 @@ void func_8017E584(struct ObjNet *a0, struct GdVec3f *a1, struct GdVec3f *a2) { struct GdVec3f sp88; struct GdVec3f sp7C; struct GdVec3f sp70; - UNUSED u8 pad30[0x40]; // unused MyMatrix4x4? f32[4][4] + UNUSED u8 filler1[64]; // unused MyMatrix4x4? f32[4][4] f32 sp2C; - UNUSED u32 sp28; + UNUSED u8 filler2[4]; struct GdVec3f sp1C; sp70.x = a2->x; @@ -1174,12 +1170,10 @@ void func_8017E584(struct ObjNet *a0, struct GdVec3f *a1, struct GdVec3f *a2) { /* @ 22D008 for 0x1B4 */ void func_8017E838(struct ObjNet *a0, struct GdVec3f *a1, struct GdVec3f *a2) { - UNUSED u32 sp84; - UNUSED u32 sp80; - UNUSED u32 sp7C; + UNUSED u8 filler1[12]; struct GdVec3f sp70; struct GdVec3f sp64; - UNUSED u8 pad24[0x40]; + UNUSED u8 filler2[64]; struct GdVec3f sp18; sp64.x = a1->x; @@ -1374,13 +1368,13 @@ s32 gd_plane_point_within(struct GdBoundingBox *box1, struct GdBoundingBox *box2 s32 transform_child_objects_recursive(struct GdObj *obj, struct GdObj *parentObj) { struct ListNode *curLink; struct ObjGroup *curGroup; - UNUSED u32 sp54; + UNUSED u8 filler1[4]; Mat4f *parentUnkMtx; Mat4f *iMtx; Mat4f *unkMtx; Mat4f *rotMtx; Mat4f *rotMtx2; - UNUSED u8 pad20[0x18]; + UNUSED u8 filler2[24]; struct GdVec3f scale; if (parentObj != NULL) { @@ -1428,13 +1422,13 @@ s32 transform_child_objects_recursive(struct GdObj *obj, struct GdObj *parentObj s32 func_8017F210(struct GdObj *a0, struct GdObj *a1) { struct ListNode *sp6C; struct ObjGroup *sp68; - UNUSED u32 sp64; + UNUSED u8 filler1[4]; UNUSED Mat4f *sp60; Mat4f *sp5C; UNUSED Mat4f *sp58; Mat4f *sp54; Mat4f *sp50; - UNUSED u8 pad38[0x18]; + UNUSED u8 filler2[24]; struct GdVec3f sp2C; s32 count = 0; @@ -1483,7 +1477,7 @@ void func_8017F3CC(struct Unk8017F3CC *a0) { /* @ 22DBD4 for 0x20 */ void stub_objects_3(UNUSED f32 a0, UNUSED struct GdObj *a1, UNUSED struct GdObj *a2) { - UNUSED u8 pad[0x30]; + UNUSED u8 filler[48]; } /** @@ -1536,9 +1530,7 @@ void move_animator(struct ObjAnimator *animObj) { s16(*animDataCam)[6]; // camera GdPlaneH[]? struct GdObj *stubObj1 = NULL; // used only for call to stubbed function struct GdObj *stubObj2 = NULL; // used only for call to stubbed function - UNUSED s32 sp50; - UNUSED s32 sp4C; - UNUSED s32 sp48; + UNUSED u8 filler[12]; UNUSED struct GdVec3f unusedVec; s32 currKeyFrame; s32 nextKeyFrame; @@ -1771,17 +1763,15 @@ void move_animator(struct ObjAnimator *animObj) { /* @ 22EDF4 for 0x300; orig name: func_80180624 */ void drag_picked_object(struct GdObj *inputObj) { - UNUSED u32 spE4; - UNUSED u32 spE0; - UNUSED u32 spDC; + UNUSED u8 filler1[12]; struct GdVec3f displacement; struct GdVec3f spC4; struct GdControl *ctrl; Mat4f sp80; Mat4f sp40; - UNUSED u32 pad34[3]; + UNUSED u8 filler2[12]; struct GdObj *obj; - UNUSED u32 pad2C; + UNUSED u8 filler3[4]; f32 dispMag; ctrl = &gGdCtrl; @@ -1852,10 +1842,10 @@ void move_camera(struct ObjCamera *cam) { struct GdVec3f spE0; struct GdVec3f spD4; struct GdVec3f spC8; - UNUSED u8 padBC[0xC8 - 0xBC]; + UNUSED u8 filler1[12]; struct GdVec3f spB0; Mat4f sp70; - UNUSED u8 pad30[0x70 - 0x30]; + UNUSED u8 filler2[64]; Mat4f *sp2C; struct GdControl *ctrl; @@ -1975,7 +1965,7 @@ void move_cameras_in_grp(struct ObjGroup *group) { /* @ 22F7DC for 0x36C*/ void func_8018100C(struct ObjLight *light) { Mat4f mtx; - UNUSED u32 pad1C[3]; + UNUSED u8 filler[12]; if (light->unk40 == 3) { if (light->unk30 > 0.0) { //? 0.0f diff --git a/src/goddard/old_menu.c b/src/goddard/old_menu.c index 3587d182..23ce508b 100644 --- a/src/goddard/old_menu.c +++ b/src/goddard/old_menu.c @@ -173,7 +173,7 @@ void set_static_gdgt_value(struct ObjValPtr *vp) { /* 23A488 -> 23A4D0 */ static void reset_gadget_default(struct ObjGadget *gdgt) { - UNUSED u8 pad[4]; + UNUSED u8 filler[4]; sCurGadgetPtr = gdgt; apply_to_obj_types_in_group(OBJ_TYPE_VALPTRS, (applyproc_t) set_static_gdgt_value, gdgt->valueGrp); @@ -181,7 +181,7 @@ static void reset_gadget_default(struct ObjGadget *gdgt) { /* 23A4D0 -> 23A784 */ void adjust_gadget(struct ObjGadget *gdgt, s32 a1, s32 a2) { - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; f32 range; struct ObjValPtr *vp; @@ -220,7 +220,7 @@ void adjust_gadget(struct ObjGadget *gdgt, s32 a1, s32 a2) { /* 23A784 -> 23A940; orig name: Unknown8018BFB4 */ void reset_gadget(struct ObjGadget *gdgt) { - UNUSED u8 pad[8]; + UNUSED u8 filler[8]; f32 range; struct ObjValPtr *vp; diff --git a/src/goddard/particles.c b/src/goddard/particles.c index 64b2d9d0..2fd83b18 100644 --- a/src/goddard/particles.c +++ b/src/goddard/particles.c @@ -19,7 +19,7 @@ typedef union { struct Connection { struct GdObj header; // this header is never used - u8 filler14[8]; + u8 filler[8]; VtxPtc node1; // first connected vertex or particle VtxPtc node2; // second connected vertex or particle f32 unk24; @@ -105,7 +105,7 @@ void Unknown80181D14(struct ObjFace *face) { /* 230680 -> 230858 */ void func_80181EB0(struct Connection *cxn) { struct GdVec3f sp34; - UNUSED u8 unused[0x2C]; + UNUSED u8 filler[44]; struct ObjParticle *sp4 = cxn->node1.ptc; struct ObjParticle *sp0 = cxn->node2.ptc; @@ -134,7 +134,7 @@ void func_80181EB0(struct Connection *cxn) { /* @ 230858 -> 230B70 */ void func_80182088(struct Connection *cxn) { struct GdVec3f sp4C; - UNUSED u8 unused[0x24]; + UNUSED u8 filler[36]; f32 sp24; f32 sp20; struct ObjParticle *sp1C; @@ -208,7 +208,7 @@ void func_801823A0(struct ObjNet *net) { /* 230CC0 -> 230DCC */ struct ObjParticle *make_particle(u32 flags, s32 colourNum, f32 x, f32 y, f32 z) { struct ObjParticle *particle = (struct ObjParticle *) make_object(OBJ_TYPE_PARTICLES); - UNUSED u8 unused[8]; + UNUSED u8 filler[8]; particle->pos.x = x; particle->pos.y = y; @@ -317,13 +317,12 @@ void func_80182A08(struct ObjParticle *ptc, struct GdVec3f *b) { /* 231454 -> 231D40; orig name: Unknown80182C84 */ void move_particle(struct ObjParticle *ptc) { f32 sp7C; - UNUSED u8 unused2[12]; + UNUSED u8 filler1[12]; struct GdVec3f sp64; struct ObjParticle *sp60; - UNUSED u8 unused1[4]; + UNUSED u8 filler2[4]; s32 i; - UNUSED u8 unused4[4]; - UNUSED u8 unused5[4]; + UNUSED u8 filler3[8]; struct ObjCamera *sp4C; struct GdVec3f sp40; struct GdVec3f sp34; diff --git a/src/goddard/renderer.c b/src/goddard/renderer.c index 64e4bb79..75ff7338 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -2,10 +2,6 @@ #include #include -#if defined(VERSION_JP) || defined(VERSION_US) -#include "prevent_bss_reordering.h" -#endif - #include "debug_utils.h" #include "draw_objects.h" #include "dynlist_proc.h" @@ -66,7 +62,7 @@ struct GdDisplayList { /* GD DL Info */ /*0x40*/ u32 id; // user specified /*0x44*/ u32 number; // count - /*0x48*/ u8 pad48[4]; + /*0x48*/ u8 filler[4]; /*0x4C*/ struct GdDisplayList *parent; // not quite sure? }; /* sizeof = 0x50 */ // accessor macros for gd dl @@ -872,14 +868,14 @@ f64 stub_renderer_1(UNUSED f64 x) { /* 249BCC -> 24A19C */ void gd_printf(const char *format, ...) { s32 i; - UNUSED u32 pad158; + UNUSED u8 filler1[4]; char c; char f; - UNUSED u32 pad150; + UNUSED u8 filler2[4]; char buf[0x100]; char *csr = buf; char spec[8]; // specifier string - UNUSED u32 pad40; + UNUSED u8 filler3[4]; union PrintVal val; va_list args; @@ -1053,7 +1049,7 @@ void draw_indexed_dl(s32 dlNum, s32 gfxIdx) { /* 24A598 -> 24A610; orig name: func_8019BDC8 */ void branch_cur_dl_to_num(s32 dlNum) { Gfx *dl; - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; dl = sGdDLArray[dlNum]->gfx; gSPDisplayList(next_gfx(), GD_VIRTUAL_TO_PHYSICAL(dl)); @@ -1152,7 +1148,7 @@ void gd_add_to_heap(void *addr, u32 size) { /* 24AAE0 -> 24AB7C */ void gdm_init(void *blockpool, u32 size) { - UNUSED u32 pad; + UNUSED u8 filler[4]; imin("gdm_init"); // Align downwards? @@ -1172,7 +1168,7 @@ void gdm_init(void *blockpool, u32 size) { * Initializes the Mario head demo */ void gdm_setup(void) { - UNUSED u32 pad; + UNUSED u8 filler[4]; imin("gdm_setup"); sYoshiSceneGrp = NULL; @@ -1213,7 +1209,7 @@ struct ObjView *make_view_withgrp(char *name, struct ObjGroup *grp) { /* 24AD14 -> 24AEB8 */ void gdm_maketestdl(s32 id) { - UNUSED u32 pad[3]; + UNUSED u8 filler[12]; imin("gdm_maketestdl"); switch (id) { @@ -1307,7 +1303,7 @@ s32 gd_sfx_to_play(void) { Gfx *gdm_gettestdl(s32 id) { struct GdObj *dobj; struct GdDisplayList *gddl; - UNUSED u32 pad28[2]; + UNUSED u8 filler[8]; struct GdVec3f vec; start_timer("dlgen"); @@ -1599,7 +1595,7 @@ void gd_dl_set_fill(struct GdColour *colour) { } /* 24CDB4 -> 24CE10; orig name: func_8019E5E4 */ -void gd_dl_set_zbuffer_area(void) { +void gd_dl_set_z_buffer_area(void) { gDPSetDepthImage(next_gfx(), GD_LOWER_24(sActiveView->parent->zbuf)); } @@ -1985,7 +1981,7 @@ void func_801A0038(void) { /* 24E840 -> 24E9BC */ void gd_dl_flush_vertices(void) { - UNUSED u32 pad; + UNUSED u8 filler[4]; s32 i; UNUSED s32 startvtx = sVertexBufStartIndex; @@ -2070,13 +2066,13 @@ void gd_dl_hilite(s32 idx, // material GdDl number; offsets into hilite array struct GdVec3f *arg4, // vector to light source? struct GdColour *colour // light color ) { - UNUSED u32 pad2[24]; + UNUSED u8 filler1[96]; Hilite *hilite; // 4c struct GdVec3f sp40; f32 sp3C; // magnitude of sp40 f32 sp38; f32 sp34; - UNUSED u32 pad[6]; + UNUSED u8 filler2[24]; sp38 = 32.0f; // x scale factor? sp34 = 32.0f; // y scale factor? @@ -2115,7 +2111,7 @@ void gd_dl_hilite(s32 idx, // material GdDl number; offsets into hilite array * Adds some display list commands that perform lighting for a material */ s32 gd_dl_material_lighting(s32 id, struct GdColour *colour, s32 material) { - UNUSED u32 pad60[2]; + UNUSED u8 filler[8]; s32 i; s32 numLights = sNumLights; s32 scaledColours[3]; @@ -2307,7 +2303,7 @@ void Unknown801A1E70(void) { gDPPipeSync(next_gfx()); gDPSetCycleType(next_gfx(), G_CYC_FILL); gDPSetRenderMode(next_gfx(), G_RM_OPA_SURF, G_RM_OPA_SURF2); - gd_dl_set_zbuffer_area(); + gd_dl_set_z_buffer_area(); gDPSetColorImage(next_gfx(), G_IM_FMT_RGBA, G_IM_SIZ_16b, sActiveView->parent->lowerRight.x, GD_LOWER_24(sActiveView->parent->zbuf)); gDPSetFillColor(next_gfx(), GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)); @@ -2326,7 +2322,7 @@ void gd_set_one_cycle(void) { /* 250B30 -> 250B44 */ void stub_renderer_3(void) { - UNUSED u32 pad[4]; + UNUSED u8 filler[16]; } /* 250B44 -> 250B58 */ @@ -2519,8 +2515,7 @@ void stub_renderer_4(f32 arg0) { return; // dead code - if (D_801BD768.x * D_801A86CC.x + arg0 * 2.0f > 160.0) - { + if (D_801BD768.x * D_801A86CC.x + arg0 * 2.0f > 160.0) { func_801A3370(D_801BD758.x - D_801BD768.x, -20.0f, 0.0f); D_801BD768.x = D_801BD758.x; } @@ -2718,11 +2713,11 @@ void gd_create_ortho_matrix(f32 l, f32 r, f32 b, f32 t, f32 n, f32 f) { /* 25245C -> 25262C */ void gd_create_perspective_matrix(f32 fovy, f32 aspect, f32 near, f32 far) { u16 perspNorm; - UNUSED u32 unused1; + UNUSED u8 filler1[4]; uintptr_t perspecMtx; uintptr_t rotMtx; - UNUSED u32 unused2; - UNUSED f32 unusedf = 0.0625f; + UNUSED u8 filler2[4]; + UNUSED f32 unused = 0.0625f; sGdPerspTimer += 0.1; guPerspective(&DL_CURRENT_MTX(sCurrentGdDl), &perspNorm, fovy, aspect, near, far, 1.0f); @@ -2989,9 +2984,9 @@ void stub_renderer_10(UNUSED u32 arg0) { /* 2530A8 -> 2530C0 */ void stub_draw_label_text(UNUSED char *s) { - UNUSED u32 pad2; + UNUSED u8 filler1[4]; UNUSED char *save = s; - UNUSED u8 pad[0x18]; + UNUSED u8 filler2[24]; } /* 2530C0 -> 2530D8; orig name: func_801A48F0 */ @@ -3107,13 +3102,13 @@ void Unknown801A4F58(void) { r = (s16)(colour >> 11 & 0x1F); g = (s16)(colour >> 6 & 0x1F); b = (s16)(colour >> 1 & 0x1F); - if ((r -= 1) < 0) { + if (--r < 0) { r = 0; } - if ((g -= 1) < 0) { + if (--g < 0) { g = 0; } - if ((b -= 1) < 0) { + if (--b < 0) { b = 0; } @@ -3135,7 +3130,7 @@ void Proc801A5110(struct ObjView *view) { /* 253938 -> 2539DC; orig name: func_801A5168 */ void update_view_and_dl(struct ObjView *view) { - UNUSED u32 pad; + UNUSED u8 filler[4]; s32 prevFlags; // 18 prevFlags = view->flags; @@ -3152,7 +3147,7 @@ void update_view_and_dl(struct ObjView *view) { * Unused - called by __main__ */ void func_801A520C(void) { - UNUSED u32 pad[2]; + UNUSED u8 filler[8]; start_timer("1frame"); start_timer("cpu"); @@ -3202,7 +3197,7 @@ void Unknown801A5344(void) { /* 253BC8 -> 2540E0 */ void gd_init(void) { s32 i; // 34 - UNUSED u32 pad30; + UNUSED u8 filler[4]; s8 *data; // 2c imin("gd_init"); @@ -3437,7 +3432,7 @@ void Unknown801A5D90(struct ObjGroup *arg0) { sp23C = FALSE; for (;;) { - trackerNum += 1; + trackerNum++; mt = get_memtracker_by_index(trackerNum); if (mt->name != NULL) { @@ -3484,11 +3479,11 @@ void Unknown801A5FF8(struct ObjGroup *arg0) { struct ObjView *menuview; // 3c UNUSED struct ObjLabel *label; // 38 struct ObjGroup *menugrp; // 34 - UNUSED u32 pad2C[2]; + UNUSED u8 filler[8]; d_start_group("menug"); sMenuGadgets[0] = d_makeobj(D_GADGET, "menu0"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(5.0f, 0.0f, 0.0f); d_set_scale(100.0f, 20.0f, 0.0f); d_set_type(6); @@ -3499,7 +3494,7 @@ void Unknown801A5FF8(struct ObjGroup *arg0) { d_add_valptr("menu0", 0x40000, 0, (uintptr_t) NULL); sMenuGadgets[1] = d_makeobj(D_GADGET, "menu1"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(5.0f, 25.0f, 0.0f); d_set_scale(100.0f, 20.0f, 0.0f); d_set_type(6); @@ -3510,7 +3505,7 @@ void Unknown801A5FF8(struct ObjGroup *arg0) { d_add_valptr("menu1", 0x40000, 0, (uintptr_t) NULL); sMenuGadgets[2] = d_makeobj(D_GADGET, "menu2"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(5.0f, 50.0f, 0.0f); d_set_scale(100.0f, 20.0f, 0.0f); d_set_type(6); @@ -3602,7 +3597,7 @@ void view_proc_print_timers(struct ObjView *self) { void make_timer_gadgets(void) { struct ObjLabel *timerLabel; struct ObjGroup *timerg; - UNUSED u32 pad6C; + UNUSED u8 filler[4]; struct ObjView *timersview; struct ObjGadget *bar1; struct ObjGadget *bar2; @@ -3616,7 +3611,7 @@ void make_timer_gadgets(void) { d_start_group("timerg"); d_makeobj(D_GADGET, "bar1"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(20.0f, 5.0f, 0.0f); d_set_scale(50.0f, 5.0f, 0.0f); d_set_type(4); @@ -3627,7 +3622,7 @@ void make_timer_gadgets(void) { bar1->colourNum = COLOUR_WHITE; d_makeobj(D_GADGET, "bar2"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(70.0f, 5.0f, 0.0f); d_set_scale(50.0f, 5.0f, 0.0f); d_set_type(4); @@ -3638,7 +3633,7 @@ void make_timer_gadgets(void) { bar2->colourNum = COLOUR_PINK; d_makeobj(D_GADGET, "bar3"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(120.0f, 5.0f, 0.0f); d_set_scale(50.0f, 5.0f, 0.0f); d_set_type(4); @@ -3649,7 +3644,7 @@ void make_timer_gadgets(void) { bar3->colourNum = COLOUR_WHITE; d_makeobj(D_GADGET, "bar4"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(170.0f, 5.0f, 0.0f); d_set_scale(50.0f, 5.0f, 0.0f); d_set_type(4); @@ -3660,7 +3655,7 @@ void make_timer_gadgets(void) { bar4->colourNum = COLOUR_PINK; d_makeobj(D_GADGET, "bar5"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(220.0f, 5.0f, 0.0f); d_set_scale(50.0f, 5.0f, 0.0f); d_set_type(4); @@ -3671,7 +3666,7 @@ void make_timer_gadgets(void) { bar5->colourNum = COLOUR_WHITE; d_makeobj(D_GADGET, "bar6"); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(270.0f, 5.0f, 0.0f); d_set_scale(50.0f, 5.0f, 0.0f); d_set_type(4); @@ -3687,7 +3682,7 @@ void make_timer_gadgets(void) { timer = get_timernum(i); d_makeobj(D_GADGET, timerNameBuf); - d_set_obj_draw_flag(OBJ_IS_GRABBALE); + d_set_obj_draw_flag(OBJ_IS_GRABBABLE); d_set_world_pos(20.0f, (f32)((i * 15) + 15), 0.0f); d_set_scale(50.0f, 14.0f, 0); d_set_type(4); @@ -3842,7 +3837,7 @@ void func_801A71CC(struct ObjNet *net) { f32 spAC; f32 spA8; struct GdBoundingBox bbox; - UNUSED u32 pad8C; + UNUSED u8 filler1[4]; struct ObjZone *sp88; register struct ListNode *link; // s0 (84) s32 sp80; // linked planes contained in zone? @@ -3851,13 +3846,13 @@ void func_801A71CC(struct ObjNet *net) { register struct ListNode *link2; // s2 (74) register struct ListNode *link3; // s3 (70) struct GdVec3f sp64; - UNUSED u32 pad60; + UNUSED u8 filler2[4]; struct ObjPlane *plane; // 5c - UNUSED u32 pad58; + UNUSED u8 filler3[4]; struct ObjZone *linkedZone; // 54 - UNUSED u32 pad50; + UNUSED u8 filler4[4]; struct ObjPlane *planeL2; // 4c - UNUSED u32 pad48; + UNUSED u8 filler5[4]; struct ObjPlane *planeL3; // 44 if (net->unk21C == NULL) { @@ -3906,11 +3901,11 @@ void func_801A71CC(struct ObjNet *net) { for (link2 = net->unk1CC->firstMember; link2 != NULL; link2 = link2->next) { planeL2 = (struct ObjPlane *) link2->obj; - sp7C += 1; + sp7C++; if (gd_plane_point_within(&planeL2->boundingBox, &sp88->boundingBox)) { planeL2->unk18 = TRUE; addto_group(sp88->unk2C, &planeL2->header); - sp80 += 1; + sp80++; } } diff --git a/src/goddard/shape_helper.c b/src/goddard/shape_helper.c index cb8ff4f0..ee1dbf63 100644 --- a/src/goddard/shape_helper.c +++ b/src/goddard/shape_helper.c @@ -1,5 +1,9 @@ #include +#if defined(VERSION_JP) || defined(VERSION_US) +#include "prevent_bss_reordering.h" +#endif + #include "debug_utils.h" #include "draw_objects.h" #include "dynlist_proc.h" @@ -16,10 +20,6 @@ #include "shape_helper.h" #include "skin.h" -#ifndef VERSION_EU -#include -#endif - // data struct ObjGroup *gMarioFaceGrp = NULL; // @ 801A82E0; returned by load_dynlist struct ObjShape *gSpotShape = NULL; // Shape used for drawing lights? @@ -131,7 +131,7 @@ void func_80197280(void) { * Computes the normal vector for a face based on three of its vertices. */ void calc_face_normal(struct ObjFace *face) { - UNUSED u32 pad5C; + UNUSED u8 filler1[4]; struct GdVec3f p1; struct GdVec3f p2; struct GdVec3f p3; @@ -139,7 +139,7 @@ void calc_face_normal(struct ObjFace *face) { struct ObjVertex *vtx1; struct ObjVertex *vtx2; struct ObjVertex *vtx3; - UNUSED u32 pad1C; + UNUSED u8 filler2[4]; f32 mul = 1000.0f; imin("calc_facenormal"); @@ -260,7 +260,7 @@ void add_3_vtx_to_face(struct ObjFace *face, struct ObjVertex *vtx1, struct ObjV struct ObjShape *make_shape(s32 flag, const char *name) { struct ObjShape *newShape; struct ObjShape *curShapeHead; - UNUSED u32 pad; + UNUSED u8 filler[4]; newShape = (struct ObjShape *) make_object(OBJ_TYPE_SHAPES); @@ -604,7 +604,7 @@ void Unknown801985E8(struct ObjShape *shape) { /* @ 246ED4 for 0x4FC; orig name: func_80198704 */ void get_3DG1_shape(struct ObjShape *shape) { - UNUSED u8 pad78[8]; + UNUSED u8 filler[8]; struct GdVec3f tempNormal; /* maybe? */ s32 curFaceVtx; s32 faceVtxID; @@ -723,7 +723,7 @@ void get_3DG1_shape(struct ObjShape *shape) { /* @ 2473D0 for 0x390; orig name: func_80198C00 */ void get_OBJ_shape(struct ObjShape *shape) { - UNUSED u8 pad7D54[4]; + UNUSED u8 filler[4]; struct GdColour faceClr; s32 curFaceVtx; s32 faceVtxIndex; @@ -881,7 +881,7 @@ void read_ARK_shape(struct ObjShape *shape, char *fileName) { union { s8 bytes[0x48]; struct { - u8 pad[0x40]; + u8 filler[0x40]; s32 word40; s32 word44; } data; @@ -911,7 +911,7 @@ void read_ARK_shape(struct ObjShape *shape, char *fileName) { } data; } vtx; - UNUSED u8 pad54[4]; + UNUSED u8 filler[4]; struct GdVec3f sp48; struct ObjFace *sp44; // newly made face with mtl sp34; struct ObjFace *sp40 = NULL; // first made face @@ -1048,13 +1048,12 @@ struct GdFile *get_shape_from_file(struct ObjShape *shape, char *fileName) { /* @ 247F78 for 0x69c; orig name: Unknown801997A8 */ struct ObjShape *make_grid_shape(enum ObjTypeFlag gridType, s32 a1, s32 a2, s32 a3, s32 a4) { - UNUSED u32 pad1074; + UNUSED u8 filler1[4]; void *objBuf[32][32]; // vertex or particle depending on gridType f32 sp70; f32 sp6C; f32 sp68; - UNUSED u32 pad64; - UNUSED u32 pad60; + UNUSED u8 filler2[8]; f32 sp5C; s32 parI; s32 row; @@ -1064,13 +1063,13 @@ struct ObjShape *make_grid_shape(enum ObjTypeFlag gridType, s32 a1, s32 a2, s32 f32 sp44; struct ObjFace *sp40 = NULL; // first made shape? struct ObjGroup *parOrVtxGrp; // group of made particles or vertices (based on gridType) - UNUSED u32 pad38; + UNUSED u8 filler3[4]; struct ObjGroup *mtlGroup; struct GdVec3f *sp30; // GdVec3f* ? from gd_get_colour struct GdVec3f *sp2C; //^ struct ObjMaterial *mtl1; // first made material struct ObjMaterial *mtl2; // second made material - UNUSED u32 pad20; + UNUSED u8 filler4[4]; sp30 = (struct GdVec3f *) gd_get_colour(a1); sp2C = (struct GdVec3f *) gd_get_colour(a2); @@ -1238,7 +1237,7 @@ void animate_mario_head_normal(struct ObjAnimator *self) { if (self->frame == 810.0f) { self->frame = 750.0f; - self->nods -= 1; + self->nods--; if (self->nods == 0) { state = 3; } @@ -1300,9 +1299,9 @@ void animate_mario_head_normal(struct ObjAnimator *self) { */ s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)) { struct ObjNet *sp54; // net made with sp48 group - UNUSED u8 pad4C[0x54 - 0x4c]; + UNUSED u8 filler1[8]; struct ObjGroup *sp48; // Joint group - UNUSED u8 pad40[0x48 - 0x40]; + UNUSED u8 filler2[8]; struct ObjGroup *mainShapesGrp; struct GdObj *sp38; // object list head before making a bunch of joints struct GdObj *faceJoint; // joint on the face that `grabberJoint` pulls @@ -1418,7 +1417,7 @@ s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)) { grabberJoint->attachedObjsGrp = make_group(1, faceJoint); grabberJoint->updateFunc = eye_joint_update_func; grabberJoint->rootAnimator = animator; - grabberJoint->header.drawFlags &= ~OBJ_IS_GRABBALE; + grabberJoint->header.drawFlags &= ~OBJ_IS_GRABBABLE; // make the right eye follow cursor grabberJoint = make_grabber_joint(sGrabJointTestShape, 0, -100.0f, 200.0f, 400.0f); @@ -1426,7 +1425,7 @@ s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)) { grabberJoint->attachedObjsGrp = make_group(1, faceJoint); grabberJoint->updateFunc = eye_joint_update_func; grabberJoint->rootAnimator = animator; - grabberJoint->header.drawFlags &= ~OBJ_IS_GRABBALE; + grabberJoint->header.drawFlags &= ~OBJ_IS_GRABBABLE; sp48 = make_group_of_type(OBJ_TYPE_JOINTS, sp38, NULL); sp54 = make_net(0, NULL, sp48, NULL, NULL); @@ -1528,11 +1527,10 @@ struct ObjGroup *Unknown8019ADC4(UNUSED u32 a0) { /* @ 249694 for 0x5c */ struct ObjGroup *Unknown8019AEC4(UNUSED u32 a0) { - UNUSED u32 sp24; - UNUSED u32 sp20; - UNUSED struct GdObj *sp1C; + UNUSED u8 filler[8]; + UNUSED struct GdObj *sp1C = gGdObjectList; - sp1C = gGdObjectList; gGdLightGroup = make_group(0); + return gGdLightGroup; } diff --git a/src/goddard/skin.c b/src/goddard/skin.c index 069d0c55..8088dc50 100644 --- a/src/goddard/skin.c +++ b/src/goddard/skin.c @@ -1,6 +1,6 @@ #include -#if defined(VERSION_EU) || defined(VERSION_SH) +#ifdef VERSION_EU #include "prevent_bss_reordering.h" #endif @@ -92,7 +92,7 @@ void func_80192294(struct ObjNet *net) { /* 240ACC -> 240B84 */ void func_801922FC(struct ObjNet *net) { struct ObjGroup *group; // 24 - UNUSED u32 pad18[2]; + UNUSED u8 filler[8]; gGdSkinNet = net; // TODO: netype constants? @@ -200,10 +200,9 @@ void collision_something_801926A4(struct ObjNet *net) { /* 2412A0 -> 24142C; not called */ void func_80192AD0(struct ObjNet *net) { - UNUSED u32 pad64; + UNUSED u8 filler1[4]; struct ObjGroup *sp60; - UNUSED u32 pad20[0x10]; - UNUSED u32 sp1C; + UNUSED u8 filler2[68]; struct ObjNet *sp18; if ((sp60 = net->unk1C8) == NULL) { @@ -232,7 +231,7 @@ void func_80192AD0(struct ObjNet *net) { /* 24142C -> 24149C; orig name: func_80192C5C */ void move_bonesnet(struct ObjNet *net) { struct ObjGroup *sp24; - UNUSED u32 pad18[3]; + UNUSED u8 filler[12]; imin("move_bonesnet"); gd_set_identity_mat4(&D_801B9DC8); @@ -300,10 +299,10 @@ void func_80192CCC(struct ObjNet *net) { /* 241768 -> 241AB4; orig name: func_80192F98 */ void convert_gd_verts_to_Vn(struct ObjGroup *grp) { - UNUSED u8 pad[0x40 - 0x2c]; + UNUSED u8 filler1[20]; Vtx *vn; // 28 u8 nx, ny, nz; // 24, 25, 26 - UNUSED u32 pad20; + UNUSED u8 filler2[4]; register struct VtxLink *vtxlink; // a1 #ifndef GBI_FLOATS register s16 *vnPos; // a2 @@ -348,7 +347,7 @@ void convert_gd_verts_to_Vn(struct ObjGroup *grp) { /* 241AB4 -> 241BCC; orig name: func_801932E4 */ void convert_gd_verts_to_Vtx(struct ObjGroup *grp) { - UNUSED u32 pad24[6]; + UNUSED u8 filler[24]; register struct VtxLink *vtxlink; // a1 #ifndef GBI_FLOATS register s16 *vtxcoords; // a2 diff --git a/src/goddard/skin_movement.c b/src/goddard/skin_movement.c index 7105ec76..05cb7e31 100644 --- a/src/goddard/skin_movement.c +++ b/src/goddard/skin_movement.c @@ -66,7 +66,7 @@ void scale_verts(struct ObjGroup *a0) { /* @ 23000C for 0x58; orig name: func8018183C*/ void move_skin(struct ObjNet *net) { - UNUSED u8 pad1C[8]; + UNUSED u8 filler[8]; if (net->shapePtr != NULL) { scale_verts(net->shapePtr->scaledVtxGroup); @@ -89,8 +89,7 @@ void func_80181894(struct ObjJoint *joint) { linkedObj = link->obj; curWeight = (struct ObjWeight *) linkedObj; - if (curWeight->weightVal > 0.0) //? 0.0f - { + if (curWeight->weightVal > 0.0) { //? 0.0f stackVec.x = curWeight->vec20.x; stackVec.y = curWeight->vec20.y; stackVec.z = curWeight->vec20.z; @@ -110,7 +109,7 @@ void func_80181894(struct ObjJoint *joint) { /* @ 2301A0 for 0x110 */ void reset_weight_vtx(struct ObjVertex *vtx) { struct GdVec3f localVec; - UNUSED u8 pad24[0x10]; + UNUSED u8 filler[16]; if (sResetWeightVtxNum++ == sResetCurWeight->vtxId) { // found matching vertex sResetCurWeight->vtx = vtx; @@ -129,7 +128,7 @@ void reset_weight_vtx(struct ObjVertex *vtx) { void reset_weight(struct ObjWeight *weight) { UNUSED u32 vtxCount; - UNUSED u32 pad20; + UNUSED u8 filler[4]; struct ObjGroup *skinGroup; sResetCurWeight = weight; diff --git a/src/menu/file_select.c b/src/menu/file_select.c index 9437dcc6..fce9a9e2 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -627,6 +627,7 @@ void render_score_menu_buttons(struct Object *scoreButton) { #else #define SCORE_TIMER 31 #endif + /** * In the score menu, checks if a button was clicked to play a sound, button state and other functions. */ @@ -681,6 +682,7 @@ void check_score_menu_clicked_buttons(struct Object *scoreButton) { } } } + #undef SCORE_TIMER /** @@ -980,6 +982,7 @@ void erase_action_file_button(struct Object *eraseButton, s32 eraseFileButtonID) break; } } + #undef BUZZ_TIMER /** @@ -1025,6 +1028,7 @@ void check_erase_menu_clicked_buttons(struct Object *eraseButton) { } } } + #undef ACTION_TIMER #undef MAIN_RETURN_TIMER @@ -1074,6 +1078,7 @@ void render_sound_mode_menu_buttons(struct Object *soundModeButton) { sMainMenuButtons[MENU_BUTTON_OPTION_MIN + sSoundMode]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN; #endif } + #undef SOUND_BUTTON_Y /** @@ -1200,9 +1205,8 @@ void load_score_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceBut // If the previous button is in default state if (sMainMenuButtons[prevMenuButtonID]->oMenuButtonState == MENU_BUTTON_STATE_DEFAULT) { // Hide buttons of corresponding button menu groups - if (prevMenuButtonID == MENU_BUTTON_SCORE) //! Not possible, this is checking if the score menu - //! was opened from the score menu! - { + //! Not possible, this is checking if the score menu was opened from the score menu! + if (prevMenuButtonID == MENU_BUTTON_SCORE) { for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) { mark_obj_for_deletion(sMainMenuButtons[buttonID]); } @@ -1246,9 +1250,8 @@ void load_copy_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceButt mark_obj_for_deletion(sMainMenuButtons[buttonID]); } } - if (prevMenuButtonID == MENU_BUTTON_COPY) //! Not possible, this is checking if the copy menu - //! was opened from the copy menu! - { + //! Not possible, this is checking if the copy menu was opened from the copy menu! + if (prevMenuButtonID == MENU_BUTTON_COPY) { for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) { mark_obj_for_deletion(sMainMenuButtons[buttonID]); } @@ -1292,9 +1295,8 @@ void load_erase_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceBut mark_obj_for_deletion(sMainMenuButtons[buttonID]); } } - if (prevMenuButtonID == MENU_BUTTON_ERASE) //! Not possible, this is checking if the erase menu - //! was opened from the erase menu! - { + //! Not possible, this is checking if the erase menu was opened from the erase menu! + if (prevMenuButtonID == MENU_BUTTON_ERASE) { for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) { mark_obj_for_deletion(sMainMenuButtons[buttonID]); } @@ -1376,7 +1378,7 @@ void bhv_menu_button_manager_init(void) { sTextBaseAlpha = 0; } -#if defined(VERSION_JP) +#ifdef VERSION_JP #define SAVE_FILE_SOUND SOUND_MENU_STAR_SOUND #else #define SAVE_FILE_SOUND SOUND_MENU_STAR_SOUND_OKEY_DOKEY @@ -1485,6 +1487,7 @@ void check_main_menu_clicked_buttons(void) { } #endif } + #undef SAVE_FILE_SOUND /** @@ -1622,10 +1625,11 @@ void handle_cursor_button_input(void) { || sSelectedButtonID == MENU_BUTTON_SCORE_FILE_D) { if (gPlayer3Controller->buttonPressed #ifdef VERSION_EU - & (B_BUTTON | START_BUTTON | Z_TRIG)) { + & (B_BUTTON | START_BUTTON | Z_TRIG) #else - & (B_BUTTON | START_BUTTON)) { + & (B_BUTTON | START_BUTTON) #endif + ) { sClickPos[0] = sCursorPos[0]; sClickPos[1] = sCursorPos[1]; sCursorClickingTimer = 1; @@ -1801,7 +1805,7 @@ void print_save_file_star_count(s8 fileIndex, s16 x, s16 y) { #define SAVEFILE_X2 209 #define MARIOTEXT_X1 92 #define MARIOTEXT_X2 207 -#else // VERSION_EU +#elif defined(VERSION_EU) #define SAVEFILE_X1 97 #define SAVEFILE_X2 204 #define MARIOTEXT_X1 97 @@ -1888,15 +1892,15 @@ void print_main_lang_strings(void) { } #endif -#ifdef VERSION_EU -#define CHECK_FILE_X checkFileX -#define NOSAVE_DATA_X1 noSaveDataX -#elif defined(VERSION_JP) || defined(VERSION_SH) -#define CHECK_FILE_X 90 -#define NOSAVE_DATA_X1 90 -#else -#define CHECK_FILE_X 95 -#define NOSAVE_DATA_X1 99 +#if defined(VERSION_JP) || defined(VERSION_SH) + #define CHECK_FILE_X 90 + #define NOSAVE_DATA_X1 90 +#elif defined(VERSION_US) + #define CHECK_FILE_X 95 + #define NOSAVE_DATA_X1 99 +#elif defined(VERSION_EU) + #define CHECK_FILE_X checkFileX + #define NOSAVE_DATA_X1 noSaveDataX #endif /** @@ -1927,14 +1931,14 @@ void score_menu_display_message(s8 messageID) { #define RETURN_X 45 #define COPYFILE_X1 128 #define ERASEFILE_X1 228 +#elif defined(VERSION_US) + #define RETURN_X 44 + #define COPYFILE_X1 135 + #define ERASEFILE_X1 231 #elif defined(VERSION_EU) #define RETURN_X centeredX #define COPYFILE_X1 centeredX #define ERASEFILE_X1 centeredX -#else - #define RETURN_X 44 - #define COPYFILE_X1 135 - #define ERASEFILE_X1 231 #endif #ifdef VERSION_EU @@ -2014,6 +2018,13 @@ void print_score_menu_strings(void) { #define NOSAVE_DATA_X2 90 #define COPYCOMPLETE_X 90 #define SAVE_EXISTS_X1 90 +#elif defined(VERSION_US) + #define NOFILE_COPY_X 119 + #define COPY_FILE_X 104 + #define COPYIT_WHERE_X 109 + #define NOSAVE_DATA_X2 101 + #define COPYCOMPLETE_X 110 + #define SAVE_EXISTS_X1 110 #elif defined(VERSION_EU) #define NOFILE_COPY_X centeredX #define COPY_FILE_X centeredX @@ -2021,13 +2032,6 @@ void print_score_menu_strings(void) { #define NOSAVE_DATA_X2 centeredX #define COPYCOMPLETE_X centeredX #define SAVE_EXISTS_X1 centeredX -#else - #define NOFILE_COPY_X 119 - #define COPY_FILE_X 104 - #define COPYIT_WHERE_X 109 - #define NOSAVE_DATA_X2 101 - #define COPYCOMPLETE_X 110 - #define SAVE_EXISTS_X1 110 #endif /** @@ -2129,14 +2133,14 @@ void copy_menu_update_message(void) { #if defined(VERSION_JP) #define VIEWSCORE_X1 133 #define ERASEFILE_X2 220 -#elif defined(VERSION_SH) - #define VIEWSCORE_X1 133 +#elif defined(VERSION_US) + #define VIEWSCORE_X1 128 #define ERASEFILE_X2 230 #elif defined(VERSION_EU) #define VIEWSCORE_X1 centeredX #define ERASEFILE_X2 centeredX -#else - #define VIEWSCORE_X1 128 +#elif defined(VERSION_SH) + #define VIEWSCORE_X1 133 #define ERASEFILE_X2 230 #endif @@ -2192,12 +2196,12 @@ void print_copy_menu_strings(void) { #endif } -#if defined(VERSION_JP) +#if defined(VERSION_JP) || defined(VERSION_SH) +#ifdef VERSION_JP #define CURSOR_X 160.0f - #define MENU_ERASE_YES_MIN_X 145 - #define MENU_ERASE_YES_MAX_X 164 -#elif defined(VERSION_SH) +#else #define CURSOR_X (x + 70) +#endif #define MENU_ERASE_YES_MIN_X 145 #define MENU_ERASE_YES_MAX_X 164 #else @@ -2289,27 +2293,27 @@ void print_erase_menu_prompt(s16 x, s16 y) { // M a r i o A --- マ リ オ A // 0 1 2 3 4 5 6 --- 0 1 2 3 #if defined(VERSION_JP) || defined(VERSION_SH) -#ifdef VERSION_SH - #define ERASE_FILE_X 111 -#else +#ifdef VERSION_JP #define ERASE_FILE_X 96 +#else + #define ERASE_FILE_X 111 #endif #define NOSAVE_DATA_X3 90 #define MARIO_ERASED_VAR 3 #define MARIO_ERASED_X 90 #define SAVE_EXISTS_X2 90 +#elif defined(VERSION_US) + #define ERASE_FILE_X 98 + #define NOSAVE_DATA_X3 100 + #define MARIO_ERASED_VAR 6 + #define MARIO_ERASED_X 100 + #define SAVE_EXISTS_X2 100 #elif defined(VERSION_EU) #define ERASE_FILE_X centeredX #define NOSAVE_DATA_X3 centeredX #define MARIO_ERASED_VAR 6 #define MARIO_ERASED_X centeredX #define SAVE_EXISTS_X2 centeredX -#else - #define ERASE_FILE_X 98 - #define NOSAVE_DATA_X3 100 - #define MARIO_ERASED_VAR 6 - #define MARIO_ERASED_X 100 - #define SAVE_EXISTS_X2 100 #endif /** @@ -2404,11 +2408,11 @@ void erase_menu_update_message(void) { } #if defined(VERSION_JP) || defined(VERSION_SH) -#define VIEWSCORE_X2 133 -#define COPYFILE_X2 223 + #define VIEWSCORE_X2 133 + #define COPYFILE_X2 223 #else -#define VIEWSCORE_X2 127 -#define COPYFILE_X2 233 + #define VIEWSCORE_X2 127 + #define COPYFILE_X2 233 #endif /** @@ -2671,9 +2675,14 @@ void print_score_file_star_score(s8 fileIndex, s16 courseIndex, s16 x, s16 y) { #define SECRET_STARS_PAD 6 #define LEVEL_NAME_X 23 #define STAR_SCORE_X 171 +#ifdef VERSION_EU + #define MYSCORE_X get_str_x_pos_from_center(257, textMyScore[sLanguageMode], 10.0f) + #define HISCORE_X get_str_x_pos_from_center(257, textHiScore[sLanguageMode], 10.0f) +#else #define MYSCORE_X 238 #define HISCORE_X 231 #endif +#endif #ifdef VERSION_EU #include "game/segment7.h" @@ -2750,7 +2759,6 @@ void print_save_file_scores(s8 fileIndex) { PRINT_COURSE_SCORES(COURSE_THI, 0) PRINT_COURSE_SCORES(COURSE_TTC, 0) PRINT_COURSE_SCORES(COURSE_RR, 0) - #undef PRINT_COURSE_SCORES // Print castle secret stars text @@ -2761,20 +2769,11 @@ void print_save_file_scores(s8 fileIndex) { // Print current coin score mode if (sScoreFileCoinScoreMode == 0) { -#ifdef VERSION_EU - print_menu_generic_string(get_str_x_pos_from_center(257, textMyScore[sLanguageMode], 10.0f), - 24, textMyScore[sLanguageMode]); -#else - print_menu_generic_string(MYSCORE_X, 24, textMyScore); -#endif + print_menu_generic_string(MYSCORE_X, 24, LANGUAGE_ARRAY(textMyScore)); } else { -#ifdef VERSION_EU - print_menu_generic_string(get_str_x_pos_from_center(257, textHiScore[sLanguageMode], 10.0f), - 24,textHiScore[sLanguageMode]); -#else - print_menu_generic_string(HISCORE_X, 24, textHiScore); -#endif + print_menu_generic_string(HISCORE_X, 24, LANGUAGE_ARRAY(textHiScore)); } + gSPDisplayList(gDisplayListHead++, dl_menu_ia8_text_end); } @@ -2783,8 +2782,7 @@ void print_save_file_scores(s8 fileIndex) { * Also checks if all saves exists and defines text and main menu timers. */ static void print_file_select_strings(void) { - UNUSED s32 unused1; - UNUSED s32 unused2; + UNUSED u8 filler[8]; create_dl_ortho_matrix(); switch (sSelectedButtonID) { @@ -2834,7 +2832,7 @@ static void print_file_select_strings(void) { sTextBaseAlpha += 10; } if (sMainMenuTimer < 1000) { - sMainMenuTimer += 1; + sMainMenuTimer++; } } diff --git a/src/menu/intro_geo.c b/src/menu/intro_geo.c index 48d53f8b..efbbfbbb 100644 --- a/src/menu/intro_geo.c +++ b/src/menu/intro_geo.c @@ -10,7 +10,6 @@ #include "buffers/framebuffers.h" #include "game/game_init.h" #include "audio/external.h" -#include "prevent_bss_reordering.h" // frame counts for the zoom in, hold, and zoom out of title model #define INTRO_STEPS_ZOOM_IN 20 @@ -29,7 +28,7 @@ struct GraphNodeMore { // intro geo bss #ifdef VERSION_SH -static u16 *sFrameBuffers[3]; +static u16 *sFramebuffers[3]; #endif static s32 sGameOverFrameCounter; static s32 sGameOverTableIndex; @@ -272,11 +271,12 @@ Gfx *geo_intro_gameover_backdrop(s32 state, struct GraphNode *node, UNUSED void } #ifdef VERSION_SH + extern Gfx title_screen_bg_dl_0A0065E8[]; extern Gfx title_screen_bg_dl_0A006618[]; extern Gfx title_screen_bg_dl_0A007548[]; -//Data +// Data s8 sFaceVisible[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -296,8 +296,7 @@ s8 sFaceToggleOrder[] = { s8 sFaceCounter = 0; -void intro_gen_face_texrect(Gfx **dlIter) -{ +void intro_gen_face_texrect(Gfx **dlIter) { s32 x; s32 y; @@ -311,8 +310,7 @@ void intro_gen_face_texrect(Gfx **dlIter) } } -Gfx *intro_draw_face(u16 *image, s32 imageW, s32 imageH) -{ +Gfx *intro_draw_face(u16 *image, s32 imageW, s32 imageH) { Gfx *dl; Gfx *dlIter; @@ -337,7 +335,7 @@ Gfx *intro_draw_face(u16 *image, s32 imageW, s32 imageH) return dl; } -u16 *intro_sample_frame_buffer(s32 imageW, s32 imageH, s32 sampleW, s32 sampleH) { +u16 *intro_sample_framebuffer(s32 imageW, s32 imageH, s32 sampleW, s32 sampleH) { u16 *fb; u16 *image; s32 pixel; @@ -348,7 +346,7 @@ u16 *intro_sample_frame_buffer(s32 imageW, s32 imageH, s32 sampleW, s32 sampleH) s32 xOffset = 120; s32 yOffset = 80; - fb = sFrameBuffers[sRenderingFrameBuffer]; + fb = sFramebuffers[sRenderingFramebuffer]; image = alloc_display_list(imageW * imageH * sizeof(u16)); if (image == NULL) { @@ -398,9 +396,9 @@ Gfx *geo_intro_face_easter_egg(s32 state, struct GraphNode *node, UNUSED void *c s32 i; if (state != 1) { - sFrameBuffers[0] = gFrameBuffer0; - sFrameBuffers[1] = gFrameBuffer1; - sFrameBuffers[2] = gFrameBuffer2; + sFramebuffers[0] = gFramebuffer0; + sFramebuffers[1] = gFramebuffer1; + sFramebuffers[2] = gFramebuffer2; for (i = 0; i < 48; i++) { sFaceVisible[i] = 0; @@ -422,7 +420,7 @@ Gfx *geo_intro_face_easter_egg(s32 state, struct GraphNode *node, UNUSED void *c // Draw while the first or last face is visible. if (sFaceVisible[0] == 1 || sFaceVisible[17] == 1) { - image = intro_sample_frame_buffer(40, 40, 2, 2); + image = intro_sample_framebuffer(40, 40, 2, 2); if (image != NULL) { genNode->fnNode.node.flags = (genNode->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8); dl = intro_draw_face(image, 40, 40); @@ -469,4 +467,3 @@ Gfx *geo_intro_rumble_pak_graphic(s32 state, struct GraphNode *node, UNUSED void } #endif - diff --git a/src/menu/star_select.c b/src/menu/star_select.c index 07610faa..f7d1d740 100644 --- a/src/menu/star_select.c +++ b/src/menu/star_select.c @@ -19,7 +19,6 @@ #include "sm64.h" #include "star_select.h" #include "text_strings.h" -#include "prevent_bss_reordering.h" /** * @file star_select.c @@ -108,7 +107,7 @@ void render_100_coin_star(u8 stars) { void bhv_act_selector_init(void) { s16 i = 0; s32 selectorModelIDs[10]; - u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); sVisibleStars = 0; while (i != sObtainedStars) { @@ -167,7 +166,7 @@ void bhv_act_selector_init(void) { void bhv_act_selector_loop(void) { s8 i; u8 starIndexCounter; - u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); if (sObtainedStars != 6) { // Sometimes, stars are not selectable even if they appear on the screen. @@ -271,14 +270,12 @@ void print_act_selector_strings(void) { u8 **actNameTbl; #else u8 **levelNameTbl = segmented_to_virtual(seg2_course_name_table); - u8 *currLevelName = segmented_to_virtual(levelNameTbl[gCurrCourseNum - 1]); + u8 *currLevelName = segmented_to_virtual(levelNameTbl[COURSE_NUM_TO_INDEX(gCurrCourseNum)]); u8 **actNameTbl = segmented_to_virtual(seg2_act_name_table); #endif u8 *selectedActName; -#ifndef VERSION_EU s16 lvlNameX; s16 actNameX; -#endif s8 i; #ifdef VERSION_EU s16 language = eu_get_language(); @@ -301,19 +298,19 @@ void print_act_selector_strings(void) { levelNameTbl = segmented_to_virtual(course_name_table_eu_de); break; } - currLevelName = segmented_to_virtual(levelNameTbl[gCurrCourseNum - 1]); + currLevelName = segmented_to_virtual(levelNameTbl[COURSE_NUM_TO_INDEX(gCurrCourseNum)]); #endif // Print the coin highscore. gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255); - print_hud_my_score_coins(1, gCurrSaveFileNum - 1, gCurrCourseNum - 1, 155, 106); + print_hud_my_score_coins(1, gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum), 155, 106); gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end); gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 255); // Print the "MY SCORE" text if the coin score is more than 0 - if (save_file_get_course_coin_score(gCurrSaveFileNum - 1, gCurrCourseNum - 1) != 0) { + if (save_file_get_course_coin_score(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)) != 0) { #ifdef VERSION_EU print_generic_string(95, 118, myScore[language]); #else @@ -321,12 +318,8 @@ void print_act_selector_strings(void) { #endif } -#ifdef VERSION_EU - print_generic_string(get_str_x_pos_from_center(160, currLevelName + 3, 10.0f), 33, currLevelName + 3); -#else lvlNameX = get_str_x_pos_from_center(160, currLevelName + 3, 10.0f); print_generic_string(lvlNameX, 33, currLevelName + 3); -#endif gSPDisplayList(gDisplayListHead++, dl_ia_text_end); @@ -340,14 +333,10 @@ void print_act_selector_strings(void) { gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 255); // Print the name of the selected act. if (sVisibleStars != 0) { - selectedActName = segmented_to_virtual(actNameTbl[(gCurrCourseNum - 1) * 6 + sSelectedActIndex]); + selectedActName = segmented_to_virtual(actNameTbl[COURSE_NUM_TO_INDEX(gCurrCourseNum) * 6 + sSelectedActIndex]); -#ifdef VERSION_EU - print_menu_generic_string(get_str_x_pos_from_center(ACT_NAME_X, selectedActName, 8.0f), 81, selectedActName); -#else actNameX = get_str_x_pos_from_center(ACT_NAME_X, selectedActName, 8.0f); print_menu_generic_string(actNameX, 81, selectedActName); -#endif } // Print the numbers above each star. @@ -383,13 +372,14 @@ Gfx *geo_act_selector_strings(s16 callContext, UNUSED struct GraphNode *node) { * Also load how much stars a course has, without counting the 100 coin star. */ s32 lvl_init_act_selector_values_and_stars(UNUSED s32 arg, UNUSED s32 unused) { - u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + u8 stars = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); sLoadedActNum = 0; sInitSelectedActNum = 0; sVisibleStars = 0; sActSelectorMenuTimer = 0; - sObtainedStars = save_file_get_course_star_count(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + sObtainedStars = + save_file_get_course_star_count(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(gCurrCourseNum)); // Don't count 100 coin star if (stars & (1 << 6)) { @@ -407,7 +397,7 @@ s32 lvl_init_act_selector_values_and_stars(UNUSED s32 arg, UNUSED s32 unused) { * Also updates objects and returns act number selected after is chosen. */ s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused) { - if (sActSelectorMenuTimer >= 11) { + if (sActSelectorMenuTimer > 10) { // If any of these buttons are pressed, play sound and go to course act #ifndef VERSION_EU if ((gPlayer3Controller->buttonPressed & A_BUTTON) @@ -416,7 +406,7 @@ s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused #else if ((gPlayer3Controller->buttonPressed & (A_BUTTON | START_BUTTON | B_BUTTON | Z_TRIG))) { #endif -#if defined(VERSION_JP) +#ifdef VERSION_JP play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); #else play_sound(SOUND_MENU_STAR_SOUND_LETS_A_GO, gGlobalSoundSource); diff --git a/src/menu/star_select.h b/src/menu/star_select.h index 6388b3f6..d00afb1a 100644 --- a/src/menu/star_select.h +++ b/src/menu/star_select.h @@ -6,8 +6,7 @@ #include "types.h" -enum StarSelectorTypes -{ +enum StarSelectorTypes { STAR_SELECTOR_NOT_SELECTED, STAR_SELECTOR_SELECTED, STAR_SELECTOR_100_COINS