1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 15:04:31 +00:00

Merge branch 'master' into doc_pause_menu

This commit is contained in:
Dragorn421 2022-09-04 16:03:05 +02:00
commit c7ba9adec2
No known key found for this signature in database
GPG key ID: 32B53D2D16FC4118
61 changed files with 1227 additions and 934 deletions

View file

@ -150,9 +150,9 @@
<Texture Name="gZorasRiverTitleCardFRATex" OutName="zoras_river_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/> <Texture Name="gZorasRiverTitleCardFRATex" OutName="zoras_river_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/>
</File> </File>
<File Name="g_pn_31"> <File Name="g_pn_31">
<Texture Name="gKokiriForestTitleCardENGTex" OutName="kokiri_firest_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/> <Texture Name="gKokiriForestTitleCardENGTex" OutName="kokiri_forest_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/>
<Texture Name="gKokiriForestTitleCardGERTex" OutName="kokiri_firest_ger" Format="ia8" Width="144" Height="24" Offset="0xD80"/> <Texture Name="gKokiriForestTitleCardGERTex" OutName="kokiri_forest_ger" Format="ia8" Width="144" Height="24" Offset="0xD80"/>
<Texture Name="gKokiriForestTitleCardFRATex" OutName="kokiri_firest_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/> <Texture Name="gKokiriForestTitleCardFRATex" OutName="kokiri_forest_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/>
</File> </File>
<File Name="g_pn_32"> <File Name="g_pn_32">
<Texture Name="gLakeHyliaTitleCardENGTex" OutName="lake_hylia_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/> <Texture Name="gLakeHyliaTitleCardENGTex" OutName="lake_hylia_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/>
@ -215,9 +215,9 @@
<Texture Name="gGanonsCastleTitleCardFRATex" OutName="ganons_castle_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/> <Texture Name="gGanonsCastleTitleCardFRATex" OutName="ganons_castle_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/>
</File> </File>
<File Name="g_pn_44"> <File Name="g_pn_44">
<Texture Name="gRoyalFamilysTumbTitleCardENGTex" OutName="royal_familys_tumb_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/> <Texture Name="gRoyalFamilysTombTitleCardENGTex" OutName="royal_familys_tomb_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/>
<Texture Name="gRoyalFamilysTumbTitleCardGERTex" OutName="royal_familys_tumb_ger" Format="ia8" Width="144" Height="24" Offset="0xD80"/> <Texture Name="gRoyalFamilysTombTitleCardGERTex" OutName="royal_familys_tomb_ger" Format="ia8" Width="144" Height="24" Offset="0xD80"/>
<Texture Name="gRoyalFamilysTumbTitleCardFRATex" OutName="royal_familys_tumb_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/> <Texture Name="gRoyalFamilysTombTitleCardFRATex" OutName="royal_familys_tomb_fra" Format="ia8" Width="144" Height="24" Offset="0x1B00"/>
</File> </File>
<File Name="g_pn_45"> <File Name="g_pn_45">
<Texture Name="gFairysFountainTitleCardENGTex" OutName="fairys_fountain_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/> <Texture Name="gFairysFountainTitleCardENGTex" OutName="fairys_fountain_eng" Format="ia8" Width="144" Height="24" Offset="0x0"/>

View file

@ -1,6 +1,7 @@
#ifndef FAULT_H #ifndef FAULT_H
#define FAULT_H #define FAULT_H
#include "ultra64.h"
#include "padmgr.h" #include "padmgr.h"
// These are the same as the 3-bit ansi color codes // These are the same as the 3-bit ansi color codes
@ -69,7 +70,7 @@ void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...);
typedef struct FaultMgr { typedef struct FaultMgr {
/* 0x000 */ OSThread thread; /* 0x000 */ OSThread thread;
/* 0x1B0 */ u8 unk_1B0[0x600]; /* 0x1B0 */ char unk_1B0[0x600]; // probably an unused internal thread stack for `Fault_ClientRunTask`/`clientThreadSp`
/* 0x7B0 */ OSMesgQueue queue; /* 0x7B0 */ OSMesgQueue queue;
/* 0x7C8 */ OSMesg msg; /* 0x7C8 */ OSMesg msg;
/* 0x7CC */ u8 exit; /* 0x7CC */ u8 exit;
@ -77,12 +78,11 @@ typedef struct FaultMgr {
/* 0x7CE */ u8 faultHandlerEnabled; /* 0x7CE */ u8 faultHandlerEnabled;
/* 0x7CF */ u8 autoScroll; /* 0x7CF */ u8 autoScroll;
/* 0x7D0 */ OSThread* faultedThread; /* 0x7D0 */ OSThread* faultedThread;
/* 0x7D4 */ void (*padCallback)(Input*); /* 0x7D4 */ void (*padCallback)(Input* inputs);
/* 0x7D8 */ FaultClient* clients; /* 0x7D8 */ FaultClient* clients;
/* 0x7DC */ FaultAddrConvClient* addrConvClients; /* 0x7DC */ FaultAddrConvClient* addrConvClients;
/* 0x7E0 */ u8 unk_7E0[4]; /* 0x7E0 */ char unk_7E0[0x4];
/* 0x7E4 */ Input padInput; /* 0x7E4 */ Input inputs[MAXCONTROLLERS];
/* 0x7FC */ u16 colors[36];
/* 0x844 */ void* fb; /* 0x844 */ void* fb;
/* 0x848 */ void* clientThreadSp; /* 0x848 */ void* clientThreadSp;
} FaultMgr; // size = 0x850 } FaultMgr; // size = 0x850

View file

@ -939,7 +939,7 @@ void ZeldaArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void ZeldaArena_Check(void); void ZeldaArena_Check(void);
void ZeldaArena_Init(void* start, u32 size); void ZeldaArena_Init(void* start, u32 size);
void ZeldaArena_Cleanup(void); void ZeldaArena_Cleanup(void);
u8 ZeldaArena_IsInitalized(void); u8 ZeldaArena_IsInitialized(void);
void MapMark_Init(PlayState* play); void MapMark_Init(PlayState* play);
void MapMark_ClearPointers(PlayState* play); void MapMark_ClearPointers(PlayState* play);
void MapMark_Draw(PlayState* play); void MapMark_Draw(PlayState* play);
@ -1132,9 +1132,9 @@ Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1
Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a); Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a);
void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b);
void func_80095974(GraphicsContext* gfxCtx); void func_80095974(GraphicsContext* gfxCtx);
void func_80095AA0(PlayState* play, Room* room, Input* arg2, UNK_TYPE arg3); void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3);
void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 mode0, void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tlutMode,
u16 tlutCount, f32 frameX, f32 frameY); u16 tlutCount, f32 offsetX, f32 offsetY);
void func_80096FD4(PlayState* play, Room* room); void func_80096FD4(PlayState* play, Room* room);
u32 func_80096FE8(PlayState* play, RoomContext* roomCtx); u32 func_80096FE8(PlayState* play, RoomContext* roomCtx);
s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum); s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum);
@ -1574,21 +1574,6 @@ void ListAlloc_Free(ListAlloc* this, void* data);
void ListAlloc_FreeAll(ListAlloc* this); void ListAlloc_FreeAll(ListAlloc* this);
void Main_LogSystemHeap(void); void Main_LogSystemHeap(void);
void Main(void* arg); void Main(void* arg);
OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr);
void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue);
void PadMgr_LockPadData(PadMgr* padMgr);
void PadMgr_UnlockPadData(PadMgr* padMgr);
void PadMgr_RumbleControl(PadMgr* padMgr);
void PadMgr_RumbleStop(PadMgr* padMgr);
void PadMgr_RumbleReset(PadMgr* padMgr);
void PadMgr_RumbleSet(PadMgr* padMgr, u8* ctrlrRumbles);
void PadMgr_ProcessInputs(PadMgr* padMgr);
void PadMgr_HandleRetraceMsg(PadMgr* padMgr);
void PadMgr_HandlePreNMI(PadMgr* padMgr);
// This function must remain commented out, because it is called incorrectly in
// fault.c (actual bug in game), and the compiler notices and won't compile it
// void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode);
void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack);
void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y); void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y);
void SpeedMeter_Init(SpeedMeter* this); void SpeedMeter_Init(SpeedMeter* this);
void SpeedMeter_Destroy(SpeedMeter* this); void SpeedMeter_Destroy(SpeedMeter* this);
@ -1729,7 +1714,7 @@ void DebugArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void DebugArena_Check(void); void DebugArena_Check(void);
void DebugArena_Init(void* start, u32 size); void DebugArena_Init(void* start, u32 size);
void DebugArena_Cleanup(void); void DebugArena_Cleanup(void);
u8 DebugArena_IsInitalized(void); u8 DebugArena_IsInitialized(void);
void UCodeDisas_Init(UCodeDisas*); void UCodeDisas_Init(UCodeDisas*);
void UCodeDisas_Destroy(UCodeDisas*); void UCodeDisas_Destroy(UCodeDisas*);
// void UCodeDisas_Disassemble(UCodeDisas*, Gfx*); // void UCodeDisas_Disassemble(UCodeDisas*, Gfx*);
@ -2031,7 +2016,7 @@ void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void SystemArena_Check(void); void SystemArena_Check(void);
void SystemArena_Init(void* start, u32 size); void SystemArena_Init(void* start, u32 size);
void SystemArena_Cleanup(void); void SystemArena_Cleanup(void);
u8 SystemArena_IsInitalized(void); u8 SystemArena_IsInitialized(void);
u32 Rand_Next(void); u32 Rand_Next(void);
void Rand_Seed(u32 seed); void Rand_Seed(u32 seed);
f32 Rand_ZeroOne(void); f32 Rand_ZeroOne(void);
@ -2060,7 +2045,7 @@ void __osMallocInit(Arena* arena, void* start, u32 size);
void __osMallocAddBlock(Arena* arena, void* start, s32 size); void __osMallocAddBlock(Arena* arena, void* start, s32 size);
void ArenaImpl_RemoveAllBlocks(Arena* arena); void ArenaImpl_RemoveAllBlocks(Arena* arena);
void __osMallocCleanup(Arena* arena); void __osMallocCleanup(Arena* arena);
u8 __osMallocIsInitalized(Arena* arena); u8 __osMallocIsInitialized(Arena* arena);
void __osMalloc_FreeBlockTest(Arena* arena, ArenaNode* node); void __osMalloc_FreeBlockTest(Arena* arena, ArenaNode* node);
void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line); void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line);
void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line); void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line);

View file

@ -43,4 +43,7 @@ void IrqMgr_Init(IrqMgr* irqMgr, void* stack, OSPri pri, u8 retraceCount);
void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQueue); void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQueue);
void IrqMgr_RemoveClient(IrqMgr* irqMgr, IrqMgrClient* client); void IrqMgr_RemoveClient(IrqMgr* irqMgr, IrqMgrClient* client);
extern vu32 gIrqMgrResetStatus;
extern volatile OSTime gIrqMgrRetraceTime;
#endif #endif

View file

