diff --git a/assets/xml/textures/map_name_static.xml b/assets/xml/textures/map_name_static.xml index b94f1046e8..dd705eab60 100644 --- a/assets/xml/textures/map_name_static.xml +++ b/assets/xml/textures/map_name_static.xml @@ -1,9 +1,9 @@ - + - + @@ -29,7 +29,7 @@ - + diff --git a/assets/xml/textures/map_name_static_pal.xml b/assets/xml/textures/map_name_static_pal.xml index 0504aa432a..780609b18c 100644 --- a/assets/xml/textures/map_name_static_pal.xml +++ b/assets/xml/textures/map_name_static_pal.xml @@ -1,5 +1,8 @@ + + + @@ -12,6 +15,7 @@ + @@ -24,6 +28,7 @@ + @@ -36,6 +41,9 @@ + + + @@ -58,6 +66,7 @@ + @@ -80,6 +89,7 @@ + diff --git a/include/controller.h b/include/controller.h new file mode 100644 index 0000000000..dbc850aa21 --- /dev/null +++ b/include/controller.h @@ -0,0 +1,27 @@ +#ifndef CONTROLLER_H +#define CONTROLLER_H + +#define BTN_A 0x8000 +#define BTN_B 0x4000 +#define BTN_Z 0x2000 +#define BTN_START 0x1000 +#define BTN_DUP 0x0800 +#define BTN_DDOWN 0x0400 +#define BTN_DLEFT 0x0200 +#define BTN_DRIGHT 0x0100 +#define BTN_L 0x0020 +#define BTN_R 0x0010 +#define BTN_CUP 0x0008 +#define BTN_CDOWN 0x0004 +#define BTN_CLEFT 0x0002 +#define BTN_CRIGHT 0x0001 + +#define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) + +#if PLATFORM_N64 +#define CHECK_BTN_ALL(state, combo) (((state) & (combo)) == (combo)) +#else +#define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) +#endif + +#endif diff --git a/include/fault.h b/include/fault.h index ac63a234db..c398a003cd 100644 --- a/include/fault.h +++ b/include/fault.h @@ -72,11 +72,13 @@ void Fault_DrawText(s32 x, s32 y, const char* fmt, ...); #if PLATFORM_N64 +void func_800AE1F8(void); + // Not implemented. Silently noop-ing is fine, these are not essential for functionality. #define Fault_SetFontColor(color) (void)0 #define Fault_SetCharPad(padW, padH) (void)0 -#else +#elif PLATFORM_GC void Fault_InitDrawer(void); void Fault_SetForeColor(u16 color); @@ -90,10 +92,11 @@ s32 Fault_VPrintf(const char* fmt, va_list args); #if PLATFORM_N64 extern vs32 gFaultMsgId; +extern volatile OSThread* gFaultFaultedThread; #define FAULT_MSG_ID gFaultMsgId -#else +#elif PLATFORM_GC typedef struct FaultMgr { /* 0x000 */ OSThread thread; diff --git a/include/functions.h b/include/functions.h index 5810b3edb8..65a95050b6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -382,7 +382,7 @@ void func_8002ED80(Actor* actor, PlayState* play, s32 flag); PosRot Actor_GetFocus(Actor* actor); PosRot Actor_GetWorld(Actor* actor); PosRot Actor_GetWorldPosShapeRot(Actor* actor); -s32 func_8002F0C8(Actor* actor, Player* player, s32 flag); +s32 Target_ShouldReleaseLockOn(Actor* actor, Player* player, s32 ignoreLeash); s32 Actor_TalkOfferAccepted(Actor* actor, PlayState* play); s32 Actor_OfferTalkExchange(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, u32 exchangeItemId); s32 Actor_OfferTalkExchangeEquiCylinder(Actor* actor, PlayState* play, f32 radius, u32 exchangeItemId); @@ -647,99 +647,7 @@ void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* d UNK_TYPE arg6); s32 func_8005B198(void); s16 Camera_SetFinishedFlag(Camera* camera); -DamageTable* DamageTable_Get(s32 index); -void DamageTable_Clear(DamageTable* table); -#if OOT_DEBUG -void Collider_DrawRedPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC); -void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, u8 r, u8 g, u8 b); -#endif -s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* jntSph); -s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* jntSph); -s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* jntSph); -s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* dest, ColliderJntSphInitToActor* src); -s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* dest, Actor* actor, - ColliderJntSphInitType1* src); -s32 Collider_SetJntSphAlloc(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src); -s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src, - ColliderJntSphElement* jntSphElements); -s32 Collider_ResetJntSphAT(PlayState* play, Collider* col); -s32 Collider_ResetJntSphAC(PlayState* play, Collider* col); -s32 Collider_ResetJntSphOC(PlayState* play, Collider* col); -s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* cyl); -s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* cyl); -s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* dest, ColliderCylinderInitToActor* src); -s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* dest, Actor* actor, ColliderCylinderInitType1* src); -s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* dest, Actor* actor, ColliderCylinderInit* src); -s32 Collider_ResetCylinderAT(PlayState* play, Collider* col); -s32 Collider_ResetCylinderAC(PlayState* play, Collider* col); -s32 Collider_ResetCylinderOC(PlayState* play, Collider* col); -s32 Collider_InitTris(PlayState* play, ColliderTris* tris); -s32 Collider_FreeTris(PlayState* play, ColliderTris* tris); -s32 Collider_DestroyTris(PlayState* play, ColliderTris* tris); -s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInitType1* src); -s32 Collider_SetTrisAlloc(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInit* src); -s32 Collider_SetTris(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInit* src, - ColliderTrisElement* trisElements); -s32 Collider_ResetTrisAT(PlayState* play, Collider* col); -s32 Collider_ResetTrisAC(PlayState* play, Collider* col); -s32 Collider_ResetTrisOC(PlayState* play, Collider* col); -s32 Collider_InitQuad(PlayState* play, ColliderQuad* quad); -s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* quad); -s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* dest, Actor* actor, ColliderQuadInitType1* src); -s32 Collider_SetQuad(PlayState* play, ColliderQuad* dest, Actor* actor, ColliderQuadInit* src); -s32 Collider_ResetQuadAT(PlayState* play, Collider* col); -s32 Collider_ResetQuadAC(PlayState* play, Collider* col); -s32 Collider_ResetQuadOC(PlayState* play, Collider* col); -s32 Collider_InitLine(PlayState* play, OcLine* line); -s32 Collider_DestroyLine(PlayState* play, OcLine* line); -s32 Collider_SetLinePoints(PlayState* play, OcLine* ocLine, Vec3f* a, Vec3f* b); -s32 Collider_SetLine(PlayState* play, OcLine* dest, OcLine* src); -s32 Collider_ResetLineOC(PlayState* play, OcLine* line); -void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colChkCtx); -void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colChkCtx); -void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colChkCtx); -void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colChkCtx); -void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx); -#if OOT_DEBUG -void Collider_Draw(PlayState* play, Collider* col); -void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChkCtx); -#endif -s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); -s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); -s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); -s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); -s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); -s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); -s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colChkCtx, OcLine* collider); -void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colChkCtx); -void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colChkCtx); -void CollisionCheck_InitInfo(CollisionCheckInfo* info); -void CollisionCheck_ResetDamage(CollisionCheckInfo* info); -void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init); -void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init); -void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init); -void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init); -void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colChkCtx); -s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, - Actor** exclusions, s32 numExclusions); -void Collider_UpdateCylinder(Actor* actor, ColliderCylinder* cyl); -void Collider_SetCylinderPosition(ColliderCylinder* cyl, Vec3s* pos); -void Collider_SetQuadVertices(ColliderQuad* quad, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d); -void Collider_SetTrisVertices(ColliderTris* tris, s32 elemIndex, Vec3f* a, Vec3f* b, Vec3f* c); -void Collider_SetTrisDim(PlayState* play, ColliderTris* tris, s32 elemIndex, ColliderTrisElementDimInit* src); -void Collider_UpdateSpheres(s32 limb, ColliderJntSph* jntSph); -void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetal(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetalSfx(PlayState* play, Vec3f* v, Vec3f* pos); -void CollisionCheck_SpawnShieldParticlesMetal2(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* actorPos); -s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, - Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); -u8 CollisionCheck_GetSwordDamage(s32 dmgFlags); + void SaveContext_Init(void); s32 func_800635D0(s32); void Regs_Init(void); @@ -1044,12 +952,12 @@ void func_80095974(GraphicsContext* gfxCtx); void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3); void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tlutMode, u16 tlutCount, f32 offsetX, f32 offsetY); -void func_80096FD4(PlayState* play, Room* room); -u32 func_80096FE8(PlayState* play, RoomContext* roomCtx); -s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum); -s32 func_800973FC(PlayState* play, RoomContext* roomCtx); +void Room_Init(PlayState* play, Room* room); +u32 Room_SetupFirstRoom(PlayState* play, RoomContext* roomCtx); +s32 Room_RequestNewRoom(PlayState* play, RoomContext* roomCtx, s32 roomNum); +s32 Room_ProcessRoomRequest(PlayState* play, RoomContext* roomCtx); void Room_Draw(PlayState* play, Room* room, u32 flags); -void func_80097534(PlayState* play, RoomContext* roomCtx); +void Room_FinishRoomChange(PlayState* play, RoomContext* roomCtx); void Sample_Destroy(GameState* thisx); void Sample_Init(GameState* thisx); void Inventory_ChangeEquipment(s16 equipment, u16 value); @@ -1061,7 +969,7 @@ 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 TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx); +void Scene_ResetTransitionActorList(GameState* state, TransitionActorList* transitionActors); void Scene_SetTransitionForNextEntrance(PlayState* play); void Scene_Draw(PlayState* play); @@ -1272,42 +1180,7 @@ void* SysCfb_GetFbEnd(void); void Math3D_DrawSphere(PlayState* play, Sphere16* sph); void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl); -void Matrix_Init(GameState* gameState); -void Matrix_Push(void); -void Matrix_Pop(void); -void Matrix_Get(MtxF* dest); -void Matrix_Put(MtxF* src); -void Matrix_Mult(MtxF* mf, u8 mode); -void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode); -void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode); -void Matrix_RotateX(f32 x, u8 mode); -void Matrix_RotateY(f32 y, u8 mode); -void Matrix_RotateZ(f32 z, u8 mode); -void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); -void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); -void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot); -Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); -#if OOT_DEBUG -Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, int line); -#else -Mtx* Matrix_ToMtx(Mtx* dest); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); -#endif -void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); -void Matrix_MtxFCopy(MtxF* dest, MtxF* src); -void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); -void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); -void Matrix_Transpose(MtxF* mf); -void Matrix_ReplaceRotation(MtxF* mf); -void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag); -void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag); -void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode); -#if OOT_DEBUG -MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line); -#endif -void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, - f32 translateZ); + u64* SysUcode_GetUCodeBoot(void); size_t SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); diff --git a/include/gfxprint.h b/include/gfxprint.h index da63c9e762..86879c4805 100644 --- a/include/gfxprint.h +++ b/include/gfxprint.h @@ -34,7 +34,7 @@ typedef struct GfxPrint { #define GFXP_FLAG_RAINBOW (1 << 1) #define GFXP_FLAG_SHADOW (1 << 2) #define GFXP_FLAG_UPDATE (1 << 3) -#if PLATFORM_GC +#if !PLATFORM_N64 #define GFXP_FLAG_ENLARGE (1 << 6) #endif #define GFXP_FLAG_OPEN (1 << 7) diff --git a/include/libc/math.h b/include/libc/math.h index b893cce72e..b46b6cd911 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -60,7 +60,7 @@ f64 sqrt(f64 f); #pragma intrinsic(sqrt) #endif -#if PLATFORM_GC +#if !PLATFORM_N64 extern float qNaN0x3FFFFF; extern float qNaN0x10000; extern float sNaN0x3FFFFF; diff --git a/include/macros.h b/include/macros.h index 126d5d990e..dab193146d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -105,14 +105,6 @@ ? gSaveContext.save.info.equips.buttonItems[(button) + 1] \ : ITEM_NONE) -#if PLATFORM_N64 -#define CHECK_BTN_ALL(state, combo) (((state) & (combo)) == (combo)) -#else -#define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) -#endif - -#define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) - #define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) // IDO doesn't support variadic macros, but it merely throws a warning for the @@ -197,9 +189,6 @@ extern struct GraphicsContext* __gfxCtx; (void)0 #define GRAPH_ALLOC(gfxCtx, size) Graph_Alloc(gfxCtx, size) -#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx, file, line) -#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx, file, line) -#define MATRIX_CHECK_FLOATS(mtx, file, line) Matrix_CheckFloats(mtx, file, line) #define DMA_REQUEST_SYNC(ram, vrom, size, file, line) DmaMgr_RequestSyncDebug(ram, vrom, size, file, line) #define DMA_REQUEST_ASYNC(req, ram, vrom, size, unk5, queue, msg, file, line) DmaMgr_RequestAsyncDebug(req, ram, vrom, size, unk5, queue, msg, file, line) #define GAME_STATE_ALLOC(gameState, size, file, line) GameState_Alloc(gameState, size, file, line) @@ -229,9 +218,6 @@ extern struct GraphicsContext* __gfxCtx; (void)0 #define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) -#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx) -#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx) -#define MATRIX_CHECK_FLOATS(mtx, file, line) (mtx) #define DMA_REQUEST_SYNC(ram, vrom, size, file, line) DmaMgr_RequestSync(ram, vrom, size) #define DMA_REQUEST_ASYNC(req, ram, vrom, size, unk5, queue, msg, file, line) DmaMgr_RequestAsync(req, ram, vrom, size, unk5, queue, msg) #define GAME_STATE_ALLOC(gameState, size, file, line) THA_AllocTailAlign16(&(gameState)->tha, size) diff --git a/include/n64dd.h b/include/n64dd.h index 399334d55c..4f117f682d 100644 --- a/include/n64dd.h +++ b/include/n64dd.h @@ -4,10 +4,11 @@ #include "ultra64.h" #include "z64pause.h" #include "z64scene.h" +#include "z64map_mark.h" struct Font; struct GameState; -union Gfx; +struct MapData; struct MessageTableEntry; struct PlayState; struct RegEditor; @@ -32,7 +33,13 @@ typedef struct n64ddStruct_80121220 { void (*unk_0C)(struct PlayState* play); void (*unk_10)(struct PlayState* play); void (*unk_14)(struct PlayState* play); - char unk_18[0x1C]; + s32 (*unk_18)(struct MapData**); + s32 (*unk_1C)(struct MapData**); + s32 (*unk_20)(struct MapData*); + s32 (*unk_24)(void); + s32 (*unk_28)(struct PlayState*); + s32 (*unk_2C)(MapMarkData***); + s32 (*unk_30)(MapMarkData***); void (*unk_34)(PauseMapMarksData**); void (*unk_38)(PauseMapMarksData**); void (*unk_3C)(void); @@ -61,7 +68,7 @@ void func_800AD590(void); void func_800AD598(s32 arg0, s32 arg1, s32 arg2); u32 func_801C6E80(void); -void func_801C6EA0(union Gfx** gfxP); +void func_801C6EA0(Gfx** gfxP); s32 func_801C70FC(void); void func_801C7268(void); s32 func_801C7658(void); diff --git a/include/rand.h b/include/rand.h index 79ced24ea1..0f4f4d9cd3 100644 --- a/include/rand.h +++ b/include/rand.h @@ -10,7 +10,7 @@ void Rand_Seed_Variable(u32* rndNum, u32 seed); u32 Rand_Next_Variable(u32* rndNum); f32 Rand_ZeroOne_Variable(u32* rndNum); -#if PLATFORM_GC +#if !PLATFORM_N64 f32 Rand_Centered(void); f32 Rand_Centered_Variable(u32* rndNum); #endif diff --git a/include/sfx.h b/include/sfx.h index 7fc597867a..3d028817ae 100644 --- a/include/sfx.h +++ b/include/sfx.h @@ -133,7 +133,7 @@ void Audio_ProcessSfxRequest(void); void Audio_ChooseActiveSfx(u8 bankId); void Audio_PlayActiveSfx(u8 bankId); void Audio_StopSfxByBank(u8 bankId); -void func_800F8884(u8 bankId, Vec3f* pos); +void Audio_RemoveSfxFromBankByPos(u8 bankId, Vec3f* pos); void Audio_StopSfxByPosAndBank(u8 bankId, Vec3f* pos); void Audio_StopSfxByPos(Vec3f* pos); void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId); diff --git a/include/sys_matrix.h b/include/sys_matrix.h new file mode 100644 index 0000000000..91a2285d77 --- /dev/null +++ b/include/sys_matrix.h @@ -0,0 +1,85 @@ +#ifndef SYS_MATRIX_H +#define SYS_MATRIX_H + +#include "z64math.h" + +struct GraphicsContext; +struct GameState; + +typedef enum MatrixMode { + /* 0 */ MTXMODE_NEW, // generates a new matrix + /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix +} MatrixMode; + +extern Mtx gMtxClear; +extern MtxF gMtxFClear; + +/* Stack operations */ + +void Matrix_Init(struct GameState* gameState); +void Matrix_Push(void); +void Matrix_Pop(void); +void Matrix_Get(MtxF* dest); +void Matrix_Put(MtxF* src); + +/* Basic operations */ + +void Matrix_Mult(MtxF* mf, u8 mode); +void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode); +void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode); +void Matrix_RotateX(f32 x, u8 mode); +void Matrix_RotateY(f32 y, u8 mode); +void Matrix_RotateZ(f32 z, u8 mode); + +/* Compound operations */ + +void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); +void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot); +void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, + f32 translateZ); + +/* Conversion and allocation operations */ + +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); + +#if OOT_DEBUG + +Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx, const char* file, int line); +MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line); + +#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx, file, line) +#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx, file, line) +#define MATRIX_CHECK_FLOATS(mtx, file, line) Matrix_CheckFloats(mtx, file, line) + +#else + +Mtx* Matrix_ToMtx(Mtx* dest); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx); + +#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx) +#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx) +#define MATRIX_CHECK_FLOATS(mtx, file, line) (mtx) + +#endif + +/* Vector operations */ + +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); + +/* Copy and another conversion */ + +void Matrix_MtxFCopy(MtxF* dest, MtxF* src); +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); + +/* Miscellaneous */ + +void Matrix_Transpose(MtxF* mf); +void Matrix_ReplaceRotation(MtxF* mf); +void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag); +void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag); +void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode); + +#endif diff --git a/include/ultra64/controller.h b/include/ultra64/controller.h index 79dcf1c47d..4ce047a201 100644 --- a/include/ultra64/controller.h +++ b/include/ultra64/controller.h @@ -103,22 +103,6 @@ #define CONT_BLOCK_GB_BANK CONT_BLOCKS(CONT_ADDR_GB_BANK) #define CONT_BLOCK_GB_STATUS CONT_BLOCKS(CONT_ADDR_GB_STATUS) -/* Buttons */ -#define BTN_CRIGHT 0x0001 -#define BTN_CLEFT 0x0002 -#define BTN_CDOWN 0x0004 -#define BTN_CUP 0x0008 -#define BTN_R 0x0010 -#define BTN_L 0x0020 -#define BTN_DRIGHT 0x0100 -#define BTN_DLEFT 0x0200 -#define BTN_DDOWN 0x0400 -#define BTN_DUP 0x0800 -#define BTN_START 0x1000 -#define BTN_Z 0x2000 -#define BTN_B 0x4000 -#define BTN_A 0x8000 - #ifdef __GNUC__ // Ensure data cache coherency for OSPifRam structures by aligning to the data cache line size. // On older compilers such as IDO this was done by placing each OSPifRam at the top of the file it is declared in, diff --git a/include/ultra64/convert.h b/include/ultra64/convert.h index 02024d17fa..13679fc5b0 100644 --- a/include/ultra64/convert.h +++ b/include/ultra64/convert.h @@ -15,7 +15,4 @@ #define OS_PHYSICAL_TO_K0(x) (void*)(((u32)(x)+0x80000000)) #define OS_PHYSICAL_TO_K1(x) (void*)(((u32)(x)+0xA0000000)) -#define OS_MSEC_TO_CYCLES(n) OS_USEC_TO_CYCLES((n) * 1000) -#define OS_SEC_TO_CYCLES(n) OS_MSEC_TO_CYCLES((n) * 1000) - #endif diff --git a/include/ultra64/leodrive.h b/include/ultra64/leodrive.h index cb70b9a1fc..fbbbef8e0f 100644 --- a/include/ultra64/leodrive.h +++ b/include/ultra64/leodrive.h @@ -187,7 +187,7 @@ extern const s32 LEORAM_BYTE[]; extern s32 __leoActive; extern LEOVersion __leoVersion; -extern STACK(leoDiskStack, 0xFF0); +extern STACK(leoDiskStack, 0x1000); extern OSPiHandle* LEOPiInfo; diff --git a/include/ultra64/rcp.h b/include/ultra64/rcp.h index 86387ef5e8..9c97e8bd9f 100644 --- a/include/ultra64/rcp.h +++ b/include/ultra64/rcp.h @@ -529,7 +529,7 @@ #define VI_CTRL_ANTIALIAS_MODE_2 0x00200 // Bit [9:8] anti-alias mode: AA disabled, resampling enabled, operate as if everything is covered #define VI_CTRL_ANTIALIAS_MODE_3 0x00300 // Bit [9:8] anti-alias mode: AA disabled, resampling disabled, replicate pixels #define VI_CTRL_PIXEL_ADV_MASK 0x0F000 // [15:12] pixel advance mode -#define VI_CTRL_PIXEL_ADV(n) (((n) << 12) & VI_CTRL_PIXEL_ADV_MASK) // Bit [15:12] pixel advance mode: Always 3 on N64 +#define VI_CTRL_PIXEL_ADV_3 0x03000 // Bit [15:12] pixel advance mode: Always 3 on N64 #define VI_CTRL_DITHER_FILTER_ON 0x10000 // 16: dither-filter mode /* diff --git a/include/variables.h b/include/variables.h index fa09f0f54f..bf4fb15c52 100644 --- a/include/variables.h +++ b/include/variables.h @@ -7,10 +7,10 @@ extern Mtx D_01000000; -extern u32 osTvType; -extern u32 osRomBase; -extern u32 osResetType; -extern u32 osCicId; +extern void* osRomBase; +extern s32 osTvType; +extern s32 osResetType; +extern s32 osCicId; extern u32 osMemSize; extern u8 osAppNMIBuffer[0x40]; @@ -104,8 +104,6 @@ extern u8 gBossMarkState; extern s32 gScreenWidth; extern s32 gScreenHeight; -extern Mtx gMtxClear; -extern MtxF gMtxFClear; #if OOT_DEBUG extern u32 gIsCtrlr2Valid; #endif diff --git a/include/z64.h b/include/z64.h index 02cdafb49a..7a6187a485 100644 --- a/include/z64.h +++ b/include/z64.h @@ -5,6 +5,7 @@ #include "ultra64/gs2dex.h" #include "attributes.h" #include "audiomgr.h" +#include "controller.h" #include "z64save.h" #include "z64light.h" #include "z64bgcheck.h" @@ -65,6 +66,7 @@ #include "sys_math.h" #include "sys_math3d.h" #include "fp_math.h" +#include "sys_matrix.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -389,11 +391,6 @@ typedef struct DebugDispObject { /* 0x28 */ struct DebugDispObject* next; } DebugDispObject; // size = 0x2C -typedef enum MatrixMode { - /* 0 */ MTXMODE_NEW, // generates a new matrix - /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix -} MatrixMode; - typedef struct StackEntry { /* 0x00 */ struct StackEntry* next; /* 0x04 */ struct StackEntry* prev; diff --git a/include/z64actor.h b/include/z64actor.h index c3a8070ee6..7c97987dc6 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -96,39 +96,6 @@ typedef struct ActorOverlay { /* 0x1E */ s8 numLoaded; // original name: "clients" } ActorOverlay; // size = 0x20 -typedef struct DamageTable { - u8 table[32]; -} DamageTable; - -typedef struct CollisionCheckInfoInit { - /* 0x00 */ u8 health; - /* 0x02 */ s16 cylRadius; - /* 0x04 */ s16 cylHeight; - /* 0x06 */ u8 mass; -} CollisionCheckInfoInit; - -typedef struct CollisionCheckInfoInit2 { - /* 0x00 */ u8 health; - /* 0x02 */ s16 cylRadius; - /* 0x04 */ s16 cylHeight; - /* 0x06 */ s16 cylYShift; - /* 0x08 */ u8 mass; -} CollisionCheckInfoInit2; - -typedef struct CollisionCheckInfo { - /* 0x00 */ DamageTable* damageTable; - /* 0x04 */ Vec3f displacement; // Amount to correct actor velocity by when colliding into a body - /* 0x10 */ s16 cylRadius; // Used for various purposes - /* 0x12 */ s16 cylHeight; // Used for various purposes - /* 0x14 */ s16 cylYShift; // Unused. Purpose inferred from Cylinder16 and CollisionCheck_CylSideVsLineSeg - /* 0x16 */ u8 mass; // Used to compute displacement for OC collisions - /* 0x17 */ u8 health; // Note: some actors may use their own health variable instead of this one - /* 0x18 */ u8 damage; // Amount to decrement health by - /* 0x19 */ u8 damageEffect; // Stores what effect should occur when hit by a weapon - /* 0x1A */ u8 atHitEffect; // Stores what effect should occur when AT connects with an AC - /* 0x1B */ u8 acHitEffect; // Stores what effect should occur when AC is touched by an AT -} CollisionCheckInfo; // size = 0x1C - typedef struct ActorShape { /* 0x00 */ Vec3s rot; // Current actor shape rotation /* 0x06 */ s16 face; // Used to index eyes and mouth textures. Only used by player diff --git a/include/z64collision_check.h b/include/z64collision_check.h index 5921eda064..99ad7aa76b 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -1,12 +1,17 @@ #ifndef Z64COLLISION_CHECK_H #define Z64COLLISION_CHECK_H +#include "ultra64.h" +#include "z64math.h" + #define COLLISION_CHECK_AT_MAX 50 #define COLLISION_CHECK_AC_MAX 60 #define COLLISION_CHECK_OC_MAX 50 #define COLLISION_CHECK_OC_LINE_MAX 3 struct Actor; +struct GraphicsContext; +struct PlayState; /* * Bases for all shapes of colliders @@ -437,4 +442,131 @@ typedef struct CollisionCheckContext { #define DMG_RANGED (DMG_ARROW | DMG_HOOKSHOT | DMG_SLINGSHOT) #define DMG_DEFAULT ~(DMG_SHIELD | DMG_MIR_RAY) +typedef struct DamageTable { + u8 table[32]; +} DamageTable; + +typedef struct CollisionCheckInfoInit { + /* 0x00 */ u8 health; + /* 0x02 */ s16 cylRadius; + /* 0x04 */ s16 cylHeight; + /* 0x06 */ u8 mass; +} CollisionCheckInfoInit; + +typedef struct CollisionCheckInfoInit2 { + /* 0x00 */ u8 health; + /* 0x02 */ s16 cylRadius; + /* 0x04 */ s16 cylHeight; + /* 0x06 */ s16 cylYShift; + /* 0x08 */ u8 mass; +} CollisionCheckInfoInit2; + +typedef struct CollisionCheckInfo { + /* 0x00 */ DamageTable* damageTable; + /* 0x04 */ Vec3f displacement; // Amount to correct actor velocity by when colliding into a body + /* 0x10 */ s16 cylRadius; // Used for various purposes + /* 0x12 */ s16 cylHeight; // Used for various purposes + /* 0x14 */ s16 cylYShift; // Unused. Purpose inferred from Cylinder16 and CollisionCheck_CylSideVsLineSeg + /* 0x16 */ u8 mass; // Used to compute displacement for OC collisions + /* 0x17 */ u8 health; // Note: some actors may use their own health variable instead of this one + /* 0x18 */ u8 damage; // Amount to decrement health by + /* 0x19 */ u8 damageEffect; // Stores what effect should occur when hit by a weapon + /* 0x1A */ u8 atHitEffect; // Stores what effect should occur when AT connects with an AC + /* 0x1B */ u8 acHitEffect; // Stores what effect should occur when AC is touched by an AT +} CollisionCheckInfo; // size = 0x1C + +DamageTable* DamageTable_Get(s32 index); +void DamageTable_Clear(DamageTable* table); +#if OOT_DEBUG +void Collider_DrawRedPoly(struct GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC); +void Collider_DrawPoly(struct GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, u8 r, u8 g, u8 b); +#endif +s32 Collider_InitJntSph(struct PlayState* play, ColliderJntSph* jntSph); +s32 Collider_FreeJntSph(struct PlayState* play, ColliderJntSph* jntSph); +s32 Collider_DestroyJntSph(struct PlayState* play, ColliderJntSph* jntSph); +s32 Collider_SetJntSphToActor(struct PlayState* play, ColliderJntSph* dest, ColliderJntSphInitToActor* src); +s32 Collider_SetJntSphAllocType1(struct PlayState* play, ColliderJntSph* dest, struct Actor* actor, + ColliderJntSphInitType1* src); +s32 Collider_SetJntSphAlloc(struct PlayState* play, ColliderJntSph* dest, struct Actor* actor, ColliderJntSphInit* src); +s32 Collider_SetJntSph(struct PlayState* play, ColliderJntSph* dest, struct Actor* actor, ColliderJntSphInit* src, + ColliderJntSphElement* jntSphElements); +s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* col); +s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* col); +s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* col); +s32 Collider_InitCylinder(struct PlayState* play, ColliderCylinder* cyl); +s32 Collider_DestroyCylinder(struct PlayState* play, ColliderCylinder* cyl); +s32 Collider_SetCylinderToActor(struct PlayState* play, ColliderCylinder* dest, ColliderCylinderInitToActor* src); +s32 Collider_SetCylinderType1(struct PlayState* play, ColliderCylinder* dest, struct Actor* actor, ColliderCylinderInitType1* src); +s32 Collider_SetCylinder(struct PlayState* play, ColliderCylinder* dest, struct Actor* actor, ColliderCylinderInit* src); +s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* col); +s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* col); +s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* col); +s32 Collider_InitTris(struct PlayState* play, ColliderTris* tris); +s32 Collider_FreeTris(struct PlayState* play, ColliderTris* tris); +s32 Collider_DestroyTris(struct PlayState* play, ColliderTris* tris); +s32 Collider_SetTrisAllocType1(struct PlayState* play, ColliderTris* dest, struct Actor* actor, ColliderTrisInitType1* src); +s32 Collider_SetTrisAlloc(struct PlayState* play, ColliderTris* dest, struct Actor* actor, ColliderTrisInit* src); +s32 Collider_SetTris(struct PlayState* play, ColliderTris* dest, struct Actor* actor, ColliderTrisInit* src, + ColliderTrisElement* trisElements); +s32 Collider_ResetTrisAT(struct PlayState* play, Collider* col); +s32 Collider_ResetTrisAC(struct PlayState* play, Collider* col); +s32 Collider_ResetTrisOC(struct PlayState* play, Collider* col); +s32 Collider_InitQuad(struct PlayState* play, ColliderQuad* quad); +s32 Collider_DestroyQuad(struct PlayState* play, ColliderQuad* quad); +s32 Collider_SetQuadType1(struct PlayState* play, ColliderQuad* dest, struct Actor* actor, ColliderQuadInitType1* src); +s32 Collider_SetQuad(struct PlayState* play, ColliderQuad* dest, struct Actor* actor, ColliderQuadInit* src); +s32 Collider_ResetQuadAT(struct PlayState* play, Collider* col); +s32 Collider_ResetQuadAC(struct PlayState* play, Collider* col); +s32 Collider_ResetQuadOC(struct PlayState* play, Collider* col); +s32 Collider_InitLine(struct PlayState* play, OcLine* line); +s32 Collider_DestroyLine(struct PlayState* play, OcLine* line); +s32 Collider_SetLinePoints(struct PlayState* play, OcLine* ocLine, Vec3f* a, Vec3f* b); +s32 Collider_SetLine(struct PlayState* play, OcLine* dest, OcLine* src); +s32 Collider_ResetLineOC(struct PlayState* play, OcLine* line); +void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_DestroyContext(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx); +#if OOT_DEBUG +void Collider_Draw(struct PlayState* play, Collider* col); +void CollisionCheck_DrawCollision(struct PlayState* play, CollisionCheckContext* colChkCtx); +#endif +s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); +s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); +s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); +s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); +s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); +s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); +s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colChkCtx, OcLine* collider); +void CollisionCheck_BlueBlood(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_InitInfo(CollisionCheckInfo* info); +void CollisionCheck_ResetDamage(CollisionCheckInfo* info); +void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init); +void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init); +void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init); +void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init); +void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colChkCtx); +s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, + struct Actor** exclusions, s32 numExclusions); +void Collider_UpdateCylinder(struct Actor* actor, ColliderCylinder* cyl); +void Collider_SetCylinderPosition(ColliderCylinder* cyl, Vec3s* pos); +void Collider_SetQuadVertices(ColliderQuad* quad, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d); +void Collider_SetTrisVertices(ColliderTris* tris, s32 elemIndex, Vec3f* a, Vec3f* b, Vec3f* c); +void Collider_SetTrisDim(struct PlayState* play, ColliderTris* tris, s32 elemIndex, ColliderTrisElementDimInit* src); +void Collider_UpdateSpheres(s32 limb, ColliderJntSph* jntSph); +void CollisionCheck_SpawnRedBlood(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnWaterDroplets(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticles(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesMetal(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesMetalSfx(struct PlayState* play, Vec3f* v, Vec3f* pos); +void CollisionCheck_SpawnShieldParticlesMetal2(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesWood(struct PlayState* play, Vec3f* v, Vec3f* actorPos); +s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, + Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); +u8 CollisionCheck_GetSwordDamage(s32 dmgFlags); + #endif diff --git a/include/z64interface.h b/include/z64interface.h index c089ce396b..ac5bfc8153 100644 --- a/include/z64interface.h +++ b/include/z64interface.h @@ -151,7 +151,7 @@ typedef struct InterfaceContext { #define A_BUTTON_X 186 #define A_BUTTON_Y 9 -#if PLATFORM_N64 +#if !PLATFORM_GC #define A_BUTTON_R 90 #define A_BUTTON_G 90 #define A_BUTTON_B 255 @@ -164,7 +164,7 @@ typedef struct InterfaceContext { #define B_BUTTON_X 160 #define B_BUTTON_Y 17 -#if PLATFORM_N64 +#if !PLATFORM_GC #define B_BUTTON_R 0 #define B_BUTTON_G 150 #define B_BUTTON_B 0 @@ -186,7 +186,7 @@ typedef struct InterfaceContext { #define C_UP_BUTTON_X 254 #define C_UP_BUTTON_Y 16 -#if PLATFORM_N64 +#if !PLATFORM_GC #define START_BUTTON_R 200 #define START_BUTTON_G 0 #define START_BUTTON_B 0 diff --git a/include/z64math.h b/include/z64math.h index 7ed235e587..95a494a693 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -7,6 +7,11 @@ #define SQ(x) ((x)*(x)) #define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z) +typedef union FloatInt { + f32 f; + u32 i; +} FloatInt; + typedef struct Vec2f { f32 x, y; } Vec2f; // size = 0x08 diff --git a/include/z64pause.h b/include/z64pause.h index 5f4de2a09e..740eaf91c8 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -121,7 +121,7 @@ typedef enum WorldMapPoint { /* 0 */ WORLD_MAP_POINT_HAUNTED_WASTELAND, /* 1 */ WORLD_MAP_POINT_GERUDOS_FORTRESS, /* 2 */ WORLD_MAP_POINT_GERUDO_VALLEY, - /* 3 */ WORLD_MAP_POINT_HYLIA_LAKESIDE, + /* 3 */ WORLD_MAP_POINT_LAKE_HYLIA, /* 4 */ WORLD_MAP_POINT_LON_LON_RANCH, /* 5 */ WORLD_MAP_POINT_MARKET, /* 6 */ WORLD_MAP_POINT_HYRULE_FIELD, diff --git a/include/z64play.h b/include/z64play.h index bfea008834..432ecc2b19 100644 --- a/include/z64play.h +++ b/include/z64play.h @@ -63,7 +63,7 @@ typedef struct PlayState { /* 0x10B20 */ AnimTaskQueue animTaskQueue; /* 0x117A4 */ ObjectContext objectCtx; /* 0x11CBC */ RoomContext roomCtx; - /* 0x11D34 */ TransitionActorContext transiActorCtx; + /* 0x11D34 */ TransitionActorList transitionActors; /* 0x11D3C */ void (*playerInit)(Player* player, struct PlayState* play, FlexSkeletonHeader* skelHeader); /* 0x11D40 */ void (*playerUpdate)(Player* player, struct PlayState* play, Input* input); /* 0x11D44 */ int (*isPlayerDroppingFish)(struct PlayState* play); @@ -81,8 +81,7 @@ typedef struct PlayState { /* 0x11DE9 */ u8 haltAllActors; /* 0x11DEA */ u8 spawn; /* 0x11DEB */ u8 numActorEntries; - /* 0x11DEC */ u8 numRooms; - /* 0x11DF0 */ RomFile* roomList; + /* 0x11DEC */ RoomList roomList; /* 0x11DF4 */ ActorEntry* playerEntry; /* 0x11DF8 */ ActorEntry* actorEntryList; /* 0x11DFC */ void* unk_11DFC; diff --git a/include/z64scene.h b/include/z64scene.h index 72fb4ebd8b..87c8927d9f 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -40,10 +40,10 @@ typedef struct TransitionActorEntry { /* 0x0E */ s16 params; } TransitionActorEntry; // size = 0x10 -typedef struct TransitionActorContext { - /* 0x00 */ u8 numActors; +typedef struct TransitionActorList { + /* 0x00 */ u8 count; /* 0x04 */ TransitionActorEntry* list; -} TransitionActorContext; // size = 0x8 +} TransitionActorList; // size = 0x8 typedef struct Spawn { /* 0x00 */ u8 playerEntryIndex; @@ -171,7 +171,7 @@ typedef enum RoomBehaviorType2 { } RoomBehaviorType2; typedef struct Room { - /* 0x00 */ s8 num; + /* 0x00 */ s8 num; // -1 is invalid room /* 0x01 */ u8 unk_01; /* 0x02 */ u8 behaviorType2; /* 0x03 */ u8 behaviorType1; @@ -185,16 +185,21 @@ typedef struct Room { typedef struct RoomContext { /* 0x00 */ Room curRoom; /* 0x14 */ Room prevRoom; - /* 0x28 */ void* bufPtrs[2]; - /* 0x30 */ u8 unk_30; - /* 0x31 */ s8 status; - /* 0x34 */ void* unk_34; + /* 0x28 */ void* bufPtrs[2]; // Start and end pointers for the room buffer. Can be split into two pages, where page 0 is allocated from the start pointer and page 1 is allocated from the end pointer. + /* 0x30 */ u8 activeBufPage; // 0 - First page in memory, 1 - Last page in memory + /* 0x31 */ s8 status; // 0 - Free for new room request, 1 - DmaRequest for a new room is in progress + /* 0x34 */ void* roomRequestAddr; // Pointer to where the requested room segment will be stored /* 0x38 */ DmaRequest dmaRequest; /* 0x58 */ OSMesgQueue loadQueue; /* 0x70 */ OSMesg loadMsg; - /* 0x74 */ s16 unk_74[2]; // context-specific data used by the current scene draw config + /* 0x74 */ s16 drawParams[2]; // context-specific data used by the current scene draw config } RoomContext; // size = 0x78 +typedef struct RoomList { + /* 0x00 */ u8 count; + /* 0x04 */ RomFile* romFiles; // Array of rom addresses for each room in a scene +} RoomList; + #define ROOM_DRAW_OPA (1 << 0) #define ROOM_DRAW_XLU (1 << 1) diff --git a/osMalloc.h b/osMalloc.h index 5fb8dd8e4d..73f310fa17 100644 --- a/osMalloc.h +++ b/osMalloc.h @@ -11,7 +11,7 @@ typedef struct Arena { #if PLATFORM_N64 /* 0x08 */ u32 size; /* 0x0C */ u8 allocFailures; -#else +#elif PLATFORM_GC /* 0x08 */ OSMesgQueue lockQueue; /* 0x20 */ u8 allocFailures; // only used in non-debug builds /* 0x21 */ u8 isInit; diff --git a/src/audio/general.c b/src/audio/general.c index 9ce7324d20..af5ca719a6 100644 --- a/src/audio/general.c +++ b/src/audio/general.c @@ -3,7 +3,7 @@ #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) -#if PLATFORM_GC +#if !PLATFORM_N64 #define AUDIO_PRINTF osSyncPrintf #elif IDO_PRINTF_WORKAROUND #define AUDIO_PRINTF(args) (void)0 @@ -858,8 +858,8 @@ NatureAmbienceDataIO sNatureAmbienceDataIO[20] = { }, }; -#if PLATFORM_GC -u32 sOcarinaAllowedButtonMask = (BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP); +#if !PLATFORM_N64 +u32 sOcarinaAllowedButtonMask = (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT); s32 sOcarinaAButtonMap = BTN_A; s32 sOcarinaCUpButtonMap = BTN_CUP; s32 sOcarinaCDownButtonMap = BTN_CDOWN; @@ -1310,7 +1310,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVol); #if PLATFORM_N64 -#define OCARINA_ALLOWED_BUTTON_MASK (BTN_A | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP) +#define OCARINA_ALLOWED_BUTTON_MASK (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT) #define OCARINA_A_MAP BTN_A #define OCARINA_CUP_MAP BTN_CUP #define OCARINA_CDOWN_MAP BTN_CDOWN diff --git a/src/audio/sfx.c b/src/audio/sfx.c index 338559773d..90ed7a28f6 100644 --- a/src/audio/sfx.c +++ b/src/audio/sfx.c @@ -342,7 +342,7 @@ void Audio_ChooseActiveSfx(u8 bankId) { entry->sfxId, entry->posX, entry->posZ, *entry->posX, *entry->posY, *entry->posZ); } entry->priority = (u32)entry->dist + (SQ(0xFF - sfxImportance) * SQ(76)); -#if PLATFORM_GC +#if !PLATFORM_N64 temp3 = entry->sfxId; // fake entry->priority = entry->priority + temp3 - temp3; #endif @@ -533,7 +533,7 @@ void Audio_StopSfxByBank(u8 bankId) { Audio_RemoveMatchingSfxRequests(0, &cmp); } -void func_800F8884(u8 bankId, Vec3f* pos) { +void Audio_RemoveSfxFromBankByPos(u8 bankId, Vec3f* pos) { SfxBankEntry* entry; u8 entryIndex = gSfxBanks[bankId][0].next; u8 prevEntryIndex = 0; @@ -557,7 +557,7 @@ void func_800F8884(u8 bankId, Vec3f* pos) { void Audio_StopSfxByPosAndBank(u8 bankId, Vec3f* pos) { SfxBankEntry cmp; - func_800F8884(bankId, pos); + Audio_RemoveSfxFromBankByPos(bankId, pos); cmp.sfxId = bankId << 12; cmp.posX = &pos->x; Audio_RemoveMatchingSfxRequests(1, &cmp); @@ -568,7 +568,7 @@ void Audio_StopSfxByPos(Vec3f* pos) { SfxBankEntry cmp; for (i = 0; i < ARRAY_COUNT(gSfxBanks); i++) { - func_800F8884(i, pos); + Audio_RemoveSfxFromBankByPos(i, pos); } cmp.posX = &pos->x; Audio_RemoveMatchingSfxRequests(2, &cmp); diff --git a/src/boot/stackcheck.c b/src/boot/stackcheck.c index a1cff55e62..399b6c051b 100644 --- a/src/boot/stackcheck.c +++ b/src/boot/stackcheck.c @@ -18,7 +18,7 @@ void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 i entry->minSpace = minSpace; entry->name = name; -#if PLATFORM_GC +#if !PLATFORM_N64 iter = sStackInfoListStart; while (iter) { if (iter == entry) { diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 915bbecf68..32d99f368b 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -42,8 +42,8 @@ */ #if PLATFORM_GC -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-eu-mq-dbg:208 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224" \ - "gc-us-mq:224" +#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-eu-mq-dbg:208 gc-jp:208 gc-jp-ce:208 gc-jp-mq:208 gc-us:208" \ + "gc-us-mq:208" #include "global.h" #include "alloca.h" @@ -144,7 +144,8 @@ void Fault_ClientRunTask(FaultClientTask* task) { // Await done while (true) { - osSetTimer(&timer, OS_SEC_TO_CYCLES(1), 0, &queue, (OSMesg)timerMsgVal); + // Wait for 1 second + osSetTimer(&timer, OS_USEC_TO_CYCLES(1000000), 0, &queue, (OSMesg)timerMsgVal); osRecvMesg(&queue, &recMsg, OS_MESG_BLOCK); if (recMsg != (OSMesg)666) { @@ -214,7 +215,9 @@ void Fault_AddClient(FaultClient* client, void* callback, void* arg0, void* arg1 end: osSetIntMask(mask); if (alreadyExists) { - osSyncPrintf(VT_COL(RED, WHITE) "fault_AddClient: %08x は既にリスト中にある\n" VT_RST, client); + osSyncPrintf(VT_COL(RED, WHITE) T("fault_AddClient: %08x は既にリスト中にある\n", + "fault_AddClient: %08x is already in the list\n") VT_RST, + client); } } @@ -250,7 +253,9 @@ void Fault_RemoveClient(FaultClient* client) { osSetIntMask(mask); if (listIsEmpty) { - osSyncPrintf(VT_COL(RED, WHITE) "fault_RemoveClient: %08x リスト不整合です\n" VT_RST, client); + osSyncPrintf(VT_COL(RED, WHITE) T("fault_RemoveClient: %08x リスト不整合です\n", + "fault_RemoveClient: %08x list inconsistency\n") VT_RST, + client); } } @@ -292,7 +297,9 @@ void Fault_AddAddrConvClient(FaultAddrConvClient* client, void* callback, void* end: osSetIntMask(mask); if (alreadyExists) { - osSyncPrintf(VT_COL(RED, WHITE) "fault_AddressConverterAddClient: %08x は既にリスト中にある\n" VT_RST, client); + osSyncPrintf(VT_COL(RED, WHITE) T("fault_AddressConverterAddClient: %08x は既にリスト中にある\n", + "fault_AddressConverterAddClient: %08x is already in the list\n") VT_RST, + client); } } @@ -326,7 +333,8 @@ void Fault_RemoveAddrConvClient(FaultAddrConvClient* client) { osSetIntMask(mask); if (listIsEmpty) { - osSyncPrintf(VT_COL(RED, WHITE) "fault_AddressConverterRemoveClient: %08x は既にリスト中にある\n" VT_RST, + osSyncPrintf(VT_COL(RED, WHITE) T("fault_AddressConverterRemoveClient: %08x は既にリスト中にある\n", + "fault_AddressConverterRemoveClient: %08x is already in the list\n") VT_RST, client); } } @@ -653,7 +661,7 @@ void Fault_Wait5Seconds(void) { do { Fault_Sleep(1000 / 60); - } while ((osGetTime() - start) < OS_SEC_TO_CYCLES(5) + 1); + } while ((osGetTime() - start) <= OS_USEC_TO_CYCLES(5000000)); // 5 seconds sFaultInstance->autoScroll = true; } @@ -674,14 +682,16 @@ void Fault_WaitForButtonCombo(void) { if (1) {} if (1) {} - // KeyWaitB (LRZ Up Down Up Down Left Left Right Right B A START) - osSyncPrintf( - VT_FGCOL(WHITE) "KeyWaitB (LRZ " VT_FGCOL(WHITE) "上" VT_FGCOL(YELLOW) "下 " VT_FGCOL(YELLOW) "上" VT_FGCOL(WHITE) "下 " VT_FGCOL(WHITE) "左" VT_FGCOL( - YELLOW) "左 " VT_FGCOL(YELLOW) "右" VT_FGCOL(WHITE) "右 " VT_FGCOL(GREEN) "B" VT_FGCOL(BLUE) "A" VT_FGCOL(RED) "START" VT_FGCOL(WHITE) ")" VT_RST - "\n"); - // KeyWaitB'(LR Left Right START) - osSyncPrintf(VT_FGCOL(WHITE) "KeyWaitB'(LR左" VT_FGCOL(YELLOW) "右 +" VT_FGCOL(RED) "START" VT_FGCOL( - WHITE) ")" VT_RST "\n"); + // "KeyWaitB (L R Z Up Down Up Down Left Left Right Right B A START)" + osSyncPrintf(VT_FGCOL(WHITE) T("KeyWaitB (LRZ ", "KeyWaitB (L R Z ") VT_FGCOL(WHITE) T("上", "Up ") + VT_FGCOL(YELLOW) T("下 ", "Down ") VT_FGCOL(YELLOW) T("上", "Up ") VT_FGCOL(WHITE) + T("下 ", "Down ") VT_FGCOL(WHITE) T("左", "Left ") VT_FGCOL(YELLOW) T("左 ", "Left ") + VT_FGCOL(YELLOW) T("右", "Right ") VT_FGCOL(WHITE) T("右 ", "Right ") VT_FGCOL(GREEN) + T("B", "B ") VT_FGCOL(BLUE) T("A", "A ") + VT_FGCOL(RED) "START" VT_FGCOL(WHITE) ")" VT_RST "\n"); + // "KeyWaitB'(L R Left Right +START)" + osSyncPrintf(VT_FGCOL(WHITE) T("KeyWaitB'(LR左", "KeyWaitB'(L R Left ") VT_FGCOL(YELLOW) T("右 +", "Right +") + VT_FGCOL(RED) "START" VT_FGCOL(WHITE) ")" VT_RST "\n"); Fault_SetForeColor(GPACK_RGBA5551(255, 255, 255, 1)); Fault_SetBackColor(GPACK_RGBA5551(0, 0, 0, 1)); @@ -1184,20 +1194,20 @@ void Fault_ThreadEntry(void* arg) { if (msg == FAULT_MSG_CPU_BREAK) { sFaultInstance->msgId = (u32)FAULT_MSG_CPU_BREAK; - // Fault Manager: OS_EVENT_CPU_BREAK received - osSyncPrintf("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n"); + osSyncPrintf(T("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n", + "Fault Manager: OS_EVENT_CPU_BREAK received\n")); } else if (msg == FAULT_MSG_FAULT) { sFaultInstance->msgId = (u32)FAULT_MSG_FAULT; - // Fault Manager: OS_EVENT_FAULT received - osSyncPrintf("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n"); + osSyncPrintf( + T("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n", "Fault Manager: OS_EVENT_FAULT received\n")); } else if (msg == FAULT_MSG_UNK) { Fault_UpdatePad(); faultedThread = NULL; continue; } else { sFaultInstance->msgId = (u32)FAULT_MSG_UNK; - // Fault Manager: Unknown message received - osSyncPrintf("フォルトマネージャ:不明なメッセージを受信しました\n"); + osSyncPrintf(T("フォルトマネージャ:不明なメッセージを受信しました\n", + "Fault Manager: Unknown message received\n")); } faultedThread = __osGetCurrFaultedThread(); diff --git a/src/code/fault_gc_drawer.c b/src/code/fault_gc_drawer.c index 5cf088fca6..808b258497 100644 --- a/src/code/fault_gc_drawer.c +++ b/src/code/fault_gc_drawer.c @@ -7,6 +7,7 @@ #include "global.h" #include "fault.h" #include "terminal.h" +#pragma increment_block_number "gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" #if PLATFORM_GC diff --git a/src/code/fault_n64.c b/src/code/fault_n64.c index 5a8dd9d1d6..92b1976aa2 100644 --- a/src/code/fault_n64.c +++ b/src/code/fault_n64.c @@ -93,7 +93,7 @@ FaultCursorCoords sFaultCursorPos; vs32 sFaultExit; vs32 gFaultMsgId; vs32 sFaultDisplayEnable; -OSThread* sFaultFaultedThread; +volatile OSThread* gFaultFaultedThread; s32 B_80122570[16]; s32 B_801225B0[8]; // Unused (file padding?) @@ -109,7 +109,7 @@ void Fault_WaitForInputImpl(void) { Fault_SleepImpl(0x10); PadMgr_RequestPadData(&gPadMgr, inputs, 0); btnPress = inputs[0].press.button; - } while (!CHECK_BTN_ANY(btnPress, (BTN_A | BTN_B | BTN_START | BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP))); + } while (!CHECK_BTN_ANY(btnPress, (BTN_A | BTN_B | BTN_START | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT))); } void Fault_WaitForInput(void) { @@ -449,11 +449,14 @@ void Fault_WaitForButtonCombo(void) { s32 count; s32 pad[4]; - // KeyWaitB (LRZ Up Down Up Down Left Left Right Right B A START) - osSyncPrintf( - VT_FGCOL(WHITE) "KeyWaitB (LRZ " VT_FGCOL(WHITE) "上" VT_FGCOL(YELLOW) "下 " VT_FGCOL(YELLOW) "上" VT_FGCOL(WHITE) "下 " VT_FGCOL(WHITE) "左" VT_FGCOL( - YELLOW) "左 " VT_FGCOL(YELLOW) "右" VT_FGCOL(WHITE) "右 " VT_FGCOL(GREEN) "B" VT_FGCOL(BLUE) "A" VT_FGCOL(RED) "START" VT_FGCOL(WHITE) ")" VT_RST - "\n"); + // "KeyWaitB (L R Z Up Down Up Down Left Left Right Right B A START)" + osSyncPrintf(VT_FGCOL(WHITE) T("KeyWaitB (LRZ ", "KeyWaitB (L R Z ") VT_FGCOL(WHITE) T("上", "Up ") + VT_FGCOL(YELLOW) T("下 ", "Down ") VT_FGCOL(YELLOW) T("上", "Up ") VT_FGCOL(WHITE) + T("下 ", "Down ") VT_FGCOL(WHITE) T("左", "Left ") VT_FGCOL(YELLOW) T("左 ", "Left ") + VT_FGCOL(YELLOW) T("右", "Right ") VT_FGCOL(WHITE) T("右 ", "Right ") VT_FGCOL(GREEN) + T("B", "B ") VT_FGCOL(BLUE) T("A", "A ") + VT_FGCOL(RED) "START" VT_FGCOL(WHITE) ")" VT_RST "\n"); + x = 0; y = 0; count = 0; @@ -585,8 +588,7 @@ void Fault_WaitForButtonCombo(void) { if ((btnCur == (BTN_A | BTN_B | BTN_START)) && (btnPress == BTN_START)) { f32 comboTimeSeconds = OS_CYCLES_TO_USEC(osGetTime() - comboStartTime) / 1000000.0f; - // Input time %f seconds - osSyncPrintf("入力時間 %f 秒\n", comboTimeSeconds); + osSyncPrintf(T("入力時間 %f 秒\n", "Input time %f seconds\n"), comboTimeSeconds); if (comboTimeSeconds <= 50.0f) { x = 11; } else { @@ -750,16 +752,16 @@ void Fault_ThreadEntry(void* arg0) { osRecvMesg(&gFaultMgr.queue, &msg, OS_MESG_BLOCK); if (msg == FAULT_MSG_CPU_BREAK) { gFaultMsgId = (s32)FAULT_MSG_CPU_BREAK; - // Fault Manager: OS_EVENT_CPU_BREAK received - osSyncPrintf("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n"); + osSyncPrintf(T("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n", + "Fault Manager: OS_EVENT_CPU_BREAK received\n")); } else if (msg == FAULT_MSG_FAULT) { gFaultMsgId = (s32)FAULT_MSG_FAULT; - // Fault Manager: OS_EVENT_FAULT received - osSyncPrintf("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n"); + osSyncPrintf( + T("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n", "Fault Manager: OS_EVENT_FAULT received\n")); } else { gFaultMsgId = (s32)FAULT_MSG_UNK; - // Fault Manager: Unknown message received - osSyncPrintf("フォルトマネージャ:不明なメッセージを受信しました\n"); + osSyncPrintf(T("フォルトマネージャ:不明なメッセージを受信しました\n", + "Fault Manager: Unknown message received\n")); } faultedThread = __osGetCurrFaultedThread(); osSyncPrintf("__osGetCurrFaultedThread()=%08x\n", faultedThread); @@ -768,7 +770,7 @@ void Fault_ThreadEntry(void* arg0) { osSyncPrintf("FindFaultedThread()=%08x\n", faultedThread); } } while (faultedThread == NULL); - sFaultFaultedThread = faultedThread; + gFaultFaultedThread = faultedThread; Fault_LogThreadContext(faultedThread); osSyncPrintf("%d %s %d:%s = %d\n", osGetThreadId(NULL), "fault.c", 1454, "fault_display_enable", sFaultDisplayEnable); diff --git a/src/code/fp.s b/src/code/fp.s index f7a00e2136..d5b42094a3 100644 --- a/src/code/fp.s +++ b/src/code/fp.s @@ -6,7 +6,7 @@ .balign 16 -#if PLATFORM_GC +#if !PLATFORM_N64 DATA(qNaN0x3FFFFF) .word 0x7FBFFFFF ENDDATA(qNaN0x3FFFFF) diff --git a/src/code/fp_math.c b/src/code/fp_math.c index fb73b58ef6..85fb4cedf3 100644 --- a/src/code/fp_math.c +++ b/src/code/fp_math.c @@ -1,7 +1,7 @@ #include "z64math.h" #include "macros.h" -#if PLATFORM_GC +#if !PLATFORM_N64 s32 gUseAtanContFrac; #endif @@ -46,7 +46,7 @@ f32 Math_FNearbyIntF(f32 x) { return nearbyintf(x); } -#if PLATFORM_GC +#if !PLATFORM_N64 /* Arctangent approximation using a Taylor series (one quadrant) */ f32 Math_FAtanTaylorQF(f32 x) { static const f32 coeffs[] = { @@ -173,7 +173,7 @@ f32 Math_FAtanContFracF(f32 x) { #endif } -#if PLATFORM_GC +#if !PLATFORM_N64 /** * @return arctan(x) in radians, in (-pi/2,pi/2) range */ diff --git a/src/code/game.c b/src/code/game.c index e00bc74066..af22e79498 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -302,22 +302,22 @@ void GameState_Update(GameState* gameState) { gfxCtx->xScale = gViConfigXScale; gfxCtx->yScale = gViConfigYScale; - if (SREG(63) == 6 || (SREG(63) == 2u && osTvType == OS_TV_NTSC)) { + if (SREG(63) == 6 || (SREG(63) == 2u && (u32)osTvType == OS_TV_NTSC)) { gfxCtx->viMode = &osViModeNtscLan1; gfxCtx->yScale = 1.0f; } - if (SREG(63) == 5 || (SREG(63) == 2u && osTvType == OS_TV_MPAL)) { + if (SREG(63) == 5 || (SREG(63) == 2u && (u32)osTvType == OS_TV_MPAL)) { gfxCtx->viMode = &osViModeMpalLan1; gfxCtx->yScale = 1.0f; } - if (SREG(63) == 4 || (SREG(63) == 2u && osTvType == OS_TV_PAL)) { + if (SREG(63) == 4 || (SREG(63) == 2u && (u32)osTvType == OS_TV_PAL)) { gfxCtx->viMode = &osViModePalLan1; gfxCtx->yScale = 1.0f; } - if (SREG(63) == 3 || (SREG(63) == 2u && osTvType == OS_TV_PAL)) { + if (SREG(63) == 3 || (SREG(63) == 2u && (u32)osTvType == OS_TV_PAL)) { gfxCtx->viMode = &osViModeFpalLan1; gfxCtx->yScale = 0.833f; } @@ -533,7 +533,7 @@ void* GameState_Alloc(GameState* gameState, size_t size, const char* file, int l void* ret; if (THA_IsCrash(&gameState->tha)) { - PRINTF("ハイラルは滅亡している\n"); + PRINTF(T("ハイラルは滅亡している\n", "Hyrule is destroyed\n")); ret = NULL; } else if ((u32)THA_GetRemaining(&gameState->tha) < size) { PRINTF(T("滅亡寸前のハイラルには %d バイトの余力もない(滅亡まであと %d バイト)\n", diff --git a/src/code/gfxprint.c b/src/code/gfxprint.c index ac4bb7ced0..dd80bcfd19 100644 --- a/src/code/gfxprint.c +++ b/src/code/gfxprint.c @@ -126,7 +126,7 @@ u8 sGfxPrintFontData[(16 * 256) / 2] = { 0x1B, 0xAA, 0x40, 0x21, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -#if PLATFORM_GC +#if !PLATFORM_N64 // Can be used to set GFXP_FLAG_ENLARGE by default static u8 sDefaultSpecialFlags; #endif @@ -342,7 +342,7 @@ void GfxPrint_Init(GfxPrint* this) { this->flags |= GFXP_FLAG_SHADOW; this->flags |= GFXP_FLAG_UPDATE; -#if PLATFORM_GC +#if !PLATFORM_N64 if (sDefaultSpecialFlags & GFXP_FLAG_ENLARGE) { this->flags |= GFXP_FLAG_ENLARGE; } else { @@ -361,7 +361,7 @@ void GfxPrint_Open(GfxPrint* this, Gfx* dList) { GfxPrint_Setup(this); } else { #if PLATFORM_N64 || OOT_DEBUG - osSyncPrintf("gfxprint_open:2重オープンです\n"); + osSyncPrintf(T("gfxprint_open:2重オープンです\n", "gfxprint_open: Double open\n")); #endif } } @@ -370,7 +370,7 @@ Gfx* GfxPrint_Close(GfxPrint* this) { Gfx* ret; this->flags &= ~GFXP_FLAG_OPEN; -#if PLATFORM_GC +#if !PLATFORM_N64 gDPPipeSync(this->dList++); #endif ret = this->dList; diff --git a/src/code/graph.c b/src/code/graph.c index 1f9ba5e30d..2b4777ea63 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -179,6 +179,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { { CfbInfo* cfb; + // Schedule a message to be handled in 3 seconds, for RCP timeout osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, (OSMesg)666); osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_BLOCK); diff --git a/src/code/irqmgr.c b/src/code/irqmgr.c index 7f630981b3..d623ddad88 100644 --- a/src/code/irqmgr.c +++ b/src/code/irqmgr.c @@ -164,7 +164,7 @@ void IrqMgr_HandlePreNMI(IrqMgr* irqMgr) { sIrqMgrResetTime = irqMgr->resetTime = osGetTime(); // Schedule a PRENMI450 message to be handled in 450ms - osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(450), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI450_MSG); + osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(450000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI450_MSG); IrqMgr_JamMesgToClients(irqMgr, (OSMesg)&irqMgr->prenmiMsg); } @@ -190,7 +190,7 @@ void IrqMgr_HandlePreNMI450(IrqMgr* irqMgr) { irqMgr->resetStatus = IRQ_RESET_STATUS_NMI; // Schedule a PRENMI480 message to be handled in 30ms - osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(30), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI480_MSG); + osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(30000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI480_MSG); // Send the NMI event to clients IrqMgr_SendMesgToClients(irqMgr, (OSMesg)&irqMgr->nmiMsg); } @@ -199,7 +199,7 @@ void IrqMgr_HandlePreNMI480(IrqMgr* irqMgr) { u32 result; // Schedule a PRENMI500 message to be handled in 20ms - osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(20), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI500_MSG); + osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(20000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI500_MSG); result = osAfterPreNMI(); if (result != 0) { @@ -207,7 +207,7 @@ void IrqMgr_HandlePreNMI480(IrqMgr* irqMgr) { // osAfterPreNMI failed, try again in 1ms //! @bug setting the same timer for a second time without letting the first one complete breaks //! the timer linked list - osSetTimer(&irqMgr->timer, OS_MSEC_TO_CYCLES(1), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI480_MSG); + osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(1000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI480_MSG); } } diff --git a/src/code/rand.c b/src/code/rand.c index 917b1ecfc6..d6199b1890 100644 --- a/src/code/rand.c +++ b/src/code/rand.c @@ -42,6 +42,7 @@ * @note Original name: qrand.c */ #include "rand.h" +#include "z64math.h" #define RAND_MULTIPLIER 1664525 #define RAND_INCREMENT 1013904223 @@ -53,13 +54,13 @@ */ static u32 sRandInt = 1; -#if PLATFORM_GC +#if !PLATFORM_N64 /** * Space to store a value to be re-interpreted as a float. * * @note Orignal name: __qrand_itemp */ -static fu sRandFloat; +static FloatInt sRandFloat; #endif /** @@ -114,7 +115,7 @@ f32 Rand_ZeroOne(void) { #endif } -#if PLATFORM_GC +#if !PLATFORM_N64 /** * Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same manner in which Rand_ZeroOne * generates its result. @@ -179,7 +180,7 @@ f32 Rand_ZeroOne_Variable(u32* rndNum) { #endif } -#if PLATFORM_GC +#if !PLATFORM_N64 /** * Generates the next pseudo-random floating-point number between -0.5f and 0.5f from the provided rndNum. * diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 570da1ab01..38fb383124 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -5,7 +5,7 @@ #include "macros.h" #include "sys_math3d.h" -#pragma increment_block_number "gc-eu:106 gc-eu-mq:106 gc-jp:106 gc-jp-ce:106 gc-jp-mq:106 gc-us:106 gc-us-mq:106" +#pragma increment_block_number "gc-eu:103 gc-eu-mq:103 gc-jp:103 gc-jp-ce:103 gc-jp-mq:103 gc-us:103 gc-us-mq:103" s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, Vec3f* lineAClosestToB, Vec3f* lineBClosestToA); diff --git a/src/code/ucode_disas.c b/src/code/ucode_disas.c index a3540390c5..c0bab3f994 100644 --- a/src/code/ucode_disas.c +++ b/src/code/ucode_disas.c @@ -222,7 +222,7 @@ void UCodeDisas_SetCurUCodeImpl(UCodeDisas* this, void* ptr) { } } if (i >= this->ucodeInfoCount) { - DISAS_LOG("マイクロコードが一致しなかった\n"); // "Microcode did not match" + DISAS_LOG(T("マイクロコードが一致しなかった\n", "Microcode did not match\n")); this->ucodeType = UCODE_NULL; } } @@ -413,7 +413,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { settile.shiftt, (settile.cs << 1) + settile.ms, settile.masks, settile.shifts); if (this->tileSyncRequired) { - DISAS_LOG("### TileSyncが必要です。\n"); + DISAS_LOG(T("### TileSyncが必要です。\n", "### TileSync is required.\n")); this->syncErr++; } } break; @@ -432,7 +432,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { loadtile.th); if (this->loadSyncRequired) { - DISAS_LOG("### LoadSyncが必要です。\n"); + DISAS_LOG(T("### LoadSyncが必要です。\n", "### LoadSync is required.\n")); this->syncErr++; } this->pipeSyncRequired = true; @@ -476,7 +476,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { UCodeDisas_GetCombineAlphaName(setcombine.Ad1, COMBINER_D)); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -529,7 +529,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { this->modeH |= s2; if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -571,7 +571,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { this->modeL |= s2; if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -582,7 +582,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { this->modeL = curGfx->words.w1; if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -632,7 +632,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { (curGfx->dma.len & 0xFFF) + 1, curGfx->setimg.dram, addr); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -641,7 +641,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { DISAS_LOG("gsDPSetDepthImage(0x%08x(0x%08x)),", curGfx->setimg.dram, addr); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -668,7 +668,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { curGfx->setcolor.b, curGfx->setcolor.a); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -678,7 +678,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { curGfx->setcolor.b, curGfx->setcolor.a); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -688,7 +688,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { curGfx->setcolor.b, curGfx->setcolor.a); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -697,7 +697,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { DISAS_LOG("gsDPSetFillColor(0x%08x),", curGfx->setcolor.color); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -706,7 +706,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { DISAS_LOG("gsDPSetPrimDepth(%d, %d),", curGfx->setprimdepth.z, curGfx->setprimdepth.dz); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; @@ -721,7 +721,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { DISAS_LOG("gsDPFullSync(),"); if (this->pipeSyncRequired) { - DISAS_LOG("### PipeSyncが必要です。\n"); + DISAS_LOG(T("### PipeSyncが必要です。\n", "### PipeSync is required.\n")); this->syncErr++; } } break; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 96617f4962..0624815ffb 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -772,19 +772,19 @@ void TitleCard_Update(PlayState* play, TitleCardContext* titleCtx) { void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { s32 width; s32 height; - s32 unused; - s32 titleX; s32 doubleWidth; - s32 titleY; - s32 titleSecondY; + s32 titleX1; + s32 titleX2; + s32 titleY1; + s32 titleY2; s32 textureLanguageOffset; if (titleCtx->alpha != 0) { width = titleCtx->width; height = titleCtx->height; doubleWidth = width * 2; - titleX = (titleCtx->x * 4) - (width * 2); - titleY = (titleCtx->y * 4) - (height * 2); + titleX1 = (titleCtx->x * 4) - (width * 2); + titleY1 = (titleCtx->y * 4) - (height * 2); OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2824); @@ -797,8 +797,13 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { #else textureLanguageOffset = width * height * gSaveContext.language; #endif - height = (width * height > 0x1000) ? 0x1000 / width : height; - titleSecondY = titleY + (height * 4); + + if (width * height > 0x1000) { + height = 0x1000 / width; + } + + titleX2 = titleX1 + (doubleWidth * 2); + titleY2 = titleY1 + (height * 4); OVERLAY_DISP = Gfx_SetupDL_52NoCD(OVERLAY_DISP); @@ -809,8 +814,8 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(OVERLAY_DISP++, titleX, titleY, ((doubleWidth * 2) + titleX) - 4, titleY + (height * 4) - 1, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, titleX1, titleY1, titleX2 - 4, titleY2 - 1, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); height = titleCtx->height - height; @@ -820,8 +825,8 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { G_IM_SIZ_8b, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(OVERLAY_DISP++, titleX, titleSecondY, ((doubleWidth * 2) + titleX) - 4, - titleSecondY + (height * 4) - 1, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, titleX1, titleY2, titleX2 - 4, titleY2 + (height * 4) - 1, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 2880); @@ -911,8 +916,7 @@ void Actor_Destroy(Actor* actor, PlayState* play) { overlayEntry = actor->overlayEntry; name = overlayEntry->name != NULL ? overlayEntry->name : ""; - // "No Actor class destruct [%s]" - PRINTF("Actorクラス デストラクトがありません [%s]\n" VT_RST, name); + PRINTF(T("Actorクラス デストラクトがありません [%s]\n", "No Actor class destruct [%s]\n") VT_RST, name); #endif } } @@ -1629,29 +1633,46 @@ TargetRangeParams sTargetRanges[TARGET_MODE_MAX] = { }; /** - * Checks if an actor at distance `distSq` is inside the range specified by its targetMode + * Checks if an actor at `distSq` is inside the range specified by its `targetMode`. + * + * Note that this gets used for both the target range check and for the lock-on leash range check. + * Despite how the data is presented in `sTargetRanges`, the leash range is stored as a scale factor value. + * When checking the leash range, this scale factor is applied to the input distance and checked against + * the base `rangeSq` value, which was used to initiate the lock-on in the first place. */ u32 Target_ActorIsInRange(Actor* actor, f32 distSq) { return distSq < sTargetRanges[actor->targetMode].rangeSq; } -s32 func_8002F0C8(Actor* actor, Player* player, s32 flag) { +/** + * Returns true if an actor lock-on should be released. + * This function does not actually release the lock-on, as that is Player's responsibility. + * + * If an actor's update function is NULL or `ACTOR_FLAG_0` is unset, the lock-on should be released. + * + * There is also a check for Player exceeding the lock-on leash distance. + * Note that this check will be ignored if `ignoreLeash` is true. + * + */ +s32 Target_ShouldReleaseLockOn(Actor* actor, Player* player, s32 ignoreLeash) { if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_0)) { return true; } - if (!flag) { - s16 var = (s16)(actor->yawTowardsPlayer - 0x8000) - player->actor.shape.rot.y; - s16 abs_var = ABS(var); - f32 dist; + if (!ignoreLeash) { + s16 yawDiff = (s16)(actor->yawTowardsPlayer - 0x8000) - player->actor.shape.rot.y; + s16 yawDiffAbs = ABS(yawDiff); + f32 distSq; - if ((player->focusActor == NULL) && (abs_var > 0x2AAA)) { - dist = MAXFLOAT; + if ((player->focusActor == NULL) && (yawDiffAbs > 0x2AAA)) { + // This function is only called (and is only relevant) when `player->focusActor != NULL`. + // This is unreachable. + distSq = MAXFLOAT; } else { - dist = actor->xyzDistToPlayerSq; + distSq = actor->xyzDistToPlayerSq; } - return !Target_ActorIsInRange(actor, sTargetRanges[actor->targetMode].leashScale * dist); + return !Target_ActorIsInRange(actor, sTargetRanges[actor->targetMode].leashScale * distSq); } return false; @@ -1972,7 +1993,7 @@ void func_8002F994(Actor* actor, s32 timer) { // Tests if something hit Jabu Jabu surface, displaying hit splash and playing sfx if true s32 func_8002F9EC(PlayState* play, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) { if (SurfaceType_GetFloorType(&play->colCtx, poly, bgId) == FLOOR_TYPE_8) { - play->roomCtx.unk_74[0] = 1; + play->roomCtx.drawParams[0] = 1; CollisionCheck_BlueBlood(play, NULL, pos); Actor_PlaySfx(actor, NA_SE_IT_WALL_HIT_BUYO); return true; @@ -2403,13 +2424,13 @@ void Actor_FaultPrint(Actor* actor, char* command) { overlayEntry = actor->overlayEntry; name = overlayEntry->name != NULL ? overlayEntry->name : ""; - PRINTF("アクターの名前(%08x:%s)\n", actor, name); // "Actor name (%08x:%s)" + PRINTF(T("アクターの名前(%08x:%s)\n", "Actor name (%08x:%s)\n"), actor, name); #else name = ""; #endif if (command != NULL) { - PRINTF("コメント:%s\n", command); // "Command:%s" + PRINTF(T("コメント:%s\n", "Command: %s\n"), command); } Fault_SetCursor(48, 24); @@ -2813,7 +2834,7 @@ void func_80031C3C(ActorContext* actorCtx, PlayState* play) { } } - ACTOR_DEBUG_PRINTF("絶対魔法領域解放\n"); // "Absolute magic field deallocation" + ACTOR_DEBUG_PRINTF(T("絶対魔法領域解放\n", "Absolute magic field deallocation\n")); if (actorCtx->absoluteSpace != NULL) { ZELDA_ARENA_FREE(actorCtx->absoluteSpace, "../z_actor.c", 6731); @@ -2883,24 +2904,24 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { PRINTF(VT_FGCOL(CYAN)); if (actorOverlay->numLoaded == 0) { - ACTOR_DEBUG_PRINTF("アクタークライアントが0になりました\n"); // "Actor client is now 0" + ACTOR_DEBUG_PRINTF(T("アクタークライアントが0になりました\n", "Actor clients are now 0\n")); if (actorOverlay->loadedRamAddr != NULL) { if (actorOverlay->allocType & ACTOROVL_ALLOC_PERSISTENT) { - ACTOR_DEBUG_PRINTF("オーバーレイ解放しません\n"); // "Overlay will not be deallocated" + ACTOR_DEBUG_PRINTF(T("オーバーレイ解放しません\n", "Overlay will not be deallocated\n")); } else if (actorOverlay->allocType & ACTOROVL_ALLOC_ABSOLUTE) { - // "Absolute magic field reserved, so deallocation will not occur" - ACTOR_DEBUG_PRINTF("絶対魔法領域確保なので解放しません\n"); + ACTOR_DEBUG_PRINTF(T("絶対魔法領域確保なので解放しません\n", + "Absolute magic field reserved, so deallocation will not occur\n")); actorOverlay->loadedRamAddr = NULL; } else { - ACTOR_DEBUG_PRINTF("オーバーレイ解放します\n"); // "Overlay deallocated" + ACTOR_DEBUG_PRINTF(T("オーバーレイ解放します\n", "Overlay deallocated\n")); ZELDA_ARENA_FREE(actorOverlay->loadedRamAddr, "../z_actor.c", 6834); actorOverlay->loadedRamAddr = NULL; } } } else { - // "%d of actor client remains" - ACTOR_DEBUG_PRINTF("アクタークライアントはあと %d 残っています\n", actorOverlay->numLoaded); + ACTOR_DEBUG_PRINTF(T("アクタークライアントはあと %d 残っています\n", "%d of actor client remaining\n"), + actorOverlay->numLoaded); } PRINTF(VT_RST); @@ -2926,32 +2947,31 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; - // "Actor class addition [%d:%s]" - ACTOR_DEBUG_PRINTF("アクタークラス追加 [%d:%s]\n", actorId, name); + ACTOR_DEBUG_PRINTF(T("アクタークラス追加 [%d:%s]\n", "Actor class addition [%d:%s]\n"), actorId, name); if (actorCtx->total > ACTOR_NUMBER_MAX) { - // "Actor set number exceeded" - PRINTF(VT_COL(YELLOW, BLACK) "Actorセット数オーバー\n" VT_RST); + PRINTF(VT_COL(YELLOW, BLACK) T("Actorセット数オーバー\n", "Actor set number exceeded\n") VT_RST); return NULL; } if (overlayEntry->vramStart == NULL) { - ACTOR_DEBUG_PRINTF("オーバーレイではありません\n"); // "Not an overlay" + ACTOR_DEBUG_PRINTF(T("オーバーレイではありません\n", "Not an overlay\n")); profile = overlayEntry->profile; } else { if (overlayEntry->loadedRamAddr != NULL) { - ACTOR_DEBUG_PRINTF("既にロードされています\n"); // "Already loaded" + ACTOR_DEBUG_PRINTF(T("既にロードされています\n", "Already loaded\n")); } else { if (overlayEntry->allocType & ACTOROVL_ALLOC_ABSOLUTE) { ASSERT(overlaySize <= ACTOROVL_ABSOLUTE_SPACE_SIZE, "actor_segsize <= AM_FIELD_SIZE", "../z_actor.c", 6934); if (actorCtx->absoluteSpace == NULL) { - // "AMF: absolute magic field" - actorCtx->absoluteSpace = ZELDA_ARENA_MALLOC_R(ACTOROVL_ABSOLUTE_SPACE_SIZE, "AMF:絶対魔法領域", 0); - // "Absolute magic field reservation - %d bytes reserved" - ACTOR_DEBUG_PRINTF("絶対魔法領域確保 %d バイト確保\n", ACTOROVL_ABSOLUTE_SPACE_SIZE); + actorCtx->absoluteSpace = ZELDA_ARENA_MALLOC_R( + ACTOROVL_ABSOLUTE_SPACE_SIZE, T("AMF:絶対魔法領域", "AMF: absolute magic field"), 0); + ACTOR_DEBUG_PRINTF( + T("絶対魔法領域確保 %d バイト確保\n", "Absolute magic field allocation %d bytes allocated\n"), + ACTOROVL_ABSOLUTE_SPACE_SIZE); } overlayEntry->loadedRamAddr = actorCtx->absoluteSpace; @@ -2962,8 +2982,8 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos } if (overlayEntry->loadedRamAddr == NULL) { - // "Cannot reserve actor program memory" - PRINTF(VT_COL(RED, WHITE) "Actorプログラムメモリが確保できません\n" VT_RST); + PRINTF(VT_COL(RED, WHITE) T("Actorプログラムメモリが確保できません\n", + "Cannot reserve actor program memory\n") VT_RST); return NULL; } @@ -2992,9 +3012,9 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos if ((objectSlot < 0) || ((profile->category == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num))) { - // "No data bank!! (profilep->bank=%d)" - PRINTF(VT_COL(RED, WHITE) "データバンク無し!!<データバンク=%d>(profilep->bank=%d)\n" VT_RST, objectSlot, - profile->objectId); + PRINTF(VT_COL(RED, WHITE) T("データバンク無し!!<データバンク=%d>(profilep->bank=%d)\n", + "No data bank!! (profilep->bank=%d)\n") VT_RST, + objectSlot, profile->objectId); Actor_FreeOverlay(overlayEntry); return NULL; } @@ -3002,9 +3022,9 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos actor = ZELDA_ARENA_MALLOC(profile->instanceSize, name, 1); if (actor == NULL) { - // "Actor class cannot be reserved! %s " - PRINTF(VT_COL(RED, WHITE) "Actorクラス確保できません! %s <サイズ=%dバイト>\n", VT_RST, name, - profile->instanceSize); + PRINTF(VT_COL(RED, WHITE) T("Actorクラス確保できません! %s <サイズ=%dバイト>\n", + "Actor class cannot be reserved! %s \n"), + VT_RST, name, profile->instanceSize); Actor_FreeOverlay(overlayEntry); return NULL; } @@ -3015,8 +3035,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos if (1) {} - // "Actor client No. %d" - ACTOR_DEBUG_PRINTF("アクタークライアントは %d 個目です\n", overlayEntry->numLoaded); + ACTOR_DEBUG_PRINTF(T("アクタークライアントは %d 個目です\n", "Actor client No. %d\n"), overlayEntry->numLoaded); Lib_MemSet((u8*)actor, profile->instanceSize, 0); actor->overlayEntry = overlayEntry; @@ -3079,8 +3098,8 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { u8 numActors; s32 i; - transitionActor = play->transiActorCtx.list; - numActors = play->transiActorCtx.numActors; + transitionActor = play->transitionActors.list; + numActors = play->transitionActors.count; for (i = 0; i < numActors; i++) { if (transitionActor->id >= 0) { @@ -3095,7 +3114,7 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { (i << TRANSITION_ACTOR_PARAMS_INDEX_SHIFT) + transitionActor->params); transitionActor->id = -transitionActor->id; - numActors = play->transiActorCtx.numActors; + numActors = play->transitionActors.count; } } transitionActor++; @@ -3118,7 +3137,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { overlayEntry = actor->overlayEntry; name = overlayEntry->name != NULL ? overlayEntry->name : ""; - ACTOR_DEBUG_PRINTF("アクタークラス削除 [%s]\n", name); // "Actor class deleted [%s]" + ACTOR_DEBUG_PRINTF(T("アクタークラス削除 [%s]\n", "Actor class deleted [%s]\n"), name); if ((player != NULL) && (actor == player->focusActor)) { func_8008EDF0(player); @@ -3145,7 +3164,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { ZELDA_ARENA_FREE(actor, "../z_actor.c", 7242); if (overlayEntry->vramStart == NULL) { - ACTOR_DEBUG_PRINTF("オーバーレイではありません\n"); // "Not an overlay" + ACTOR_DEBUG_PRINTF(T("オーバーレイではありません\n", "Not an overlay\n")); } else { ASSERT(overlayEntry->loadedRamAddr != NULL, "actor_dlftbl->allocp != NULL", "../z_actor.c", 7251); ASSERT(overlayEntry->numLoaded > 0, "actor_dlftbl->clients > 0", "../z_actor.c", 7252); diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index 05e7e8d3f4..6e1fdb97cf 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -98,19 +98,47 @@ void ActorOverlayTable_LogPrint(void) { void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { ActorOverlay* overlayEntry; u32 overlaySize; + uintptr_t ramStart; + uintptr_t ramEnd; + u32 offset; +#if PLATFORM_N64 + uintptr_t pc = gFaultFaultedThread != NULL ? gFaultFaultedThread->context.pc : 0; + uintptr_t ra = gFaultFaultedThread != NULL ? gFaultFaultedThread->context.ra : 0; + u32 i; +#else s32 i; +#endif +#if PLATFORM_N64 + func_800AE1F8(); + + Fault_Printf("actor_dlftbls %u\n", gMaxActorId); + Fault_Printf("No. RamStart-RamEnd Offset\n"); +#else Fault_SetCharPad(-2, 0); Fault_Printf("actor_dlftbls %u\n", gMaxActorId); Fault_Printf("No. RamStart- RamEnd cn Name\n"); +#endif for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; - if (overlayEntry->loadedRamAddr != NULL) { - Fault_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, - (uintptr_t)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, + ramStart = (uintptr_t)overlayEntry->loadedRamAddr; + ramEnd = ramStart + overlaySize; + offset = (uintptr_t)overlayEntry->vramStart - ramStart; + if (ramStart != 0) { +#if PLATFORM_N64 + Fault_Printf("%3d %08x-%08x %08x", i, ramStart, ramEnd, offset); + if (ramStart <= pc && pc < ramEnd) { + Fault_Printf(" PC:%08x", pc + offset); + } else if (ramStart <= ra && ra < ramEnd) { + Fault_Printf(" RA:%08x", ra + offset); + } + Fault_Printf("\n"); +#else + Fault_Printf("%3d %08x-%08x %3d %s\n", i, ramStart, ramEnd, overlayEntry->numLoaded, (OOT_DEBUG && overlayEntry->name != NULL) ? overlayEntry->name : ""); +#endif } } } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index b18f3e226d..f584641b66 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -2318,7 +2318,6 @@ void CollisionCheck_ATQuadVsACCyl(PlayState* play, CollisionCheckContext* colChk static s8 sBssDummy3; static s8 sBssDummy4; static s8 sBssDummy5; -static s8 sBssDummy6; #endif void CollisionCheck_ATTrisVsACTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 3eea3ebc8e..aa0b7c1f67 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -170,7 +170,7 @@ void Regs_UpdateEditor(Input* input) { s32 increment; s32 i; - dPadInputCur = input->cur.button & (BTN_DUP | BTN_DLEFT | BTN_DRIGHT | BTN_DDOWN); + dPadInputCur = input->cur.button & (BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); if (CHECK_BTN_ALL(input->cur.button, BTN_L) || CHECK_BTN_ALL(input->cur.button, BTN_R) || CHECK_BTN_ALL(input->cur.button, BTN_START)) { diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 6cf3ae941e..f46e33a552 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -310,8 +310,8 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { break; case CS_MISC_FADE_KOKIRI_GRASS_ENV_ALPHA: - if (play->roomCtx.unk_74[0] <= 127) { - play->roomCtx.unk_74[0] += 4; + if (play->roomCtx.drawParams[0] <= 127) { + play->roomCtx.drawParams[0] += 4; } break; @@ -324,14 +324,14 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { break; case CS_MISC_DEKU_TREE_DEATH: - if (play->roomCtx.unk_74[0] < 1650) { - play->roomCtx.unk_74[0] += 20; + if (play->roomCtx.drawParams[0] < 1650) { + play->roomCtx.drawParams[0] += 20; } if (csCtx->curFrame == 783) { Sfx_PlaySfxCentered(NA_SE_EV_DEKU_DEATH); } else if (csCtx->curFrame == 717) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; } break; @@ -344,12 +344,12 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { break; case CS_MISC_TRIFORCE_FLASH: - if (play->roomCtx.unk_74[1] == 0) { + if (play->roomCtx.drawParams[1] == 0) { Sfx_PlaySfxCentered(NA_SE_EV_TRIFORCE_FLASH); } - if (play->roomCtx.unk_74[1] < 255) { - play->roomCtx.unk_74[1] += 5; + if (play->roomCtx.drawParams[1] < 255) { + play->roomCtx.drawParams[1] += 5; } break; diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index e0957a0164..212f5ee7df 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -399,7 +399,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* if (vtx == NULL) { PRINTF(T("z_eff_blure.c::SQ_NoInterpolate_disp() 頂点確保できず。\n", "z_eff_blure.c::SQ_NoInterpolate_disp() Vertices cannot be secured.\n")); - goto end; + goto close_disps; } vtx[0].v = baseVtx; @@ -470,7 +470,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* gSPVertex(POLY_XLU_DISP++, vtx, 4, 0); gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 2, 3, 0); -end: +close_disps: CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 932); } diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.c index ba39da6b80..a997caa129 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -174,7 +174,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { if (vertices == NULL) { PRINTF(T("EffectSparkInfo_disp():メモリー確保失敗 graph_malloc\n", "EffectSparkInfo_disp(): Memory Allocation Failure graph_malloc\n")); - goto end; + goto close_disps; } j = 0; @@ -262,7 +262,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp12C); if (mtx == NULL) { - goto end; + goto close_disps; } gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -273,6 +273,6 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { gDPPipeSync(POLY_XLU_DISP++); } -end: +close_disps: CLOSE_DISPS(gfxCtx, "../z_eff_spark.c", 498); } diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c index 2a64a23f4a..3c1adf4cb6 100644 --- a/src/code/z_eff_ss_dead.c +++ b/src/code/z_eff_ss_dead.c @@ -30,7 +30,7 @@ void func_80026400(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { Gfx* displayListHead; f32 cos; -#if PLATFORM_GC +#if !PLATFORM_N64 if (arg3 == 0) { return; } diff --git a/src/code/z_frame_advance.c b/src/code/z_frame_advance.c index 64404fb2f7..486717a50f 100644 --- a/src/code/z_frame_advance.c +++ b/src/code/z_frame_advance.c @@ -2,6 +2,7 @@ #include "stdbool.h" +#include "controller.h" #include "padmgr.h" #include "macros.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 49fcbf4357..6a8026cdb9 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -441,8 +441,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) sLightningBolts[i].state = LIGHTNING_BOLT_INACTIVE; } - play->roomCtx.unk_74[0] = 0; - play->roomCtx.unk_74[1] = 0; + play->roomCtx.drawParams[0] = 0; + play->roomCtx.drawParams[1] = 0; for (i = 0; i < ARRAY_COUNT(play->csCtx.actorCues); i++) { play->csCtx.actorCues[i] = NULL; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 4f4a9a9cd9..e9af22cd5c 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -61,8 +61,8 @@ void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_lights.c", 339); - gSPNumLights(POLY_OPA_DISP++, lights->numLights); - gSPNumLights(POLY_XLU_DISP++, lights->numLights); + gSPNumLights(POLY_OPA_DISP++, (u32)lights->numLights); + gSPNumLights(POLY_XLU_DISP++, (u32)lights->numLights); light = &lights->l.l[0]; i = 0; diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 87cc5cb124..8095daa08c 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -2,6 +2,9 @@ #include "terminal.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/textures/parameter_static/parameter_static.h" +#if PLATFORM_N64 +#include "n64dd.h" +#endif MapData* gMapData; @@ -160,10 +163,22 @@ void Map_InitData(PlayState* play, s16 room) { "Deku Tree Dungeon MAP Texture DMA(%x) scene_id_offset=%d VREG(30)=%d\n"), room, mapIndex, VREG(30)); PRINTF(VT_RST); + +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_28 != NULL) && B_80121220->unk_28(play)) { + } else { + DmaMgr_RequestSync(play->interfaceCtx.mapSegment, + (uintptr_t)_map_i_staticSegmentRomStart + + ((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * MAP_I_TEX_SIZE), + MAP_I_TEX_SIZE); + } +#else DMA_REQUEST_SYNC(play->interfaceCtx.mapSegment, (uintptr_t)_map_i_staticSegmentRomStart + ((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * MAP_I_TEX_SIZE), MAP_I_TEX_SIZE, "../z_map_exp.c", 346); +#endif + R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room]; R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room]; Map_SetFloorPalettesData(play, VREG(30)); @@ -221,6 +236,16 @@ void Map_InitRoomData(PlayState* play, s16 room) { void Map_Destroy(PlayState* play) { MapMark_ClearPointers(play); + +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_24 != NULL)) { + B_80121220->unk_24(); + } + if ((B_80121220 != NULL) && (B_80121220->unk_1C != NULL)) { + B_80121220->unk_1C(&gMapData); + } +#endif + gMapData = NULL; } @@ -230,6 +255,12 @@ void Map_Init(PlayState* play) { gMapData = &gMapDataTable; +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_18 != NULL)) { + B_80121220->unk_18(&gMapData); + } +#endif + interfaceCtx->unk_258 = -1; interfaceCtx->unk_25A = -1; @@ -303,6 +334,11 @@ void Map_Init(PlayState* play) { R_COMPASS_OFFSET_X = gMapData->dgnCompassInfo[mapIndex][2]; R_COMPASS_OFFSET_Y = gMapData->dgnCompassInfo[mapIndex][3]; R_MAP_TEX_INDEX = R_MAP_TEX_INDEX_BASE = gMapData->dgnTexIndexBase[mapIndex]; +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_20 != NULL)) { + B_80121220->unk_20(gMapData); + } +#endif Map_InitRoomData(play, play->roomCtx.curRoom.num); MapMark_Init(play); } diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.c index 4fc7d7cfab..ae654c22d3 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.c @@ -1,6 +1,9 @@ #include "global.h" #include "terminal.h" #include "assets/textures/parameter_static/parameter_static.h" +#if PLATFORM_N64 +#include "n64dd.h" +#endif typedef struct MapMarkInfo { /* 0x00 */ void* texture; @@ -52,9 +55,21 @@ void MapMark_Init(PlayState* play) { ? (void*)((uintptr_t)overlay->vramTable - (intptr_t)((uintptr_t)overlay->vramStart - (uintptr_t)overlay->loadedRamAddr)) : NULL); + +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_2C != NULL)) { + B_80121220->unk_2C(&sLoadedMarkDataTable); + } +#endif } void MapMark_ClearPointers(PlayState* play) { +#if PLATFORM_N64 + if ((B_80121220 != NULL) && (B_80121220->unk_30 != NULL)) { + B_80121220->unk_30(&sLoadedMarkDataTable); + } +#endif + sMapMarkDataOvl.loadedRamAddr = NULL; sLoadedMarkDataTable = NULL; } diff --git a/src/code/z_message.c b/src/code/z_message.c index 566e217649..24a1989ae8 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -10,7 +10,7 @@ #pragma increment_block_number "gc-eu:128 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" -#if PLATFORM_N64 +#if !PLATFORM_GC #define OCARINA_BUTTON_A_PRIM_R 80 #define OCARINA_BUTTON_A_PRIM_G 150 #define OCARINA_BUTTON_A_PRIM_B 255 @@ -465,9 +465,8 @@ void Message_FindMessagePAL(PlayState* play, u16 textId) { nextSeg = messageTableEntry->segment; font->msgOffset = foundSeg - seg; font->msgLength = nextSeg - foundSeg; - // "Message found!!!" - PRINTF(" メッセージが,見つかった!!! = %x " - "(data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", + PRINTF(T(" メッセージが,見つかった!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", + "Message found!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n"), textId, font->msgOffset, font->msgLength, foundSeg, seg, nextSeg); return; } @@ -486,9 +485,8 @@ void Message_FindMessagePAL(PlayState* play, u16 textId) { nextSeg = *languageSegmentTable; font->msgOffset = foundSeg - seg; font->msgLength = nextSeg - foundSeg; - // "Message found!!!" - PRINTF(" メッセージが,見つかった!!! = %x " - "(data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", + PRINTF(T(" メッセージが,見つかった!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", + "Message found!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n"), textId, font->msgOffset, font->msgLength, foundSeg, seg, nextSeg); return; } @@ -496,8 +494,7 @@ void Message_FindMessagePAL(PlayState* play, u16 textId) { languageSegmentTable++; } } - // "Message not found!!!" - PRINTF(" メッセージが,見つからなかった!!! = %x\n", textId); + PRINTF(T(" メッセージが,見つからなかった!!! = %x\n", "Message not found!!! = %x\n"), textId); messageTableEntry = sNesMessageEntryTablePtr; if (gSaveContext.language == LANGUAGE_ENG) { @@ -535,8 +532,8 @@ void Message_FindCreditsMessage(PlayState* play, u16 textId) { nextSeg = messageTableEntry->segment; font->msgOffset = foundSeg - seg; font->msgLength = nextSeg - foundSeg; - // "Message found!!!" - PRINTF(" メッセージが,見つかった!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", + PRINTF(T(" メッセージが,見つかった!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", + "Message found!!! = %x (data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n"), textId, font->msgOffset, font->msgLength, foundSeg, seg, nextSeg); return; } @@ -941,11 +938,11 @@ void Message_HandleOcarina(PlayState* play) { if (msgCtx->ocarinaAction == OCARINA_ACTION_SCARECROW_LONG_RECORDING) { msgCtx->msgMode = MSGMODE_SCARECROW_LONG_RECORDING_START; - // "Recording Start / Recording Start / Recording Start / Recording Start -> " - PRINTF("録音開始 録音開始 録音開始 録音開始 -> "); + PRINTF(T("録音開始 録音開始 録音開始 録音開始 -> ", + "Recording Start Recording Start Recording Start Recording Start -> ")); } else if (msgCtx->ocarinaAction == OCARINA_ACTION_SCARECROW_LONG_PLAYBACK) { - // "Recording Playback / Recording Playback / Recording Playback / Recording Playback -> " - PRINTF("録音再生 録音再生 録音再生 録音再生 -> "); + PRINTF(T("録音再生 録音再生 録音再生 録音再生 -> ", + "Recording Playback Recording Playback Recording Playback Recording Playback -> ")); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); @@ -957,11 +954,10 @@ void Message_HandleOcarina(PlayState* play) { AudioOcarina_SetPlaybackSong(OCARINA_SONG_SCARECROW_LONG + 1, 1); } else if (msgCtx->ocarinaAction == OCARINA_ACTION_SCARECROW_SPAWN_RECORDING) { msgCtx->msgMode = MSGMODE_SCARECROW_SPAWN_RECORDING_START; - // "8 Note Recording Start / 8 Note Recording Start / 8 Note Recording Start -> " - PRINTF("8音録音開始 8音録音開始 8音録音開始 -> "); + PRINTF(T("8音録音開始 8音録音開始 8音録音開始 -> ", + "8 Note Recording Start 8 Note Recording Start 8 Note Recording Start -> ")); } else if (msgCtx->ocarinaAction == OCARINA_ACTION_SCARECROW_SPAWN_PLAYBACK) { - // "8 Note Playback / 8 Note Playback / 8 Note Playback -> " - PRINTF("8音再生 8音再生 8音再生 -> "); + PRINTF(T("8音再生 8音再生 8音再生 -> ", "8 Note Playback 8 Note Playback 8 Note Playback -> ")); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); @@ -973,15 +969,13 @@ void Message_HandleOcarina(PlayState* play) { AudioOcarina_SetPlaybackSong(OCARINA_SONG_SCARECROW_SPAWN + 1, 1); } else if (msgCtx->ocarinaAction == OCARINA_ACTION_MEMORY_GAME) { msgCtx->msgMode = MSGMODE_MEMORY_GAME_START; - // "Musical Round Start / Musical Round Start / Musical Round Start / Musical Round Start -> " - PRINTF("輪唱開始 輪唱開始 輪唱開始 輪唱開始 -> "); + PRINTF(T("輪唱開始 輪唱開始 輪唱開始 輪唱開始 -> ", + "Musical Round Start Musical Round Start Musical Round Start Musical Round Start -> ")); } else if (msgCtx->ocarinaAction == OCARINA_ACTION_FROGS) { msgCtx->msgMode = MSGMODE_FROGS_START; - // "Frog Chorus / Frog Chorus -> " - PRINTF("カエルの合唱 カエルの合唱 -> "); + PRINTF(T("カエルの合唱 カエルの合唱 -> ", "Frog Chorus Frog Chorus -> ")); } else { - // "Ocarina(%d)" - PRINTF("オカリナ(%d) ", msgCtx->ocarinaAction); + PRINTF(T("オカリナ(%d) ", "Ocarina (%d)"), msgCtx->ocarinaAction); if (msgCtx->ocarinaAction == OCARINA_ACTION_UNK_0 || msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY || msgCtx->ocarinaAction >= OCARINA_ACTION_CHECK_SARIA) { msgCtx->msgMode = MSGMODE_OCARINA_STARTING; @@ -1447,20 +1441,18 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { msgCtx->msgMode = MSGMODE_TEXT_DONE; msgCtx->textboxEndType = TEXTBOX_ENDTYPE_FADING; - // "Timer" - PRINTF("タイマー (%x) (%x)", msgCtx->msgBufDecoded[i + 1], msgCtx->msgBufDecoded[i + 2]); + PRINTF(T("タイマー (%x) (%x)", "Timer (%x) (%x)"), msgCtx->msgBufDecoded[i + 1], + msgCtx->msgBufDecoded[i + 2]); msgCtx->stateTimer = msgCtx->msgBufDecoded[++i] << 8; msgCtx->stateTimer |= msgCtx->msgBufDecoded[++i]; - // "Total wct" - PRINTF("合計wct=%x(%d)\n", msgCtx->stateTimer, msgCtx->stateTimer); + PRINTF(T("合計wct=%x(%d)\n", " Total wct=%x(%d)\n"), msgCtx->stateTimer, msgCtx->stateTimer); } *gfxP = gfx; return; case MESSAGE_SFX: if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING && !sMessageHasSetSfx) { sMessageHasSetSfx = true; - // "Sound (SE)" - PRINTF("サウンド(SE)\n"); + PRINTF(T("サウンド(SE)\n", "Sound (SE)\n")); sfxHi = msgCtx->msgBufDecoded[i + 1]; sfxHi <<= 8; Audio_PlaySfxGeneral(sfxHi | msgCtx->msgBufDecoded[i + 2], &gSfxDefaultPos, 4, @@ -1644,16 +1636,14 @@ void Message_LoadItemIcon(PlayState* play, u16 itemId, s16 y) { R_TEXTBOX_ICON_DIMENSION = ITEM_ICON_WIDTH; // assumes the image is square DMA_REQUEST_SYNC(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, GET_ITEM_ICON_VROM(itemId), ITEM_ICON_SIZE, "../z_message_PAL.c", 1473); - // "Item 32-0" - PRINTF("アイテム32-0\n"); + PRINTF(T("アイテム32-0\n", "Item 32-0\n")); } else { R_TEXTBOX_ICON_XPOS = R_TEXT_INIT_XPOS - sIconItem24XOffsets[gSaveContext.language]; R_TEXTBOX_ICON_YPOS = y + ((44 - QUEST_ICON_HEIGHT) / 2); R_TEXTBOX_ICON_DIMENSION = QUEST_ICON_WIDTH; // assumes the image is square DMA_REQUEST_SYNC(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, GET_QUEST_ICON_VROM(itemId), QUEST_ICON_SIZE, "../z_message_PAL.c", 1482); - // "Item 24" - PRINTF("アイテム24=%d (%d) {%d}\n", itemId, itemId - ITEM_KOKIRI_EMERALD, 84); + PRINTF(T("アイテム24=%d (%d) {%d}\n", "Item 24=%d (%d) {%d}\n"), itemId, itemId - ITEM_KOKIRI_EMERALD, 84); } msgCtx->msgBufPos++; msgCtx->choiceNum = 1; @@ -2062,8 +2052,7 @@ void Message_Decode(PlayState* play) { break; } } - // "Name" - PRINTF("\n名前 = "); + PRINTF(T("\n名前 = ", "\nName = ")); for (i = 0; i < playerNameLen; i++) { curChar = gSaveContext.save.info.playerData.playerName[i]; if (curChar == FILENAME_SPACE) { @@ -2094,8 +2083,7 @@ void Message_Decode(PlayState* play) { } else if (curChar == MESSAGE_MARATHON_TIME || curChar == MESSAGE_RACE_TIME) { // Convert the values of the appropriate timer to digits and add the // digits to the decoded buffer in place of the control character. - // "EVENT timer" - PRINTF("\nEVENTタイマー = "); + PRINTF(T("\nEVENTタイマー = ", "\nEVENT timer = ")); digits[0] = digits[1] = digits[2] = 0; if (curChar == MESSAGE_RACE_TIME) { digits[3] = gSaveContext.timerSeconds; @@ -2135,8 +2123,7 @@ void Message_Decode(PlayState* play) { } else if (curChar == MESSAGE_POINTS) { // Convert the values of the current minigame score to digits and // add the digits to the decoded buffer in place of the control character. - // "Yabusame score" - PRINTF("\n流鏑馬スコア = %d\n", gSaveContext.minigameScore); + PRINTF(T("\n流鏑馬スコア = %d\n", "\nYabusame score = %d\n"), gSaveContext.minigameScore); digits[0] = digits[1] = digits[2] = 0; digits[3] = gSaveContext.minigameScore; @@ -2169,8 +2156,8 @@ void Message_Decode(PlayState* play) { } else if (curChar == MESSAGE_TOKENS) { // Convert the current number of collected gold skulltula tokens to digits and // add the digits to the decoded buffer in place of the control character. - // "Total number of gold stars" - PRINTF("\n金スタ合計数 = %d", gSaveContext.save.info.inventory.gsTokens); + PRINTF(T("\n金スタ合計数 = %d", "\nTotal number of gold stars = %d"), + gSaveContext.save.info.inventory.gsTokens); digits[0] = digits[1] = 0; digits[2] = gSaveContext.save.info.inventory.gsTokens; @@ -2198,8 +2185,7 @@ void Message_Decode(PlayState* play) { } decodedBufPos--; } else if (curChar == MESSAGE_FISH_INFO) { - // "Fishing hole fish size" - PRINTF("\n釣り堀魚サイズ = "); + PRINTF(T("\n釣り堀魚サイズ = ", "\nFishing hole fish size = ")); digits[0] = 0; digits[1] = gSaveContext.minigameScore; @@ -2220,8 +2206,7 @@ void Message_Decode(PlayState* play) { decodedBufPos--; } else if (curChar == MESSAGE_HIGHSCORE) { value = HIGH_SCORE((u8)font->msgBuf[++msgCtx->msgBufPos]); - // "Highscore" - PRINTF("ランキング=%d\n", font->msgBuf[msgCtx->msgBufPos]); + PRINTF(T("ランキング=%d\n", "Highscore=%d\n"), font->msgBuf[msgCtx->msgBufPos]); if ((font->msgBuf[msgCtx->msgBufPos] & 0xFF) == 2) { if (LINK_AGE_IN_YEARS == YEARS_CHILD) { value &= 0x7F; @@ -2307,8 +2292,7 @@ void Message_Decode(PlayState* play) { break; } } else if (curChar == MESSAGE_TIME) { - // "Zelda time" - PRINTF("\nゼルダ時間 = "); + PRINTF(T("\nゼルダ時間 = ", "\nZelda time = ")); digits[0] = 0; timeInSeconds = gSaveContext.save.dayTime * (24.0f * 60.0f / 0x10000); @@ -2527,8 +2511,7 @@ void Message_OpenText(PlayState* play, u16 textId) { msgCtx->textBoxType = msgCtx->textBoxProperties >> 4; msgCtx->textBoxPos = msgCtx->textBoxProperties & 0xF; textBoxType = msgCtx->textBoxType; - // "Text Box Type" - PRINTF("吹き出し種類=%d\n", msgCtx->textBoxType); + PRINTF(T("吹き出し種類=%d\n", "Text Box Type = %d\n"), msgCtx->textBoxType); if (textBoxType < TEXTBOX_TYPE_NONE_BOTTOM) { DMA_REQUEST_SYNC(msgCtx->textboxSegment, (uintptr_t)_message_staticSegmentRomStart + @@ -2568,8 +2551,7 @@ void Message_StartTextbox(PlayState* play, u16 textId, Actor* actor) { MessageContext* msgCtx = &play->msgCtx; PRINTF(VT_FGCOL(BLUE)); - // "Message" - PRINTF("めっせーじ=%x(%d)\n", textId, actor); + PRINTF(T("めっせーじ=%x(%d)\n", "Message=%x(%d)\n"), textId, actor); PRINTF(VT_RST); msgCtx->ocarinaAction = 0xFFFF; @@ -2589,8 +2571,7 @@ void Message_ContinueTextbox(PlayState* play, u16 textId) { #endif PRINTF(VT_FGCOL(GREEN)); - // "Message" - PRINTF("めっせーじ=%x message->msg_data\n", textId, msgCtx->msgLength); + PRINTF(T("めっせーじ=%x message->msg_data\n", "Message=%x message->msg_data\n"), textId, msgCtx->msgLength); PRINTF(VT_RST); msgCtx->msgLength = 0; @@ -2652,8 +2633,8 @@ void Message_StartOcarinaImpl(PlayState* play, u16 ocarinaActionId) { Message_ResetOcarinaNoteState(); sLastPlayedSong = msgCtx->unk_E3F2 = msgCtx->lastOcarinaButtonIndex = 0xFF; - // "Ocarina Number" - PRINTF(VT_FGCOL(RED) "☆☆☆☆☆ オカリナ番号=%d(%d) ☆☆☆☆☆\n" VT_RST, ocarinaActionId, 2); + PRINTF(VT_FGCOL(RED) T("☆☆☆☆☆ オカリナ番号=%d(%d) ☆☆☆☆☆\n", "☆☆☆☆☆ Ocarina Number = %d(%d) ☆☆☆☆☆\n") VT_RST, + ocarinaActionId, 2); noStopDoAction = false; if (ocarinaActionId >= 0x893) { Message_OpenText(play, ocarinaActionId); // You played the [song name] @@ -2690,8 +2671,7 @@ void Message_StartOcarinaImpl(PlayState* play, u16 ocarinaActionId) { } } msgCtx->talkActor = NULL; - // "Ocarina Mode" - PRINTF("オカリナモード = %d (%x)\n", msgCtx->ocarinaAction, textId); + PRINTF(T("オカリナモード = %d (%x)\n", "Ocarina Mode = %d (%x)\n"), msgCtx->ocarinaAction, textId); msgCtx->textDelayTimer = 0; play->msgCtx.ocarinaMode = OCARINA_MODE_00; R_TEXTBOX_X = 34; @@ -2714,8 +2694,7 @@ void Message_StartOcarinaImpl(PlayState* play, u16 ocarinaActionId) { Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_B_ALT); gSaveContext.hudVisibilityMode = noStopDoAction; } - // "Music Performance Start" - PRINTF("演奏開始\n"); + PRINTF(T("演奏開始\n", "Music Performance Start\n")); if (ocarinaActionId == OCARINA_ACTION_FREE_PLAY || ocarinaActionId == OCARINA_ACTION_CHECK_NOWARP) { msgCtx->msgMode = MSGMODE_OCARINA_STARTING; msgCtx->textBoxType = 0x63; @@ -2727,8 +2706,8 @@ void Message_StartOcarinaImpl(PlayState* play, u16 ocarinaActionId) { Message_Decode(play); msgCtx->msgMode = MSGMODE_MEMORY_GAME_START; } else if (ocarinaActionId == OCARINA_ACTION_SCARECROW_LONG_PLAYBACK) { - // "?????Recording Playback / Recording Playback / Recording Playback / Recording Playback -> " - PRINTF("?????録音再生 録音再生 録音再生 録音再生 -> "); + PRINTF(T("?????録音再生 録音再生 録音再生 録音再生 -> ", + "????? Recording Playback Recording Playback Recording Playback Recording Playback -> ")); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); @@ -2959,8 +2938,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { msgCtx->ocarinaAction == OCARINA_ACTION_CHECK_NOWARP) { AudioOcarina_Start(sOcarinaSongBitFlags + 0xC000); } else { - // "On Stage Performance" - PRINTF("台上演奏\n"); + PRINTF(T("台上演奏\n", "On Stage Performance\n")); AudioOcarina_Start(sOcarinaSongBitFlags); } } else { @@ -2973,8 +2951,8 @@ void Message_DrawMain(PlayState* play, Gfx** p) { msgCtx->msgMode = MSGMODE_SONG_DEMONSTRATION_SELECT_INSTRUMENT; } else { AudioOcarina_Start((1 << (msgCtx->ocarinaAction - OCARINA_ACTION_PLAYBACK_MINUET)) + 0x8000); - // "Performance Check" - PRINTF("演奏チェック=%d\n", msgCtx->ocarinaAction - OCARINA_ACTION_PLAYBACK_MINUET); + PRINTF(T("演奏チェック=%d\n", "Performance Check = %d\n"), + msgCtx->ocarinaAction - OCARINA_ACTION_PLAYBACK_MINUET); msgCtx->msgMode = MSGMODE_SONG_PLAYBACK; } if (msgCtx->ocarinaAction != OCARINA_ACTION_FREE_PLAY && @@ -3012,8 +2990,9 @@ void Message_DrawMain(PlayState* play, Gfx** p) { &gSfxDefaultReverb); msgCtx->msgMode = MSGMODE_OCARINA_STARTING; } else { - // "Ocarina_Flog Correct Example Performance" - PRINTF("Ocarina_Flog 正解模範演奏=%x\n", msgCtx->lastPlayedSong); + PRINTF(T("Ocarina_Flog 正解模範演奏=%x\n", + "Ocarina_Flog Correct Example Performance = %x\n"), + msgCtx->lastPlayedSong); Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; @@ -3032,8 +3011,9 @@ void Message_DrawMain(PlayState* play, Gfx** p) { msgCtx->stateTimer = 10; msgCtx->msgMode = MSGMODE_OCARINA_FAIL; } else { - // "Ocarina_Flog Correct Example Performance" - PRINTF("Ocarina_Flog 正解模範演奏=%x\n", msgCtx->lastPlayedSong); + PRINTF(T("Ocarina_Flog 正解模範演奏=%x\n", + "Ocarina_Flog Correct Example Performance = %x\n"), + msgCtx->lastPlayedSong); Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; @@ -3044,8 +3024,9 @@ void Message_DrawMain(PlayState* play, Gfx** p) { Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_NOTHING); } } else if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY) { - // "Ocarina_Free Correct Example Performance" - PRINTF("Ocarina_Free 正解模範演奏=%x\n", msgCtx->lastPlayedSong); + PRINTF( + T("Ocarina_Free 正解模範演奏=%x\n", "Ocarina_Free Correct Example Performance = %x\n"), + msgCtx->lastPlayedSong); Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; @@ -3198,8 +3179,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { if (msgCtx->stateTimer == 0) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); if (msgCtx->msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) { - // "Correct Example Performance" - PRINTF("正解模範演奏=%x\n", msgCtx->lastPlayedSong); + PRINTF(T("正解模範演奏=%x\n", "Correct Example Performance = %x\n"), msgCtx->lastPlayedSong); Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; @@ -3230,16 +3210,14 @@ void Message_DrawMain(PlayState* play, Gfx** p) { if (msgCtx->stateTimer == 0) { R_OCARINA_BUTTONS_YPOS_OFFSET = 1; if (msgCtx->msgMode == MSGMODE_SONG_PLAYBACK_FAIL) { - // "kokokokokoko" - PRINTF("ここここここ\n"); + PRINTF(T("ここここここ\n", "Here here here\n")); Message_ContinueTextbox(play, 0x88B); // red X background Message_Decode(play); msgCtx->msgMode = MSGMODE_SONG_PLAYBACK_NOTES_DROP; } else { msgCtx->msgMode = MSGMODE_OCARINA_NOTES_DROP; } - // "Cancel" - PRINTF("キャンセル\n"); + PRINTF(T("キャンセル\n", "Cancel\n")); } break; case MSGMODE_OCARINA_NOTES_DROP: @@ -3306,8 +3284,8 @@ void Message_DrawMain(PlayState* play, Gfx** p) { case MSGMODE_SONG_DEMONSTRATION_SELECT_INSTRUMENT: msgCtx->stateTimer--; if (msgCtx->stateTimer == 0) { - // "ocarina_no=%d Song Chosen=%d" - PRINTF("ocarina_no=%d 選曲=%d\n", msgCtx->ocarinaAction, 0x16); + PRINTF(T("ocarina_no=%d 選曲=%d\n", "ocarina_no=%d Song Chosen=%d\n"), msgCtx->ocarinaAction, + 0x16); if (msgCtx->ocarinaAction < OCARINA_ACTION_TEACH_SARIA) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_HARP); } else if (msgCtx->ocarinaAction == OCARINA_ACTION_TEACH_EPONA) { @@ -3319,8 +3297,8 @@ void Message_DrawMain(PlayState* play, Gfx** p) { } else { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); } - // "Example Performance" - PRINTF("模範演奏=%x\n", msgCtx->ocarinaAction - OCARINA_ACTION_TEACH_MINUET); + PRINTF(T("模範演奏=%x\n", "Example Performance = %x\n"), + msgCtx->ocarinaAction - OCARINA_ACTION_TEACH_MINUET); AudioOcarina_SetPlaybackSong(msgCtx->ocarinaAction - OCARINA_ACTION_TEACH_MINUET + 1, 2); sOcarinaButtonIndexBufPos = 0; msgCtx->msgMode = MSGMODE_SONG_DEMONSTRATION; @@ -3443,8 +3421,8 @@ void Message_DrawMain(PlayState* play, Gfx** p) { msgCtx->msgMode = MSGMODE_SONG_PLAYBACK_SUCCESS; Item_Give(play, ITEM_SONG_MINUET + gOcarinaSongItemMap[msgCtx->ocarinaStaff->state]); PRINTF(VT_FGCOL(YELLOW)); - // "z_message.c Song Acquired" - PRINTF("z_message.c 取得メロディ=%d\n", ITEM_SONG_MINUET + msgCtx->ocarinaStaff->state); + PRINTF(T("z_message.c 取得メロディ=%d\n", "z_message.c Song Acquired = %d\n"), + ITEM_SONG_MINUET + msgCtx->ocarinaStaff->state); PRINTF(VT_RST); msgCtx->stateTimer = 20; Audio_PlaySfxGeneral(NA_SE_SY_TRE_BOX_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3464,8 +3442,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { } break; case MSGMODE_SCARECROW_LONG_RECORDING_START: - // "Scarecrow Recording Initialization" - PRINTF("案山子録音 初期化\n"); + PRINTF(T("案山子録音 初期化\n", "Scarecrow Recording Initialization\n")); AudioOcarina_SetRecordingState(OCARINA_RECORD_SCARECROW_LONG); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetRecordingStaff(); @@ -3486,8 +3463,8 @@ void Message_DrawMain(PlayState* play, Gfx** p) { } sOcarinaButtonIndexBufLen--; } - // "Button Entered" - PRINTF(" 入力ボタン【%d】=%d", sOcarinaButtonIndexBufLen, msgCtx->ocarinaStaff->buttonIndex); + PRINTF(T(" 入力ボタン【%d】=%d", " Button Entered[%d]=%d"), sOcarinaButtonIndexBufLen, + msgCtx->ocarinaStaff->buttonIndex); msgCtx->lastOcarinaButtonIndex = sOcarinaButtonIndexBuf[sOcarinaButtonIndexBufLen] = msgCtx->ocarinaStaff->buttonIndex; sOcarinaButtonIndexBufLen++; @@ -3500,8 +3477,9 @@ void Message_DrawMain(PlayState* play, Gfx** p) { if (msgCtx->ocarinaStaff->state == OCARINA_RECORD_OFF || CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B)) { if (sOcarinaButtonIndexBufLen != 0) { - // "Recording complete!!!!!!!!!" - PRINTF("録音終了!!!!!!!!! message->info->status=%d \n", msgCtx->ocarinaStaff->state); + PRINTF(T("録音終了!!!!!!!!! message->info->status=%d \n", + "Recording complete!!!!!!!!! message->info->status=%d \n"), + msgCtx->ocarinaStaff->state); gSaveContext.save.info.scarecrowLongSongSet = true; } Audio_PlaySfxGeneral(NA_SE_SY_OCARINA_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3511,8 +3489,8 @@ void Message_DrawMain(PlayState* play, Gfx** p) { msgCtx->stateTimer = 10; play->msgCtx.ocarinaMode = OCARINA_MODE_04; Message_CloseTextbox(play); - // "Recording complete!!!!!!!!!Recording Complete" - PRINTF("録音終了!!!!!!!!!録音終了\n"); + PRINTF( + T("録音終了!!!!!!!!!録音終了\n", "Recording complete!!!!!!!!! Recording Complete\n")); PRINTF(VT_FGCOL(YELLOW)); PRINTF("\n====================================================================\n"); MemCpy(gSaveContext.save.info.scarecrowLongSong, gScarecrowLongSongPtr, @@ -3572,8 +3550,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { sOcarinaButtonIndexBuf[sOcarinaButtonIndexBufPos] = OCARINA_BTN_INVALID; } if (msgCtx->ocarinaStaff->state == OCARINA_RECORD_OFF) { - // "8 Note Recording OK!" - PRINTF("8音録音OK!\n"); + PRINTF(T("8音録音OK!\n", "8 Note Recording OK!\n")); msgCtx->stateTimer = 20; gSaveContext.save.info.scarecrowSpawnSongSet = true; msgCtx->msgMode = MSGMODE_SCARECROW_SPAWN_RECORDING_DONE; @@ -3590,8 +3567,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { PRINTF("\n====================================================================\n"); } else if (msgCtx->ocarinaStaff->state == OCARINA_RECORD_REJECTED || CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B)) { - // "Played an existing song!!!" - PRINTF("すでに存在する曲吹いた!!! \n"); + PRINTF(T("すでに存在する曲吹いた!!! \n", "Played an existing song!!! \n")); AudioOcarina_SetRecordingState(OCARINA_RECORD_OFF); Audio_PlaySfxGeneral(NA_SE_SY_OCARINA_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -3664,16 +3640,14 @@ void Message_DrawMain(PlayState* play, Gfx** p) { sOcarinaButtonIndexBufPos++; } if (msgCtx->ocarinaStaff->state == 0xFF) { - // "Musical round failed!!!!!!!!!" - PRINTF("輪唱失敗!!!!!!!!!\n"); + PRINTF(T("輪唱失敗!!!!!!!!!\n", "Musical round failed!!!!!!!!!\n")); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); Audio_PlaySfxGeneral(NA_SE_SY_OCARINA_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); msgCtx->stateTimer = 10; play->msgCtx.ocarinaMode = OCARINA_MODE_03; } else if (msgCtx->ocarinaStaff->state == OCARINA_SONG_MEMORY_GAME) { - // "Musical round succeeded!!!!!!!!!" - PRINTF("輪唱成功!!!!!!!!!\n"); + PRINTF(T("輪唱成功!!!!!!!!!\n", "Musical round succeeded!!!!!!!!!\n")); Audio_PlaySfxGeneral(NA_SE_SY_GET_ITEM, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); msgCtx->msgMode = MSGMODE_MEMORY_GAME_ROUND_SUCCESS; @@ -3979,8 +3953,8 @@ void Message_Update(PlayState* play) { while (entry->textId != 0xFFFD) { if (entry->textId == R_MESSAGE_DEBUGGER_TEXTID) { - // "The message was found! !! !!" - PRINTF(" メッセージが,見つかった!!! = %x\n", R_MESSAGE_DEBUGGER_TEXTID); + PRINTF(T(" メッセージが,見つかった!!! = %x\n", "The message was found!!! = %x\n"), + R_MESSAGE_DEBUGGER_TEXTID); Message_StartTextbox(play, R_MESSAGE_DEBUGGER_TEXTID, NULL); R_MESSAGE_DEBUGGER_TEXTID++; R_MESSAGE_DEBUGGER_SELECT = 0; diff --git a/src/code/z_play.c b/src/code/z_play.c index 4a0309b5fa..99bb024681 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -468,7 +468,8 @@ void Play_Init(GameState* thisx) { Actor_InitContext(this, &this->actorCtx, this->playerEntry); - while (!func_800973FC(this, &this->roomCtx)) { + // Busyloop until the room loads + while (!Room_ProcessRoomRequest(this, &this->roomCtx)) { ; // Empty Loop } @@ -950,7 +951,7 @@ void Play_Update(PlayState* this) { } } else { PLAY_LOG(3606); - func_800973FC(this, &this->roomCtx); + Room_ProcessRoomRequest(this, &this->roomCtx); PLAY_LOG(3612); CollisionCheck_AT(this, &this->colChkCtx); @@ -1524,8 +1525,8 @@ void Play_InitScene(PlayState* this, s32 spawn) { Object_InitContext(this, &this->objectCtx); LightContext_Init(this, &this->lightCtx); - TransitionActor_InitContext(&this->state, &this->transiActorCtx); - func_80096FD4(this, &this->roomCtx.curRoom); + Scene_ResetTransitionActorList(&this->state, &this->transitionActors); + Room_Init(this, &this->roomCtx.curRoom); R_SCENE_CAM_TYPE = SCENE_CAM_TYPE_DEFAULT; gSaveContext.worldMapArea = WORLD_MAP_AREA_HYRULE_FIELD; Scene_ExecuteCommands(this, this->sceneSegment); @@ -1579,7 +1580,7 @@ void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) { } #endif - size = func_80096FE8(this, &this->roomCtx); + size = Room_SetupFirstRoom(this, &this->roomCtx); PRINTF("ROOM SIZE=%fK\n", size / 1024.0f); } @@ -1913,7 +1914,7 @@ s32 func_800C0D34(PlayState* this, Actor* actor, s16* yaw) { return 0; } - transitionActor = &this->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(actor)]; + transitionActor = &this->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(actor)]; frontRoom = transitionActor->sides[0].room; if (frontRoom == transitionActor->sides[1].room) { diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 74cf589e49..d57cf2ed49 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1813,8 +1813,6 @@ void Player_DrawPauseImpl(PlayState* play, void* gameplayKeep, void* linkObject, gSPDisplayList(WORK_DISP++, POLY_OPA_DISP); gSPDisplayList(WORK_DISP++, POLY_XLU_DISP); - { s32 pad[2]; } - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gDPPipeSync(POLY_OPA_DISP++); @@ -1826,7 +1824,14 @@ void Player_DrawPauseImpl(PlayState* play, void* gameplayKeep, void* linkObject, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); + + // Also matches if some of the previous graphics commands are moved inside this block too. Possible macro? + if (1) { + s32 pad[2]; + + gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); + } + gDPSetScissor(POLY_OPA_DISP++, G_SC_NON_INTERLACE, 0, 0, width, height); gSPClipRatio(POLY_OPA_DISP++, FRUSTRATIO_1); diff --git a/src/code/z_room.c b/src/code/z_room.c index 5a88f1c281..e0906de17e 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -536,13 +536,18 @@ void Room_DrawImage(PlayState* play, Room* room, u32 flags) { } } -void func_80096FD4(PlayState* play, Room* room) { +void Room_Init(PlayState* play, Room* room) { room->num = -1; room->segment = NULL; } -u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { - u32 maxRoomSize = 0; +/** + * Allocates memory for rooms and fetches the first room that the player will spawn into. + * + * @return u32 size of the buffer reserved for room data + */ +u32 Room_SetupFirstRoom(PlayState* play, RoomContext* roomCtx) { + u32 roomBufferSize = 0; u32 roomSize; s32 i; s32 j; @@ -553,25 +558,27 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { u32 cumulRoomSize; s32 pad; + // Set roomBufferSize to the largest room { - RomFile* roomList = play->roomList; + RomFile* roomList = play->roomList.romFiles; - for (i = 0; i < play->numRooms; i++) { + for (i = 0; i < play->roomList.count; i++) { roomSize = roomList[i].vromEnd - roomList[i].vromStart; PRINTF("ROOM%d size=%d\n", i, roomSize); - if (maxRoomSize < roomSize) { - maxRoomSize = roomSize; + if (roomBufferSize < roomSize) { + roomBufferSize = roomSize; } } } - if ((u32)play->transiActorCtx.numActors != 0) { - RomFile* roomList = play->roomList; - TransitionActorEntry* transitionActor = &play->transiActorCtx.list[0]; + // If there any rooms are connected, find their combined size and update roomBufferSize if larger + if ((u32)play->transitionActors.count != 0) { + RomFile* roomList = play->roomList.romFiles; + TransitionActorEntry* transitionActor = &play->transitionActors.list[0]; - LOG_NUM("game_play->room_rom_address.num", play->numRooms, "../z_room.c", 912); + LOG_NUM("game_play->room_rom_address.num", play->roomList.count, "../z_room.c", 912); - for (j = 0; j < play->transiActorCtx.numActors; j++) { + for (j = 0; j < play->transitionActors.count; j++) { frontRoom = transitionActor->sides[0].room; backRoom = transitionActor->sides[1].room; frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart; @@ -580,32 +587,52 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { PRINTF("DOOR%d=<%d> ROOM1=<%d, %d> ROOM2=<%d, %d>\n", j, cumulRoomSize, frontRoom, frontRoomSize, backRoom, backRoomSize); - if (maxRoomSize < cumulRoomSize) { - maxRoomSize = cumulRoomSize; + if (roomBufferSize < cumulRoomSize) { + roomBufferSize = cumulRoomSize; } transitionActor++; } } PRINTF(VT_FGCOL(YELLOW)); - PRINTF(T("部屋バッファサイズ=%08x(%5.1fK)\n", "Room buffer size=%08x(%5.1fK)\n"), maxRoomSize, - maxRoomSize / 1024.0f); - roomCtx->bufPtrs[0] = GAME_STATE_ALLOC(&play->state, maxRoomSize, "../z_room.c", 946); + PRINTF(T("部屋バッファサイズ=%08x(%5.1fK)\n", "Room buffer size=%08x(%5.1fK)\n"), roomBufferSize, + roomBufferSize / 1024.0f); + roomCtx->bufPtrs[0] = GAME_STATE_ALLOC(&play->state, roomBufferSize, "../z_room.c", 946); PRINTF(T("部屋バッファ開始ポインタ=%08x\n", "Room buffer initial pointer=%08x\n"), roomCtx->bufPtrs[0]); - roomCtx->bufPtrs[1] = (void*)((uintptr_t)roomCtx->bufPtrs[0] + maxRoomSize); + roomCtx->bufPtrs[1] = (void*)((uintptr_t)roomCtx->bufPtrs[0] + roomBufferSize); PRINTF(T("部屋バッファ終了ポインタ=%08x\n", "Room buffer end pointer=%08x\n"), roomCtx->bufPtrs[1]); PRINTF(VT_RST); - roomCtx->unk_30 = 0; + roomCtx->activeBufPage = 0; roomCtx->status = 0; frontRoom = gSaveContext.respawnFlag > 0 ? ((void)0, gSaveContext.respawn[gSaveContext.respawnFlag - 1].roomIndex) : play->spawnList[play->spawn].room; - func_8009728C(play, roomCtx, frontRoom); - return maxRoomSize; + // Load into a room for the first time. + // Since curRoom was initialized to `room = -1` and `segment = NULL` in Play_InitScene, the previous room + // will also be initialized to the nulled state when this function completes. + Room_RequestNewRoom(play, roomCtx, frontRoom); + + return roomBufferSize; } -s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { +/** + * Tries to create an asynchronous request to transfer room data into memory. + * If successful, the requested room will be loaded into memory and becomes the new current room; the room that was + * current before becomes the previous room. + * + * Room_RequestNewRoom will be blocked from loading new rooms until Room_ProcessRoomRequest completes room + * initialization. + * + * Calling Room_RequestNewRoom outside of Room_SetupFirstRoom will allow for two rooms being initialized simultaneously. + * This allows an actor like ACTOR_EN_HOLL to seamlessly swap the two rooms as the player moves between them. Calling + * Room_FinishRoomChange afterward will finalize the room swap. + * + * @param roomNum is the id of the room to load. roomNum must NOT be the same id as curRoom.num, since this will create + * duplicate actor instances that cannot be cleaned up by calling Room_FinishRoomChange + * @returns bool false if the request could not be created. + */ +s32 Room_RequestNewRoom(PlayState* play, RoomContext* roomCtx, s32 roomNum) { if (roomCtx->status == 0) { u32 size; @@ -614,11 +641,11 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { roomCtx->curRoom.segment = NULL; roomCtx->status = 1; - ASSERT(roomNum < play->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); + ASSERT(roomNum < play->roomList.count, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); - size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; - roomCtx->unk_34 = - (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); + size = play->roomList.romFiles[roomNum].vromEnd - play->roomList.romFiles[roomNum].vromStart; + roomCtx->roomRequestAddr = (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->activeBufPage] - + ((size + 8) * roomCtx->activeBufPage + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); @@ -626,37 +653,44 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { if ((B_80121220 != NULL) && (B_80121220->unk_08 != NULL)) { B_80121220->unk_08(play, roomCtx, roomNum); } else { - DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, - &roomCtx->loadQueue, NULL, "../z_room.c", 1036); + DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->roomRequestAddr, + play->roomList.romFiles[roomNum].vromStart, size, 0, &roomCtx->loadQueue, NULL, + "../z_room.c", 1036); } #else - DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, - &roomCtx->loadQueue, NULL, "../z_room.c", 1036); + DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->roomRequestAddr, play->roomList.romFiles[roomNum].vromStart, + size, 0, &roomCtx->loadQueue, NULL, "../z_room.c", 1036); #endif - roomCtx->unk_30 ^= 1; + roomCtx->activeBufPage ^= 1; return true; } return false; } -s32 func_800973FC(PlayState* play, RoomContext* roomCtx) { +/** + * Completes room initialization for the room requested by a call to Room_RequestNewRoom. + * This function does not block the thread if the room data is still being transferred. + * + * @returns bool false if a dma transfer is in progress. + */ +s32 Room_ProcessRoomRequest(PlayState* play, RoomContext* roomCtx) { if (roomCtx->status == 1) { if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { roomCtx->status = 0; - roomCtx->curRoom.segment = roomCtx->unk_34; - gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); + roomCtx->curRoom.segment = roomCtx->roomRequestAddr; + gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->curRoom.segment); Scene_ExecuteCommands(play, roomCtx->curRoom.segment); Player_SetBootData(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); } else { - return 0; + return false; } } - return 1; + return true; } void Room_Draw(PlayState* play, Room* room, u32 flags) { @@ -668,9 +702,17 @@ void Room_Draw(PlayState* play, Room* room, u32 flags) { } } -void func_80097534(PlayState* play, RoomContext* roomCtx) { +/** + * Finalizes a swap between two rooms. + * + * When a new room is created with Room_RequestNewRoom, the previous room and its actors remain in memory. This allows + * an actor like ACTOR_EN_HOLL to seamlessly swap the two rooms as the player moves between them. + */ +void Room_FinishRoomChange(PlayState* play, RoomContext* roomCtx) { + // Delete the previous room roomCtx->prevRoom.num = -1; roomCtx->prevRoom.segment = NULL; + func_80031B14(play, &play->actorCtx); Actor_SpawnTransitionActors(play, &play->actorCtx); Map_InitRoomData(play, roomCtx->curRoom.num); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 83714b8a4d..f72c06cada 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -230,8 +230,8 @@ BAD_RETURN(s32) Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd) { } BAD_RETURN(s32) Scene_CommandRoomList(PlayState* play, SceneCmd* cmd) { - play->numRooms = cmd->roomList.length; - play->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.data); + play->roomList.count = cmd->roomList.length; + play->roomList.romFiles = SEGMENTED_TO_VIRTUAL(cmd->roomList.data); } BAD_RETURN(s32) Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) { @@ -327,12 +327,12 @@ BAD_RETURN(s32) Scene_CommandPathList(PlayState* play, SceneCmd* cmd) { } BAD_RETURN(s32) Scene_CommandTransitionActorEntryList(PlayState* play, SceneCmd* cmd) { - play->transiActorCtx.numActors = cmd->transiActorList.length; - play->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.data); + play->transitionActors.count = cmd->transiActorList.length; + play->transitionActors.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.data); } -void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) { - transiActorCtx->numActors = 0; +void Scene_ResetTransitionActorList(GameState* state, TransitionActorList* transitionActors) { + transitionActors->count = 0; } BAD_RETURN(s32) Scene_CommandLightSettingsList(PlayState* play, SceneCmd* cmd) { diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 6767993f0c..a2fc170e8e 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -137,7 +137,7 @@ Gfx sDefaultDisplayList[] = { gsSPEndDisplayList(), }; -#if PLATFORM_N64 // Scene_Draw is at end of file in GC versions +#if PLATFORM_N64 // Scene_Draw is at end of file in GC/iQue versions SceneDrawConfigFunc sSceneDrawConfigs[SDC_MAX] = { Scene_DrawConfigDefault, // SDC_DEFAULT @@ -289,12 +289,12 @@ void Scene_DrawConfigDodongosCavern(PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT]); + gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT]); + gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT]); gSPEndDisplayList(displayListHead++); CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4956); @@ -306,7 +306,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5069); - temp = play->roomCtx.unk_74[0] / 255.0f; + temp = play->roomCtx.drawParams[0] / 255.0f; gSPSegment(POLY_XLU_DISP++, 0x08, displayListHead); gSPSegment(POLY_OPA_DISP++, 0x08, displayListHead); @@ -323,7 +323,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x0A, displayListHead); gSPSegment(POLY_XLU_DISP++, 0x0A, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead); @@ -331,7 +331,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { gDPSetPrimColor(displayListHead++, 0, 0, 89 + (u8)(166.0f * temp), 89 + (u8)(166.0f * temp), 89 + (u8)(166.0f * temp), 255); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead); @@ -339,13 +339,13 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { gDPSetPrimColor(displayListHead++, 0, 0, 255 + (u8)(179.0f * temp), 255 + (u8)(179.0f * temp), 255 + (u8)(179.0f * temp), 255); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0D, displayListHead); gSPSegment(POLY_XLU_DISP++, 0x0D, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[1]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[1]); gSPEndDisplayList(displayListHead); CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5145); @@ -539,8 +539,8 @@ void Scene_DrawConfigWaterTemple(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5535); - spB0 = (play->roomCtx.unk_74[1] >> 8) & 0xFF; - spAC = play->roomCtx.unk_74[1] & 0xFF; + spB0 = (play->roomCtx.drawParams[1] >> 8) & 0xFF; + spAC = play->roomCtx.drawParams[1] & 0xFF; gameplayFrames = play->gameplayFrames; #if !OOT_MQ @@ -613,7 +613,7 @@ void Scene_DrawConfigWaterTempleBoss(PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, play->roomCtx.unk_74[0]); + gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, play->roomCtx.drawParams[0]); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 145); @@ -913,7 +913,7 @@ void Scene_DrawConfigFishingPond(PlayState* play) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScrollPrimColor(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 255, 255, - 255, play->roomCtx.unk_74[0] + 127)); + 255, play->roomCtx.drawParams[0] + 127)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1093,16 +1093,16 @@ void Scene_DrawConfigHyruleField(PlayState* play) { gSPEndDisplayList(displayListHead++); } else { if (gSaveContext.save.dayTime > CLOCK_TIME(18, 30)) { - if (play->roomCtx.unk_74[0] != 255) { - Math_StepToS(&play->roomCtx.unk_74[0], 255, 5); + if (play->roomCtx.drawParams[0] != 255) { + Math_StepToS(&play->roomCtx.drawParams[0], 255, 5); } } else if (gSaveContext.save.dayTime >= CLOCK_TIME(6, 0)) { - if (play->roomCtx.unk_74[0] != 0) { - Math_StepToS(&play->roomCtx.unk_74[0], 0, 10); + if (play->roomCtx.drawParams[0] != 0) { + Math_StepToS(&play->roomCtx.drawParams[0], 0, 10); } } - gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.unk_74[0]); + gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.drawParams[0]); gSPDisplayList(displayListHead++, spot00_room_0DL_012B20); gSPEndDisplayList(displayListHead++); } @@ -1187,9 +1187,9 @@ void Scene_DrawConfigKokiriForest(PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); if (gSaveContext.sceneLayer == 4) { - spA3 = 255 - (u8)play->roomCtx.unk_74[0]; + spA3 = 255 - (u8)play->roomCtx.drawParams[0]; } else if (gSaveContext.sceneLayer == 6) { - spA0 = play->roomCtx.unk_74[0] + 500; + spA0 = play->roomCtx.drawParams[0] + 500; } else if ((!IS_CUTSCENE_LAYER || LINK_IS_ADULT) && GET_EVENTCHKINF(EVENTCHKINF_07)) { spA0 = 2150; } @@ -1206,8 +1206,8 @@ void Scene_DrawConfigKokiriForest(PlayState* play) { gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, - Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, (s16)(-play->roomCtx.unk_74[0] * 0.02f), 32, 16, - 1, 0, (s16)(-play->roomCtx.unk_74[0] * 0.02f), 32, 16)); + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, (s16)(-play->roomCtx.drawParams[0] * 0.02f), 32, + 16, 1, 0, (s16)(-play->roomCtx.drawParams[0] * 0.02f), 32, 16)); CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7044); } @@ -1218,16 +1218,16 @@ void Scene_DrawConfigLakeHylia(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7058); if (IS_CUTSCENE_LAYER || (LINK_IS_ADULT && !GET_EVENTCHKINF(EVENTCHKINF_69))) { - play->roomCtx.unk_74[0] = 87; + play->roomCtx.drawParams[0] = 87; } gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, G_TX_RENDERTILE, gameplayFrames, gameplayFrames, 32, 32, 1, - 0, 0, 32, 32, 0, 0, 0, play->roomCtx.unk_74[0] + 168)); + 0, 0, 32, 32, 0, 0, 0, play->roomCtx.drawParams[0] + 168)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, G_TX_RENDERTILE, -gameplayFrames, -gameplayFrames, 32, 32, - 1, 0, 0, 16, 64, 0, 0, 0, play->roomCtx.unk_74[0] + 168)); + 1, 0, 0, 16, 64, 0, 0, 0, play->roomCtx.drawParams[0] + 168)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 128); @@ -1341,12 +1341,12 @@ void Scene_DrawConfigLostWoods(PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - if ((play->roomCtx.unk_74[0] == 0) && (INV_CONTENT(ITEM_COJIRO) == ITEM_COJIRO)) { - if (play->roomCtx.unk_74[1] == 50) { + if ((play->roomCtx.drawParams[0] == 0) && (INV_CONTENT(ITEM_COJIRO) == ITEM_COJIRO)) { + if (play->roomCtx.drawParams[1] == 50) { Player_PlaySfx(GET_PLAYER(play), NA_SE_EV_CHICKEN_CRY_M); - play->roomCtx.unk_74[0] = 1; + play->roomCtx.drawParams[0] = 1; } - play->roomCtx.unk_74[1]++; + play->roomCtx.drawParams[1]++; } CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7309); @@ -1441,16 +1441,16 @@ void Scene_DrawConfigDeathMountainTrail(PlayState* play) { gSPEndDisplayList(displayListHead++); } else { if (gSaveContext.save.dayTime > CLOCK_TIME(18, 0)) { - if (play->roomCtx.unk_74[0] != 255) { - Math_StepToS(&play->roomCtx.unk_74[0], 255, 5); + if (play->roomCtx.drawParams[0] != 255) { + Math_StepToS(&play->roomCtx.drawParams[0], 255, 5); } } else if (gSaveContext.save.dayTime >= CLOCK_TIME(6, 0)) { - if (play->roomCtx.unk_74[0] != 0) { - Math_StepToS(&play->roomCtx.unk_74[0], 0, 10); + if (play->roomCtx.drawParams[0] != 0) { + Math_StepToS(&play->roomCtx.drawParams[0], 0, 10); } } - gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.unk_74[0]); + gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.drawParams[0]); gSPDisplayList(displayListHead++, spot16_room_0DL_00AA48); gSPEndDisplayList(displayListHead++); } @@ -1604,27 +1604,27 @@ void Scene_DrawConfigJabuJabu(PlayState* play) { 1.f + (1 * temp * Math_CosS(D_8012A39C))); View_SetDistortionSpeed(&play->view, 0.95f); - switch (play->roomCtx.unk_74[0]) { + switch (play->roomCtx.drawParams[0]) { case 0: break; case 1: - if (play->roomCtx.unk_74[1] < 1200) { - play->roomCtx.unk_74[1] += 200; + if (play->roomCtx.drawParams[1] < 1200) { + play->roomCtx.drawParams[1] += 200; } else { - play->roomCtx.unk_74[0]++; + play->roomCtx.drawParams[0]++; } break; case 2: - if (play->roomCtx.unk_74[1] > 0) { - play->roomCtx.unk_74[1] -= 30; + if (play->roomCtx.drawParams[1] > 0) { + play->roomCtx.drawParams[1] -= 30; } else { - play->roomCtx.unk_74[1] = 0; - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[1] = 0; + play->roomCtx.drawParams[0] = 0; } break; } - D_8012A398 += 0.15f + (play->roomCtx.unk_74[1] * 0.001f); + D_8012A398 += 0.15f + (play->roomCtx.drawParams[1] * 0.001f); } if (play->roomCtx.curRoom.num == 2) { @@ -1693,7 +1693,7 @@ void Scene_DrawConfigBesitu(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7910); } -#if PLATFORM_GC // Scene_Draw is at beginning of file in N64 versions +#if !PLATFORM_N64 // Scene_Draw is at beginning of file in N64 versions SceneDrawConfigFunc sSceneDrawConfigs[SDC_MAX] = { Scene_DrawConfigDefault, // SDC_DEFAULT diff --git a/src/code/z_vimode.c b/src/code/z_vimode.c index d9478867fb..8abcb62e79 100644 --- a/src/code/z_vimode.c +++ b/src/code/z_vimode.c @@ -85,7 +85,7 @@ void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antia yScaleHiOddField = modeF ? (loResInterlaced ? (F210(0.75) << 16) : (F210(0.5) << 16)) : 0; viMode->customViMode.type = type; - viMode->customViMode.comRegs.ctrl = VI_CTRL_PIXEL_ADV(3) | VI_CTRL_GAMMA_ON | VI_CTRL_GAMMA_DITHER_ON | + viMode->customViMode.comRegs.ctrl = VI_CTRL_PIXEL_ADV_3 | VI_CTRL_GAMMA_ON | VI_CTRL_GAMMA_DITHER_ON | (!loResDeinterlaced ? VI_CTRL_SERRATE_ON : 0) | (antialiasOn ? VI_CTRL_DIVOT_ON : 0) | (fb32Bit ? VI_CTRL_TYPE_32 : VI_CTRL_TYPE_16); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index ca183ce482..d2aac8c1f3 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -69,10 +69,10 @@ s32 Skybox_CalculateFace256(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 roomVtxS s32 k; u16 index; s16 m; + s16 l; s16 ult; s16 uls; s16 vtxIdx; - s16 l; s32 xPoints[9 * 5]; s32 yPoints[9 * 5]; s32 zPoints[9 * 5]; @@ -304,6 +304,8 @@ s32 Skybox_CalculateFace128(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 roomVtxS break; } + if (1) {} + // Select gfx buffer skyboxCtx->gfx = &skyboxCtx->dListBuf[2 * faceNum][0]; diff --git a/src/libleo/api/cacreateleomanager.c b/src/libleo/api/cacreateleomanager.c index 7628f58896..1f2caf6d97 100644 --- a/src/libleo/api/cacreateleomanager.c +++ b/src/libleo/api/cacreateleomanager.c @@ -1,4 +1,5 @@ #include "global.h" +#include "ultra64/asm.h" #include "ultra64/leo.h" #include "ultra64/leoappli.h" #include "ultra64/leodrive.h" @@ -25,7 +26,7 @@ s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) driveRomHandle = osDriveRomInit(); __leoActive = true; - __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, STACK_TOP(leoDiskStack)); + __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, (u8*)STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); leoInitialize(comPri, intPri, cmdBuf, cmdMsgCnt); if (osResetType == 1) { // NMI diff --git a/src/libleo/api/cjcreateleomanager.c b/src/libleo/api/cjcreateleomanager.c index c10e1fd263..e3a5183005 100644 --- a/src/libleo/api/cjcreateleomanager.c +++ b/src/libleo/api/cjcreateleomanager.c @@ -1,4 +1,5 @@ #include "global.h" +#include "ultra64/asm.h" #include "ultra64/leo.h" #include "ultra64/leoappli.h" #include "ultra64/leodrive.h" @@ -25,7 +26,7 @@ s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) driveRomHandle = osDriveRomInit(); __leoActive = true; - __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, STACK_TOP(leoDiskStack)); + __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, (u8*)STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); leoInitialize(comPri, intPri, cmdBuf, cmdMsgCnt); if (osResetType == 1) { // NMI diff --git a/src/libleo/leo/leointerrupt.c b/src/libleo/leo/leointerrupt.c index e11d345080..d9e2175ad3 100644 --- a/src/libleo/leo/leointerrupt.c +++ b/src/libleo/leo/leointerrupt.c @@ -9,7 +9,7 @@ extern OSHWIntr __OSGlobalIntMask; void __osLeoAbnormalResume(void); void __osLeoResume(void); -STACK(leoDiskStack, 0xFF0); +STACK(leoDiskStack, 0x1000); s32 __osLeoInterrupt(void) { u32 stat = 0; diff --git a/src/libultra/io/vimodefpallan1.c b/src/libultra/io/vimodefpallan1.c index 5fb019cdfb..37cb5ff557 100644 --- a/src/libultra/io/vimodefpallan1.c +++ b/src/libultra/io/vimodefpallan1.c @@ -16,15 +16,15 @@ OSViMode osViModeFpalLan1 = { { // comRegs VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | - VI_CTRL_PIXEL_ADV(3), // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs { diff --git a/src/libultra/io/vimodempallan1.c b/src/libultra/io/vimodempallan1.c index 23d53987b0..bcc4273afb 100644 --- a/src/libultra/io/vimodempallan1.c +++ b/src/libultra/io/vimodempallan1.c @@ -16,15 +16,15 @@ OSViMode osViModeMpalLan1 = { { // comRegs VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | - VI_CTRL_PIXEL_ADV(3), // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs { diff --git a/src/libultra/io/vimodentsclan1.c b/src/libultra/io/vimodentsclan1.c index 19a7160ac8..a29d15129f 100644 --- a/src/libultra/io/vimodentsclan1.c +++ b/src/libultra/io/vimodentsclan1.c @@ -16,15 +16,15 @@ OSViMode osViModeNtscLan1 = { { // comRegs VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | - VI_CTRL_PIXEL_ADV(3), // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs { diff --git a/src/libultra/io/vimodepallan1.c b/src/libultra/io/vimodepallan1.c index 7a8db603f4..d656dc4f94 100644 --- a/src/libultra/io/vimodepallan1.c +++ b/src/libultra/io/vimodepallan1.c @@ -16,15 +16,15 @@ OSViMode osViModePalLan1 = { { // comRegs VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | - VI_CTRL_PIXEL_ADV(3), // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs { diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index b1ec6987ac..48b2a6c4d5 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -287,7 +287,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } } else if (CHECK_BTN_ANY(play->state.input[0].press.button, - (BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN))) { + (BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT))) { this->timer = 0; } } diff --git a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c index 419f214972..0c1b1b564e 100644 --- a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c +++ b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c @@ -121,7 +121,7 @@ void BgDodoago_Init(Actor* thisx, PlayState* play) { if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { BgDodoago_SetupAction(this, BgDodoago_DoNothing); this->dyna.actor.shape.rot.x = 0x1333; - play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] = play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] = 255; + play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] = play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] = 255; return; } @@ -154,15 +154,15 @@ void BgDodoago_WaitExplosives(BgDodoago* this, PlayState* play) { ? BGDODOAGO_EYE_RIGHT : BGDODOAGO_EYE_LEFT; - if (((play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] == 255) && (this->state == BGDODOAGO_EYE_RIGHT)) || - ((play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] == 255) && (this->state == BGDODOAGO_EYE_LEFT))) { + if (((play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] == 255) && (this->state == BGDODOAGO_EYE_RIGHT)) || + ((play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] == 255) && (this->state == BGDODOAGO_EYE_LEFT))) { Flags_SetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); this->state = 0; Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); BgDodoago_SetupAction(this, BgDodoago_OpenJaw); OnePointCutscene_Init(play, 3380, 160, &this->dyna.actor, CAM_ID_MAIN); - } else if (play->roomCtx.unk_74[this->state] == 0) { + } else if (play->roomCtx.drawParams[this->state] == 0) { OnePointCutscene_Init(play, 3065, 40, &this->dyna.actor, CAM_ID_MAIN); BgDodoago_SetupAction(this, BgDodoago_LightOneEye); Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -212,14 +212,14 @@ void BgDodoago_OpenJaw(BgDodoago* this, PlayState* play) { s32 i; // make both eyes red (one already is) - if (play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] < 255) { - play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] += 5; + if (play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] < 255) { + play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] += 5; } - if (play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] < 255) { - play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] += 5; + if (play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] < 255) { + play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] += 5; } - if (play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] != 255 || play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] != 255) { + if (play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] != 255 || play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] != 255) { sTimer--; return; } @@ -260,9 +260,9 @@ void BgDodoago_DoNothing(BgDodoago* this, PlayState* play) { } void BgDodoago_LightOneEye(BgDodoago* this, PlayState* play) { - play->roomCtx.unk_74[this->state] += 5; + play->roomCtx.drawParams[this->state] += 5; - if (play->roomCtx.unk_74[this->state] == 255) { + if (play->roomCtx.drawParams[this->state] == 255) { BgDodoago_SetupAction(this, BgDodoago_WaitExplosives); } } diff --git a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c index e6f353eacf..141a4617bd 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c @@ -238,7 +238,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 5.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; Message_CloseTextbox(play); } @@ -253,7 +253,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { this->targetY = this->baseY; } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; } waterBoxes[6].ySurface = this->actor.world.pos.y; @@ -265,7 +265,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { this->targetY = this->baseY; } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; } waterBoxes[8].ySurface = this->actor.world.pos.y; @@ -277,7 +277,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { this->targetY = this->baseY; } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; } waterBoxes[16].ySurface = this->actor.world.pos.y; @@ -323,7 +323,7 @@ void BgMizuWater_Update(Actor* thisx, PlayState* play) { unk1 = 255 - (s32)((posY - WATER_TEMPLE_WATER_F2_Y) / (WATER_TEMPLE_WATER_F3_Y - WATER_TEMPLE_WATER_F2_Y) * (255 - 160)); } - play->roomCtx.unk_74[1] = ((u8)unk0 << 8) | (unk1 & 0xFF); + play->roomCtx.drawParams[1] = ((u8)unk0 << 8) | (unk1 & 0xFF); } this->actionFunc(this, play); diff --git a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c index 61cd9da383..61a3603baa 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c +++ b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c @@ -105,7 +105,7 @@ void func_808BA018(Actor* thisx, PlayState* play) { } void func_808BA204(BgTokiHikari* this, PlayState* play) { - if (play->roomCtx.unk_74[1] != 0) { + if (play->roomCtx.drawParams[1] != 0) { this->actionFunc = func_808BA22C; } } diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 2a689189c9..e4106619a6 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -77,7 +77,7 @@ void BgTokiSwd_Init(Actor* thisx, PlayState* play) { } if (gSaveContext.sceneLayer == 5) { - play->roomCtx.unk_74[0] = 0xFF; + play->roomCtx.drawParams[0] = 0xFF; } Collider_InitCylinder(play, &this->collider); @@ -119,10 +119,10 @@ void func_808BAF40(BgTokiSwd* this, PlayState* play) { } } if (gSaveContext.sceneLayer == 5) { - if (play->roomCtx.unk_74[0] > 0) { - play->roomCtx.unk_74[0]--; + if (play->roomCtx.drawParams[0] > 0) { + play->roomCtx.drawParams[0]--; } else { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; } } } @@ -146,8 +146,8 @@ void func_808BB0AC(BgTokiSwd* this, PlayState* play) { } void func_808BB128(BgTokiSwd* this, PlayState* play) { - if (CutsceneFlags_Get(play, 1) && (play->roomCtx.unk_74[0] < 0xFF)) { - play->roomCtx.unk_74[0] += 5; + if (CutsceneFlags_Get(play, 1) && (play->roomCtx.drawParams[0] < 0xFF)) { + play->roomCtx.drawParams[0] += 5; } } diff --git a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c index d1748fafc0..4edc3a4e3c 100644 --- a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c +++ b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c @@ -241,7 +241,7 @@ void BgTreemouth_Draw(Actor* thisx, PlayState* play) { } if (gSaveContext.sceneLayer == 6) { - alpha = (play->roomCtx.unk_74[0] + 0x1F4); + alpha = (play->roomCtx.drawParams[0] + 0x1F4); } gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, alpha * 0.1f); diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 1eb8e5496a..cf483fddfb 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -337,7 +337,7 @@ void BossMo_Init(Actor* thisx, PlayState* play2) { Flags_SetSwitch(play, 0x14); sMorphaCore = this; MO_WATER_LEVEL(play) = this->waterLevel = MO_WATER_LEVEL(play); - play->roomCtx.unk_74[0] = 0xA0; + play->roomCtx.drawParams[0] = 0xA0; play->specialEffects = sEffects; for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++) { sEffects[i].type = MO_FX_NONE; @@ -357,7 +357,7 @@ void BossMo_Init(Actor* thisx, PlayState* play2) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, -280.0f, 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, -200.0f, -280.0f, 0.0f, 0, 0, 0, 0); - play->roomCtx.unk_74[0] = 0xFF; + play->roomCtx.drawParams[0] = 0xFF; MO_WATER_LEVEL(play) = -500; return; } @@ -1711,9 +1711,9 @@ void BossMo_DeathCs(BossMo* this, PlayState* play) { } } if (sMorphaCore->waterLevel < -200.0f) { - play->roomCtx.unk_74[0]++; - if (play->roomCtx.unk_74[0] >= 0xFF) { - play->roomCtx.unk_74[0] = 0xFF; + play->roomCtx.drawParams[0]++; + if (play->roomCtx.drawParams[0] >= 0xFF) { + play->roomCtx.drawParams[0] = 0xFF; } } if (sMorphaCore->waterLevel < -250.0f) { @@ -2261,7 +2261,7 @@ void BossMo_UpdateCore(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_0; } -#if PLATFORM_GC +#if !PLATFORM_N64 BossMo_SfxTest(); #endif } @@ -3051,7 +3051,7 @@ void BossMo_DrawEffects(BossMoEffect* effect, PlayState* play) { CLOSE_DISPS(gfxCtx, "../z_boss_mo.c", 7482); } -#if PLATFORM_GC +#if !PLATFORM_N64 void BossMo_SfxTest(void) { // Appears to be a test function for sound effects. static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index e2e78726ba..66f3b7dc4f 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -3411,45 +3411,48 @@ void func_80942C70(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_boss_tw.c", 6765); - if (this->beamDist != 0.0f) { - Matrix_Push(); - gSPSegment(POLY_XLU_DISP++, 0xC, - Gfx_TexScroll(play->state.gfxCtx, 0, (u8)(this->work[CS_TIMER_1] * -0xF), 0x20, 0x40)); - alpha = this->beamScale * 100.0f * 255.0f; - - if (this->actor.params == TW_KOUME) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 60, alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); - } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 100, 100, 255, 128); - } - - Matrix_Translate(this->beamOrigin.x, this->beamOrigin.y, this->beamOrigin.z, MTXMODE_NEW); - Matrix_RotateY(this->beamYaw, MTXMODE_APPLY); - Matrix_RotateX(this->beamPitch, MTXMODE_APPLY); - Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY); - Matrix_Scale(this->beamScale, this->beamScale, (this->beamDist * 0.01f * 98.0f) / 20000.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6846), - G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL)); - - if (this->beamReflectionDist > 10.0f) { - Matrix_Translate(this->beamReflectionOrigin.x, this->beamReflectionOrigin.y, this->beamReflectionOrigin.z, - MTXMODE_NEW); - Matrix_RotateY(this->beamReflectionYaw, MTXMODE_APPLY); - Matrix_RotateX(this->beamReflectionPitch, MTXMODE_APPLY); - Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY); - Matrix_Scale(this->beamScale, this->beamScale, (this->beamReflectionDist * 0.01f * 100.0f) / 20000.0f, - MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6870), - G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); - gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL)); - } - - Matrix_Pop(); + if (this->beamDist == 0.0f) { + goto close_disps; } + Matrix_Push(); + gSPSegment(POLY_XLU_DISP++, 0xC, + Gfx_TexScroll(play->state.gfxCtx, 0, (u8)(this->work[CS_TIMER_1] * -0xF), 0x20, 0x40)); + alpha = this->beamScale * 100.0f * 255.0f; + + if (this->actor.params == TW_KOUME) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 60, alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 100, 255, 128); + } + + Matrix_Translate(this->beamOrigin.x, this->beamOrigin.y, this->beamOrigin.z, MTXMODE_NEW); + Matrix_RotateY(this->beamYaw, MTXMODE_APPLY); + Matrix_RotateX(this->beamPitch, MTXMODE_APPLY); + Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY); + Matrix_Scale(this->beamScale, this->beamScale, (this->beamDist * 0.01f * 98.0f) / 20000.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6846), + G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL)); + + if (this->beamReflectionDist > 10.0f) { + Matrix_Translate(this->beamReflectionOrigin.x, this->beamReflectionOrigin.y, this->beamReflectionOrigin.z, + MTXMODE_NEW); + Matrix_RotateY(this->beamReflectionYaw, MTXMODE_APPLY); + Matrix_RotateX(this->beamReflectionPitch, MTXMODE_APPLY); + Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY); + Matrix_Scale(this->beamScale, this->beamScale, (this->beamReflectionDist * 0.01f * 100.0f) / 20000.0f, + MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6870), + G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); + gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL)); + } + + Matrix_Pop(); + +close_disps: CLOSE_DISPS(play->state.gfxCtx, "../z_boss_tw.c", 6878); } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index cd106c8519..16d4fa28c9 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -236,7 +236,7 @@ void DemoKankyo_Init(Actor* thisx, PlayState* play) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_TOKI, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x0000); } else { - play->roomCtx.unk_74[1] = 0xFF; + play->roomCtx.drawParams[1] = 0xFF; Actor_Kill(&this->actor); } break; diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 7a5298ebd6..64be9c8321 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -350,7 +350,7 @@ void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc * @return true if the door is barred */ s32 DoorShutter_SetupDoor(DoorShutter* this, PlayState* play) { - TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; + TransitionActorEntry* transitionEntry = &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; s8 frontRoom = transitionEntry->sides[0].room; s32 doorType = this->doorType; DoorShutterStyleInfo* styleInfo = &sStyleInfo[this->styleType]; @@ -462,7 +462,7 @@ void DoorShutter_Destroy(Actor* thisx, PlayState* play) { if (this->dyna.actor.room >= 0) { s32 transitionActorId = GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor); - play->transiActorCtx.list[transitionActorId].id *= -1; + play->transitionActors.list[transitionActorId].id *= -1; } } @@ -801,7 +801,7 @@ void DoorShutter_SetupClosed(DoorShutter* this, PlayState* play) { Vec3f relPlayerPos; Actor_WorldToActorCoords(&this->dyna.actor, &relPlayerPos, &player->actor.world.pos); - this->dyna.actor.room = play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)] + this->dyna.actor.room = play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)] .sides[(relPlayerPos.z < 0.0f) ? 0 : 1] .room; if (room != this->dyna.actor.room) { @@ -809,9 +809,9 @@ void DoorShutter_SetupClosed(DoorShutter* this, PlayState* play) { play->roomCtx.curRoom = play->roomCtx.prevRoom; play->roomCtx.prevRoom = tempRoom; - play->roomCtx.unk_30 ^= 1; + play->roomCtx.activeBufPage ^= 1; } - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); Play_SetupRespawnPoint(play, RESPAWN_MODE_DOWN, 0x0EFF); } this->isActive = false; @@ -1012,7 +1012,7 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) { } else { if (gfxInfo->barsDL != NULL) { TransitionActorEntry* transitionEntry = - &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; + &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; if (play->roomCtx.prevRoom.num >= 0 || transitionEntry->sides[0].room == transitionEntry->sides[1].room) { diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 0dca15d850..590337ed70 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -166,7 +166,7 @@ void EnDoor_Destroy(Actor* thisx, PlayState* play) { TransitionActorEntry* transitionEntry; EnDoor* this = (EnDoor*)thisx; - transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; + transitionEntry = &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; if (transitionEntry->id < 0) { transitionEntry->id = -transitionEntry->id; } @@ -334,7 +334,7 @@ s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* TransitionActorEntry* transitionEntry; Gfx** doorDLists = sDoorDLists[this->dListIndex]; - transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; + transitionEntry = &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; rot->z += this->actor.world.rot.y; if ((play->roomCtx.prevRoom.num >= 0) || (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { // Draw the side of the door that is visible to the camera diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index bc5d25a168..9b6619730a 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -133,7 +133,7 @@ void EnHoll_Init(Actor* thisx, PlayState* play) { void EnHoll_Destroy(Actor* thisx, PlayState* play) { s32 transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(thisx); - TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[transitionActorIndex]; + TransitionActorEntry* transitionEntry = &play->transitionActors.list[transitionActorIndex]; transitionEntry->id = -transitionEntry->id; } @@ -145,7 +145,7 @@ void EnHoll_SwapRooms(PlayState* play) { tempRoom = roomCtx->curRoom; roomCtx->curRoom = roomCtx->prevRoom; roomCtx->prevRoom = tempRoom; - play->roomCtx.unk_30 ^= 1; + play->roomCtx.activeBufPage ^= 1; } /** @@ -196,14 +196,14 @@ void EnHoll_HorizontalVisibleNarrow(EnHoll* this, PlayState* play) { transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); if (orthogonalDistToPlayer > sHorizontalVisibleNarrowTriggerDists[triggerDistsIndex][1]) { if (play->roomCtx.prevRoom.num >= 0 && play->roomCtx.status == 0) { - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[this->side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[this->side].room; EnHoll_SwapRooms(play); - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); } } else { - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[this->side ^ 1].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[this->side ^ 1].room; if (play->roomCtx.prevRoom.num < 0) { - func_8009728C(play, &play->roomCtx, this->actor.room); + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room); } else { this->planeAlpha = (255.0f / (sHorizontalVisibleNarrowTriggerDists[triggerDistsIndex][2] - @@ -239,14 +239,14 @@ void EnHoll_HorizontalInvisible(EnHoll* this, PlayState* play) { orthogonalDistToSubject > ENHOLL_H_INVISIBLE_LOAD_DEPTH_MIN))) { s32 transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); s32 side = (relSubjectPos.z < 0.0f) ? 0 : 1; - TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[transitionActorIndex]; + TransitionActorEntry* transitionEntry = &play->transitionActors.list[transitionActorIndex]; s32 room = transitionEntry->sides[side].room; this->actor.room = room; if (isKokiriLayer8) {} if (this->actor.room != play->roomCtx.curRoom.num) { if (room) {} - if (func_8009728C(play, &play->roomCtx, this->actor.room)) { + if (Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); } } @@ -273,11 +273,11 @@ void EnHoll_VerticalDownBgCoverLarge(EnHoll* this, PlayState* play) { } if (absYDistToPlayer < ENHOLL_V_DOWN_LOAD_YDIST) { - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[1].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[1].room; Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 1.0f, 50.0f, 10.0f); Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 1.0f, 50.0f, 10.0f); if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); this->resetBgCoverAlpha = true; player->actor.speed = 0.0f; @@ -308,9 +308,9 @@ void EnHoll_VerticalBgCover(EnHoll* this, PlayState* play) { s32 transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); s32 side = (this->actor.yDistToPlayer > 0.0f) ? 0 : 1; - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[side].room; if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); this->resetBgCoverAlpha = true; } @@ -334,9 +334,9 @@ void EnHoll_VerticalInvisible(EnHoll* this, PlayState* play) { absYDistToPlayer > ENHOLL_V_INVISIBLE_LOAD_YDIST_MIN) { transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); side = (this->actor.yDistToPlayer > 0.0f) ? 0 : 1; - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[side].room; if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); } } @@ -375,9 +375,9 @@ void EnHoll_HorizontalBgCoverSwitchFlag(EnHoll* this, PlayState* play) { if (orthogonalDistToPlayer < ENHOLL_H_SWITCHFLAG_LOAD_DEPTH) { s32 side = (relPlayerPos.z < 0.0f) ? 0 : 1; - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[side].room; if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); } } @@ -392,7 +392,7 @@ void EnHoll_HorizontalBgCoverSwitchFlag(EnHoll* this, PlayState* play) { void EnHoll_WaitRoomLoaded(EnHoll* this, PlayState* play) { if (!EnHoll_IsKokiriLayer8() && play->roomCtx.status == 0) { - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); if (play->bgCoverAlpha == 0) { this->resetBgCoverAlpha = false; } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 1cdad1e81c..fcf7aec8a6 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -151,8 +151,8 @@ void EnMag_CheckSramResetCode(PlayState* play, EnMag* this) { s32 var_v1; var_v1 = - play->state.input[2].cur.button & (BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_R | BTN_L | BTN_DRIGHT | - BTN_DLEFT | BTN_DDOWN | BTN_DUP | BTN_START | BTN_Z | BTN_B | BTN_A); + play->state.input[2].cur.button & (BTN_A | BTN_B | BTN_Z | BTN_START | BTN_DUP | BTN_DDOWN | BTN_DLEFT | + BTN_DRIGHT | BTN_L | BTN_R | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT); if (this->unk_E31C == var_v1) { this->unk_E320--; if (this->unk_E320 < 0) { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index ff77304215..a0cecf0478 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -16,7 +16,7 @@ #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4) -#if PLATFORM_N64 +#if !PLATFORM_GC #define CURSOR_COLOR_R 0 #define CURSOR_COLOR_G 80 #define CURSOR_COLOR_B 255 diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 1ab4258a3f..f4978efb0d 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -14,7 +14,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:148 gc-eu-mq:148 gc-jp:150 gc-jp-ce:150 gc-jp-mq:150 gc-us:150 gc-us-mq:150" +#pragma increment_block_number "gc-eu:141 gc-eu-mq:141 gc-jp:143 gc-jp-ce:143 gc-jp-mq:143 gc-us:143 gc-us-mq:143" #define FLAGS ACTOR_FLAG_4 @@ -920,10 +920,10 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { sFishGameNumber = (HIGH_SCORE(HS_FISHING) & (HS_FISH_PLAYED * 255)) >> 0x10; if ((sFishGameNumber & 7) == 7) { - play->roomCtx.unk_74[0] = 90; + play->roomCtx.drawParams[0] = 90; sFishingFoggy = 1; } else { - play->roomCtx.unk_74[0] = 40; + play->roomCtx.drawParams[0] = 40; sFishingFoggy = 0; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index c0a7022614..77e881b4d0 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -366,7 +366,7 @@ static s32 D_80858AA4; static Vec3f sInteractWallCheckResult; static Input* sControlInput; -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" +#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" // .data @@ -2789,7 +2789,7 @@ int func_80834E44(PlayState* play) { int func_80834E7C(PlayState* play) { return (play->shootingGalleryStatus != 0) && ((play->shootingGalleryStatus < 0) || - CHECK_BTN_ANY(sControlInput->cur.button, BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)); + CHECK_BTN_ANY(sControlInput->cur.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)); } s32 func_80834EB8(Player* this, PlayState* play) { @@ -3540,7 +3540,7 @@ s32 func_80836AB8(Player* this, s32 arg1) { // Update things related to Z Targeting void func_80836BEC(Player* this, PlayState* play) { - s32 sp1C = 0; + s32 ignoreLeash = false; s32 zTrigPressed = CHECK_BTN_ALL(sControlInput->cur.button, BTN_Z); Actor* actorToTarget; s32 pad; @@ -3567,7 +3567,7 @@ void func_80836BEC(Player* this, PlayState* play) { } if (this->unk_66C >= 6) { - sp1C = 1; + ignoreLeash = true; } cond = func_8083224C(play); @@ -3614,7 +3614,7 @@ void func_80836BEC(Player* this, PlayState* play) { if (this->focusActor != NULL) { if ((this->actor.category == ACTORCAT_PLAYER) && (this->focusActor != this->unk_684) && - func_8002F0C8(this->focusActor, this, sp1C)) { + Target_ShouldReleaseLockOn(this->focusActor, this, ignoreLeash)) { func_8008EDF0(this); this->stateFlags1 |= PLAYER_STATE1_30; } else if (this->focusActor != NULL) { @@ -5008,7 +5008,7 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) { if (slidingDoor->dyna.actor.category == ACTORCAT_DOOR) { this->cv.slidingDoorBgCamIndex = - play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&slidingDoor->dyna.actor)] + play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&slidingDoor->dyna.actor)] .sides[(doorDirection > 0) ? 0 : 1] .bgCamIndex; @@ -5091,7 +5091,7 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) { } } else { Camera_ChangeDoorCam(Play_GetCamera(play, CAM_ID_MAIN), doorActor, - play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] + play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] .sides[(doorDirection > 0) ? 0 : 1] .bgCamIndex, 0, 38.0f * D_808535EC, 26.0f * D_808535EC, 10.0f * D_808535EC); @@ -5100,12 +5100,12 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) { } if ((this->doorType != PLAYER_DOORTYPE_FAKE) && (doorActor->category == ACTORCAT_DOOR)) { - frontRoom = play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] + frontRoom = play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] .sides[(doorDirection > 0) ? 0 : 1] .room; if ((frontRoom >= 0) && (frontRoom != play->roomCtx.curRoom.num)) { - func_8009728C(play, &play->roomCtx, frontRoom); + Room_RequestNewRoom(play, &play->roomCtx, frontRoom); } } @@ -6957,7 +6957,7 @@ s32 func_8083EAF0(Player* this, Actor* actor) { s32 Player_ActionChange_9(Player* this, PlayState* play) { if ((this->stateFlags1 & PLAYER_STATE1_11) && (this->heldActor != NULL) && - CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { if (!func_80835644(play, this, this->heldActor)) { if (!func_8083EAF0(this, this->heldActor)) { Player_SetupAction(play, this, Player_Action_808464B0, 1); @@ -8999,7 +8999,7 @@ void Player_Action_8084411C(Player* this, PlayState* play) { heldActor = this->heldActor; if (!func_80835644(play, this, heldActor) && (heldActor->id == ACTOR_EN_NIW) && - CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { func_8084409C(play, this, this->speedXZ + 2.0f, this->actor.velocity.y + 2.0f); } } @@ -9703,7 +9703,7 @@ void Player_Action_80845EF8(Player* this, PlayState* play) { } else { func_8083C0E8(this, play); if (play->roomCtx.prevRoom.num >= 0) { - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); } Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); Play_SetupRespawnPoint(play, RESPAWN_MODE_DOWN, 0xDFF); @@ -9785,7 +9785,7 @@ void Player_Action_80846260(Player* this, PlayState* play) { } else if (LinkAnimation_OnFrame(&this->skelAnime, 25.0f)) { Player_PlayVoiceSfx(this, NA_SE_VO_LI_SWORD_L); } - } else if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + } else if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { Player_SetupAction(play, this, Player_Action_80846358, 1); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_silver_throw); } @@ -11866,7 +11866,7 @@ void Player_Action_8084B1D8(Player* this, PlayState* play) { func_80833B2C(this) || (!func_8002DD78(this) && !func_808334B4(this)))) || ((this->unk_6AD == 1) && CHECK_BTN_ANY(sControlInput->press.button, - BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)))) { + BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)))) { func_8083C148(this, play); Sfx_PlaySfxCentered(NA_SE_SY_CAMERA_ZOOM_UP); } else if ((DECR(this->av2.actionVar2) == 0) || (this->unk_6AD != 2)) { @@ -13816,7 +13816,7 @@ void Player_Action_8084FBF4(Player* this, PlayState* play) { s32 Player_UpdateNoclip(Player* this, PlayState* play) { sControlInput = &play->state.input[0]; - if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_L | BTN_R | BTN_A) && + if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_A | BTN_L | BTN_R) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B)) || (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) { @@ -13845,7 +13845,7 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) { this->actor.world.pos.y -= speed; } - if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP | BTN_DLEFT | BTN_DDOWN | BTN_DRIGHT)) { + if (CHECK_BTN_ANY(sControlInput->cur.button, BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT)) { s16 angle; s16 temp; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index edeba3484a..2e9364ac80 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -3,6 +3,9 @@ #include "versions.h" #include "assets/textures/title_static/title_static.h" #include "assets/textures/parameter_static/parameter_static.h" +#if PLATFORM_N64 +#include "n64dd.h" +#endif static s16 sUnused = 106; @@ -219,6 +222,14 @@ void FileSelect_UpdateMainMenu(GameState* thisx) { } else if (!this->n64ddFlags[this->buttonIndex]) { Audio_PlaySfxGeneral(NA_SE_SY_FSEL_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } else { +#if PLATFORM_N64 + if (D_80121212 != 0) { + func_801C7268(); + // Setting ioData to 1 and writing it to ioPort 7 will skip the harp intro + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); + } +#endif } } else { if (this->warningLabel == FS_WARNING_NONE) { @@ -824,14 +835,13 @@ static s16 sHeartEnvColors[2][3] = { { 50, 40, 60 }, { 255, 255, 255 } }; void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { FileSelectState* this = (FileSelectState*)thisx; Font* sp54 = &this->font; - s32 heartType; - s16 i; + s16 heartType; s16 vtxOffset; + s16 i; s16 j; + s16 k; s16 deathCountSplit[3]; - if (1) {} - OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1709); gDPPipeSync(POLY_OPA_DISP++); @@ -860,8 +870,8 @@ void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { FileSelect_SplitNumber(this->deaths[fileIndex], &deathCountSplit[0], &deathCountSplit[1], &deathCountSplit[2]); // draw death count - for (i = 0, vtxOffset = 0; i < 3; i++, vtxOffset += 4) { - FileSelect_DrawCharacter(this->state.gfxCtx, sp54->fontBuf + deathCountSplit[i] * FONT_CHAR_TEX_SIZE, + for (k = 0, vtxOffset = 0; k < 3; k++, vtxOffset += 4) { + FileSelect_DrawCharacter(this->state.gfxCtx, sp54->fontBuf + deathCountSplit[k] * FONT_CHAR_TEX_SIZE, vtxOffset); } @@ -877,10 +887,10 @@ void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { gDPSetEnvColor(POLY_OPA_DISP++, sHeartEnvColors[heartType][0], sHeartEnvColors[heartType][1], sHeartEnvColors[heartType][2], 255); - i = this->healthCapacities[fileIndex] / 0x10; + k = this->healthCapacities[fileIndex] / 0x10; // draw hearts - for (vtxOffset = 0, j = 0; j < i; j++, vtxOffset += 4) { + for (vtxOffset = 0, j = 0; j < k; j++, vtxOffset += 4) { gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x30, 4, 0); POLY_OPA_DISP = FileSelect_QuadTextureIA8(POLY_OPA_DISP, sHeartTextures[heartType], 0x10, 0x10, 0); @@ -987,9 +997,9 @@ static void* sOptionsButtonTextures[] = LANGUAGE_ARRAY(gFileSelOptionsButtonJPNT void FileSelect_DrawWindowContents(GameState* thisx) { FileSelectState* this = (FileSelectState*)thisx; s16 fileIndex; - s16 temp; s16 i; s16 quadVtxIndex; + s16 temp; s16 isActive; s16 pad; @@ -1563,6 +1573,14 @@ void FileSelect_LoadGame(GameState* thisx) { gSaveContext.save.info.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SWORD]; gSaveContext.save.info.inventory.equipment ^= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, swordEquipValue - 1); } + +#if PLATFORM_N64 + if (D_80121212 != 0) { + s32 fileNum = gSaveContext.fileNum; + + n64dd_SetDiskVersion(this->n64ddFlags[fileNum]); + } +#endif } static void (*sSelectModeUpdateFuncs[])(GameState*) = { @@ -1648,7 +1666,15 @@ void FileSelect_Main(GameState* thisx) { OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2898); +#if PLATFORM_N64 + if ((D_80121212 != 0) && (func_801C70FC() != 0)) { + this->n64ddFlag = 1; + } else { + this->n64ddFlag = 0; + } +#else this->n64ddFlag = 0; +#endif gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); @@ -1927,6 +1953,12 @@ void FileSelect_Init(GameState* thisx) { u32 size = (uintptr_t)_title_staticSegmentRomEnd - (uintptr_t)_title_staticSegmentRomStart; s32 pad; +#if PLATFORM_N64 + if (D_80121212 != 0) { + func_801C7268(); + } +#endif + SREG(30) = 1; PRINTF("SIZE=%x\n", size); diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c index a412b17c46..fc307208c1 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c @@ -308,7 +308,7 @@ void FileSelect_SetNameEntryVtx(GameState* thisx) { gSPVertex(POLY_OPA_DISP++, this->nameEntryVtx + 4, 32, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->nameEntryBoxAlpha); - for (phi_v0 = 0, phi_s0 = 0; phi_s0 < 0x20; phi_s0 += 4, phi_v0++) { + for (phi_s0 = 0, phi_v0 = 0; phi_s0 < 0x20; phi_s0 += 4, phi_v0++) { FileSelect_DrawCharacter(this->state.gfxCtx, font->fontBuf + this->fileNames[this->buttonIndex][phi_v0] * FONT_CHAR_TEX_SIZE, phi_s0); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c index c497b8114c..da69f04ac5 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -4,7 +4,7 @@ #define SONG_MAX_LENGTH 8 -#if PLATFORM_N64 +#if !PLATFORM_GC #define KALEIDO_COLOR_COLLECT_UNK_R 80 #define KALEIDO_COLOR_COLLECT_UNK_G 150 #define KALEIDO_COLOR_COLLECT_UNK_B 255 diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c index d0773a2f42..0a38c2aa94 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c @@ -753,7 +753,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 235, 235, 235, pauseCtx->alpha); for (k = 0; k < 15; k += 8) { - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[15 * 4 + k * 4], 32, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[(PAGE_BG_QUADS + k) * 4], 32, 0); for (j = i = 0; i < 8; i++, j += 4) { if (!(gSaveContext.save.info.worldMapAreaData & gBitFlags[cloudFlagNums[k + i]])) { diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c index a783254c3f..fa42fc6ded 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c @@ -15,7 +15,7 @@ #include "assets/textures/icon_item_gameover_static/icon_item_gameover_static.h" #include "terminal.h" -#if PLATFORM_N64 +#if !PLATFORM_GC #define KALEIDO_COLOR_PROMPT_UNK_R 100 #define KALEIDO_COLOR_PROMPT_UNK_G 100 #define KALEIDO_COLOR_PROMPT_UNK_B 255 @@ -560,7 +560,7 @@ s16 gVtxPageMapWorldQuadsWidth[VTX_PAGE_MAP_WORLD_QUADS] = { 8, // WORLD_MAP_POINT_HAUNTED_WASTELAND 8, // WORLD_MAP_POINT_GERUDOS_FORTRESS 8, // WORLD_MAP_POINT_GERUDO_VALLEY - 8, // WORLD_MAP_POINT_HYLIA_LAKESIDE + 8, // WORLD_MAP_POINT_LAKE_HYLIA 8, // WORLD_MAP_POINT_LON_LON_RANCH 8, // WORLD_MAP_POINT_MARKET 8, // WORLD_MAP_POINT_HYRULE_FIELD @@ -595,7 +595,7 @@ s16 gVtxPageMapWorldQuadsHeight[VTX_PAGE_MAP_WORLD_QUADS] = { 8, // WORLD_MAP_POINT_HAUNTED_WASTELAND 8, // WORLD_MAP_POINT_GERUDOS_FORTRESS 8, // WORLD_MAP_POINT_GERUDO_VALLEY - 8, // WORLD_MAP_POINT_HYLIA_LAKESIDE + 8, // WORLD_MAP_POINT_LAKE_HYLIA 8, // WORLD_MAP_POINT_LON_LON_RANCH 8, // WORLD_MAP_POINT_MARKET 8, // WORLD_MAP_POINT_HYRULE_FIELD @@ -2148,12 +2148,12 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { // `texIndex` is a `WorldMapPoint` enum value if (gSaveContext.language) { // != LANGUAGE_JPN for NTSC versions, LANGUAGE_ENG for PAL versions - texIndex += 12; + texIndex += WORLD_MAP_POINT_MAX; } #if OOT_PAL if (gSaveContext.language == LANGUAGE_FRA) { - texIndex += 12; + texIndex += WORLD_MAP_POINT_MAX; } #endif @@ -2303,7 +2303,7 @@ static s16 sVtxPageMapWorldQuadsX[VTX_PAGE_MAP_WORLD_QUADS] = { -93, // WORLD_MAP_POINT_HAUNTED_WASTELAND -67, // WORLD_MAP_POINT_GERUDOS_FORTRESS -56, // WORLD_MAP_POINT_GERUDO_VALLEY - -33, // WORLD_MAP_POINT_HYLIA_LAKESIDE + -33, // WORLD_MAP_POINT_LAKE_HYLIA -10, // WORLD_MAP_POINT_LON_LON_RANCH 1, // WORLD_MAP_POINT_MARKET 14, // WORLD_MAP_POINT_HYRULE_FIELD @@ -2365,7 +2365,7 @@ static s16 sVtxPageMapWorldQuadsY[VTX_PAGE_MAP_WORLD_QUADS] = { 31, // WORLD_MAP_POINT_HAUNTED_WASTELAND 27, // WORLD_MAP_POINT_GERUDOS_FORTRESS 15, // WORLD_MAP_POINT_GERUDO_VALLEY - -49, // WORLD_MAP_POINT_HYLIA_LAKESIDE + -49, // WORLD_MAP_POINT_LAKE_HYLIA 8, // WORLD_MAP_POINT_LON_LON_RANCH 38, // WORLD_MAP_POINT_MARKET 7, // WORLD_MAP_POINT_HYRULE_FIELD @@ -3918,13 +3918,13 @@ void KaleidoScope_Update(PlayState* play) { } if (CUR_UPG_VALUE(UPG_SCALE)) { - pauseCtx->worldMapPoints[WORLD_MAP_POINT_HYLIA_LAKESIDE] = WORLD_MAP_POINT_STATE_SHOW; + pauseCtx->worldMapPoints[WORLD_MAP_POINT_LAKE_HYLIA] = WORLD_MAP_POINT_STATE_SHOW; } if (CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, EQUIP_INV_BOOTS_IRON)) { - pauseCtx->worldMapPoints[WORLD_MAP_POINT_HYLIA_LAKESIDE] = WORLD_MAP_POINT_STATE_HIGHLIGHT; + pauseCtx->worldMapPoints[WORLD_MAP_POINT_LAKE_HYLIA] = WORLD_MAP_POINT_STATE_HIGHLIGHT; } if (CHECK_QUEST_ITEM(QUEST_MEDALLION_WATER)) { - pauseCtx->worldMapPoints[WORLD_MAP_POINT_HYLIA_LAKESIDE] = WORLD_MAP_POINT_STATE_SHOW; + pauseCtx->worldMapPoints[WORLD_MAP_POINT_LAKE_HYLIA] = WORLD_MAP_POINT_STATE_SHOW; } if (GET_EVENTCHKINF(EVENTCHKINF_09)) { @@ -4069,7 +4069,7 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->tradeQuestLocation = WORLD_MAP_POINT_ZORAS_DOMAIN; } if (i == ITEM_EYEBALL_FROG) { - pauseCtx->tradeQuestLocation = WORLD_MAP_POINT_HYLIA_LAKESIDE; + pauseCtx->tradeQuestLocation = WORLD_MAP_POINT_LAKE_HYLIA; } if ((i == ITEM_CLAIM_CHECK) && !gSaveContext.save.info.playerData.bgsFlag) { pauseCtx->tradeQuestLocation = WORLD_MAP_POINT_DEATH_MOUNTAIN; @@ -4124,7 +4124,7 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->state = PAUSE_STATE_CLOSING; R_PAUSE_OFFSET_VERTICAL = -6240; func_800F64E0(0); -#if PLATFORM_GC && OOT_NTSC +#if !PLATFORM_N64 && OOT_NTSC AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); #endif } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -4282,7 +4282,7 @@ void KaleidoScope_Update(PlayState* play) { R_PAUSE_OFFSET_VERTICAL = -6240; YREG(8) = pauseCtx->rollRotSavePrompt_; func_800F64E0(0); -#if PLATFORM_GC && OOT_NTSC +#if !PLATFORM_N64 && OOT_NTSC AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); #endif } else { @@ -4315,7 +4315,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.buttonStatus[3] = BTN_ENABLED; gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); -#if PLATFORM_GC && OOT_NTSC +#if !PLATFORM_N64 && OOT_NTSC AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); #endif } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h index faaa4dff98..99f9a306d5 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h @@ -120,6 +120,8 @@ typedef enum EquipQuad { #define WORLD_MAP_IMAGE_FRAG_HEIGHT ((TMEM_SIZE / 2) / (WORLD_MAP_IMAGE_WIDTH * G_IM_SIZ_8b_BYTES)) #define WORLD_MAP_IMAGE_FRAG_NUM (((WORLD_MAP_IMAGE_HEIGHT - 1) / WORLD_MAP_IMAGE_FRAG_HEIGHT) + 1) +// Clouds quads cover undiscovered areas. +// Point quads are location markers. They can also be highlighted as a hint of where to go. typedef enum MapQuad { /* 0 */ QUAD_MAP_WORLD_CLOUDS_SACRED_FOREST_MEADOW, /* 1 */ QUAD_MAP_WORLD_CLOUDS_HYRULE_FIELD, diff --git a/tools/disasm/ntsc-1.2/files_ovl_file_choose.csv b/tools/disasm/ntsc-1.2/files_ovl_file_choose.csv index 1e4aeabcc3..ab21a34f0c 100644 --- a/tools/disasm/ntsc-1.2/files_ovl_file_choose.csv +++ b/tools/disasm/ntsc-1.2/files_ovl_file_choose.csv @@ -1,7 +1,7 @@ offset,vram,.text 0,80803880,src/overlays/gamestates/ovl_file_choose/z_file_copy_erase 3040,808068C0,src/overlays/gamestates/ovl_file_choose/z_file_nameset -8440,8080BCC0,z_file_choose +8440,8080BCC0,src/overlays/gamestates/ovl_file_choose/z_file_choose offset,vram,.data EC50,808124D0,src/overlays/gamestates/ovl_file_choose/z_file_nameset_data diff --git a/tools/disasm/ntsc-1.2/functions.txt b/tools/disasm/ntsc-1.2/functions.txt index cdcfe8192b..cba1d3b05c 100644 --- a/tools/disasm/ntsc-1.2/functions.txt +++ b/tools/disasm/ntsc-1.2/functions.txt @@ -410,7 +410,7 @@ Actor_GetWorld = 0x80022CE4; // type:func Actor_GetWorldPosShapeRot = 0x80022D18; // type:func Target_WeightedDistToPlayerSq = 0x80022D94; // type:func Target_ActorIsInRange = 0x80022E64; // type:func -func_8002F0C8 = 0x80022EA0; // type:func +Target_ShouldReleaseLockOn = 0x80022EA0; // type:func Actor_TalkOfferAccepted = 0x80022F70; // type:func Actor_OfferTalkExchange = 0x80022FA0; // type:func Actor_OfferTalkExchangeEquiCylinder = 0x80023074; // type:func @@ -1595,12 +1595,12 @@ Room_DrawImageSingle = 0x800805E0; // type:func Room_GetImageMultiBgEntry = 0x80080990; // type:func Room_DrawImageMulti = 0x80080A7C; // type:func Room_DrawImage = 0x80080E48; // type:func -func_80096FD4 = 0x80080EB0; // type:func -func_80096FE8 = 0x80080EC8; // type:func -func_8009728C = 0x80081064; // type:func -func_800973FC = 0x800811CC; // type:func +Room_Init = 0x80080EB0; // type:func +Room_SetupFirstRoom = 0x80080EC8; // type:func +Room_RequestNewRoom = 0x80081064; // type:func +Room_ProcessRoomRequest = 0x800811CC; // type:func Room_Draw = 0x80081270; // type:func -func_80097534 = 0x800812C0; // type:func +Room_FinishRoomChange = 0x800812C0; // type:func Sample_HandleStateChange = 0x80081360; // type:func Sample_Draw = 0x80081394; // type:func Sample_Main = 0x80081580; // type:func @@ -1632,7 +1632,7 @@ Scene_CommandObjectList = 0x80082308; // type:func Scene_CommandLightList = 0x800824BC; // type:func Scene_CommandPathList = 0x8008256C; // type:func Scene_CommandTransitionActorEntryList = 0x800825B4; // type:func -TransitionActor_InitContext = 0x8008260C; // type:func +Scene_ResetTransitionActorList = 0x8008260C; // type:func Scene_CommandLightSettingsList = 0x8008261C; // type:func Scene_CommandSkyboxSettings = 0x80082674; // type:func Scene_CommandSkyboxDisables = 0x800826B8; // type:func @@ -2795,7 +2795,7 @@ Audio_RemoveSfxBankEntry = 0x800C8F78; // type:func Audio_ChooseActiveSfx = 0x800C9110; // type:func Audio_PlayActiveSfx = 0x800C9844; // type:func Audio_StopSfxByBank = 0x800C9B64; // type:func -func_800F8884 = 0x800C9C48; // type:func +Audio_RemoveSfxFromBankByPos = 0x800C9C48; // type:func Audio_StopSfxByPosAndBank = 0x800C9D64; // type:func Audio_StopSfxByPos = 0x800C9DAC; // type:func Audio_StopSfxByPosAndId = 0x800C9E08; // type:func @@ -3099,6 +3099,8 @@ Regs_InitDataImpl = 0x800E2704; // type:func Regs_InitData = 0x800E35D0; // type:func njpgdspMainTextStart = 0x800E7200; // type:func func_801C6E80 = 0x801C7740; // type:func +func_801C70FC = 0x801C79BC; // type:func +func_801C7268 = 0x801C7BC4; // type:func func_801C7C1C = 0x801C8510; // type:func n64dd_SetDiskVersion = 0x801C8808; // type:func ConsoleLogo_Calc = 0x80800000; // type:func