Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

effects and action command cleanup #1213

Merged
merged 20 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
87 changes: 44 additions & 43 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef s8 b8;

typedef s32 HitID;
typedef u32 AnimID;
typedef s32 HudElemID;

typedef struct {
u8 r, g, b, a;
Expand Down Expand Up @@ -651,59 +652,59 @@ typedef struct MusicProximityTrigger {
} MusicProximityTrigger; // size = 0x18

typedef struct StatusBar {
/* 0x00 */ s32 hpIconHIDs[2];
/* 0x08 */ s32 fpIconHIDs[2];
/* 0x10 */ s32 coinIconHID;
/* 0x14 */ s32 coinSparkleHID;
/* 0x18 */ s32 spIconHID;
/* 0x1C */ s32 spShineHID;
/* 0x20 */ s32 hpTimesHID;
/* 0x24 */ s32 fpTimesHID;
/* 0x28 */ s32 spTimesHID;
/* 0x2C */ s32 coinTimesHID;
/* 0x30 */ s32 starIconHID;
/* 0x00 */ HudElemID hpIconHIDs[2];
/* 0x08 */ HudElemID fpIconHIDs[2];
/* 0x10 */ HudElemID coinIconHID;
/* 0x14 */ HudElemID coinSparkleHID;
/* 0x18 */ HudElemID spIconHID;
/* 0x1C */ HudElemID spShineHID;
/* 0x20 */ HudElemID hpTimesHID;
/* 0x24 */ HudElemID fpTimesHID;
/* 0x28 */ HudElemID spTimesHID;
/* 0x2C */ HudElemID coinTimesHID;
/* 0x30 */ HudElemID starIconHID;
/* 0x34 */ s16 drawPosX; // base position of the whole bar
/* 0x36 */ s16 drawPosY; // base position of the whole bar, animated when it appears
/* 0x38 */ s16 showTimer;
/* 0x3A */ b8 hidden;
/* 0x3A */ b8 hidden; // current state of the status bar's visiblity
/* 0x3B */ b8 unk_3B;
/* 0x3C */ b8 unk_3C;
/* 0x3D */ s8 displayHP;
/* 0x3E */ s8 displayFP;
/* 0x3F */ char unk_3F;
/* 0x3F */ char pad_3F;
/* 0x40 */ s16 displayCoins;
/* 0x42 */ s16 displayStarpoints;
/* 0x44 */ s8 ignoreChanges; /* set != 0 to prevent automatic opening from HP/FP changes */
/* 0x45 */ s8 openInputDisabled;
/* 0x45 */ s8 alwaysShown; // when set, the status bar will always be shown. used while browsing a shop.
/* 0x47 */ s8 disabled; /* set != 0 for menu to be disabled completely */
/* 0x48 */ s16 displayStarPower;
/* 0x4A */ s8 hpBlinking; /* bool */
/* 0x4B */ s8 hpBlinkCounter;
/* 0x4C */ s8 hpBlinkTimer; /* until stop */
/* 0x4D */ s8 fpBlinking; /* bool */
/* 0x4E */ s8 fpBlinkCounter;
/* 0x4F */ s8 fpBlinkTimer; /* until stop */
/* 0x50 */ s8 spBlinking;
/* 0x51 */ s8 spBlinkCounter;
/* 0x52 */ s8 starpointsBlinking; /* bool */
/* 0x53 */ s8 starpointsBlinkCounter;
/* 0x54 */ s8 coinsBlinking; /* bool */
/* 0x55 */ s8 coinsBlinkCounter;
/* 0x56 */ s8 coinsBlinkTimer; /* until stop */
/* 0x57 */ s8 unk_57;
/* 0x58 */ s8 unk_58;
/* 0x59 */ s8 unk_59;
/* 0x5A */ s8 spBarsToBlink; /* how many sp bars to blink */
/* 0x5B */ char unk_5B;
/* 0x5C */ s32 coinCountTimesHID;
/* 0x60 */ s32 coinCountIconHID;
/* 0x64 */ s32 iconIndex12;
/* 0x68 */ s32 iconIndex13;
/* 0x6C */ s8 coinCounterHideTime;
/* 0x6D */ s8 unk_6D;
/* 0x6E */ s8 unk_6E;
/* 0x6F */ char unk_6F;
/* 0x4A */ b8 hpBlinking;
/* 0x4B */ s8 hpBlinkAnimTime;
/* 0x4C */ s8 hpBlinkTimeLeft;
/* 0x4D */ b8 fpBlinking;
/* 0x4E */ s8 fpBlinkAnimTime;
/* 0x4F */ s8 fpBlinkTimeLeft;
/* 0x50 */ b8 starPowerBlinking;
/* 0x51 */ s8 starPowerBlinkCounter;
/* 0x52 */ b8 starpointsBlinking;
/* 0x53 */ s8 starpointsBlinkAnimTime;
/* 0x54 */ b8 coinsBlinking;
/* 0x55 */ s8 coinsBlinkAnimTime;
/* 0x56 */ s8 coinsBlinkTimeLeft;
/* 0x57 */ s8 shimmerState;
/* 0x58 */ s8 shimmerTime;
/* 0x59 */ s8 shimmerLimit;
/* 0x5A */ s8 powBarsToBlink; // how many star power bars to blink
/* 0x5B */ char pad_5B;
/* 0x5C */ HudElemID coinCountTimesHID;
/* 0x60 */ HudElemID coinCountIconHID;
/* 0x64 */ HudElemID iconIndex12;
/* 0x68 */ HudElemID iconIndex13;
/* 0x6C */ s8 coinCounterHideDelay;
/* 0x6D */ s8 coinCountDisposeTime;
/* 0x6E */ s8 prevIgnoreChanges; // while the coin counter is open, ignoreChanges count is pushed here
/* 0x6F */ char pad_6F;
} StatusBar; // size = 0x70

typedef struct CameraInitData {
Expand Down Expand Up @@ -912,11 +913,11 @@ typedef struct BattleStatus {
/* 0x07B */ u8 damageTaken;
/* 0x07C */ s8 changePartnerAllowed;
/* 0x07D */ s8 menuStatus[4]; ///< -1 = automatically pick the first move, 0 = disabled, 1 = enabled
/* 0x081 */ s8 actionSuccess;
/* 0x082 */ char unk_82;
/* 0x081 */ s8 actionQuality; // degree of success for action command, -1 indicates failure, 0 is in progress, >0 is some degree of success
/* 0x082 */ s8 maxActionQuality; // seems to indicate the maximum positive value for actionQuality; never read and inconsistently used between various action commands
/* 0x083 */ s8 actionCommandMode;
/* 0x084 */ s8 actionQuality; // actionCommandVar1 ?
/* 0x085 */ s8 unk_85; // actionCommandVar2 ?
/* 0x084 */ s8 actionProgress;
/* 0x085 */ s8 resultTier;
/* 0x086 */ s8 actionResult; // see enum ActionResult
/* 0x087 */ s8 blockResult; // see enum BlockResult
/* 0x088 */ s8 itemUsesLeft; /* set to 2 for double dip, 3 for triple dip */
Expand Down
2 changes: 1 addition & 1 deletion include/dead.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
#define GetNextPathPos dead_GetNextPathPos
#define queue_render_task dead_queue_render_task
#define dma_copy dead_dma_copy
#define create_worker_world dead_create_worker_world
#define create_worker_scene dead_create_worker_scene
#define GetEntryID dead_GetEntryID
#define SetMusicTrack dead_SetMusicTrack
#define FadeInMusic dead_FadeInMusic
Expand Down
18 changes: 9 additions & 9 deletions include/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -2606,14 +2606,14 @@ typedef union {
struct PinkSparklesFXData* pinkSparkles;
struct StarOutlineFXData* starOutline;
struct Effect86FXData* unk_86;
} EffectData;
} EffectInstanceDataPtr;

typedef struct EffectInstance {
/* 0x00 */ s32 flags;
/* 0x04 */ s32 effectIndex;
/* 0x04 */ s32 effectID;
/* 0x08 */ s32 numParts;
/* 0x0C */ EffectData data;
/* 0x10 */ struct EffectGraphics* graphics;
/* 0x0C */ EffectInstanceDataPtr data;
/* 0x10 */ struct EffectSharedData* shared;
} EffectInstance; // size = 0x14

// composite struct for watt effects -- NOT the same as StaticStatusFXData
Expand Down Expand Up @@ -2661,20 +2661,20 @@ typedef struct EffectBlueprint {
/* 0x04 */ s32 effectID;
/* 0x08 */ void (*init)(EffectInstance* effectInst);
/* 0x0C */ void (*update)(EffectInstance* effectInst);
/* 0x10 */ void (*renderWorld)(EffectInstance* effectInst);
/* 0x10 */ void (*renderScene)(EffectInstance* effectInst);
/* 0x14 */ void (*renderUI)(EffectInstance* effectInst);
} EffectBlueprint; // size = 0x18

typedef struct EffectGraphics {
typedef struct EffectSharedData {
/* 0x00 */ s32 flags;
/* 0x04 */ s32 effectIndex;
/* 0x08 */ s32 instanceCounter;
/* 0x0C */ s32 freeDelay;
/* 0x10 */ void (*update)(EffectInstance* effectInst);
/* 0x14 */ void (*renderWorld)(EffectInstance* effectInst);
/* 0x14 */ void (*renderScene)(EffectInstance* effectInst);
/* 0x18 */ void (*renderUI)(EffectInstance* effectInst);
/* 0x1C */ s32* data;
} EffectGraphics; // size = 0x20
/* 0x1C */ s32* graphics;
} EffectSharedData; // size = 0x20

typedef struct EffectTableEntry {
/* 0x00 */ void (*entryPoint);
Expand Down
29 changes: 14 additions & 15 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ enum SoundIDs {
SOUND_FIRE_BAR_8_A = 0x0000033E,
SOUND_FIRE_BAR_9_A = 0x0000033F,
SOUND_FIRE_BAR_DEAD = 0x00000340,
SOUND_LRAW_CHARGE_BAR = 0x00000341,
SOUND_LRAW_CHARGE_METER = 0x00000341,
SOUND_POKEY_SWAY = 0x00000342, // same as SOUND_POKEY_LEAN_BACK?
SOUND_POKEY_WALK = 0x00000343,
SOUND_POKEY_LEAN_FORWARD = 0x00000344,
Expand Down Expand Up @@ -1643,7 +1643,7 @@ enum SoundIDs {
SOUND_LOOP_TIK_UNUSED3_FLOW3 = 0x8000003E, // #unused
SOUND_LOOP_TIK_UNUSED3_FLOW2 = 0x8000003F, // #unused
SOUND_LOOP_SAM_STAIRS_RISE = 0x80000040,
SOUND_LOOP_CHARGE_BAR = 0x80000041,
SOUND_LOOP_CHARGE_METER = 0x80000041,
SOUND_LOOP_CRYSTAL_BALL_GLOW = 0x80000042,
SOUND_LOOP_TIK18_WATER = 0x80000043,
SOUND_LOOP_TIK19_WATER = 0x80000044,
Expand Down Expand Up @@ -1961,12 +1961,12 @@ typedef enum HitResult {
} HitResult;

typedef enum ActionResult {
ACTION_RESULT_NONE = 127,
ACTION_RESULT_MINUS_4 = -4,
ACTION_RESULT_MINUS_2 = -2,
ACTION_RESULT_EARLY = -1,
ACTION_RESULT_FAIL = 0,
ACTION_RESULT_SUCCESS = 1,
ACTION_RESULT_NONE = 127,
ACTION_RESULT_METER_BELOW_HALF = -4, // certain mashing comamnds fail with this value
ACTION_RESULT_METER_NOT_ENOUGH = -2, // certain mashing comamnds fail with this value
ACTION_RESULT_EARLY = -1, // timing commands too early fail with this value
ACTION_RESULT_FAIL = 0, // simple failure to complete action command
ACTION_RESULT_SUCCESS = 1,
} ActionResult;

typedef enum BlockResult {
Expand Down Expand Up @@ -3477,10 +3477,10 @@ enum ActionCommand {
ACTION_COMMAND_BREAK_FREE = 0x00000004,
ACTION_COMMAND_WHIRLWIND = 0x00000005,
ACTION_COMMAND_STOP_LEECH = 0x00000006,
ACTION_COMMAND_07 = 0x00000007,
ACTION_COMMAND_UNUSED_FLEE = 0x00000007,
ACTION_COMMAND_DIZZY_SHELL = 0x00000008,
ACTION_COMMAND_FIRE_SHELL = 0x00000009,
ACTION_COMMAND_0A = 0x0000000A,
ACTION_COMMAND_UNUSED_MASH_A = 0x0000000A,
ACTION_COMMAND_BOMB = 0x0000000B,
ACTION_COMMAND_BODY_SLAM = 0x0000000C,
ACTION_COMMAND_AIR_LIFT = 0x0000000D,
Expand All @@ -3492,7 +3492,7 @@ enum ActionCommand {
ACTION_COMMAND_SPINY_SURGE = 0x00000013,
ACTION_COMMAND_HURRICANE = 0x00000014,
ACTION_COMMAND_SPOOK = 0x00000015,
ACTION_COMMAND_WATER_BLOCK = 0x00000016,
ACTION_COMMAND_THREE_CHANCES = 0x00000016,
ACTION_COMMAND_TIDAL_WAVE = 0x00000017,
};

Expand All @@ -3518,10 +3518,9 @@ enum EffectInstanceFlags {
FX_INSTANCE_FLAG_DISMISS = 0x00000010, // effect should perform cleanup and self-delete
};

enum EffectGfxDataFlags {
FX_GRAPHICS_DISABLED = 0x00000000,
FX_GRAPHICS_LOADED = 0x00000001,
FX_GRAPHICS_CAN_FREE = 0x00000002,
enum EffectSharedDataFlags {
FX_SHARED_DATA_LOADED = 0x00000001,
FX_SHARED_DATA_CAN_FREE = 0x00000002,
};

#include "move_enum.h"
Expand Down
11 changes: 6 additions & 5 deletions include/filemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _FILEMENU_H_

#include "common.h"
#include "filemenu.h"

enum {
PAGE_0,
Expand All @@ -17,20 +18,20 @@ extern MenuPanel* filemenu_menus[];

extern s32 filemenu_iterFileIdx;
extern s32 filemenu_pressedButtons;
extern s32 filemenu_cursorHudElem;
extern HudElemID filemenu_cursorHID;
extern s32 filemenu_heldButtons;
extern s8 filemenu_filename_pos;
extern s32 filemenu_loadedFileIdx;
extern s8 filemenu_currentMenu;
extern s32 filemenu_8024C09C;
extern s32 filemenu_cursorHudElemID[1];
extern HudElemID filemenu_cursorHIDs[1];
extern s32 filemenu_8024C0A4[3];
extern s32 filemenu_hudElemIDs[20];
extern s32 filemenu_createfile_hudElems[4];
extern HudElemID filemenu_mainHIDs[20];
extern HudElemID filemenu_createfile_HIDs[4];
extern u8 filemenu_filename[8];

#if VERSION_PAL
extern s32 D_802517D0[1];
extern HudElemID PauseLanguageHIDs[1];
extern s32 D_802517D4[1];
extern u16 D_802517E0[2][0x400];
extern u8 D_filemenu_8025095C[4];
Expand Down
21 changes: 7 additions & 14 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,14 +796,7 @@ void basic_ai_chase(Evt* script, MobileAISettings* npcAISettings, EnemyDetectVol
void basic_ai_lose_player(Evt* script, MobileAISettings* npcAISettings, EnemyDetectVolume* territory);
void basic_ai_suspend(Evt* script);

// This legally allows all functions to be pointers without warnings.
// Perhaps the void arg functions can be changed later to remove this need.
typedef union {
void (*func1)(Evt*, s32);
void (*func2)(void);
} WorldArgs TRANSPARENT_UNION;

s32 create_worker_world(WorldArgs, WorldArgs);
s32 create_worker_scene(void (*updateFunc)(void), void (*renderFunc)(void));

void init_entity_models(void);
f32 phys_get_spin_history(s32 lag, s32* x, s32* y, s32* z);
Expand Down Expand Up @@ -961,10 +954,10 @@ void status_bar_respond_to_changes(void);
void status_bar_always_show_on(void);
void status_bar_always_show_off(void);
void func_800F0C9C(void);
void func_800F0CB0(s32, f32, f32, f32);
void func_800F0D5C(void);
void func_800F0D80(void);
void func_800F102C(void);
void star_power_shimmer_start(s32, f32, f32, f32);
void star_power_shimmer_init(void);
void star_power_shimmer_update(void);
void star_power_shimmer_draw(void);
s32 get_item_count(void);
s32 get_stored_empty_count(void);
s32 get_stored_count(void);
Expand Down Expand Up @@ -1020,8 +1013,8 @@ void init_encounters_ui(void);
void initialize_collision(void);
void render_entities(void);
void render_player(void);
void render_workers_world(void);
void render_effects_world(void);
void render_workers_scene(void);
void render_effects_scene(void);
s32 get_asset_offset(char*, s32*);
void initialize_status_bar(void);
void status_bar_start_blinking_fp(void);
Expand Down
4 changes: 4 additions & 0 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
#define SP_PER_BAR 256
#define SP_PER_SEG 32

#define AC_DIFFICULTY_LEN 8
typedef s32 Difficulty1D[AC_DIFFICULTY_LEN];
typedef s32 Difficulty2D[AC_DIFFICULTY_LEN][2];

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240

Expand Down
8 changes: 0 additions & 8 deletions include/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
#include "script_api/map.h"
#include "npc.h"

// temporary: some standard script names
#define EVS_MakeEntities EVS_MakeEntities
#define EVS_SetupMusic EVS_SetupMusic
#define EVS_SetupRooms EVS_SetupRooms
#define EVS_SetupFoliage EVS_SetupFoliage
#define EVS_BindExitTriggers EVS_BindExitTriggers
#define EVS_EnterMap EVS_EnterMap

#define CLONED_MODEL(idx) (10000+(idx))

// TODO: consider moving Npc here
Expand Down
4 changes: 2 additions & 2 deletions include/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ typedef struct EncounterStatus {
/* 0x008 */ s8 unk_08;
/* 0x009 */ s8 battleOutcome; // see enum: EncounterOutcomes
/* 0x00A */ s8 battleTriggerCooldown; ///< set to 15 after victory, 45 after fleeing
/* 0x00B */ b8 hasMerleeCoinBonus; /* triple coins when TRUE */
/* 0x00B */ s8 hasMerleeCoinBonus; /* triple coins when TRUE */
/* 0x00C */ u8 damageTaken; /* valid after battle */
/* 0x00D */ char unk_0D;
/* 0x00E */ s16 coinsEarned; /* valid after battle */
Expand Down Expand Up @@ -424,7 +424,7 @@ extern EncounterStatus gCurrentEncounter;

#endif

b32 basic_ai_check_player_dist(EnemyDetectVolume* arg0, Enemy* arg1, f32 arg2, f32 arg3, b8 arg4);
b32 basic_ai_check_player_dist(EnemyDetectVolume* arg0, Enemy* arg1, f32 arg2, f32 arg3, s8 arg4);

/// The default Npc::onUpdate and Npc::onRender callback.
void STUB_npc_callback(Npc*);
Expand Down
4 changes: 2 additions & 2 deletions include/script_api/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ API_CALLABLE(EnablePlayerBlur);
API_CALLABLE(PlayerBasicJumpToGoal);
API_CALLABLE(PlayerSuperJumpToGoal);
API_CALLABLE(PlayerUltraJumpToGoal);
API_CALLABLE(GetPlayerActionSuccess);
API_CALLABLE(GetPlayerActionQuality);
API_CALLABLE(BindTakeTurn);
API_CALLABLE(PauseTakeTurn);
API_CALLABLE(ResumeTakeTurn);
Expand Down Expand Up @@ -283,7 +283,7 @@ API_CALLABLE(SetBattleCamTargetingModes);
API_CALLABLE(UseBattleCamPresetImmediately);
API_CALLABLE(UseBattleCamPresetWait);
API_CALLABLE(HideHealthBar);
API_CALLABLE(GetPartnerActionSuccess);
API_CALLABLE(GetPartnerActionQuality);
API_CALLABLE(CreateNpc);
API_CALLABLE(EnableBattleStatusBar);
API_CALLABLE(PlayerYieldTurn);
Expand Down
2 changes: 1 addition & 1 deletion include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extern WindowStyle gWindowStyles[];
extern u16 gCurrentDoorSounds;
extern u16 gCurrentRoomDoorSounds;

extern b8 D_8014C248;
extern s8 D_8014C248;

extern UNK_FUN_PTR(TalkNotificationCallback);
extern UNK_FUN_PTR(InteractNotificationCallback);
Expand Down
Loading
Loading