@ -1,8 +1,15 @@
#ifndef PADMGR_H #ifndef PADMGR_H
#define PADMGR_H #define PADMGR_H
#include "ultra64.h"
#include "irqmgr.h" #include "irqmgr.h"
typedef enum {
CONT_PAK_NONE,
CONT_PAK_RUMBLE,
CONT_PAK_OTHER
} ControllerPakType;
typedef struct { typedef struct {
/* 0x00 */ OSContPad cur; /* 0x00 */ OSContPad cur;
/* 0x06 */ OSContPad prev; /* 0x06 */ OSContPad prev;
@ -11,9 +18,9 @@ typedef struct {
} Input; // size = 0x18 } Input; // size = 0x18
typedef struct PadMgr { typedef struct PadMgr {
/* 0x0000 */ OSContStatus padStatus[4]; /* 0x0000 */ OSContStatus padStatus[MAXCONTROLLERS];
/* 0x0010 */ OSMesg serialLockMsgBuf[1]; /* 0x0010 */ OSMesg serialMsg;
/* 0x0014 */ OSMesg lockMsgBuf[1]; /* 0x0014 */ OSMesg lockMsg;
/* 0x0018 */ OSMesg interruptMsgBuf[4]; /* 0x0018 */ OSMesg interruptMsgBuf[4];
/* 0x0028 */ OSMesgQueue serialLockQueue; /* 0x0028 */ OSMesgQueue serialLockQueue;
/* 0x0040 */ OSMesgQueue lockQueue; /* 0x0040 */ OSMesgQueue lockQueue;
@ -21,20 +28,46 @@ typedef struct PadMgr {
/* 0x0070 */ IrqMgrClient irqClient; /* 0x0070 */ IrqMgrClient irqClient;
/* 0x0078 */ IrqMgr* irqMgr; /* 0x0078 */ IrqMgr* irqMgr;
/* 0x0080 */ OSThread thread; /* 0x0080 */ OSThread thread;
/* 0x0230 */ Input inputs[4]; /* 0x0230 */ Input inputs[MAXCONTROLLERS];
/* 0x0290 */ OSContPad pads[4]; /* 0x0290 */ OSContPad pads[MAXCONTROLLERS];
/* 0x02A8 */ vu8 validCtrlrsMask; /* 0x02A8 */ vu8 validCtrlrsMask;
/* 0x02A9 */ u8 nControllers; /* 0x02A9 */ u8 nControllers;
/* 0x02AA */ u8 ctrlrIsConnected[4]; // "Key_switch" originally /* 0x02AA */ u8 ctrlrIsConnected[MAXCONTROLLERS];
/* 0x02AE */ u8 pakType[4]; // 1 if rumble pack, 2 if mempak? /* 0x02AE */ u8 pakType[MAXCONTROLLERS];
/* 0x02B2 */ vu8 rumbleEnable[4]; /* 0x02B2 */ vu8 rumbleEnable[MAXCONTROLLERS];
/* 0x02B6 */ u8 rumbleCounter[4]; // not clear exact meaning /* 0x02B6 */ u8 rumbleTimer[MAXCONTROLLERS];
/* 0x02BC */ OSPfs pfs[4]; /* 0x02BC */ OSPfs rumblePfs[MAXCONTROLLERS];
/* 0x045C */ vu8 rumbleOffFrames; /* 0x045C */ vu8 rumbleOffTimer; // amount of VI retraces to not rumble for, takes priority over rumbleOnTimer
/* 0x045D */ vu8 rumbleOnFrames; /* 0x045D */ vu8 rumbleOnTimer; // amount of VI retraces to rumble for
/* 0x045E */ u8 preNMIShutdown; /* 0x045E */ u8 isResetting;
/* 0x0460 */ void (*retraceCallback)(struct PadMgr* padmgr, s32 unk464); /* 0x0460 */ void (*retraceCallback)(struct PadMgr* padMgr, s32 arg);
/* 0x0464 */ u32 retraceCallbackValue; /* 0x0464 */ s32 retraceCallbackValue;
} PadMgr; // size = 0x468 } PadMgr; // size = 0x468
extern PadMgr gPadMgr;
// Initialization
void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack);
// Fetching inputs
// This function cannot be prototyped here without AVOID_UB because it is called incorrectly in fault.c (see bug in
// `Fault_PadCallback`)
#ifdef AVOID_UB
void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 gameRequest);
#endif
// For internal use by Controller Pak systems
OSMesgQueue* PadMgr_AcquireSerialEventQueue(PadMgr* padMgr);
void PadMgr_ReleaseSerialEventQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue);
// Rumble
void PadMgr_RumbleStop(PadMgr* padMgr);
void PadMgr_RumbleReset(PadMgr* padMgr);
void PadMgr_RumbleSetSingle(PadMgr* padMgr, u32 port, u32 rumble);
void PadMgr_RumbleSet(PadMgr* padMgr, u8* enable);
#endif #endif

View file

@ -48,6 +48,8 @@
#define R_ENV_TIME_SPEED_OLD REG(15) // Most likely used during development. Unused in the final game. #define R_ENV_TIME_SPEED_OLD REG(15) // Most likely used during development. Unused in the final game.
#define R_RUN_SPEED_LIMIT REG(45) #define R_RUN_SPEED_LIMIT REG(45)
#define R_ENABLE_ARENA_DBG SREG(0) #define R_ENABLE_ARENA_DBG SREG(0)
#define R_ROOM_IMAGE_NODRAW_FLAGS SREG(25)
#define R_ROOM_BG2D_FORCE_SCALEBG SREG(26)
#define R_UPDATE_RATE SREG(30) #define R_UPDATE_RATE SREG(30)
#define R_GRAPH_TASKSET00_FLAGS SREG(33) #define R_GRAPH_TASKSET00_FLAGS SREG(33)
#define R_ENABLE_AUDIO_DBG SREG(36) #define R_ENABLE_AUDIO_DBG SREG(36)
@ -57,13 +59,17 @@
#define R_FB_FILTER_ENV_COLOR(c) SREG(85 + (c)) #define R_FB_FILTER_ENV_COLOR(c) SREG(85 + (c))
#define R_ENABLE_FB_FILTER SREG(88) #define R_ENABLE_FB_FILTER SREG(88)
#define R_PAUSE_BG_PRERENDER_STATE SREG(94) // `PauseBgPreRenderState` #define R_PAUSE_BG_PRERENDER_STATE SREG(94) // `PauseBgPreRenderState`
#define R_CAM_MAX_PHI OREG(5) #define R_CAM_MAX_PITCH OREG(5)
#define R_CAM_DEFA_PHI_UPDRATE OREG(7) #define R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV OREG(7)
#define R_DEFA_CAM_ANIM_TIME OREG(23) #define R_CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC OREG(17)
#define R_CAM_MIN_PHI OREG(34) #define R_CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC OREG(18)
#define R_CAM_MIN_PHI2 OREG(35) #define R_CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC OREG(19)
#define R_AT_LERP_MIN OREG(41) #define R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT OREG(20)
#define R_AT_LERP_SCALE OREG(42) #define R_CAM_DEFAULT_ANIM_TIME OREG(23)
#define R_CAM_MIN_PITCH_1 OREG(34)
#define R_CAM_MIN_PITCH_2 OREG(35)
#define R_CAM_AT_LERP_STEP_SCALE_MIN OREG(41)
#define R_CAM_AT_LERP_STEP_SCALE_FAC OREG(42)
#define R_CAM_YOFFSET_NORM OREG(46) #define R_CAM_YOFFSET_NORM OREG(46)
#define R_CAM_DATA(type) PREG(0 + (type)) #define R_CAM_DATA(type) PREG(0 + (type))
#define R_DBG_CAM_UPDATE PREG(80) #define R_DBG_CAM_UPDATE PREG(80)
@ -132,6 +138,10 @@
#define R_TEXTBOX_TEXHEIGHT_TARGET XREG(77) #define R_TEXTBOX_TEXHEIGHT_TARGET XREG(77)
#define R_ENV_LIGHT1_DIR(i) cREG(3 + (i)) #define R_ENV_LIGHT1_DIR(i) cREG(3 + (i))
#define R_ENV_LIGHT2_DIR(i) cREG(6 + (i)) #define R_ENV_LIGHT2_DIR(i) cREG(6 + (i))
#define R_ROOM_CULL_DEBUG_MODE iREG(86)
#define R_ROOM_CULL_NUM_ENTRIES iREG(87)
#define R_ROOM_CULL_USED_ENTRIES iREG(88)
#define R_ROOM_CULL_DEBUG_TARGET iREG(89)
#define R_B_LABEL_DD WREG(0) #define R_B_LABEL_DD WREG(0)
#define R_PAUSE_OFFSET_VERTICAL WREG(2) #define R_PAUSE_OFFSET_VERTICAL WREG(2)
#define R_PAUSE_OFFSET_DEPTH WREG(3) #define R_PAUSE_OFFSET_DEPTH WREG(3)

View file

@ -110,8 +110,6 @@ extern s32 gScreenHeight;
extern Mtx gMtxClear; extern Mtx gMtxClear;
extern MtxF gMtxFClear; extern MtxF gMtxFClear;
extern u32 gIsCtrlr2Valid; extern u32 gIsCtrlr2Valid;
extern vu32 gIrqMgrResetStatus;
extern volatile OSTime gIrqMgrRetraceTime;
extern s16* gWaveSamples[9]; extern s16* gWaveSamples[9];
extern f32 gBendPitchOneOctaveFrequencies[256]; extern f32 gBendPitchOneOctaveFrequencies[256];
extern f32 gBendPitchTwoSemitonesFrequencies[256]; extern f32 gBendPitchTwoSemitonesFrequencies[256];
@ -128,7 +126,7 @@ extern f32 gStereoPanVolume[128];
extern f32 gDefaultPanVolume[128]; extern f32 gDefaultPanVolume[128];
extern s16 gLowPassFilterData[16 * 8]; extern s16 gLowPassFilterData[16 * 8];
extern s16 gHighPassFilterData[15 * 8]; extern s16 gHighPassFilterData[15 * 8];
extern s32 gAudioContextInitalized; extern s32 gAudioContextInitialized;
extern u8 gIsLargeSfxBank[7]; extern u8 gIsLargeSfxBank[7];
extern u8 gChannelsPerBank[4][7]; extern u8 gChannelsPerBank[4][7];
extern u8 gUsedChannelsPerBank[4][7]; extern u8 gUsedChannelsPerBank[4][7];
@ -193,7 +191,6 @@ extern s32 gTrnsnUnkState;
extern Color_RGBA8_u32 D_801614B0; extern Color_RGBA8_u32 D_801614B0;
extern PreNmiBuff* gAppNmiBufferPtr; extern PreNmiBuff* gAppNmiBufferPtr;
extern Scheduler gScheduler; extern Scheduler gScheduler;
extern PadMgr gPadMgr;
extern u32 gSegments[NUM_SEGMENTS]; extern u32 gSegments[NUM_SEGMENTS];
extern volatile OSTime D_8016A520; extern volatile OSTime D_8016A520;
extern volatile OSTime D_8016A528; extern volatile OSTime D_8016A528;

View file

@ -871,7 +871,7 @@ typedef enum {
/* 01 */ GAMEOVER_DEATH_START, /* 01 */ GAMEOVER_DEATH_START,
/* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for link to fall and hit the ground /* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for link to fall and hit the ground
/* 03 */ GAMEOVER_DEATH_DELAY_MENU, // wait for 1 second before showing the game over menu /* 03 */ GAMEOVER_DEATH_DELAY_MENU, // wait for 1 second before showing the game over menu
/* 04 */ GAMEOVER_DEATH_MENU, // do nothing while kaliedoscope handles the game over menu /* 04 */ GAMEOVER_DEATH_MENU, // do nothing while kaleidoscope handles the game over menu
/* 20 */ GAMEOVER_REVIVE_START = 20, /* 20 */ GAMEOVER_REVIVE_START = 20,
/* 21 */ GAMEOVER_REVIVE_RUMBLE, /* 21 */ GAMEOVER_REVIVE_RUMBLE,
/* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for link to fall and hit the ground /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for link to fall and hit the ground
@ -932,7 +932,7 @@ typedef struct {
/* 0x03 */ u8 behaviorType1; /* 0x03 */ u8 behaviorType1;
/* 0x04 */ s8 echo; /* 0x04 */ s8 echo;
/* 0x05 */ u8 lensMode; /* 0x05 */ u8 lensMode;
/* 0x08 */ MeshHeader* meshHeader; // original name: "ground_shape" /* 0x08 */ RoomShape* roomShape; // original name: "ground_shape"
/* 0x0C */ void* segment; /* 0x0C */ void* segment;
/* 0x10 */ char unk_10[0x4]; /* 0x10 */ char unk_10[0x4];
} Room; // size = 0x14 } Room; // size = 0x14
@ -1120,7 +1120,7 @@ typedef struct GameState {
/* 0x08 */ GameStateFunc destroy; // "cleanup" /* 0x08 */ GameStateFunc destroy; // "cleanup"
/* 0x0C */ GameStateFunc init; /* 0x0C */ GameStateFunc init;
/* 0x10 */ u32 size; /* 0x10 */ u32 size;
/* 0x14 */ Input input[4]; /* 0x14 */ Input input[MAXCONTROLLERS];
/* 0x74 */ TwoHeadArena tha; /* 0x74 */ TwoHeadArena tha;
/* 0x84 */ GameAlloc alloc; /* 0x84 */ GameAlloc alloc;
/* 0x98 */ u32 running; /* 0x98 */ u32 running;

View file

@ -220,7 +220,7 @@ typedef struct Actor {
/* 0x100 */ Vec3f prevPos; // World position from the previous update cycle /* 0x100 */ Vec3f prevPos; // World position from the previous update cycle
/* 0x10C */ u8 isTargeted; // Set to true if the actor is currently being targeted by the player /* 0x10C */ u8 isTargeted; // Set to true if the actor is currently being targeted by the player
/* 0x10D */ u8 targetPriority; // Lower values have higher priority. Resets to 0 when player stops targeting /* 0x10D */ u8 targetPriority; // Lower values have higher priority. Resets to 0 when player stops targeting
/* 0x10E */ u16 textId; // Text ID to pass to link/display when interacting with the actor /* 0x10E */ u16 textId; // Text ID to pass to player/display when interacting with the actor
/* 0x110 */ u16 freezeTimer; // Actor does not update when set. Timer decrements automatically /* 0x110 */ u16 freezeTimer; // Actor does not update when set. Timer decrements automatically
/* 0x112 */ u16 colorFilterParams; // Set color filter to red, blue, or white. Toggle opa or xlu /* 0x112 */ u16 colorFilterParams; // Set color filter to red, blue, or white. Toggle opa or xlu
/* 0x114 */ u8 colorFilterTimer; // A non-zero value enables the color filter. Decrements automatically /* 0x114 */ u8 colorFilterTimer; // A non-zero value enables the color filter. Decrements automatically

View file

@ -64,7 +64,7 @@ typedef struct {
/* 0x06 */ Vec3s rot; /* 0x06 */ Vec3s rot;
/* 0x0C */ s16 fov; /* 0x0C */ s16 fov;
/* 0x0E */ union { /* 0x0E */ union {
s16 jfifId; s16 roomImageOverrideBgCamIndex;
s16 timer; s16 timer;
s16 flags; s16 flags;
}; };

View file

@ -68,7 +68,7 @@ typedef enum {
/* 0x18 */ CAM_SET_PIVOT_IN_FRONT, // The camera used on Link's balcony in Kokiri forest. Data present in scene data for Deku Tree, GTG, Inside Ganon's Castle (TODO: may or may not be used) "CIRCLE3" /* 0x18 */ CAM_SET_PIVOT_IN_FRONT, // The camera used on Link's balcony in Kokiri forest. Data present in scene data for Deku Tree, GTG, Inside Ganon's Castle (TODO: may or may not be used) "CIRCLE3"
/* 0x19 */ CAM_SET_PREREND_FIXED, // Camera is fixed in position and rotation "PREREND0" /* 0x19 */ CAM_SET_PREREND_FIXED, // Camera is fixed in position and rotation "PREREND0"
/* 0x1A */ CAM_SET_PREREND_PIVOT, // Camera is fixed in position with fixed pitch, but is free to rotate in the yaw direction 360 degrees "PREREND1" /* 0x1A */ CAM_SET_PREREND_PIVOT, // Camera is fixed in position with fixed pitch, but is free to rotate in the yaw direction 360 degrees "PREREND1"
/* 0x1B */ CAM_SET_PREREND_SIDE_SCROLL, // Camera side-scrolls position to follow link. Only used in castle courtyard with the guards "PREREND3" /* 0x1B */ CAM_SET_PREREND_SIDE_SCROLL, // Camera side-scrolls position to follow the player. Only used in castle courtyard with the guards "PREREND3"
/* 0x1C */ CAM_SET_DOOR0, // Custom room door transitions, used in fire and royal family tomb /* 0x1C */ CAM_SET_DOOR0, // Custom room door transitions, used in fire and royal family tomb
/* 0x1D */ CAM_SET_DOORC, // Generic room door transitions, camera moves and follows player as the door is open and closed /* 0x1D */ CAM_SET_DOORC, // Generic room door transitions, camera moves and follows player as the door is open and closed
/* 0x1E */ CAM_SET_CRAWLSPACE, // Used in all crawlspaces "RAIL3" /* 0x1E */ CAM_SET_CRAWLSPACE, // Used in all crawlspaces "RAIL3"
@ -813,7 +813,7 @@ typedef struct {
/* 0x0 */ Vec3s rot; /* 0x0 */ Vec3s rot;
/* 0x6 */ s16 fov; /* 0x6 */ s16 fov;
/* 0x8 */ s16 updDirTimer; /* 0x8 */ s16 updDirTimer;
/* 0xA */ s16 jfifId; /* 0xA */ s16 roomImageOverrideBgCamIndex;
} Fixed3ReadWriteData; // size = 0xC } Fixed3ReadWriteData; // size = 0xC
typedef struct { typedef struct {

View file

@ -58,44 +58,44 @@ typedef struct {
/* 0x04 */ Vec3s* points; // Segment Address to the array of points /* 0x04 */ Vec3s* points; // Segment Address to the array of points
} Path; // size = 0x8 } Path; // size = 0x8
// Mesh headers // Room shapes
typedef enum { typedef enum {
/* 0 */ MESH_HEADER_TYPE_0, /* 0 */ ROOM_SHAPE_TYPE_NORMAL,
/* 1 */ MESH_HEADER_TYPE_1, /* 1 */ ROOM_SHAPE_TYPE_IMAGE,
/* 2 */ MESH_HEADER_TYPE_2, /* 2 */ ROOM_SHAPE_TYPE_CULLABLE,
/* 3 */ MESH_HEADER_TYPE_MAX /* 3 */ ROOM_SHAPE_TYPE_MAX
} MeshHeaderType; } RoomShapeType;
typedef struct { typedef struct {
/* 0x00 */ u8 type; /* 0x00 */ u8 type;
} MeshHeaderBase; // size = 0x01 } RoomShapeBase; // size = 0x01
typedef struct { typedef struct {
/* 0x00 */ Gfx* opa; /* 0x00 */ Gfx* opa;
/* 0x04 */ Gfx* xlu; /* 0x04 */ Gfx* xlu;
} MeshHeader01Entry; // size = 0x08 } RoomShapeDListsEntry; // size = 0x08
typedef struct { typedef struct {
/* 0x00 */ MeshHeaderBase base; /* 0x00 */ RoomShapeBase base;
/* 0x01 */ u8 numEntries; /* 0x01 */ u8 numEntries;
/* 0x04 */ MeshHeader01Entry* entries; /* 0x04 */ RoomShapeDListsEntry* entries;
/* 0x08 */ MeshHeader01Entry* entriesEnd; /* 0x08 */ RoomShapeDListsEntry* entriesEnd;
} MeshHeader0; // size = 0x0C } RoomShapeNormal; // size = 0x0C
typedef enum { typedef enum {
/* 1 */ MESH_HEADER1_FORMAT_SINGLE = 1, /* 1 */ ROOM_SHAPE_IMAGE_AMOUNT_SINGLE = 1,
/* 2 */ MESH_HEADER1_FORMAT_MULTI /* 2 */ ROOM_SHAPE_IMAGE_AMOUNT_MULTI
} MeshHeader1Format; } RoomShapeImageAmountType;
typedef struct { typedef struct {
/* 0x00 */ MeshHeaderBase base; /* 0x00 */ RoomShapeBase base;
/* 0x01 */ u8 format; // MeshHeader1Format /* 0x01 */ u8 amountType; // RoomShapeImageAmountType
/* 0x04 */ MeshHeader01Entry* entry; /* 0x04 */ RoomShapeDListsEntry* entry;
} MeshHeader1Base; // size = 0x08 } RoomShapeImageBase; // size = 0x08
typedef struct { typedef struct {
/* 0x00 */ MeshHeader1Base base; /* 0x00 */ RoomShapeImageBase base;
/* 0x08 */ void* source; /* 0x08 */ void* source;
/* 0x0C */ u32 unk_0C; /* 0x0C */ u32 unk_0C;
/* 0x10 */ void* tlut; /* 0x10 */ void* tlut;
@ -103,13 +103,13 @@ typedef struct {
/* 0x16 */ u16 height; /* 0x16 */ u16 height;
/* 0x18 */ u8 fmt; /* 0x18 */ u8 fmt;
/* 0x19 */ u8 siz; /* 0x19 */ u8 siz;
/* 0x1A */ u16 mode0; /* 0x1A */ u16 tlutMode;
/* 0x1C */ u16 tlutCount; /* 0x1C */ u16 tlutCount;
} MeshHeader1Single; // size = 0x20 } RoomShapeImageSingle; // size = 0x20
typedef struct { typedef struct {
/* 0x00 */ u16 unk_00; /* 0x00 */ u16 unk_00;
/* 0x02 */ u8 id; /* 0x02 */ u8 bgCamIndex; // for which bg cam index is this entry for
/* 0x04 */ void* source; /* 0x04 */ void* source;
/* 0x08 */ u32 unk_0C; /* 0x08 */ u32 unk_0C;
/* 0x0C */ void* tlut; /* 0x0C */ void* tlut;
@ -117,44 +117,52 @@ typedef struct {
/* 0x12 */ u16 height; /* 0x12 */ u16 height;
/* 0x14 */ u8 fmt; /* 0x14 */ u8 fmt;
/* 0x15 */ u8 siz; /* 0x15 */ u8 siz;
/* 0x16 */ u16 mode0; /* 0x16 */ u16 tlutMode;
/* 0x18 */ u16 tlutCount; /* 0x18 */ u16 tlutCount;
} BgImage; // size = 0x1C } RoomShapeImageMultiBgEntry; // size = 0x1C
typedef struct { typedef struct {
/* 0x00 */ MeshHeader1Base base; /* 0x00 */ RoomShapeImageBase base;
/* 0x08 */ u8 count; /* 0x08 */ u8 numBackgrounds;
/* 0x0C */ BgImage* list; /* 0x0C */ RoomShapeImageMultiBgEntry* backgrounds;
} MeshHeader1Multi; // size = 0x10 } RoomShapeImageMulti; // size = 0x10
typedef struct { typedef struct {
/* 0x00 */ Vec3s pos; /* 0x00 */ Vec3s boundsSphereCenter;
/* 0x06 */ s16 unk_06; /* 0x06 */ s16 boundsSphereRadius;
/* 0x08 */ Gfx* opa; /* 0x08 */ Gfx* opa;
/* 0x0C */ Gfx* xlu; /* 0x0C */ Gfx* xlu;
} MeshHeader2Entry; // size = 0x10 } RoomShapeCullableEntry; // size = 0x10
#define ROOM_SHAPE_CULLABLE_MAX_ENTRIES 64
typedef struct { typedef struct {
/* 0x00 */ MeshHeaderBase base; /* 0x00 */ RoomShapeBase base;
/* 0x01 */ u8 numEntries; /* 0x01 */ u8 numEntries;
/* 0x04 */ MeshHeader2Entry* entries; /* 0x04 */ RoomShapeCullableEntry* entries;
/* 0x08 */ MeshHeader2Entry* entriesEnd; /* 0x08 */ RoomShapeCullableEntry* entriesEnd;
} MeshHeader2; // size = 0x0C } RoomShapeCullable; // size = 0x0C
typedef union { typedef union {
MeshHeaderBase base; RoomShapeBase base;
MeshHeader0 meshHeader0; RoomShapeNormal normal;
MeshHeader1Base meshHeader1Base; union {
MeshHeader1Single meshHeader1Single; RoomShapeImageBase base;
MeshHeader1Multi meshHeader1Multi; RoomShapeImageSingle single;
MeshHeader2 meshHeader2; RoomShapeImageMulti multi;
} MeshHeader; // "Ground Shape" } image;
RoomShapeCullable cullable;
} RoomShape; // "Ground Shape"
// TODO update ZAPD // TODO update ZAPD
typedef MeshHeader01Entry PolygonDlist; typedef RoomShapeDListsEntry PolygonDlist;
typedef MeshHeader0 PolygonType0; typedef RoomShapeNormal PolygonType0;
typedef MeshHeader2Entry PolygonDlist2; typedef RoomShapeImageSingle MeshHeader1Single;
typedef MeshHeader2 PolygonType2; typedef RoomShapeImageMultiBgEntry BgImage;
typedef RoomShapeImageMulti MeshHeader1Multi;
typedef RoomShapeCullableEntry PolygonDlist2;
typedef RoomShapeCullable PolygonType2;
#define SCENE_CMD_MESH SCENE_CMD_ROOM_SHAPE
#define ROOM_DRAW_OPA (1 << 0) #define ROOM_DRAW_OPA (1 << 0)
#define ROOM_DRAW_XLU (1 << 1) #define ROOM_DRAW_XLU (1 << 1)
@ -228,7 +236,7 @@ typedef struct {
typedef struct { typedef struct {
/* 0x00 */ u8 code; /* 0x00 */ u8 code;
/* 0x01 */ u8 data1; /* 0x01 */ u8 data1;
/* 0x04 */ MeshHeaderBase* data; /* 0x04 */ RoomShapeBase* data;
} SCmdMesh; } SCmdMesh;
typedef struct { typedef struct {
@ -474,7 +482,7 @@ typedef enum {
/* 0x07 */ SCENE_CMD_ID_SPECIAL_FILES, /* 0x07 */ SCENE_CMD_ID_SPECIAL_FILES,
/* 0x08 */ SCENE_CMD_ID_ROOM_BEHAVIOR, /* 0x08 */ SCENE_CMD_ID_ROOM_BEHAVIOR,
/* 0x09 */ SCENE_CMD_ID_UNDEFINED_9, /* 0x09 */ SCENE_CMD_ID_UNDEFINED_9,
/* 0x0A */ SCENE_CMD_ID_MESH_HEADER, /* 0x0A */ SCENE_CMD_ID_ROOM_SHAPE,
/* 0x0B */ SCENE_CMD_ID_OBJECT_LIST, /* 0x0B */ SCENE_CMD_ID_OBJECT_LIST,
/* 0x0C */ SCENE_CMD_ID_LIGHT_LIST, /* 0x0C */ SCENE_CMD_ID_LIGHT_LIST,
/* 0x0D */ SCENE_CMD_ID_PATH_LIST, /* 0x0D */ SCENE_CMD_ID_PATH_LIST,
@ -524,8 +532,8 @@ typedef enum {
#define SCENE_CMD_UNK_09() \ #define SCENE_CMD_UNK_09() \
{ SCENE_CMD_ID_UNDEFINED_9, 0, CMD_W(0) } { SCENE_CMD_ID_UNDEFINED_9, 0, CMD_W(0) }
#define SCENE_CMD_MESH(meshHeader) \ #define SCENE_CMD_ROOM_SHAPE(roomShape) \
{ SCENE_CMD_ID_MESH_HEADER, 0, CMD_PTR(meshHeader) } { SCENE_CMD_ID_ROOM_SHAPE, 0, CMD_PTR(roomShape) }
#define SCENE_CMD_OBJECT_LIST(numObjects, objectList) \ #define SCENE_CMD_OBJECT_LIST(numObjects, objectList) \
{ SCENE_CMD_ID_OBJECT_LIST, numObjects, CMD_PTR(objectList) } { SCENE_CMD_ID_OBJECT_LIST, numObjects, CMD_PTR(objectList) }

View file

@ -163,7 +163,7 @@ void __osMallocCleanup(Arena* arena) {
bzero(arena, sizeof(*arena)); bzero(arena, sizeof(*arena));
} }
u8 __osMallocIsInitalized(Arena* arena) { u8 __osMallocIsInitialized(Arena* arena) {
return arena->isInit; return arena->isInit;
} }
@ -682,8 +682,8 @@ void __osDisplayArena(Arena* arena) {
ArenaNode* iter; ArenaNode* iter;
ArenaNode* next; ArenaNode* next;
if (!__osMallocIsInitalized(arena)) { if (!__osMallocIsInitialized(arena)) {
osSyncPrintf("アリーナは初期化されていません\n"); // "Arena is not initalized" osSyncPrintf("アリーナは初期化されていません\n"); // "Arena is not initialized"
return; return;
} }
@ -746,7 +746,7 @@ void ArenaImpl_FaultClient(Arena* arena) {
ArenaNode* next; ArenaNode* next;
FaultDrawer_Printf("ARENA INFO (0x%08x)\n", arena); FaultDrawer_Printf("ARENA INFO (0x%08x)\n", arena);
if (!__osMallocIsInitalized(arena)) { if (!__osMallocIsInitialized(arena)) {
FaultDrawer_Printf("Arena is uninitalized\n", arena); FaultDrawer_Printf("Arena is uninitalized\n", arena);
return; return;
} }

View file

@ -1059,7 +1059,7 @@ void AudioHeap_Init(void) {
AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize); AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize);
AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes); AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes);
// Initalize Loads // Initialize Loads
gAudioContext.preloadSampleStackTop = 0; gAudioContext.preloadSampleStackTop = 0;
AudioLoad_InitSlowLoads(); AudioLoad_InitSlowLoads();
AudioLoad_InitScriptLoads(); AudioLoad_InitScriptLoads();

View file

@ -70,7 +70,7 @@ s32 sAudioLoadPad2[4]; // double file padding?
DmaHandler sDmaHandler = osEPiStartDma; DmaHandler sDmaHandler = osEPiStartDma;
void* sUnusedHandler = NULL; void* sUnusedHandler = NULL;
s32 gAudioContextInitalized = false; s32 gAudioContextInitialized = false;
void AudioLoad_DecreaseSampleDmaTtls(void) { void AudioLoad_DecreaseSampleDmaTtls(void) {
u32 i; u32 i;
@ -1235,7 +1235,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
} }
AudioHeap_InitPool(&gAudioContext.permanentPool, ramAddr, gAudioHeapInitSizes.permanentPoolSize); AudioHeap_InitPool(&gAudioContext.permanentPool, ramAddr, gAudioHeapInitSizes.permanentPoolSize);
gAudioContextInitalized = true; gAudioContextInitialized = true;
osSendMesg(gAudioContext.taskStartQueueP, (OSMesg)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); osSendMesg(gAudioContext.taskStartQueueP, (OSMesg)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK);
} }

View file

@ -1266,7 +1266,7 @@ Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
} }
/** /**
* The Haas Effect gives directionality to sound by appling a small (< 35ms) delay to either the left or right channel. * The Haas Effect gives directionality to sound by applying a small (< 35ms) delay to either the left or right channel.
* The delay is small enough that the sound is still perceived as one sound, but the channel that is not delayed will * The delay is small enough that the sound is still perceived as one sound, but the channel that is not delayed will
* reach our ear first and give a sense of directionality. The sound is directed towards the opposite side of the delay. * reach our ear first and give a sense of directionality. The sound is directed towards the opposite side of the delay.
*/ */

View file

@ -573,7 +573,7 @@ s32 func_800E5F88(s32 resetPreloadID) {
void Audio_PreNMIInternal(void) { void Audio_PreNMIInternal(void) {
gAudioContext.resetTimer = 1; gAudioContext.resetTimer = 1;
if (gAudioContextInitalized) { if (gAudioContextInitialized) {
func_800E5F88(0); func_800E5F88(0);
gAudioContext.resetStatus = 0; gAudioContext.resetStatus = 0;
} }

View file

@ -1267,7 +1267,8 @@ OcarinaNote sScarecrowsLongSongSecondNote;
u8 sAudioHasMalonBgm; u8 sAudioHasMalonBgm;
f32 sAudioMalonBgmDist; f32 sAudioMalonBgmDist;
void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode); void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest);
void Audio_StepFreqLerp(FreqLerp* lerp); void Audio_StepFreqLerp(FreqLerp* lerp);
void func_800F56A8(void); void func_800F56A8(void);
void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId); void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId);
@ -1292,11 +1293,11 @@ void AudioOcarina_SetCustomButtonMapping(u8 useCustom) {
} }
void AudioOcarina_ReadControllerInput(void) { void AudioOcarina_ReadControllerInput(void) {
Input inputs[4]; Input inputs[MAXCONTROLLERS];
Input* input = &inputs[0]; Input* input = &inputs[0];
u32 ocarinaInputButtonPrev = sOcarinaInputButtonCur; u32 ocarinaInputButtonPrev = sOcarinaInputButtonCur;
PadMgr_RequestPadData(&gPadMgr, inputs, 0); PadMgr_RequestPadData(&gPadMgr, inputs, false);
sOcarinaInputButtonCur = input->cur.button; sOcarinaInputButtonCur = input->cur.button;
sOcarinaInputButtonPrev = ocarinaInputButtonPrev; sOcarinaInputButtonPrev = ocarinaInputButtonPrev;
sOcarinaInputStickAdj.x = input->rel.stick_x; sOcarinaInputStickAdj.x = input->rel.stick_x;
@ -2371,10 +2372,10 @@ u8 sAudioNatureFailed = false;
u8 sPeakNumNotes = 0; u8 sPeakNumNotes = 0;
void AudioDebug_SetInput(void) { void AudioDebug_SetInput(void) {
Input inputs[4]; Input inputs[MAXCONTROLLERS];
u32 btn; u32 btn;
PadMgr_RequestPadData(&gPadMgr, inputs, 0); PadMgr_RequestPadData(&gPadMgr, inputs, false);
btn = inputs[3].cur.button; btn = inputs[3].cur.button;
sDebugPadHold = btn & 0xFFFF; sDebugPadHold = btn & 0xFFFF;
sDebugPadPress = (btn ^ sDebugPadBtnLast) & btn; sDebugPadPress = (btn ^ sDebugPadBtnLast) & btn;
@ -4854,7 +4855,7 @@ void Audio_SetSequenceMode(u8 seqMode) {
sPrevSeqMode = seqMode + 0x80; sPrevSeqMode = seqMode + 0x80;
} }
} else { } else {
// Hyrule Field will play slightly different bgm music depending on whether player is standing // Hyrule Field will play slightly different background music depending on whether player is standing
// still or moving. This is the logic to determine the transition between those two states // still or moving. This is the logic to determine the transition between those two states
if (seqMode == SEQ_MODE_DEFAULT) { if (seqMode == SEQ_MODE_DEFAULT) {
if (sPrevSeqMode == SEQ_MODE_STILL) { if (sPrevSeqMode == SEQ_MODE_STILL) {

View file

@ -1,6 +1,8 @@
#include "ultra64.h" #include "ultra64.h"
#include "global.h" #include "global.h"
#define DBCAM_CONTROLLER_PORT 2
static PlayState* sPlay; static PlayState* sPlay;
// TODO: cleanup these arrays and UB access // TODO: cleanup these arrays and UB access
@ -346,7 +348,7 @@ s32 func_800B4370(DbCamera* dbCamera, s16 idx, Camera* cam) {
void func_800B44E0(DbCamera* dbCamera, Camera* cam) { void func_800B44E0(DbCamera* dbCamera, Camera* cam) {
s32 i; s32 i;
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CRIGHT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CRIGHT)) {
sDbCamAnim.keyframe = 0; sDbCamAnim.keyframe = 0;
sDbCamAnim.unk_0A = 1; sDbCamAnim.unk_0A = 1;
sDbCamAnim.curFrame = 0.0f; sDbCamAnim.curFrame = 0.0f;
@ -597,7 +599,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
sp80 = &dbCamera->eye; sp80 = &dbCamera->eye;
sp7C = &dbCamera->at; sp7C = &dbCamera->at;
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_Z)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_Z)) {
dbCamera->unk_00++; dbCamera->unk_00++;
dbCamera->unk_00 %= 3; dbCamera->unk_00 %= 3;
dbCamera->unk_38 = 1; dbCamera->unk_38 = 1;
@ -688,7 +690,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
dbCamera->unk_3C = D_80161140; dbCamera->unk_3C = D_80161140;
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_B | BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_B | BTN_L)) {
sp104.r += temp_f2; sp104.r += temp_f2;
if (sp104.r > 30000.0f) { if (sp104.r > 30000.0f) {
@ -702,7 +704,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
dbCamera->unk_40 = 7; dbCamera->unk_40 = 7;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_B)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_B)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
if (!D_80161144) { if (!D_80161144) {
@ -719,7 +721,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 0xB; dbCamera->unk_40 = 0xB;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_A | BTN_L)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_A | BTN_L)) {
sp104.r -= temp_f2; sp104.r -= temp_f2;
if (sp104.r < 10.0f) { if (sp104.r < 10.0f) {
sp104.r = 10.0f; sp104.r = 10.0f;
@ -730,7 +732,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 8; dbCamera->unk_40 = 8;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_A)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_A)) {
spFC = sp104; spFC = sp104;
spFC.r = -temp_f2; spFC.r = -temp_f2;
if (!D_80161144) { if (!D_80161144) {
@ -752,7 +754,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_40 = -1; dbCamera->unk_40 = -1;
} }
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DDOWN | BTN_L)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DDOWN | BTN_L)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
spFC.pitch = 0; spFC.pitch = 0;
@ -770,7 +772,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 1; dbCamera->unk_40 = 1;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DUP | BTN_L)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DUP | BTN_L)) {
spFC = sp104; spFC = sp104;
spFC.r = -temp_f2; spFC.r = -temp_f2;
spFC.pitch = 0; spFC.pitch = 0;
@ -787,7 +789,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 2; dbCamera->unk_40 = 2;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DUP)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DUP)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
spFC.pitch = 0x3FFF; spFC.pitch = 0x3FFF;
@ -803,7 +805,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 3; dbCamera->unk_40 = 3;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DDOWN)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DDOWN)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
spFC.pitch = -0x3FFF; spFC.pitch = -0x3FFF;
@ -819,8 +821,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 4; dbCamera->unk_40 = 4;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, (BTN_DRIGHT | BTN_L)) || } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, (BTN_DRIGHT | BTN_L)) ||
CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DRIGHT)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DRIGHT)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
spFC.pitch = 0; spFC.pitch = 0;
@ -837,8 +839,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 5; dbCamera->unk_40 = 5;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, (BTN_DLEFT | BTN_L)) || } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, (BTN_DLEFT | BTN_L)) ||
CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DLEFT)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DLEFT)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
spFC.pitch = 0; spFC.pitch = 0;
@ -855,7 +857,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 6; dbCamera->unk_40 = 6;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_B | BTN_L)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_B | BTN_L)) {
sp104.r = sp104.r + temp_f2; sp104.r = sp104.r + temp_f2;
if (sp104.r > 30000.0f) { if (sp104.r > 30000.0f) {
sp104.r = 30000.0f; sp104.r = 30000.0f;
@ -866,7 +868,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 7; dbCamera->unk_40 = 7;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_B)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_B)) {
spFC = sp104; spFC = sp104;
spFC.r = temp_f2; spFC.r = temp_f2;
if (!D_80161144) { if (!D_80161144) {
@ -883,7 +885,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 0xB; dbCamera->unk_40 = 0xB;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_A | BTN_L)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_A | BTN_L)) {
sp104.r -= temp_f2; sp104.r -= temp_f2;
if (sp104.r < 10.0f) { if (sp104.r < 10.0f) {
@ -895,7 +897,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_44 = 0; dbCamera->unk_44 = 0;
} }
dbCamera->unk_40 = 8; dbCamera->unk_40 = 8;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_A)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_A)) {
spFC = sp104; spFC = sp104;
spFC.r = -temp_f2; spFC.r = -temp_f2;
if (!D_80161144) { if (!D_80161144) {
@ -917,7 +919,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->unk_40 = -1; dbCamera->unk_40 = -1;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_R)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_R)) {
if (dbCamera->unk_00 == 0) { if (dbCamera->unk_00 == 0) {
dbCamera->sub.unk_104A = cam->inputDir; dbCamera->sub.unk_104A = cam->inputDir;
*sp7C = cam->at; *sp7C = cam->at;
@ -932,13 +934,13 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
func_800B41DC(dbCamera, dbCamera->sub.unkIdx, cam); func_800B41DC(dbCamera, dbCamera->sub.unkIdx, cam);
} else { } else {
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_R) && if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_R) &&
CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.nPoints = dbCamera->sub.unkIdx + 1; dbCamera->sub.nPoints = dbCamera->sub.unkIdx + 1;
func_800B4088(dbCamera, cam); func_800B4088(dbCamera, cam);
} else if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_R)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_R)) {
if (dbCamera->sub.unkIdx == 0x80) { if (dbCamera->sub.unkIdx == 0x80) {
Audio_PlaySfxGeneral(NA_SE_SY_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -955,8 +957,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
} }
} else { } else {
temp_f0_5 = sPlay->state.input[2].rel.stick_y; temp_f0_5 = sPlay->state.input[DBCAM_CONTROLLER_PORT].rel.stick_y;
temp_f2_2 = sPlay->state.input[2].rel.stick_x; temp_f2_2 = sPlay->state.input[DBCAM_CONTROLLER_PORT].rel.stick_x;
pitch = CAM_DEG_TO_BINANG((SQ(temp_f0_5) / 600.0f) * 0.8f); pitch = CAM_DEG_TO_BINANG((SQ(temp_f0_5) / 600.0f) * 0.8f);
yaw = CAM_DEG_TO_BINANG((SQ(temp_f2_2) / 600.0f) * 0.8f); yaw = CAM_DEG_TO_BINANG((SQ(temp_f2_2) / 600.0f) * 0.8f);
if (!D_80161144) { if (!D_80161144) {
@ -977,7 +979,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
DbCamera_CalcUpFromPitchYawRoll(&dbCamera->unk_1C, spF4.pitch, spF4.yaw, DbCamera_CalcUpFromPitchYawRoll(&dbCamera->unk_1C, spF4.pitch, spF4.yaw,
CAM_DEG_TO_BINANG(dbCamera->rollDegrees)); CAM_DEG_TO_BINANG(dbCamera->rollDegrees));
if (dbCamera->unk_00 == 1) { if (dbCamera->unk_00 == 1) {
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_CRIGHT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_CRIGHT)) {
cam->inputDir = dbCamera->sub.unk_104A; cam->inputDir = dbCamera->sub.unk_104A;
new_var2 = OLib_Vec3fDist(&cam->at, &cam->eye); new_var2 = OLib_Vec3fDist(&cam->at, &cam->eye);
cam->at = *sp7C; cam->at = *sp7C;
@ -991,12 +993,12 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
if (dbCamera->unk_00 == 1) { if (dbCamera->unk_00 == 1) {
OREG(0) = 8; OREG(0) = 8;
func_8006376C(0xC, 5, 0, D_8012CEF4); func_8006376C(0xC, 5, 0, D_8012CEF4);
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_CRIGHT) && if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_CRIGHT) &&
!CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { !CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
func_800B44E0(dbCamera, cam); func_800B44E0(dbCamera, cam);
} else { } else {
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CRIGHT) && if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CRIGHT) &&
CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
Audio_PlaySfxGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** start here *** */\n@@@\n"); osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** start here *** */\n@@@\n");
@ -1006,14 +1008,14 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
osSyncPrintf("@@@static short nFrames = %d;\n@@@\n", dbCamera->sub.nFrames); osSyncPrintf("@@@static short nFrames = %d;\n@@@\n", dbCamera->sub.nFrames);
osSyncPrintf("@@@static short Mode = %d;\n@@@\n", dbCamera->sub.mode); osSyncPrintf("@@@static short Mode = %d;\n@@@\n", dbCamera->sub.mode);
osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** finish! *** */\n@@@\n"); osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** finish! *** */\n@@@\n");
} else if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CLEFT)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CLEFT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.unk_08 = (dbCamera->sub.unk_08 + 1) % 3; dbCamera->sub.unk_08 = (dbCamera->sub.unk_08 + 1) % 3;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CUP) && if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CUP) &&
CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.unkIdx > 0) { if (dbCamera->sub.unkIdx > 0) {
@ -1022,7 +1024,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->sub.unkIdx = dbCamera->sub.nPoints - 1; dbCamera->sub.unkIdx = dbCamera->sub.nPoints - 1;
} }
} else { } else {
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CUP)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CUP)) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.unkIdx > 0) { if (dbCamera->sub.unkIdx > 0) {
@ -1043,8 +1045,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L) && if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L) &&
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CDOWN)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CDOWN)) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) { if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) {
@ -1053,7 +1055,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->sub.unkIdx = 0; dbCamera->sub.unkIdx = 0;
} }
} else { } else {
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CDOWN)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CDOWN)) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) { if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) {
@ -1123,7 +1125,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
break; break;
case 1: case 1:
dbCamera->unk_3C = true; dbCamera->unk_3C = true;
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DUP)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DUP)) {
Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.unk_0A == 0) { if (dbCamera->sub.unk_0A == 0) {
@ -1132,7 +1134,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->sub.unk_0A--; dbCamera->sub.unk_0A--;
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DDOWN)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DDOWN)) {
Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.unk_0A == 5) { if (dbCamera->sub.unk_0A == 5) {
@ -1141,12 +1143,12 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->sub.unk_0A++; dbCamera->sub.unk_0A++;
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DLEFT)) {
Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
switch (dbCamera->sub.unk_0A) { switch (dbCamera->sub.unk_0A) {
case 1: case 1:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame -= 5; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame -= 5;
} else { } else {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame--; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame--;
@ -1178,7 +1180,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->sub.unk_0C = false; dbCamera->sub.unk_0C = false;
break; break;
case 2: case 2:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll -= 5; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll -= 5;
dbCamera->roll = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll; dbCamera->roll = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll;
} else { } else {
@ -1190,7 +1192,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DLEFT)) {
if ((D_8012D10C++ % 5) == 0) { if ((D_8012D10C++ % 5) == 0) {
Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -1198,7 +1200,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
switch (dbCamera->sub.unk_0A) { switch (dbCamera->sub.unk_0A) {
case 0: case 0:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle -= 1.0f; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle -= 1.0f;
dbCamera->fov = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle; dbCamera->fov = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle;
} else { } else {
@ -1207,7 +1209,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
break; break;
case 5: case 5:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.nFrames -= 10; dbCamera->sub.nFrames -= 10;
} else { } else {
dbCamera->sub.nFrames--; dbCamera->sub.nFrames--;
@ -1229,13 +1231,13 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DRIGHT)) {
Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
switch (dbCamera->sub.unk_0A) { switch (dbCamera->sub.unk_0A) {
case 1: case 1:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame += 5; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame += 5;
} else { } else {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame++; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame++;
@ -1267,7 +1269,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->sub.unk_0C = true; dbCamera->sub.unk_0C = true;
break; break;
case 2: case 2:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll += 5; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll += 5;
dbCamera->roll = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll; dbCamera->roll = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll;
} else { } else {
@ -1278,7 +1280,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
break; break;
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DRIGHT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_DRIGHT)) {
if ((D_8012D10C++ % 5) == 0) { if ((D_8012D10C++ % 5) == 0) {
Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -1286,7 +1288,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
switch (dbCamera->sub.unk_0A) { switch (dbCamera->sub.unk_0A) {
case 0: case 0:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle += 1.0f; dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle += 1.0f;
dbCamera->fov = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle; dbCamera->fov = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle;
} else { } else {
@ -1295,7 +1297,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
} }
break; break;
case 5: case 5:
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
dbCamera->sub.nFrames += 10; dbCamera->sub.nFrames += 10;
} else { } else {
dbCamera->sub.nFrames++; dbCamera->sub.nFrames++;
@ -1432,7 +1434,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) {
dbCamera->roll = 0; dbCamera->roll = 0;
dbCamera->fov = 60.0f; dbCamera->fov = 60.0f;
dbCamera->rollDegrees = dbCamera->roll * 1.40625f; dbCamera->rollDegrees = dbCamera->roll * 1.40625f;
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CLEFT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CLEFT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->unk_78 = (dbCamera->unk_78 + 1) % 3; dbCamera->unk_78 = (dbCamera->unk_78 + 1) % 3;
@ -1603,7 +1605,7 @@ s32 DbCamera_LoadCallback(char* c) {
} }
} }
if (!Mempak_Read(2, *c, sDbCameraCuts, 0, sizeof(sDbCameraCuts))) { if (!Mempak_Read(DBCAM_CONTROLLER_PORT, *c, sDbCameraCuts, 0, sizeof(sDbCameraCuts))) {
return false; return false;
} }
@ -1618,7 +1620,7 @@ s32 DbCamera_LoadCallback(char* c) {
osSyncPrintf("%s: %d: デバッグカメラ メモリ確保失敗!!\n", "../db_camera.c", 2847); osSyncPrintf("%s: %d: デバッグカメラ メモリ確保失敗!!\n", "../db_camera.c", 2847);
return false; return false;
} }
if (!Mempak_Read(2, *c, sDbCameraCuts[i].lookAt, off, ALIGN32(size))) { if (!Mempak_Read(DBCAM_CONTROLLER_PORT, *c, sDbCameraCuts[i].lookAt, off, ALIGN32(size))) {
return false; return false;
} }
off += ALIGN32(size); off += ALIGN32(size);
@ -1629,7 +1631,7 @@ s32 DbCamera_LoadCallback(char* c) {
osSyncPrintf("%s: %d: デバッグカメラ メモリ確保失敗!!\n", "../db_camera.c", 2858); osSyncPrintf("%s: %d: デバッグカメラ メモリ確保失敗!!\n", "../db_camera.c", 2858);
return false; return false;
} }
if (!Mempak_Read(2, *c, sDbCameraCuts[i].position, off, ALIGN32(size))) { if (!Mempak_Read(DBCAM_CONTROLLER_PORT, *c, sDbCameraCuts[i].position, off, ALIGN32(size))) {
return false; return false;
} }
off += ALIGN32(size); off += ALIGN32(size);
@ -1649,16 +1651,16 @@ s32 DbCamera_SaveCallback(char* c) {
s32 size; s32 size;
s32 i; s32 i;
ret = Mempak_GetFileSize(2, *c); ret = Mempak_GetFileSize(DBCAM_CONTROLLER_PORT, *c);
freeSize = Mempak_GetFreeBytes(2); freeSize = Mempak_GetFreeBytes(DBCAM_CONTROLLER_PORT);
if ((u32)sAllocSize < (freeSize + ret)) { if ((u32)sAllocSize < (freeSize + ret)) {
if (!Mempak_Alloc(2, c, sAllocSize)) { if (!Mempak_Alloc(DBCAM_CONTROLLER_PORT, c, sAllocSize)) {
return false; return false;
} }
if (!Mempak_Write(2, *c, sDbCameraCuts, 0, sizeof(sDbCameraCuts))) { if (!Mempak_Write(DBCAM_CONTROLLER_PORT, *c, sDbCameraCuts, 0, sizeof(sDbCameraCuts))) {
Mempak_DeleteFile(2, *c); Mempak_DeleteFile(DBCAM_CONTROLLER_PORT, *c);
return false; return false;
} }
@ -1667,13 +1669,13 @@ s32 DbCamera_SaveCallback(char* c) {
if (sDbCameraCuts[i].letter != '?') { if (sDbCameraCuts[i].letter != '?') {
size = sDbCameraCuts[i].nPoints * sizeof(CutsceneCameraPoint); size = sDbCameraCuts[i].nPoints * sizeof(CutsceneCameraPoint);
ret = Mempak_Write(2, *c, sDbCameraCuts[i].lookAt, off, ALIGN32(size)); ret = Mempak_Write(DBCAM_CONTROLLER_PORT, *c, sDbCameraCuts[i].lookAt, off, ALIGN32(size));
if (!ret) { if (!ret) {
break; break;
} }
off += ALIGN32(size); off += ALIGN32(size);
ret = Mempak_Write(2, *c, sDbCameraCuts[i].position, off, ALIGN32(size)); ret = Mempak_Write(DBCAM_CONTROLLER_PORT, *c, sDbCameraCuts[i].position, off, ALIGN32(size));
if (!ret) { if (!ret) {
break; break;
} }
@ -1686,7 +1688,7 @@ s32 DbCamera_SaveCallback(char* c) {
if (ret) { if (ret) {
return *c; return *c;
} else { } else {
Mempak_DeleteFile(2, *c); Mempak_DeleteFile(DBCAM_CONTROLLER_PORT, *c);
return false; return false;
} }
} }
@ -1695,7 +1697,7 @@ s32 DbCamera_SaveCallback(char* c) {
} }
s32 DbCamera_ClearCallback(char* c) { s32 DbCamera_ClearCallback(char* c) {
return Mempak_DeleteFile(2, *c); return Mempak_DeleteFile(DBCAM_CONTROLLER_PORT, *c);
} }
void DbCamera_DrawSlotLetters(char* str, s16 y, s16 x, s32 colorIndex) { void DbCamera_DrawSlotLetters(char* str, s16 y, s16 x, s32 colorIndex) {
@ -1861,8 +1863,8 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
case DEMO_CTRL_MENU(ACTION_LOAD, MENU_INFO): case DEMO_CTRL_MENU(ACTION_LOAD, MENU_INFO):
case DEMO_CTRL_MENU(ACTION_CLEAR, MENU_INFO): { case DEMO_CTRL_MENU(ACTION_CLEAR, MENU_INFO): {
if ((1 << sCurFileIdx) & sMempakFiles) { if ((1 << sCurFileIdx) & sMempakFiles) {
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DLEFT) || if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DLEFT) ||
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DRIGHT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlToggleSwitch ^= 1; dbCamera->sub.demoCtrlToggleSwitch ^= 1;
@ -1875,7 +1877,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
func_8006376C(0x11, 8, dbCamera->sub.demoCtrlToggleSwitch ? 4 : 7, D_8012CF94); func_8006376C(0x11, 8, dbCamera->sub.demoCtrlToggleSwitch ? 4 : 7, D_8012CF94);
func_8006376C(0x15, 8, dbCamera->sub.demoCtrlToggleSwitch ? 7 : 4, D_8012CF98); func_8006376C(0x15, 8, dbCamera->sub.demoCtrlToggleSwitch ? 7 : 4, D_8012CF98);
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_A)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_A)) {
if (dbCamera->sub.demoCtrlToggleSwitch == 0) { if (dbCamera->sub.demoCtrlToggleSwitch == 0) {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -1897,7 +1899,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
func_8006376C(0xD, 9, dbCamera->sub.demoCtrlToggleSwitch ? 1 : 6, "PRESS B BUTTON"); func_8006376C(0xD, 9, dbCamera->sub.demoCtrlToggleSwitch ? 1 : 6, "PRESS B BUTTON");
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_B)) {
Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlMenu = 0; dbCamera->sub.demoCtrlMenu = 0;
@ -1933,8 +1935,8 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
func_8006376C(0x17, 7, 5, D_8012CFA4); func_8006376C(0x17, 7, 5, D_8012CFA4);
func_8006376C(0xD, 9, (dbCamera->sub.demoCtrlToggleSwitch != 0) ? 1 : 6, "PRESS B BUTTON"); func_8006376C(0xD, 9, (dbCamera->sub.demoCtrlToggleSwitch != 0) ? 1 : 6, "PRESS B BUTTON");
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_A) || if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_A) ||
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_B)) {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (dbCamera->sub.demoCtrlMenu == DEMO_CTRL_MENU(ACTION_LOAD, MENU_SUCCESS)) { if (dbCamera->sub.demoCtrlMenu == DEMO_CTRL_MENU(ACTION_LOAD, MENU_SUCCESS)) {
@ -1956,8 +1958,8 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
func_8006376C(0x17, 7, 5, D_8012CFA4); func_8006376C(0x17, 7, 5, D_8012CFA4);
func_8006376C(0xD, 9, (dbCamera->sub.demoCtrlToggleSwitch != 0) ? 1 : 6, "PRESS B BUTTON"); func_8006376C(0xD, 9, (dbCamera->sub.demoCtrlToggleSwitch != 0) ? 1 : 6, "PRESS B BUTTON");
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_A) || if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_A) ||
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_B)) {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlMenu -= 9; dbCamera->sub.demoCtrlMenu -= 9;
@ -1970,12 +1972,12 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
goto block_1; goto block_1;
default: { default: {
if (Mempak_Init(2)) { if (Mempak_Init(DBCAM_CONTROLLER_PORT)) {
sMempakFiles = Mempak_FindFile(2, 'A', 'E'); sMempakFiles = Mempak_FindFile(DBCAM_CONTROLLER_PORT, 'A', 'E');
dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_CALLBACK); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_CALLBACK);
DbCamera_CalcMempakAllocSize(); DbCamera_CalcMempakAllocSize();
if ((1 << sCurFileIdx) & sMempakFiles) { if ((1 << sCurFileIdx) & sMempakFiles) {
sMempakFilesize = Mempak_GetFileSize(2, sCurFileIdx + 'A'); sMempakFilesize = Mempak_GetFileSize(DBCAM_CONTROLLER_PORT, sCurFileIdx + 'A');
dbCamera->sub.demoCtrlActionIdx = ACTION_LOAD; dbCamera->sub.demoCtrlActionIdx = ACTION_LOAD;
} else { } else {
sMempakFilesize = 0; sMempakFilesize = 0;
@ -1992,7 +1994,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
sp74[i * 2 + 0] = '-'; sp74[i * 2 + 0] = '-';
sp74[i * 2 + 1] = '\0'; sp74[i * 2 + 1] = '\0';
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DRIGHT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (sCurFileIdx >= 4) { if (sCurFileIdx >= 4) {
@ -2002,14 +2004,14 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
} }
if ((1 << sCurFileIdx) & sMempakFiles) { if ((1 << sCurFileIdx) & sMempakFiles) {
sMempakFilesize = Mempak_GetFileSize(2, sCurFileIdx + 'A'); sMempakFilesize = Mempak_GetFileSize(DBCAM_CONTROLLER_PORT, sCurFileIdx + 'A');
dbCamera->sub.demoCtrlActionIdx = ACTION_LOAD; dbCamera->sub.demoCtrlActionIdx = ACTION_LOAD;
} else { } else {
sMempakFilesize = 0; sMempakFilesize = 0;
dbCamera->sub.demoCtrlActionIdx = ACTION_SAVE; dbCamera->sub.demoCtrlActionIdx = ACTION_SAVE;
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DLEFT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (sCurFileIdx <= 0) { if (sCurFileIdx <= 0) {
@ -2019,7 +2021,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
} }
if ((1 << sCurFileIdx) & sMempakFiles) { if ((1 << sCurFileIdx) & sMempakFiles) {
sMempakFilesize = Mempak_GetFileSize(2, sCurFileIdx + 'A'); sMempakFilesize = Mempak_GetFileSize(DBCAM_CONTROLLER_PORT, sCurFileIdx + 'A');
dbCamera->sub.demoCtrlActionIdx = ACTION_LOAD; dbCamera->sub.demoCtrlActionIdx = ACTION_LOAD;
} else { } else {
sMempakFilesize = 0; sMempakFilesize = 0;
@ -2034,7 +2036,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
DbCamera_SetTextValue(DbCamera_GetMempakAllocSize(), sp74, 6); DbCamera_SetTextValue(DbCamera_GetMempakAllocSize(), sp74, 6);
func_8006376C(0xD, 9, 6, D_8012CF78); // NEED BYTE func_8006376C(0xD, 9, 6, D_8012CF78); // NEED BYTE
func_8006376C(0x11, 9, 4, sp74); func_8006376C(0x11, 9, 4, sp74);
DbCamera_SetTextValue(Mempak_GetFreeBytes(2), sp74, 6); DbCamera_SetTextValue(Mempak_GetFreeBytes(DBCAM_CONTROLLER_PORT), sp74, 6);
func_8006376C(0xD, 0xA, 6, D_8012CF74); // FREE BYTE func_8006376C(0xD, 0xA, 6, D_8012CF74); // FREE BYTE
func_8006376C(0x11, 0xA, 4, sp74); func_8006376C(0x11, 0xA, 4, sp74);
if (sMempakFilesize != 0) { if (sMempakFilesize != 0) {
@ -2052,24 +2054,24 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
func_8006376C(0xD, 0x1A, 5, D_8012CF60[0]); func_8006376C(0xD, 0x1A, 5, D_8012CF60[0]);
func_8006376C(0x14, 0x1A, 5, D_8012CF70); func_8006376C(0x14, 0x1A, 5, D_8012CF70);
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DUP)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DUP)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u; dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DDOWN)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DDOWN)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx + 1) % 4u; dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx + 1) % 4u;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_A)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_A)) {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlToggleSwitch = 0; dbCamera->sub.demoCtrlToggleSwitch = 0;
dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(dbCamera->sub.demoCtrlActionIdx, MENU_INFO); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(dbCamera->sub.demoCtrlActionIdx, MENU_INFO);
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_B)) {
Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlActionIdx = ACTION_E; dbCamera->sub.demoCtrlActionIdx = ACTION_E;
@ -2079,9 +2081,9 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
} else { } else {
func_8006376C(0xC, 0x1A, 4, D_8012CF60[0]); func_8006376C(0xC, 0x1A, 4, D_8012CF60[0]);
func_8006376C(0x13, 0x1A, 4, D_8012CF80); func_8006376C(0x13, 0x1A, 4, D_8012CF80);
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B) || if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_B) ||
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DUP) || CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DUP) ||
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DDOWN)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DDOWN)) {
Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -2095,14 +2097,14 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
break; break;
default: { default: {
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DUP)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DUP)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO);
dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u; dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u;
sCurFileIdx = 0; sCurFileIdx = 0;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DDOWN)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DDOWN)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO);
@ -2116,7 +2118,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
func_8006376C(4, 7, 5, D_8012CF4C); func_8006376C(4, 7, 5, D_8012CF4C);
func_8006376C(D_8016110C * 2 + 6, 7, 7, ">"); func_8006376C(D_8016110C * 2 + 6, 7, 7, ">");
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CUP)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CUP)) {
if (D_8016110C > 0) { if (D_8016110C > 0) {
D_8016110C--; D_8016110C--;
} }
@ -2124,7 +2126,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
sDbCamAnim.curFrame = 0.0f; sDbCamAnim.curFrame = 0.0f;
sDbCamAnim.keyframe = 0; sDbCamAnim.keyframe = 0;
sDbCamAnim.unk_04 = 0; sDbCamAnim.unk_04 = 0;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CDOWN)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CDOWN)) {
if (D_8016110C < 14) { if (D_8016110C < 14) {
D_8016110C++; D_8016110C++;
} }
@ -2132,7 +2134,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
sDbCamAnim.curFrame = 0.0f; sDbCamAnim.curFrame = 0.0f;
sDbCamAnim.keyframe = 0; sDbCamAnim.keyframe = 0;
sDbCamAnim.unk_04 = 0; sDbCamAnim.unk_04 = 0;
} else if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CLEFT)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CLEFT)) {
sDbCamAnim.unk_0A = 0; sDbCamAnim.unk_0A = 0;
Interface_ChangeAlpha(2); Interface_ChangeAlpha(2);
Letterbox_SetSizeTarget(0); Letterbox_SetSizeTarget(0);
@ -2166,7 +2168,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_L)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_L)) {
if (sp74[sCurFileIdx] == '?') { if (sp74[sCurFileIdx] == '?') {
sLastFileIdx = -1; sLastFileIdx = -1;
D_801612EA = '*'; D_801612EA = '*';
@ -2175,7 +2177,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
D_801612EA = sDbCameraCuts[idx1].letter; D_801612EA = sDbCameraCuts[idx1].letter;
} }
if (1) {} if (1) {}
} else if (!CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { } else if (!CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L)) {
if (sLastFileIdx != -1) { if (sLastFileIdx != -1) {
switch (sp74[sCurFileIdx]) { switch (sp74[sCurFileIdx]) {
case '?': case '?':
@ -2217,7 +2219,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
sLastFileIdx = -1; sLastFileIdx = -1;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_A)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_A)) {
if (sp74[sCurFileIdx] == '?') { if (sp74[sCurFileIdx] == '?') {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -2228,7 +2230,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_B)) {
if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') { if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') {
Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -2237,7 +2239,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_R)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_R)) {
if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') { if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -2261,7 +2263,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DRIGHT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
if (sCurFileIdx == 0x1E) { if (sCurFileIdx == 0x1E) {
@ -2270,22 +2272,22 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
sCurFileIdx++; sCurFileIdx++;
} }
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_DLEFT)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
sCurFileIdx = (sCurFileIdx == 0) ? 0x1E : sCurFileIdx - 1; sCurFileIdx = (sCurFileIdx == 0) ? 0x1E : sCurFileIdx - 1;
} }
if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L) && if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L) &&
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CRIGHT)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CRIGHT)) {
for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) { for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) {
osSyncPrintf("###%2d:(%c) (%d %d) %d %d %d\n", i, sDbCameraCuts[i].letter, osSyncPrintf("###%2d:(%c) (%d %d) %d %d %d\n", i, sDbCameraCuts[i].letter,
sDbCameraCuts[i].position, sDbCameraCuts[i].lookAt, sDbCameraCuts[i].nFrames, sDbCameraCuts[i].position, sDbCameraCuts[i].lookAt, sDbCameraCuts[i].nFrames,
sDbCameraCuts[i].nPoints, sDbCameraCuts[i].mode); sDbCameraCuts[i].nPoints, sDbCameraCuts[i].mode);
} }
DbCamera_PrintAllCuts(cam); DbCamera_PrintAllCuts(cam);
} else if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L) && } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].cur.button, BTN_L) &&
CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CLEFT)) { CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CLEFT)) {
Audio_PlaySfxGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) { for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) {
@ -2294,7 +2296,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) {
DbCamera_PrintCutBytes(&sDbCameraCuts[i]); DbCamera_PrintCutBytes(&sDbCameraCuts[i]);
} }
} }
} else if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CRIGHT)) { } else if (CHECK_BTN_ALL(sPlay->state.input[DBCAM_CONTROLLER_PORT].press.button, BTN_CRIGHT)) {
sDbCamAnim.curFrame = 0.0f; sDbCamAnim.curFrame = 0.0f;
sDbCamAnim.keyframe = 0; sDbCamAnim.keyframe = 0;
sDbCamAnim.unk_04 = 0.0f; sDbCamAnim.unk_04 = 0.0f;

View file

@ -106,6 +106,6 @@ void DebugArena_Cleanup(void) {
__osMallocCleanup(&sDebugArena); __osMallocCleanup(&sDebugArena);
} }
u8 DebugArena_IsInitalized(void) { u8 DebugArena_IsInitialized(void) {
return __osMallocIsInitalized(&sDebugArena); return __osMallocIsInitialized(&sDebugArena);
} }

