From 76438a7198e0a9be7da0129e1f55a175f5a3b630 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Thu, 2 Feb 2023 02:48:25 +0900 Subject: [PATCH] Fix typedefs for various things to be more C compliant (#929) --- include/common_structs.h | 2 +- include/effects.h | 32 --------------------- include/entity.h | 8 +++--- include/item_entity.h | 2 +- include/sparkle_script.h | 2 +- src/entity/sbk_omo/Tweester.c | 4 +-- src/entity_model.c | 13 +++++---- src/hud_element.h | 2 +- src/world/area_sbk/sbk_14/sbk_14_2_entity.c | 2 +- src/world/area_sbk/sbk_23/sbk_23_2_entity.c | 2 +- src/world/area_sbk/sbk_33/sbk_33_1_entity.c | 2 +- src/world/area_sbk/sbk_41/sbk_41_2_entity.c | 2 +- src/world/area_sbk/sbk_54/sbk_54_2_entity.c | 2 +- src/world/area_tst/tst_10/tst_10_1_main.c | 4 +-- 14 files changed, 25 insertions(+), 54 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 35fd4b4494..7188dff082 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -11,7 +11,7 @@ struct Evt; typedef ApiStatus(*ApiFunc)(struct Evt*, s32); -typedef Bytecode EvtScript[0]; +typedef Bytecode EvtScript[]; typedef void NoArgCallback(void*); diff --git a/include/effects.h b/include/effects.h index f8d8d86be0..7d7776642e 100644 --- a/include/effects.h +++ b/include/effects.h @@ -142,10 +142,6 @@ enum EffectID { EFFECT_86 = 0x86, }; -typedef struct Effect00FXData { - /* 0x00 */ char todo[0]; -} Effect00FXData; // size = unknown - typedef struct BigSmokePuffFXData { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; @@ -162,22 +158,6 @@ typedef struct BigSmokePuffFXData { /* 0x28 */ char unk_28[0x4]; } BigSmokePuffFXData; // size = 0x2C -typedef struct Effect02FXData { - /* 0x00 */ char todo[0]; -} Effect02FXData; // size = unknown - -typedef struct Effect03FXData { - /* 0x00 */ char todo[0]; -} Effect03FXData; // size = unknown - -typedef struct Effect04FXData { - /* 0x00 */ char todo[0]; -} Effect04FXData; // size = unknown - -typedef struct Effect05FXData { - /* 0x00 */ char todo[0]; -} Effect05FXData; // size = unknown - typedef struct LandingDustFXData { /* 0x00 */ u16 type; /* 0x02 */ char unk_02[0x2]; @@ -788,10 +768,6 @@ typedef struct SleepBubbleFXData { /* 0xC8 */ f32 unk_C8; } SleepBubbleFXData; // size = 0xCC -typedef struct Unk2AFXData { - /* 0x00 */ char todo[0]; -} Unk2AFXData; // size = unknown - typedef struct WindyLeavesFXData { /* 0x00 */ s32 type; /* 0x04 */ Vec3f unk_04; @@ -2093,10 +2069,6 @@ typedef struct FloatingCloudPuffFXData { /* 0x38 */ f32 unk_38; } FloatingCloudPuffFXData; // size = 0x3C -typedef struct Effect6AFXData { - /* 0x00 */ char todo[0]; -} Effect6AFXData; // size = unknown - typedef struct EnergyInOutFXData { /* 0x00 */ s32 unk_00; /* 0x04 */ Vec3f pos; @@ -2332,10 +2304,6 @@ typedef struct Effect75FXData { /* 0x7C */ f32 unk_7C; } Effect75FXData; // size = 0x80 -typedef struct Effect76FXData { - /* 0x00 */ char todo[0]; -} Effect76FXData; // size = unknown - typedef struct FireworkRocketFXData { /* 0x00 */ s32 variation; /* 0x04 */ Vec3f pos; diff --git a/include/entity.h b/include/entity.h index 0ce041ed09..1b54a1edfb 100644 --- a/include/entity.h +++ b/include/entity.h @@ -3,8 +3,8 @@ #include "common.h" -typedef s32 EntityScript[0]; -typedef s32 EntityModelScript[0]; +typedef s32 EntityScript[]; +typedef s32 EntityModelScript[]; enum { ENTITY_SCRIPT_OP_End, @@ -64,8 +64,8 @@ enum { #define BLOCK_GRID_SIZE 25 -#define TWEETSER_PATH_STOP 0x80000000 -#define TWEETSER_PATH_LOOP 0x80000001 +#define TWEESTER_PATH_STOP 0x80000000 +#define TWEESTER_PATH_LOOP 0x80000001 typedef struct SaveBlockData { /* 0x000 */ char unk_0[4]; diff --git a/include/item_entity.h b/include/item_entity.h index 652b1447a8..6801e1c314 100644 --- a/include/item_entity.h +++ b/include/item_entity.h @@ -3,7 +3,7 @@ #include "common.h" -typedef s32 ItemScript[0]; +typedef s32 ItemScript[]; enum { ITEM_SCRIPT_OP_End, diff --git a/include/sparkle_script.h b/include/sparkle_script.h index 92e368d755..e1fbcd48b3 100644 --- a/include/sparkle_script.h +++ b/include/sparkle_script.h @@ -1,6 +1,6 @@ #include "common.h" -typedef s32 SparkleScript[0]; +typedef s32 SparkleScript[]; enum { SPARKLE_OP_End = 0, diff --git a/src/entity/sbk_omo/Tweester.c b/src/entity/sbk_omo/Tweester.c index 165e974cb4..b1bf2671bd 100644 --- a/src/entity/sbk_omo/Tweester.c +++ b/src/entity/sbk_omo/Tweester.c @@ -160,9 +160,9 @@ void entity_Tweester_select_target_point(Entity* entity) { data->currentPath = paths[j]; } pathPtr = &data->currentPath[pathOffset]; - if (*pathPtr != TWEETSER_PATH_STOP) { + if (*pathPtr != TWEESTER_PATH_STOP) { pathOffset += 3; - if (*pathPtr == TWEETSER_PATH_LOOP){ + if (*pathPtr == TWEESTER_PATH_LOOP){ pathOffset = 0; pathPtr = data->currentPath; data->targetX = *pathPtr++; diff --git a/src/entity_model.c b/src/entity_model.c index 7955b4b6b0..aaad6adb9b 100644 --- a/src/entity_model.c +++ b/src/entity_model.c @@ -1,7 +1,10 @@ #include "common.h" #include "entity.h" -EntityModelScript D_8014C260[] = { {ems_End}, {ems_End }}; +EntityModelScript D_8014C260 = { + ems_End + ems_End +}; Lights1 D_8014C268 = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0); extern EntityModelList gWorldEntityModelList; @@ -112,7 +115,7 @@ s32 load_entity_model(EntityModelScript* cmdList) { newEntityModel->nextFrameTime = 1.0f; newEntityModel->timeScale = 1.0f; if (cmdList == NULL) { - newEntityModel->cmdListReadPos = D_8014C260; + newEntityModel->cmdListReadPos = &D_8014C260; } newEntityModel->vertexArray = NULL; newEntityModel->fpSetupGfxCallback = NULL; @@ -154,7 +157,7 @@ s32 ALT_load_entity_model(EntityModelScript* cmdList) { newEntityModel->nextFrameTime = 1.0f; newEntityModel->timeScale = 1.0f; if (cmdList == NULL) { - newEntityModel->cmdListReadPos = D_8014C260; + newEntityModel->cmdListReadPos = &D_8014C260; } newEntityModel->vertexArray = NULL; newEntityModel->fpSetupGfxCallback = NULL; @@ -189,7 +192,7 @@ void exec_entity_model_commandlist(s32 idx) { s32 step_entity_model_commandlist(EntityModel* entityModel) { SpriteRasterInfo* imageData; - u32* curPos = entityModel->cmdListReadPos[0]; + u32* curPos = *entityModel->cmdListReadPos; switch (*curPos++) { case 0: // kill model free_entity_model_by_ref(entityModel); @@ -719,7 +722,7 @@ void set_entity_model_render_command_list(s32 idx, EntityModelScript* cmdList) { if (entityModel != NULL && entityModel->flags) { if (cmdList == NULL) { - cmdList = D_8014C260; + cmdList = &D_8014C260; } entityModel->cmdListReadPos = cmdList; entityModel->cmdListSavedPos = cmdList; diff --git a/src/hud_element.h b/src/hud_element.h index 7eef7ef788..75412ba26d 100644 --- a/src/hud_element.h +++ b/src/hud_element.h @@ -6,7 +6,7 @@ #define HUD_ELEMENT_BATTLE_ID_MASK 0x800 -typedef s32 HudScript[0]; +typedef s32 HudScript[]; typedef s32 HudElemID; diff --git a/src/world/area_sbk/sbk_14/sbk_14_2_entity.c b/src/world/area_sbk/sbk_14/sbk_14_2_entity.c index 048ff69ccd..7565c780a5 100644 --- a/src/world/area_sbk/sbk_14/sbk_14_2_entity.c +++ b/src/world/area_sbk/sbk_14/sbk_14_2_entity.c @@ -6,7 +6,7 @@ TweesterPath N(D_80240440_936B20)[] = { { -262, 0, -64 }, { 57, 0, -286 }, { 327, 0, 8 }, - { TWEETSER_PATH_LOOP } + { TWEESTER_PATH_LOOP } }; TweesterPath* N(D_80240474_936B54)[] = { diff --git a/src/world/area_sbk/sbk_23/sbk_23_2_entity.c b/src/world/area_sbk/sbk_23/sbk_23_2_entity.c index a355471845..26d560760f 100644 --- a/src/world/area_sbk/sbk_23/sbk_23_2_entity.c +++ b/src/world/area_sbk/sbk_23/sbk_23_2_entity.c @@ -6,7 +6,7 @@ TweesterPath N(D_802403C0_93AB20)[] = { { -262, 0, -64 }, { 57, 0, -286 }, { 327, 0, 8 }, - { TWEETSER_PATH_LOOP } + { TWEESTER_PATH_LOOP } }; TweesterPath* N(D_802403F4_93AB54)[] = { diff --git a/src/world/area_sbk/sbk_33/sbk_33_1_entity.c b/src/world/area_sbk/sbk_33/sbk_33_1_entity.c index ec065bef7e..48252403ec 100644 --- a/src/world/area_sbk/sbk_33/sbk_33_1_entity.c +++ b/src/world/area_sbk/sbk_33/sbk_33_1_entity.c @@ -6,7 +6,7 @@ TweesterPath N(DefaultTweesterPath)[] = { { -262, 0, -64 }, { 57, 0, -286 }, { 327, 0, 8 }, - { TWEETSER_PATH_LOOP } + { TWEESTER_PATH_LOOP } }; TweesterPath* N(TweesterPaths)[] = { diff --git a/src/world/area_sbk/sbk_41/sbk_41_2_entity.c b/src/world/area_sbk/sbk_41/sbk_41_2_entity.c index cf963080d8..4fe5a4a7f3 100644 --- a/src/world/area_sbk/sbk_41/sbk_41_2_entity.c +++ b/src/world/area_sbk/sbk_41/sbk_41_2_entity.c @@ -6,7 +6,7 @@ TweesterPath N(DefaultTweesterPath)[] = { { -262, 0, -64 }, { 57, 0, -286 }, { 327, 0, 8 }, - { TWEETSER_PATH_LOOP } + { TWEESTER_PATH_LOOP } }; TweesterPath* N(TweesterPaths)[] = { diff --git a/src/world/area_sbk/sbk_54/sbk_54_2_entity.c b/src/world/area_sbk/sbk_54/sbk_54_2_entity.c index 36c068ef7e..8f86d02a8a 100644 --- a/src/world/area_sbk/sbk_54/sbk_54_2_entity.c +++ b/src/world/area_sbk/sbk_54/sbk_54_2_entity.c @@ -6,7 +6,7 @@ TweesterPath N(TweesterPath1)[] = { { -262, 0, -64 }, { 57, 0, -286 }, { 327, 0, 8 }, - { TWEETSER_PATH_LOOP } + { TWEESTER_PATH_LOOP } }; TweesterPath* N(TweesterPaths)[] = { diff --git a/src/world/area_tst/tst_10/tst_10_1_main.c b/src/world/area_tst/tst_10/tst_10_1_main.c index 6451ac7724..d883e1917f 100644 --- a/src/world/area_tst/tst_10/tst_10_1_main.c +++ b/src/world/area_tst/tst_10/tst_10_1_main.c @@ -108,9 +108,9 @@ TweesterPath N(DefaultTweesterPath)[] = { { -262, 0, -64 }, { 57, 0, -286 }, { 327, 0, 8 }, - { TWEETSER_PATH_LOOP } + { TWEESTER_PATH_LOOP } }; - + TweesterPath* N(UnusedTweesterPaths)[] = { N(DefaultTweesterPath), N(DefaultTweesterPath),