diff --git a/include/functions.h b/include/functions.h index 3fc311f9e9..292d8bde5d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -98,24 +98,6 @@ void PreNmiBuff_Init(PreNmiBuff* this); void PreNmiBuff_SetReset(PreNmiBuff* this); u32 PreNmiBuff_IsResetting(PreNmiBuff* this); void Sched_FlushTaskQueue(void); -f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); -f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); -f32 OLib_ClampMinDist(f32 val, f32 min); -f32 OLib_ClampMaxDist(f32 val, f32 max); -Vec3f OLib_Vec3fDistNormalize(Vec3f* a, Vec3f* b); -Vec3f OLib_VecGeoToVec3f(VecGeo* geo); -VecSph OLib_Vec3fToVecSph(Vec3f* vec); -VecGeo OLib_Vec3fToVecGeo(Vec3f* vec); -VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b); -Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b); -s16 OnePointCutscene_Init(PlayState* play, s16 csId, s16 timer, Actor* actor, s16 parentCamId); -s16 OnePointCutscene_EndCutscene(PlayState* play, s16 subCamId); -s32 OnePointCutscene_Attention(PlayState* play, Actor* actor); -s32 OnePointCutscene_AttentionSetSfx(PlayState* play, Actor* actor, s32 sfxId); -void OnePointCutscene_EnableAttention(void); -void OnePointCutscene_DisableAttention(void); -s32 OnePointCutscene_CheckForCategory(PlayState* play, s32 actorCategory); -void OnePointCutscene_Noop(PlayState* play, s32 arg1); Path* Path_GetByIndex(PlayState* play, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); @@ -135,16 +117,6 @@ void Room_FinishRoomChange(PlayState* play, RoomContext* roomCtx); void Sample_Destroy(GameState* thisx); void Sample_Init(GameState* thisx); -void Object_InitContext(PlayState* play, ObjectContext* objectCtx); -void Object_UpdateEntries(ObjectContext* objectCtx); -s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId); -s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot); -void func_800981B8(ObjectContext* objectCtx); -s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd); -void Scene_ResetTransitionActorList(GameState* state, TransitionActorList* transitionActors); -void Scene_SetTransitionForNextEntrance(PlayState* play); -void Scene_Draw(PlayState* play); - void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos); void Skin_DrawAnimatedLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags); void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dlistOverride, s32 drawFlags); diff --git a/include/one_point_cutscene.h b/include/one_point_cutscene.h new file mode 100644 index 0000000000..2c829ba642 --- /dev/null +++ b/include/one_point_cutscene.h @@ -0,0 +1,18 @@ +#ifndef ONE_POINT_CUTSCENE_H +#define ONE_POINT_CUTSCENE_H + +#include "ultra64.h" + +struct Actor; +struct PlayState; + +s16 OnePointCutscene_Init(struct PlayState* play, s16 csId, s16 timer, struct Actor* actor, s16 parentCamId); +s16 OnePointCutscene_EndCutscene(struct PlayState* play, s16 subCamId); +s32 OnePointCutscene_Attention(struct PlayState* play, struct Actor* actor); +s32 OnePointCutscene_AttentionSetSfx(struct PlayState* play, struct Actor* actor, s32 sfxId); +void OnePointCutscene_EnableAttention(void); +void OnePointCutscene_DisableAttention(void); +s32 OnePointCutscene_CheckForCategory(struct PlayState* play, s32 actorCategory); +void OnePointCutscene_Noop(struct PlayState* play, s32 arg1); + +#endif diff --git a/include/variables.h b/include/variables.h index f4e15f7362..b2f8039759 100644 --- a/include/variables.h +++ b/include/variables.h @@ -64,22 +64,9 @@ extern s32 gZeldaArenaLogSeverity; extern MapData gMapDataTable; extern s16 gSpoilingItems[3]; extern s16 gSpoilingItemReverts[3]; -extern FlexSkeletonHeader* gPlayerSkelHeaders[2]; -extern u8 gPlayerModelTypes[PLAYER_MODELGROUP_MAX][PLAYER_MODELGROUPENTRY_MAX]; -extern Gfx* gPlayerLeftHandBgsDLs[]; -extern Gfx* gPlayerLeftHandOpenDLs[]; -extern Gfx* gPlayerLeftHandClosedDLs[]; -extern Gfx* gPlayerLeftHandBoomerangDLs[]; -extern Gfx gCullBackDList[]; -extern Gfx gCullFrontDList[]; + extern Gfx gEmptyDL[]; -extern SceneCmdHandlerFunc gSceneCmdHandlers[SCENE_CMD_ID_MAX]; -extern s16 gLinkObjectIds[2]; -extern u32 gObjectTableSize; -extern RomFile gObjectTable[OBJECT_ID_MAX]; -extern EntranceInfo gEntranceTable[ENTR_MAX]; -extern SceneTableEntry gSceneTable[SCENE_ID_MAX]; extern u16 gSramSlotOffsets[]; // 4 16-colors palettes extern u64 gMojiFontTLUTs[4][4]; // original name: "moji_tlut" diff --git a/include/z64.h b/include/z64.h index 93362edb00..d52d459de3 100644 --- a/include/z64.h +++ b/include/z64.h @@ -32,6 +32,8 @@ #include "z64math.h" #include "z64map_mark.h" #include "z64message.h" +#include "z64olib.h" +#include "one_point_cutscene.h" #include "z64pause.h" #include "z64play.h" #include "z64skin.h" @@ -286,26 +288,6 @@ typedef struct FileSelectState { /* 0x1CAD6 */ s16 unk_1CAD6[5]; } FileSelectState; // size = 0x1CAE0 -// Macros for `EntranceInfo.field` -#define ENTRANCE_INFO_CONTINUE_BGM_FLAG (1 << 15) -#define ENTRANCE_INFO_DISPLAY_TITLE_CARD_FLAG (1 << 14) -#define ENTRANCE_INFO_END_TRANS_TYPE_MASK 0x3F80 -#define ENTRANCE_INFO_END_TRANS_TYPE_SHIFT 7 -#define ENTRANCE_INFO_END_TRANS_TYPE(field) \ - (((field) >> ENTRANCE_INFO_END_TRANS_TYPE_SHIFT) \ - & (ENTRANCE_INFO_END_TRANS_TYPE_MASK >> ENTRANCE_INFO_END_TRANS_TYPE_SHIFT)) -#define ENTRANCE_INFO_START_TRANS_TYPE_MASK 0x7F -#define ENTRANCE_INFO_START_TRANS_TYPE_SHIFT 0 -#define ENTRANCE_INFO_START_TRANS_TYPE(field) \ - (((field) >> ENTRANCE_INFO_START_TRANS_TYPE_SHIFT) \ - & (ENTRANCE_INFO_START_TRANS_TYPE_MASK >> ENTRANCE_INFO_START_TRANS_TYPE_SHIFT)) - -typedef struct EntranceInfo { - /* 0x00 */ s8 sceneId; - /* 0x01 */ s8 spawn; - /* 0x02 */ u16 field; -} EntranceInfo; // size = 0x4 - typedef struct GameStateOverlay { /* 0x00 */ void* loadedRamAddr; /* 0x04 */ RomFile file; // if applicable diff --git a/include/z64object.h b/include/z64object.h index e74b1793d1..016eda00d7 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -4,6 +4,8 @@ #include "ultra64.h" #include "z64dma.h" +struct PlayState; + typedef struct ObjectEntry { /* 0x00 */ s16 id; /* 0x04 */ void* segment; @@ -35,4 +37,13 @@ typedef enum ObjectId { #undef DEFINE_OBJECT_EMPTY #undef DEFINE_OBJECT_UNSET +void Object_InitContext(struct PlayState* play, ObjectContext* objectCtx); +void Object_UpdateEntries(ObjectContext* objectCtx); +s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId); +s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot); +void func_800981B8(ObjectContext* objectCtx); + +extern u32 gObjectTableSize; +extern RomFile gObjectTable[OBJECT_ID_MAX]; + #endif diff --git a/include/z64olib.h b/include/z64olib.h new file mode 100644 index 0000000000..1b704b0e69 --- /dev/null +++ b/include/z64olib.h @@ -0,0 +1,17 @@ +#ifndef Z64OLIB_H +#define Z64OLIB_H + +#include "z64math.h" + +f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); +f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); +f32 OLib_ClampMinDist(f32 val, f32 min); +f32 OLib_ClampMaxDist(f32 val, f32 max); +Vec3f OLib_Vec3fDistNormalize(Vec3f* a, Vec3f* b); +Vec3f OLib_VecGeoToVec3f(VecGeo* geo); +VecSph OLib_Vec3fToVecSph(Vec3f* vec); +VecGeo OLib_Vec3fToVecGeo(Vec3f* vec); +VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b); +Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b); + +#endif diff --git a/include/z64player.h b/include/z64player.h index 2441941d29..d717903483 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -930,7 +930,7 @@ typedef struct Player { /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position } Player; // size = 0xA94 -// z_player_lib public functions +// z_player_lib.c void Player_SetBootData(struct PlayState* play, Player* this); int Player_InBlockingCsMode(struct PlayState* play, Player* this); int Player_InCsMode(struct PlayState* play); @@ -984,4 +984,17 @@ u32 Player_InitPauseDrawData(struct PlayState* play, u8* segment, SkelAnime* ske void Player_DrawPause(struct PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots); +// z_player_lib.c +extern FlexSkeletonHeader* gPlayerSkelHeaders[2]; +extern u8 gPlayerModelTypes[PLAYER_MODELGROUP_MAX][PLAYER_MODELGROUPENTRY_MAX]; +extern Gfx* gPlayerLeftHandBgsDLs[]; +extern Gfx* gPlayerLeftHandOpenDLs[]; +extern Gfx* gPlayerLeftHandClosedDLs[]; +extern Gfx* gPlayerLeftHandBoomerangDLs[]; +extern Gfx gCullBackDList[]; +extern Gfx gCullFrontDList[]; + +// object_table.c +extern s16 gLinkObjectIds[2]; + #endif diff --git a/include/z64scene.h b/include/z64scene.h index 87c8927d9f..53c868553d 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -11,6 +11,7 @@ #include "command_macros_base.h" +struct GameState; struct PlayState; typedef struct SceneTableEntry { @@ -432,6 +433,26 @@ typedef enum SceneID { // Deleted scene #define SCENE_UNUSED_6E 0x6E +// Macros for `EntranceInfo.field` +#define ENTRANCE_INFO_CONTINUE_BGM_FLAG (1 << 15) +#define ENTRANCE_INFO_DISPLAY_TITLE_CARD_FLAG (1 << 14) +#define ENTRANCE_INFO_END_TRANS_TYPE_MASK 0x3F80 +#define ENTRANCE_INFO_END_TRANS_TYPE_SHIFT 7 +#define ENTRANCE_INFO_END_TRANS_TYPE(field) \ + (((field) >> ENTRANCE_INFO_END_TRANS_TYPE_SHIFT) \ + & (ENTRANCE_INFO_END_TRANS_TYPE_MASK >> ENTRANCE_INFO_END_TRANS_TYPE_SHIFT)) +#define ENTRANCE_INFO_START_TRANS_TYPE_MASK 0x7F +#define ENTRANCE_INFO_START_TRANS_TYPE_SHIFT 0 +#define ENTRANCE_INFO_START_TRANS_TYPE(field) \ + (((field) >> ENTRANCE_INFO_START_TRANS_TYPE_SHIFT) \ + & (ENTRANCE_INFO_START_TRANS_TYPE_MASK >> ENTRANCE_INFO_START_TRANS_TYPE_SHIFT)) + +typedef struct EntranceInfo { + /* 0x00 */ s8 sceneId; + /* 0x01 */ s8 spawn; + /* 0x02 */ u16 field; +} EntranceInfo; // size = 0x4 + // Entrance Index Enum #define DEFINE_ENTRANCE(enum, _1, _2, _3, _4, _5, _6) enum, @@ -639,5 +660,12 @@ typedef enum SceneCommandTypeID { #define SCENE_CMD_MISC_SETTINGS(sceneCamType, worldMapLocation) \ { SCENE_CMD_ID_MISC_SETTINGS, sceneCamType, CMD_W(worldMapLocation) } +s32 Scene_ExecuteCommands(struct PlayState* play, SceneCmd* sceneCmd); +void Scene_ResetTransitionActorList(struct GameState* state, TransitionActorList* transitionActors); +void Scene_SetTransitionForNextEntrance(struct PlayState* play); +void Scene_Draw(struct PlayState* play); + +extern EntranceInfo gEntranceTable[ENTR_MAX]; +extern SceneTableEntry gSceneTable[SCENE_ID_MAX]; #endif diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 10611d66e9..3c6019182b 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -27,7 +27,7 @@ #endif #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:96 pal-1.0:94 pal-1.1:94" + "ntsc-1.2:94 pal-1.0:92 pal-1.1:92" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 12152f17a8..e9b7de4b61 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -42,7 +42,7 @@ */ #if PLATFORM_GC -#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-eu-mq-dbg:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192" \ +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-eu-mq-dbg:176 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192" \ "gc-us-mq:192" #include "global.h" diff --git a/src/code/main.c b/src/code/main.c index 7bec04a76a..03831ffb32 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -23,7 +23,7 @@ extern struct IrqMgr gIrqMgr; #endif #pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ - "ntsc-1.2:155 pal-1.0:153 pal-1.1:153" + "ntsc-1.2:154 pal-1.0:152 pal-1.1:152" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index cebb5260ad..fee1ae1388 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3638,7 +3638,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:97 pal-1.0:95 pal-1.1:95" + "ntsc-1.2:96 pal-1.0:94 pal-1.1:94" s32 Camera_KeepOn4(Camera* camera) { static Vec3f D_8015BD50; diff --git a/src/code/z_debug.c b/src/code/z_debug.c index dbbc8fd8db..8feacf15e1 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -12,8 +12,8 @@ typedef struct InputCombo { /* 0x2 */ u16 press; } InputCombo; // size = 0x4 -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ + "ntsc-1.2:192 pal-1.0:192 pal-1.1:192" RegEditor* gRegEditor; diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 908e01d673..27157ae2e9 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1,5 +1,5 @@ #pragma increment_block_number "gc-eu:248 gc-eu-mq:248 gc-jp:240 gc-jp-ce:240 gc-jp-mq:240 gc-us:240 gc-us-mq:240" \ - "ntsc-1.2:0 pal-1.0:0 pal-1.1:0" + "ntsc-1.2:0 pal-1.0:252 pal-1.1:252" #include "global.h" #include "ultra64.h" diff --git a/src/code/z_play.c b/src/code/z_play.c index dc61dd25f9..e4269a2c2f 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -10,7 +10,7 @@ #include "z64frame_advance.h" -#pragma increment_block_number "gc-eu:8 gc-eu-mq:8 gc-jp:8 gc-jp-ce:8 gc-jp-mq:8 gc-us:8 gc-us-mq:8" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" TransitionTile gTransitionTile; s32 gTransitionTileState; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 9b04bccec8..f96005a4a0 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -2,6 +2,7 @@ #include "terminal.h" #include "versions.h" +SceneCmdHandlerFunc sSceneCmdHandlers[SCENE_CMD_ID_MAX]; RomFile sNaviQuestHintFiles[]; /** @@ -191,8 +192,8 @@ s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd) { break; } - if (cmdCode < ARRAY_COUNT(gSceneCmdHandlers)) { - gSceneCmdHandlers[cmdCode](play, sceneCmd); + if (cmdCode < ARRAY_COUNT(sSceneCmdHandlers)) { + sSceneCmdHandlers[cmdCode](play, sceneCmd); } else { PRINTF(VT_FGCOL(RED)); PRINTF(T("code の値が異常です\n", "code variable is abnormal\n")); @@ -515,7 +516,7 @@ void Scene_SetTransitionForNextEntrance(PlayState* play) { play->transitionType = ENTRANCE_INFO_START_TRANS_TYPE(gEntranceTable[entranceIndex].field); } -SceneCmdHandlerFunc gSceneCmdHandlers[SCENE_CMD_ID_MAX] = { +SceneCmdHandlerFunc sSceneCmdHandlers[SCENE_CMD_ID_MAX] = { Scene_CommandPlayerEntryList, // SCENE_CMD_ID_SPAWN_LIST Scene_CommandActorEntryList, // SCENE_CMD_ID_ACTOR_LIST Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2 diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index af61e8491b..72fe16901f 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -35,7 +35,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:199 gc-eu-mq:199 gc-jp:199 gc-jp-ce:199 gc-jp-mq:199 gc-us:199 gc-us-mq:199" \ +#pragma increment_block_number "gc-eu:183 gc-eu-mq:183 gc-jp:183 gc-jp-ce:183 gc-jp-mq:183 gc-us:183 gc-us-mq:183" \ "ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS ACTOR_FLAG_4