View file

@ -352,18 +352,25 @@ void Fault_Sleep(u32 msec) {
Fault_SleepImpl(msec); Fault_SleepImpl(msec);
} }
void PadMgr_RequestPadData(Input* input, s32 mode); #ifndef AVOID_UB
void PadMgr_RequestPadData(Input* inputs, s32 gameRequest);
#endif
void Fault_PadCallback(Input* input) { void Fault_PadCallback(Input* inputs) {
//! @bug This function is not called correctly, it is missing a leading PadMgr* argument. This //! @bug This function is not called correctly, it is missing a leading PadMgr* argument. This
//! renders the crash screen unusable. //! renders the crash screen unusable.
//! In Majora's Mask, PadMgr functions were changed to not require this argument, and this was //! In Majora's Mask, PadMgr functions were changed to not require this argument, and this was
//! likely just not addressed when backporting. //! likely just not addressed when backporting.
PadMgr_RequestPadData(input, 0); #ifndef AVOID_UB
PadMgr_RequestPadData(inputs, false);
#else
// Guarantee crashing behavior: false -> NULL, previous value in a2 is more often non-zero than zero
PadMgr_RequestPadData((PadMgr*)inputs, NULL, true);
#endif
} }
void Fault_UpdatePadImpl(void) { void Fault_UpdatePadImpl(void) {
sFaultInstance->padCallback(&sFaultInstance->padInput); sFaultInstance->padCallback(sFaultInstance->inputs);
} }
/** /**
@ -376,7 +383,7 @@ void Fault_UpdatePadImpl(void) {
* DPad-Left continues and returns false * DPad-Left continues and returns false
*/ */
u32 Fault_WaitForInputImpl(void) { u32 Fault_WaitForInputImpl(void) {
Input* input = &sFaultInstance->padInput; Input* input = &sFaultInstance->inputs[0];
s32 count = 600; s32 count = 600;
u32 pressedBtn; u32 pressedBtn;
@ -651,7 +658,7 @@ void Fault_Wait5Seconds(void) {
* (L & R & Z) + DPad-Up + C-Down + C-Up + DPad-Down + DPad-Left + C-Left + C-Right + DPad-Right + (B & A & START) * (L & R & Z) + DPad-Up + C-Down + C-Up + DPad-Down + DPad-Left + C-Left + C-Right + DPad-Right + (B & A & START)
*/ */
void Fault_WaitForButtonCombo(void) { void Fault_WaitForButtonCombo(void) {
Input* input = &sFaultInstance->padInput; Input* input = &sFaultInstance->inputs[0];
s32 state; s32 state;
u32 s1; u32 s1;
u32 s2; u32 s2;
@ -853,7 +860,7 @@ void Fault_DrawMemDumpContents(const char* title, uintptr_t addr, u32 arg2) {
* @param cRightJump Unused parameter, pressing C-Right jumps to this address * @param cRightJump Unused parameter, pressing C-Right jumps to this address
*/ */
void Fault_DrawMemDump(uintptr_t pc, uintptr_t sp, uintptr_t cLeftJump, uintptr_t cRightJump) { void Fault_DrawMemDump(uintptr_t pc, uintptr_t sp, uintptr_t cLeftJump, uintptr_t cRightJump) {
Input* input = &sFaultInstance->padInput; Input* input = &sFaultInstance->inputs[0];
uintptr_t addr = pc; uintptr_t addr = pc;
s32 scrollCountdown; s32 scrollCountdown;
u32 off; u32 off;

View file

@ -227,10 +227,10 @@ void func_800C49F4(GraphicsContext* gfxCtx) {
CLOSE_DISPS(gfxCtx, "../game.c", 865); CLOSE_DISPS(gfxCtx, "../game.c", 865);
} }
void PadMgr_RequestPadData(PadMgr*, Input*, s32); void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest);
void GameState_ReqPadData(GameState* gameState) { void GameState_ReqPadData(GameState* gameState) {
PadMgr_RequestPadData(&gPadMgr, &gameState->input[0], 1); PadMgr_RequestPadData(&gPadMgr, gameState->input, true);
} }
void GameState_Update(GameState* gameState) { void GameState_Update(GameState* gameState) {

View file

@ -17,14 +17,14 @@ s32 Mempak_Init(s32 controllerNb) {
s32 pad; s32 pad;
s32 ret = false; s32 ret = false;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr); mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
if (!osPfsInitPak(mq, &sMempakPfsHandle, controllerNb)) { if (!osPfsInitPak(mq, &sMempakPfsHandle, controllerNb)) {
ret = true; ret = true;
} }
osPfsFreeBlocks(&sMempakPfsHandle, &sMempakFreeBytes); osPfsFreeBlocks(&sMempakPfsHandle, &sMempakFreeBytes);
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
return ret; return ret;
} }
@ -40,7 +40,7 @@ s32 Mempak_FindFile(s32 controllerNb, char start, char end) {
u32 bit = 1; u32 bit = 1;
s32 flag = 0; s32 flag = 0;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr); mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
for (idx = start; idx <= end; idx++) { for (idx = start; idx <= end; idx++) {
sMempakExtName[0] = idx - 0x27; sMempakExtName[0] = idx - 0x27;
@ -57,7 +57,7 @@ s32 Mempak_FindFile(s32 controllerNb, char start, char end) {
osSyncPrintf("mempak: find '%c' (%d)\n", idx, error); osSyncPrintf("mempak: find '%c' (%d)\n", idx, error);
} }
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
osSyncPrintf("mempak: find '%c' - '%c' %02x\n", start, end, flag); osSyncPrintf("mempak: find '%c' - '%c' %02x\n", start, end, flag);
return flag; return flag;
@ -69,7 +69,7 @@ s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size)
s32 ret = false; s32 ret = false;
s32 pad; s32 pad;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr); mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
if (size < sMempakFreeBytes) { if (size < sMempakFreeBytes) {
error = osPfsReadWriteFile(&sMempakPfsHandle, sMempakFiles[idx - 'A'], 1, offset, size, buffer); error = osPfsReadWriteFile(&sMempakPfsHandle, sMempakFiles[idx - 'A'], 1, offset, size, buffer);
@ -78,7 +78,7 @@ s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size)
} }
osSyncPrintf("mempak: write %d byte '%c' (%d)->%d\n", size, idx, sMempakFiles[idx - 'A'], error); osSyncPrintf("mempak: write %d byte '%c' (%d)->%d\n", size, idx, sMempakFiles[idx - 'A'], error);
} }
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
return ret; return ret;
} }
@ -89,7 +89,7 @@ s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size)
s32 ret = false; s32 ret = false;
s32 pad; s32 pad;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr); mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
if (size < sMempakFreeBytes) { if (size < sMempakFreeBytes) {
error = osPfsReadWriteFile(&sMempakPfsHandle, sMempakFiles[idx - 'A'], 0, offset, size, buffer); error = osPfsReadWriteFile(&sMempakPfsHandle, sMempakFiles[idx - 'A'], 0, offset, size, buffer);
@ -98,7 +98,7 @@ s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size)
} }
osSyncPrintf("mempak: read %d byte '%c' (%d)<-%d\n", size, idx, sMempakFiles[idx - 'A'], error); osSyncPrintf("mempak: read %d byte '%c' (%d)<-%d\n", size, idx, sMempakFiles[idx - 'A'], error);
} }
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
return ret; return ret;
} }
@ -109,7 +109,7 @@ s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size) {
s32 i; s32 i;
s32 pad; s32 pad;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr); mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
if (*idx >= 'A' && *idx < 'L') { if (*idx >= 'A' && *idx < 'L') {
sMempakExtName[0] = *idx - 0x27; sMempakExtName[0] = *idx - 0x27;
@ -149,7 +149,7 @@ s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size) {
ret = 1; ret = 1;
} }
} }
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
return ret; return ret;
} }
@ -159,7 +159,7 @@ s32 Mempak_DeleteFile(s32 controllerNb, char idx) {
s32 error; s32 error;
s32 ret = false; s32 ret = false;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr); mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
sMempakExtName[0] = idx - 0x27; sMempakExtName[0] = idx - 0x27;
error = osPfsDeleteFile(&sMempakPfsHandle, sMempakCompanyCode, sMempakGameCode, sMempakGameName, sMempakExtName); error = osPfsDeleteFile(&sMempakPfsHandle, sMempakCompanyCode, sMempakGameCode, sMempakGameName, sMempakExtName);
@ -167,18 +167,18 @@ s32 Mempak_DeleteFile(s32 controllerNb, char idx) {
ret = true; ret = true;
} }
osSyncPrintf("mempak: delete '%c' (%d)\n", idx, error); osSyncPrintf("mempak: delete '%c' (%d)\n", idx, error);
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
return ret; return ret;
} }
s32 Mempak_GetFileSize(s32 controllerNb, char idx) { s32 Mempak_GetFileSize(s32 controllerNb, char idx) {
OSMesgQueue* mq = PadMgr_LockSerialMesgQueue(&gPadMgr); OSMesgQueue* mq = PadMgr_AcquireSerialEventQueue(&gPadMgr);
OSPfsState state; OSPfsState state;
s32 error = osPfsFileState(&sMempakPfsHandle, sMempakFiles[idx - 'A'], &state); s32 error = osPfsFileState(&sMempakPfsHandle, sMempakFiles[idx - 'A'], &state);
s32 pad; s32 pad;
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq); PadMgr_ReleaseSerialEventQueue(&gPadMgr, mq);
if (error != 0) { if (error != 0) {
return 0; return 0;

View file

@ -1,12 +1,74 @@
/**
* @file padmgr.c
*
* This file implements communicating with joybus devices at a high level and serving the results to other threads.
*
* Any device that can be plugged into one of the four controller ports such as a standard N64 controller is a joybus
* device. Some joybus devices are also located inside the cartridge such as EEPROM for save data or the Real-Time
* Clock, however neither of these are used in Zelda64 and so this type of communication is unimplemented. Of the
* possible devices that can be plugged into the controller ports, the only device that padmgr will recognize and
* attempt to communicate with is the standard N64 controller.
*
* Communicating with these devices is broken down into various layers:
*
* Other threads : The rest of the program that will use the polled data
* |
* PadMgr : Manages devices, submits polling commands at vertical retrace
* |
* Libultra osCont* routines : Interface for building commands and safely using the Serial Interface
* |
* Serial Interface : Hardware unit for sending joybus commands and receiving data via DMA
* |
* PIF : Forwards joybus commands and receives response data from the devices
* |---¬---¬---¬-------¬
* 1 2 3 4 5 : The joybus devices plugged into the four controller ports or on the cartridge
*
* Joybus communication is handled on another thread as polling and receiving controller data is a slow process; the
* N64 programming manual section 26.2.4.1 quotes 2 milliseconds as the expected delay from calling
* `osContStartReadData` to receiving the data. By running this on a separate thread to the game state, work can be
* done while waiting for this operation to complete.
*/
#include "global.h" #include "global.h"
#include "vt.h" #include "vt.h"
s32 D_8012D280 = 1; #define PADMGR_LOG(controllerNo, msg) \
if (1) { \
osSyncPrintf(VT_FGCOL(YELLOW)); \
/* padmgr: Controller %d: %s */ \
osSyncPrintf("padmgr: %dコン: %s\n", (controllerNo) + 1, (msg)); \
osSyncPrintf(VT_RST); \
} \
(void)0
OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) { #define LOG_SEVERITY_NOLOG 0
#define LOG_SEVERITY_CRITICAL 1
#define LOG_SEVERITY_ERROR 2
#define LOG_SEVERITY_VERBOSE 3
s32 gPadMgrLogSeverity = LOG_SEVERITY_CRITICAL;
/**
* Acquires exclusive access to the serial event queue.
*
* When a DMA to/from PIF RAM completes, an SI interrupt is generated to notify the process that the DMA has completed
* and a message is posted to the serial event queue. If multiple processes are trying to use the SI at the same time
* it becomes ambiguous as to which DMA has completed, so a locking system is required to arbitrate access to the SI.
*
* Once the task requiring the serial event queue is complete, it should be released with a call to
* `PadMgr_ReleaseSerialEventQueue()`.
*
* If another process tries to acquire the event queue, the current thread will be blocked until the event queue is
* released. Note the possibility for a deadlock, if the thread that already holds the serial event queue attempts to
* acquire it again it will block forever.
*
* @return The message queue to which SI interrupt events are posted.
*
* @see PadMgr_ReleaseSerialEventQueue
*/
OSMesgQueue* PadMgr_AcquireSerialEventQueue(PadMgr* padMgr) {
OSMesgQueue* serialEventQueue = NULL; OSMesgQueue* serialEventQueue = NULL;
if (D_8012D280 > 2) { if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
// "serialMsgQ Waiting for lock" // "serialMsgQ Waiting for lock"
osSyncPrintf("%2d %d serialMsgQロック待ち %08x %08x %08x\n", osGetThreadId(NULL), osSyncPrintf("%2d %d serialMsgQロック待ち %08x %08x %08x\n", osGetThreadId(NULL),
MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, &serialEventQueue); MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, &serialEventQueue);
@ -14,7 +76,7 @@ OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) {
osRecvMesg(&padMgr->serialLockQueue, (OSMesg*)&serialEventQueue, OS_MESG_BLOCK); osRecvMesg(&padMgr->serialLockQueue, (OSMesg*)&serialEventQueue, OS_MESG_BLOCK);
if (D_8012D280 > 2) { if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
// "serialMsgQ Locked" // "serialMsgQ Locked"
osSyncPrintf("%2d %d serialMsgQをロックしました %08x\n", osGetThreadId(NULL), osSyncPrintf("%2d %d serialMsgQをロックしました %08x\n", osGetThreadId(NULL),
MQ_GET_COUNT(&padMgr->serialLockQueue), serialEventQueue); MQ_GET_COUNT(&padMgr->serialLockQueue), serialEventQueue);
@ -23,8 +85,15 @@ OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) {
return serialEventQueue; return serialEventQueue;
} }
void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue) { /**
if (D_8012D280 > 2) { * Relinquishes access to the serial message queue, allowing another process to acquire and use it.
*
* @param serialEventQueue The serial message queue acquired by `PadMgr_AcquireSerialEventQueue`
*
* @see PadMgr_AcquireSerialEventQueue
*/
void PadMgr_ReleaseSerialEventQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue) {
if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
// "serialMsgQ Unlock" // "serialMsgQ Unlock"
osSyncPrintf("%2d %d serialMsgQロック解除します %08x %08x %08x\n", osGetThreadId(NULL), osSyncPrintf("%2d %d serialMsgQロック解除します %08x %08x %08x\n", osGetThreadId(NULL),
MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, serialEventQueue); MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, serialEventQueue);
@ -32,97 +101,99 @@ void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue)
osSendMesg(&padMgr->serialLockQueue, (OSMesg)serialEventQueue, OS_MESG_BLOCK); osSendMesg(&padMgr->serialLockQueue, (OSMesg)serialEventQueue, OS_MESG_BLOCK);
if (D_8012D280 > 2) { if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
// "serialMsgQ Unlocked" // "serialMsgQ Unlocked"
osSyncPrintf("%2d %d serialMsgQロック解除しました %08x %08x %08x\n", osGetThreadId(NULL), osSyncPrintf("%2d %d serialMsgQロック解除しました %08x %08x %08x\n", osGetThreadId(NULL),
MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, serialEventQueue); MQ_GET_COUNT(&padMgr->serialLockQueue), padMgr, &padMgr->serialLockQueue, serialEventQueue);
} }
} }
/**
* Locks controller input data while padmgr is reading new inputs or another thread is using the current inputs.
* This prevents new inputs overwriting the current inputs while they are in use.
*
* @see PadMgr_UnlockPadData
*/
void PadMgr_LockPadData(PadMgr* padMgr) { void PadMgr_LockPadData(PadMgr* padMgr) {
osRecvMesg(&padMgr->lockQueue, NULL, OS_MESG_BLOCK); osRecvMesg(&padMgr->lockQueue, NULL, OS_MESG_BLOCK);
} }
/**
* Unlocks controller input data, allowing padmgr to read new inputs or another thread to access the most recently
* polled inputs.
*
* @see PadMgr_LockPadData
*/
void PadMgr_UnlockPadData(PadMgr* padMgr) { void PadMgr_UnlockPadData(PadMgr* padMgr) {
osSendMesg(&padMgr->lockQueue, NULL, OS_MESG_BLOCK); osSendMesg(&padMgr->lockQueue, NULL, OS_MESG_BLOCK);
} }
void PadMgr_RumbleControl(PadMgr* padMgr) { /**
static u32 errcnt = 0; * Activates the rumble pak for all controllers it is enabled on, stops it for all controllers it is disabled on and
static u32 frame; * attempts to initialize it for a controller if it is not already initialized.
s32 temp = 1; */
void PadMgr_UpdateRumble(PadMgr* padMgr) {
static u32 sRumbleErrorCount = 0; // original name: "errcnt"
static u32 sRumbleUpdateCounter;
s32 motorStart = MOTOR_START; // required for matching?
s32 triedRumbleComm; s32 triedRumbleComm;
OSMesgQueue* serialEventQueue = PadMgr_LockSerialMesgQueue(padMgr); OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(padMgr);
s32 var4; s32 ret;
s32 i; s32 i;
triedRumbleComm = 0; triedRumbleComm = false;
for (i = 0; i < 4; i++) { for (i = 0; i < MAXCONTROLLERS; i++) {
if (padMgr->ctrlrIsConnected[i]) { if (padMgr->ctrlrIsConnected[i]) {
if (padMgr->padStatus[i].status & 1) { // Check status for whether a controller pak is connected
if (padMgr->pakType[i] == temp) { if (padMgr->padStatus[i].status & CONT_CARD_ON) {
if (padMgr->rumbleEnable[i] != 0) { if (padMgr->pakType[i] == CONT_PAK_RUMBLE) {
if (padMgr->rumbleCounter[i] < 3) { if (padMgr->rumbleEnable[i]) {
// clang-format off if (padMgr->rumbleTimer[i] < 3) {
if (1) {} osSyncPrintf(VT_FGCOL(YELLOW)); // "Rumble pack brrr"
// clang-format on PADMGR_LOG(i, "振動パック ぶるぶるぶるぶる");
// "Vibration pack jumble jumble"? // This should be the osMotorStart macro, however the temporary variable motorStart is
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック ぶるぶるぶるぶる"); // currently required for matching
osSyncPrintf(VT_RST); if (__osMotorAccess(&padMgr->rumblePfs[i], motorStart) != 0) {
padMgr->pakType[i] = CONT_PAK_NONE;
if (__osMotorAccess(&padMgr->pfs[i], temp) != 0) {
padMgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
// "A communication error has occurred with the vibration pack" // "A communication error has occurred with the vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました"); PADMGR_LOG(i, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
} else { } else {
padMgr->rumbleCounter[i] = 3; padMgr->rumbleTimer[i] = 3;
} }
triedRumbleComm = 1; triedRumbleComm = true;
} }
} else { } else {
if (padMgr->rumbleCounter[i] != 0) { if (padMgr->rumbleTimer[i] != 0) {
// clang-format off
if (1) {} osSyncPrintf(VT_FGCOL(YELLOW));
// clang-format on
// "Stop vibration pack" // "Stop vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止"); PADMGR_LOG(i, "振動パック 停止");
osSyncPrintf(VT_RST);
if (osMotorStop(&padMgr->rumblePfs[i]) != 0) {
padMgr->pakType[i] = CONT_PAK_NONE;
if (osMotorStop(&padMgr->pfs[i]) != 0) {
padMgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
// "A communication error has occurred with the vibration pack" // "A communication error has occurred with the vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました"); PADMGR_LOG(i, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
} else { } else {
padMgr->rumbleCounter[i]--; padMgr->rumbleTimer[i]--;
} }
triedRumbleComm = 1; triedRumbleComm = true;
} }
} }
} }
} else { } else {
if (padMgr->pakType[i] != 0) { if (padMgr->pakType[i] != CONT_PAK_NONE) {
if (padMgr->pakType[i] == 1) { if (padMgr->pakType[i] == CONT_PAK_RUMBLE) {
osSyncPrintf(VT_FGCOL(YELLOW));
// "It seems that a vibration pack was pulled out" // "It seems that a vibration pack was pulled out"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックが抜かれたようです"); PADMGR_LOG(i, "振動パックが抜かれたようです");
osSyncPrintf(VT_RST); padMgr->pakType[i] = CONT_PAK_NONE;
padMgr->pakType[i] = 0;
} else { } else {
osSyncPrintf(VT_FGCOL(YELLOW));
// "It seems that a controller pack that is not a vibration pack was pulled out" // "It seems that a controller pack that is not a vibration pack was pulled out"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, PADMGR_LOG(i, "振動パックではないコントローラパックが抜かれたようです");
"振動パックではないコントローラパックが抜かれたようです"); padMgr->pakType[i] = CONT_PAK_NONE;
osSyncPrintf(VT_RST);
padMgr->pakType[i] = 0;
} }
} }
} }
@ -130,128 +201,145 @@ void PadMgr_RumbleControl(PadMgr* padMgr) {
} }
if (!triedRumbleComm) { if (!triedRumbleComm) {
i = frame % 4; // Try to initialize the rumble pak for controller port `i` if a controller pak is connected and
// not already known to be an initialized a rumble pak
i = sRumbleUpdateCounter % MAXCONTROLLERS;
if (padMgr->ctrlrIsConnected[i] && (padMgr->padStatus[i].status & 1) && (padMgr->pakType[i] != 1)) { if (padMgr->ctrlrIsConnected[i] && (padMgr->padStatus[i].status & CONT_CARD_ON) &&
var4 = osMotorInit(serialEventQueue, &padMgr->pfs[i], i); padMgr->pakType[i] != CONT_PAK_RUMBLE) {
ret = osMotorInit(serialEventQueue, &padMgr->rumblePfs[i], i);
if (ret == 0) {
padMgr->pakType[i] = CONT_PAK_RUMBLE;
osMotorStart(&padMgr->rumblePfs[i]);
osMotorStop(&padMgr->rumblePfs[i]);
if (var4 == 0) {
padMgr->pakType[i] = 1;
osMotorStart(&padMgr->pfs[i]);
osMotorStop(&padMgr->pfs[i]);
osSyncPrintf(VT_FGCOL(YELLOW));
// "Recognized vibration pack" // "Recognized vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックを認識しました"); PADMGR_LOG(i, "振動パックを認識しました");
osSyncPrintf(VT_RST); } else if (ret == PFS_ERR_DEVICE) {
} else if (var4 == 11) { padMgr->pakType[i] = CONT_PAK_OTHER;
padMgr->pakType[i] = 2; } else if (ret == PFS_ERR_CONTRFAIL) {
} else if (var4 == 4) { LOG_NUM("++errcnt", ++sRumbleErrorCount, "../padmgr.c", 282);
LOG_NUM("++errcnt", ++errcnt, "../padmgr.c", 282);
osSyncPrintf(VT_FGCOL(YELLOW));
// "Controller pack communication error" // "Controller pack communication error"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "コントローラパックの通信エラー"); PADMGR_LOG(i, "コントローラパックの通信エラー");
osSyncPrintf(VT_RST);
} }
} }
} }
sRumbleUpdateCounter++;
frame++; PadMgr_ReleaseSerialEventQueue(padMgr, serialEventQueue);
PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue);
} }
/**
* Immediately stops rumble on all controllers
*/
void PadMgr_RumbleStop(PadMgr* padMgr) { void PadMgr_RumbleStop(PadMgr* padMgr) {
s32 i; s32 i;
OSMesgQueue* serialEventQueue = PadMgr_LockSerialMesgQueue(padMgr); OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(padMgr);
for (i = 0; i < 4; i++) { for (i = 0; i < MAXCONTROLLERS; i++) {
if (osMotorInit(serialEventQueue, &padMgr->pfs[i], i) == 0) { if (osMotorInit(serialEventQueue, &padMgr->rumblePfs[i], i) == 0) {
if ((gFaultMgr.msgId == 0) && (padMgr->rumbleOnFrames != 0)) { // If there is a rumble pak attached to this controller, stop it
osSyncPrintf(VT_FGCOL(YELLOW));
// "Stop vibration pack" if (gFaultMgr.msgId == 0 && padMgr->rumbleOnTimer != 0) {
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止"); // "Stop rumble pak"
osSyncPrintf(VT_RST); PADMGR_LOG(i, "振動パック 停止");
} }
osMotorStop(&padMgr->rumblePfs[i]);
osMotorStop(&padMgr->pfs[i]);
} }
} }
PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue); PadMgr_ReleaseSerialEventQueue(padMgr, serialEventQueue);
} }
/**
* Prevents rumble for 3 VI, ~0.05 seconds at 60 VI/sec
*/
void PadMgr_RumbleReset(PadMgr* padMgr) { void PadMgr_RumbleReset(PadMgr* padMgr) {
padMgr->rumbleOffFrames = 3; padMgr->rumbleOffTimer = 3;
} }
void PadMgr_RumbleSetSingle(PadMgr* padMgr, u32 ctrlr, u32 rumble) { /**
padMgr->rumbleEnable[ctrlr] = rumble; * Enables or disables rumble on controller port `port` for 240 VI,
padMgr->rumbleOnFrames = 240; * ~4 seconds at 60 VI/sec and ~4.8 seconds at 50 VI/sec
*/
void PadMgr_RumbleSetSingle(PadMgr* padMgr, u32 port, u32 rumble) {
padMgr->rumbleEnable[port] = rumble;
padMgr->rumbleOnTimer = 240;
} }
void PadMgr_RumbleSet(PadMgr* padMgr, u8* ctrlrRumbles) { /**
* Enables or disables rumble on all controller ports for 240 VI,
* ~4 seconds at 60 VI/sec and ~4.8 seconds at 50 VI/sec
*
* @param enable Array of u8 of length MAXCONTROLLERS containing either true or false to enable or disable rumble
* for that controller
*/
void PadMgr_RumbleSet(PadMgr* padMgr, u8* enable) {
s32 i; s32 i;
for (i = 0; i < 4; i++) { for (i = 0; i < MAXCONTROLLERS; i++) {
padMgr->rumbleEnable[i] = ctrlrRumbles[i]; padMgr->rumbleEnable[i] = enable[i];
} }
padMgr->rumbleOnFrames = 240; padMgr->rumbleOnTimer = 240;
} }
void PadMgr_ProcessInputs(PadMgr* padMgr) { /**
* Updates `padMgr->inputs` based on the error response of each controller
*/
void PadMgr_UpdateInputs(PadMgr* padMgr) {
s32 i; s32 i;
Input* input; Input* input;
OSContPad* padnow1; // original name OSContPad* pad; // original name: "padnow1"
s32 buttonDiff; s32 buttonDiff;
PadMgr_LockPadData(padMgr); PadMgr_LockPadData(padMgr);
input = &padMgr->inputs[0]; for (input = &padMgr->inputs[0], pad = &padMgr->pads[0], i = 0; i < padMgr->nControllers; i++, input++, pad++) {
padnow1 = &padMgr->pads[0];
for (i = 0; i < padMgr->nControllers; i++, input++, padnow1++) {
input->prev = input->cur; input->prev = input->cur;
if (1) {} // Necessary to match switch (pad->errno) {
switch (padnow1->errno) {
case 0: case 0:
input->cur = *padnow1; // No error, copy inputs
input->cur = *pad;
if (!padMgr->ctrlrIsConnected[i]) { if (!padMgr->ctrlrIsConnected[i]) {
padMgr->ctrlrIsConnected[i] = true; padMgr->ctrlrIsConnected[i] = true;
osSyncPrintf(VT_FGCOL(YELLOW)); // "Recognized"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "認識しました"); // "Recognized" PADMGR_LOG(i, "認識しました");
osSyncPrintf(VT_RST);
} }
break; break;
case 4: case (CHNL_ERR_OVERRUN >> 4):
// Overrun error, reuse previous inputs
input->cur = input->prev; input->cur = input->prev;
LOG_NUM("this->Key_switch[i]", padMgr->ctrlrIsConnected[i], "../padmgr.c", 380); LOG_NUM("this->Key_switch[i]", padMgr->ctrlrIsConnected[i], "../padmgr.c", 380);
osSyncPrintf(VT_FGCOL(YELLOW));
// "Overrun error occurred" // "Overrun error occurred"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "オーバーランエラーが発生"); PADMGR_LOG(i, "オーバーランエラーが発生");
osSyncPrintf(VT_RST);
break; break;
case 8: case (CHNL_ERR_NORESP >> 4):
// No response error, take inputs as 0
input->cur.button = 0; input->cur.button = 0;
input->cur.stick_x = 0; input->cur.stick_x = 0;
input->cur.stick_y = 0; input->cur.stick_y = 0;
input->cur.errno = padnow1->errno; input->cur.errno = pad->errno;
if (padMgr->ctrlrIsConnected[i]) { if (padMgr->ctrlrIsConnected[i]) {
// If we get no response, consider the controller disconnected
padMgr->ctrlrIsConnected[i] = false; padMgr->ctrlrIsConnected[i] = false;
padMgr->pakType[i] = 0; padMgr->pakType[i] = CONT_PAK_NONE;
padMgr->rumbleCounter[i] = 0xFF; padMgr->rumbleTimer[i] = UINT8_MAX;
osSyncPrintf(VT_FGCOL(YELLOW)); // "Not responding"
// "Do not respond"? PADMGR_LOG(i, "応答しません");
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "応答しません");
osSyncPrintf(VT_RST);
} }
break; break;
default: default:
LOG_HEX("padnow1->errno", padnow1->errno, "../padmgr.c", 396); // Unknown error response
LOG_HEX("padnow1->errno", pad->errno, "../padmgr.c", 396);
Fault_AddHungupAndCrash("../padmgr.c", 397); Fault_AddHungupAndCrash("../padmgr.c", 397);
break;
} }
// Calculate pressed and relative inputs
buttonDiff = input->prev.button ^ input->cur.button; buttonDiff = input->prev.button ^ input->cur.button;
input->press.button |= (u16)(buttonDiff & input->cur.button); input->press.button |= (u16)(buttonDiff & input->cur.button);
input->rel.button |= (u16)(buttonDiff & input->prev.button); input->rel.button |= (u16)(buttonDiff & input->prev.button);
@ -263,29 +351,43 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) {
PadMgr_UnlockPadData(padMgr); PadMgr_UnlockPadData(padMgr);
} }
void PadMgr_HandleRetraceMsg(PadMgr* padMgr) { void PadMgr_HandleRetrace(PadMgr* padMgr) {
s32 i; s32 i;
OSMesgQueue* serialEventQueue = PadMgr_LockSerialMesgQueue(padMgr); OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(padMgr);
u32 mask; u32 mask;
// Begin reading controller data
osContStartReadData(serialEventQueue); osContStartReadData(serialEventQueue);
if (padMgr->retraceCallback) {
// Execute retrace callback
if (padMgr->retraceCallback != NULL) {
padMgr->retraceCallback(padMgr, padMgr->retraceCallbackValue); padMgr->retraceCallback(padMgr, padMgr->retraceCallbackValue);
} }
// Wait for controller data
osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK); osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK);
osContGetReadData(padMgr->pads); osContGetReadData(padMgr->pads);
if (padMgr->preNMIShutdown) {
// If resetting, clear all controllers
if (padMgr->isResetting) {
bzero(padMgr->pads, sizeof(padMgr->pads)); bzero(padMgr->pads, sizeof(padMgr->pads));
} }
PadMgr_ProcessInputs(padMgr);
// Update input data
PadMgr_UpdateInputs(padMgr);
// Query controller status for all controllers
osContStartQuery(serialEventQueue); osContStartQuery(serialEventQueue);
osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK); osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK);
osContGetQuery(padMgr->padStatus); osContGetQuery(padMgr->padStatus);
PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue);
PadMgr_ReleaseSerialEventQueue(padMgr, serialEventQueue);
// Update the state of connected controllers
mask = 0; mask = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < MAXCONTROLLERS; i++) {
if (padMgr->padStatus[i].errno == 0) { if (padMgr->padStatus[i].errno == 0) {
// Only standard N64 controllers are supported
if (padMgr->padStatus[i].type == CONT_TYPE_NORMAL) { if (padMgr->padStatus[i].type == CONT_TYPE_NORMAL) {
mask |= 1 << i; mask |= 1 << i;
} else { } else {
@ -298,53 +400,64 @@ void PadMgr_HandleRetraceMsg(PadMgr* padMgr) {
padMgr->validCtrlrsMask = mask; padMgr->validCtrlrsMask = mask;
if (gFaultMgr.msgId != 0) { if (gFaultMgr.msgId != 0) {
// If fault is active, no rumble
PadMgr_RumbleStop(padMgr); PadMgr_RumbleStop(padMgr);
} else if (padMgr->rumbleOffFrames > 0) { } else if (padMgr->rumbleOffTimer > 0) {
--padMgr->rumbleOffFrames; // If the rumble off timer is active, no rumble
--padMgr->rumbleOffTimer;
PadMgr_RumbleStop(padMgr); PadMgr_RumbleStop(padMgr);
} else if (padMgr->rumbleOnFrames == 0) { } else if (padMgr->rumbleOnTimer == 0) {
// If the rumble on timer is inactive, no rumble
PadMgr_RumbleStop(padMgr); PadMgr_RumbleStop(padMgr);
} else if (!padMgr->preNMIShutdown) { } else if (!padMgr->isResetting) {
PadMgr_RumbleControl(padMgr); // If not resetting, update rumble
--padMgr->rumbleOnFrames; PadMgr_UpdateRumble(padMgr);
--padMgr->rumbleOnTimer;
} }
} }
void PadMgr_HandlePreNMI(PadMgr* padMgr) { void PadMgr_HandlePreNMI(PadMgr* padMgr) {
osSyncPrintf("padmgr_HandlePreNMI()\n"); osSyncPrintf("padmgr_HandlePreNMI()\n");
padMgr->preNMIShutdown = true; padMgr->isResetting = true;
PadMgr_RumbleReset(padMgr); PadMgr_RumbleReset(padMgr);
} }
void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 mode) { /**
* Fetches the most recently polled inputs from padmgr
*
* @param inputs Array of Input of length MAXCONTROLLERS to copy inputs into
* @param gamePoll True if polling inputs for updating the game state
*/
void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest) {
s32 i; s32 i;
Input* ogInput; Input* inputIn;
Input* newInput; Input* inputOut;
s32 buttonDiff; s32 buttonDiff;
PadMgr_LockPadData(padMgr); PadMgr_LockPadData(padMgr);
ogInput = &padMgr->inputs[0]; for (inputIn = &padMgr->inputs[0], inputOut = &inputs[0], i = 0; i < MAXCONTROLLERS; i++, inputIn++, inputOut++) {
newInput = &inputs[0]; if (gameRequest) {
for (i = 0; i < 4; i++) { // Copy inputs as-is, press and rel are calculated prior in `PadMgr_UpdateInputs`
if (mode != 0) { *inputOut = *inputIn;
*newInput = *ogInput; // Zero parts of the press and rel inputs in the polled inputs so they are not read more than once
ogInput->press.button = 0; inputIn->press.button = 0;
ogInput->press.stick_x = 0; inputIn->press.stick_x = 0;
ogInput->press.stick_y = 0; inputIn->press.stick_y = 0;
ogInput->rel.button = 0; inputIn->rel.button = 0;
} else { } else {
newInput->prev = newInput->cur; // Take as the previous inputs the inputs that are currently in the destination array
newInput->cur = ogInput->cur; inputOut->prev = inputOut->cur;
buttonDiff = newInput->prev.button ^ newInput->cur.button; // Copy current inputs from the polled inputs
newInput->press.button = newInput->cur.button & buttonDiff; inputOut->cur = inputIn->cur;
newInput->rel.button = newInput->prev.button & buttonDiff; // Calculate press and rel from these
PadUtils_UpdateRelXY(newInput); buttonDiff = inputOut->prev.button ^ inputOut->cur.button;
newInput->press.stick_x += (s8)(newInput->cur.stick_x - newInput->prev.stick_x); inputOut->press.button = inputOut->cur.button & buttonDiff;
newInput->press.stick_y += (s8)(newInput->cur.stick_y - newInput->prev.stick_y); inputOut->rel.button = inputOut->prev.button & buttonDiff;
PadUtils_UpdateRelXY(inputOut);
inputOut->press.stick_x += (s8)(inputOut->cur.stick_x - inputOut->prev.stick_x);
inputOut->press.stick_y += (s8)(inputOut->cur.stick_y - inputOut->prev.stick_y);
} }
ogInput++;
newInput++;
} }
PadMgr_UnlockPadData(padMgr); PadMgr_UnlockPadData(padMgr);
@ -358,7 +471,7 @@ void PadMgr_ThreadEntry(PadMgr* padMgr) {
exit = false; exit = false;
while (!exit) { while (!exit) {
if ((D_8012D280 > 2) && MQ_IS_EMPTY(&padMgr->interruptQueue)) { if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE && MQ_IS_EMPTY(&padMgr->interruptQueue)) {
// "Waiting for controller thread event" // "Waiting for controller thread event"
osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime())); osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
} }
@ -368,16 +481,15 @@ void PadMgr_ThreadEntry(PadMgr* padMgr) {
switch (*msg) { switch (*msg) {
case OS_SC_RETRACE_MSG: case OS_SC_RETRACE_MSG:
if (D_8012D280 > 2) { if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
osSyncPrintf("padmgr_HandleRetraceMsg START %lld\n", OS_CYCLES_TO_USEC(osGetTime())); osSyncPrintf("padmgr_HandleRetraceMsg START %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
} }
PadMgr_HandleRetraceMsg(padMgr); PadMgr_HandleRetrace(padMgr);
if (D_8012D280 > 2) { if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
osSyncPrintf("padmgr_HandleRetraceMsg END %lld\n", OS_CYCLES_TO_USEC(osGetTime())); osSyncPrintf("padmgr_HandleRetraceMsg END %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
} }
break; break;
case OS_SC_PRE_NMI_MSG: case OS_SC_PRE_NMI_MSG:
PadMgr_HandlePreNMI(padMgr); PadMgr_HandlePreNMI(padMgr);
@ -401,13 +513,16 @@ void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr,
osCreateMesgQueue(&padMgr->interruptQueue, padMgr->interruptMsgBuf, ARRAY_COUNT(padMgr->interruptMsgBuf)); osCreateMesgQueue(&padMgr->interruptQueue, padMgr->interruptMsgBuf, ARRAY_COUNT(padMgr->interruptMsgBuf));
IrqMgr_AddClient(padMgr->irqMgr, &padMgr->irqClient, &padMgr->interruptQueue); IrqMgr_AddClient(padMgr->irqMgr, &padMgr->irqClient, &padMgr->interruptQueue);
osCreateMesgQueue(&padMgr->serialLockQueue, padMgr->serialLockMsgBuf, ARRAY_COUNT(padMgr->serialLockMsgBuf));
PadMgr_UnlockSerialMesgQueue(padMgr, serialEventQueue); osCreateMesgQueue(&padMgr->serialLockQueue, &padMgr->serialMsg, 1);
osCreateMesgQueue(&padMgr->lockQueue, padMgr->lockMsgBuf, ARRAY_COUNT(padMgr->lockMsgBuf)); PadMgr_ReleaseSerialEventQueue(padMgr, serialEventQueue);
osCreateMesgQueue(&padMgr->lockQueue, &padMgr->lockMsg, 1);
PadMgr_UnlockPadData(padMgr); PadMgr_UnlockPadData(padMgr);
PadSetup_Init(serialEventQueue, (u8*)&padMgr->validCtrlrsMask, padMgr->padStatus); PadSetup_Init(serialEventQueue, (u8*)&padMgr->validCtrlrsMask, padMgr->padStatus);
padMgr->nControllers = 4; padMgr->nControllers = MAXCONTROLLERS;
osContSetCh(padMgr->nControllers); osContSetCh(padMgr->nControllers);
osCreateThread(&padMgr->thread, id, (void (*)(void*))PadMgr_ThreadEntry, padMgr, stack, priority); osCreateThread(&padMgr->thread, id, (void (*)(void*))PadMgr_ThreadEntry, padMgr, stack, priority);

View file

@ -9,16 +9,16 @@ s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status) {
if (ret != 0) { if (ret != 0) {
return ret; return ret;
} }
if (*outMask == 0xFF) { if (*outMask == 0xFF) {
if (osContStartQuery(mq) != 0) { if (osContStartQuery(mq) != 0) {
return 1; return 1;
} }
osRecvMesg(mq, NULL, OS_MESG_BLOCK); osRecvMesg(mq, NULL, OS_MESG_BLOCK);
osContGetQuery(status); osContGetQuery(status);
*outMask = 0; *outMask = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < MAXCONTROLLERS; i++) {
switch (status[i].errno) { switch (status[i].errno) {
case 0: case 0:
if (status[i].type == CONT_TYPE_NORMAL) { if (status[i].type == CONT_TYPE_NORMAL) {

View file

@ -167,7 +167,7 @@ void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, Gam
y = 212; y = 212;
if (SREG(0) > 2) { if (SREG(0) > 2) {
if (ZeldaArena_IsInitalized()) { if (ZeldaArena_IsInitialized()) {
ZeldaArena_GetSizes(&zeldaFreeMax, &zeldaFree, &zeldaAlloc); ZeldaArena_GetSizes(&zeldaFreeMax, &zeldaFree, &zeldaAlloc);
SpeedMeter_InitAllocEntry(&entry, zeldaFree + zeldaAlloc, zeldaAlloc, GPACK_RGBA5551(0, 0, 255, 1), SpeedMeter_InitAllocEntry(&entry, zeldaFree + zeldaAlloc, zeldaAlloc, GPACK_RGBA5551(0, 0, 255, 1),
GPACK_RGBA5551(255, 255, 255, 1), ulx, lrx, y, y + 1); GPACK_RGBA5551(255, 255, 255, 1), ulx, lrx, y, y + 1);

View file

@ -105,6 +105,6 @@ void SystemArena_Cleanup(void) {
__osMallocCleanup(&gSystemArena); __osMallocCleanup(&gSystemArena);
} }
u8 SystemArena_IsInitalized(void) { u8 SystemArena_IsInitialized(void) {
return __osMallocIsInitalized(&gSystemArena); return __osMallocIsInitialized(&gSystemArena);
} }

View file

@ -2939,7 +2939,7 @@ void func_800328D4(PlayState* play, ActorContext* actorCtx, Player* player, u32
if ((actor->update != NULL) && ((Player*)actor != player) && CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_0)) { if ((actor->update != NULL) && ((Player*)actor != player) && CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_0)) {
// This block below is for determining the closest actor to player in determining the volume // This block below is for determining the closest actor to player in determining the volume
// used while playing enemy bgm music // used while playing enemy background music
if ((actorCategory == ACTORCAT_ENEMY) && CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2) && if ((actorCategory == ACTORCAT_ENEMY) && CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2) &&
(actor->xyzDistToPlayerSq < SQ(500.0f)) && (actor->xyzDistToPlayerSq < sbgmEnemyDistSq)) { (actor->xyzDistToPlayerSq < SQ(500.0f)) && (actor->xyzDistToPlayerSq < sbgmEnemyDistSq)) {
actorCtx->targetCtx.bgmEnemy = actor; actorCtx->targetCtx.bgmEnemy = actor;

View file

@ -68,8 +68,8 @@ f32 Camera_InterpolateCurve(f32 a, f32 b) {
} }
/* /*
* Performs linear interpoloation between `cur` and `target`. If `cur` is within * Performs linear interpolation between `cur` and `target`. If `cur` is within
* `minDiff` units, The result is rounded up to `target` * `minDiff` units, the result is rounded up to `target`
*/ */
f32 Camera_LERPCeilF(f32 target, f32 cur, f32 stepScale, f32 minDiff) { f32 Camera_LERPCeilF(f32 target, f32 cur, f32 stepScale, f32 minDiff) {
f32 diff = target - cur; f32 diff = target - cur;
@ -87,8 +87,8 @@ f32 Camera_LERPCeilF(f32 target, f32 cur, f32 stepScale, f32 minDiff) {
} }
/* /*
* Performs linear interpoloation between `cur` and `target`. If `cur` is within * Performs linear interpolation between `cur` and `target`. If `cur` is within
* `minDiff` units, The result is rounded down to `cur` * `minDiff` units, the result is rounded down to `cur`
*/ */
f32 Camera_LERPFloorF(f32 target, f32 cur, f32 stepScale, f32 minDiff) { f32 Camera_LERPFloorF(f32 target, f32 cur, f32 stepScale, f32 minDiff) {
f32 diff = target - cur; f32 diff = target - cur;
@ -106,8 +106,8 @@ f32 Camera_LERPFloorF(f32 target, f32 cur, f32 stepScale, f32 minDiff) {
} }
/* /*
* Performs linear interpoloation between `cur` and `target`. If `cur` is within * Performs linear interpolation between `cur` and `target`. If `cur` is within
* `minDiff` units, The result is rounded up to `target` * `minDiff` units, the result is rounded up to `target`
*/ */
s16 Camera_LERPCeilS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { s16 Camera_LERPCeilS(s16 target, s16 cur, f32 stepScale, s16 minDiff) {
s16 diff = target - cur; s16 diff = target - cur;
@ -125,8 +125,8 @@ s16 Camera_LERPCeilS(s16 target, s16 cur, f32 stepScale, s16 minDiff) {
} }
/* /*
* Performs linear interpoloation between `cur` and `target`. If `cur` is within * Performs linear interpolation between `cur` and `target`. If `cur` is within
* `minDiff` units, The result is rounded down to `cur` * `minDiff` units, the result is rounded down to `cur`
*/ */
s16 Camera_LERPFloorS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { s16 Camera_LERPFloorS(s16 target, s16 cur, f32 stepScale, s16 minDiff) {
s16 diff = target - cur; s16 diff = target - cur;
@ -144,8 +144,8 @@ s16 Camera_LERPFloorS(s16 target, s16 cur, f32 stepScale, s16 minDiff) {
} }
/* /*
* Performs linear interpoloation between `cur` and `target`. If `cur` is within * Performs linear interpolation between `cur` and `target`. If `cur` is within
* `minDiff` units, The result is rounded up to `target` * `minDiff` units, the result is rounded up to `target`
*/ */
void Camera_LERPCeilVec3f(Vec3f* target, Vec3f* cur, f32 yStepScale, f32 xzStepScale, f32 minDiff) { void Camera_LERPCeilVec3f(Vec3f* target, Vec3f* cur, f32 yStepScale, f32 xzStepScale, f32 minDiff) {
cur->x = Camera_LERPCeilF(target->x, cur->x, xzStepScale, minDiff); cur->x = Camera_LERPCeilF(target->x, cur->x, xzStepScale, minDiff);
@ -155,7 +155,7 @@ void Camera_LERPCeilVec3f(Vec3f* target, Vec3f* cur, f32 yStepScale, f32 xzStepS
void func_80043ABC(Camera* camera) { void func_80043ABC(Camera* camera) {
camera->yawUpdateRateInv = 100.0f; camera->yawUpdateRateInv = 100.0f;
camera->pitchUpdateRateInv = R_CAM_DEFA_PHI_UPDRATE; camera->pitchUpdateRateInv = R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV;
camera->rUpdateRateInv = OREG(6); camera->rUpdateRateInv = OREG(6);
camera->xzOffsetUpdateRate = CAM_DATA_SCALED(OREG(2)); camera->xzOffsetUpdateRate = CAM_DATA_SCALED(OREG(2));
camera->yOffsetUpdateRate = CAM_DATA_SCALED(OREG(3)); camera->yOffsetUpdateRate = CAM_DATA_SCALED(OREG(3));
@ -574,71 +574,83 @@ s16 Camera_XZAngle(Vec3f* to, Vec3f* from) {
return CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(from->x - to->x, from->z - to->z))); return CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(from->x - to->x, from->z - to->z)));
} }
s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) { s16 Camera_GetPitchAdjFromFloorHeightDiffs(Camera* camera, s16 viewYaw, s16 initAndReturnZero) {
static f32 D_8015CE50; static f32 sFloorYNear;
static f32 D_8015CE54; static f32 sFloorYFar;
static CamColChk D_8015CE58; static CamColChk sFarColChk;
Vec3f playerPos; Vec3f playerPos;
Vec3f rotatedPos; Vec3f nearPos;
Vec3f floorNorm; Vec3f floorNorm;
f32 temp_f2; f32 checkOffsetY;
s16 temp_s0; s16 pitchNear;
s16 temp_s1; s16 pitchFar;
f32 phi_f18; f32 floorYDiffFar;
f32 sinYaw; f32 viewForwardsUnitX;
f32 cosYaw; f32 viewForwardsUnitZ;
s32 bgId; s32 bgId;
f32 sp30; f32 nearDist;
f32 sp2C; f32 farDist;
f32 phi_f16; f32 floorYDiffNear;
f32 playerHeight; f32 playerHeight;
sinYaw = Math_SinS(yaw); viewForwardsUnitX = Math_SinS(viewYaw);
cosYaw = Math_CosS(yaw); viewForwardsUnitZ = Math_CosS(viewYaw);
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
temp_f2 = CAM_DATA_SCALED(OREG(19)) * playerHeight; checkOffsetY = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC) * playerHeight;
sp30 = CAM_DATA_SCALED(OREG(17)) * playerHeight; nearDist = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC) * playerHeight;
sp2C = CAM_DATA_SCALED(OREG(18)) * playerHeight; farDist = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC) * playerHeight;
playerPos.x = camera->playerPosRot.pos.x; playerPos.x = camera->playerPosRot.pos.x;
playerPos.y = camera->playerGroundY + temp_f2; playerPos.y = camera->playerGroundY + checkOffsetY;
playerPos.z = camera->playerPosRot.pos.z; playerPos.z = camera->playerPosRot.pos.z;
rotatedPos.x = playerPos.x + (sp30 * sinYaw);
rotatedPos.y = playerPos.y; nearPos.x = playerPos.x + (nearDist * viewForwardsUnitX);
rotatedPos.z = playerPos.z + (sp30 * cosYaw); nearPos.y = playerPos.y;
if (arg2 || (camera->play->state.frames % 2) == 0) { nearPos.z = playerPos.z + (nearDist * viewForwardsUnitZ);
D_8015CE58.pos.x = playerPos.x + (sp2C * sinYaw);
D_8015CE58.pos.y = playerPos.y; if (initAndReturnZero || (camera->play->state.frames % 2) == 0) {
D_8015CE58.pos.z = playerPos.z + (sp2C * cosYaw); sFarColChk.pos.x = playerPos.x + (farDist * viewForwardsUnitX);
Camera_BGCheckInfo(camera, &playerPos, &D_8015CE58); sFarColChk.pos.y = playerPos.y;
if (arg2) { sFarColChk.pos.z = playerPos.z + (farDist * viewForwardsUnitZ);
D_8015CE50 = D_8015CE54 = camera->playerGroundY;
Camera_BGCheckInfo(camera, &playerPos, &sFarColChk);
if (initAndReturnZero) {
sFloorYNear = sFloorYFar = camera->playerGroundY;
} }
} else { } else {
sp2C = OLib_Vec3fDistXZ(&playerPos, &D_8015CE58.pos); farDist = OLib_Vec3fDistXZ(&playerPos, &sFarColChk.pos);
D_8015CE58.pos.x += D_8015CE58.norm.x * 5.0f;
D_8015CE58.pos.y += D_8015CE58.norm.y * 5.0f; sFarColChk.pos.x += sFarColChk.norm.x * 5.0f;
D_8015CE58.pos.z += D_8015CE58.norm.z * 5.0f; sFarColChk.pos.y += sFarColChk.norm.y * 5.0f;
if (sp2C < sp30) { sFarColChk.pos.z += sFarColChk.norm.z * 5.0f;
sp30 = sp2C;
D_8015CE50 = D_8015CE54 = Camera_GetFloorYLayer(camera, &floorNorm, &D_8015CE58.pos, &bgId); if (nearDist > farDist) {
nearDist = farDist;
sFloorYNear = sFloorYFar = Camera_GetFloorYLayer(camera, &floorNorm, &sFarColChk.pos, &bgId);
} else { } else {
D_8015CE50 = Camera_GetFloorYLayer(camera, &floorNorm, &rotatedPos, &bgId); sFloorYNear = Camera_GetFloorYLayer(camera, &floorNorm, &nearPos, &bgId);
D_8015CE54 = Camera_GetFloorYLayer(camera, &floorNorm, &D_8015CE58.pos, &bgId); sFloorYFar = Camera_GetFloorYLayer(camera, &floorNorm, &sFarColChk.pos, &bgId);
} }
if (D_8015CE50 == BGCHECK_Y_MIN) { if (sFloorYNear == BGCHECK_Y_MIN) {
D_8015CE50 = camera->playerGroundY; sFloorYNear = camera->playerGroundY;
} }
if (D_8015CE54 == BGCHECK_Y_MIN) { if (sFloorYFar == BGCHECK_Y_MIN) {
D_8015CE54 = D_8015CE50; sFloorYFar = sFloorYNear;
} }
} }
phi_f16 = CAM_DATA_SCALED(OREG(20)) * (D_8015CE50 - camera->playerGroundY);
phi_f18 = (1.0f - CAM_DATA_SCALED(OREG(20))) * (D_8015CE54 - camera->playerGroundY); floorYDiffNear = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT) * (sFloorYNear - camera->playerGroundY);
temp_s0 = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(phi_f16, sp30))); floorYDiffFar =
temp_s1 = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(phi_f18, sp2C))); (1.0f - CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT)) * (sFloorYFar - camera->playerGroundY);
return temp_s0 + temp_s1;
pitchNear = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(floorYDiffNear, nearDist)));
pitchFar = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(floorYDiffFar, farDist)));
return pitchNear + pitchFar;
} }
/** /**
@ -695,12 +707,12 @@ Vec3f* Camera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll
f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) { f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) {
f32 ret; f32 ret;
if (camera->atLERPStepScale < CAM_DATA_SCALED(R_AT_LERP_MIN)) { if (camera->atLERPStepScale < CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_MIN)) {
ret = CAM_DATA_SCALED(R_AT_LERP_MIN); ret = CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_MIN);
} else if (camera->atLERPStepScale >= maxLERPScale) { } else if (camera->atLERPStepScale >= maxLERPScale) {
ret = maxLERPScale; ret = maxLERPScale;
} else { } else {
ret = CAM_DATA_SCALED(R_AT_LERP_SCALE) * camera->atLERPStepScale; ret = CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_FAC) * camera->atLERPStepScale;
} }
return ret; return ret;
@ -1277,7 +1289,7 @@ s16 Camera_CalcDefaultPitch(Camera* camera, s16 arg1, s16 arg2, s16 arg3) {
if (ABS(target) < absCur) { if (ABS(target) < absCur) {
stepScale = (1.0f / camera->pitchUpdateRateInv) * 3.0f; stepScale = (1.0f / camera->pitchUpdateRateInv) * 3.0f;
} else { } else {
t = absCur * (1.0f / R_CAM_MAX_PHI); t = absCur * (1.0f / R_CAM_MAX_PITCH);
pad = Camera_InterpolateCurve(0.8f, 1.0f - t); pad = Camera_InterpolateCurve(0.8f, 1.0f - t);
stepScale = (1.0f / camera->pitchUpdateRateInv) * pad; stepScale = (1.0f / camera->pitchUpdateRateInv) * pad;
} }
@ -1523,24 +1535,26 @@ s32 Camera_Normal1(Camera* camera) {
Camera_LERPCeilF(rwData->swing.swingUpdateRate + (f32)(rwData->swing.swingUpdateRateTimer * 2), Camera_LERPCeilF(rwData->swing.swingUpdateRate + (f32)(rwData->swing.swingUpdateRateTimer * 2),
camera->yawUpdateRateInv, sp98, rate); camera->yawUpdateRateInv, sp98, rate);
camera->pitchUpdateRateInv = camera->pitchUpdateRateInv =
Camera_LERPCeilF((f32)R_CAM_DEFA_PHI_UPDRATE + (f32)(rwData->swing.swingUpdateRateTimer * 2), Camera_LERPCeilF((f32)R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV + (f32)(rwData->swing.swingUpdateRateTimer * 2),
camera->pitchUpdateRateInv, sp9C, rate); camera->pitchUpdateRateInv, sp9C, rate);
rwData->swing.swingUpdateRateTimer--; rwData->swing.swingUpdateRateTimer--;
} else { } else {
camera->yawUpdateRateInv = Camera_LERPCeilF(rwData->swing.swingUpdateRate - camera->yawUpdateRateInv = Camera_LERPCeilF(rwData->swing.swingUpdateRate -
((OREG(49) * 0.01f) * rwData->swing.swingUpdateRate * sp94), ((OREG(49) * 0.01f) * rwData->swing.swingUpdateRate * sp94),
camera->yawUpdateRateInv, sp98, rate); camera->yawUpdateRateInv, sp98, rate);
camera->pitchUpdateRateInv = Camera_LERPCeilF(R_CAM_DEFA_PHI_UPDRATE, camera->pitchUpdateRateInv, sp9C, rate); camera->pitchUpdateRateInv =
Camera_LERPCeilF(R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp9C, rate);
} }
camera->pitchUpdateRateInv = Camera_LERPCeilF(R_CAM_DEFA_PHI_UPDRATE, camera->pitchUpdateRateInv, sp9C, rate); camera->pitchUpdateRateInv =
Camera_LERPCeilF(R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp9C, rate);
camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(2)), camera->xzOffsetUpdateRate, spA0, rate); camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(2)), camera->xzOffsetUpdateRate, spA0, rate);
camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(3)), camera->yOffsetUpdateRate, sp9C, rate); camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(3)), camera->yOffsetUpdateRate, sp9C, rate);
camera->fovUpdateRate = camera->fovUpdateRate =
Camera_LERPCeilF(CAM_DATA_SCALED(OREG(4)), camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, rate); Camera_LERPCeilF(CAM_DATA_SCALED(OREG(4)), camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, rate);
if (roData->interfaceFlags & 1) { if (roData->interfaceFlags & 1) {
t = func_80044ADC(camera, atEyeGeo.yaw - 0x7FFF, 0); t = Camera_GetPitchAdjFromFloorHeightDiffs(camera, atEyeGeo.yaw - 0x7FFF, false);
sp9C = ((1.0f / roData->unk_10) * 0.5f) * (1.0f - camera->speedRatio); sp9C = ((1.0f / roData->unk_10) * 0.5f) * (1.0f - camera->speedRatio);
rwData->slopePitchAdj = rwData->slopePitchAdj =
Camera_LERPCeilS(t, rwData->slopePitchAdj, ((1.0f / roData->unk_10) * 0.5f) + sp9C, 0xF); Camera_LERPCeilS(t, rwData->slopePitchAdj, ((1.0f / roData->unk_10) * 0.5f) + sp9C, 0xF);
@ -1670,7 +1684,7 @@ s32 Camera_Normal2(Camera* camera) {
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
yNormal = yNormal =
(1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
if (R_RELOAD_CAM_PARAMS) { if (R_RELOAD_CAM_PARAMS) {
Camera_CopyPREGToModeValues(camera); Camera_CopyPREGToModeValues(camera);
@ -1740,7 +1754,8 @@ s32 Camera_Normal2(Camera* camera) {
camera->yawUpdateRateInv = Camera_LERPCeilF(roData->unk_0C, camera->yawUpdateRateInv * camera->speedRatio, camera->yawUpdateRateInv = Camera_LERPCeilF(roData->unk_0C, camera->yawUpdateRateInv * camera->speedRatio,
CAM_DATA_SCALED(OREG(25)), 0.1f); CAM_DATA_SCALED(OREG(25)), 0.1f);
camera->pitchUpdateRateInv = Camera_LERPCeilF(OREG(7), camera->pitchUpdateRateInv, spA0, 0.1f); camera->pitchUpdateRateInv =
Camera_LERPCeilF(R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, spA0, 0.1f);
camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(2)), camera->xzOffsetUpdateRate, spA4, 0.1f); camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(2)), camera->xzOffsetUpdateRate, spA4, 0.1f);
camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(3)), camera->yOffsetUpdateRate, spA0, 0.1f); camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(3)), camera->yOffsetUpdateRate, spA0, 0.1f);
camera->fovUpdateRate = camera->fovUpdateRate =
@ -1870,9 +1885,10 @@ s32 Camera_Normal3(Camera* camera) {
rwData->unk_20 = camera->playerGroundY; rwData->unk_20 = camera->playerGroundY;
rwData->swing.unk_16 = rwData->swing.unk_14 = rwData->swing.unk_18 = 0; rwData->swing.unk_16 = rwData->swing.unk_14 = rwData->swing.unk_18 = 0;
rwData->swing.swingUpdateRate = roData->yawUpdateSpeed; rwData->swing.swingUpdateRate = roData->yawUpdateSpeed;
rwData->yawUpdAmt = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - sp7C.yaw) * (1.0f / OREG(23)); rwData->yawUpdAmt =
(s16)((s16)(playerPosRot->rot.y - 0x7FFF) - sp7C.yaw) * (1.0f / R_CAM_DEFAULT_ANIM_TIME);
rwData->distTimer = 10; rwData->distTimer = 10;
rwData->yawTimer = OREG(23); rwData->yawTimer = R_CAM_DEFAULT_ANIM_TIME;
camera->animState = 1; camera->animState = 1;
rwData->swing.swingUpdateRateTimer = 0; rwData->swing.swingUpdateRateTimer = 0;
} }
@ -1887,20 +1903,22 @@ s32 Camera_Normal3(Camera* camera) {
if (rwData->swing.swingUpdateRateTimer != 0) { if (rwData->swing.swingUpdateRateTimer != 0) {
camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdateSpeed + (rwData->swing.swingUpdateRateTimer * 2), camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdateSpeed + (rwData->swing.swingUpdateRateTimer * 2),
camera->yawUpdateRateInv, sp98, 0.1f); camera->yawUpdateRateInv, sp98, 0.1f);
camera->pitchUpdateRateInv = Camera_LERPCeilF((f32)OREG(7) + (rwData->swing.swingUpdateRateTimer * 2), camera->pitchUpdateRateInv =
camera->pitchUpdateRateInv, sp94, 0.1f); Camera_LERPCeilF((f32)R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV + (rwData->swing.swingUpdateRateTimer * 2),
camera->pitchUpdateRateInv, sp94, 0.1f);
if (1) {} if (1) {}
rwData->swing.swingUpdateRateTimer--; rwData->swing.swingUpdateRateTimer--;
} else { } else {
camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdateSpeed, camera->yawUpdateRateInv, sp98, 0.1f); camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdateSpeed, camera->yawUpdateRateInv, sp98, 0.1f);
camera->pitchUpdateRateInv = Camera_LERPCeilF(OREG(7), camera->pitchUpdateRateInv, sp94, 0.1f); camera->pitchUpdateRateInv =
Camera_LERPCeilF(R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp94, 0.1f);
} }
camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(2)), camera->xzOffsetUpdateRate, sp98, 0.1f); camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(2)), camera->xzOffsetUpdateRate, sp98, 0.1f);
camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(3)), camera->yOffsetUpdateRate, sp94, 0.1f); camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(3)), camera->yOffsetUpdateRate, sp94, 0.1f);
camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(4)), camera->fovUpdateRate, sp94, 0.1f); camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(4)), camera->fovUpdateRate, sp94, 0.1f);
t2 = func_80044ADC(camera, sp7C.yaw - 0x7FFF, 1); t2 = Camera_GetPitchAdjFromFloorHeightDiffs(camera, sp7C.yaw - 0x7FFF, true);
sp94 = ((1.0f / roData->unk_10) * 0.5f); sp94 = ((1.0f / roData->unk_10) * 0.5f);
temp_f0 = (((1.0f / roData->unk_10) * 0.5f) * (1.0f - camera->speedRatio)); temp_f0 = (((1.0f / roData->unk_10) * 0.5f) * (1.0f - camera->speedRatio));
rwData->curPitch = Camera_LERPCeilS(t2, rwData->curPitch, sp94 + temp_f0, 0xF); rwData->curPitch = Camera_LERPCeilS(t2, rwData->curPitch, sp94 + temp_f0, 0xF);
@ -1915,11 +1933,11 @@ s32 Camera_Normal3(Camera* camera) {
phi_a0 = roData->pitchTarget - rwData->curPitch; phi_a0 = roData->pitchTarget - rwData->curPitch;
sp84.pitch = Camera_LERPCeilS(phi_a0, sp74.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA); sp84.pitch = Camera_LERPCeilS(phi_a0, sp74.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA);
if (OREG(5) < sp84.pitch) { if (sp84.pitch > R_CAM_MAX_PITCH) {
sp84.pitch = OREG(5); sp84.pitch = R_CAM_MAX_PITCH;
} }
if (sp84.pitch < OREG(34)) { if (sp84.pitch < R_CAM_MIN_PITCH_1) {
sp84.pitch = OREG(34); sp84.pitch = R_CAM_MIN_PITCH_1;
} }
phi_a0 = playerPosRot->rot.y - (s16)(sp74.yaw - 0x7FFF); phi_a0 = playerPosRot->rot.y - (s16)(sp74.yaw - 0x7FFF);
@ -1990,7 +2008,8 @@ s32 Camera_Parallel1(Camera* camera) {
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerHeight)); f32 yNormal =
1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->distTarget = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->distTarget = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
@ -2022,7 +2041,7 @@ s32 Camera_Parallel1(Camera* camera) {
if (roData->interfaceFlags & 4) { if (roData->interfaceFlags & 4) {
rwData->animTimer = 20; rwData->animTimer = 20;
} else { } else {
rwData->animTimer = OREG(23); rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME;
} }
rwData->unk_00.x = 0.0f; rwData->unk_00.x = 0.0f;
rwData->yTarget = playerPosRot->pos.y - camera->playerPosDelta.y; rwData->yTarget = playerPosRot->pos.y - camera->playerPosDelta.y;
@ -2069,7 +2088,7 @@ s32 Camera_Parallel1(Camera* camera) {
Camera_LERPCeilF(CAM_DATA_SCALED(OREG(4)), camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.1f); Camera_LERPCeilF(CAM_DATA_SCALED(OREG(4)), camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.1f);
if (roData->interfaceFlags & 1) { if (roData->interfaceFlags & 1) {
tangle = func_80044ADC(camera, atToEyeDir.yaw - 0x7FFF, 1); tangle = Camera_GetPitchAdjFromFloorHeightDiffs(camera, atToEyeDir.yaw - 0x7FFF, true);
spB8 = ((1.0f / roData->unk_0C) * 0.3f); spB8 = ((1.0f / roData->unk_0C) * 0.3f);
pad2 = (((1.0f / roData->unk_0C) * 0.7f) * (1.0f - camera->speedRatio)); pad2 = (((1.0f / roData->unk_0C) * 0.7f) * (1.0f - camera->speedRatio));
@ -2120,12 +2139,12 @@ s32 Camera_Parallel1(Camera* camera) {
spA8.pitch = Camera_LERPCeilS(phi_a0, atToEyeNextDir.pitch, 1.0f / camera->pitchUpdateRateInv, 4); spA8.pitch = Camera_LERPCeilS(phi_a0, atToEyeNextDir.pitch, 1.0f / camera->pitchUpdateRateInv, 4);
if (spA8.pitch > OREG(5)) { if (spA8.pitch > R_CAM_MAX_PITCH) {
spA8.pitch = OREG(5); spA8.pitch = R_CAM_MAX_PITCH;
} }
if (spA8.pitch < OREG(34)) { if (spA8.pitch < R_CAM_MIN_PITCH_1) {
spA8.pitch = OREG(34); spA8.pitch = R_CAM_MIN_PITCH_1;
} }
} }
Camera_Vec3fVecSphGeoAdd(eyeNext, at, &spA8); Camera_Vec3fVecSphGeoAdd(eyeNext, at, &spA8);
@ -2201,8 +2220,8 @@ s32 Camera_Jump1(Camera* camera) {
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - f32 yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->atYOffset = CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) * playerHeight * yNormal; roData->atYOffset = CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) * playerHeight * yNormal;
roData->distMin = CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) * playerHeight * yNormal; roData->distMin = CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) * playerHeight * yNormal;
@ -2243,14 +2262,15 @@ s32 Camera_Jump1(Camera* camera) {
if (rwData->swing.swingUpdateRateTimer != 0) { if (rwData->swing.swingUpdateRateTimer != 0) {
camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpateRateTarget + rwData->swing.swingUpdateRateTimer, camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpateRateTarget + rwData->swing.swingUpdateRateTimer,
camera->yawUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f); camera->yawUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f);
camera->pitchUpdateRateInv = Camera_LERPCeilF((f32)R_CAM_DEFA_PHI_UPDRATE + rwData->swing.swingUpdateRateTimer, camera->pitchUpdateRateInv =
camera->pitchUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f); Camera_LERPCeilF((f32)R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV + rwData->swing.swingUpdateRateTimer,
camera->pitchUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f);
rwData->swing.swingUpdateRateTimer--; rwData->swing.swingUpdateRateTimer--;
} else { } else {
camera->yawUpdateRateInv = camera->yawUpdateRateInv =
Camera_LERPCeilF(roData->yawUpateRateTarget, camera->yawUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f); Camera_LERPCeilF(roData->yawUpateRateTarget, camera->yawUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f);
camera->pitchUpdateRateInv = camera->pitchUpdateRateInv = Camera_LERPCeilF((f32)R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV,
Camera_LERPCeilF((f32)R_CAM_DEFA_PHI_UPDRATE, camera->pitchUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f); camera->pitchUpdateRateInv, CAM_DATA_SCALED(OREG(26)), 0.1f);
} }
camera->xzOffsetUpdateRate = camera->xzOffsetUpdateRate =
@ -2285,11 +2305,11 @@ s32 Camera_Jump1(Camera* camera) {
eyeDiffSph.r = roData->distMax; eyeDiffSph.r = roData->distMax;
} }
// Clamp the phi rotation at R_CAM_MAX_PHI AND R_CAM_MIN_PHI2 // Clamp the phi rotation at R_CAM_MAX_PITCH AND R_CAM_MIN_PITCH_2
if (eyeDiffSph.pitch > R_CAM_MAX_PHI) { if (eyeDiffSph.pitch > R_CAM_MAX_PITCH) {
eyeDiffSph.pitch = R_CAM_MAX_PHI; eyeDiffSph.pitch = R_CAM_MAX_PITCH;
} else if (eyeDiffSph.pitch < R_CAM_MIN_PHI2) { } else if (eyeDiffSph.pitch < R_CAM_MIN_PITCH_2) {
eyeDiffSph.pitch = R_CAM_MIN_PHI2; eyeDiffSph.pitch = R_CAM_MIN_PITCH_2;
} }
Camera_Vec3fVecSphGeoAdd(&newEye, at, &eyeDiffSph); Camera_Vec3fVecSphGeoAdd(&newEye, at, &eyeDiffSph);
@ -2356,7 +2376,8 @@ s32 Camera_Jump2(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
yNormal = (1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerHeight)); yNormal =
1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->atYOffset = roData->atYOffset =
CAM_DATA_SCALED((camera->playerPosDelta.y > 0.0f ? -10.0f : 10.0f) + GET_NEXT_RO_DATA(values)) * CAM_DATA_SCALED((camera->playerPosDelta.y > 0.0f ? -10.0f : 10.0f) + GET_NEXT_RO_DATA(values)) *
playerHeight * yNormal; playerHeight * yNormal;
@ -2396,7 +2417,7 @@ s32 Camera_Jump2(Camera* camera) {
} }
yawDiff = (s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNextDir.yaw; yawDiff = (s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNextDir.yaw;
rwData->initYawDiff = ((yawDiff / OREG(23)) / 4) * 3; rwData->initYawDiff = ((yawDiff / R_CAM_DEFAULT_ANIM_TIME) / 4) * 3;
if (roData->interfaceFlags & 2) { if (roData->interfaceFlags & 2) {
rwData->yawAdj = 0xA; rwData->yawAdj = 0xA;
} else { } else {
@ -2406,7 +2427,7 @@ s32 Camera_Jump2(Camera* camera) {
playerPosRot->pos.x -= camera->playerPosDelta.x; playerPosRot->pos.x -= camera->playerPosDelta.x;
playerPosRot->pos.y -= camera->playerPosDelta.y; playerPosRot->pos.y -= camera->playerPosDelta.y;
playerPosRot->pos.z -= camera->playerPosDelta.z; playerPosRot->pos.z -= camera->playerPosDelta.z;
rwData->animTimer = OREG(23); rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME;
camera->animState++; camera->animState++;
camera->atLERPStepScale = roData->atLERPStepScale; camera->atLERPStepScale = roData->atLERPStepScale;
} }
@ -2560,8 +2581,8 @@ s32 Camera_Jump3(Camera* camera) {
if (RELOAD_PARAMS(camera) || modeSwitch || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || modeSwitch || R_RELOAD_CAM_PARAMS) {
values = sCameraSettings[camera->setting].cameraModes[rwData->mode].values; values = sCameraSettings[camera->setting].cameraModes[rwData->mode].values;
yNormal = ((1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight))); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
t2 = CAM_DATA_SCALED(playerHeight) * yNormal; t2 = CAM_DATA_SCALED(playerHeight) * yNormal;
roData->yOffset = GET_NEXT_RO_DATA(values) * t2; roData->yOffset = GET_NEXT_RO_DATA(values) * t2;
roData->distMin = GET_NEXT_RO_DATA(values) * t2; roData->distMin = GET_NEXT_RO_DATA(values) * t2;
@ -2660,12 +2681,12 @@ s32 Camera_Jump3(Camera* camera) {
eyeDiffSph.pitch = Camera_CalcDefaultPitch(camera, eyeNextAtOffset.pitch, roData->pitchTarget, 0); eyeDiffSph.pitch = Camera_CalcDefaultPitch(camera, eyeNextAtOffset.pitch, roData->pitchTarget, 0);
} }
if (eyeDiffSph.pitch > OREG(5)) { if (eyeDiffSph.pitch > R_CAM_MAX_PITCH) {
eyeDiffSph.pitch = OREG(5); eyeDiffSph.pitch = R_CAM_MAX_PITCH;
} }
if (eyeDiffSph.pitch < OREG(34)) { if (eyeDiffSph.pitch < R_CAM_MIN_PITCH_1) {
eyeDiffSph.pitch = OREG(34); eyeDiffSph.pitch = R_CAM_MIN_PITCH_1;
} }
Camera_Vec3fVecSphGeoAdd(eyeNext, at, &eyeDiffSph); Camera_Vec3fVecSphGeoAdd(eyeNext, at, &eyeDiffSph);
@ -2751,7 +2772,8 @@ s32 Camera_Battle1(Camera* camera) {
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerHeight)); f32 yNormal =
1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->distance = GET_NEXT_RO_DATA(values); roData->distance = GET_NEXT_RO_DATA(values);
@ -2837,7 +2859,7 @@ s32 Camera_Battle1(Camera* camera) {
Camera_ChangeMode(camera, CAM_MODE_TARGET); Camera_ChangeMode(camera, CAM_MODE_TARGET);
return true; return true;
} }
rwData->animTimer = OREG(23) + OREG(24); rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME + OREG(24);
rwData->initialEyeToAtYaw = atToEyeDir.yaw; rwData->initialEyeToAtYaw = atToEyeDir.yaw;
rwData->initialEyeToAtPitch = atToEyeDir.pitch; rwData->initialEyeToAtPitch = atToEyeDir.pitch;
rwData->initialEyeToAtDist = atToEyeDir.r; rwData->initialEyeToAtDist = atToEyeDir.r;
@ -2894,7 +2916,7 @@ s32 Camera_Battle1(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&playerToTargetDir, at, eye); OLib_Vec3fDiffToVecSphGeo(&playerToTargetDir, at, eye);
playerToTargetDir.yaw = tmpAng2 - 0x7FFF; playerToTargetDir.yaw = tmpAng2 - 0x7FFF;
var2 = 1.0f / OREG(23); var2 = 1.0f / R_CAM_DEFAULT_ANIM_TIME;
var3 = (rwData->initialEyeToAtDist - playerToTargetDir.r) * var2; var3 = (rwData->initialEyeToAtDist - playerToTargetDir.r) * var2;
tmpAng1 = (s16)(rwData->initialEyeToAtYaw - playerToTargetDir.yaw) * var2; tmpAng1 = (s16)(rwData->initialEyeToAtYaw - playerToTargetDir.yaw) * var2;
tmpAng2 = (s16)(rwData->initialEyeToAtPitch - playerToTargetDir.pitch) * var2; tmpAng2 = (s16)(rwData->initialEyeToAtPitch - playerToTargetDir.pitch) * var2;
@ -2992,8 +3014,8 @@ s32 Camera_Battle4(Camera* camera) {
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - f32 yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->rTarget = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->rTarget = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
@ -3103,7 +3125,8 @@ s32 Camera_KeepOn1(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerHeight)); f32 yNormal =
1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->unk_04 = GET_NEXT_RO_DATA(values); roData->unk_04 = GET_NEXT_RO_DATA(values);
@ -3132,7 +3155,7 @@ s32 Camera_KeepOn1(Camera* camera) {
rwData->unk_10 = 0; rwData->unk_10 = 0;
rwData->unk_04 = 0.0f; rwData->unk_04 = 0.0f;
rwData->unk_0C = camera->target; rwData->unk_0C = camera->target;
rwData->unk_16 = OREG(23) + OREG(24); rwData->unk_16 = R_CAM_DEFAULT_ANIM_TIME + OREG(24);
rwData->unk_12 = spC0.yaw; rwData->unk_12 = spC0.yaw;
rwData->unk_14 = spC0.pitch; rwData->unk_14 = spC0.pitch;
rwData->unk_00 = spC0.r; rwData->unk_00 = spC0.r;
@ -3225,7 +3248,7 @@ s32 Camera_KeepOn1(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&spC8, at, eye); OLib_Vec3fDiffToVecSphGeo(&spC8, at, eye);
spC8.yaw = spE2 - 0x7FFF; spC8.yaw = spE2 - 0x7FFF;
t2 = 1.0f / OREG(23); t2 = 1.0f / R_CAM_DEFAULT_ANIM_TIME;
spE8 = (rwData->unk_00 - spC8.r) * t2; spE8 = (rwData->unk_00 - spC8.r) * t2;
spE2 = (s16)(rwData->unk_12 - spC8.yaw) * t2; spE2 = (s16)(rwData->unk_12 - spC8.yaw) * t2;
spE0 = (s16)(rwData->unk_14 - spC8.pitch) * t2; spE0 = (s16)(rwData->unk_14 - spC8.pitch) * t2;
@ -3344,7 +3367,8 @@ s32 Camera_KeepOn3(Camera* camera) {
camera->unk_14C &= ~0x10; camera->unk_14C &= ~0x10;
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerHeight)); f32 yNormal =
1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->minDist = GET_NEXT_RO_DATA(values); roData->minDist = GET_NEXT_RO_DATA(values);
@ -3420,7 +3444,7 @@ s32 Camera_KeepOn3(Camera* camera) {
angleCnt = ARRAY_COUNT(D_8011D3B0); angleCnt = ARRAY_COUNT(D_8011D3B0);
i = 0; i = 0;
targetToPlayerDir.r = prevTargetPlayerDist; targetToPlayerDir.r = prevTargetPlayerDist;
atToEyeAdj.r = ((roData->minDist + (targetToPlayerDir.r * (1 - 0.5f))) - atToEyeNextDir.r) + atToEyeNextDir.r; atToEyeAdj.r = roData->minDist + (targetToPlayerDir.r * (1 - 0.5f)) - atToEyeNextDir.r + atToEyeNextDir.r;
Camera_Vec3fVecSphGeoAdd(&lineChkPointB, &rwData->atTarget, &atToEyeAdj); Camera_Vec3fVecSphGeoAdd(&lineChkPointB, &rwData->atTarget, &atToEyeAdj);
if (!(roData->flags & 0x80)) { if (!(roData->flags & 0x80)) {
while (i < angleCnt) { while (i < angleCnt) {
@ -3537,7 +3561,7 @@ s32 Camera_KeepOn4(Camera* camera) {
camera->unk_14C &= ~0x10; camera->unk_14C &= ~0x10;
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + t) - ((68.0f / playerHeight) * t); f32 yNormal = 1.0f + t - (68.0f / playerHeight * t);
roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
@ -3947,8 +3971,8 @@ s32 Camera_Fixed2(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - f32 yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * playerHeight) * yNormal; roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * playerHeight) * yNormal;
roData->eyeStepScale = GET_NEXT_SCALED_RO_DATA(values); roData->eyeStepScale = GET_NEXT_SCALED_RO_DATA(values);
@ -4035,7 +4059,7 @@ s32 Camera_Fixed3(Camera* camera) {
*eye = *eyeNext; *eye = *eyeNext;
rwData->rot = bgCamFuncData->rot; rwData->rot = bgCamFuncData->rot;
rwData->fov = bgCamFuncData->fov; rwData->fov = bgCamFuncData->fov;
rwData->jfifId = bgCamFuncData->jfifId; rwData->roomImageOverrideBgCamIndex = bgCamFuncData->roomImageOverrideBgCamIndex;
if (rwData->fov == -1) { if (rwData->fov == -1) {
rwData->fov = 6000; rwData->fov = 6000;
} }
@ -4054,9 +4078,9 @@ s32 Camera_Fixed3(Camera* camera) {
camera->animState++; camera->animState++;
} }
if (bgCamFuncData->jfifId != rwData->jfifId) { if (bgCamFuncData->roomImageOverrideBgCamIndex != rwData->roomImageOverrideBgCamIndex) {
osSyncPrintf("camera: position change %d \n", rwData->jfifId); osSyncPrintf("camera: position change %d \n", rwData->roomImageOverrideBgCamIndex);
rwData->jfifId = bgCamFuncData->jfifId; rwData->roomImageOverrideBgCamIndex = bgCamFuncData->roomImageOverrideBgCamIndex;
rwData->updDirTimer = 5; rwData->updDirTimer = 5;
} }
@ -4104,7 +4128,8 @@ s32 Camera_Fixed4(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = ((1.0f + CAM_DATA_SCALED(OREG(46))) - (CAM_DATA_SCALED(OREG(46)) * (68.0f / playerYOffset))); f32 yNormal = 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) -
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerYOffset));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerYOffset * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerYOffset * yNormal;
roData->speedToEyePos = GET_NEXT_SCALED_RO_DATA(values); roData->speedToEyePos = GET_NEXT_SCALED_RO_DATA(values);
@ -4230,7 +4255,7 @@ s32 Camera_Subj3(Camera* camera) {
rwData->r = sp7C.r; rwData->r = sp7C.r;
rwData->yaw = sp7C.yaw; rwData->yaw = sp7C.yaw;
rwData->pitch = sp7C.pitch; rwData->pitch = sp7C.pitch;
rwData->animTimer = OREG(23); rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME;
camera->dist = roData->eyeNextDist; camera->dist = roData->eyeNextDist;
camera->animState++; camera->animState++;
camera->rUpdateRateInv = 1.0f; camera->rUpdateRateInv = 1.0f;
@ -4247,7 +4272,7 @@ s32 Camera_Subj3(Camera* camera) {
at->y = at->y + (sp98.y - pad2->y) * temp_f0_3; at->y = at->y + (sp98.y - pad2->y) * temp_f0_3;
at->z = at->z + (sp98.z - pad2->z) * temp_f0_3; at->z = at->z + (sp98.z - pad2->z) * temp_f0_3;
temp_f0_3 = (1.0f / OREG(23)); temp_f0_3 = (1.0f / R_CAM_DEFAULT_ANIM_TIME);
sp58 = (tsph.r - sp84.r) * temp_f0_3; sp58 = (tsph.r - sp84.r) * temp_f0_3;
sp52 = (s16)(tsph.yaw - sp84.yaw) * temp_f0_3; sp52 = (s16)(tsph.yaw - sp84.yaw) * temp_f0_3;
sp50 = (s16)(tsph.pitch - sp84.pitch) * temp_f0_3; sp50 = (s16)(tsph.pitch - sp84.pitch) * temp_f0_3;
@ -4480,8 +4505,8 @@ s32 Camera_Data4(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
yNormal = (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->fov = GET_NEXT_RO_DATA(values); roData->fov = GET_NEXT_RO_DATA(values);
roData->interfaceFlags = GET_NEXT_RO_DATA(values); roData->interfaceFlags = GET_NEXT_RO_DATA(values);
@ -4556,8 +4581,8 @@ s32 Camera_Unique1(Camera* camera) {
playerHeight = Player_GetHeight(camera->player); playerHeight = Player_GetHeight(camera->player);
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - f32 yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->distMin = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->distMin = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
@ -4585,7 +4610,7 @@ s32 Camera_Unique1(Camera* camera) {
rwData->unk_00 = 0.0f; rwData->unk_00 = 0.0f;
playerWaistPos = camera->player->bodyPartsPos[PLAYER_BODYPART_WAIST]; playerWaistPos = camera->player->bodyPartsPos[PLAYER_BODYPART_WAIST];
OLib_Vec3fDiffToVecSphGeo(&unk908PlayerPosOffset, &playerPosRot->pos, &playerWaistPos); OLib_Vec3fDiffToVecSphGeo(&unk908PlayerPosOffset, &playerPosRot->pos, &playerWaistPos);
rwData->timer = R_DEFA_CAM_ANIM_TIME; rwData->timer = R_CAM_DEFAULT_ANIM_TIME;
rwData->yawTargetAdj = ABS((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw)) < 0x3A98 rwData->yawTargetAdj = ABS((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw)) < 0x3A98
? 0 ? 0
: (((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw) / rwData->timer) / 4) * 3; : (((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw) / rwData->timer) / 4) * 3;
@ -4608,11 +4633,11 @@ s32 Camera_Unique1(Camera* camera) {
phiTarget = roData->pitchTarget; phiTarget = roData->pitchTarget;
sp8C.pitch = Camera_LERPCeilS(phiTarget, eyeNextAtOffset.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA); sp8C.pitch = Camera_LERPCeilS(phiTarget, eyeNextAtOffset.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA);
if (sp8C.pitch > OREG(5)) { if (sp8C.pitch > R_CAM_MAX_PITCH) {
sp8C.pitch = OREG(5); sp8C.pitch = R_CAM_MAX_PITCH;
} }
if (sp8C.pitch < -OREG(5)) { if (sp8C.pitch < -R_CAM_MAX_PITCH) {
sp8C.pitch = -OREG(5); sp8C.pitch = -R_CAM_MAX_PITCH;
} }
if (rwData->timer != 0) { if (rwData->timer != 0) {
@ -4650,8 +4675,8 @@ s32 Camera_Unique2(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = ((1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - f32 yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight))); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->distTarget = GET_NEXT_RO_DATA(values); roData->distTarget = GET_NEXT_RO_DATA(values);
@ -4726,8 +4751,8 @@ s32 Camera_Unique3(Camera* camera) {
camera->unk_14C &= ~0x10; camera->unk_14C &= ~0x10;
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - f32 yNormal =
(CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal;
roData->fov = GET_NEXT_RO_DATA(values); roData->fov = GET_NEXT_RO_DATA(values);
@ -5617,7 +5642,7 @@ s32 Camera_Demo1(Camera* camera) {
switch (camera->animState) { switch (camera->animState) {
case 0: case 0:
// initalize camera state // initialize camera state
rwData->keyframe = 0; rwData->keyframe = 0;
rwData->curFrame = 0.0f; rwData->curFrame = 0.0f;
camera->animState++; camera->animState++;
@ -6149,7 +6174,7 @@ s32 Camera_Demo6(Camera* camera) {
switch (camera->animState) { switch (camera->animState) {
case 0: case 0:
// initalizes the camera state. // initializes the camera state.
rwData->animTimer = 0; rwData->animTimer = 0;
camera->fov = 60.0f; camera->fov = 60.0f;
Actor_GetWorld(&focusPosRot, camFocus); Actor_GetWorld(&focusPosRot, camFocus);
@ -6255,7 +6280,7 @@ s32 Camera_Demo9(Camera* camera) {
switch (camera->animState) { switch (camera->animState) {
case 0: case 0:
// initalize the camera state // initialize the camera state
rwData->keyframe = 0; rwData->keyframe = 0;
rwData->finishAction = 0; rwData->finishAction = 0;
rwData->curFrame = 0.0f; rwData->curFrame = 0.0f;
@ -6276,7 +6301,7 @@ s32 Camera_Demo9(Camera* camera) {
// if the animation timer is still running, run the demo logic // if the animation timer is still running, run the demo logic
// if it is not, then the case will fallthrough to the finish logic. // if it is not, then the case will fallthrough to the finish logic.
// Run the at and eye cs interpoloation functions, if either of them return 1 (that no more points // Run the at and eye cs interpolation functions, if either of them returns 1 (that no more points
// exist) change the animation state to 2 (standby) // exist) change the animation state to 2 (standby)
if (func_800BB2B4(&csEyeUpdate, &newRoll, camFOV, onePointCamData->eyePoints, &rwData->keyframe, if (func_800BB2B4(&csEyeUpdate, &newRoll, camFOV, onePointCamData->eyePoints, &rwData->keyframe,
&rwData->curFrame) != 0 || &rwData->curFrame) != 0 ||
@ -6478,7 +6503,7 @@ s32 Camera_Special5(Camera* camera) {
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
f32 yNormal = f32 yNormal =
(1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / yOffset)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / yOffset));
roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * yOffset) * yNormal; roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * yOffset) * yNormal;
roData->eyeDist = GET_NEXT_RO_DATA(values); roData->eyeDist = GET_NEXT_RO_DATA(values);
@ -6686,7 +6711,7 @@ s32 Camera_Special6(Camera* camera) {
camera->fov += (CAM_DATA_SCALED(fov) - camera->fov) / rwData->animTimer; camera->fov += (CAM_DATA_SCALED(fov) - camera->fov) / rwData->animTimer;
rwData->animTimer--; rwData->animTimer--;
} else { } else {
// Camera following link on the x axis. // Camera following player on the x axis.
sCameraInterfaceFlags &= 0xF0FF; sCameraInterfaceFlags &= 0xF0FF;
eyePosCalc = *eyeNext; eyePosCalc = *eyeNext;
eyePosCalc.x += (playerPosRot->pos.x - eyePosCalc.x) * 0.5f; eyePosCalc.x += (playerPosRot->pos.x - eyePosCalc.x) * 0.5f;
@ -6730,7 +6755,7 @@ s32 Camera_Special9(Camera* camera) {
playerYOffset = Player_GetHeight(camera->player); playerYOffset = Player_GetHeight(camera->player);
camera->unk_14C &= ~0x10; camera->unk_14C &= ~0x10;
yNormal = yNormal =
(1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM)) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerYOffset)); 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerYOffset));
if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
@ -6930,7 +6955,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState
camera->up.y = 1.0f; camera->up.y = 1.0f;
camera->up.z = 0.0f; camera->up.z = 0.0f;
camera->fov = 60.0f; camera->fov = 60.0f;
camera->pitchUpdateRateInv = R_CAM_DEFA_PHI_UPDRATE; camera->pitchUpdateRateInv = R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV;
camera->xzOffsetUpdateRate = CAM_DATA_SCALED(OREG(2)); camera->xzOffsetUpdateRate = CAM_DATA_SCALED(OREG(2));
camera->yOffsetUpdateRate = CAM_DATA_SCALED(OREG(3)); camera->yOffsetUpdateRate = CAM_DATA_SCALED(OREG(3));
camera->fovUpdateRate = CAM_DATA_SCALED(OREG(4)); camera->fovUpdateRate = CAM_DATA_SCALED(OREG(4));
@ -6959,7 +6984,7 @@ void func_80057FC4(Camera* camera) {
if (camera != &camera->play->mainCamera) { if (camera != &camera->play->mainCamera) {
camera->prevSetting = camera->setting = CAM_SET_FREE0; camera->prevSetting = camera->setting = CAM_SET_FREE0;
camera->unk_14C &= ~0x4; camera->unk_14C &= ~0x4;
} else if (camera->play->roomCtx.curRoom.meshHeader->base.type != MESH_HEADER_TYPE_1) { } else if (camera->play->roomCtx.curRoom.roomShape->base.type != ROOM_SHAPE_TYPE_IMAGE) {
switch (camera->play->roomCtx.curRoom.behaviorType1) { switch (camera->play->roomCtx.curRoom.behaviorType1) {
case ROOM_BEHAVIOR_TYPE1_1: case ROOM_BEHAVIOR_TYPE1_1:
Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10);

View file

@ -27,12 +27,62 @@ typedef struct {
/*==================================================================*/ /*==================================================================*/
// Data // Data
s16 sOREGInit[] = { s16 sOREGInit[] = {
0, 1, 5, 5, 5, 14500, 20, 16, 150, 25, 150, 6, 10, 10, 0, 0, 1, 100, 0, // OREG(0)
250, 120, 80, 30, 120, 4, 1, 50, 20, 1800, 50, 50, 50, 20, 20, -10, -5460, -9100, 1, // OREG(1)
-6, 8, 15, 75, 60, 12, 110, 40, 50, 250, -10, 30, 30, 70, 20, 20, 20, 5, // OREG(2)
5, // OREG(3)
5, // OREG(4)
14500, // R_CAM_MAX_PITCH
20, // OREG(6)
16, // R_CAM_DEFAULT_PITCH_UPDATE_RATE_INV
150, // OREG(8)
25, // OREG(9)
150, // OREG(10)
6, // OREG(11)
10, // OREG(12)
10, // OREG(13)
0, // OREG(14)
0, // OREG(15)
1, // OREG(16)
100, // R_CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC
250, // R_CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC
120, // R_CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC
80, // R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT
30, // OREG(21)
120, // OREG(22)
4, // R_CAM_DEFAULT_ANIM_TIME
1, // OREG(24)
50, // OREG(25)
20, // OREG(26)
1800, // OREG(27)
50, // OREG(28)
50, // OREG(29)
50, // OREG(30)
20, // OREG(31)
20, // OREG(32)
-10, // OREG(33)
-5460, // R_CAM_MIN_PITCH_1
-9100, // R_CAM_MIN_PITCH_2
-6, // OREG(36)
8, // OREG(37)
15, // OREG(38)
75, // OREG(39)
60, // OREG(40)
12, // R_CAM_AT_LERP_STEP_SCALE_MIN
110, // R_CAM_AT_LERP_STEP_SCALE_FAC
40, // OREG(43)
50, // OREG(44)
250, // OREG(45)
-10, // R_CAM_YOFFSET_NORM
30, // OREG(47)
30, // OREG(48)
70, // OREG(49)
20, // OREG(50)
20, // OREG(51)
20, // OREG(52)
}; };
s16 sOREGInitCnt = 53; s16 sOREGInitCnt = ARRAY_COUNT(sOREGInit);
s16 sCamDataRegsInit[CAM_DATA_MAX] = { s16 sCamDataRegsInit[CAM_DATA_MAX] = {
-20, // CAM_DATA_Y_OFFSET -20, // CAM_DATA_Y_OFFSET
@ -355,8 +405,8 @@ CameraModeValue sSetNormal3ModeTalkData[] = {
CAM_FUNCDATA_KEEP3(-30, 70, 200, 40, 10, 10, 20, 70, 45, 10, 10, 0x3500), CAM_FUNCDATA_KEEP3(-30, 70, 200, 40, 10, 10, 20, 70, 45, 10, 10, 0x3500),
}; };
/* These values are for when the eye /*
* >= OREG(45) units below the surface of the water. * These values are for when the eye is >= OREG(45) units below the surface of the water.
*/ */
CameraModeValue sSetNormal3ModeBoomerangData[] = { CameraModeValue sSetNormal3ModeBoomerangData[] = {
CAM_FUNCDATA_JUMP3(-40, 150, 250, -5, 18, 5, 60, 60, 40, 0x0005), CAM_FUNCDATA_JUMP3(-40, 150, 250, -5, 18, 5, 60, 60, 40, 0x0005),

View file

@ -104,6 +104,6 @@ void ZeldaArena_Cleanup(void) {
__osMallocCleanup(&sZeldaArena); __osMallocCleanup(&sZeldaArena);
} }
u8 ZeldaArena_IsInitalized(void) { u8 ZeldaArena_IsInitialized(void) {
return __osMallocIsInitalized(&sZeldaArena); return __osMallocIsInitialized(&sZeldaArena);
} }

View file

@ -517,10 +517,10 @@ void Play_Update(PlayState* this) {
// fade out bgm if "continue bgm" flag is not set // fade out bgm if "continue bgm" flag is not set
if (!(gEntranceTable[this->nextEntranceIndex + sceneLayer].field & if (!(gEntranceTable[this->nextEntranceIndex + sceneLayer].field &
ENTRANCE_INFO_CONTINUE_BGM_FLAG)) { ENTRANCE_INFO_CONTINUE_BGM_FLAG)) {
// "Sound initalized. 111" // "Sound initialized. 111"
osSyncPrintf("\n\n\nサウンドイニシャル来ました。111"); osSyncPrintf("\n\n\nサウンドイニシャル来ました。111");
if ((this->transitionType < TRANS_TYPE_MAX) && !Environment_IsForcedSequenceDisabled()) { if ((this->transitionType < TRANS_TYPE_MAX) && !Environment_IsForcedSequenceDisabled()) {
// "Sound initalized. 222" // "Sound initialized. 222"
osSyncPrintf("\n\n\nサウンドイニシャル来ました。222"); osSyncPrintf("\n\n\nサウンドイニシャル来ました。222");
func_800F6964(0x14); func_800F6964(0x14);
gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.seqId = (u8)NA_BGM_DISABLED;
@ -1740,8 +1740,8 @@ void Play_TriggerRespawn(PlayState* this) {
s32 Play_CamIsNotFixed(PlayState* this) { s32 Play_CamIsNotFixed(PlayState* this) {
// SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT was probably intended to be in this condition, // SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT was probably intended to be in this condition,
// but the scene mesh header handles all shop cases regardless // but the room shape type check handles all shop cases regardless
return (this->roomCtx.curRoom.meshHeader->base.type != MESH_HEADER_TYPE_1) && return (this->roomCtx.curRoom.roomShape->base.type != ROOM_SHAPE_TYPE_IMAGE) &&
(R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) && (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED) && (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) && (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED) &&
(R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_MARKET) && (this->sceneId != SCENE_HAIRAL_NIWA); (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_MARKET) && (this->sceneId != SCENE_HAIRAL_NIWA);
} }

View file

@ -1,10 +1,6 @@
#include "global.h" #include "global.h"
#include "vt.h" #include "vt.h"
void Room_Draw0(PlayState* play, Room* room, u32 flags);
void Room_Draw2(PlayState* play, Room* room, u32 flags);
void Room_Draw1(PlayState* play, Room* room, u32 flags);
Vec3f D_801270A0 = { 0.0f, 0.0f, 0.0f }; Vec3f D_801270A0 = { 0.0f, 0.0f, 0.0f };
// unused // unused
@ -22,19 +18,23 @@ Gfx D_801270B0[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
void (*sRoomDrawHandlers[MESH_HEADER_TYPE_MAX])(PlayState* play, Room* room, u32 flags) = { void Room_DrawNormal(PlayState* play, Room* room, u32 flags);
Room_Draw0, void Room_DrawImage(PlayState* play, Room* room, u32 flags);
Room_Draw1, void Room_DrawCullable(PlayState* play, Room* room, u32 flags);
Room_Draw2,
void (*sRoomDrawHandlers[ROOM_SHAPE_TYPE_MAX])(PlayState* play, Room* room, u32 flags) = {
Room_DrawNormal, // ROOM_SHAPE_TYPE_NORMAL
Room_DrawImage, // ROOM_SHAPE_TYPE_IMAGE
Room_DrawCullable, // ROOM_SHAPE_TYPE_CULLABLE
}; };
void func_80095AA0(PlayState* play, Room* room, Input* arg2, UNK_TYPE arg3) { void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3) {
} }
void Room_Draw0(PlayState* play, Room* room, u32 flags) { void Room_DrawNormal(PlayState* play, Room* room, u32 flags) {
s32 i; s32 i;
MeshHeader0* meshHeader0; RoomShapeNormal* roomShape;
MeshHeader01Entry* meshHeader0Entry; RoomShapeDListsEntry* entry;
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 193); OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 193);
@ -52,59 +52,75 @@ void Room_Draw0(PlayState* play, Room* room, u32 flags) {
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
} }
meshHeader0 = &room->meshHeader->meshHeader0; roomShape = &room->roomShape->normal;
meshHeader0Entry = SEGMENTED_TO_VIRTUAL(meshHeader0->entries); entry = SEGMENTED_TO_VIRTUAL(roomShape->entries);
for (i = 0; i < meshHeader0->numEntries; i++) { for (i = 0; i < roomShape->numEntries; i++) {
if ((flags & ROOM_DRAW_OPA) && (meshHeader0Entry->opa != NULL)) { if ((flags & ROOM_DRAW_OPA) && (entry->opa != NULL)) {
gSPDisplayList(POLY_OPA_DISP++, meshHeader0Entry->opa); gSPDisplayList(POLY_OPA_DISP++, entry->opa);
} }
if ((flags & ROOM_DRAW_XLU) && (meshHeader0Entry->xlu != NULL)) { if ((flags & ROOM_DRAW_XLU) && (entry->xlu != NULL)) {
gSPDisplayList(POLY_XLU_DISP++, meshHeader0Entry->xlu); gSPDisplayList(POLY_XLU_DISP++, entry->xlu);
} }
meshHeader0Entry++; entry++;
} }
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 239); CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 239);
} }
#define SHAPE_SORT_MAX 64 typedef enum {
/* 0 */ ROOM_CULL_DEBUG_MODE_OFF,
/* 1 */ ROOM_CULL_DEBUG_MODE_UP_TO_TARGET,
/* 2 */ ROOM_CULL_DEBUG_MODE_ONLY_TARGET
} RoomCullableDebugMode;
typedef struct struct_80095D04 { typedef struct RoomShapeCullableEntryLinked {
/* 0x00 */ MeshHeader2Entry* unk_00; /* 0x00 */ RoomShapeCullableEntry* entry;
/* 0x04 */ f32 unk_04; /* 0x04 */ f32 boundsNearZ;
/* 0x08 */ struct struct_80095D04* unk_08; /* 0x08 */ struct RoomShapeCullableEntryLinked* prev;
/* 0x0C */ struct struct_80095D04* unk_0C; /* 0x0C */ struct RoomShapeCullableEntryLinked* next;
} struct_80095D04; // size = 0x10 } RoomShapeCullableEntryLinked; // size = 0x10
void Room_Draw2(PlayState* play, Room* room, u32 flags) { /**
MeshHeader2* meshHeader2; * Handle room drawing for the "cullable" type of room shape.
MeshHeader2Entry* meshHeader2Entry; *
struct_80095D04 spB8[SHAPE_SORT_MAX]; * Each entry referenced by the room shape struct is attached to display lists, and a position and radius indicating the
struct_80095D04* spB4 = NULL; * bounding sphere for the geometry drawn.
struct_80095D04* spB0 = NULL; * The first step Z-sorts the entries, and excludes the entries with a bounding sphere that is entirely before or
struct_80095D04* iter; * beyond the rendered depth range.
* The second step draws the entries that remain, from nearest to furthest.
*/
void Room_DrawCullable(PlayState* play, Room* room, u32 flags) {
RoomShapeCullable* roomShape;
RoomShapeCullableEntry* roomShapeCullableEntry;
RoomShapeCullableEntryLinked linkedEntriesBuffer[ROOM_SHAPE_CULLABLE_MAX_ENTRIES];
RoomShapeCullableEntryLinked* head = NULL;
RoomShapeCullableEntryLinked* tail = NULL;
RoomShapeCullableEntryLinked* iter;
s32 pad; s32 pad;
struct_80095D04* spA4; RoomShapeCullableEntryLinked* insert;
s32 j; s32 j;
s32 i; s32 i;
Vec3f pos; Vec3f pos;
Vec3f projectedPos; Vec3f projectedPos;
f32 projectedW; f32 projectedW;
s32 pad2; s32 pad2;
MeshHeader2Entry* meshHeader2Entries; RoomShapeCullableEntry* roomShapeCullableEntries;
MeshHeader2Entry* meshHeader2EntryIter; RoomShapeCullableEntry* roomShapeCullableEntryIter;
f32 temp_f2; f32 entryBoundsNearZ;
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287); OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287);
if (flags & ROOM_DRAW_OPA) { if (flags & ROOM_DRAW_OPA) {
func_800342EC(&D_801270A0, play); func_800342EC(&D_801270A0, play);
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
func_80093C80(play); func_80093C80(play);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
} }
if (1) {} if (1) {}
if (flags & ROOM_DRAW_XLU) { if (flags & ROOM_DRAW_XLU) {
func_8003435C(&D_801270A0, play); func_8003435C(&D_801270A0, play);
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
@ -112,80 +128,103 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
} }
meshHeader2 = &room->meshHeader->meshHeader2; roomShape = &room->roomShape->cullable;
meshHeader2Entry = SEGMENTED_TO_VIRTUAL(meshHeader2->entries); roomShapeCullableEntry = SEGMENTED_TO_VIRTUAL(roomShape->entries);
spA4 = spB8; insert = linkedEntriesBuffer;
ASSERT(meshHeader2->numEntries <= SHAPE_SORT_MAX, "polygon2->num <= SHAPE_SORT_MAX", "../z_room.c", 317); ASSERT(roomShape->numEntries <= ROOM_SHAPE_CULLABLE_MAX_ENTRIES, "polygon2->num <= SHAPE_SORT_MAX", "../z_room.c",
meshHeader2Entries = meshHeader2Entry; 317);
for (i = 0; i < meshHeader2->numEntries; i++, meshHeader2Entry++) { roomShapeCullableEntries = roomShapeCullableEntry;
pos.x = meshHeader2Entry->pos.x;
pos.y = meshHeader2Entry->pos.y; // Pick and sort entries by depth
pos.z = meshHeader2Entry->pos.z; for (i = 0; i < roomShape->numEntries; i++, roomShapeCullableEntry++) {
// Project the entry position, to get the depth it is at.
pos.x = roomShapeCullableEntry->boundsSphereCenter.x;
pos.y = roomShapeCullableEntry->boundsSphereCenter.y;
pos.z = roomShapeCullableEntry->boundsSphereCenter.z;
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW); SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW);
if (-(f32)meshHeader2Entry->unk_06 < projectedPos.z) {
temp_f2 = projectedPos.z - meshHeader2Entry->unk_06; // If the entry bounding sphere isn't fully before the rendered depth range
if (temp_f2 < play->lightCtx.fogFar) { if (-(f32)roomShapeCullableEntry->boundsSphereRadius < projectedPos.z) {
spA4->unk_00 = meshHeader2Entry;
spA4->unk_04 = temp_f2; // Compute the depth of the nearest point in the entry's bounding sphere
iter = spB4; entryBoundsNearZ = projectedPos.z - roomShapeCullableEntry->boundsSphereRadius;
// If the entry bounding sphere isn't fully beyond the rendered depth range
if (entryBoundsNearZ < play->lightCtx.fogFar) {
// This entry will be rendered
insert->entry = roomShapeCullableEntry;
insert->boundsNearZ = entryBoundsNearZ;
// Insert into the linked list, ordered by ascending depth of the nearest point in the bounding sphere
iter = head;
if (iter == NULL) { if (iter == NULL) {
spB4 = spB0 = spA4; head = tail = insert;
spA4->unk_08 = spA4->unk_0C = NULL; insert->prev = insert->next = NULL;
} else { } else {
do { do {
if (spA4->unk_04 < iter->unk_04) { if (insert->boundsNearZ < iter->boundsNearZ) {
break; break;
} }
iter = iter->unk_0C; iter = iter->next;
} while (iter != NULL); } while (iter != NULL);
if (iter == NULL) { if (iter == NULL) {
spA4->unk_08 = spB0; insert->prev = tail;
spA4->unk_0C = NULL; insert->next = NULL;
spB0->unk_0C = spA4; tail->next = insert;
spB0 = spA4; tail = insert;
} else { } else {
spA4->unk_08 = iter->unk_08; insert->prev = iter->prev;
if (spA4->unk_08 == NULL) { if (insert->prev == NULL) {
spB4 = spA4; head = insert;
} else { } else {
spA4->unk_08->unk_0C = spA4; insert->prev->next = insert;
} }
iter->unk_08 = spA4; iter->prev = insert;
spA4->unk_0C = iter; insert->next = iter;
} }
} }
spA4++;
insert++;
} }
} }
} }
iREG(87) = meshHeader2->numEntries & 0xFFFF & 0xFFFF & 0xFFFF; // if this is real then I might not be // if this is real then I might not be
R_ROOM_CULL_NUM_ENTRIES = roomShape->numEntries & 0xFFFF & 0xFFFF & 0xFFFF;
for (i = 1; spB4 != NULL; spB4 = spB4->unk_0C, i++) { // Draw entries, from nearest to furthest
for (i = 1; head != NULL; head = head->next, i++) {
Gfx* displayList; Gfx* displayList;
meshHeader2Entry = spB4->unk_00; roomShapeCullableEntry = head->entry;
if (iREG(86) != 0) {
meshHeader2EntryIter = meshHeader2Entries; if (R_ROOM_CULL_DEBUG_MODE != ROOM_CULL_DEBUG_MODE_OFF) {
for (j = 0; j < meshHeader2->numEntries; j++, meshHeader2EntryIter++) { // Debug mode drawing
if (meshHeader2Entry == meshHeader2EntryIter) {
break; // This loop does nothing? // This loop does nothing
roomShapeCullableEntryIter = roomShapeCullableEntries;
for (j = 0; j < roomShape->numEntries; j++, roomShapeCullableEntryIter++) {
if (roomShapeCullableEntry == roomShapeCullableEntryIter) {
break;
} }
} }
if (((iREG(86) == 1) && (iREG(89) >= i)) || ((iREG(86) == 2) && (iREG(89) == i))) { if (((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_UP_TO_TARGET) && (i <= R_ROOM_CULL_DEBUG_TARGET)) ||
((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_ONLY_TARGET) && (i == R_ROOM_CULL_DEBUG_TARGET))) {
if (flags & ROOM_DRAW_OPA) { if (flags & ROOM_DRAW_OPA) {
displayList = meshHeader2Entry->opa; displayList = roomShapeCullableEntry->opa;
if (displayList != NULL) { if (displayList != NULL) {
gSPDisplayList(POLY_OPA_DISP++, displayList); gSPDisplayList(POLY_OPA_DISP++, displayList);
} }
} }
if (flags & ROOM_DRAW_XLU) { if (flags & ROOM_DRAW_XLU) {
displayList = meshHeader2Entry->xlu; displayList = roomShapeCullableEntry->xlu;
if (displayList != NULL) { if (displayList != NULL) {
gSPDisplayList(POLY_XLU_DISP++, displayList); gSPDisplayList(POLY_XLU_DISP++, displayList);
} }
@ -193,14 +232,14 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
} }
} else { } else {
if (flags & ROOM_DRAW_OPA) { if (flags & ROOM_DRAW_OPA) {
displayList = meshHeader2Entry->opa; displayList = roomShapeCullableEntry->opa;
if (displayList != NULL) { if (displayList != NULL) {
gSPDisplayList(POLY_OPA_DISP++, displayList); gSPDisplayList(POLY_OPA_DISP++, displayList);
} }
} }
if (flags & ROOM_DRAW_XLU) { if (flags & ROOM_DRAW_XLU) {
displayList = meshHeader2Entry->xlu; displayList = roomShapeCullableEntry->xlu;
if (displayList != NULL) { if (displayList != NULL) {
gSPDisplayList(POLY_XLU_DISP++, displayList); gSPDisplayList(POLY_XLU_DISP++, displayList);
} }
@ -208,14 +247,18 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
} }
} }
iREG(88) = i - 1; R_ROOM_CULL_USED_ENTRIES = i - 1;
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 430); CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 430);
} }
#define JPEG_MARKER 0xFFD8FFE0 #define JPEG_MARKER 0xFFD8FFE0
s32 func_80096238(void* data) { /**
* If the data is JPEG, decode it and overwrite the initial data with the result.
* Uses the depth frame buffer as temporary storage.
*/
s32 Room_DecodeJpeg(void* data) {
OSTime time; OSTime time;
if (*(u32*)data == JPEG_MARKER) { if (*(u32*)data == JPEG_MARKER) {
@ -232,10 +275,10 @@ s32 func_80096238(void* data) {
osSyncPrintf("成功…だと思う。 time = %6.3f ms \n", OS_CYCLES_TO_USEC(time) / 1000.0f); osSyncPrintf("成功…だと思う。 time = %6.3f ms \n", OS_CYCLES_TO_USEC(time) / 1000.0f);
// "Writing back to original address from work buffer." // "Writing back to original address from work buffer."
osSyncPrintf("ワークバッファから元のアドレスに書き戻します。\n"); osSyncPrintf("ワークバッファから元のアドレスに書き戻します。\n");
// "If the original buffer size isn't at least 150kb, it will be out of control." // "If the original buffer size isn't at least 150kB, it will be out of control."
osSyncPrintf("元のバッファのサイズが150キロバイト無いと暴走するでしょう。\n"); osSyncPrintf("元のバッファのサイズが150キロバイト無いと暴走するでしょう。\n");
bcopy(gZBuffer, data, sizeof(gZBuffer)); bcopy(gZBuffer, data, sizeof(u16[SCREEN_HEIGHT][SCREEN_WIDTH]));
} else { } else {
osSyncPrintf("失敗!なんで〜\n"); // "Failure! Why is it 〜" osSyncPrintf("失敗!なんで〜\n"); // "Failure! Why is it 〜"
} }
@ -244,72 +287,78 @@ s32 func_80096238(void* data) {
return 0; return 0;
} }
void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 mode0, void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tlutMode,
u16 tlutCount, f32 frameX, f32 frameY) { u16 tlutCount, f32 offsetX, f32 offsetY) {
Gfx* displayListHead; Gfx* gfx = *gfxP;
uObjBg* bg; uObjBg* bg;
displayListHead = *displayList; Room_DecodeJpeg(SEGMENTED_TO_VIRTUAL(tex));
func_80096238(SEGMENTED_TO_VIRTUAL(source));
bg = (uObjBg*)(gfx + 1);
gSPBranchList(gfx, (u32)bg + sizeof(uObjBg));
bg = (uObjBg*)(displayListHead + 1);
gSPBranchList(displayListHead, (u8*)bg + sizeof(uObjBg));
bg->b.imageX = 0; bg->b.imageX = 0;
bg->b.imageW = width * 4; bg->b.imageW = width * (1 << 2);
bg->b.frameX = frameX * 4; bg->b.frameX = offsetX * (1 << 2);
bg->b.imageY = 0; bg->b.imageY = 0;
bg->b.imageH = height * 4; bg->b.imageH = height * (1 << 2);
bg->b.frameY = frameY * 4; bg->b.frameY = offsetY * (1 << 2);
bg->b.imagePtr = source; bg->b.imagePtr = tex;
bg->b.imageLoad = G_BGLT_LOADTILE; bg->b.imageLoad = G_BGLT_LOADTILE;
bg->b.imageFmt = fmt; bg->b.imageFmt = fmt;
bg->b.imageSiz = siz; bg->b.imageSiz = siz;
bg->b.imagePal = 0; bg->b.imagePal = 0;
bg->b.imageFlip = 0; bg->b.imageFlip = 0;
displayListHead = (void*)(bg + 1); gfx = (Gfx*)((u32)bg + sizeof(uObjBg));
if (fmt == G_IM_FMT_CI) { if (fmt == G_IM_FMT_CI) {
gDPLoadTLUT(displayListHead++, tlutCount, 256, tlut); gDPLoadTLUT(gfx++, tlutCount, 256, tlut);
} else { } else {
gDPPipeSync(displayListHead++); gDPPipeSync(gfx++);
} }
if ((fmt == G_IM_FMT_RGBA) && (SREG(26) == 0)) { if ((fmt == G_IM_FMT_RGBA) && !R_ROOM_BG2D_FORCE_SCALEBG) {
bg->b.frameW = width * 4; bg->b.frameW = width * (1 << 2);
bg->b.frameH = height * 4; bg->b.frameH = height * (1 << 2);
guS2DInitBg(bg); guS2DInitBg(bg);
gDPSetOtherMode(displayListHead++, mode0 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, gDPSetOtherMode(gfx++, tlutMode | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE,
G_AC_THRESHOLD | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); G_AC_THRESHOLD | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
gSPBgRectCopy(displayListHead++, bg); gSPBgRectCopy(gfx++, bg);
} else { } else {
bg->s.frameW = width * 4; bg->s.frameW = width * (1 << 2);
bg->s.frameH = height * 4; bg->s.frameH = height * (1 << 2);
bg->s.scaleW = 1024; bg->s.scaleW = 1 << 10;
bg->s.scaleH = 1024; bg->s.scaleH = 1 << 10;
bg->s.imageYorig = bg->b.imageY; bg->s.imageYorig = bg->b.imageY;
gDPSetOtherMode(displayListHead++, gDPSetOtherMode(gfx++,
mode0 | G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | tlutMode | G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TL_TILE |
G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_THRESHOLD | G_ZS_PIXEL | AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | G_AC_THRESHOLD | G_ZS_PIXEL | AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL |
GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_BL, G_BL_1MA) | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_BL, G_BL_1MA) |
GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_BL, G_BL_1MA)); GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_BL, G_BL_1MA));
gDPSetCombineLERP(displayListHead++, 0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1); gDPSetCombineLERP(gfx++, 0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1);
gSPObjRenderMode(displayListHead++, G_OBJRM_ANTIALIAS | G_OBJRM_BILERP); gSPObjRenderMode(gfx++, G_OBJRM_ANTIALIAS | G_OBJRM_BILERP);
gSPBgRect1Cyc(displayListHead++, bg); gSPBgRect1Cyc(gfx++, bg);
} }
gDPPipeSync(displayListHead++); gDPPipeSync(gfx++);
*displayList = displayListHead;
*gfxP = gfx;
} }
void Room_Draw1Single(PlayState* play, Room* room, u32 flags) { #define ROOM_IMAGE_NODRAW_BACKGROUND (1 << 0)
#define ROOM_IMAGE_NODRAW_OPA (1 << 1)
#define ROOM_IMAGE_NODRAW_XLU (1 << 2)
void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) {
Camera* activeCam; Camera* activeCam;
Gfx* spA8; Gfx* gfx;
MeshHeader1Single* meshHeader1Single; RoomShapeImageSingle* roomShape;
MeshHeader01Entry* meshHeader1Entry; RoomShapeDListsEntry* entry;
u32 isFixedCamera; u32 isFixedCamera;
u32 drawBg; u32 drawBackground;
u32 drawOpa; u32 drawOpa;
u32 drawXlu; u32 drawXlu;
@ -317,123 +366,34 @@ void Room_Draw1Single(PlayState* play, Room* room, u32 flags) {
activeCam = GET_ACTIVE_CAM(play); activeCam = GET_ACTIVE_CAM(play);
isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED); isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED);
meshHeader1Single = &room->meshHeader->meshHeader1Single; roomShape = &room->roomShape->image.single;
meshHeader1Entry = SEGMENTED_TO_VIRTUAL(meshHeader1Single->base.entry); entry = SEGMENTED_TO_VIRTUAL(roomShape->base.entry);
drawBg = (flags & ROOM_DRAW_OPA) && isFixedCamera && meshHeader1Single->source && !(SREG(25) & 1); drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (roomShape->source != NULL) &&
drawOpa = (flags & ROOM_DRAW_OPA) && (meshHeader1Entry->opa != NULL) && !(SREG(25) & 2); !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND);
drawXlu = (flags & ROOM_DRAW_XLU) && (meshHeader1Entry->xlu != NULL) && !(SREG(25) & 4); drawOpa = (flags & ROOM_DRAW_OPA) && (entry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA);
drawXlu = (flags & ROOM_DRAW_XLU) && (entry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU);
if (drawOpa || drawBg) { if (drawOpa || drawBackground) {
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
if (drawOpa) { if (drawOpa) {
Gfx_SetupDL_25Opa(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, meshHeader1Entry->opa); gSPDisplayList(POLY_OPA_DISP++, entry->opa);
} }
if (drawBg) { if (drawBackground) {
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2d_fifo); gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2d_fifo);
{ {
Vec3f sp60; Vec3f quakeOffset;
spA8 = POLY_OPA_DISP;
Camera_GetSkyboxOffset(&sp60, activeCam);
func_8009638C(&spA8, meshHeader1Single->source, meshHeader1Single->tlut, meshHeader1Single->width,
meshHeader1Single->height, meshHeader1Single->fmt, meshHeader1Single->siz,
meshHeader1Single->mode0, meshHeader1Single->tlutCount,
(sp60.x + sp60.z) * 1.2f + sp60.y * 0.6f, sp60.y * 2.4f + (sp60.x + sp60.z) * 0.3f);
POLY_OPA_DISP = spA8;
}
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
}
}
if (drawXlu) {
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, meshHeader1Entry->xlu);
}
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 691);
}
BgImage* func_80096A74(MeshHeader1Multi* meshHeader1Multi, PlayState* play) {
Camera* activeCam = GET_ACTIVE_CAM(play);
s32 bgCamIndex = activeCam->bgCamIndex;
s16 jfifId;
Player* player;
BgImage* bgImage;
s32 i;
jfifId = ((BgCamFuncData*)BgCheck_GetBgCamFuncDataImpl(&play->colCtx, bgCamIndex, BGCHECK_SCENE))->jfifId;
if (jfifId >= 0) {
bgCamIndex = jfifId;
}
player = GET_PLAYER(play);
player->actor.params = (player->actor.params & 0xFF00) | bgCamIndex;
bgImage = SEGMENTED_TO_VIRTUAL(meshHeader1Multi->list);
for (i = 0; i < meshHeader1Multi->count; i++) {
if (bgImage->id == bgCamIndex) {
return bgImage;
}
bgImage++;
}
// "z_room.c: Data consistent with camera id does not exist camid=%d"
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, bgCamIndex);
LogUtils_HungupThread("../z_room.c", 726);
return NULL;
}
void Room_Draw1Multi(PlayState* play, Room* room, u32 flags) {
Camera* activeCam;
Gfx* gfx;
MeshHeader1Multi* meshHeader1Multi;
BgImage* bgImage;
MeshHeader01Entry* meshHeader1Entry;
u32 isFixedCamera;
u32 drawBg;
u32 drawOpa;
u32 drawXlu;
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 752);
activeCam = GET_ACTIVE_CAM(play);
isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED);
meshHeader1Multi = &room->meshHeader->meshHeader1Multi;
meshHeader1Entry = SEGMENTED_TO_VIRTUAL(meshHeader1Multi->base.entry);
bgImage = func_80096A74(meshHeader1Multi, play);
drawBg = (flags & ROOM_DRAW_OPA) && isFixedCamera && bgImage->source && !(SREG(25) & 1);
drawOpa = (flags & ROOM_DRAW_OPA) && (meshHeader1Entry->opa != NULL) && !(SREG(25) & 2);
drawXlu = (flags & ROOM_DRAW_XLU) && (meshHeader1Entry->xlu != NULL) && !(SREG(25) & 4);
if (drawOpa || drawBg) {
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
if (drawOpa) {
Gfx_SetupDL_25Opa(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, meshHeader1Entry->opa);
}
if (drawBg) {
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2d_fifo);
{
Vec3f skyboxOffset;
gfx = POLY_OPA_DISP; gfx = POLY_OPA_DISP;
Camera_GetSkyboxOffset(&skyboxOffset, activeCam); Camera_GetSkyboxOffset(&quakeOffset, activeCam);
func_8009638C(&gfx, bgImage->source, bgImage->tlut, bgImage->width, bgImage->height, bgImage->fmt, Room_DrawBackground2D(&gfx, roomShape->source, roomShape->tlut, roomShape->width, roomShape->height,
bgImage->siz, bgImage->mode0, bgImage->tlutCount, roomShape->fmt, roomShape->siz, roomShape->tlutMode, roomShape->tlutCount,
(skyboxOffset.x + skyboxOffset.z) * 1.2f + skyboxOffset.y * 0.6f, (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f,
skyboxOffset.y * 2.4f + (skyboxOffset.x + skyboxOffset.z) * 0.3f); quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f);
POLY_OPA_DISP = gfx; POLY_OPA_DISP = gfx;
} }
@ -445,19 +405,117 @@ void Room_Draw1Multi(PlayState* play, Room* room, u32 flags) {
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
Gfx_SetupDL_25Xlu(play->state.gfxCtx); Gfx_SetupDL_25Xlu(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, meshHeader1Entry->xlu); gSPDisplayList(POLY_XLU_DISP++, entry->xlu);
}
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 691);
}
RoomShapeImageMultiBgEntry* Room_GetImageMultiBgEntry(RoomShapeImageMulti* roomShapeImageMulti, PlayState* play) {
Camera* activeCam = GET_ACTIVE_CAM(play);
s32 bgCamIndex = activeCam->bgCamIndex;
s16 overrideBgCamIndex;
Player* player;
RoomShapeImageMultiBgEntry* bgEntry;
s32 i;
// In mq debug vanilla scenes, overrideBgCamIndex is always -1 or the same as bgCamIndex
overrideBgCamIndex = ((BgCamFuncData*)BgCheck_GetBgCamFuncDataImpl(&play->colCtx, bgCamIndex, BGCHECK_SCENE))
->roomImageOverrideBgCamIndex;
if (overrideBgCamIndex >= 0) {
bgCamIndex = overrideBgCamIndex;
}
player = GET_PLAYER(play);
player->actor.params = (player->actor.params & 0xFF00) | bgCamIndex;
bgEntry = SEGMENTED_TO_VIRTUAL(roomShapeImageMulti->backgrounds);
for (i = 0; i < roomShapeImageMulti->numBackgrounds; i++) {
if (bgEntry->bgCamIndex == bgCamIndex) {
return bgEntry;
}
bgEntry++;
}
// "z_room.c: Data consistent with camera id does not exist camid=%d"
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, bgCamIndex);
LogUtils_HungupThread("../z_room.c", 726);
return NULL;
}
void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) {
Camera* activeCam;
Gfx* gfx;
RoomShapeImageMulti* roomShape;
RoomShapeImageMultiBgEntry* bgEntry;
RoomShapeDListsEntry* dListsEntry;
u32 isFixedCamera;
u32 drawBackground;
u32 drawOpa;
u32 drawXlu;
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 752);
activeCam = GET_ACTIVE_CAM(play);
isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED);
roomShape = &room->roomShape->image.multi;
dListsEntry = SEGMENTED_TO_VIRTUAL(roomShape->base.entry);
bgEntry = Room_GetImageMultiBgEntry(roomShape, play);
drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (bgEntry->source != NULL) &&
!(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND);
drawOpa =
(flags & ROOM_DRAW_OPA) && (dListsEntry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA);
drawXlu =
(flags & ROOM_DRAW_XLU) && (dListsEntry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU);
if (drawOpa || drawBackground) {
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
if (drawOpa) {
Gfx_SetupDL_25Opa(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, dListsEntry->opa);
}
if (drawBackground) {
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2d_fifo);
{
Vec3f quakeOffset;
gfx = POLY_OPA_DISP;
Camera_GetSkyboxOffset(&quakeOffset, activeCam);
Room_DrawBackground2D(&gfx, bgEntry->source, bgEntry->tlut, bgEntry->width, bgEntry->height,
bgEntry->fmt, bgEntry->siz, bgEntry->tlutMode, bgEntry->tlutCount,
(quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f,
quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f);
POLY_OPA_DISP = gfx;
}
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
}
}
if (drawXlu) {
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, dListsEntry->xlu);
} }
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 819); CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 819);
} }
void Room_Draw1(PlayState* play, Room* room, u32 flags) { void Room_DrawImage(PlayState* play, Room* room, u32 flags) {
MeshHeader1Base* meshHeader1Base = &room->meshHeader->meshHeader1Base; RoomShapeImageBase* roomShape = &room->roomShape->image.base;
if (meshHeader1Base->format == MESH_HEADER1_FORMAT_SINGLE) { if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_SINGLE) {
Room_Draw1Single(play, room, flags); Room_DrawImageSingle(play, room, flags);
} else if (meshHeader1Base->format == MESH_HEADER1_FORMAT_MULTI) { } else if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_MULTI) {
Room_Draw1Multi(play, room, flags); Room_DrawImageMulti(play, room, flags);
} else { } else {
LogUtils_HungupThread("../z_room.c", 841); LogUtils_HungupThread("../z_room.c", 841);
} }
@ -578,9 +636,9 @@ s32 func_800973FC(PlayState* play, RoomContext* roomCtx) {
void Room_Draw(PlayState* play, Room* room, u32 flags) { void Room_Draw(PlayState* play, Room* room, u32 flags) {
if (room->segment != NULL) { if (room->segment != NULL) {
gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment); gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment);
ASSERT(room->meshHeader->base.type < ARRAY_COUNTU(sRoomDrawHandlers), ASSERT(room->roomShape->base.type < ARRAY_COUNTU(sRoomDrawHandlers),
"this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125); "this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125);
sRoomDrawHandlers[room->meshHeader->base.type](play, room, flags); sRoomDrawHandlers[room->roomShape->base.type](play, room, flags);
} }
} }

