diff --git a/include/common_structs.h b/include/common_structs.h index 52a9e571cd..c5af5ab8b1 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -619,13 +619,13 @@ typedef struct Shadow { typedef Shadow* ShadowList[MAX_SHADOWS]; -typedef struct DynamicEntity { +typedef struct Worker { /* 0x00 */ s32 flags; /* 0x04 */ void (*update)(void); /* 0x08 */ void (*draw)(void); -} DynamicEntity; +} Worker; -typedef DynamicEntity* DynamicEntityList[MAX_DYNAMIC_ENTITIES]; +typedef Worker* WorkerList[MAX_WORKERS]; typedef struct MusicSettings { /* 0x00 */ u16 flags; @@ -963,7 +963,7 @@ typedef struct BattleStatus { /* 0x330 */ s32 pushInputBuffer[64]; /* 0x430 */ s8 holdInputBufferPos; /* 0x431 */ s8 inputBufferPos; - /* 0x432 */ s8 unk_432; + /* 0x432 */ s8 darknessMode; /* 0x433 */ u8 unk_433; /* 0x434 */ s32* actionCmdDifficultyTable; /* 0x438 */ struct Stage* currentStage; diff --git a/include/dead.h b/include/dead.h index 31b557f962..5354c32c92 100644 --- a/include/dead.h +++ b/include/dead.h @@ -123,6 +123,6 @@ #define GetNextPathPos dead_GetNextPathPos #define queue_render_task dead_queue_render_task #define dma_copy dead_dma_copy -#define create_generic_entity_world dead_create_generic_entity_world +#define create_worker_world dead_create_worker_world #endif diff --git a/include/enums.h b/include/enums.h index 75ad77f2a9..892dd312c3 100644 --- a/include/enums.h +++ b/include/enums.h @@ -3090,6 +3090,14 @@ enum ItemEntityFlags { ITEM_ENTITY_FLAGS_80000000 = 0x80000000, }; +// Worker +enum WorkerFlags { + WORKER_FLAG_1 = 0x00000001, + WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE = 0x00000002, + WORKER_FLAG_FRONT_UI = 0x00000004, + WORKER_FLAG_BACK_UI = 0x00000008, +}; + enum Buttons { BUTTON_C_RIGHT = 0x00000001, BUTTON_C_LEFT = 0x00000002, @@ -5819,4 +5827,28 @@ enum EncounterPostBattleSubStates { ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_TO_NEUTRAL = 402, }; +enum PlayerSpriteSets { + PLAYER_SPRITES_MARIO_WORLD = 0, + PLAYER_SPRITES_MARIO_REFLECT_FLOOR = 1, + PLAYER_SPRITES_COMBINED_EPILOGUE = 2, + PLAYER_SPRITES_MARIO_PARADE = 3, + PLAYER_SPRITES_PEACH_WORLD = 4, + PLAYER_SPRITES_MARIO_BATTLE = 5, + PLAYER_SPRITES_PEACH_BATTLE = 6, +}; + +enum BattleDarknessMode { + BTL_DARKNESS_MODE_0 = 0, + BTL_DARKNESS_MODE_1 = 1, + BTL_DARKNESS_MODE_2 = 2, + BTL_DARKNESS_MODE_3 = 3, +}; + +enum BattleDarknessState { + BTL_DARKNESS_STATE_LOCKED = -2, + BTL_DARKNESS_STATE_DARK = -1, + BTL_DARKNESS_STATE_NONE = 0, + BTL_DARKNESS_STATE_WATT_BASED = 1, +}; + #endif diff --git a/include/functions.h b/include/functions.h index 200e91b19c..f87232a2a7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -498,8 +498,8 @@ s32 make_item_entity_nodelay(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, void set_item_entity_flags(s32 itemEntityIndex, s32 flag); void clear_item_entity_flags(s32 index, s32 flags); -s32 create_generic_entity_frontUI(void (*updateFunc)(void), void (*drawFunc)(void)); -DynamicEntity* get_generic_entity(s32 idx); +s32 create_worker_frontUI(void (*updateFunc)(void), void (*drawFunc)(void)); +Worker* get_worker(s32 idx); Trigger* bind_trigger_1(EvtScript* script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1, s32 priority); void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height); @@ -583,7 +583,7 @@ void start_bounce_b(void); void update_input(void); void update_max_rumble_duration(void); void func_8011BAE8(void); -void update_generic_entities(void); +void update_workers(void); void update_triggers(void); void update_scripts(void); void update_messages(void); @@ -597,12 +597,12 @@ void update_windows(void); void player_render_interact_prompts(void); void func_802C3EE4(void); void render_screen_overlay_backUI(void); -void render_generic_entities_backUI(void); +void render_workers_backUI(void); void render_effects_UI(void); void state_render_backUI(void); void render_window_root(void); void render_messages(void); -void render_generic_entities_frontUI(void); +void render_workers_frontUI(void); void render_screen_overlay_frontUI(void); void render_curtains(void); void state_render_frontUI(void); @@ -792,7 +792,7 @@ typedef union { void (*func2)(void); } WorldArgs TRANSPARENT_UNION; -s32 create_generic_entity_world(WorldArgs, WorldArgs); +s32 create_worker_world(WorldArgs, WorldArgs); void init_entity_models(void); EntityModel* get_entity_model(s32 idx); @@ -801,7 +801,7 @@ void fold_update(u32, FoldType, s32, s32, s32, s32, s32); s32 fold_appendGfx_component(s32, FoldImageRecPart*, u32, Matrix4f); void func_8013A6E8(void); s32 func_8013A704(s32); -void free_generic_entity(s32); +void free_worker(s32); s32 ai_check_fwd_collisions(Npc* npc, f32 arg1, f32* arg2, f32* arg3, f32* arg4, f32* arg5); void basic_ai_loiter_init(Evt* script, MobileAISettings* aiSettings, EnemyDetectVolume* territory); @@ -903,7 +903,7 @@ void remove_all_effects(void); void update_effects(void); void update_cameras(void); void clear_render_tasks(void); -void clear_generic_entity_list(void); +void clear_worker_list(void); void clear_printers(void); void clear_item_entity_data(void); void clear_player_data(void); @@ -1006,7 +1006,7 @@ void init_encounters_ui(void); void initialize_collision(void); void render_entities(void); void render_player(void); -void render_generic_entities_world(void); +void render_workers_world(void); void render_effects_world(void); s32 get_asset_offset(char*, s32*); void initialize_status_menu(void); diff --git a/include/macros.h b/include/macros.h index 6fa50be52b..f63088ec88 100644 --- a/include/macros.h +++ b/include/macros.h @@ -72,7 +72,7 @@ #define MAX_TRIGGERS 64 #define MAX_SHADOWS 60 #define MAX_ENTITIES 30 -#define MAX_DYNAMIC_ENTITIES 16 +#define MAX_WORKERS 16 #define MAX_TEX_PANNERS 16 #define MAX_ITEM_ENTITIES 256 @@ -108,6 +108,9 @@ #define BATTLE_ENTITY_ID_MASK 0x800 +#define UNPACK_BTL_AREA(battleID) (((battleID) >> 8) & 0xFF) +#define UNPACK_BTL_INDEX(battleID) ((battleID) & 0xFF) + #define COLLISION_WITH_NPC_BIT 0x2000 #define COLLISION_WITH_ENTITY_BIT 0x4000 diff --git a/include/model.h b/include/model.h index 9882b11951..cd4c50b19e 100644 --- a/include/model.h +++ b/include/model.h @@ -172,7 +172,7 @@ void animator_update_model_transforms(ModelAnimator* animator, Mtx* rootTransfor void render_animated_model(s32 animatorID, Mtx* rootTransform); void animator_node_update_model_transform(ModelAnimator* animator, f32 (*flipMtx)[4], AnimatorNode* node, Mtx* rootTransform); -void init_generic_entity_list(void); +void init_worker_list(void); ModelAnimator* get_animator_by_index(s32 animModelID); void reset_animator_list(void); void delete_model_animator_node(AnimatorNode* node); diff --git a/include/npc.h b/include/npc.h index 0e54f62f9a..ac3e4c4aba 100644 --- a/include/npc.h +++ b/include/npc.h @@ -600,7 +600,7 @@ void draw_encounter_ui(void); void draw_first_strike_ui(void); -void npc_dyn_entity_draw_no_op(void); +void npc_render_worker_do_nothing(void); void make_npcs(s32 flags, s32 mapID, s32* npcGroupList); diff --git a/include/variables.h b/include/variables.h index e441bd9f89..0477143673 100644 --- a/include/variables.h +++ b/include/variables.h @@ -23,9 +23,7 @@ extern s32 D_800DC4D4; extern s32 D_800DC4D8; extern s32 gBattleSubState; extern s32 D_800DC4E4; -extern s32 D_800DC4E8; -extern u8 gCurrentBattleSection; // in the middle of the previous var -extern u8 D_800DC4EB; // in the middle of the previous var +extern s32 gCurrentBattleID; extern s32 D_800DC4E0; extern s32 D_800DC4EC; extern s32 D_800DC4F0; @@ -38,9 +36,9 @@ extern EntityList gWorldEntityList; extern EntityList gBattleEntityList; extern EntityList* gCurrentEntityListPtr; -extern DynamicEntityList gWorldDynamicEntityList; -extern DynamicEntityList gBattleDynamicEntityList; -extern DynamicEntityList* gCurrentDynamicEntityListPtr; +extern WorkerList gWorldWorkerList; +extern WorkerList gBattleWorkerList; +extern WorkerList* gCurrentWorkerListPtr; extern NpcList gWorldNpcList; extern NpcList gBattleNpcList; diff --git a/src/16F740.c b/src/16F740.c index 5d85473d5b..28bca99ccc 100644 --- a/src/16F740.c +++ b/src/16F740.c @@ -289,7 +289,7 @@ void btl_state_update_normal_start(void) { battleStatus->unk_8C = 0; battleStatus->merleeAttackBoost = 0; battleStatus->merleeDefenseBoost = 0; - battleStatus->unk_432 = 0; + battleStatus->darknessMode = BTL_DARKNESS_STATE_NONE; battleStatus->unk_433 = -1; battleStatus->hustleTurns = 0; battleStatus->unk_93 = 0; @@ -420,7 +420,7 @@ void btl_state_update_normal_start(void) { battleStatus->controlScript = script; battleStatus->controlScriptID = script->id; } - if (battleStatus->unk_432 > 0) { + if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) { set_screen_overlay_color(1, 0, 0, 0); set_screen_overlay_params_back(0, 215.0f); } diff --git a/src/16c8e0.c b/src/16c8e0.c index fcd50dca69..92b4c63fed 100644 --- a/src/16c8e0.c +++ b/src/16c8e0.c @@ -200,7 +200,7 @@ void initialize_battle(void) { gBattleStatus.flags2 &= ~BS_FLAGS2_40; } - create_generic_entity_world(NULL, func_8023ED5C); + create_worker_world(NULL, func_8023ED5C); btl_popup_messages_init(); func_80268E88(); set_windows_visible(WINDOW_GROUP_1); @@ -415,13 +415,13 @@ void btl_update(void) { btl_popup_messages_update(); update_actor_shadows(); - if (battleStatus->unk_432 != -2) { + if (battleStatus->darknessMode != BTL_DARKNESS_STATE_LOCKED) { u8 paramType; f32 paramAmount; get_screen_overlay_params(1, ¶mType, ¶mAmount); - if (battleStatus->unk_432 > 0) { + if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) { set_screen_overlay_color(1, 0, 0, 0); if (partner == NULL) { set_screen_overlay_params_back(0, 215.0f); @@ -438,12 +438,12 @@ void btl_update(void) { } set_screen_overlay_params_back(0, paramAmount); } - } else if (battleStatus->unk_432 < 0) { + } else if (battleStatus->darknessMode < BTL_DARKNESS_STATE_NONE) { paramAmount -= 10.0f; if (paramAmount < 0.0f) { paramAmount = 0.0f; - set_screen_overlay_params_back(0xFF, -1.0f); - battleStatus->unk_432 = 0; + set_screen_overlay_params_back(255, -1.0f); + battleStatus->darknessMode = BTL_DARKNESS_STATE_NONE; } else { set_screen_overlay_params_back(0, paramAmount); } @@ -456,19 +456,19 @@ void btl_update(void) { f32 paramAmount; get_screen_overlay_params(0, ¶mType, ¶mAmount); - if (paramType == 0xFF) { + if (paramType == 255) { D_802809F6 = 0; set_screen_overlay_params_front(0, 0.0f); } } - } else if (D_802809F6 == 0xFF) { + } else if (D_802809F6 == 255) { if (gBattleState != BATTLE_STATE_END_DEMO_BATTLE) { btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); } } else { D_802809F6 += 10; - if (D_802809F6 > 0xFF) { - D_802809F6 = 0xFF; + if (D_802809F6 > 255) { + D_802809F6 = 255; } set_screen_overlay_params_front(0, D_802809F6); diff --git a/src/181810.c b/src/181810.c index bf2abf5421..a7a4966d47 100644 --- a/src/181810.c +++ b/src/181810.c @@ -227,16 +227,18 @@ ApiStatus OverrideBattleDmaDest(Evt* script, s32 isInitialCall) { } ApiStatus LoadBattleDmaData(Evt* script, s32 isInitialCall) { - DmaTable* moveScript = &gBattleAreas[gCurrentBattleSection].dmaTable[evt_get_variable(script, *script->ptrReadPos)]; + s32 dmaIndex = evt_get_variable(script, *script->ptrReadPos); + BattleArea* battleArea = &gBattleAreas[UNPACK_BTL_AREA(gCurrentBattleID)]; + DmaTable* dmaEntry = &battleArea->dmaTable[dmaIndex]; - if (moveScript == NULL) { + if (dmaEntry == NULL) { return ApiStatus_DONE2; } if (gBattleDmaDest == NULL) { - dma_copy(moveScript->start, moveScript->end, moveScript->dest); + dma_copy(dmaEntry->start, dmaEntry->end, dmaEntry->dest); } else { - dma_copy(moveScript->start, moveScript->end, gBattleDmaDest); + dma_copy(dmaEntry->start, dmaEntry->end, gBattleDmaDest); } return ApiStatus_DONE2; @@ -262,17 +264,17 @@ ApiStatus func_80253734(Evt* script, s32 isInitialCall) { s32 val = evt_get_variable(script, *script->ptrReadPos); switch (val) { - case 0: - battleStatus->unk_432 = -1; + case BTL_DARKNESS_MODE_0: + battleStatus->darknessMode = BTL_DARKNESS_STATE_DARK; break; - case 1: - battleStatus->unk_432 = 1; + case BTL_DARKNESS_MODE_1: + battleStatus->darknessMode = BTL_DARKNESS_STATE_WATT_BASED; break; - case 2: - battleStatus->unk_432 = -2; + case BTL_DARKNESS_MODE_2: + battleStatus->darknessMode = BTL_DARKNESS_STATE_LOCKED; break; - case 3: - battleStatus->unk_432 = 1; + case BTL_DARKNESS_MODE_3: + battleStatus->darknessMode = BTL_DARKNESS_STATE_WATT_BASED; break; } diff --git a/src/8800.c b/src/8800.c index c3cc658096..33a05e1551 100644 --- a/src/8800.c +++ b/src/8800.c @@ -195,7 +195,7 @@ void render_frame(s32 flag) { } render_player(); render_npcs(); - render_generic_entities_world(); + render_workers_world(); render_effects_world(); execute_render_tasks(); render_hud_elements_world(); @@ -209,7 +209,7 @@ void render_frame(s32 flag) { render_item_entities(); } } else { - render_generic_entities_world(); + render_workers_world(); execute_render_tasks(); } diff --git a/src/8a860_len_3f30.c b/src/8a860_len_3f30.c index 3b8ef84b7a..3e10ac80c4 100644 --- a/src/8a860_len_3f30.c +++ b/src/8a860_len_3f30.c @@ -805,12 +805,12 @@ s32 popup_menu_update(void) { break; } destroy_popup_menu(); - free_generic_entity(D_8010D694); + free_worker(D_8010D694); D_8010D640 = -5; gPopupMenu->result = 255; return 255; case -4: - free_generic_entity(D_8010D694); + free_worker(D_8010D694); D_8010D640 = -5; gPopupMenu->result = 255; return 255; @@ -1258,7 +1258,7 @@ void create_popup_menu(PopupMenu* popup) { D_8010D650 = 255; D_8010D691 = 4; D_8010D692 = 6; - D_8010D694 = create_generic_entity_frontUI(popup_menu_update, NULL); + D_8010D694 = create_worker_frontUI(popup_menu_update, NULL); } void func_800F4FC4(PopupMenu* popup) { @@ -1303,7 +1303,7 @@ void func_800F4FC4(PopupMenu* popup) { D_8010D650 = 255; D_8010D691 = 4; D_8010D692 = 6; - D_8010D694 = create_generic_entity_frontUI(popup_menu_update, NULL); + D_8010D694 = create_worker_frontUI(popup_menu_update, NULL); } void func_800F513C(PopupMenu* popup) { @@ -1347,7 +1347,7 @@ void func_800F513C(PopupMenu* popup) { D_8010D650 = 255; D_8010D691 = 9; D_8010D692 = 2; - D_8010D694 = create_generic_entity_frontUI(popup_menu_update, NULL); + D_8010D694 = create_worker_frontUI(popup_menu_update, NULL); } void func_800F52BC(void) { diff --git a/src/C50A0.c b/src/C50A0.c index 9b38078bae..ff3f129270 100644 --- a/src/C50A0.c +++ b/src/C50A0.c @@ -743,8 +743,8 @@ void clear_item_entity_data(void) { ItemEntityRenderGroup = 0; } - create_generic_entity_world(NULL, draw_item_entities); - create_generic_entity_frontUI(NULL, draw_item_entities_UI); + create_worker_world(NULL, draw_item_entities); + create_worker_frontUI(NULL, draw_item_entities_UI); isPickingUpItem = FALSE; D_801565A8 = 0; } diff --git a/src/battle/action_cmd.c b/src/battle/action_cmd.c index 90f63f39cc..f0678f6262 100644 --- a/src/battle/action_cmd.c +++ b/src/battle/action_cmd.c @@ -526,7 +526,7 @@ void action_command_free(void) { void func_80268E88(void) { ActionCommandStatus* actionCmdStatus = &gActionCommandStatus; - actionCmdStatus->workerID = create_generic_entity_frontUI(action_command_update, action_command_draw); + actionCmdStatus->workerID = create_worker_frontUI(action_command_update, action_command_draw); actionCmdStatus->actionCommandID = 0; } diff --git a/src/battle/area_kgr/actor/fuzzipede.c b/src/battle/area_kgr/actor/fuzzipede.c index 6764ab72c7..bd6ac22e49 100644 --- a/src/battle/area_kgr/actor/fuzzipede.c +++ b/src/battle/area_kgr/actor/fuzzipede.c @@ -134,7 +134,7 @@ EvtScript N(init_80218B70) = { EVT_CALL(SetActorPos, ACTOR_SELF, 125, 33, -15) EVT_CALL(SetHomePos, ACTOR_SELF, 125, 33, -15) EVT_CALL(HPBarToHome, ACTOR_SELF) - EVT_CALL(func_80253734, 1) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_kpa/stage/kpa_03.c b/src/battle/area_kpa/stage/kpa_03.c index e5c6a8249d..cf48c94dec 100644 --- a/src/battle/area_kpa/stage/kpa_03.c +++ b/src/battle/area_kpa/stage/kpa_03.c @@ -6,9 +6,9 @@ #define NAMESPACE b_area_kpa_kpa_03 EvtScript N(beforeBattle) = { - EVT_CALL(SetSpriteShading, -1) - EVT_CALL(SetCamBGColor, 1, 0, 0, 0) - EVT_CALL(func_80253734, 1) + EVT_CALL(SetSpriteShading, SHADING_NONE) + EVT_CALL(SetCamBGColor, CAM_BATTLE, 0, 0, 0) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_kpa4/stage/kpa_03.c b/src/battle/area_kpa4/stage/kpa_03.c index a9fb693873..ab43f5151b 100644 --- a/src/battle/area_kpa4/stage/kpa_03.c +++ b/src/battle/area_kpa4/stage/kpa_03.c @@ -6,9 +6,9 @@ #define NAMESPACE b_area_kpa4_kpa_03 EvtScript N(beforeBattle) = { - EVT_CALL(SetSpriteShading, -1) - EVT_CALL(SetCamBGColor, 1, 0, 0, 0) - EVT_CALL(func_80253734, 1) + EVT_CALL(SetSpriteShading, SHADING_NONE) + EVT_CALL(SetCamBGColor, CAM_BATTLE, 0, 0, 0) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_kzn2/actor/lava_piranha.c b/src/battle/area_kzn2/actor/lava_piranha.c index 2ed54cd8e1..112d9dc718 100644 --- a/src/battle/area_kzn2/actor/lava_piranha.c +++ b/src/battle/area_kzn2/actor/lava_piranha.c @@ -523,7 +523,7 @@ API_CALLABLE(N(MarkVineInterpolationDirty)) { API_CALLABLE(N(CreateVineRenderer)) { N(VineRenderState) = -1; - create_generic_entity_world(NULL, &N(worker_render_piranha_vines)); + create_worker_world(NULL, &N(worker_render_piranha_vines)); return ApiStatus_DONE2; } diff --git a/src/battle/area_omo2/actor/general_guy.c b/src/battle/area_omo2/actor/general_guy.c index 7ea4bf82de..d4c1139364 100644 --- a/src/battle/area_omo2/actor/general_guy.c +++ b/src/battle/area_omo2/actor/general_guy.c @@ -430,7 +430,7 @@ EvtScript N(attack_lightning_shot) = { EVT_WAIT(10) EVT_CALL(GetActorVar, ACTOR_ENEMY1, 7, LVar0) EVT_IF_NE(LVar0, 0) - EVT_CALL(func_80253734, 2) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_2) EVT_END_IF EVT_CALL(SetAnimation, ACTOR_SELF, 1, ANIM_GeneralGuy_Anim03) EVT_WAIT(20) @@ -479,7 +479,7 @@ EvtScript N(attack_lightning_shot) = { EVT_END_IF EVT_CALL(GetActorVar, ACTOR_ENEMY1, 7, LVar0) EVT_IF_NE(LVar0, 0) - EVT_CALL(func_80253734, 3) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_3) EVT_END_IF EVT_CALL(N(UnfadeBackgroundToBlack)) EVT_CALL(SetAnimation, ACTOR_ENEMY0, 1, ANIM_GeneralGuy_Anim02) @@ -508,7 +508,7 @@ EvtScript N(attack_lightning_shot) = { EVT_WAIT(12) EVT_CALL(GetActorVar, ACTOR_ENEMY1, 7, LVar0) EVT_IF_NE(LVar0, 0) - EVT_CALL(func_80253734, 3) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_3) EVT_END_IF EVT_CALL(N(UnfadeBackgroundToBlack)) EVT_CALL(SetAnimation, ACTOR_ENEMY0, 1, ANIM_GeneralGuy_Anim02) @@ -556,7 +556,7 @@ EvtScript N(attack_lightning_shot) = { EVT_CALL(EnemyDamageTarget, ACTOR_SELF, LVarF, DAMAGE_TYPE_ELECTRIC | DAMAGE_TYPE_NO_CONTACT, 0, 0, 2, BS_FLAGS1_SP_EVT_ACTIVE) EVT_CALL(GetActorVar, ACTOR_ENEMY1, 7, LVar0) EVT_IF_NE(LVar0, 0) - EVT_CALL(func_80253734, 3) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_3) EVT_END_IF EVT_CALL(N(UnfadeBackgroundToBlack)) EVT_CALL(SetAnimation, ACTOR_ENEMY0, 1, ANIM_GeneralGuy_Anim02) diff --git a/src/battle/area_omo2/actor/toy_tank.c b/src/battle/area_omo2/actor/toy_tank.c index 24f366a776..bb0c877ac7 100644 --- a/src/battle/area_omo2/actor/toy_tank.c +++ b/src/battle/area_omo2/actor/toy_tank.c @@ -643,7 +643,7 @@ EvtScript N(summon_tank_squad) = { EVT_CALL(SetAnimation, ACTOR_ENEMY0, 1, ANIM_GeneralGuy_Anim03) EVT_CALL(SetActorVar, ACTOR_SELF, 6, 0) EVT_WAIT(10) - EVT_CALL(func_80253734, 1) + EVT_CALL(func_80253734, BTL_DARKNESS_MODE_1) EVT_CALL(SetActorVar, ACTOR_SELF, 7, 1) EVT_EXEC(N(8022F2BC)) EVT_WAIT(30) diff --git a/src/battle/battle.c b/src/battle/battle.c index afb335d542..63ef600d62 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -286,7 +286,7 @@ void reset_battle_status(void) { D_800DC4D4 = 0; D_800DC4FC = NULL; D_800DC4F8 = 0; - D_800DC4E8 = 0; + gCurrentBattleID = 0; D_800DC064 = NULL; D_800DC060 = 0; D_800DC4EC = 0; @@ -302,8 +302,8 @@ void func_80072BCC(s32 arg0) { } void load_battle_section(void) { - BattleArea* battleArea = &gBattleAreas[gCurrentBattleSection]; - s32 battleIdx = D_800DC4EB; + BattleArea* battleArea = &gBattleAreas[UNPACK_BTL_AREA(gCurrentBattleID)]; + s32 battleIdx = UNPACK_BTL_INDEX(gCurrentBattleID); dma_copy(battleArea->dmaStart, battleArea->dmaEnd, battleArea->dmaDest); @@ -319,8 +319,8 @@ void load_battle_section(void) { D_800DC4D0 = 0; } -void load_battle(s32 arg0) { - D_800DC4E8 = arg0; +void load_battle(s32 battleID) { + gCurrentBattleID = battleID; set_game_mode(GAME_MODE_BATTLE); gBattleState = 0; D_800DC4D0 = 0; @@ -398,10 +398,10 @@ void load_demo_battle(u32 index) { gGameStatusPtr->isBattle = FALSE; general_heap_create(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_animator_list(); clear_entity_models(); clear_npcs(); diff --git a/src/battle/item/coconut.c b/src/battle/item/coconut.c index 9bbf168792..6568c387db 100644 --- a/src/battle/item/coconut.c +++ b/src/battle/item/coconut.c @@ -1,4 +1,5 @@ #include "coconut.h" +#include "entity.h" #include "ld_addrs.h" #include "battle/item/coconut.png.h" @@ -41,12 +42,10 @@ Gfx N(displayList)[] = { gsSPEndDisplayList(), }; -s32 N(modelCommandList)[] = { - 0x00000004, 0x0000000D, 0x00000001, sizeof(N(displayList)) / sizeof(s32), (s32) &N(displayList), 0x00000002, 0x00000000, -}; +EntityModelScript N(modelCommandList) = STANDARD_ENTITY_MODEL_SCRIPT(N(displayList), RENDER_MODE_ALPHATEST);; EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0x000000AC) + EVT_SET_CONST(LVarA, ITEM_COCONUT) EVT_EXEC_WAIT(N(UseItemWithEffect)) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_D) EVT_CALL(MoveBattleCamOver, 15) diff --git a/src/battle/item/dizzy_dial.c b/src/battle/item/dizzy_dial.c index 04885b4818..34c08c5e04 100644 --- a/src/battle/item/dizzy_dial.c +++ b/src/battle/item/dizzy_dial.c @@ -23,7 +23,7 @@ ApiStatus N(func_802A1270_727B80)(Evt* script, s32 isInitialCall) { script->functionTemp[2] = 0; sfx_play_sound(SOUND_2033); camera->auxPitch = 0; - D_802A1CD0 = create_generic_entity_frontUI(NULL, func_802A123C_727B4C); + D_802A1CD0 = create_worker_frontUI(NULL, func_802A123C_727B4C); script->functionTemp[0] = 1; case 1: camera->flags |= CAMERA_FLAGS_SHAKING; @@ -36,7 +36,7 @@ ApiStatus N(func_802A1270_727B80)(Evt* script, s32 isInitialCall) { } camera->auxPitch = 0; camera->flags &= ~CAMERA_FLAGS_SHAKING; - free_generic_entity(D_802A1CD0); + free_worker(D_802A1CD0); return ApiStatus_DONE2; } diff --git a/src/battle/item/dusty_hammer.c b/src/battle/item/dusty_hammer.c index f33c647e30..79fba29afc 100644 --- a/src/battle/item/dusty_hammer.c +++ b/src/battle/item/dusty_hammer.c @@ -1,4 +1,5 @@ #include "dusty_hammer.h" +#include "entity.h" #include "ld_addrs.h" #include "battle/item/dusty_hammer.png.h" @@ -40,12 +41,10 @@ Gfx N(displayList)[] = { gsSPEndDisplayList(), }; -s32 N(modelCommandList)[] = { - 0x00000004, 0x0000000D, 0x00000001, sizeof(N(displayList)) / sizeof(s32), (s32) &N(displayList), 0x00000002, 0x00000000, -}; +EntityModelScript N(modelCommandList) = STANDARD_ENTITY_MODEL_SCRIPT(N(displayList), RENDER_MODE_ALPHATEST);; EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0x00000086) + EVT_SET_CONST(LVarA, ITEM_DUSTY_HAMMER) EVT_EXEC_WAIT(N(UseItemWithEffect)) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_D) EVT_CALL(MoveBattleCamOver, 15) diff --git a/src/battle/item/egg_missile.c b/src/battle/item/egg_missile.c index 472913fe85..7a71f04da9 100644 --- a/src/battle/item/egg_missile.c +++ b/src/battle/item/egg_missile.c @@ -1,5 +1,6 @@ #include "egg_missile.h" #include "effects.h" +#include "entity.h" #include "ld_addrs.h" #include "battle/item/egg_missile1.png.h" #include "battle/item/egg_missile2.png.h" @@ -128,26 +129,27 @@ Gfx N(frame4_displayList)[] = { gsSPEndDisplayList(), }; -s32 N(modelCommandList)[] = { - 0x00000004, 0x0000000D, - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000001, 0x00000002, (s32) &N(frame2_displayList), - 0x00000001, 0x00000002, (s32) &N(frame3_displayList), - 0x00000002, 0x00000000, - 0x00000004, 0x0000000D, - 0x00000001, sizeof(N(frame4_displayList)) / sizeof(s32), (s32) &N(frame4_displayList), - 0x00000002, 0x00000000, +EntityModelScript N(modelCommandList) = { + ems_SetRenderMode(RENDER_MODE_ALPHATEST) + ems_Draw(N(frame1_displayList), 2) + ems_Draw(N(frame2_displayList), 2) + ems_Draw(N(frame3_displayList), 2) + ems_Restart + ems_End }; +EntityModelScript unusedModelScript = STANDARD_ENTITY_MODEL_SCRIPT( + N(frame4_displayList), RENDER_MODE_ALPHATEST); + EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0xC8) + EVT_SET_CONST(LVarA, ITEM_EGG_MISSILE) EVT_EXEC_WAIT(battle_item_egg_missile_UseItemWithEffect) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_D) EVT_CALL(MoveBattleCamOver, 15) EVT_CALL(SetAnimation, 0, 0, 65558) EVT_CALL(PlaySound, 1018) EVT_WAIT(3) - EVT_CALL(CreateVirtualEntity, LVarA, (s32) battle_item_egg_missile_modelCommandList) + EVT_CALL(CreateVirtualEntity, LVarA, EVT_PTR(battle_item_egg_missile_modelCommandList)) EVT_CALL(GetActorPos, 0, LVar0, LVar1, LVar2) EVT_ADD(LVar0, 20) EVT_ADD(LVar1, 42) diff --git a/src/battle/item/insecticide_herb.c b/src/battle/item/insecticide_herb.c index 1617f59a63..6ff534a694 100644 --- a/src/battle/item/insecticide_herb.c +++ b/src/battle/item/insecticide_herb.c @@ -1,5 +1,6 @@ #include "insecticide_herb.h" #include "effects.h" +#include "entity.h" #include "ld_addrs.h" #include "battle/item/insecticide_herb.png.h" @@ -84,12 +85,11 @@ Gfx N(displayList)[] = { gsSPEndDisplayList(), }; -s32 N(modelCommandList)[] = { - 0x00000004, 0x0000000D, 0x00000001, sizeof(N(displayList)) / sizeof(s32), &N(displayList), 0x00000002, 0x00000000, -}; +EntityModelScript N(modelCommandList) = STANDARD_ENTITY_MODEL_SCRIPT(N(displayList), RENDER_MODE_ALPHATEST);; + EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0x00000087) + EVT_SET_CONST(LVarA, ITEM_INSECTICIDE_HERB) EVT_EXEC_WAIT(N(UseItemWithEffect)) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_D) EVT_CALL(MoveBattleCamOver, 15) diff --git a/src/battle/item/mystery.c b/src/battle/item/mystery.c index 080c5fb34d..36de2cc451 100644 --- a/src/battle/item/mystery.c +++ b/src/battle/item/mystery.c @@ -1,5 +1,6 @@ #include "mystery.h" #include "effects.h" +#include "entity.h" #include "ld_addrs.h" #include "battle/item/mystery.png.h" @@ -53,12 +54,12 @@ s32 N(func_802A13E4_72C994)(Evt* script, s32 isInitialCall) { switch (D_802A25E4) { case 0: - D_802A25F8 = create_generic_entity_frontUI(NULL, N(func_802A123C_72C7EC)); + D_802A25F8 = create_worker_frontUI(NULL, N(func_802A123C_72C7EC)); D_802A25EC = rand_int(18200); D_802A25F0 = 1000; D_802A25FC = N(D_802A227C_72D82C); - if (battleStatus->unk_432 > 0) { + if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) { u8 type; f32 zoom; @@ -149,7 +150,7 @@ s32 N(func_802A13E4_72C994)(Evt* script, s32 isInitialCall) { var_v0_3 = i = D_802A25E8 / 26; // use of i required to match battleStatus->selectedItemID = D_802A25FC[D_802A25E8 / 26]; script->varTable[0] = battleStatus->selectedItemID; - free_generic_entity(D_802A25F8); + free_worker(D_802A25F8); for (i = 0; i < ARRAY_COUNT(D_802A25C8); i++) { hud_element_free(D_802A25C8[i]); } @@ -205,22 +206,32 @@ Gfx N(displayList)[] = { gsSPEndDisplayList(), }; -s32 N(modelCommandList)[] = { - 0x00000004, 0x0000000D, 0x00000001, sizeof(N(displayList)) / sizeof(s32), (s32) &N(displayList), 0x00000002, 0x00000000, -}; +EntityModelScript N(modelCommandList) = STANDARD_ENTITY_MODEL_SCRIPT(N(displayList), RENDER_MODE_ALPHATEST);; s32 N(D_802A227C_72D82C)[8] = { - 0x0000008A, 0x0000008C, 0x00000080, 0x00000088, - 0x0000009A, 0x00000082, 0x00000085, 0x0000008A + ITEM_MUSHROOM, + ITEM_SUPER_SHROOM, + ITEM_FIRE_FLOWER, + ITEM_STONE_CAP, + ITEM_DIZZY_DIAL, + ITEM_THUNDER_RAGE, + ITEM_PEBBLE, + ITEM_MUSHROOM }; s32 N(D_802A229C_72D84C)[8] = { - 0x0000008A, 0x0000008C, 0x00000085, 0x00000088, - 0x0000008A, 0x0000008C, 0x00000085, 0x0000008A + ITEM_MUSHROOM, + ITEM_SUPER_SHROOM, + ITEM_PEBBLE, + ITEM_STONE_CAP, + ITEM_MUSHROOM, + ITEM_SUPER_SHROOM, + ITEM_PEBBLE, + ITEM_MUSHROOM }; EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0x00000096) + EVT_SET_CONST(LVarA, ITEM_MYSTERY) EVT_EXEC_WAIT(N(UseItemWithEffect)) EVT_THREAD EVT_WAIT(220) diff --git a/src/battle/item/pebble.c b/src/battle/item/pebble.c index 585297bf40..9135d9600b 100644 --- a/src/battle/item/pebble.c +++ b/src/battle/item/pebble.c @@ -45,7 +45,7 @@ s32 N(modelCommandList)[] = { }; EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0x00000085) + EVT_SET_CONST(LVarA, ITEM_PEBBLE) EVT_EXEC_WAIT(N(UseItemWithEffect)) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_D) EVT_CALL(MoveBattleCamOver, 15) diff --git a/src/battle/item/sleepy_sheep.c b/src/battle/item/sleepy_sheep.c index 8289e098e0..1c2a4c2e0e 100644 --- a/src/battle/item/sleepy_sheep.c +++ b/src/battle/item/sleepy_sheep.c @@ -1,4 +1,5 @@ #include "sleepy_sheep.h" +#include "entity.h" #include "ld_addrs.h" #include "battle/item/sleepy_sheep1.png.h" #include "battle/item/sleepy_sheep2.png.h" @@ -312,31 +313,38 @@ Gfx N(frame3_displayList)[] = { gsSPEndDisplayList(), }; -s32 N(modelCommandList)[] = { - 0x00000004, 0x0000000D, - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000001, 0x00000003, (s32) &N(frame2_displayList), - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000001, 0x00000002, (s32) &N(frame3_displayList), - 0x00000002, 0x00000000, +EntityModelScript N(modelCommandList) = { + ems_SetRenderMode(RENDER_MODE_ALPHATEST) + ems_Draw(N(frame1_displayList), 2) + ems_Draw(N(frame2_displayList), 3) + ems_Draw(N(frame1_displayList), 2) + ems_Draw(N(frame3_displayList), 2) + ems_Restart + ems_End +}; - 0x00000004, 0x0000000D, - 0x00000001, 0x00000003, (s32) &N(frame2_displayList), - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000001, 0x00000002, (s32) &N(frame3_displayList), - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000002, 0x00000000, +EntityModelScript N(modelCommandList_unused1) = { + ems_SetRenderMode(RENDER_MODE_ALPHATEST) + ems_Draw(N(frame2_displayList),3) + ems_Draw(N(frame1_displayList),2) + ems_Draw(N(frame3_displayList),2) + ems_Draw(N(frame1_displayList),2) + ems_Restart + ems_End +}; - 0x00000004, 0x0000000D, - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000001, 0x00000002, (s32) &N(frame3_displayList), - 0x00000001, 0x00000002, (s32) &N(frame1_displayList), - 0x00000001, 0x00000003, (s32) &N(frame2_displayList), - 0x00000002, 0x00000000, +EntityModelScript N(modelCommandList_unused2) = { + ems_SetRenderMode(RENDER_MODE_ALPHATEST) + ems_Draw(N(frame1_displayList), 2) + ems_Draw(N(frame3_displayList), 2) + ems_Draw(N(frame1_displayList), 2) + ems_Draw(N(frame2_displayList), 3) + ems_Restart + ems_End }; EvtScript N(main) = { - EVT_SET_CONST(LVarA, 0x0000008F) + EVT_SET_CONST(LVarA, ITEM_SLEEPY_SHEEP) EVT_EXEC_WAIT(N(UseItemWithEffect)) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_19) EVT_CALL(SetBattleCamTarget, -67, -15, -5) diff --git a/src/battle/item/strange_cake.c b/src/battle/item/strange_cake.c index f6dd6d0382..ffbd74f66f 100644 --- a/src/battle/item/strange_cake.c +++ b/src/battle/item/strange_cake.c @@ -56,7 +56,7 @@ s32 N(func_802A13E4_7316E4)(Evt* script, s32 isInitialCall) { switch (D_802A2DEC) { case 0: - D_802A2E00 = create_generic_entity_frontUI(NULL, N(func_802A123C_73153C)); + D_802A2E00 = create_worker_frontUI(NULL, N(func_802A123C_73153C)); D_802A2DF4 = rand_int(13000); D_802A2DF8 = 1000; @@ -142,7 +142,7 @@ s32 N(func_802A13E4_7316E4)(Evt* script, s32 isInitialCall) { var_v0_3 = i = D_802A2DF0 / 26; // use of i required to match battleStatus->selectedItemID = N(D_802A2858_732B58)[var_v0_3]; script->varTable[0] = battleStatus->selectedItemID; - free_generic_entity(D_802A2E00); + free_worker(D_802A2E00); for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) { hud_element_free(D_802A2DD8[i]); } diff --git a/src/entity_model.c b/src/entity_model.c index a0ff832151..16ed9230d8 100644 --- a/src/entity_model.c +++ b/src/entity_model.c @@ -40,7 +40,6 @@ extern Gfx D_8014BF18[]; extern Gfx D_8014BF40[]; extern Gfx D_8014BF68[]; - s32 step_entity_model_commandlist(EntityModel* entityModel); void free_entity_model_by_ref(EntityModel* entityModel); @@ -836,188 +835,3 @@ void get_entity_fog_color(s32* r, s32* g, s32* b, s32* a) { *b = entity_fog_blue; *a = entity_fog_alpha; } - -void stub_generic_entity_delegate(void) { -} - -void clear_generic_entity_list(void) { - s32 i; - - if (!gGameStatusPtr->isBattle) { - gCurrentDynamicEntityListPtr = &gWorldDynamicEntityList; - } else { - gCurrentDynamicEntityListPtr = &gBattleDynamicEntityList; - } - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - (*gCurrentDynamicEntityListPtr)[i] = NULL; - } -} - -void init_generic_entity_list(void) { - if (!gGameStatusPtr->isBattle) { - gCurrentDynamicEntityListPtr = &gWorldDynamicEntityList; - } else { - gCurrentDynamicEntityListPtr = &gBattleDynamicEntityList; - } -} - -s32 create_generic_entity_world(void (*updateFunc)(void), void (*drawFunc)(void)) { - s32 i; - DynamicEntity* newDynEntity; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* dynEntity = (*gCurrentDynamicEntityListPtr)[i]; - if (dynEntity == NULL) { - break; - } - } - ASSERT(i < MAX_DYNAMIC_ENTITIES); - - (*gCurrentDynamicEntityListPtr)[i] = newDynEntity = heap_malloc(sizeof(*newDynEntity)); - ASSERT(newDynEntity != NULL); - - newDynEntity->flags = ENTITY_FLAGS_HIDDEN | ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1; - newDynEntity->update = updateFunc; - if (updateFunc == NULL) { - newDynEntity->update = stub_generic_entity_delegate; - } - newDynEntity->draw = drawFunc; - if (drawFunc == NULL) { - newDynEntity->draw = stub_generic_entity_delegate; - } - - if (gGameStatusPtr->isBattle) { - i |= BATTLE_ENTITY_ID_MASK; - } - return i; -} - -s32 create_generic_entity_frontUI(void (*updateFunc)(void), void (*drawFunc)(void)) { - s32 i; - DynamicEntity* newDynEntity; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* dynEntity = (*gCurrentDynamicEntityListPtr)[i]; - if (dynEntity == NULL) { - break; - } - } - ASSERT(i < MAX_DYNAMIC_ENTITIES); - - (*gCurrentDynamicEntityListPtr)[i] = newDynEntity = heap_malloc(sizeof(*newDynEntity)); - ASSERT(newDynEntity != NULL); - - newDynEntity->flags = ENTITY_FLAGS_HIDDEN | ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1 | ENTITY_FLAGS_HAS_DYNAMIC_SHADOW; - newDynEntity->update = updateFunc; - if (updateFunc == NULL) { - newDynEntity->update = stub_generic_entity_delegate; - } - newDynEntity->draw = drawFunc; - if (drawFunc == NULL) { - newDynEntity->draw = stub_generic_entity_delegate; - } - - if (gGameStatusPtr->isBattle) { - i |= BATTLE_ENTITY_ID_MASK; - } - return i; -} - -s32 create_generic_entity_backUI(void (*updateFunc)(void), void (*drawFunc)(void)) { - s32 i; - DynamicEntity* newDynEntity; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* dynEntity = (*gCurrentDynamicEntityListPtr)[i]; - if (dynEntity == NULL) { - break; - } - } - ASSERT(i < MAX_DYNAMIC_ENTITIES); - - (*gCurrentDynamicEntityListPtr)[i] = newDynEntity = heap_malloc(sizeof(*newDynEntity)); - ASSERT(newDynEntity != NULL); - - newDynEntity->flags = ENTITY_FLAGS_HIDDEN | ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1 | ENTITY_FLAGS_HAS_ANIMATED_MODEL; - newDynEntity->update = updateFunc; - if (updateFunc == NULL) { - newDynEntity->update = &stub_generic_entity_delegate; - } - newDynEntity->draw = drawFunc; - if (drawFunc == NULL) { - newDynEntity->draw = &stub_generic_entity_delegate; - } - - if (gGameStatusPtr->isBattle) { - i |= BATTLE_ENTITY_ID_MASK; - } - return i; -} - -void update_generic_entities(void) { - s32 i; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* entity = (*gCurrentDynamicEntityListPtr)[i]; - if (entity != NULL) { - entity->flags &= ~ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1; - entity->update(); - } - } -} - -void render_generic_entities_world(void) { - s32 i; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* entity = (*gCurrentDynamicEntityListPtr)[i]; - if (entity != NULL && !(entity->flags & ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1)) { - if (!(entity->flags & ENTITY_FLAGS_HAS_DYNAMIC_SHADOW)) { - entity->draw(); - } - } - } -} - -void render_generic_entities_frontUI(void) { - s32 i; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* entity = (*gCurrentDynamicEntityListPtr)[i]; - if (entity != NULL && !(entity->flags & ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1)) { - if (entity->flags & ENTITY_FLAGS_HAS_DYNAMIC_SHADOW) { - entity->draw(); - } - } - } -} - -void render_generic_entities_backUI(void) { - s32 i; - - for (i = 0; i < MAX_DYNAMIC_ENTITIES; i++) { - DynamicEntity* entity = (*gCurrentDynamicEntityListPtr)[i]; - if (entity != NULL && !(entity->flags & ENTITY_FLAGS_DRAW_IF_CLOSE_HIDE_MODE1)) { - if (entity->flags & ENTITY_FLAGS_HAS_ANIMATED_MODEL) { - entity->draw(); - } - } - } -} - -void free_generic_entity(s32 idx) { - if (!gGameStatusPtr->isBattle || (idx & BATTLE_ENTITY_ID_MASK)) { - DynamicEntityList** curDynEntityList = &gCurrentDynamicEntityListPtr; - - idx &= ~BATTLE_ENTITY_ID_MASK; - if ((**curDynEntityList)[idx] != NULL) { - heap_free((**curDynEntityList)[idx]); - (**curDynEntityList)[idx] = NULL; - } - } -} - -DynamicEntity* get_generic_entity(s32 idx) { - return (*gCurrentDynamicEntityListPtr)[idx & ~BATTLE_ENTITY_ID_MASK]; -} diff --git a/src/evt/model_api.c b/src/evt/model_api.c index 0097169c1d..f1125e9420 100644 --- a/src/evt/model_api.c +++ b/src/evt/model_api.c @@ -272,7 +272,7 @@ void reset_model_animators(void) { (*gCurrentMeshAnimationListPtr)[i]->animModelID = -1; } - create_generic_entity_world(update_animated_models, render_animated_models); + create_worker_world(update_animated_models, render_animated_models); } void init_model_animators(void) { diff --git a/src/evt/player_api.c b/src/evt/player_api.c index 43011eb915..9b5894b341 100644 --- a/src/evt/player_api.c +++ b/src/evt/player_api.c @@ -6,17 +6,9 @@ extern Npc playerNpcData; extern u16 D_802DB5B0; extern s32 D_802DB5B4[3]; // unused -extern VirtualEntityList D_802DB5C0; -extern VirtualEntityList D_802DB6C0; -extern VirtualEntityList* D_802DB7C0; Npc* playerNpc = &playerNpcData; -void virtual_entity_list_render_world(void); -void virtual_entity_list_render_UI(void); -s32 ALT_load_entity_model(s32* cmdList); -s32 create_generic_entity_backUI(void (*updateFunc)(void), void (*drawFunc)(void)); - ApiStatus HidePlayerShadow(Evt* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; s32 hideShadow = evt_get_variable(script, *args++); @@ -844,672 +836,3 @@ ApiStatus PlaySoundAtPlayer(Evt* script, s32 isInitialCall) { sfx_play_sound_at_player(soundID, flags); return ApiStatus_DONE2; } - -void virtual_entity_appendGfx_quad(u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 right, u16 bottom) { - gDPPipeSync(gMasterGfxPos++); - - if (a == 0xFF) { - gDPSetCombineLERP(gMasterGfxPos++, 0, 0, 0, PRIMITIVE, 0, 0, 0, 1, 0, 0, 0, PRIMITIVE, 0, 0, 0, 1); - } else { - gDPSetRenderMode(gMasterGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - gDPSetCombineMode(gMasterGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); - } - - gDPSetPrimColor(gMasterGfxPos++, 0, 0, r, g, b, a); - gDPFillRectangle(gMasterGfxPos++, left, top, right, bottom); - gDPPipeSync(gMasterGfxPos++); - gDPSetRenderMode(gMasterGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2); - gDPSetCombineMode(gMasterGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA); -} - -void virtual_entity_render_quad(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7) { - u16 temp1 = arg4 + arg6; - u16 temp2 = arg5 + arg7; - - virtual_entity_appendGfx_quad(arg0, arg1, arg2, arg3, arg4, arg5, temp1, temp2); -} - -void virtual_entity_move_polar(VirtualEntity* virtualEntity, f32 magnitude, f32 angle) { - f32 theta = DEG_TO_RAD(angle); - f32 sinTheta = sin_rad(theta); - f32 cosTheta = cos_rad(theta); - - virtualEntity->pos.x += magnitude * sinTheta; - virtualEntity->pos.z += -magnitude * cosTheta; -} - -void virtual_entity_list_update(void) { - s32 i; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[i]; - - if (virtualEntity != NULL && virtualEntity->entityModelIndex >= 0) { - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - } - } -} - -void virtual_entity_list_render_world(void) { - Matrix4f translation; - Matrix4f xRot; - Matrix4f yRot; - Matrix4f zRot; - Matrix4f rotation; - Matrix4f temp; - Matrix4f transform; - Matrix4f scale; - Mtx transformMtxL; - VirtualEntity* virtualEntity; - s32 i; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - virtualEntity = (*D_802DB7C0)[i]; - if (virtualEntity != NULL) { - if (!(virtualEntity->entityModelIndex < 0 || get_entity_model(virtualEntity->entityModelIndex)->flags & ENTITY_MODEL_FLAGS_CAM3)) { - guTranslateF(translation, virtualEntity->pos.x, virtualEntity->pos.y, virtualEntity->pos.z); - guRotateF(xRot, virtualEntity->rot.x, 1.0f, 0.0f, 0.0f); - guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f); - guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f); - guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z); - guMtxCatF(zRot, xRot, temp); - guMtxCatF(temp, yRot, rotation); - guMtxCatF(scale, rotation, temp); - guMtxCatF(temp, translation, transform); - guMtxF2L(transform, &transformMtxL); - draw_entity_model_A(virtualEntity->entityModelIndex, &transformMtxL); - } - } - } -} - -void virtual_entity_list_render_UI(void) { - Matrix4f translation; - Matrix4f xRot; - Matrix4f yRot; - Matrix4f zRot; - Matrix4f rotation; - Matrix4f temp; - Matrix4f transform; - Matrix4f scale; - Mtx transformMtxL; - VirtualEntity* virtualEntity; - s32 i; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - virtualEntity = (*D_802DB7C0)[i]; - if (virtualEntity != NULL) { - if (!(virtualEntity->entityModelIndex < 0 || !(get_entity_model(virtualEntity->entityModelIndex)->flags & ENTITY_MODEL_FLAGS_CAM3))) { - guTranslateF(translation, virtualEntity->pos.x, virtualEntity->pos.y, virtualEntity->pos.z); - guRotateF(xRot, virtualEntity->rot.x, 1.0f, 0.0f, 0.0f); - guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f); - guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f); - guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z); - guMtxCatF(zRot, xRot, temp); - guMtxCatF(temp, yRot, rotation); - guMtxCatF(scale, rotation, temp); - guMtxCatF(temp, translation, transform); - guMtxF2L(transform, &transformMtxL); - draw_entity_model_E(virtualEntity->entityModelIndex, &transformMtxL); - } - } - } -} - -ApiStatus InitVirtualEntityList(Evt* script, s32 isInitialCall) { - if (!gGameStatusPtr->isBattle) { - D_802DB7C0 = &D_802DB6C0; - } else { - D_802DB7C0 = &D_802DB5C0; - } - return ApiStatus_DONE2; -} - -ApiStatus CreateVirtualEntityAt(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - u32* cmdList = (u32*)evt_get_variable(script, *args++); - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->entityModelIndex = load_entity_model(cmdList); - virtualEntity->pos.x = 0.0f; - virtualEntity->pos.y = 0.0f; - virtualEntity->pos.z = 0.0f; - virtualEntity->rot.x = 0.0f; - virtualEntity->rot.y = 0.0f; - virtualEntity->rot.z = 0.0f; - virtualEntity->scale.x = 1.0f; - virtualEntity->scale.y = 1.0f; - virtualEntity->scale.z = 1.0f; - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - - return ApiStatus_DONE2; -} - -ApiStatus CreateVirtualEntity(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 outVar = *args++; - s32* unkStructPtr = (s32*)evt_get_variable(script, *args++); - VirtualEntity* virtualEntity; - s32 i; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - virtualEntity = (*D_802DB7C0)[i]; - if (virtualEntity->entityModelIndex < 0) { - break; - } - } - - if (i >= ARRAY_COUNT(*D_802DB7C0)) { - return ApiStatus_DONE2; - } - - virtualEntity->entityModelIndex = load_entity_model(unkStructPtr); - virtualEntity->pos.x = 0.0f; - virtualEntity->pos.y = 0.0f; - virtualEntity->pos.z = 0.0f; - virtualEntity->rot.x = 0.0f; - virtualEntity->rot.y = 0.0f; - virtualEntity->rot.z = 0.0f; - virtualEntity->scale.x = 1.0f; - virtualEntity->scale.y = 1.0f; - virtualEntity->scale.z = 1.0f; - - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - evt_set_variable(script, outVar, i); - - return ApiStatus_DONE2; -} - -ApiStatus CreateVirtualEntity_ALT(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 outVar = *args++; - s32* unkStructPtr = (s32*)evt_get_variable(script, *args++); - VirtualEntity* virtualEntity; - s32 i; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - virtualEntity = (*D_802DB7C0)[i]; - if (virtualEntity->entityModelIndex < 0) { - break; - } - } - - if (i >= ARRAY_COUNT(*D_802DB7C0)) { - return ApiStatus_DONE2; - } - - virtualEntity->entityModelIndex = ALT_load_entity_model(unkStructPtr); - virtualEntity->pos.x = 0.0f; - virtualEntity->pos.y = 0.0f; - virtualEntity->pos.z = 0.0f; - virtualEntity->rot.x = 0.0f; - virtualEntity->rot.y = 0.0f; - virtualEntity->rot.z = 0.0f; - virtualEntity->scale.x = 1.0f; - virtualEntity->scale.y = 1.0f; - virtualEntity->scale.z = 1.0f; - - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - evt_set_variable(script, outVar, i); - - return ApiStatus_DONE2; -} - -ApiStatus DeleteVirtualEntity(Evt* script, s32 isInitialCall) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[evt_get_variable(script, *script->ptrReadPos)]; - - free_entity_model_by_index(virtualEntity->entityModelIndex); - virtualEntity->entityModelIndex = -1; - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityRenderCommands(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - u32* commandList = (u32*)evt_get_variable(script, *args++); - - set_entity_model_render_command_list((*D_802DB7C0)[index]->entityModelIndex, commandList); - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityPosition(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - f32 x = evt_get_float_variable(script, *args++); - f32 y = evt_get_float_variable(script, *args++); - f32 z = evt_get_float_variable(script, *args++); - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->pos.x = x; - virtualEntity->pos.y = y; - virtualEntity->pos.z = z; - return ApiStatus_DONE2; -} - -ApiStatus GetVirtualEntityPosition(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - s32 outVar1 = *args++; - s32 outVar2 = *args++; - s32 outVar3 = *args++; - - evt_set_variable(script, outVar1, virtualEntity->pos.x); - evt_set_variable(script, outVar2, virtualEntity->pos.y); - evt_set_variable(script, outVar3, virtualEntity->pos.z); - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityRotation(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - f32 x = evt_get_float_variable(script, *args++); - f32 y = evt_get_float_variable(script, *args++); - f32 z = evt_get_float_variable(script, *args++); - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->rot.x = x; - virtualEntity->rot.y = y; - virtualEntity->rot.z = z; - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityScale(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - f32 x = evt_get_float_variable(script, *args++); - f32 y = evt_get_float_variable(script, *args++); - f32 z = evt_get_float_variable(script, *args++); - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->scale.x = x; - virtualEntity->scale.y = y; - virtualEntity->scale.z = z; - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityMoveSpeed(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - - (*D_802DB7C0)[index]->moveSpeed = evt_get_float_variable(script, *args++); - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityJumpGravity(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - - (*D_802DB7C0)[index]->jumpGravity = evt_get_float_variable(script, *args++); - return ApiStatus_DONE2; -} - -ApiStatus VirtualEntityMoveTo(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - VirtualEntity* virtualEntity; - - if (isInitialCall) { - script->functionTemp[0] = 0; - } - - if (script->functionTemp[0] == 0) { - s32 index = evt_get_variable(script, *args++); - f32 xTemp = evt_get_variable(script, *args++); - f32 yTemp = evt_get_variable(script, *args++); - f32 zTemp = evt_get_variable(script, *args++); - s32 moveTime = evt_get_variable(script, *args++); - f32 goalPosX; - f32 goalPosZ; - - virtualEntity = (*D_802DB7C0)[index]; - script->functionTemp[1] = index; - - virtualEntity->goalPos.x = xTemp; - virtualEntity->goalPos.y = yTemp; - virtualEntity->goalPos.z = zTemp; - - xTemp = virtualEntity->pos.x; - zTemp = virtualEntity->pos.z; - - goalPosX = virtualEntity->goalPos.x; - goalPosZ = virtualEntity->goalPos.z; - - virtualEntity->moveTime = moveTime; - virtualEntity->moveAngle = atan2(xTemp, zTemp, goalPosX, goalPosZ); - virtualEntity->moveDist = dist2D(xTemp, zTemp, goalPosX, goalPosZ); - - if (virtualEntity->moveTime == 0.0f) { - virtualEntity->moveTime = virtualEntity->moveDist / virtualEntity->moveSpeed; - } else { - virtualEntity->moveSpeed = virtualEntity->moveDist / virtualEntity->moveTime; - } - - script->functionTemp[0] = 1; - } - - virtualEntity = (*D_802DB7C0)[script->functionTemp[1]]; - virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle); - virtualEntity->moveTime--; - - if (virtualEntity->moveTime <= 0.0f) { - virtualEntity->pos.x = virtualEntity->goalPos.x; - virtualEntity->pos.z = virtualEntity->goalPos.z; - return ApiStatus_DONE1; - } - - return ApiStatus_BLOCK; -} - -ApiStatus VirtualEntityJumpTo(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - VirtualEntity* virtualEntity; - s32 index; - f32 xTemp; - f32 yTemp; - f32 zTemp; - s32 moveTime; - f32 goalPosX; - f32 goalPosY; - f32 goalPosZ; - - if (isInitialCall) { - script->functionTemp[0] = 0; - } - - if (script->functionTemp[0] == 0) { - index = evt_get_variable(script, *args++); - xTemp = evt_get_variable(script, *args++); - yTemp = evt_get_variable(script, *args++); - zTemp = evt_get_variable(script, *args++); - moveTime = evt_get_variable(script, *args++); - - virtualEntity = (*D_802DB7C0)[index]; - script->functionTemp[1] = index; - - virtualEntity->goalPos.x = xTemp; - virtualEntity->goalPos.y = yTemp; - virtualEntity->goalPos.z = zTemp; - - xTemp = virtualEntity->pos.x; - yTemp = virtualEntity->pos.y; - zTemp = virtualEntity->pos.z; - - goalPosX = virtualEntity->goalPos.x; - yTemp = virtualEntity->goalPos.y - yTemp; - goalPosZ = virtualEntity->goalPos.z; - - - virtualEntity->moveTime = moveTime; - virtualEntity->moveAngle = atan2(xTemp, zTemp, goalPosX, goalPosZ); - virtualEntity->moveDist = dist2D(xTemp, zTemp, goalPosX, goalPosZ); - - if (virtualEntity->moveTime == 0.0f) { - virtualEntity->moveTime = virtualEntity->moveDist / virtualEntity->moveSpeed; - } else { - virtualEntity->moveSpeed = virtualEntity->moveDist / virtualEntity->moveTime; - } - - virtualEntity->jumpVelocity = (virtualEntity->jumpGravity * virtualEntity->moveTime / 2) + - (yTemp / virtualEntity->moveTime); - script->functionTemp[0] = 1; - } - - virtualEntity = (*D_802DB7C0)[script->functionTemp[1]]; - virtualEntity->pos.y += virtualEntity->jumpVelocity; - virtualEntity->jumpVelocity -= virtualEntity->jumpGravity; - - virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle); - - virtualEntity->moveTime -= 1.0f; - if (virtualEntity->moveTime <= 0.0f) { - virtualEntity->pos.x = virtualEntity->goalPos.x; - virtualEntity->pos.y = virtualEntity->goalPos.y; - virtualEntity->pos.z = virtualEntity->goalPos.z; - return ApiStatus_DONE1; - } - - return ApiStatus_BLOCK; -} - -ApiStatus VirtualEntityLandJump(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - VirtualEntity* virtualEntity; - - if (isInitialCall) { - script->functionTemp[0] = 0; - } - - if (script->functionTemp[0] == 0) { - script->functionTemp[1] = evt_get_variable(script, *args++); - script->functionTemp[0] = 1; - } - - virtualEntity = (*D_802DB7C0)[script->functionTemp[1]]; - virtualEntity->pos.y += virtualEntity->jumpVelocity; - virtualEntity->jumpVelocity -= virtualEntity->jumpGravity; - - virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle); - - if (virtualEntity->pos.y < 0.0f) { - virtualEntity->pos.y = 0.0f; - return ApiStatus_DONE1; - } - - return ApiStatus_BLOCK; -} - -ApiStatus SetVirtualEntityFlags(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - s32 flags = *args++; - - get_entity_model((*D_802DB7C0)[index]->entityModelIndex)->flags = flags; - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityFlagBits(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - s32 flags = *args++; - s32 cond = evt_get_variable(script, *args++); - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - if (cond) { - set_entity_model_flags(virtualEntity->entityModelIndex, flags); - } else { - clear_entity_model_flags(virtualEntity->entityModelIndex, flags); - } - - return ApiStatus_DONE2; -} - -ApiStatus SetVirtualEntityRenderMode(Evt* script, s32 isInitialCall) { - Bytecode* args = script->ptrReadPos; - s32 index = evt_get_variable(script, *args++); - s32 var2 = evt_get_variable(script, *args++); - EntityModel* entityModel = get_entity_model((*D_802DB7C0)[index]->entityModelIndex); - - switch (var2) { - case -1: - entityModel->renderMode = 1; - break; - case 0: - entityModel->renderMode = 1; - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - break; - case 2: - entityModel->renderMode = 0xD; - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - break; - case 3: - entityModel->renderMode = 0x16; - evt_get_variable(script, *args++); - break; - case 4: - entityModel->renderMode = 0x16; - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - evt_get_variable(script, *args++); - break; - } - return ApiStatus_DONE2; -} - -VirtualEntity* virtual_entity_get_by_index(s32 index) { - return (*D_802DB7C0)[index]; -} - -VirtualEntity* virtual_entity_create_at_index(s32 index, s32* entityModelData) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->entityModelIndex = load_entity_model(entityModelData); - virtualEntity->pos.x = 0.0f; - virtualEntity->pos.y = 0.0f; - virtualEntity->pos.z = 0.0f; - virtualEntity->rot.x = 0.0f; - virtualEntity->rot.y = 0.0f; - virtualEntity->rot.z = 0.0f; - virtualEntity->scale.x = 1.0f; - virtualEntity->scale.y = 1.0f; - virtualEntity->scale.z = 1.0f; - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - - return (*D_802DB7C0)[index]; -} - -s32 virtual_entity_create(s32* cmdList) { - s32 i; - VirtualEntity* virtualEntity; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - virtualEntity = (*D_802DB7C0)[i]; - if (virtualEntity->entityModelIndex < 0) { - break; - } - } - - if (i >= ARRAY_COUNT(*D_802DB7C0)) { - return 0; - } - - virtualEntity->entityModelIndex = load_entity_model(cmdList); - virtualEntity->pos.x = 0.0f; - virtualEntity->pos.y = 0.0f; - virtualEntity->pos.z = 0.0f; - virtualEntity->rot.x = 0.0f; - virtualEntity->rot.y = 0.0f; - virtualEntity->rot.z = 0.0f; - virtualEntity->scale.x = 1.0f; - virtualEntity->scale.y = 1.0f; - virtualEntity->scale.z = 1.0f; - - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - - return i; -} - -VirtualEntity* ALT_virtual_entity_create(s32* cmdList) { - s32 i; - VirtualEntity* virtualEntity; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - virtualEntity = (*D_802DB7C0)[i]; - if (virtualEntity->entityModelIndex < 0) { - break; - } - } - - if (i >= ARRAY_COUNT(*D_802DB7C0)) { - return NULL; - } - - virtualEntity->entityModelIndex = ALT_load_entity_model(cmdList); - virtualEntity->pos.x = 0.0f; - virtualEntity->pos.y = 0.0f; - virtualEntity->pos.z = 0.0f; - virtualEntity->rot.x = 0.0f; - virtualEntity->rot.y = 0.0f; - virtualEntity->rot.z = 0.0f; - virtualEntity->scale.x = 1.0f; - virtualEntity->scale.y = 1.0f; - virtualEntity->scale.z = 1.0f; - - exec_entity_model_commandlist(virtualEntity->entityModelIndex); - - return (*D_802DB7C0)[i]; -} - -void virtual_entity_set_pos(s32 index, s32 arg1, s32 arg2, s32 arg3) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->pos.x = arg1; - virtualEntity->pos.y = arg2; - virtualEntity->pos.z = arg3; -} - -void virtual_entity_set_scale(s32 index, f32 arg1, f32 arg2, f32 arg3) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->scale.x = arg1; - virtualEntity->scale.y = arg2; - virtualEntity->scale.z = arg3; -} - -void virtual_entity_set_rotation(s32 index, f32 arg1, f32 arg2, f32 arg3) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - virtualEntity->rot.x = arg1; - virtualEntity->rot.y = arg2; - virtualEntity->rot.z = arg3; -} - -void virtual_entity_delete_by_index(s32 index) { - VirtualEntity* virtualEntity = (*D_802DB7C0)[index]; - - free_entity_model_by_index(virtualEntity->entityModelIndex); - virtualEntity->entityModelIndex = -1; -} - -void virtual_entity_delete_by_ref(VirtualEntity* arg0) { - s32 i; - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - if ((*D_802DB7C0)[i] == arg0) { - virtual_entity_delete_by_index(i); - return; - } - } -} - -void clear_virtual_entity_list(void) { - s32 i; - - if (!gGameStatusPtr->isBattle) { - D_802DB7C0 = &D_802DB6C0; - } else { - D_802DB7C0 = &D_802DB5C0; - } - - for (i = 0; i < ARRAY_COUNT(*D_802DB7C0); i++) { - (*D_802DB7C0)[i] = heap_malloc(sizeof(VirtualEntity)); - ASSERT((*D_802DB7C0)[i] != NULL); - (*D_802DB7C0)[i]->entityModelIndex = -1; - } - - create_generic_entity_world(virtual_entity_list_update, virtual_entity_list_render_world); - create_generic_entity_backUI(NULL, virtual_entity_list_render_UI); -} - -void init_virtual_entity_list(void) { - if (!gGameStatusPtr->isBattle) { - D_802DB7C0 = &D_802DB6C0; - } else { - D_802DB7C0 = &D_802DB5C0; - } -} diff --git a/src/evt/script_list.c b/src/evt/script_list.c index b5d0daf462..9c56ff4abf 100644 --- a/src/evt/script_list.c +++ b/src/evt/script_list.c @@ -52,9 +52,9 @@ BSS s32 D_802DB26C; // unused? BSS Npc playerNpcData; BSS u16 D_802DB5B0; BSS s32 D_802DB5B4[3]; // unused -BSS VirtualEntityList D_802DB5C0; -BSS VirtualEntityList D_802DB6C0; -BSS VirtualEntityList* D_802DB7C0; +BSS VirtualEntityList bBattleVirtualEntityList; +BSS VirtualEntityList wWorldVirtualEntityList; +BSS VirtualEntityList* gCurrentVirtualEntityListPtr; BSS s32 D_802DB7C4[3]; // unused // fa4c0_len_3bf0 diff --git a/src/evt/virtual_entity.c b/src/evt/virtual_entity.c new file mode 100644 index 0000000000..0727542875 --- /dev/null +++ b/src/evt/virtual_entity.c @@ -0,0 +1,681 @@ +#include "common.h" + +extern VirtualEntityList bBattleVirtualEntityList; +extern VirtualEntityList wWorldVirtualEntityList; +extern VirtualEntityList* gCurrentVirtualEntityListPtr; + +void virtual_entity_list_render_world(void); +void virtual_entity_list_render_UI(void); +s32 ALT_load_entity_model(s32* cmdList); +s32 create_worker_backUI(void (*updateFunc)(void), void (*drawFunc)(void)); + +void virtual_entity_appendGfx_quad(u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 right, u16 bottom) { + gDPPipeSync(gMasterGfxPos++); + + if (a == 0xFF) { + gDPSetCombineLERP(gMasterGfxPos++, 0, 0, 0, PRIMITIVE, 0, 0, 0, 1, 0, 0, 0, PRIMITIVE, 0, 0, 0, 1); + } else { + gDPSetRenderMode(gMasterGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(gMasterGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + } + + gDPSetPrimColor(gMasterGfxPos++, 0, 0, r, g, b, a); + gDPFillRectangle(gMasterGfxPos++, left, top, right, bottom); + gDPPipeSync(gMasterGfxPos++); + gDPSetRenderMode(gMasterGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2); + gDPSetCombineMode(gMasterGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA); +} + +void virtual_entity_render_quad(s32 r, s32 g, s32 b, s32 a, s32 posX, s32 posY, s32 width, s32 height) { + u16 endX = posX + width; + u16 endY = posY + height; + + virtual_entity_appendGfx_quad(r, g, b, a, posX, posY, endX, endY); +} + +void virtual_entity_move_polar(VirtualEntity* virtualEntity, f32 magnitude, f32 angle) { + f32 theta = DEG_TO_RAD(angle); + f32 sinTheta = sin_rad(theta); + f32 cosTheta = cos_rad(theta); + + virtualEntity->pos.x += magnitude * sinTheta; + virtualEntity->pos.z += -magnitude * cosTheta; +} + +void virtual_entity_list_update(void) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + + if (virtualEntity != NULL && virtualEntity->entityModelIndex >= 0) { + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + } + } +} + +void virtual_entity_list_render_world(void) { + Matrix4f translation; + Matrix4f xRot; + Matrix4f yRot; + Matrix4f zRot; + Matrix4f rotation; + Matrix4f temp; + Matrix4f transform; + Matrix4f scale; + Mtx transformMtxL; + VirtualEntity* virtualEntity; + s32 i; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + if (virtualEntity != NULL) { + if (!(virtualEntity->entityModelIndex < 0 || get_entity_model(virtualEntity->entityModelIndex)->flags & ENTITY_MODEL_FLAGS_CAM3)) { + guTranslateF(translation, virtualEntity->pos.x, virtualEntity->pos.y, virtualEntity->pos.z); + guRotateF(xRot, virtualEntity->rot.x, 1.0f, 0.0f, 0.0f); + guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f); + guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f); + guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z); + guMtxCatF(zRot, xRot, temp); + guMtxCatF(temp, yRot, rotation); + guMtxCatF(scale, rotation, temp); + guMtxCatF(temp, translation, transform); + guMtxF2L(transform, &transformMtxL); + draw_entity_model_A(virtualEntity->entityModelIndex, &transformMtxL); + } + } + } +} + +void virtual_entity_list_render_UI(void) { + Matrix4f translation; + Matrix4f xRot; + Matrix4f yRot; + Matrix4f zRot; + Matrix4f rotation; + Matrix4f temp; + Matrix4f transform; + Matrix4f scale; + Mtx transformMtxL; + VirtualEntity* virtualEntity; + s32 i; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + if (virtualEntity != NULL) { + if (!(virtualEntity->entityModelIndex < 0 || !(get_entity_model(virtualEntity->entityModelIndex)->flags & ENTITY_MODEL_FLAGS_CAM3))) { + guTranslateF(translation, virtualEntity->pos.x, virtualEntity->pos.y, virtualEntity->pos.z); + guRotateF(xRot, virtualEntity->rot.x, 1.0f, 0.0f, 0.0f); + guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f); + guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f); + guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z); + guMtxCatF(zRot, xRot, temp); + guMtxCatF(temp, yRot, rotation); + guMtxCatF(scale, rotation, temp); + guMtxCatF(temp, translation, transform); + guMtxF2L(transform, &transformMtxL); + draw_entity_model_E(virtualEntity->entityModelIndex, &transformMtxL); + } + } + } +} + +ApiStatus InitVirtualEntityList(Evt* script, s32 isInitialCall) { + if (!gGameStatusPtr->isBattle) { + gCurrentVirtualEntityListPtr = &wWorldVirtualEntityList; + } else { + gCurrentVirtualEntityListPtr = &bBattleVirtualEntityList; + } + return ApiStatus_DONE2; +} + +ApiStatus CreateVirtualEntityAt(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + u32* cmdList = (u32*) evt_get_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->entityModelIndex = load_entity_model(cmdList); + virtualEntity->pos.x = 0.0f; + virtualEntity->pos.y = 0.0f; + virtualEntity->pos.z = 0.0f; + virtualEntity->rot.x = 0.0f; + virtualEntity->rot.y = 0.0f; + virtualEntity->rot.z = 0.0f; + virtualEntity->scale.x = 1.0f; + virtualEntity->scale.y = 1.0f; + virtualEntity->scale.z = 1.0f; + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + + return ApiStatus_DONE2; +} + +ApiStatus CreateVirtualEntity(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 outVar = *args++; + s32* unkStructPtr = (s32*)evt_get_variable(script, *args++); + VirtualEntity* virtualEntity; + s32 i; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + if (virtualEntity->entityModelIndex < 0) { + break; + } + } + + if (i >= ARRAY_COUNT(*gCurrentVirtualEntityListPtr)) { + return ApiStatus_DONE2; + } + + virtualEntity->entityModelIndex = load_entity_model(unkStructPtr); + virtualEntity->pos.x = 0.0f; + virtualEntity->pos.y = 0.0f; + virtualEntity->pos.z = 0.0f; + virtualEntity->rot.x = 0.0f; + virtualEntity->rot.y = 0.0f; + virtualEntity->rot.z = 0.0f; + virtualEntity->scale.x = 1.0f; + virtualEntity->scale.y = 1.0f; + virtualEntity->scale.z = 1.0f; + + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + evt_set_variable(script, outVar, i); + + return ApiStatus_DONE2; +} + +ApiStatus CreateVirtualEntity_ALT(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 outVar = *args++; + s32* unkStructPtr = (s32*) evt_get_variable(script, *args++); + VirtualEntity* virtualEntity; + s32 i; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + if (virtualEntity->entityModelIndex < 0) { + break; + } + } + + if (i >= ARRAY_COUNT(*gCurrentVirtualEntityListPtr)) { + return ApiStatus_DONE2; + } + + virtualEntity->entityModelIndex = ALT_load_entity_model(unkStructPtr); + virtualEntity->pos.x = 0.0f; + virtualEntity->pos.y = 0.0f; + virtualEntity->pos.z = 0.0f; + virtualEntity->rot.x = 0.0f; + virtualEntity->rot.y = 0.0f; + virtualEntity->rot.z = 0.0f; + virtualEntity->scale.x = 1.0f; + virtualEntity->scale.y = 1.0f; + virtualEntity->scale.z = 1.0f; + + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + evt_set_variable(script, outVar, i); + + return ApiStatus_DONE2; +} + +ApiStatus DeleteVirtualEntity(Evt* script, s32 isInitialCall) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[evt_get_variable(script, *script->ptrReadPos)]; + + free_entity_model_by_index(virtualEntity->entityModelIndex); + virtualEntity->entityModelIndex = -1; + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityRenderCommands(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + u32* commandList = (u32*) evt_get_variable(script, *args++); + + set_entity_model_render_command_list((*gCurrentVirtualEntityListPtr)[index]->entityModelIndex, commandList); + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityPosition(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + f32 x = evt_get_float_variable(script, *args++); + f32 y = evt_get_float_variable(script, *args++); + f32 z = evt_get_float_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->pos.x = x; + virtualEntity->pos.y = y; + virtualEntity->pos.z = z; + return ApiStatus_DONE2; +} + +ApiStatus GetVirtualEntityPosition(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + s32 outVar1 = *args++; + s32 outVar2 = *args++; + s32 outVar3 = *args++; + + evt_set_variable(script, outVar1, virtualEntity->pos.x); + evt_set_variable(script, outVar2, virtualEntity->pos.y); + evt_set_variable(script, outVar3, virtualEntity->pos.z); + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityRotation(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + f32 x = evt_get_float_variable(script, *args++); + f32 y = evt_get_float_variable(script, *args++); + f32 z = evt_get_float_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->rot.x = x; + virtualEntity->rot.y = y; + virtualEntity->rot.z = z; + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityScale(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + f32 x = evt_get_float_variable(script, *args++); + f32 y = evt_get_float_variable(script, *args++); + f32 z = evt_get_float_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->scale.x = x; + virtualEntity->scale.y = y; + virtualEntity->scale.z = z; + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityMoveSpeed(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + + (*gCurrentVirtualEntityListPtr)[index]->moveSpeed = evt_get_float_variable(script, *args++); + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityJumpGravity(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + + (*gCurrentVirtualEntityListPtr)[index]->jumpGravity = evt_get_float_variable(script, *args++); + return ApiStatus_DONE2; +} + +ApiStatus VirtualEntityMoveTo(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + VirtualEntity* virtualEntity; + + if (isInitialCall) { + script->functionTemp[0] = 0; + } + + if (script->functionTemp[0] == 0) { + s32 index = evt_get_variable(script, *args++); + f32 xTemp = evt_get_variable(script, *args++); + f32 yTemp = evt_get_variable(script, *args++); + f32 zTemp = evt_get_variable(script, *args++); + s32 moveTime = evt_get_variable(script, *args++); + f32 goalPosX; + f32 goalPosZ; + + virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + script->functionTemp[1] = index; + + virtualEntity->goalPos.x = xTemp; + virtualEntity->goalPos.y = yTemp; + virtualEntity->goalPos.z = zTemp; + + xTemp = virtualEntity->pos.x; + zTemp = virtualEntity->pos.z; + + goalPosX = virtualEntity->goalPos.x; + goalPosZ = virtualEntity->goalPos.z; + + virtualEntity->moveTime = moveTime; + virtualEntity->moveAngle = atan2(xTemp, zTemp, goalPosX, goalPosZ); + virtualEntity->moveDist = dist2D(xTemp, zTemp, goalPosX, goalPosZ); + + if (virtualEntity->moveTime == 0.0f) { + virtualEntity->moveTime = virtualEntity->moveDist / virtualEntity->moveSpeed; + } else { + virtualEntity->moveSpeed = virtualEntity->moveDist / virtualEntity->moveTime; + } + + script->functionTemp[0] = 1; + } + + virtualEntity = (*gCurrentVirtualEntityListPtr)[script->functionTemp[1]]; + virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle); + virtualEntity->moveTime--; + + if (virtualEntity->moveTime <= 0.0f) { + virtualEntity->pos.x = virtualEntity->goalPos.x; + virtualEntity->pos.z = virtualEntity->goalPos.z; + return ApiStatus_DONE1; + } + + return ApiStatus_BLOCK; +} + +ApiStatus VirtualEntityJumpTo(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + VirtualEntity* virtualEntity; + s32 index; + f32 xTemp; + f32 yTemp; + f32 zTemp; + s32 moveTime; + f32 goalPosX; + f32 goalPosY; + f32 goalPosZ; + + if (isInitialCall) { + script->functionTemp[0] = 0; + } + + if (script->functionTemp[0] == 0) { + index = evt_get_variable(script, *args++); + xTemp = evt_get_variable(script, *args++); + yTemp = evt_get_variable(script, *args++); + zTemp = evt_get_variable(script, *args++); + moveTime = evt_get_variable(script, *args++); + + virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + script->functionTemp[1] = index; + + virtualEntity->goalPos.x = xTemp; + virtualEntity->goalPos.y = yTemp; + virtualEntity->goalPos.z = zTemp; + + xTemp = virtualEntity->pos.x; + yTemp = virtualEntity->pos.y; + zTemp = virtualEntity->pos.z; + + goalPosX = virtualEntity->goalPos.x; + yTemp = virtualEntity->goalPos.y - yTemp; + goalPosZ = virtualEntity->goalPos.z; + + + virtualEntity->moveTime = moveTime; + virtualEntity->moveAngle = atan2(xTemp, zTemp, goalPosX, goalPosZ); + virtualEntity->moveDist = dist2D(xTemp, zTemp, goalPosX, goalPosZ); + + if (virtualEntity->moveTime == 0.0f) { + virtualEntity->moveTime = virtualEntity->moveDist / virtualEntity->moveSpeed; + } else { + virtualEntity->moveSpeed = virtualEntity->moveDist / virtualEntity->moveTime; + } + + virtualEntity->jumpVelocity = (virtualEntity->jumpGravity * virtualEntity->moveTime / 2) + + (yTemp / virtualEntity->moveTime); + script->functionTemp[0] = 1; + } + + virtualEntity = (*gCurrentVirtualEntityListPtr)[script->functionTemp[1]]; + virtualEntity->pos.y += virtualEntity->jumpVelocity; + virtualEntity->jumpVelocity -= virtualEntity->jumpGravity; + + virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle); + + virtualEntity->moveTime -= 1.0f; + if (virtualEntity->moveTime <= 0.0f) { + virtualEntity->pos.x = virtualEntity->goalPos.x; + virtualEntity->pos.y = virtualEntity->goalPos.y; + virtualEntity->pos.z = virtualEntity->goalPos.z; + return ApiStatus_DONE1; + } + + return ApiStatus_BLOCK; +} + +ApiStatus VirtualEntityLandJump(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + VirtualEntity* virtualEntity; + + if (isInitialCall) { + script->functionTemp[0] = 0; + } + + if (script->functionTemp[0] == 0) { + script->functionTemp[1] = evt_get_variable(script, *args++); + script->functionTemp[0] = 1; + } + + virtualEntity = (*gCurrentVirtualEntityListPtr)[script->functionTemp[1]]; + virtualEntity->pos.y += virtualEntity->jumpVelocity; + virtualEntity->jumpVelocity -= virtualEntity->jumpGravity; + + virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle); + + if (virtualEntity->pos.y < 0.0f) { + virtualEntity->pos.y = 0.0f; + return ApiStatus_DONE1; + } + + return ApiStatus_BLOCK; +} + +ApiStatus SetVirtualEntityFlags(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + s32 flags = *args++; + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + get_entity_model(virtualEntity->entityModelIndex)->flags = flags; + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityFlagBits(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + s32 flags = *args++; + s32 mode = evt_get_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + if (mode) { + set_entity_model_flags(virtualEntity->entityModelIndex, flags); + } else { + clear_entity_model_flags(virtualEntity->entityModelIndex, flags); + } + + return ApiStatus_DONE2; +} + +ApiStatus SetVirtualEntityRenderMode(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 index = evt_get_variable(script, *args++); + s32 mode = evt_get_variable(script, *args++); + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + EntityModel* entityModel = get_entity_model(virtualEntity->entityModelIndex); + + switch (mode) { + case -1: + entityModel->renderMode = RENDER_MODE_SURFACE_OPA; + break; + case 0: + entityModel->renderMode = RENDER_MODE_SURFACE_OPA; + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + break; + case 2: + entityModel->renderMode = RENDER_MODE_ALPHATEST; + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + break; + case 3: + entityModel->renderMode = RENDER_MODE_SURFACE_XLU_LAYER2; + evt_get_variable(script, *args++); + break; + case 4: + entityModel->renderMode = RENDER_MODE_SURFACE_XLU_LAYER2; + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + evt_get_variable(script, *args++); + break; + } + return ApiStatus_DONE2; +} + +VirtualEntity* virtual_entity_get_by_index(s32 index) { + return (*gCurrentVirtualEntityListPtr)[index]; +} + +VirtualEntity* virtual_entity_create_at_index(s32 index, s32* entityModelData) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->entityModelIndex = load_entity_model(entityModelData); + virtualEntity->pos.x = 0.0f; + virtualEntity->pos.y = 0.0f; + virtualEntity->pos.z = 0.0f; + virtualEntity->rot.x = 0.0f; + virtualEntity->rot.y = 0.0f; + virtualEntity->rot.z = 0.0f; + virtualEntity->scale.x = 1.0f; + virtualEntity->scale.y = 1.0f; + virtualEntity->scale.z = 1.0f; + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + + return (*gCurrentVirtualEntityListPtr)[index]; +} + +s32 virtual_entity_create(s32* cmdList) { + s32 i; + VirtualEntity* virtualEntity; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + if (virtualEntity->entityModelIndex < 0) { + break; + } + } + + if (i >= ARRAY_COUNT(*gCurrentVirtualEntityListPtr)) { + return 0; + } + + virtualEntity->entityModelIndex = load_entity_model(cmdList); + virtualEntity->pos.x = 0.0f; + virtualEntity->pos.y = 0.0f; + virtualEntity->pos.z = 0.0f; + virtualEntity->rot.x = 0.0f; + virtualEntity->rot.y = 0.0f; + virtualEntity->rot.z = 0.0f; + virtualEntity->scale.x = 1.0f; + virtualEntity->scale.y = 1.0f; + virtualEntity->scale.z = 1.0f; + + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + + return i; +} + +VirtualEntity* ALT_virtual_entity_create(s32* cmdList) { + s32 i; + VirtualEntity* virtualEntity; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + virtualEntity = (*gCurrentVirtualEntityListPtr)[i]; + if (virtualEntity->entityModelIndex < 0) { + break; + } + } + + if (i >= ARRAY_COUNT(*gCurrentVirtualEntityListPtr)) { + return NULL; + } + + virtualEntity->entityModelIndex = ALT_load_entity_model(cmdList); + virtualEntity->pos.x = 0.0f; + virtualEntity->pos.y = 0.0f; + virtualEntity->pos.z = 0.0f; + virtualEntity->rot.x = 0.0f; + virtualEntity->rot.y = 0.0f; + virtualEntity->rot.z = 0.0f; + virtualEntity->scale.x = 1.0f; + virtualEntity->scale.y = 1.0f; + virtualEntity->scale.z = 1.0f; + + exec_entity_model_commandlist(virtualEntity->entityModelIndex); + + return (*gCurrentVirtualEntityListPtr)[i]; +} + +void virtual_entity_set_pos(s32 index, s32 posX, s32 posY, s32 posZ) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->pos.x = posX; + virtualEntity->pos.y = posY; + virtualEntity->pos.z = posZ; +} + +void virtual_entity_set_scale(s32 index, f32 scaleX, f32 scaleY, f32 scaleZ) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->scale.x = scaleX; + virtualEntity->scale.y = scaleY; + virtualEntity->scale.z = scaleZ; +} + +void virtual_entity_set_rotation(s32 index, f32 angleX, f32 angleY, f32 angleZ) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + virtualEntity->rot.x = angleX; + virtualEntity->rot.y = angleY; + virtualEntity->rot.z = angleZ; +} + +void virtual_entity_delete_by_index(s32 index) { + VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index]; + + free_entity_model_by_index(virtualEntity->entityModelIndex); + virtualEntity->entityModelIndex = -1; +} + +void virtual_entity_delete_by_ref(VirtualEntity* obj) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + if ((*gCurrentVirtualEntityListPtr)[i] == obj) { + virtual_entity_delete_by_index(i); + return; + } + } +} + +void clear_virtual_entity_list(void) { + s32 i; + + if (!gGameStatusPtr->isBattle) { + gCurrentVirtualEntityListPtr = &wWorldVirtualEntityList; + } else { + gCurrentVirtualEntityListPtr = &bBattleVirtualEntityList; + } + + for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) { + (*gCurrentVirtualEntityListPtr)[i] = heap_malloc(sizeof(VirtualEntity)); + ASSERT((*gCurrentVirtualEntityListPtr)[i] != NULL); + (*gCurrentVirtualEntityListPtr)[i]->entityModelIndex = -1; + } + + create_worker_world(virtual_entity_list_update, virtual_entity_list_render_world); + create_worker_backUI(NULL, virtual_entity_list_render_UI); +} + +void init_virtual_entity_list(void) { + if (!gGameStatusPtr->isBattle) { + gCurrentVirtualEntityListPtr = &wWorldVirtualEntityList; + } else { + gCurrentVirtualEntityListPtr = &bBattleVirtualEntityList; + } +} diff --git a/src/main_loop.c b/src/main_loop.c index b5ad26ede3..d0cfd5730f 100644 --- a/src/main_loop.c +++ b/src/main_loop.c @@ -81,7 +81,7 @@ void step_game_loop(void) { func_8011BAE8(); npc_iter_no_op(); - update_generic_entities(); + update_workers(); update_triggers(); update_scripts(); update_messages(); @@ -191,7 +191,7 @@ void gfx_draw_frame(void) { player_render_interact_prompts(); func_802C3EE4(); render_screen_overlay_backUI(); - render_generic_entities_backUI(); + render_workers_backUI(); render_hud_elements_backUI(); render_effects_UI(); state_render_backUI(); @@ -208,7 +208,7 @@ void gfx_draw_frame(void) { render_messages(); } - render_generic_entities_frontUI(); + render_workers_frontUI(); render_hud_elements_frontUI(); render_screen_overlay_frontUI(); @@ -275,11 +275,11 @@ void load_engine_data(void) { func_80028838(); general_heap_create(); clear_render_tasks(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); clear_player_status(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_entity_models(); clear_animator_list(); clear_model_data(); diff --git a/src/npc.c b/src/npc.c index d5c2edb204..60f4a1aac8 100644 --- a/src/npc.c +++ b/src/npc.c @@ -2254,7 +2254,7 @@ void init_encounter_status(void) { func_80045AC0(); gEncounterState = ENCOUNTER_STATE_NONE; - create_generic_entity_world(0, npc_dyn_entity_draw_no_op); + create_worker_world(NULL, npc_render_worker_do_nothing); } void clear_encounter_status(void) { @@ -2293,7 +2293,7 @@ void clear_encounter_status(void) { func_80045AC0(); gEncounterState = ENCOUNTER_STATE_NONE; - create_generic_entity_world(NULL, npc_dyn_entity_draw_no_op); + create_worker_world(NULL, npc_render_worker_do_nothing); } void func_8003E50C(void) { @@ -2361,7 +2361,7 @@ void draw_first_strike_ui(void) { } } -void npc_dyn_entity_draw_no_op(void) { +void npc_render_worker_do_nothing(void) { } void make_npcs(s32 flags, s32 mapID, s32* npcGroupList) { diff --git a/src/sprite.c b/src/sprite.c index d6d8a584e1..63a581affc 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -87,17 +87,40 @@ Gfx D_802DF490[] = { f32 spr_animUpdateTimeScale = 1.0f; +#define MARIO_SPRITE_COMMON_BITS \ + 1 << SPR_Mario_1 \ + | 1 << SPR_Mario_2 \ + +#define MARIO_SPRITE_WORLD_BITS \ + MARIO_SPRITE_COMMON_BITS \ + | 1 << SPR_Mario_6 \ + | 1 << SPR_Mario_7 \ + | 1 << SPR_Mario_8 \ + | 1 << SPR_Mario_9 + +#define MARIO_SPRITE_BATTLE_BITS \ + MARIO_SPRITE_COMMON_BITS \ + | 1 << SPR_Mario_3 \ + | 1 << SPR_Mario_4 \ + | 1 << SPR_Mario_5 + +#define PEACH_SPRITE_BITS \ + 1 << SPR_Peach_A \ + | 1 << SPR_Peach_B \ + | 1 << SPR_Peach_C \ + | 1 << SPR_Peach_D \ + // TODO(player raster splat header generation): // - macroify rasterSize based on the biggest raster // - OR values of a generated player raster name enum together for initiallyLoaded bits PlayerSpriteSet spr_playerSpriteSets[] = { - /* Mario */ { 6, 0x700, 0x000003C6 }, - /* Mario */ { 18, 0x700, 0x000003C6 }, - /* Mario */ { 10, 0x900, 0x00003FC6 }, - /* Mario */ { 3, 0x700, 0x00000006 }, - /* Peach */ { 6, 0x900, 0x00003C00 }, - /* Peach */ { 6, 0x700, 0x0000003E }, - /* Peach */ { 6, 0x900, 0x00003C00 }, + [PLAYER_SPRITES_MARIO_WORLD] { 6, 0x700, MARIO_SPRITE_WORLD_BITS }, + [PLAYER_SPRITES_MARIO_REFLECT_FLOOR] { 18, 0x700, MARIO_SPRITE_WORLD_BITS }, + [PLAYER_SPRITES_COMBINED_EPILOGUE] { 10, 0x900, MARIO_SPRITE_WORLD_BITS | PEACH_SPRITE_BITS }, + [PLAYER_SPRITES_MARIO_PARADE] { 3, 0x700, MARIO_SPRITE_COMMON_BITS }, + [PLAYER_SPRITES_PEACH_WORLD] { 6, 0x900, PEACH_SPRITE_BITS }, + [PLAYER_SPRITES_MARIO_BATTLE] { 6, 0x700, MARIO_SPRITE_BATTLE_BITS }, + [PLAYER_SPRITES_PEACH_BATTLE] { 6, 0x900, PEACH_SPRITE_BITS}, }; void spr_init_quad_cache(void) { @@ -759,7 +782,7 @@ void spr_init_sprites(s32 playerSpriteSet) { spr_playerMaxComponents = 0; if (gGameStatusPtr->peachFlags & PEACH_STATUS_FLAG_IS_PEACH) { - playerSpriteSet = 4; + playerSpriteSet = PLAYER_SPRITES_PEACH_WORLD; } loadedFlags = (&spr_playerSpriteSets[playerSpriteSet])->initiallyLoaded; diff --git a/src/state_battle.c b/src/state_battle.c index 85f0750817..5844e77827 100644 --- a/src/state_battle.c +++ b/src/state_battle.c @@ -24,7 +24,7 @@ void state_init_battle(void) { void state_step_battle(void) { u32 currentBattleSelection; - u32 temp; + u32 currentBattleIndex; if (D_800A0900 == 5) { if (nuGfxCfb[1] != nuGfxCfb_ptr) { @@ -51,14 +51,15 @@ void state_step_battle(void) { func_802B20B4(); sfx_clear_env_sounds(0); - currentBattleSelection = gCurrentBattleSection; - temp = D_800DC4EB; + currentBattleSelection = UNPACK_BTL_AREA(gCurrentBattleID); + currentBattleIndex = UNPACK_BTL_INDEX(gCurrentBattleID); - if (gGameStatusPtr->peachFlags & PEACH_STATUS_FLAG_IS_PEACH || (currentBattleSelection == BTL_AREA_KKJ && temp == 0)) { + if (gGameStatusPtr->peachFlags & PEACH_STATUS_FLAG_IS_PEACH || + (currentBattleSelection == BTL_AREA_KKJ && currentBattleIndex == 0)) { gGameStatusPtr->peachFlags |= PEACH_STATUS_FLAG_IS_PEACH; - spr_init_sprites(6); + spr_init_sprites(PLAYER_SPRITES_PEACH_BATTLE); } else { - spr_init_sprites(5); + spr_init_sprites(PLAYER_SPRITES_MARIO_BATTLE); } clear_model_data(); @@ -66,7 +67,7 @@ void state_step_battle(void) { reset_background_settings(); clear_entity_models(); clear_animator_list(); - clear_generic_entity_list(); + clear_worker_list(); hud_element_set_aux_cache(NULL, 0); hud_element_clear_cache(); reset_status_menu(); @@ -142,7 +143,7 @@ void state_step_end_battle(void) { init_sprite_shading_data(); init_entity_models(); reset_animator_list(); - init_generic_entity_list(); + init_worker_list(); hud_element_set_aux_cache(0, 0); init_hud_element_list(); init_item_entity_list(); diff --git a/src/state_demo.c b/src/state_demo.c index 66dd6f4e79..da0b7e5437 100644 --- a/src/state_demo.c +++ b/src/state_demo.c @@ -95,10 +95,10 @@ void state_step_demo(void) { gOverrideFlags &= ~GLOBAL_OVERRIDES_8; general_heap_create(); clear_render_tasks(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_entity_models(); clear_animator_list(); clear_model_data(); diff --git a/src/state_file_select.c b/src/state_file_select.c index 3ec3e62bea..228c75a4ae 100644 --- a/src/state_file_select.c +++ b/src/state_file_select.c @@ -121,13 +121,13 @@ void state_step_language_select(void) { backup_map_collision_data(); battle_heap_create(); sfx_clear_env_sounds(0); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_model_data(); clear_sprite_shading_data(); reset_background_settings(); clear_entity_models(); clear_animator_list(); - clear_generic_entity_list(); + clear_worker_list(); hud_element_set_aux_cache(&D_80200000, 0x20000); hud_element_clear_cache(); reset_status_menu(); @@ -279,7 +279,7 @@ void state_step_exit_language_select(void) { init_sprite_shading_data(); init_entity_models(); reset_animator_list(); - init_generic_entity_list(); + init_worker_list(); hud_element_set_aux_cache(0, 0); init_hud_element_list(); init_item_entity_list(); diff --git a/src/state_intro.c b/src/state_intro.c index cc31cbf8aa..52f9c38467 100644 --- a/src/state_intro.c +++ b/src/state_intro.c @@ -144,10 +144,10 @@ void state_step_intro(void) { if (gGameStatusPtr->creditsViewportMode == -1) { general_heap_create(); clear_render_tasks(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_entity_models(); clear_animator_list(); clear_model_data(); diff --git a/src/state_logos.c b/src/state_logos.c index b03f8e47c9..432d89e4ee 100644 --- a/src/state_logos.c +++ b/src/state_logos.c @@ -84,9 +84,9 @@ void state_init_logos(void) { gCameras[CAM_DEFAULT].lookAt_eye.z = 1500.0f; gCameras[CAM_DEFAULT].lookAt_obj_target.z = 150.0f; clear_script_list(); - clear_generic_entity_list(); + clear_worker_list(); clear_render_tasks(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_animator_list(); clear_entity_models(); clear_npcs(); diff --git a/src/state_pause.c b/src/state_pause.c index 618c0f6411..d62785364c 100644 --- a/src/state_pause.c +++ b/src/state_pause.c @@ -63,13 +63,13 @@ void state_step_pause(void) { battle_heap_create(); nuContRmbForceStop(); sfx_clear_env_sounds(0); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_model_data(); clear_sprite_shading_data(); reset_background_settings(); clear_entity_models(); clear_animator_list(); - clear_generic_entity_list(); + clear_worker_list(); hud_element_set_aux_cache(_3169F0_VRAM, 0x38000); hud_element_clear_cache(); reset_status_menu(); @@ -151,7 +151,7 @@ void state_step_unpause(void) { init_sprite_shading_data(); init_entity_models(); reset_animator_list(); - init_generic_entity_list(); + init_worker_list(); hud_element_set_aux_cache(0, 0); init_hud_element_list(); init_item_entity_list(); diff --git a/src/state_startup.c b/src/state_startup.c index 092aeac258..68ef1e2da2 100644 --- a/src/state_startup.c +++ b/src/state_startup.c @@ -33,10 +33,10 @@ void state_step_startup(void) { general_heap_create(); clear_render_tasks(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_entity_models(); clear_animator_list(); clear_model_data(); diff --git a/src/state_title_screen.c b/src/state_title_screen.c index 71a3740f9f..b642daaf5c 100644 --- a/src/state_title_screen.c +++ b/src/state_title_screen.c @@ -121,9 +121,9 @@ void state_init_title_screen(void) { gCameras[CAM_DEFAULT].lookAt_eye.z = 1500.0f; gCameras[CAM_DEFAULT].lookAt_obj_target.z = 150.0f; clear_script_list(); - clear_generic_entity_list(); + clear_worker_list(); clear_render_tasks(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_animator_list(); clear_entity_models(); clear_npcs(); @@ -247,7 +247,7 @@ void state_step_title_screen(void) { clear_animator_list(); clear_npcs(); hud_element_clear_cache(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_entity_data(1); clear_windows(); gOverrideFlags &= ~GLOBAL_OVERRIDES_8; diff --git a/src/status_icons.c b/src/status_icons.c index 866d92cc99..64fbee5b4a 100644 --- a/src/status_icons.c +++ b/src/status_icons.c @@ -129,7 +129,7 @@ void func_80045AC0(void) { popup->message = NULL; } - create_generic_entity_world(NULL, func_80045BC8); + create_worker_world(NULL, func_80045BC8); init_all_status_icons(); } diff --git a/src/worker.c b/src/worker.c new file mode 100644 index 0000000000..0d110326fe --- /dev/null +++ b/src/worker.c @@ -0,0 +1,184 @@ +#include "common.h" + +void worker_delegate_do_nothing(void) { +} + +void clear_worker_list(void) { + s32 i; + + if (!gGameStatusPtr->isBattle) { + gCurrentWorkerListPtr = &gWorldWorkerList; + } else { + gCurrentWorkerListPtr = &gBattleWorkerList; + } + + for (i = 0; i < MAX_WORKERS; i++) { + (*gCurrentWorkerListPtr)[i] = NULL; + } +} + +void init_worker_list(void) { + if (!gGameStatusPtr->isBattle) { + gCurrentWorkerListPtr = &gWorldWorkerList; + } else { + gCurrentWorkerListPtr = &gBattleWorkerList; + } +} + +s32 create_worker_world(void (*updateFunc)(void), void (*drawFunc)(void)) { + Worker* worker; + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* lastWorker = (*gCurrentWorkerListPtr)[i]; + if (lastWorker == NULL) { + break; + } + } + ASSERT(i < MAX_WORKERS); + + (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker)); + ASSERT(worker != NULL); + + worker->flags = WORKER_FLAG_1 | WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE; + worker->update = updateFunc; + if (updateFunc == NULL) { + worker->update = worker_delegate_do_nothing; + } + worker->draw = drawFunc; + if (drawFunc == NULL) { + worker->draw = worker_delegate_do_nothing; + } + + if (gGameStatusPtr->isBattle) { + i |= BATTLE_ENTITY_ID_MASK; + } + return i; +} + +s32 create_worker_frontUI(void (*updateFunc)(void), void (*drawFunc)(void)) { + Worker* worker; + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* lastWorker = (*gCurrentWorkerListPtr)[i]; + if (lastWorker == NULL) { + break; + } + } + ASSERT(i < MAX_WORKERS); + + (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker)); + ASSERT(worker != NULL); + + worker->flags = WORKER_FLAG_1 | WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE | WORKER_FLAG_FRONT_UI; + worker->update = updateFunc; + if (updateFunc == NULL) { + worker->update = worker_delegate_do_nothing; + } + worker->draw = drawFunc; + if (drawFunc == NULL) { + worker->draw = worker_delegate_do_nothing; + } + + if (gGameStatusPtr->isBattle) { + i |= BATTLE_ENTITY_ID_MASK; + } + return i; +} + +s32 create_worker_backUI(void (*updateFunc)(void), void (*drawFunc)(void)) { + Worker* worker; + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* lastWorker = (*gCurrentWorkerListPtr)[i]; + if (lastWorker == NULL) { + break; + } + } + ASSERT(i < MAX_WORKERS); + + (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker)); + ASSERT(worker != NULL); + + worker->flags = WORKER_FLAG_1 | WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE | WORKER_FLAG_BACK_UI; + worker->update = updateFunc; + if (updateFunc == NULL) { + worker->update = &worker_delegate_do_nothing; + } + worker->draw = drawFunc; + if (drawFunc == NULL) { + worker->draw = &worker_delegate_do_nothing; + } + + if (gGameStatusPtr->isBattle) { + i |= BATTLE_ENTITY_ID_MASK; + } + return i; +} + +void update_workers(void) { + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* worker = (*gCurrentWorkerListPtr)[i]; + if (worker != NULL) { + worker->flags &= ~WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE; + worker->update(); + } + } +} + +void render_workers_world(void) { + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* worker = (*gCurrentWorkerListPtr)[i]; + if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) { + if (!(worker->flags & WORKER_FLAG_FRONT_UI)) { + worker->draw(); + } + } + } +} + +void render_workers_frontUI(void) { + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* worker = (*gCurrentWorkerListPtr)[i]; + if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) { + if (worker->flags & WORKER_FLAG_FRONT_UI) { + worker->draw(); + } + } + } +} + +void render_workers_backUI(void) { + s32 i; + + for (i = 0; i < MAX_WORKERS; i++) { + Worker* worker = (*gCurrentWorkerListPtr)[i]; + if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) { + if (worker->flags & WORKER_FLAG_BACK_UI) { + worker->draw(); + } + } + } +} + +void free_worker(s32 idx) { + if (!gGameStatusPtr->isBattle || (idx & BATTLE_ENTITY_ID_MASK)) { + idx &= ~BATTLE_ENTITY_ID_MASK; + if ((*gCurrentWorkerListPtr)[idx] != NULL) { + heap_free((*gCurrentWorkerListPtr)[idx]); + (*gCurrentWorkerListPtr)[idx] = NULL; + } + } +} + +Worker* get_worker(s32 idx) { + return (*gCurrentWorkerListPtr)[idx & ~BATTLE_ENTITY_ID_MASK]; +} diff --git a/src/world/area_dro/dro_02/npc_merlee.c b/src/world/area_dro/dro_02/npc_merlee.c index 73ca24191b..444f2928b4 100644 --- a/src/world/area_dro/dro_02/npc_merlee.c +++ b/src/world/area_dro/dro_02/npc_merlee.c @@ -183,7 +183,7 @@ API_CALLABLE(N(CreateRitualCards)) { fold_update(ret, FOLD_TYPE_5, 0x12, 1, 1, 0, 0x800); evt_set_variable(script, RITUAL_VAR_FOLDER_4, ret); - evt_set_variable(script, RITUAL_VAR_WORKER, create_generic_entity_world( + evt_set_variable(script, RITUAL_VAR_WORKER, create_worker_world( N(card_worker_update), N(card_worker_render))); return ApiStatus_DONE2; @@ -194,7 +194,7 @@ API_CALLABLE(N(DestroyRitualCards)) { func_8013A854(evt_get_variable(script, RITUAL_VAR_FOLDER_2)); func_8013A854(evt_get_variable(script, RITUAL_VAR_FOLDER_3)); func_8013A854(evt_get_variable(script, RITUAL_VAR_FOLDER_4)); - free_generic_entity(evt_get_variable(script, RITUAL_VAR_WORKER)); + free_worker(evt_get_variable(script, RITUAL_VAR_WORKER)); return ApiStatus_DONE2; } diff --git a/src/world/area_end/end_00/end_00_0_header.c b/src/world/area_end/end_00/end_00_0_header.c index 09f989d080..480f1ca54e 100644 --- a/src/world/area_end/end_00/end_00_0_header.c +++ b/src/world/area_end/end_00/end_00_0_header.c @@ -1,7 +1,7 @@ #include "end_00.h" s32 N(map_init)(void) { - gGameStatusPtr->playerSpriteSet = 3; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_PARADE; return FALSE; } diff --git a/src/world/area_gv/gv_01/gv_01_1_main.c b/src/world/area_gv/gv_01/gv_01_1_main.c index 4f60986f21..71eb9b2062 100644 --- a/src/world/area_gv/gv_01/gv_01_1_main.c +++ b/src/world/area_gv/gv_01/gv_01_1_main.c @@ -155,10 +155,10 @@ ApiStatus N(ChangeStateToTitleScreen)(Evt* script, s32 isInitialCall) { gOverrideFlags &= ~GLOBAL_OVERRIDES_8; general_heap_create(); clear_render_tasks(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); - spr_init_sprites(0); + spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD); clear_entity_models(); clear_animator_list(); clear_model_data(); diff --git a/src/world/area_hos/hos_05/A2AAC0.c b/src/world/area_hos/hos_05/A2AAC0.c index b750c6c28f..0e1edb543f 100644 --- a/src/world/area_hos/hos_05/A2AAC0.c +++ b/src/world/area_hos/hos_05/A2AAC0.c @@ -933,7 +933,7 @@ ApiStatus func_80244454_A2E694(Evt* script, s32 isInitialCall) { return ApiStatus_BLOCK; } else { D_8024AA20_A34C60->unk_5C = 0; - free_generic_entity(D_8024AA20_A34C60->unk_00); + free_worker(D_8024AA20_A34C60->unk_00); D_8024AA20_A34C60->unk_00 = 0; return ApiStatus_DONE1; } diff --git a/src/world/area_isk/isk_05/97DAD0.c b/src/world/area_isk/isk_05/97DAD0.c index 0f7ea5ce92..0a46d4a9e5 100644 --- a/src/world/area_isk/isk_05/97DAD0.c +++ b/src/world/area_isk/isk_05/97DAD0.c @@ -106,14 +106,14 @@ ApiStatus func_80241B28_97F5F8(Evt* script, s32 isInitialCall) { ambush->alpha = 0.0f; ambush->foldID = 0; - ambush->workerID = create_generic_entity_frontUI(NULL, func_80241610_97F0E0); + ambush->workerID = create_worker_frontUI(NULL, func_80241610_97F0E0); return ApiStatus_DONE2; } ApiStatus func_80241C34_97F704(Evt* script, s32 isInitialCall) { StoneChompAmbushIsk05* ambush = &N(ChompAmbush); - free_generic_entity(ambush->workerID); + free_worker(ambush->workerID); return ApiStatus_DONE2; } diff --git a/src/world/area_isk/isk_13/98F7E0.c b/src/world/area_isk/isk_13/98F7E0.c index 384ac7d73d..2371600457 100644 --- a/src/world/area_isk/isk_13/98F7E0.c +++ b/src/world/area_isk/isk_13/98F7E0.c @@ -117,14 +117,14 @@ ApiStatus func_80241BA8_991388(Evt* script, s32 isInitialCall) { ambush->color.a = 0.0f; ambush->foldID = 0; - ambush->workerID = create_generic_entity_frontUI(NULL, func_80241610_990DF0); + ambush->workerID = create_worker_frontUI(NULL, func_80241610_990DF0); evt_set_variable(script, MapVar(10), (s32) ambush); return ApiStatus_DONE2; } ApiStatus func_80241D08_9914E8(Evt* script, s32 isInitialCall) { StoneChompAmbushIsk13* ambush = (StoneChompAmbushIsk13*) evt_get_variable(script, MapVar(10)); - free_generic_entity(ambush->workerID); + free_worker(ambush->workerID); return ApiStatus_DONE2; } diff --git a/src/world/area_isk/isk_14/992730.c b/src/world/area_isk/isk_14/992730.c index 412e76aa04..a8397908e9 100644 --- a/src/world/area_isk/isk_14/992730.c +++ b/src/world/area_isk/isk_14/992730.c @@ -103,14 +103,14 @@ ApiStatus func_80241AF0_994220(Evt* script, s32 isInitialCall) { ambush->renderYaw = 270.0f; ambush->foldID = 0; - ambush->workerID = create_generic_entity_frontUI(NULL, func_80241610_993D40); + ambush->workerID = create_worker_frontUI(NULL, func_80241610_993D40); return ApiStatus_DONE2; } ApiStatus func_80241BC4_9942F4(Evt* script, s32 isInitialCall) { StoneChompAmbushIsk14* ambush = &N(ChompAmbush); - free_generic_entity(ambush->workerID); + free_worker(ambush->workerID); return ApiStatus_DONE2; } diff --git a/src/world/area_kkj/kkj_00/ABB290.c b/src/world/area_kkj/kkj_00/ABB290.c index 1414e7cd3f..6228f4c7d7 100644 --- a/src/world/area_kkj/kkj_00/ABB290.c +++ b/src/world/area_kkj/kkj_00/ABB290.c @@ -7,8 +7,8 @@ extern SlideParams D_8024160C_ABC89C; extern SlideParams D_8024162C_ABC8BC; ApiStatus func_80240000_ABB290(Evt* script, s32 isInitialCall) { - if (evt_get_variable(NULL, GB_StoryProgress) >= 96) { - gGameStatusPtr->playerSpriteSet = 2; + if (evt_get_variable(NULL, GB_StoryProgress) >= STORY_EPILOGUE) { + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_COMBINED_EPILOGUE; } return ApiStatus_BLOCK; diff --git a/src/world/area_kkj/kkj_19/AF7950.c b/src/world/area_kkj/kkj_19/AF7950.c index 6dafc6527b..8755409087 100644 --- a/src/world/area_kkj/kkj_19/AF7950.c +++ b/src/world/area_kkj/kkj_19/AF7950.c @@ -65,7 +65,7 @@ ApiStatus func_802401FC_AF7B4C(Evt* script, s32 isInitialCall) { D_80240E8C_AF87DC = 0; D_80240E90_AF87E0 = 0; - get_generic_entity(create_generic_entity_frontUI(func_80240068_AF79B8, NULL)); + get_worker(create_worker_frontUI(func_80240068_AF79B8, NULL)); setup_pause_menu_tab(D_80240EF0_AF8840, ARRAY_COUNT(D_80240EF0_AF8840)); for (i = 0; i < 10; i++) { diff --git a/src/world/area_kkj/kkj_19/AF7C00.c b/src/world/area_kkj/kkj_19/AF7C00.c index 7852b03404..8a6c70fee6 100644 --- a/src/world/area_kkj/kkj_19/AF7C00.c +++ b/src/world/area_kkj/kkj_19/AF7C00.c @@ -112,7 +112,7 @@ ApiStatus func_802406C4_AF8014(Evt* script, s32 isInitialCall) { switch (D_80246558_kkj_19) { case 0: D_80246534 = evt_get_variable(script, *args++); - D_80246554 = create_generic_entity_frontUI(NULL, func_802406A0_AF7FF0); + D_80246554 = create_worker_frontUI(NULL, func_802406A0_AF7FF0); dgb_08_npcGroup_80246528 = 0; D_80246530 = 0; for (i = 0; i < 10; i++) { @@ -206,7 +206,7 @@ ApiStatus func_802406C4_AF8014(Evt* script, s32 isInitialCall) { script->varTable[0] = dgb_08_npcGroup_80246528; hud_element_free(D_80246568_C8C018[0]); hud_element_free(D_80246568_C8C018[1]); - free_generic_entity(D_80246554); + free_worker(D_80246554); return ApiStatus_DONE2; } diff --git a/src/world/area_kkj/kkj_25/B06D10.c b/src/world/area_kkj/kkj_25/B06D10.c index 4562f04b17..62c1f80804 100644 --- a/src/world/area_kkj/kkj_25/B06D10.c +++ b/src/world/area_kkj/kkj_25/B06D10.c @@ -23,7 +23,7 @@ ApiStatus func_802406EC_B070EC(Evt* script, s32 isInitialCall) { unkStruct->scale.y = SPRITE_WORLD_SCALE_F; unkStruct->scale.z = SPRITE_WORLD_SCALE_F; unkStruct->foldID = func_8013A704(1); - unkStruct->entityID = create_generic_entity_world(NULL, kkj_25_UnkFoldFunc); + unkStruct->entityID = create_worker_world(NULL, kkj_25_UnkFoldFunc); evt_set_variable(script, MapVar(10), (s32) unkStruct); return ApiStatus_DONE2; @@ -33,7 +33,7 @@ ApiStatus func_80240800_B07200(Evt* script, s32 isInitialCall) { UnkEntityStruct* unkStruct = (UnkEntityStruct*) evt_get_variable(NULL, MapVar(10)); func_8013A854(unkStruct->foldID); - free_generic_entity(unkStruct->entityID); + free_worker(unkStruct->entityID); heap_free(unkStruct); evt_set_variable(script, MapVar(10), 0); diff --git a/src/world/area_kmr/kmr_06/kmr_06_5_sticker_sign.c b/src/world/area_kmr/kmr_06/kmr_06_5_sticker_sign.c index 46e582a925..b84e069e76 100644 --- a/src/world/area_kmr/kmr_06/kmr_06_5_sticker_sign.c +++ b/src/world/area_kmr/kmr_06/kmr_06_5_sticker_sign.c @@ -108,7 +108,7 @@ API_CALLABLE(N(CreateSticker)) { iconPal); sticker->folderID = func_8013A704(1); - sticker->workerID = create_generic_entity_world(NULL, N(worker_render_sticker)); + sticker->workerID = create_worker_world(NULL, N(worker_render_sticker)); evt_set_variable(script, MapVar(10), (s32) sticker); evt_set_variable(script, MapVar(11), (s32) iconImg); evt_set_variable(script, MapVar(12), (s32) iconPal); @@ -204,7 +204,7 @@ API_CALLABLE(N(DeleteSticker)) { IMG_PTR img = (IMG_PTR) evt_get_variable(script, MV_StickerImage); PAL_PTR pal = (PAL_PTR) evt_get_variable(script, MV_StickerPalette); - free_generic_entity(data->workerID); + free_worker(data->workerID); heap_free(data); heap_free(img); diff --git a/src/world/area_kmr/kmr_20/8EBE50.c b/src/world/area_kmr/kmr_20/8EBE50.c index 7344f679d3..27d8f7f7ee 100644 --- a/src/world/area_kmr/kmr_20/8EBE50.c +++ b/src/world/area_kmr/kmr_20/8EBE50.c @@ -31,7 +31,7 @@ ApiStatus func_802406BC_8EC4DC(Evt* script, s32 isInitialCall) { INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_802406C8_8EC4E8); ApiStatus func_80240B20_8EC940(Evt* script, s32 isInitialCall) { - free_generic_entity(D_8025B2A8); + free_worker(D_8025B2A8); return ApiStatus_DONE2; } diff --git a/src/world/area_kmr/kmr_21/kmr_21_1_main.c b/src/world/area_kmr/kmr_21/kmr_21_1_main.c index 4e299c4495..69fa73ac6a 100644 --- a/src/world/area_kmr/kmr_21/kmr_21_1_main.c +++ b/src/world/area_kmr/kmr_21/kmr_21_1_main.c @@ -64,7 +64,7 @@ API_CALLABLE(N(LoadTitleImage)) { decode_yay0(compressed, TitleData); general_heap_free(compressed); TitleImage = (IMG_PTR)(TitleData->img_offset_title + (s32)TitleData); - create_generic_entity_frontUI(NULL, worker_render_title_image); + create_worker_frontUI(NULL, worker_render_title_image); return ApiStatus_DONE2; } diff --git a/src/world/area_kmr/kmr_22/8FF8B0.c b/src/world/area_kmr/kmr_22/8FF8B0.c index c31eb9bd22..c00f9c0a9e 100644 --- a/src/world/area_kmr/kmr_22/8FF8B0.c +++ b/src/world/area_kmr/kmr_22/8FF8B0.c @@ -41,7 +41,7 @@ ApiStatus func_80240B3C_9001AC(Evt* script, s32 isInitialCall) { ApiStatus func_80240B4C_9001BC(Evt* script, s32 isInitialCall) { evt_set_variable(script, MapVar(0), (s32) heap_malloc(0x780)); // TODO what is this D_802483D0 = -1; - create_generic_entity_world(NULL, func_80240B00_900170); + create_worker_world(NULL, func_80240B00_900170); return ApiStatus_DONE2; } diff --git a/src/world/area_kpa/kpa_53/A6ACA0.c b/src/world/area_kpa/kpa_53/A6ACA0.c index 9a28ddb615..977ed15832 100644 --- a/src/world/area_kpa/kpa_53/A6ACA0.c +++ b/src/world/area_kpa/kpa_53/A6ACA0.c @@ -1,7 +1,7 @@ #include "kpa_53.h" ApiStatus func_80240000_A6ACA0(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 2; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_COMBINED_EPILOGUE; sprintf(wMapShapeName, "kpa_50_shape"); sprintf(wMapHitName, "kpa_50_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_kzn/kzn_19/kzn_19_4_npc.c b/src/world/area_kzn/kzn_19/kzn_19_4_npc.c index 746c4bc344..9b859a6ccb 100644 --- a/src/world/area_kzn/kzn_19/kzn_19_4_npc.c +++ b/src/world/area_kzn/kzn_19/kzn_19_4_npc.c @@ -319,7 +319,7 @@ API_CALLABLE(N(CreateVineRenderer)) { LavaPiranhaVine* data = heap_malloc(NUM_VINES * sizeof(*data)); evt_set_variable(script, MV_VinesData, (s32) data); N(VineRenderState) = -1; - create_generic_entity_world(NULL, &N(worker_render_piranha_vines)); + create_worker_world(NULL, &N(worker_render_piranha_vines)); return ApiStatus_DONE2; } diff --git a/src/world/area_mac/mac_01/8017D0.c b/src/world/area_mac/mac_01/8017D0.c index def06d3895..9a0bb48d90 100644 --- a/src/world/area_mac/mac_01/8017D0.c +++ b/src/world/area_mac/mac_01/8017D0.c @@ -48,7 +48,7 @@ ApiStatus func_80243380_803C00(Evt* script, s32 isInitialCall) { temp_v0->scale.y = SPRITE_WORLD_SCALE_F; temp_v0->scale.z = SPRITE_WORLD_SCALE_F; temp_v0->foldID = func_8013A704(1); - temp_v0->entityID = create_generic_entity_world(NULL, mac_01_UnkFoldFunc); + temp_v0->entityID = create_worker_world(NULL, mac_01_UnkFoldFunc); evt_set_variable(script, MapVar(10), (s32) temp_v0); return ApiStatus_DONE2; } @@ -57,7 +57,7 @@ ApiStatus func_80243494_803D14(Evt* script, s32 isInitialCall) { UnkEntityStruct* temp_v0 = (UnkEntityStruct*) evt_get_variable(NULL, MapVar(10)); func_8013A854(temp_v0->foldID); - free_generic_entity(temp_v0->entityID); + free_worker(temp_v0->entityID); heap_free(temp_v0); evt_set_variable(script, MapVar(10), NULL); return ApiStatus_DONE2; diff --git a/src/world/area_mac/mac_04/844860.c b/src/world/area_mac/mac_04/844860.c index 0e6068860c..669d0207b5 100644 --- a/src/world/area_mac/mac_04/844860.c +++ b/src/world/area_mac/mac_04/844860.c @@ -6,7 +6,7 @@ void func_80241DAC_84497C(void*); ApiStatus func_80241C90_844860(Evt* script, s32 isInitialCall) { gPlayerStatus.animFlags |= PA_FLAGS_IN_DISGUISE; - evt_set_variable(script, MapVar(11), create_generic_entity_world(NULL, func_80241D30_844900)); + evt_set_variable(script, MapVar(11), create_worker_world(NULL, func_80241D30_844900)); return ApiStatus_DONE2; } @@ -14,7 +14,7 @@ ApiStatus func_80241C90_844860(Evt* script, s32 isInitialCall) { ApiStatus func_80241CEC_8448BC(Evt* script, s32 isInitialCall) { s32 index = evt_get_variable(script, MapVar(11)); gPlayerStatus.animFlags &= ~PA_FLAGS_IN_DISGUISE; - free_generic_entity(index); + free_worker(index); return ApiStatus_DONE2; } diff --git a/src/world/area_mgm/mgm_00/mgm_00_3_scoreboard.c b/src/world/area_mgm/mgm_00/mgm_00_3_scoreboard.c index 1dc6248d1c..6eef514a4a 100644 --- a/src/world/area_mgm/mgm_00/mgm_00_3_scoreboard.c +++ b/src/world/area_mgm/mgm_00/mgm_00_3_scoreboard.c @@ -141,13 +141,13 @@ API_CALLABLE(N(UpdateRecordDisplay)) { script->functionTempPtr[0] = data; data->state = RECORD_START_SHOW; data->alpha = 255; - data->workerID = create_generic_entity_world(NULL, &N(work_draw_record)); + data->workerID = create_worker_world(NULL, &N(work_draw_record)); data->gameType = gameType; evt_set_variable(script, MV_RecordDisplayData, (s32)data); } data = script->functionTempPtr[0]; if (data->state == RECORD_STATE_DONE) { - free_generic_entity(data->workerID); + free_worker(data->workerID); heap_free(data); return ApiStatus_DONE1; } diff --git a/src/world/area_mgm/mgm_01/mgm_01_2_npc.c b/src/world/area_mgm/mgm_01/mgm_01_2_npc.c index beafb7582a..8f893441ce 100644 --- a/src/world/area_mgm/mgm_01/mgm_01_2_npc.c +++ b/src/world/area_mgm/mgm_01/mgm_01_2_npc.c @@ -628,7 +628,7 @@ API_CALLABLE(N(CreateMinigame)) { s32 hudElemID; scorekeeper->varTablePtr[JUMP_DATA_VAR_IDX] = data; - data->workerID = create_generic_entity_world(NULL, &mgm_01_worker_draw_score); + data->workerID = create_worker_world(NULL, &mgm_01_worker_draw_score); hudElemID = hud_element_create(&HES_StatusCoin); data->hudElemID = hudElemID; @@ -646,7 +646,7 @@ API_CALLABLE(N(CreateMinigame)) { API_CALLABLE(N(DestroyMinigame)) { JumpGameData* data = get_enemy(SCOREKEEPER_ENEMY_IDX)->varTablePtr[JUMP_DATA_VAR_IDX]; - free_generic_entity(data->workerID); + free_worker(data->workerID); hud_element_free(data->hudElemID); return ApiStatus_DONE2; diff --git a/src/world/area_mgm/mgm_02/mgm_02_2_npc.c b/src/world/area_mgm/mgm_02/mgm_02_2_npc.c index 9c5152b257..54eb75977e 100644 --- a/src/world/area_mgm/mgm_02/mgm_02_2_npc.c +++ b/src/world/area_mgm/mgm_02/mgm_02_2_npc.c @@ -196,7 +196,7 @@ API_CALLABLE(N(CreateScoreDisplay)) { s32 hudElemA, hudElemMeter; if (isInitialCall) { - data->workerID = create_generic_entity_world(NULL, &N(worker_draw_score)); + data->workerID = create_worker_world(NULL, &N(worker_draw_score)); hudElemA = hud_element_create(&HES_AButton); data->hudElemID_AButton = hudElemA; @@ -967,7 +967,7 @@ API_CALLABLE(N(CreateMinigame)) { API_CALLABLE(N(DestroyMinigame)) { SmashGameData* data = get_enemy(SCOREKEEPER_ENEMY_IDX)->varTablePtr[SMASH_DATA_VAR_IDX]; - free_generic_entity(data->workerID); + free_worker(data->workerID); hud_element_free(data->hudElemID_AButton); hud_element_free(data->hudElemID_Meter); diff --git a/src/world/area_obk/obk_07/BCF0F0.c b/src/world/area_obk/obk_07/BCF0F0.c index bc93bff260..52dc62cf0e 100644 --- a/src/world/area_obk/obk_07/BCF0F0.c +++ b/src/world/area_obk/obk_07/BCF0F0.c @@ -114,7 +114,7 @@ ApiStatus func_80241168_BCFD58(Evt* script, s32 isInitialCall) { s32 i; gOverrideFlags |= GLOBAL_OVERRIDES_10; - temp_s1->unk_2C = create_generic_entity_frontUI(func_80240A6C_BCF65C, func_802410C0_BCFCB0); + temp_s1->unk_2C = create_worker_frontUI(func_80240A6C_BCF65C, func_802410C0_BCFCB0); temp_s1->unk_30 = 0; temp_s1->unk_04 = 0; temp_s1->unk_08 = 0; @@ -179,7 +179,7 @@ ApiStatus func_802413D0_BCFFC0(Evt* script, s32 isInitialCall) { hud_element_free(temp_v0->unk_3C); hud_element_free(temp_v0->unk_40); hud_element_free(temp_v0->unk_44); - free_generic_entity(temp_v0->unk_2C); + free_worker(temp_v0->unk_2C); return ApiStatus_DONE2; } diff --git a/src/world/area_obk/obk_08/BD3870.c b/src/world/area_obk/obk_08/BD3870.c index 15f6f2269e..de5a5137e2 100644 --- a/src/world/area_obk/obk_08/BD3870.c +++ b/src/world/area_obk/obk_08/BD3870.c @@ -8,7 +8,7 @@ ApiStatus func_802404F0_BD3D60(Evt* script, s32 isInitialCall) { UnkEntityStruct* temp_v0 = (UnkEntityStruct*) evt_get_variable(NULL, MapVar(10)); func_8013A854(temp_v0->foldID); - free_generic_entity(temp_v0->entityID); + free_worker(temp_v0->entityID); heap_free(temp_v0); evt_set_variable(script, MapVar(10), NULL); return ApiStatus_DONE2; diff --git a/src/world/area_osr/osr_04/AB92B0.c b/src/world/area_osr/osr_04/AB92B0.c index a2deb79c91..fa4ea5b96f 100644 --- a/src/world/area_osr/osr_04/AB92B0.c +++ b/src/world/area_osr/osr_04/AB92B0.c @@ -1,7 +1,7 @@ #include "osr_04.h" ApiStatus func_80240000_AB92B0(Evt *script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 2; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_COMBINED_EPILOGUE; sprintf(wMapShapeName, "osr_03_shape"); sprintf(wMapHitName, "osr_03_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_06/D57430.c b/src/world/area_pra/pra_06/D57430.c index 1c288671ee..308f269086 100644 --- a/src/world/area_pra/pra_06/D57430.c +++ b/src/world/area_pra/pra_06/D57430.c @@ -1,7 +1,7 @@ #include "pra_06.h" ApiStatus func_80240000_D57430(void) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_05_shape"); sprintf(wMapHitName, "pra_05_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_12/D62D10.c b/src/world/area_pra/pra_12/D62D10.c index 5694549df3..914274ecbb 100644 --- a/src/world/area_pra/pra_12/D62D10.c +++ b/src/world/area_pra/pra_12/D62D10.c @@ -1,7 +1,7 @@ #include "pra_12.h" ApiStatus func_80240000_D62D10(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_05_shape"); sprintf(wMapHitName, "pra_05_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_13/D64600.c b/src/world/area_pra/pra_13/D64600.c index 1ce11c78c6..640c5b015e 100644 --- a/src/world/area_pra/pra_13/D64600.c +++ b/src/world/area_pra/pra_13/D64600.c @@ -74,7 +74,7 @@ void func_8024140C_D659EC(void); void func_802414BC_D65A9C(void* npc); ApiStatus func_802413D0_D659B0(Evt* script, s32 isInitialCall) { - script->array[0] = create_generic_entity_world(0, func_8024140C_D659EC); + script->array[0] = create_worker_world(0, func_8024140C_D659EC); return ApiStatus_DONE2; } diff --git a/src/world/area_pra/pra_19/D6E9D0.c b/src/world/area_pra/pra_19/D6E9D0.c index ed1e36ae4c..2a7b3fa5fb 100644 --- a/src/world/area_pra/pra_19/D6E9D0.c +++ b/src/world/area_pra/pra_19/D6E9D0.c @@ -105,7 +105,7 @@ void func_802415E0_D6FF90(void* data); void func_80241530_D6FEE0(void); ApiStatus func_802414F4_D6FEA4(Evt* script, s32 isInitialCall) { - script->array[0] = create_generic_entity_world(0, func_80241530_D6FEE0); + script->array[0] = create_worker_world(0, func_80241530_D6FEE0); return ApiStatus_DONE2; } diff --git a/src/world/area_pra/pra_27/D799F0.c b/src/world/area_pra/pra_27/D799F0.c index 8535d8f2f6..b2661a9fd2 100644 --- a/src/world/area_pra/pra_27/D799F0.c +++ b/src/world/area_pra/pra_27/D799F0.c @@ -1,7 +1,7 @@ #include "pra_27.h" ApiStatus func_80240000_D799F0(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_05_shape"); sprintf(wMapHitName, "pra_05_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_28/D7B2A0.c b/src/world/area_pra/pra_28/D7B2A0.c index 1e4b4fd191..0105479f9e 100644 --- a/src/world/area_pra/pra_28/D7B2A0.c +++ b/src/world/area_pra/pra_28/D7B2A0.c @@ -1,7 +1,7 @@ #include "pra_28.h" ApiStatus func_80240000_D7B2A0(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_05_shape"); sprintf(wMapHitName, "pra_05_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_31/D7ED60.c b/src/world/area_pra/pra_31/D7ED60.c index 7404e58d98..1f6fd35944 100644 --- a/src/world/area_pra/pra_31/D7ED60.c +++ b/src/world/area_pra/pra_31/D7ED60.c @@ -4,6 +4,6 @@ static char* N(exit_str_0) = "pra_34"; static char* N(exit_str_1) = "pra_40"; ApiStatus func_80240000_D7ED60(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; return ApiStatus_BLOCK; } diff --git a/src/world/area_pra/pra_36/D91700.c b/src/world/area_pra/pra_36/D91700.c index a02b23f478..f0bd0d9ba3 100644 --- a/src/world/area_pra/pra_36/D91700.c +++ b/src/world/area_pra/pra_36/D91700.c @@ -1,7 +1,7 @@ #include "pra_36.h" ApiStatus func_80240000_D91700(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_10_shape"); sprintf(wMapHitName, "pra_10_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_37/D92F40.c b/src/world/area_pra/pra_37/D92F40.c index 51eb2f3e45..d1ecd084c0 100644 --- a/src/world/area_pra/pra_37/D92F40.c +++ b/src/world/area_pra/pra_37/D92F40.c @@ -1,7 +1,7 @@ #include "pra_37.h" ApiStatus func_80240000_D92F40(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_10_shape"); sprintf(wMapHitName, "pra_10_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_38/D955F0.c b/src/world/area_pra/pra_38/D955F0.c index fe33c49047..588e6ac466 100644 --- a/src/world/area_pra/pra_38/D955F0.c +++ b/src/world/area_pra/pra_38/D955F0.c @@ -1,7 +1,7 @@ #include "pra_38.h" ApiStatus func_80240000_D955F0(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_10_shape"); sprintf(wMapHitName, "pra_10_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_pra/pra_39/D97890.c b/src/world/area_pra/pra_39/D97890.c index 30892a2c58..78cf628534 100644 --- a/src/world/area_pra/pra_39/D97890.c +++ b/src/world/area_pra/pra_39/D97890.c @@ -1,7 +1,7 @@ #include "pra_39.h" ApiStatus func_80240000_D97890(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; sprintf(wMapShapeName, "pra_10_shape"); sprintf(wMapHitName, "pra_10_hit"); return ApiStatus_BLOCK; diff --git a/src/world/area_trd/trd_05/trd_05_3_trap.c b/src/world/area_trd/trd_05/trd_05_3_trap.c index dcc365459b..80f16db504 100644 --- a/src/world/area_trd/trd_05/trd_05_3_trap.c +++ b/src/world/area_trd/trd_05/trd_05_3_trap.c @@ -87,13 +87,13 @@ API_CALLABLE(N(InitializeFallingSprite)) { falling->scale.y = SPRITE_WORLD_SCALE_F; falling->scale.z = SPRITE_WORLD_SCALE_F; falling->foldStateID = func_8013A704(1); - falling->workerID = create_generic_entity_world(0, &N(appendGfx_FallingSprite)); + falling->workerID = create_worker_world(0, &N(appendGfx_FallingSprite)); return ApiStatus_DONE2; } API_CALLABLE(N(DeleteFallingSprite)) { func_8013A854(N(Falling).foldStateID); - free_generic_entity(N(Falling).workerID); + free_worker(N(Falling).workerID); return ApiStatus_DONE2; } diff --git a/src/world/area_trd/trd_06/trd_06_2_falling.c b/src/world/area_trd/trd_06/trd_06_2_falling.c index 47b5d5e81c..3df5b026a5 100644 --- a/src/world/area_trd/trd_06/trd_06_2_falling.c +++ b/src/world/area_trd/trd_06/trd_06_2_falling.c @@ -95,13 +95,13 @@ API_CALLABLE(N(InitializeFallingSprite)) { falling->scale.z = SPRITE_WORLD_SCALE_F; falling->foldStateID = func_8013A704(1); - falling->workerID = create_generic_entity_world(0, &N(appendGfx_FallingSprite)); + falling->workerID = create_worker_world(0, &N(appendGfx_FallingSprite)); return ApiStatus_DONE2; } API_CALLABLE(N(DeleteFallingSprite)) { func_8013A854(N(Falling).foldStateID); - free_generic_entity(N(Falling).workerID); + free_worker(N(Falling).workerID); return ApiStatus_DONE2; } diff --git a/src/world/area_tst/tst_04/tst_04_3_reflection.c b/src/world/area_tst/tst_04/tst_04_3_reflection.c index 7bd5a8e144..0a83230dc0 100644 --- a/src/world/area_tst/tst_04/tst_04_3_reflection.c +++ b/src/world/area_tst/tst_04/tst_04_3_reflection.c @@ -9,7 +9,7 @@ void N(worker_update_partner_reflection)(void); static s32 N(Animator); API_CALLABLE(N(EnablePlayerReflection)) { - script->array[0] = (s32) create_generic_entity_frontUI(NULL, &N(worker_render_player_reflection)); + script->array[0] = (s32) create_worker_frontUI(NULL, &N(worker_render_player_reflection)); return ApiStatus_DONE2; } @@ -63,7 +63,7 @@ void N(appendGfx_test_player_reflection)(void* data) { API_CALLABLE(N(EnablePartnerReflection)) { Npc* partner; - script->array[1] = create_generic_entity_world(&N(worker_update_partner_reflection), NULL); + script->array[1] = create_worker_world(&N(worker_update_partner_reflection), NULL); partner = get_npc_safe(NPC_PARTNER); if (partner == NULL) { @@ -101,7 +101,7 @@ void N(worker_render_animator)(void) { } API_CALLABLE(N(SetupAnimatedModel)) { - create_generic_entity_world(N(worker_update_animator), N(worker_render_animator)); + create_worker_world(N(worker_update_animator), N(worker_render_animator)); return ApiStatus_DONE2; } diff --git a/src/world/area_tst/tst_11/tst_11_2_extra.c b/src/world/area_tst/tst_11/tst_11_2_extra.c index e3286ab3e4..86202706da 100644 --- a/src/world/area_tst/tst_11/tst_11_2_extra.c +++ b/src/world/area_tst/tst_11/tst_11_2_extra.c @@ -9,7 +9,7 @@ void N(test_reflection_worker_partner)(void); // identical to final version API_CALLABLE(N(EnableWallReflectionTest)) { - script->array[0] = (s32) create_generic_entity_frontUI(NULL, N(test_reflection_worker_render_wall)); + script->array[0] = (s32) create_worker_frontUI(NULL, N(test_reflection_worker_render_wall)); return ApiStatus_DONE2; } @@ -60,7 +60,7 @@ void N(appendGfx_test_reflection_wall)(void* data) { } API_CALLABLE(N(EnableFloorReflectionTest)) { - script->array[0] = (s32) create_generic_entity_frontUI(NULL, &N(test_reflection_worker_render_floor)); + script->array[0] = (s32) create_worker_frontUI(NULL, &N(test_reflection_worker_render_floor)); return ApiStatus_DONE2; } @@ -127,7 +127,7 @@ void N(appendGfx_test_reflection_floor)(void* data) { API_CALLABLE(N(PartnerReflectTest)) { Npc* partner; - script->array[1] = create_generic_entity_world(N(test_reflection_worker_partner), NULL); + script->array[1] = create_worker_world(N(test_reflection_worker_partner), NULL); partner = get_npc_safe(NPC_PARTNER); if (partner == NULL) { diff --git a/src/world/common/atomic/Credits.inc.c b/src/world/common/atomic/Credits.inc.c index 7efefc990d..baf918cc9a 100644 --- a/src/world/common/atomic/Credits.inc.c +++ b/src/world/common/atomic/Credits.inc.c @@ -791,7 +791,7 @@ void N(init_credits)(void) { s32 i; N(CreditsDataPtr) = &N(CreditsData); - N(CreditsData).workerID = create_generic_entity_frontUI(NULL, N(credits_worker_render)); + N(CreditsData).workerID = create_worker_frontUI(NULL, N(credits_worker_render)); for (i = 0; i < ARRAY_COUNT(N(CreditsData).lines); i++) { N(CreditsData).lines[i].flags = 0; diff --git a/src/world/common/atomic/Quizmo.inc.c b/src/world/common/atomic/Quizmo.inc.c index 41f7c968e1..c9a6b624ca 100644 --- a/src/world/common/atomic/Quizmo.inc.c +++ b/src/world/common/atomic/Quizmo.inc.c @@ -292,7 +292,7 @@ ApiStatus N(Quizmo_DestroyEffects)(Evt* script, s32 isInitialCall) { if (stageData->microphoneRaiseAmt <= 0) { stageData->microphoneRaiseAmt = 0; remove_effect(N(Quizmo_StageEffect)); - free_generic_entity(N(Quizmo_Worker)); + free_worker(N(Quizmo_Worker)); return ApiStatus_DONE2; } @@ -461,6 +461,6 @@ void N(Quizmo_CreateReactionEffect)(void) { } ApiStatus N(Quizmo_CreateWorker)(Evt* script, s32 isInitialCall) { - N(Quizmo_Worker) = create_generic_entity_frontUI(NULL, N(Quizmo_CreateReactionEffect)); + N(Quizmo_Worker) = create_worker_frontUI(NULL, N(Quizmo_CreateReactionEffect)); return ApiStatus_DONE2; } diff --git a/src/world/common/atomic/Reflection.inc.c b/src/world/common/atomic/Reflection.inc.c index 03a27a5d71..fc8c7d2f71 100644 --- a/src/world/common/atomic/Reflection.inc.c +++ b/src/world/common/atomic/Reflection.inc.c @@ -63,7 +63,7 @@ s32 N(reflection_unk_change_anim_facing)(s32 playerAnim) { } API_CALLABLE(N(EnableWallReflection)){ - script->array[0] = (s32) create_generic_entity_world(NULL, N(worker_reflect_player_wall)); + script->array[0] = (s32) create_worker_world(NULL, N(worker_reflect_player_wall)); return ApiStatus_DONE2; } @@ -140,7 +140,7 @@ API_CALLABLE(N(EnableFloorReflection)){ switch (script->varTable[0]) { case REFLECTION_FLOOR_WALL: case REFLECTION_FLOOR: - script->array[0] = create_generic_entity_world(NULL, N(worker_reflect_player_floor)); + script->array[0] = create_worker_world(NULL, N(worker_reflect_player_floor)); gOverrideFlags |= GLOBAL_OVERRIDES_80; break; case REFLECTION_WALL: @@ -320,20 +320,20 @@ API_CALLABLE(N(EnablePartnerReflection)){ if (script->varTable[1] == FALSE) { switch (script->varTable[0]) { case REFLECTION_FLOOR_WALL: - script->array[1] = create_generic_entity_world(N(worker_reflect_partner_all), NULL); + script->array[1] = create_worker_world(N(worker_reflect_partner_all), NULL); break; case REFLECTION_FLOOR: - script->array[1] = create_generic_entity_world(N(worker_reflect_partner_floor), NULL); + script->array[1] = create_worker_world(N(worker_reflect_partner_floor), NULL); break; case REFLECTION_WALL: - script->array[1] = create_generic_entity_world(N(worker_reflect_partner_wall), NULL); + script->array[1] = create_worker_world(N(worker_reflect_partner_wall), NULL); break; } } else { switch (script->varTable[0]) { case REFLECTION_FLOOR_WALL: case REFLECTION_FLOOR: - script->array[1] = create_generic_entity_world(N(worker_reflect_partner_floor), NULL); + script->array[1] = create_worker_world(N(worker_reflect_partner_floor), NULL); break; case REFLECTION_WALL: break; diff --git a/src/world/common/complete/Quizmo.inc.c b/src/world/common/complete/Quizmo.inc.c index 05d100129e..05abd26baf 100644 --- a/src/world/common/complete/Quizmo.inc.c +++ b/src/world/common/complete/Quizmo.inc.c @@ -345,7 +345,7 @@ API_CALLABLE(N(Quizmo_DestroyEffects)) { if (stageData->microphoneRaiseAmt <= 0) { stageData->microphoneRaiseAmt = 0; remove_effect(N(Quizmo_StageEffect)); - free_generic_entity(N(Quizmo_Worker)); + free_worker(N(Quizmo_Worker)); return ApiStatus_DONE2; } @@ -514,7 +514,7 @@ void N(Quizmo_CreateReactionEffect)(void) { } API_CALLABLE(N(Quizmo_CreateWorker)) { - N(Quizmo_Worker) = create_generic_entity_frontUI(NULL, N(Quizmo_CreateReactionEffect)); + N(Quizmo_Worker) = create_worker_frontUI(NULL, N(Quizmo_CreateReactionEffect)); return ApiStatus_DONE2; } diff --git a/src/world/common/todo/SetGameStatusUnk84_1.inc.c b/src/world/common/todo/SetGameStatusUnk84_1.inc.c index 30418d9fac..5701a4cb9c 100644 --- a/src/world/common/todo/SetGameStatusUnk84_1.inc.c +++ b/src/world/common/todo/SetGameStatusUnk84_1.inc.c @@ -2,6 +2,6 @@ #include "npc.h" ApiStatus N(SetGameStatusUnk84_1)(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 1; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_REFLECT_FLOOR; return ApiStatus_BLOCK; } diff --git a/src/world/common/todo/SetPlayerSpriteSet2.inc.c b/src/world/common/todo/SetPlayerSpriteSet2.inc.c index 0bff233950..41644ce097 100644 --- a/src/world/common/todo/SetPlayerSpriteSet2.inc.c +++ b/src/world/common/todo/SetPlayerSpriteSet2.inc.c @@ -1,6 +1,6 @@ #include "common.h" ApiStatus N(SetPlayerSpriteSet2)(Evt* script, s32 isInitialCall) { - gGameStatusPtr->playerSpriteSet = 2; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_COMBINED_EPILOGUE; return ApiStatus_BLOCK; } diff --git a/src/world/dead/kzn_19/EA8AE0.c b/src/world/dead/kzn_19/EA8AE0.c index 46a904ccc4..ebea58c9ca 100644 --- a/src/world/dead/kzn_19/EA8AE0.c +++ b/src/world/dead/kzn_19/EA8AE0.c @@ -280,7 +280,7 @@ ApiStatus func_8024140C_EA9EEC(Evt* script, s32 isInitialCall) { LavaPiranhaVine* data = heap_malloc(NUM_VINES * sizeof(*data)); evt_set_variable(script, MV_VinesData, (s32) data); D_80248380 = -1; - create_generic_entity_world(0, &func_802413C0_EA9EA0); + create_worker_world(0, &func_802413C0_EA9EA0); return ApiStatus_DONE2; } diff --git a/src/world/partners.c b/src/world/partners.c index 451f5be38a..c60d7494cb 100644 --- a/src/world/partners.c +++ b/src/world/partners.c @@ -990,7 +990,7 @@ void partner_reset_data(void) { s32 currentPartner = gPlayerData.currentPartner; mem_clear(&gPartnerActionStatus, sizeof(gPartnerActionStatus)); - get_generic_entity(create_generic_entity_frontUI(_use_partner_ability, NULL)); + get_worker(create_worker_frontUI(_use_partner_ability, NULL)); D_8010CFE0 = 1; D_8010CFE8 = 9; diff --git a/src/world/script_api/7E0E80.c b/src/world/script_api/7E0E80.c index b6fc8e13ea..128dbccd67 100644 --- a/src/world/script_api/7E0E80.c +++ b/src/world/script_api/7E0E80.c @@ -924,7 +924,7 @@ ApiStatus MakeShop(Evt* script, s32 isInitialCall) { shop->costIconID = hud_element_create(&HES_Item_Coin); hud_element_set_flags(shop->costIconID, HUD_ELEMENT_FLAGS_80); hud_element_clear_flags(shop->costIconID, HUD_ELEMENT_FLAGS_FILTER_TEX); - get_generic_entity(create_generic_entity_frontUI(NULL, draw_shop_items)); + get_worker(create_worker_frontUI(NULL, draw_shop_items)); set_window_properties(WINDOW_ID_10, 100, 66, 120, 28, 0, shop_draw_item_name, NULL, -1); set_window_properties(WINDOW_ID_11, 32, 184, 256, 32, 1, shop_draw_item_desc, NULL, -1); gWindowStyles[10].defaultStyleID = 9; diff --git a/src/world/world.c b/src/world/world.c index a1289db49c..3a24ccd961 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -48,11 +48,11 @@ void load_map_by_IDs(s16 areaID, s16 mapID, s16 loadType) { gOverrideFlags &= ~GLOBAL_OVERRIDES_40; gOverrideFlags &= ~GLOBAL_OVERRIDES_80; - gGameStatusPtr->playerSpriteSet = 0; + gGameStatusPtr->playerSpriteSet = PLAYER_SPRITES_MARIO_WORLD; func_8002D160(); func_802B2078(); clear_render_tasks(); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); switch (loadType) { @@ -116,7 +116,7 @@ void load_map_by_IDs(s16 areaID, s16 mapID, s16 loadType) { func_8002D160(); func_802B2078(); sfx_clear_env_sounds(0); - clear_generic_entity_list(); + clear_worker_list(); clear_script_list(); create_cameras_a(); spr_init_sprites(gGameStatusPtr->playerSpriteSet); diff --git a/tools/ignored_funcs.txt b/tools/ignored_funcs.txt index 8d0c7ef2a4..80d6a807ba 100644 --- a/tools/ignored_funcs.txt +++ b/tools/ignored_funcs.txt @@ -48,7 +48,7 @@ func_8004D8E0 = 0x8004D8E0; dead_LoadPath = 0x802E2A80; dead_GetNextPathPos = 0x802E2B74; dead_queue_render_task = 0x80128510; -dead_create_generic_entity_world = 0x8012DFE8; +dead_create_worker_world = 0x8012DFE8; dead_dma_copy = 0x8002AA2C; func_80059AC8 = 0x80059AC8; dead_get_entity_by_index = 0x80118BB0; diff --git a/ver/us/asm/bss.s b/ver/us/asm/bss.s index 3ad665d580..a0f1f485ea 100644 --- a/ver/us/asm/bss.s +++ b/ver/us/asm/bss.s @@ -1072,14 +1072,8 @@ dlabel D_800DC4E0 dlabel D_800DC4E4 .space 4 -dlabel D_800DC4E8 -.space 2 - -dlabel gCurrentBattleSection -.space 1 - -dlabel D_800DC4EB -.space 1 +dlabel gCurrentBattleID +.space 4 dlabel D_800DC4EC .space 4 diff --git a/ver/us/asm/bss3.s b/ver/us/asm/bss3.s index 5c5a061433..c815929067 100644 --- a/ver/us/asm/bss3.s +++ b/ver/us/asm/bss3.s @@ -430,13 +430,13 @@ dlabel entity_fog_dist_max dlabel D_80154394 .space 0x0000000c -dlabel gWorldDynamicEntityList +dlabel gWorldWorkerList .space 0x00000040 -dlabel gBattleDynamicEntityList +dlabel gBattleWorkerList .space 0x00000040 -dlabel gCurrentDynamicEntityListPtr +dlabel gCurrentWorkerListPtr .space 4 dlabel D_80154424 diff --git a/ver/us/asm/nonmatchings/world/area_hos/hos_05/A2AAC0/func_80243FC4_A2E204.s b/ver/us/asm/nonmatchings/world/area_hos/hos_05/A2AAC0/func_80243FC4_A2E204.s index 8b64c6c223..33a9a0cfb1 100644 --- a/ver/us/asm/nonmatchings/world/area_hos/hos_05/A2AAC0/func_80243FC4_A2E204.s +++ b/ver/us/asm/nonmatchings/world/area_hos/hos_05/A2AAC0/func_80243FC4_A2E204.s @@ -7,7 +7,7 @@ glabel func_80243FC4_A2E204 /* A2E20C 80243FCC 3C058024 */ lui $a1, %hi(func_80243CC0_A2DF00) /* A2E210 80243FD0 24A53CC0 */ addiu $a1, $a1, %lo(func_80243CC0_A2DF00) /* A2E214 80243FD4 AFBF0014 */ sw $ra, 0x14($sp) -/* A2E218 80243FD8 0C048C8F */ jal create_generic_entity_frontUI +/* A2E218 80243FD8 0C048C8F */ jal create_worker_frontUI /* A2E21C 80243FDC AFB00010 */ sw $s0, 0x10($sp) /* A2E220 80243FE0 3C040001 */ lui $a0, 1 /* A2E224 80243FE4 3C108025 */ lui $s0, %hi(D_8024AA20_A34C60) diff --git a/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EBE50/func_802406C8_8EC4E8.s b/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EBE50/func_802406C8_8EC4E8.s index 83b7c7d3c9..390aec9397 100644 --- a/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EBE50/func_802406C8_8EC4E8.s +++ b/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EBE50/func_802406C8_8EC4E8.s @@ -278,7 +278,7 @@ glabel func_802406C8_8EC4E8 /* 8EC8E0 80240AC0 8FA70010 */ lw $a3, 0x10($sp) /* 8EC8E4 80240AC4 3C058024 */ lui $a1, %hi(func_802405BC_8EC3DC) /* 8EC8E8 80240AC8 24A505BC */ addiu $a1, $a1, %lo(func_802405BC_8EC3DC) -/* 8EC8EC 80240ACC 0C048C8F */ jal create_generic_entity_frontUI +/* 8EC8EC 80240ACC 0C048C8F */ jal create_worker_frontUI /* 8EC8F0 80240AD0 AE270024 */ sw $a3, 0x24($s1) /* 8EC8F4 80240AD4 3C018026 */ lui $at, %hi(D_8025B2A8) /* 8EC8F8 80240AD8 AC22B2A8 */ sw $v0, %lo(D_8025B2A8)($at) diff --git a/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EDFC0/func_80242B04_8EE924.s b/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EDFC0/func_80242B04_8EE924.s index 1b51514682..3ecbaf0908 100644 --- a/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EDFC0/func_80242B04_8EE924.s +++ b/ver/us/asm/nonmatchings/world/area_kmr/kmr_20/8EDFC0/func_80242B04_8EE924.s @@ -17,7 +17,7 @@ glabel func_80242B04_8EE924 /* 8EE954 80242B34 240200FF */ addiu $v0, $zero, 0xff /* 8EE958 80242B38 AE300070 */ sw $s0, 0x70($s1) /* 8EE95C 80242B3C A6000000 */ sh $zero, ($s0) -/* 8EE960 80242B40 0C048C56 */ jal create_generic_entity_world +/* 8EE960 80242B40 0C048C56 */ jal create_worker_world /* 8EE964 80242B44 A602001A */ sh $v0, 0x1a($s0) /* 8EE968 80242B48 0220202D */ daddu $a0, $s1, $zero /* 8EE96C 80242B4C 3C05FD05 */ lui $a1, 0xfd05 @@ -34,7 +34,7 @@ glabel func_80242B04_8EE924 /* 8EE994 80242B74 14620007 */ bne $v1, $v0, .L80242B94 /* 8EE998 80242B78 0000102D */ daddu $v0, $zero, $zero /* 8EE99C 80242B7C 8E040020 */ lw $a0, 0x20($s0) -/* 8EE9A0 80242B80 0C048D70 */ jal free_generic_entity +/* 8EE9A0 80242B80 0C048D70 */ jal free_worker /* 8EE9A4 80242B84 00000000 */ nop /* 8EE9A8 80242B88 0C00AB4B */ jal heap_free /* 8EE9AC 80242B8C 0200202D */ daddu $a0, $s0, $zero diff --git a/ver/us/asm/nonmatchings/world/area_obk/obk_08/BD3870/func_802403DC_BD3C4C.s b/ver/us/asm/nonmatchings/world/area_obk/obk_08/BD3870/func_802403DC_BD3C4C.s index 6e84b08e8b..0edf3af6fa 100644 --- a/ver/us/asm/nonmatchings/world/area_obk/obk_08/BD3870/func_802403DC_BD3C4C.s +++ b/ver/us/asm/nonmatchings/world/area_obk/obk_08/BD3870/func_802403DC_BD3C4C.s @@ -55,7 +55,7 @@ glabel func_802403DC_BD3C4C /* BD3D14 802404A4 0000202D */ daddu $a0, $zero, $zero /* BD3D18 802404A8 3C058024 */ lui $a1, %hi(obk_08_UnkFoldFunc) /* BD3D1C 802404AC 24A50000 */ addiu $a1, $a1, %lo(obk_08_UnkFoldFunc) -/* BD3D20 802404B0 0C048C56 */ jal create_generic_entity_world +/* BD3D20 802404B0 0C048C56 */ jal create_worker_world /* BD3D24 802404B4 AE020000 */ sw $v0, ($s0) /* BD3D28 802404B8 0260202D */ daddu $a0, $s3, $zero /* BD3D2C 802404BC 3C05FD05 */ lui $a1, 0xfd05 diff --git a/ver/us/asm/nonmatchings/world/script_api/7E0E80/MakeShop.s b/ver/us/asm/nonmatchings/world/script_api/7E0E80/MakeShop.s index 9c864c4ff2..677508d124 100644 --- a/ver/us/asm/nonmatchings/world/script_api/7E0E80/MakeShop.s +++ b/ver/us/asm/nonmatchings/world/script_api/7E0E80/MakeShop.s @@ -177,9 +177,9 @@ glabel MakeShop /* 7E2974 80281AF4 34058000 */ ori $a1, $zero, 0x8000 /* 7E2978 80281AF8 3C058028 */ lui $a1, %hi(draw_shop_items) /* 7E297C 80281AFC 24A51524 */ addiu $a1, $a1, %lo(draw_shop_items) -/* 7E2980 80281B00 0C048C8F */ jal create_generic_entity_frontUI +/* 7E2980 80281B00 0C048C8F */ jal create_worker_frontUI /* 7E2984 80281B04 0000202D */ daddu $a0, $zero, $zero -/* 7E2988 80281B08 0C048D8F */ jal get_generic_entity +/* 7E2988 80281B08 0C048D8F */ jal get_worker /* 7E298C 80281B0C 0040202D */ daddu $a0, $v0, $zero /* 7E2990 80281B10 2404000A */ addiu $a0, $zero, 0xa /* 7E2994 80281B14 24050064 */ addiu $a1, $zero, 0x64 diff --git a/ver/us/splat.yaml b/ver/us/splat.yaml index 3ddf932f63..4382ee98d8 100644 --- a/ver/us/splat.yaml +++ b/ver/us/splat.yaml @@ -821,6 +821,7 @@ segments: - [0xA5DD0, c, a5dd0_len_114e0] - [0xB4580, c, B4580] - [0xB72B0, c, entity_model] + - [0xB97B0, c, worker] - [0xB9D60, c, msg] - [0xC50A0, c, C50A0] - [0xCD180, c, cd180_len_38f0] @@ -876,6 +877,7 @@ segments: - [0xF2470, c, npc_api] - [0xF4C60, c, msg_api] - [0xF5750, c, player_api] + - [0xF76E0, c, virtual_entity] - [0xF8F60, c, f8f60_len_1560] - [0xFA4C0, c, fa4c0_len_3bf0] - [0xFBE10, c, fx_api] diff --git a/ver/us/symbol_addrs.txt b/ver/us/symbol_addrs.txt index 0007243e51..3412002eca 100644 --- a/ver/us/symbol_addrs.txt +++ b/ver/us/symbol_addrs.txt @@ -326,7 +326,7 @@ func_8003E514 = 0x8003E514; // type:func rom:0x19914 update_encounters = 0x8003E524; // type:func rom:0x19924 draw_encounter_ui = 0x8003E5B0; // type:func rom:0x199B0 draw_first_strike_ui = 0x8003E63C; // type:func rom:0x19A3C -npc_dyn_entity_draw_no_op = 0x8003E670; // type:func rom:0x19A70 +npc_render_worker_do_nothing = 0x8003E670; // type:func rom:0x19A70 make_npcs = 0x8003E678; // type:func rom:0x19A78 kill_encounter = 0x8003E730; // type:func rom:0x19B30 kill_enemy = 0x8003E7AC; // type:func rom:0x19BAC @@ -4175,9 +4175,7 @@ D_800DC4D8 = 0x800DC4D8; // type:data rom:0xB78D8 gBattleSubState = 0x800DC4DC; // type:data rom:0xB78DC D_800DC4E0 = 0x800DC4E0; // type:data rom:0xB78E0 D_800DC4E4 = 0x800DC4E4; // type:data rom:0xB78E4 -D_800DC4E8 = 0x800DC4E8; // type:data rom:0xB78E8 -gCurrentBattleSection = 0x800DC4EA; // type:data rom:0xB78EA -D_800DC4EB = 0x800DC4EB; // type:data rom:0xB78EB +gCurrentBattleID = 0x800DC4E8; // type:data rom:0xB78E8 D_800DC4EC = 0x800DC4EC; // type:data rom:0xB78EC D_800DC4F0 = 0x800DC4F0; // type:data rom:0xB78F0 D_800DC4F4 = 0x800DC4F4; // type:data rom:0xB78F4 @@ -4205,18 +4203,18 @@ set_entity_fog_color = 0x80123028; // type:func rom:0xB9728 is_entity_fog_enabled = 0x80123050; // type:func rom:0xB9750 get_entity_fog_distance = 0x80123060; // type:func rom:0xB9760 get_entity_fog_color = 0x8012307C; // type:func rom:0xB977C -stub_generic_entity_delegate = 0x801230B0; // type:func rom:0xB97B0 -clear_generic_entity_list = 0x801230B8; // type:func rom:0xB97B8 -init_generic_entity_list = 0x80123114; // type:func rom:0xB9814 -create_generic_entity_world = 0x80123158; // type:func rom:0xB9858 -create_generic_entity_frontUI = 0x8012323C; // type:func rom:0xB993C -create_generic_entity_backUI = 0x80123320; // type:func rom:0xB9A20 -update_generic_entities = 0x80123404; // type:func rom:0xB9B04 -render_generic_entities_world = 0x80123470; // type:func rom:0xB9B70 -render_generic_entities_frontUI = 0x801234E0; // type:func rom:0xB9BE0 -render_generic_entities_backUI = 0x80123550; // type:func rom:0xB9C50 -free_generic_entity = 0x801235C0; // type:func rom:0xB9CC0 -get_generic_entity = 0x8012363C; // type:func rom:0xB9D3C +worker_delegate_do_nothing = 0x801230B0; // type:func rom:0xB97B0 +clear_worker_list = 0x801230B8; // type:func rom:0xB97B8 +init_worker_list = 0x80123114; // type:func rom:0xB9814 +create_worker_world = 0x80123158; // type:func rom:0xB9858 +create_worker_frontUI = 0x8012323C; // type:func rom:0xB993C +create_worker_backUI = 0x80123320; // type:func rom:0xB9A20 +update_workers = 0x80123404; // type:func rom:0xB9B04 +render_workers_world = 0x80123470; // type:func rom:0xB9B70 +render_workers_frontUI = 0x801234E0; // type:func rom:0xB9BE0 +render_workers_backUI = 0x80123550; // type:func rom:0xB9C50 +free_worker = 0x801235C0; // type:func rom:0xB9CC0 +get_worker = 0x8012363C; // type:func rom:0xB9D3C clear_character_set = 0x80123660; // type:func rom:0xB9D60 clear_printers = 0x80123674; // type:func rom:0xB9D74 load_font_data = 0x80123708; // type:func rom:0xB9E08 @@ -5060,10 +5058,10 @@ D_8015438B = 0x8015438B; // type:data rom:0xEAA8B entity_fog_dist_min = 0x8015438C; // type:data rom:0xEAA8C entity_fog_dist_max = 0x80154390; // type:data rom:0xEAA90 D_80154394 = 0x80154394; // type:data rom:0xEAA94 -gWorldDynamicEntityList = 0x801543A0; // rom:0xEAAA0 -gBattleDynamicEntityList = 0x801543E0; // rom:0xEAAE0 +gWorldWorkerList = 0x801543A0; // rom:0xEAAA0 +gBattleWorkerList = 0x801543E0; // rom:0xEAAE0 evt_handle_get_Nth_float = 0x802C614C; // type:func rom:0xEAAFC -gCurrentDynamicEntityListPtr = 0x80154420; // rom:0xEAB20 +gCurrentWorkerListPtr = 0x80154420; // rom:0xEAB20 D_80154424 = 0x80154424; // type:data rom:0xEAB24 gMessageBuffers = 0x80154430; // type:data rom:0xEAB30 evt_handle_set_array = 0x802C61AC; // type:func rom:0xEAB5C @@ -27128,9 +27126,9 @@ gCurrentPrintContext = 0x802DB260; // D_802DB264 = 0x802DB264; // type:data D_802DB268 = 0x802DB268; // type:data D_802DB5B0 = 0x802DB5B0; // type:data -D_802DB5C0 = 0x802DB5C0; // type:data -D_802DB6C0 = 0x802DB6C0; // type:data -D_802DB7C0 = 0x802DB7C0; // type:data +bBattleVirtualEntityList = 0x802DB5C0; // type:data +wWorldVirtualEntityList = 0x802DB6C0; // type:data +gCurrentVirtualEntityListPtr = 0x802DB7C0; // type:data MusicEventList = 0x802DB7D0; // type:data RunningMusicEvents = 0x802DB7D8; // type:data RunningMusicEventIDs = 0x802DB800; // type:data diff --git a/ver/us/undefined_syms.txt b/ver/us/undefined_syms.txt index 42d5b5ff1e..ee1ed28bcf 100644 --- a/ver/us/undefined_syms.txt +++ b/ver/us/undefined_syms.txt @@ -620,7 +620,7 @@ dead_dist3D = 0x8002B21C; dead_LoadPath = 0x802E2A80; dead_GetNextPathPos = 0x802E2B74; dead_queue_render_task = 0x80128510; -dead_create_generic_entity_world = 0x8012DFE8; +dead_create_worker_world = 0x8012DFE8; dead_dma_copy = 0x8002AA2C; dead_get_entity_by_index = 0x80118BB0; dead_fx_sun = 0x80077BD0;