View file

@ -243,8 +243,8 @@ void Scene_CommandRoomBehavior(PlayState* play, SceneCmd* cmd) {
play->msgCtx.disableWarpSongs = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; play->msgCtx.disableWarpSongs = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1;
} }
void Scene_CommandMeshHeader(PlayState* play, SceneCmd* cmd) { void Scene_CommandRoomShape(PlayState* play, SceneCmd* cmd) {
play->roomCtx.curRoom.meshHeader = SEGMENTED_TO_VIRTUAL(cmd->mesh.data); play->roomCtx.curRoom.roomShape = SEGMENTED_TO_VIRTUAL(cmd->mesh.data);
} }
void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) {
@ -480,7 +480,7 @@ void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(PlayState*, SceneCmd*) = {
Scene_CommandSpecialFiles, // SCENE_CMD_ID_SPECIAL_FILES Scene_CommandSpecialFiles, // SCENE_CMD_ID_SPECIAL_FILES
Scene_CommandRoomBehavior, // SCENE_CMD_ID_ROOM_BEHAVIOR Scene_CommandRoomBehavior, // SCENE_CMD_ID_ROOM_BEHAVIOR
Scene_CommandUndefined9, // SCENE_CMD_ID_UNDEFINED_9 Scene_CommandUndefined9, // SCENE_CMD_ID_UNDEFINED_9
Scene_CommandMeshHeader, // SCENE_CMD_ID_MESH_HEADER Scene_CommandRoomShape, // SCENE_CMD_ID_ROOM_SHAPE
Scene_CommandObjectList, // SCENE_CMD_ID_OBJECT_LIST Scene_CommandObjectList, // SCENE_CMD_ID_OBJECT_LIST
Scene_CommandLightList, // SCENE_CMD_ID_LIGHT_LIST Scene_CommandLightList, // SCENE_CMD_ID_LIGHT_LIST
Scene_CommandPathList, // SCENE_CMD_ID_PATH_LIST Scene_CommandPathList, // SCENE_CMD_ID_PATH_LIST

View file

@ -334,7 +334,7 @@ s32 View_ApplyPerspective(View* view) {
Matrix_MtxToMtxF(projection, &mf); Matrix_MtxToMtxF(projection, &mf);
osSyncPrintf("projection\n"); osSyncPrintf("projection\n");
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
osSyncPrintf(" %f %f %f %f\n", mf.mf[i][0], mf.mf[i][1], mf.mf[i][2], mf.mf[i][3]); osSyncPrintf("\t%f\t%f\t%f\t%f\n", mf.mf[i][0], mf.mf[i][1], mf.mf[i][2], mf.mf[i][3]);
} }
osSyncPrintf("\n"); osSyncPrintf("\n");
} }
@ -373,7 +373,7 @@ s32 View_ApplyPerspective(View* view) {
Matrix_MtxToMtxF(view->viewingPtr, &mf); Matrix_MtxToMtxF(view->viewingPtr, &mf);
osSyncPrintf("viewing\n"); osSyncPrintf("viewing\n");
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
osSyncPrintf(" %f %f %f %f\n", mf.mf[i][0], mf.mf[i][1], mf.mf[i][2], mf.mf[i][3]); osSyncPrintf("\t%f\t%f\t%f\t%f\n", mf.mf[i][0], mf.mf[i][1], mf.mf[i][2], mf.mf[i][3]);
} }
osSyncPrintf("\n"); osSyncPrintf("\n");
} }

View file

@ -31,38 +31,38 @@ ENDDATA(__osPiIntTable)
.balign 16 .balign 16
__osIntOffTable: __osIntOffTable:
.byte 0x00 /* redispatch */ .byte 0x00 /* redispatch */
.byte 0x14 /* prenmi */ .byte 0x14 /* prenmi */
.byte 0x18 /* IP6_Hdlr */ .byte 0x18 /* IP6_Hdlr */
.byte 0x18 /* IP6_Hdlr */ .byte 0x18 /* IP6_Hdlr */
.byte 0x1C /* IP7_Hdlr */ .byte 0x1C /* IP7_Hdlr */
.byte 0x1C /* IP7_Hdlr */ .byte 0x1C /* IP7_Hdlr */
.byte 0x1C /* IP7_Hdlr */ .byte 0x1C /* IP7_Hdlr */
.byte 0x1C /* IP7_Hdlr */ .byte 0x1C /* IP7_Hdlr */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x20 /* counter */ .byte 0x20 /* counter */
.byte 0x00 /* redispatch */ .byte 0x00 /* redispatch */
.byte 0x04 /* sw1 */ .byte 0x04 /* sw1 */
.byte 0x08 /* sw2 */ .byte 0x08 /* sw2 */
.byte 0x08 /* sw2 */ .byte 0x08 /* sw2 */
.byte 0x0C /* rcp */ .byte 0x0C /* rcp */
.byte 0x0C /* rcp */ .byte 0x0C /* rcp */
.byte 0x0C /* rcp */ .byte 0x0C /* rcp */
.byte 0x0C /* rcp */ .byte 0x0C /* rcp */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
.byte 0x10 /* cart */ .byte 0x10 /* cart */
__osIntTable: __osIntTable:
.word redispatch .word redispatch

View file

@ -158,7 +158,7 @@ void BgHakaGate_StatueInactive(BgHakaGate* this, PlayState* play) {
void BgHakaGate_StatueIdle(BgHakaGate* this, PlayState* play) { void BgHakaGate_StatueIdle(BgHakaGate* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
s32 linkDirection; s32 playerDirection;
f32 forceDirection; f32 forceDirection;
if (this->dyna.unk_150 != 0.0f) { if (this->dyna.unk_150 != 0.0f) {
@ -166,8 +166,8 @@ void BgHakaGate_StatueIdle(BgHakaGate* this, PlayState* play) {
this->vInitTurnAngle = this->dyna.actor.shape.rot.y - this->dyna.actor.yawTowardsPlayer; this->vInitTurnAngle = this->dyna.actor.shape.rot.y - this->dyna.actor.yawTowardsPlayer;
sStatueDistToPlayer = this->dyna.actor.xzDistToPlayer; sStatueDistToPlayer = this->dyna.actor.xzDistToPlayer;
forceDirection = (this->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; forceDirection = (this->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f;
linkDirection = ((s16)(this->dyna.actor.yawTowardsPlayer - player->actor.shape.rot.y) > 0) ? -1 : 1; playerDirection = ((s16)(this->dyna.actor.yawTowardsPlayer - player->actor.shape.rot.y) > 0) ? -1 : 1;
this->vTurnDirection = linkDirection * forceDirection; this->vTurnDirection = playerDirection * forceDirection;
this->actionFunc = BgHakaGate_StatueTurn; this->actionFunc = BgHakaGate_StatueTurn;
} else { } else {
player->stateFlags2 &= ~PLAYER_STATE2_4; player->stateFlags2 &= ~PLAYER_STATE2_4;

View file

@ -236,7 +236,7 @@ void BgTreemouth_Draw(Actor* thisx, PlayState* play) {
if (GET_EVENTCHKINF(EVENTCHKINF_07)) { if (GET_EVENTCHKINF(EVENTCHKINF_07)) {
alpha = 2150; alpha = 2150;
} }
} else { // neeeded to match } else { // needed to match
} }
if (gSaveContext.sceneLayer == 6) { if (gSaveContext.sceneLayer == 6) {

View file

@ -660,7 +660,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
this->targetPos = this->actor.world.pos; this->targetPos = this->actor.world.pos;
Math_ApproachF(&this->tentMaxAngle, 0.5f, 1.0f, 0.01); Math_ApproachF(&this->tentMaxAngle, 0.5f, 1.0f, 0.01);
Math_ApproachF(&this->tentSpeed, 160.0f, 1.0f, 50.0f); Math_ApproachF(&this->tentSpeed, 160.0f, 1.0f, 50.0f);
if ((this->timers[0] == 0) || (this->linkHitTimer != 0)) { if ((this->timers[0] == 0) || (this->playerHitTimer != 0)) {
dx = this->tentPos[22].x - player->actor.world.pos.x; dx = this->tentPos[22].x - player->actor.world.pos.x;
dy = this->tentPos[22].y - player->actor.world.pos.y; dy = this->tentPos[22].y - player->actor.world.pos.y;
dz = this->tentPos[22].z - player->actor.world.pos.z; dz = this->tentPos[22].z - player->actor.world.pos.z;
@ -670,9 +670,9 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
this->timers[0] = 40; this->timers[0] = 40;
this->tentSpeed = 0; this->tentSpeed = 0;
if ((s16)(this->actor.shape.rot.y - this->actor.yawTowardsPlayer) >= 0) { if ((s16)(this->actor.shape.rot.y - this->actor.yawTowardsPlayer) >= 0) {
this->linkToLeft = false; this->playerToLeft = false;
} else { } else {
this->linkToLeft = true; this->playerToLeft = true;
} }
} else { } else {
this->tentMaxAngle = .001f; this->tentMaxAngle = .001f;
@ -702,7 +702,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
} }
for (indS1 = 0; indS1 < 41; indS1++) { for (indS1 = 0; indS1 < 41; indS1++) {
if (this->timers[0] > 25) { if (this->timers[0] > 25) {
if (!this->linkToLeft) { if (!this->playerToLeft) {
Math_ApproachS(&this->tentRot[indS1].z, sCurlRot[indS1] * 0x100, 1.0f / this->tentMaxAngle, Math_ApproachS(&this->tentRot[indS1].z, sCurlRot[indS1] * 0x100, 1.0f / this->tentMaxAngle,
this->tentSpeed); this->tentSpeed);
} else { } else {
@ -710,7 +710,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
this->tentSpeed); this->tentSpeed);
} }
} else { } else {
if (!this->linkToLeft) { if (!this->playerToLeft) {
Math_ApproachS(&this->tentRot[indS1].z, sGrabRot[indS1] * 0x100, 1.0f / this->tentMaxAngle, Math_ApproachS(&this->tentRot[indS1].z, sGrabRot[indS1] * 0x100, 1.0f / this->tentMaxAngle,
this->tentSpeed); this->tentSpeed);
} else { } else {
@ -725,7 +725,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0xC8); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0xC8);
} }
if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_CURL) { if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_CURL) {
if ((this->timers[0] >= 5) && (this->linkHitTimer != 0) && (player->actor.parent == NULL)) { if ((this->timers[0] >= 5) && (this->playerHitTimer != 0) && (player->actor.parent == NULL)) {
if (play->grabPlayer(play, player)) { if (play->grabPlayer(play, player)) {
player->actor.parent = &this->actor; player->actor.parent = &this->actor;
this->work[MO_TENT_ACTION_STATE] = MO_TENT_GRAB; this->work[MO_TENT_ACTION_STATE] = MO_TENT_GRAB;
@ -1158,7 +1158,7 @@ void BossMo_TentCollisionCheck(BossMo* this, PlayState* play) {
this->cutScale = 1.0f; this->cutScale = 1.0f;
} else if (hurtbox->toucher.dmgFlags & (DMG_JUMP_MASTER | DMG_JUMP_GIANT | DMG_SPIN_MASTER | } else if (hurtbox->toucher.dmgFlags & (DMG_JUMP_MASTER | DMG_JUMP_GIANT | DMG_SPIN_MASTER |
DMG_SPIN_GIANT | DMG_SLASH_GIANT | DMG_SLASH_MASTER)) { DMG_SPIN_GIANT | DMG_SLASH_GIANT | DMG_SLASH_MASTER)) {
this->linkHitTimer = 5; this->playerHitTimer = 5;
} }
this->tentRippleSize = 0.2f; this->tentRippleSize = 0.2f;
for (i2 = 0; i2 < 10; i2++) { for (i2 = 0; i2 < 10; i2++) {
@ -1177,7 +1177,7 @@ void BossMo_TentCollisionCheck(BossMo* this, PlayState* play) {
break; break;
} else if (this->tentCollider.elements[i1].info.toucherFlags & TOUCH_HIT) { } else if (this->tentCollider.elements[i1].info.toucherFlags & TOUCH_HIT) {
this->tentCollider.elements[i1].info.toucherFlags &= ~TOUCH_HIT; this->tentCollider.elements[i1].info.toucherFlags &= ~TOUCH_HIT;
this->linkHitTimer = 5; this->playerHitTimer = 5;
break; break;
} }
} }
@ -2377,8 +2377,8 @@ void BossMo_UpdateTent(Actor* thisx, PlayState* play) {
if (this->work[MO_TENT_INVINC_TIMER] != 0) { if (this->work[MO_TENT_INVINC_TIMER] != 0) {
this->work[MO_TENT_INVINC_TIMER]--; this->work[MO_TENT_INVINC_TIMER]--;
} }
if (this->linkHitTimer != 0) { if (this->playerHitTimer != 0) {
this->linkHitTimer--; this->playerHitTimer--;
} }
if (this->drawActor) { if (this->drawActor) {
@ -2540,7 +2540,7 @@ void BossMo_DrawTentacle(BossMo* this, PlayState* play) {
Vec3s sp84; Vec3s sp84;
Matrix_Push(); Matrix_Push();
if (this->linkToLeft) { if (this->playerToLeft) {
sp8C.x *= -1.0f; sp8C.x *= -1.0f;
} }
Matrix_MultVec3f(&sp8C, &this->grabPosRot.pos); Matrix_MultVec3f(&sp8C, &this->grabPosRot.pos);

View file

@ -67,7 +67,7 @@ typedef struct BossMo {
/* 0x0170 */ s16 zSwing; /* 0x0170 */ s16 zSwing;
/* 0x0172 */ s16 cutIndex; /* 0x0172 */ s16 cutIndex;
/* 0x0174 */ s16 meltIndex; /* 0x0174 */ s16 meltIndex;
/* 0x0176 */ s16 linkToLeft; /* 0x0176 */ s16 playerToLeft;
/* 0x0178 */ s16 mashCounter; /* 0x0178 */ s16 mashCounter;
/* 0x017A */ s16 noBubbles; /* 0x017A */ s16 noBubbles;
/* 0x017C */ s16 sfxTimer; /* 0x017C */ s16 sfxTimer;
@ -87,7 +87,7 @@ typedef struct BossMo {
/* 0x01CE */ s16 attackAngleMod; /* 0x01CE */ s16 attackAngleMod;
/* 0x01D0 */ u8 unk_1D0; // unused? /* 0x01D0 */ u8 unk_1D0; // unused?
/* 0x01D1 */ u8 drawActor; /* 0x01D1 */ u8 drawActor;
/* 0x01D2 */ u8 linkHitTimer; /* 0x01D2 */ u8 playerHitTimer;
/* 0x01D4 */ Vec3f targetPos; /* 0x01D4 */ Vec3f targetPos;
/* 0x01E0 */ f32 tentRippleSize; /* 0x01E0 */ f32 tentRippleSize;
/* 0x01E4 */ PosRot grabPosRot; /* 0x01E4 */ PosRot grabPosRot;

View file

@ -198,7 +198,7 @@ static Vec3f sTwinrovaPillarPos[] = {
{ 0.0f, 380.0f, -580.0f }, { 0.0f, 380.0f, -580.0f },
}; };
static u8 sTwInitalized = false; static u8 sTwInitialized = false;
static InitChainEntry sInitChain[] = { static InitChainEntry sInitChain[] = {
ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE),
@ -488,8 +488,8 @@ void BossTw_Init(Actor* thisx, PlayState* play2) {
this->actor.colChkInfo.health = 0; this->actor.colChkInfo.health = 0;
Collider_InitCylinder(play, &this->collider); Collider_InitCylinder(play, &this->collider);
if (!sTwInitalized) { if (!sTwInitialized) {
sTwInitalized = true; sTwInitialized = true;
play->envCtx.lightSettingOverride = 1; play->envCtx.lightSettingOverride = 1;
play->envCtx.prevLightSetting = 1; play->envCtx.prevLightSetting = 1;
play->envCtx.lightSetting = 1; play->envCtx.lightSetting = 1;
@ -600,7 +600,7 @@ void BossTw_Destroy(Actor* thisx, PlayState* play) {
} }
if (thisx->params == TW_TWINROVA) { if (thisx->params == TW_TWINROVA) {
sTwInitalized = false; sTwInitialized = false;
} }
} }

View file

@ -263,7 +263,7 @@ void EnAni_Update(Actor* thisx, PlayState* play) {
func_800788CC(NA_SE_IT_EARTHQUAKE); func_800788CC(NA_SE_IT_EARTHQUAKE);
} }
} else { } else {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
this->skelAnime.curFrame = 0.0f; this->skelAnime.curFrame = 0.0f;
} }
this->actionFunc(this, play); this->actionFunc(this, play);

View file

@ -303,7 +303,7 @@ void EnCow_Update(Actor* thisx, PlayState* play2) {
CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[1].base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliders[1].base);
Actor_MoveForward(thisx); Actor_MoveForward(thisx);
Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2);
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->skelAnime.animation == &gCowBodyChewAnim) { if (this->skelAnime.animation == &gCowBodyChewAnim) {
Audio_PlayActorSfx2(thisx, NA_SE_EV_COW_CRY); Audio_PlayActorSfx2(thisx, NA_SE_EV_COW_CRY);
Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f,
@ -343,7 +343,7 @@ void func_809DFE98(Actor* thisx, PlayState* play) {
EnCow* this = (EnCow*)thisx; EnCow* this = (EnCow*)thisx;
s32 pad; s32 pad;
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->skelAnime.animation == &gCowTailIdleAnim) { if (this->skelAnime.animation == &gCowTailIdleAnim) {
Animation_Change(&this->skelAnime, &gCowTailSwishAnim, 1.0f, 0.0f, Animation_Change(&this->skelAnime, &gCowTailSwishAnim, 1.0f, 0.0f,
Animation_GetLastFrame(&gCowTailSwishAnim), ANIMMODE_ONCE, 1.0f); Animation_GetLastFrame(&gCowTailSwishAnim), ANIMMODE_ONCE, 1.0f);

View file

@ -398,7 +398,7 @@ void EnCs_Wait(EnCs* this, PlayState* play) {
void EnCs_Talk(EnCs* this, PlayState* play) { void EnCs_Talk(EnCs* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnCs_ChangeAnim(this, this->currentAnimIndex, &this->currentAnimIndex); EnCs_ChangeAnim(this, this->currentAnimIndex, &this->currentAnimIndex);
} }

View file

@ -678,7 +678,7 @@ void EnDodongo_Death(EnDodongo* this, PlayState* play) {
} else if (this->actor.colorFilterTimer == 0) { } else if (this->actor.colorFilterTimer == 0) {
Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4); Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4);
} }
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->timer == 0) { if (this->timer == 0) {
bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x,
this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 6, BOMB_BODY); this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 6, BOMB_BODY);

View file

@ -236,7 +236,7 @@ void EnDs_Wait(EnDs* this, PlayState* play) {
void EnDs_Update(Actor* thisx, PlayState* play) { void EnDs_Update(Actor* thisx, PlayState* play) {
EnDs* this = (EnDs*)thisx; EnDs* this = (EnDs*)thisx;
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
this->skelAnime.curFrame = 0.0f; this->skelAnime.curFrame = 0.0f;
} }

View file

@ -442,11 +442,11 @@ void EnFloormas_Die(EnFloormas* this, PlayState* play) {
void EnFloormas_BigDecideAction(EnFloormas* this, PlayState* play) { void EnFloormas_BigDecideAction(EnFloormas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime)) { if (SkelAnime_Update(&this->skelAnime)) {
// within 400 units of link and within 90 degrees rotation of him // within 400 units and within 90 degrees rotation of player
if (this->actor.xzDistToPlayer < 400.0f && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { if (this->actor.xzDistToPlayer < 400.0f && !Actor_IsFacingPlayer(&this->actor, 0x4000)) {
this->actionTarget = this->actor.yawTowardsPlayer; this->actionTarget = this->actor.yawTowardsPlayer;
EnFloormas_SetupTurn(this); EnFloormas_SetupTurn(this);
// within 280 units of link and within 45 degrees rotation of him // within 280 units and within 45 degrees rotation of player
} else if (this->actor.xzDistToPlayer < 280.0f && Actor_IsFacingPlayer(&this->actor, 0x2000)) { } else if (this->actor.xzDistToPlayer < 280.0f && Actor_IsFacingPlayer(&this->actor, 0x2000)) {
EnFloormas_SetupHover(this, play); EnFloormas_SetupHover(this, play);
} else { } else {
@ -490,7 +490,7 @@ void EnFloormas_BigWalk(EnFloormas* this, PlayState* play) {
this->actionTarget = this->actor.wallYaw; this->actionTarget = this->actor.wallYaw;
EnFloormas_SetupTurn(this); EnFloormas_SetupTurn(this);
} else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) {
// set target rotation to link. // set target rotation to player.
this->actionTarget = this->actor.yawTowardsPlayer; this->actionTarget = this->actor.yawTowardsPlayer;
EnFloormas_SetupTurn(this); EnFloormas_SetupTurn(this);
} else if (this->actionTimer == 0) { } else if (this->actionTimer == 0) {
@ -910,7 +910,7 @@ void EnFloormas_Merge(EnFloormas* this, PlayState* play) {
this->collider.dim.radius = (sCylinderInit.dim.radius * 100.0f) * this->actor.scale.x; this->collider.dim.radius = (sCylinderInit.dim.radius * 100.0f) * this->actor.scale.x;
this->collider.dim.height = (sCylinderInit.dim.height * 100.0f) * this->actor.scale.x; this->collider.dim.height = (sCylinderInit.dim.height * 100.0f) * this->actor.scale.x;
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->actor.scale.x >= 0.01f) { if (this->actor.scale.x >= 0.01f) {
this->actor.flags &= ~ACTOR_FLAG_4; this->actor.flags &= ~ACTOR_FLAG_4;
EnFloormas_MakeVulnerable(this); EnFloormas_MakeVulnerable(this);
@ -935,7 +935,7 @@ void EnFloormas_SmWait(EnFloormas* this, PlayState* play) {
} }
void EnFloormas_TakeDamage(EnFloormas* this, PlayState* play) { void EnFloormas_TakeDamage(EnFloormas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->actor.colChkInfo.health == 0) { if (this->actor.colChkInfo.health == 0) {
EnFloormas_Die(this, play); EnFloormas_Die(this, play);
} else { } else {
@ -954,7 +954,7 @@ void EnFloormas_TakeDamage(EnFloormas* this, PlayState* play) {
} }
void EnFloormas_Recover(EnFloormas* this, PlayState* play) { void EnFloormas_Recover(EnFloormas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnFloormas_SetupStand(this); EnFloormas_SetupStand(this);
} }
} }

View file

@ -241,7 +241,7 @@ void EnFu_Update(Actor* thisx, PlayState* play) {
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
Actor_MoveForward(&this->actor); Actor_MoveForward(&this->actor);
Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2);
if (!(this->behaviorFlags & FU_WAIT) && (SkelAnime_Update(&this->skelanime) != 0)) { if (!(this->behaviorFlags & FU_WAIT) && SkelAnime_Update(&this->skelanime)) {
Animation_Change(&this->skelanime, this->skelanime.animation, 1.0f, 0.0f, Animation_Change(&this->skelanime, this->skelanime.animation, 1.0f, 0.0f,
Animation_GetLastFrame(this->skelanime.animation), ANIMMODE_ONCE, 0.0f); Animation_GetLastFrame(this->skelanime.animation), ANIMMODE_ONCE, 0.0f);
} }

View file

@ -1183,17 +1183,17 @@ void EnGeldB_Block(EnGeldB* this, PlayState* play) {
} }
void EnGeldB_SetupSidestep(EnGeldB* this, PlayState* play) { void EnGeldB_SetupSidestep(EnGeldB* this, PlayState* play) {
s16 linkAngle; s16 playerRotY;
Player* player; Player* player;
f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim); f32 lastFrame = Animation_GetLastFrame(&gGerudoRedSidestepAnim);
Animation_Change(&this->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f); Animation_Change(&this->skelAnime, &gGerudoRedSidestepAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP_INTERP, 0.0f);
player = GET_PLAYER(play); player = GET_PLAYER(play);
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1);
linkAngle = player->actor.shape.rot.y; playerRotY = player->actor.shape.rot.y;
if (Math_SinS(linkAngle - this->actor.shape.rot.y) > 0.0f) { if (Math_SinS(playerRotY - this->actor.shape.rot.y) > 0.0f) {
this->actor.speedXZ = -6.0f; this->actor.speedXZ = -6.0f;
} else if (Math_SinS(linkAngle - this->actor.shape.rot.y) < 0.0f) { } else if (Math_SinS(playerRotY - this->actor.shape.rot.y) < 0.0f) {
this->actor.speedXZ = 6.0f; this->actor.speedXZ = 6.0f;
} else { } else {
this->actor.speedXZ = Rand_CenteredFloat(12.0f); this->actor.speedXZ = Rand_CenteredFloat(12.0f);

View file

@ -263,7 +263,7 @@ void func_80A68DB0(EnHorseGanon* this, PlayState* play) {
func_80A686A8(this, play); func_80A686A8(this, play);
if (SkelAnime_Update(&this->skin.skelAnime) != 0) { if (SkelAnime_Update(&this->skin.skelAnime)) {
func_80A68B20(this); func_80A68B20(this);
} }
} }

View file

@ -113,7 +113,7 @@ void EnHs2_Update(Actor* thisx, PlayState* play) {
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
Actor_MoveForward(&this->actor); Actor_MoveForward(&this->actor);
Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2);
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
this->skelAnime.curFrame = 0.0f; this->skelAnime.curFrame = 0.0f;
} }
this->actionFunc(this, play); this->actionFunc(this, play);

View file

@ -617,7 +617,7 @@ void func_80A7A304(EnIn* this, PlayState* play) {
if (this->skelAnime.animation == &object_in_Anim_018C38 && this->skelAnime.curFrame == 20.0f) { if (this->skelAnime.animation == &object_in_Anim_018C38 && this->skelAnime.curFrame == 20.0f) {
Audio_PlayActorSfx2(&this->actor, NA_SE_VO_IN_CRY_0); Audio_PlayActorSfx2(&this->actor, NA_SE_VO_IN_CRY_0);
} }
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
this->animationIdx %= 8; this->animationIdx %= 8;
this->unk_1E8 = this->animationIdx; this->unk_1E8 = this->animationIdx;
if (this->animationIdx == 3 || this->animationIdx == 4) { if (this->animationIdx == 3 || this->animationIdx == 4) {

View file

@ -365,13 +365,13 @@ void func_80ABA878(EnNiwLady* this, PlayState* play) {
} }
if (Actor_ProcessTalkRequest(&this->actor, play)) { if (Actor_ProcessTalkRequest(&this->actor, play)) {
playerExchangeItemId = func_8002F368(play); playerExchangeItemId = func_8002F368(play);
if ((playerExchangeItemId == 6) && GET_EVENTCHKINF(EVENTCHKINF_6A)) { if ((playerExchangeItemId == EXCH_ITEM_POCKET_CUCCO) && GET_EVENTCHKINF(EVENTCHKINF_6A)) {
func_80078884(NA_SE_SY_TRE_BOX_APPEAR); func_80078884(NA_SE_SY_TRE_BOX_APPEAR);
player->actor.textId = sTradeItemTextIds[5]; player->actor.textId = sTradeItemTextIds[5];
this->unk_26E = this->unk_27A + 21; this->unk_26E = this->unk_27A + 21;
this->unk_262 = TEXT_STATE_CHOICE; this->unk_262 = TEXT_STATE_CHOICE;
this->actionFunc = func_80ABAB08; this->actionFunc = func_80ABAB08;
} else if (playerExchangeItemId != 0) { } else if (playerExchangeItemId != EXCH_ITEM_NONE) {
player->actor.textId = sTradeItemTextIds[7]; player->actor.textId = sTradeItemTextIds[7];
this->unk_26E = this->unk_27A + 21; this->unk_26E = this->unk_27A + 21;
} else { } else {

View file

@ -249,9 +249,9 @@ void EnOwl_LookAtLink(EnOwl* this, PlayState* play) {
} }
/** /**
* Checks if link is within `targetDist` units, initalize the camera for the owl. * Checks if link is within `targetDist` units, initialize the camera for the owl.
* returns 0 if the link is not within `targetDistance`, returns 1 once link is within * returns 0 if the link is not within `targetDistance`, returns 1 once link is within
* the distance, and the camera has been initalized. * the distance, and the camera has been initialized.
*/ */
s32 EnOwl_CheckInitTalk(EnOwl* this, PlayState* play, u16 textId, f32 targetDist, u16 flags) { s32 EnOwl_CheckInitTalk(EnOwl* this, PlayState* play, u16 textId, f32 targetDist, u16 flags) {
s32 timer; s32 timer;

View file

@ -231,7 +231,7 @@ void EnSkb_RiseFromGround(EnSkb* this, PlayState* play) {
if ((play->gameplayFrames & 1) != 0) { if ((play->gameplayFrames & 1) != 0) {
EnSkb_SpawnDebris(play, this, &this->actor.world.pos); EnSkb_SpawnDebris(play, this, &this->actor.world.pos);
} }
if ((SkelAnime_Update(&this->skelAnime) != 0) && (0.0f == this->actor.shape.yOffset)) { if (SkelAnime_Update(&this->skelAnime) && (0.0f == this->actor.shape.yOffset)) {
EnSkb_DecideNextAction(this); EnSkb_DecideNextAction(this);
} }
} }
@ -253,7 +253,7 @@ void EnSkb_Despawn(EnSkb* this, PlayState* play) {
EnSkb_SpawnDebris(play, this, &this->actor.world.pos); EnSkb_SpawnDebris(play, this, &this->actor.world.pos);
} }
Math_SmoothStepToF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f, 0.0f); Math_SmoothStepToF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f, 0.0f);
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
Actor_Kill(&this->actor); Actor_Kill(&this->actor);
} }
} }
@ -328,7 +328,7 @@ void EnSkb_Attack(EnSkb* this, PlayState* play) {
if (this->collider.base.atFlags & AT_BOUNCED) { if (this->collider.base.atFlags & AT_BOUNCED) {
this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED);
EnSkb_SetupRecoil(this); EnSkb_SetupRecoil(this);
} else if (SkelAnime_Update(&this->skelAnime) != 0) { } else if (SkelAnime_Update(&this->skelAnime)) {
EnSkb_DecideNextAction(this); EnSkb_DecideNextAction(this);
} }
} }
@ -343,7 +343,7 @@ void EnSkb_SetupRecoil(EnSkb* this) {
} }
void EnSkb_Recoil(EnSkb* this, PlayState* play) { void EnSkb_Recoil(EnSkb* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnSkb_DecideNextAction(this); EnSkb_DecideNextAction(this);
} }
} }

View file

@ -270,7 +270,7 @@ void EnSt_SetDropAnimAndVel(EnSt* this) {
} }
/** /**
* Initalizes the Skulltula's 6 cylinders, and sphere collider. * Initializes the Skulltula's 6 cylinders, and sphere collider.
*/ */
void EnSt_InitColliders(EnSt* this, PlayState* play) { void EnSt_InitColliders(EnSt* this, PlayState* play) {
ColliderCylinderInit* cylinders[6] = { ColliderCylinderInit* cylinders[6] = {
@ -380,7 +380,7 @@ void EnSt_UpdateCylinders(EnSt* this, PlayState* play) {
} }
} }
s32 EnSt_CheckHitLink(EnSt* this, PlayState* play) { s32 EnSt_CheckHitPlayer(EnSt* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
s32 hit; s32 hit;
s32 i; s32 i;
@ -500,8 +500,8 @@ s32 EnSt_CheckColliders(EnSt* this, PlayState* play) {
} }
if (this->stunTimer == 0 && this->takeDamageSpinTimer == 0) { if (this->stunTimer == 0 && this->takeDamageSpinTimer == 0) {
// check if the Skulltula has hit link. // check if the Skulltula has hit the player.
EnSt_CheckHitLink(this, play); EnSt_CheckHitPlayer(this, play);
} }
return false; return false;
} }

View file

@ -267,7 +267,7 @@ void EnTite_Attack(EnTite* this, PlayState* play) {
s32 attackState; s32 attackState;
Vec3f ripplePos; Vec3f ripplePos;
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
attackState = this->vAttackState; // for deciding whether to change animation attackState = this->vAttackState; // for deciding whether to change animation
switch (this->vAttackState) { switch (this->vAttackState) {
case TEKTITE_BEGIN_LUNGE: case TEKTITE_BEGIN_LUNGE:

View file

@ -378,7 +378,7 @@ void EnTr_Update(Actor* thisx, PlayState* play) {
Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2);
this->actionFunc(this, play); this->actionFunc(this, play);
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->animation != NULL) { if (this->animation != NULL) {
if ((this->animation == &object_tr_Anim_0035CC) || (this->animation == &object_tr_Anim_0013CC)) { if ((this->animation == &object_tr_Anim_0035CC) || (this->animation == &object_tr_Anim_0013CC)) {
if (this->actor.params != TR_KOUME) { if (this->actor.params != TR_KOUME) {

View file

@ -328,13 +328,13 @@ void EnWallmas_Drop(EnWallmas* this, PlayState* play) {
} }
void EnWallmas_Land(EnWallmas* this, PlayState* play) { void EnWallmas_Land(EnWallmas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnWallmas_SetupStand(this); EnWallmas_SetupStand(this);
} }
} }
void EnWallmas_Stand(EnWallmas* this, PlayState* play) { void EnWallmas_Stand(EnWallmas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnWallmas_SetupWalk(this); EnWallmas_SetupWalk(this);
} }
@ -342,7 +342,7 @@ void EnWallmas_Stand(EnWallmas* this, PlayState* play) {
} }
void EnWallmas_Walk(EnWallmas* this, PlayState* play) { void EnWallmas_Walk(EnWallmas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnWallmas_SetupJumpToCeiling(this); EnWallmas_SetupJumpToCeiling(this);
} }
@ -355,7 +355,7 @@ void EnWallmas_Walk(EnWallmas* this, PlayState* play) {
} }
void EnWallmas_JumpToCeiling(EnWallmas* this, PlayState* play) { void EnWallmas_JumpToCeiling(EnWallmas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnWallmas_SetupReturnToCeiling(this); EnWallmas_SetupReturnToCeiling(this);
} }
} }
@ -388,7 +388,7 @@ void EnWallmas_ReturnToCeiling(EnWallmas* this, PlayState* play) {
} }
void EnWallmas_TakeDamage(EnWallmas* this, PlayState* play) { void EnWallmas_TakeDamage(EnWallmas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
if (this->actor.colChkInfo.health == 0) { if (this->actor.colChkInfo.health == 0) {
EnWallmas_SetupDie(this, play); EnWallmas_SetupDie(this, play);
} else { } else {
@ -403,7 +403,7 @@ void EnWallmas_TakeDamage(EnWallmas* this, PlayState* play) {
} }
void EnWallmas_Cooldown(EnWallmas* this, PlayState* play) { void EnWallmas_Cooldown(EnWallmas* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
EnWallmas_SetupReturnToCeiling(this); EnWallmas_SetupReturnToCeiling(this);
} }
} }
@ -430,7 +430,7 @@ void EnWallmas_TakePlayer(EnWallmas* this, PlayState* play) {
Audio_PlayActorSfx2(&this->actor, NA_SE_EN_FALL_CATCH); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_FALL_CATCH);
} }
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime)) {
player->actor.world.pos.x = this->actor.world.pos.x; player->actor.world.pos.x = this->actor.world.pos.x;
player->actor.world.pos.z = this->actor.world.pos.z; player->actor.world.pos.z = this->actor.world.pos.z;

View file

@ -125,7 +125,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
osSyncPrintf("now=%d ccc=%d\n", cursorPoint, cursorItem); osSyncPrintf("now=%d ccc=%d\n", cursorPoint, cursorItem);
// Seem necessary to match // Seems necessary to match
if (pauseCtx->cursorX[PAUSE_ITEM]) {} if (pauseCtx->cursorX[PAUSE_ITEM]) {}
if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]) {} if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]) {}

View file

@ -528,17 +528,16 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) {
gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0);
} else if (HREG(15) == 1) { } else if (HREG(15) == 1) {
Gfx* sp1CC = POLY_OPA_DISP; Gfx* gfx = POLY_OPA_DISP;
void* mapImage = gWorldMapImageTex;
gSPLoadUcodeL(sp1CC++, gspS2DEX2d_fifo); gSPLoadUcodeL(gfx++, gspS2DEX2d_fifo);
func_8009638C(&sp1CC, mapImage, gWorldMapImageTLUT, 216, 128, G_IM_FMT_CI, G_IM_SIZ_8b, 0x8000, 256, Room_DrawBackground2D(&gfx, gWorldMapImageTex, gWorldMapImageTLUT, 216, 128, G_IM_FMT_CI, G_IM_SIZ_8b,
HREG(13) / 100.0f, HREG(14) / 100.0f); G_TT_RGBA16, 256, HREG(13) / 100.0f, HREG(14) / 100.0f);
gSPLoadUcode(sp1CC++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
POLY_OPA_DISP = sp1CC; POLY_OPA_DISP = gfx;
} }
if (HREG(15) == 2) { if (HREG(15) == 2) {