1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 14:34:32 +00:00

Fix most compiler warnings in the boot and code segments (#674)

* Less warnings in boot & code segments

* few more warnings gone

* Ran formatter

* z_view warning gone

* -> 1

* f31 -> 31

* Remove function casts

* Few more small improvements

* Separate declaration and assignment in func_80091738 and Item_Give

Co-authored-by: Thar0 <maximilianc64@gmail.com>
This commit is contained in:
Tharo 2021-02-14 00:49:40 +00:00 committed by GitHub
parent d615ec4f31
commit f9d96d9f73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
208 changed files with 1702 additions and 1846 deletions

View file

@ -26,11 +26,11 @@ glabel func_8085F938
/* 00308 8085F958 3C014F00 */ lui $at, 0x4F00 ## $at = 4F000000
/* 0030C 8085F95C 46040182 */ mul.s $f6, $f0, $f4
/* 00310 8085F960 8FA60018 */ lw $a2, 0x0018($sp)
/* 00314 8085F964 444EF800 */ cfc1 $t6, $f31
/* 00318 8085F968 44CFF800 */ ctc1 $t7, $f31
/* 00314 8085F964 444EF800 */ cfc1 $t6, $31
/* 00318 8085F968 44CFF800 */ ctc1 $t7, $31
/* 0031C 8085F96C 00000000 */ nop
/* 00320 8085F970 46003224 */ cvt.w.s $f8, $f6
/* 00324 8085F974 444FF800 */ cfc1 $t7, $f31
/* 00324 8085F974 444FF800 */ cfc1 $t7, $31
/* 00328 8085F978 00000000 */ nop
/* 0032C 8085F97C 31EF0078 */ andi $t7, $t7, 0x0078 ## $t7 = 00000000
/* 00330 8085F980 51E00013 */ beql $t7, $zero, .L8085F9D0
@ -38,10 +38,10 @@ glabel func_8085F938
/* 00338 8085F988 44814000 */ mtc1 $at, $f8 ## $f8 = 2147483648.00
/* 0033C 8085F98C 240F0001 */ addiu $t7, $zero, 0x0001 ## $t7 = 00000001
/* 00340 8085F990 46083201 */ sub.s $f8, $f6, $f8
/* 00344 8085F994 44CFF800 */ ctc1 $t7, $f31
/* 00344 8085F994 44CFF800 */ ctc1 $t7, $31
/* 00348 8085F998 00000000 */ nop
/* 0034C 8085F99C 46004224 */ cvt.w.s $f8, $f8
/* 00350 8085F9A0 444FF800 */ cfc1 $t7, $f31
/* 00350 8085F9A0 444FF800 */ cfc1 $t7, $31
/* 00354 8085F9A4 00000000 */ nop
/* 00358 8085F9A8 31EF0078 */ andi $t7, $t7, 0x0078 ## $t7 = 00000000
/* 0035C 8085F9AC 15E00005 */ bne $t7, $zero, .L8085F9C4
@ -59,7 +59,7 @@ glabel func_8085F938
/* 00384 8085F9D4 05E0FFFB */ bltz $t7, .L8085F9C4
/* 00388 8085F9D8 00000000 */ nop
.L8085F9DC:
/* 0038C 8085F9DC 44CEF800 */ ctc1 $t6, $f31
/* 0038C 8085F9DC 44CEF800 */ ctc1 $t6, $31
/* 00390 8085F9E0 2DE1000B */ sltiu $at, $t7, 0x000B
/* 00394 8085F9E4 1020002E */ beq $at, $zero, .L8085FAA0
/* 00398 8085F9E8 000F7880 */ sll $t7, $t7, 2

View file

@ -46,11 +46,11 @@ glabel func_8085FAB0
/* 004C4 8085FB14 46040182 */ mul.s $f6, $f0, $f4
/* 004C8 8085FB18 8FA60020 */ lw $a2, 0x0020($sp)
/* 004CC 8085FB1C 8FA70024 */ lw $a3, 0x0024($sp)
/* 004D0 8085FB20 444FF800 */ cfc1 $t7, $f31
/* 004D4 8085FB24 44D8F800 */ ctc1 $t8, $f31
/* 004D0 8085FB20 444FF800 */ cfc1 $t7, $31
/* 004D4 8085FB24 44D8F800 */ ctc1 $t8, $31
/* 004D8 8085FB28 00000000 */ nop
/* 004DC 8085FB2C 46003224 */ cvt.w.s $f8, $f6
/* 004E0 8085FB30 4458F800 */ cfc1 $t8, $f31
/* 004E0 8085FB30 4458F800 */ cfc1 $t8, $31
/* 004E4 8085FB34 00000000 */ nop
/* 004E8 8085FB38 33180078 */ andi $t8, $t8, 0x0078 ## $t8 = 00000000
/* 004EC 8085FB3C 53000013 */ beql $t8, $zero, .L8085FB8C
@ -58,10 +58,10 @@ glabel func_8085FAB0
/* 004F4 8085FB44 44814000 */ mtc1 $at, $f8 ## $f8 = 2147483648.00
/* 004F8 8085FB48 24180001 */ addiu $t8, $zero, 0x0001 ## $t8 = 00000001
/* 004FC 8085FB4C 46083201 */ sub.s $f8, $f6, $f8
/* 00500 8085FB50 44D8F800 */ ctc1 $t8, $f31
/* 00500 8085FB50 44D8F800 */ ctc1 $t8, $31
/* 00504 8085FB54 00000000 */ nop
/* 00508 8085FB58 46004224 */ cvt.w.s $f8, $f8
/* 0050C 8085FB5C 4458F800 */ cfc1 $t8, $f31
/* 0050C 8085FB5C 4458F800 */ cfc1 $t8, $31
/* 00510 8085FB60 00000000 */ nop
/* 00514 8085FB64 33180078 */ andi $t8, $t8, 0x0078 ## $t8 = 00000000
/* 00518 8085FB68 17000005 */ bne $t8, $zero, .L8085FB80
@ -79,7 +79,7 @@ glabel func_8085FAB0
/* 00540 8085FB90 0700FFFB */ bltz $t8, .L8085FB80
/* 00544 8085FB94 00000000 */ nop
.L8085FB98:
/* 00548 8085FB98 44CFF800 */ ctc1 $t7, $f31
/* 00548 8085FB98 44CFF800 */ ctc1 $t7, $31
/* 0054C 8085FB9C 2F01000A */ sltiu $at, $t8, 0x000A
/* 00550 8085FBA0 10200087 */ beq $at, $zero, .L8085FDC0
/* 00554 8085FBA4 0018C080 */ sll $t8, $t8, 2

View file

@ -12,10 +12,10 @@ f64 sqrt(f64 d);
void cleararena(void);
void bootproc(void);
void Main_ThreadEntry(void* arg0);
void Idle_ThreadEntry(void* a0);
void ViConfig_UpdateVi(u32 arg0);
void ViConfig_UpdateBlack();
void Main_ThreadEntry(void* arg);
void Idle_ThreadEntry(void* arg);
void ViConfig_UpdateVi(u32 mode);
void ViConfig_UpdateBlack(void);
s32 DmaMgr_CompareName(const char* name1, const char* name2);
s32 DmaMgr_DMARomToRam(u32 rom, u32 ram, u32 size);
s32 DmaMgr_DmaCallback0(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction);
@ -27,47 +27,47 @@ void DmaMgr_ProcessMsg(DmaRequest* req);
void DmaMgr_ThreadEntry(void* arg0);
s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg);
s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size);
void DmaMgr_Init();
void DmaMgr_Init(void);
s32 DmaMgr_SendRequest2(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg,
const char* file, s32 line);
s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 line);
void* Yaz0_FirstDMA();
void* Yaz0_FirstDMA(void);
void* Yaz0_NextDMA(void* curSrcPos);
void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst);
void Yaz0_Decompress(u32 romStart, void* dst, u32 size);
void Locale_Init();
void Locale_ResetRegion();
u32 func_80001F48();
u32 func_80001F8C();
u32 Locale_IsRegionNative();
void Locale_Init(void);
void Locale_ResetRegion(void);
u32 func_80001F48(void);
u32 func_80001F8C(void);
u32 Locale_IsRegionNative(void);
void __assert(const char* exp, const char* file, s32 line);
void isPrintfInit();
void isPrintfInit(void);
void osSyncPrintfUnused(const char* fmt, ...);
void osSyncPrintf(const char* fmt, ...);
void rmonPrintf(const char* fmt, ...);
u32 is_proutSyncPrintf(void* arg0, const char* str, s32 count);
void* is_proutSyncPrintf(void* arg, const char* str, u32 count);
void func_80002384(const char* exp, const char* file, u32 line);
OSPiHandle* osDriveRomInit();
OSPiHandle* osDriveRomInit(void);
void Mio0_Decompress(Yaz0Header* hdr, u8* dst);
void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 initValue, s32 minSpace,
const char* name);
void StackCheck_Cleanup(StackEntry* entry);
StackStatus StackCheck_GetState(StackEntry* entry);
u32 StackCheck_CheckAll();
u32 StackCheck_CheckAll(void);
u32 StackCheck_Check(StackEntry* entry);
f32 LogUtils_CheckFloatRange(const char* exp, s32 arg1, const char* var1Name, f32 var1, const char* var2Name, f32 var2,
const char* var3Name, f32 var3);
s32 LogUtils_CheckIntRange(const char* exp, s32 arg1, const char* var1Name, s32 var1, const char* var2Name, s32 var2,
const char* var3Name, s32 var3);
f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min,
const char* maxName, f32 max);
s32 LogUtils_CheckIntRange(const char* exp, s32 line, const char* valueName, s32 value, const char* minName, s32 min,
const char* maxName, s32 max);
void LogUtils_LogHexDump(void* ptr, s32 size0);
void LogUtils_LogPointer(s32 value, u32 max, void* ptr, const char* name, const char* file, s32 line);
void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* file, s32 line);
void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, s32 line);
void LogUtils_CheckValidPointer(const char* exp, void* ptr0, const char* file, s32 line);
void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, s32 line);
void LogUtils_LogThreadId(const char* name, s32 line);
void LogUtils_HungupThread(const char* name, s32 line);
void LogUtils_ResetHungup();
char* proutSprintf(char* dst, const char* fmt, size_t size);
void LogUtils_ResetHungup(void);
void* proutSprintf(void* dst, const char* fmt, u32 size);
s32 vsprintf(char* dst, const char* fmt, va_list args);
s32 sprintf(char* dst, const char* fmt, ...);
void __osPiCreateAccessQueue(void);
@ -79,7 +79,7 @@ void osViExtendVStart(u32 arg0);
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag);
void __createSpeedParam(void);
void __osInitialize_common(void);
void __osInitialize_autodetect();
void __osInitialize_autodetect(void);
void __osExceptionPreamble();
// ? __osException(?);
void __osEnqueueAndYield(OSThread**);
@ -95,7 +95,7 @@ void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg,
void __osSetSR(u32);
u32 __osGetSR();
void osWritebackDCache(void* vaddr, s32 nbytes);
void* osViGetNextFramebuffer();
void* osViGetNextFramebuffer(void);
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt);
void __osDevMgrMain(void* arg);
s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size);
@ -108,16 +108,16 @@ void osViSetMode(OSViMode* mode);
u32 __osProbeTLB(void*);
u32 osGetMemSize(void);
void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg msg);
s32 _Printf(char* (*pfn)(char*, const char*, size_t), char* arg, const char* fmt, va_list ap);
s32 _Printf(PrintCallback, void* arg, const char* fmt, va_list ap);
void osUnmapTLBAll(void);
s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction);
const u8* strchr(const u8* str, s32 ch);
size_t strlen(const u8* str);
void* memcpy(void* dst, const void* src, size_t size);
const char* strchr(const char* str, s32 ch);
u32 strlen(const char* str);
void* memcpy(void* dst, const void* src, u32 size);
void osInvalICache(void* vaddr, s32 nbytes);
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count);
void osInvalDCache(void* vaddr, s32 nbytes);
s32 __osSiDeviceBusy();
s32 __osSiDeviceBusy(void);
s32 osJamMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag);
void osSetThreadPri(OSThread* thread, OSPri pri);
OSPri osGetThreadPri(OSThread* thread);
@ -126,10 +126,10 @@ void osViSwapBuffer(void* vaddr);
s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size);
u32 bcmp(void* __sl, void* __s2, u32 __n);
OSTime osGetTime(void);
void __osTimerServicesInit();
void __osTimerInterrupt();
void __osSetTimerIntr(OSTime tim);
OSTime __osInsertTimer(OSTimer* a0);
void __osTimerServicesInit(void);
void __osTimerInterrupt(void);
void __osSetTimerIntr(OSTime time);
OSTime __osInsertTimer(OSTimer* timer);
u32 osGetCount(void);
void __osSetGlobalIntMask(u32 mask);
void __osSetCompare(u32);
@ -137,17 +137,17 @@ void* bcopy(void* __src, void* __dest, u32 __n);
void __osResetGlobalIntMask(u32 mask);
s32 __osDisableInt(void);
void __osRestoreInt(s32);
void __osViInit();
void __osViSwapContext();
OSMesgQueue* osPiGetCmdQueue();
void __osViInit(void);
void __osViSwapContext(void);
OSMesgQueue* osPiGetCmdQueue(void);
s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data);
void osViSetSpecialFeatures(u32 func);
OSPiHandle* osCartRomInit();
OSPiHandle* osCartRomInit(void);
void __osSetFpcCsr(u32);
u32 __osGetFpcCsr();
s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data);
void osMapTLBRdb(void);
void osYieldThread();
void osYieldThread(void);
u32 __osGetCause();
s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data);
void _Litob(_Pft* args, u8 type);
@ -157,7 +157,7 @@ void _Ldtob(_Pft* args, u8 type);
s32 __osSiRawWriteIo(void* a0, u32 a1);
void osCreateViManager(OSPri pri);
void viMgrMain(void* vargs);
OSViContext* __osViGetCurrentContext();
OSViContext* __osViGetCurrentContext(void);
void osStartThread(OSThread* thread);
void osViSetYScale(f32 scale);
void osViSetXScale(f32 value);
@ -354,6 +354,7 @@ void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCt
void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx);
void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex,
Vec3f* rightFootPos);
void func_8002BE04(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3);
void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx);
s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag);
void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag);
@ -460,6 +461,8 @@ void func_800304B0(GlobalContext* globalCtx);
void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry);
void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx);
s32 func_800314D4(GlobalContext* globalCtx, Actor* actorB, Vec3f* arg2, f32 arg3);
void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx);
void func_80031A28(GlobalContext* globalCtx, ActorContext* actorCtx);
void func_80031B14(GlobalContext* globalCtx, ActorContext* actorCtx);
void func_80031C3C(ActorContext* actorCtx, GlobalContext* globalCtx);
Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ,
@ -664,7 +667,7 @@ void func_8003EBF8(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgI
void func_8003EC50(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId);
void func_8003ECA8(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId);
s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader);
Actor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId);
DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId);
void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId);
// ? DynaPoly_ExpandSRT(?);
void func_8003F8EC(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor);
@ -751,7 +754,7 @@ s32 func_80043548(DynaPolyActor* dynaActor);
s32 func_8004356C(DynaPolyActor* dynaActor);
s32 func_80043590(DynaPolyActor* dynaActor);
s32 func_800435B4(DynaPolyActor* dynaActor);
s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dyna, s16 arg2, s16 arg3, s16 arg4);
s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4);
void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalContext* globalCtx);
void Camera_InitPlayerSettings(Camera* camera, Player* player);
s16 Camera_ChangeStatus(Camera* camera, s16 status);
@ -872,7 +875,7 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a
Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2);
u8 CollisionCheck_GetSwordDamage(s32 dmgFlags);
void SaveContext_Init(void);
// ? func_800636C0(?);
void func_800636C0(void);
void func_8006375C(s32 arg0, s32 arg1, const char* text);
void func_8006376C(u8 x, u8 y, u8 colorId, const char* text);
// ? func_8006376C(?);
@ -940,37 +943,38 @@ u8 func_8006F140(GlobalContext*, EnvironmentContext*, UNK_TYPE);
f32 func_8006F93C(u16, u16, u16);
f32 func_8006F9BC(u16 endFrame, u16 startFrame, u16 frames, u16, u16);
// ? func_8006FB94(?);
// ? func_8006FC88(?);
void func_8006FC88(s16 skyboxId, EnvironmentContext* envCtx, SkyboxContext* skyboxCtx);
void func_80070600(GlobalContext* globalCtx, s32 waterboxProperties);
void func_800706A0(GlobalContext* globalCtx);
// ? func_80070718(?);
// ? func_80070C24(?);
// ? func_800730DC(?);
void func_80070C24(GlobalContext* globalCtx, EnvironmentContext* envCtx, LightContext* lightCtx, PauseContext* pauseCtx,
MessageContext* msgCtx, u16*, GraphicsContext* gfxCtx);
void func_800730DC(GlobalContext*);
void func_80073988(GlobalContext*, EnvironmentContext*, View*, GraphicsContext*, Vec3f, UNK_TYPE);
// ? func_80073A5C(?);
f32 func_800746DC();
// ? func_80074704(?);
void func_80074704(GlobalContext*, View*, GraphicsContext*);
void func_80074CE8(GlobalContext* globalCtx, s32 arg1);
// ? func_80074D6C(?);
void func_80074D6C(GlobalContext*);
// ? func_80074FF4(?);
// ? func_800750C0(?);
void func_800753C4(GlobalContext* globalCtx, u8 arg1);
// ? func_8007542C(?);
// ? func_800758AC(?);
void func_800750C0(GlobalContext*);
void func_800753C4(GlobalContext*, u8);
void func_8007542C(GlobalContext*, u8);
void func_800758AC(GlobalContext* globalCtx);
// ? func_80075B44(?);
// ? func_80075E68(?);
void func_80075E68(GlobalContext* globalCtx);
// ? func_80075F14(?);
// ? func_800760F4(?);
// ? func_800763A8(?);
// ? func_800766C4(?);
void func_8007672C(GraphicsContext*, u8, u8, u8, u8, UNK_TYPE);
// ? func_80076934(?);
void func_80076934(GlobalContext* globalCtx);
void func_800773A8(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4);
s32 func_800775CC();
void func_800775D8();
s32 func_800775E4();
void func_800775F0(u16);
// ? func_80077600(?);
s32 func_80077600(void);
void func_80077624(GlobalContext* globalCtx);
void func_80077684(GlobalContext* globalCtx);
void func_800776E4(GlobalContext* globalCtx);
@ -1057,7 +1061,7 @@ void MapMark_DrawConditionally(GlobalContext* globalCtx);
void PreNmiBuff_Init(PreNmiBuff* this);
void PreNmiBuff_SetReset(PreNmiBuff* this);
u32 PreNmiBuff_IsResetting(PreNmiBuff* this);
void MsgEvent_SendNullTask();
void MsgEvent_SendNullTask(void);
f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b);
f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b);
f32 OLib_ClampMinDist(f32 val, f32 min);
@ -1124,8 +1128,8 @@ void Interface_Update(GlobalContext* globalCtx);
Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max);
f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw);
void Path_CopyLastPoint(Path* path, Vec3f* dest);
// ? func_8008E6A0(?);
// ? func_8008E6AC(?);
void func_8008E6A0(SubGlobalContext7B8*);
u32 func_8008E6AC(SubGlobalContext7B8* this, Input* input);
void Player_SetBootData(GlobalContext* globalCtx, Player* player);
s32 Player_InBlockingCsMode(GlobalContext* globalCtx, Player* player);
s32 Player_InCsMode(GlobalContext* globalCtx);
@ -1183,7 +1187,7 @@ s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake);
s16 Quake_GetFreeIndex();
s16 Quake_GetFreeIndex(void);
QuakeRequest* Quake_AddImpl(Camera* cam, u32 callbackIdx);
void Quake_Remove(QuakeRequest* req);
QuakeRequest* Quake_GetRequest(s16 idx);
@ -1193,7 +1197,7 @@ u32 Quake_SetCountdown(s16 idx, s16 value);
s16 Quake_GetCountdown(s16 idx);
u32 Quake_SetQuakeValues(s16 idx, s16 y, s16 x, s16 zoom, s16 rotZ);
u32 Quake_SetUnkValues(s16 idx, s16 arg1, SubQuakeRequest14 arg2);
void Quake_Init();
void Quake_Init(void);
s16 Quake_Add(Camera* cam, u32 callbackIdx);
u32 Quake_RemoveFromIdx(s16 idx);
s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData);
@ -1401,6 +1405,7 @@ void func_800A9F30(PadMgr*, s32);
void func_800A9F6C(f32, u8, u8, u8);
void func_800AA000(f32, u8, u8, u8);
void func_800AA0B4();
void func_800AA0F0(void);
u32 func_800AA148();
void func_800AA15C();
void func_800AA16C();
@ -1437,10 +1442,10 @@ s32 func_800ABE74(f32 eyeX, f32 eyeY, f32 eyeZ);
// ? func_800AC2F4(?);
// ? func_800AC89C(?);
// ? func_800AC9A4(?);
// ? func_800ACA28(?);
// ? func_800ACA90(?);
void func_800ACA28(unk_80166528*);
void func_800ACA90(unk_80166528*);
// ? func_800ACA98(?);
// ? func_800ACAF8(?);
void func_800ACAF8(unk_80166528*, Input*, GraphicsContext*);
void func_800ACE70(struct_801664F0* this);
void func_800ACE90(struct_801664F0* this);
void func_800ACE98(struct_801664F0* this, Gfx** gfxp);
@ -1459,10 +1464,11 @@ void func_800AD958(struct_80166500* this, Gfx** gfxp);
// ? func_800AF178(?);
// ? func_800AF218(?);
// ? func_800B0E50(?);
void func_800B0E50(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyboxId);
Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z);
void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 alpha, f32 x, f32 y, f32 z);
void SkyboxDraw_Update(SkyboxContext* skyboxCtx);
void PlayerCall_InitFuncPtrs();
void PlayerCall_InitFuncPtrs(void);
void TransitionUnk_InitGraphics(TransitionUnk* this);
void TransitionUnk_InitData(TransitionUnk* this);
void TransitionUnk_Destroy(TransitionUnk* this);
@ -1470,39 +1476,39 @@ TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col);
void TransitionUnk_SetData(TransitionUnk* this);
void TransitionUnk_Draw(TransitionUnk* this, Gfx**);
void func_800B23E8(TransitionUnk* this);
void TransitionTriforce_Start(TransitionTriforce* this);
TransitionTriforce* TransitionTriforce_Init(TransitionTriforce* this);
void TransitionTriforce_Destroy(TransitionTriforce* this);
void TransitionTriforce_Update(TransitionTriforce* this, s32 updateRate);
void TransitionTriforce_SetColor(TransitionTriforce* this, u32 color);
void TransitionTriforce_SetType(TransitionTriforce* this, s32 type);
void TransitionTriforce_Draw(TransitionTriforce* this, Gfx** gfxP);
s32 TransitionTriforce_IsDone(TransitionTriforce* this);
void TransitionWipe_Start(TransitionWipe* this);
TransitionWipe* TransitionWipe_Init(TransitionWipe* this);
void TransitionWipe_Destroy(TransitionWipe* this);
void TransitionWipe_Update(TransitionWipe* this, s32 updateRate);
void TransitionWipe_Draw(TransitionWipe* this, Gfx** gfxP);
s32 TransitionWipe_IsDone(TransitionWipe* this);
void TransitionWipe_SetType(TransitionWipe* this, s32 type);
void TransitionWipe_SetColor(TransitionWipe* this, u32 color);
void TransitionCircle_Start(TransitionCircle* this);
TransitionCircle* TransitionCircle_Init(TransitionCircle* this);
void TransitionCircle_Destroy(TransitionCircle* this);
void TransitionCircle_Update(TransitionCircle* this, s32 updateRate);
void TransitionCircle_Draw(TransitionCircle* this, Gfx** gfxP);
s32 TransitionCircle_IsDone(TransitionCircle* this);
void TransitionCircle_SetType(TransitionCircle* this, s32 type);
void TransitionCircle_SetColor(TransitionCircle* this, u32 color);
void TransitionCircle_SetEnvColor(TransitionCircle* this, u32 color);
void TransitionFade_Start(TransitionFade* this);
TransitionFade* TransitionFade_Init(TransitionFade* this);
void TransitionFade_Destroy(TransitionFade* this);
void TransitionFade_Update(TransitionFade* this, s32 updateRate);
void TransitionFade_Draw(TransitionFade* this, Gfx** gfxP);
s32 TransitionFade_IsDone(TransitionFade* this);
void TransitionFade_SetColor(TransitionFade* this, u32 color);
void TransitionFade_SetType(TransitionFade* this, s32 type);
void TransitionTriforce_Start(void* this);
void* TransitionTriforce_Init(void* this);
void TransitionTriforce_Destroy(void* this);
void TransitionTriforce_Update(void* this, s32 updateRate);
void TransitionTriforce_SetColor(void* this, u32 color);
void TransitionTriforce_SetType(void* this, s32 type);
void TransitionTriforce_Draw(void* this, Gfx** gfxP);
s32 TransitionTriforce_IsDone(void* this);
void TransitionWipe_Start(void* this);
void* TransitionWipe_Init(void* this);
void TransitionWipe_Destroy(void* this);
void TransitionWipe_Update(void* this, s32 updateRate);
void TransitionWipe_Draw(void* this, Gfx** gfxP);
s32 TransitionWipe_IsDone(void* this);
void TransitionWipe_SetType(void* this, s32 type);
void TransitionWipe_SetColor(void* this, u32 color);
void TransitionCircle_Start(void* thisx);
void* TransitionCircle_Init(void* thisx);
void TransitionCircle_Destroy(void* thisx);
void TransitionCircle_Update(void* thisx, s32 updateRate);
void TransitionCircle_Draw(void* thisx, Gfx** gfxP);
s32 TransitionCircle_IsDone(void* thisx);
void TransitionCircle_SetType(void* thisx, s32 type);
void TransitionCircle_SetColor(void* thisx, u32 color);
void TransitionCircle_SetEnvColor(void* thisx, u32 color);
void TransitionFade_Start(void* this);
void* TransitionFade_Init(void* this);
void TransitionFade_Destroy(void* this);
void TransitionFade_Update(void* this, s32 updateRate);
void TransitionFade_Draw(void* this, Gfx** gfxP);
s32 TransitionFade_IsDone(void* this);
void TransitionFade_SetColor(void* this, u32 color);
void TransitionFade_SetType(void* this, s32 type);
void ShrinkWindow_SetVal(s32 value);
u32 ShrinkWindow_GetVal(void);
void ShrinkWindow_SetCurrentVal(s32 nowVal);
@ -1679,8 +1685,8 @@ void GameAlloc_Free(GameAlloc* this, void* data);
void GameAlloc_Cleanup(GameAlloc* this);
void GameAlloc_Init(GameAlloc* this);
void Graph_FaultClient();
void Graph_DisassembleUCode(void* arg0);
void Graph_UCodeFaultClient(void* arg0);
void Graph_DisassembleUCode(Gfx* workBuf);
void Graph_UCodeFaultClient(Gfx* workBuf);
void* Graph_InitTHGA(GraphicsContext* gfxCtx);
GameStateOverlay* Graph_GetNextGameState(GameState* gameState);
void Graph_Init(GraphicsContext* gfxCtx);
@ -1699,8 +1705,8 @@ ListAlloc* ListAlloc_Init(ListAlloc* this);
void* ListAlloc_Alloc(ListAlloc* this, u32 size);
void ListAlloc_Free(ListAlloc* this, void* data);
void ListAlloc_FreeAll(ListAlloc* this);
void Main_LogSystemHeap();
void Main(void*);
void Main_LogSystemHeap(void);
void Main(void* arg);
OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padmgr);
void PadMgr_UnlockSerialMesgQueue(PadMgr* padmgr, OSMesgQueue* ctrlrqueue);
void PadMgr_LockPadData(PadMgr* padmgr);
@ -1731,7 +1737,7 @@ void Sched_HandleEntry(SchedContext* sc);
void Sched_HandleRetrace(SchedContext* sc);
void Sched_HandleRSPDone(SchedContext* sc);
void Sched_HandleRDPDone(SchedContext* sc);
void Sched_SendEntryMsg(OSMesgQueue* mq);
void Sched_SendEntryMsg(SchedContext* sc);
void Sched_ThreadEntry(void* arg);
void Sched_Init(SchedContext* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr);
void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y);
@ -1848,15 +1854,16 @@ void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag);
void func_800D23FC(f32 f, Vec3f* vec, u8 mode);
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line);
void func_800D2CEC(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6);
u32 SysUcode_GetUCodeBoot();
u32 SysUcode_GetUCodeBootSize();
u32 SysUcode_GetUCode();
u32 SysUcode_GetUCodeData();
u32 SysUcode_GetUCodeBoot(void);
u32 SysUcode_GetUCodeBootSize(void);
u32 SysUcode_GetUCode(void);
u32 SysUcode_GetUCodeData(void);
void func_800D2E30(UnkRumbleStruct* arg0);
void func_800D3140(UnkRumbleStruct* arg0);
void func_800D3178(UnkRumbleStruct* arg0);
// ? func_800D31F0(?);
// ? func_800D3210(?);
void func_800D31A0(void);
void func_800D31F0(void);
void func_800D3210(void);
void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ);
void IrqMgr_RemoveClient(IrqMgr* this, IrqMgrClient* c);
void IrqMgr_SendMesgForClient(IrqMgr* this, OSMesg msg);
@ -1879,14 +1886,14 @@ void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line
void DebugArena_Free(void* ptr);
void DebugArena_FreeDebug(void* ptr, const char* file, s32 line);
void* DebugArena_Calloc(u32 num, u32 size);
void DebugArena_Display();
void DebugArena_Display(void);
void DebugArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void DebugArena_Check();
void DebugArena_Check(void);
void DebugArena_Init(void* start, u32 size);
void DebugArena_Cleanup();
u8 DebugArena_IsInitalized();
void DebugArena_Cleanup(void);
u8 DebugArena_IsInitalized(void);
void Fault_SleepImpl(u32);
void Fault_ClientProcessThread(FaultClientContext*);
void Fault_ClientProcessThread(void* arg);
void Fault_ProcessClientContext(FaultClientContext*);
u32 Fault_ProcessClient(u32, u32, u32);
void Fault_AddClient(FaultClient*, void*, void*, void*);
@ -1938,7 +1945,7 @@ void FaultDrawer_SetFontColor(u16);
void FaultDrawer_SetCharPad(s8, s8);
void FaultDrawer_SetCursor(s32, s32);
void FaultDrawer_FillScreen();
u32 FaultDrawer_FormatStringFunc(u32, const char*, s32);
void* FaultDrawer_FormatStringFunc(void*, const char*, u32);
void FaultDrawer_VPrintf(const char*, char*);
void FaultDrawer_Printf(const char*, ...);
void FaultDrawer_DrawText(s32, s32, const char*, ...);
@ -1948,15 +1955,15 @@ void FaultDrawer_SetDefault();
// ? UCodeDisas_TranslateAddr(?);
// ? UCodeDisas_ParseCombineColor(?);
// ? UCodeDisas_ParseCombineAlpha(?);
// ? UCodeDisas_Init(?);
// ? UCodeDisas_Destroy(?);
void UCodeDisas_Init(UCodeDisas*);
void UCodeDisas_Destroy(UCodeDisas*);
// ? UCodeDisas_SetCurUCodeImpl(?);
// ? UCodeDisas_ParseGeometryMode(?);
// ? UCodeDisas_ParseRenderMode(?);
// ? UCodeDisas_PrintVertices(?);
// ? UCodeDisas_Disassemble(?);
// ? UCodeDisas_RegisterUCode(?);
// ? UCodeDisas_SetCurUCode(?);
void UCodeDisas_Disassemble(UCodeDisas*, Gfx*);
void UCodeDisas_RegisterUCode(UCodeDisas*, s32, UCodeInfo*);
void UCodeDisas_SetCurUCode(UCodeDisas*, void*);
// ? func_800DACC0(?);
// ? func_800DB03C(?);
// ? func_800DB0C4(?);
@ -2113,7 +2120,7 @@ void func_800E4D94(void);
// ? func_800E4EEC(?);
// ? func_800E4F58(?);
void func_800E4FB0(void);
// ? func_800E4FE0(?);
Sub_AudioMgr_18* func_800E4FE0(void);
// ? func_800E5000(?);
// ? func_800E5584(?);
// ? func_800E5958(?);
@ -2219,11 +2226,11 @@ void func_800ED858(u8);
// ? func_800EE57C(?);
// ? func_800EE5EC(?);
// ? func_800EE6F4(?);
void func_800EE824(CutsceneContext* csCtx);
void func_800EE824(void);
// ? func_800EE930(?);
// ? func_800EE97C(?);
// ? func_800EE9D0(?);
// ? func_800EEA50(?);
void func_800EEA50(GfxPrint* printer);
// ? func_800F1BDC(?);
// ? func_800F2150(?);
// ? func_800F227C(?);
@ -2235,7 +2242,7 @@ void func_800EE824(CutsceneContext* csCtx);
// ? func_800F2A04(?);
void func_800F2D6C(u8*, u16 sfxId);
// ? func_800F2E28(?);
// ? func_800F3054(?);
void func_800F3054(void);
// ? func_800F3188(?);
// ? func_800F32F0(?);
// ? func_800F3468(?);
@ -2283,9 +2290,9 @@ void func_800F5E90(u8);
void func_800F6114(f32);
void func_800F6268(f32, UNK_TYPE);
void func_800F6584(UNK_TYPE);
// ? func_800F64E0(?);
void func_800F64E0(u8);
void func_800F6584(UNK_TYPE);
// ? func_800F66C0(?);
void func_800F66C0(s8 echo);
void func_800F66DC(s8);
void func_800F6700(s8 outputMode);
void func_800F67A0(u8);
@ -2299,7 +2306,7 @@ void func_800F6AB0(u8);
// ? func_800F6BB8(?);
void func_800F6C14();
// ? func_800F6C34(?);
void func_800F6D58(u8 arg0, u8 arg1, u8 arg2);
void func_800F6D58(u8, u8, u8);
// ? func_800F6E7C(?);
// ? func_800F6FB4(?);
void func_800F70F8();
@ -2369,7 +2376,7 @@ s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, voi
// ? func_800FCAB4(?);
void SystemHeap_Init(void* start, u32 size);
void PadUtils_Init(Input* input);
void func_800FCB70();
void func_800FCB70(void);
void PadUtils_ResetPressRel(Input* input);
u32 PadUtils_CheckCurExact(Input* input, u16 value);
u32 PadUtils_CheckCur(Input* input, u16 key);
@ -2410,12 +2417,12 @@ void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 lin
void SystemArena_Free(void* ptr);
void SystemArena_FreeDebug(void* ptr, const char* file, s32 line);
void* SystemArena_Calloc(u32 num, u32 size);
void SystemArena_Display();
void SystemArena_Display(void);
void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void SystemArena_Check();
void SystemArena_Check(void);
void SystemArena_Init(void* start, u32 size);
void SystemArena_Cleanup();
u8 SystemArena_IsInitalized();
void SystemArena_Cleanup(void);
u8 SystemArena_IsInitalized(void);
u32 Rand_Next(void);
void Rand_Seed(u32 seed);
f32 Rand_ZeroOne(void);
@ -2463,8 +2470,8 @@ void __osDisplayArena(Arena* arena);
void ArenaImpl_FaultClient(Arena* arena);
u32 __osCheckArena(Arena* arena);
u8 func_800FF334(Arena* arena);
void PrintUtils_VPrintf(char** arg0, const char* fmt, va_list args);
void PrintUtils_Printf(void* arg0, const char* fmt, ...);
void PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args);
void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...);
void Sleep_Cycles(OSTime cycles);
void Sleep_Nsec(u32 nsec);
void Sleep_Usec(u32 usec);
@ -2479,8 +2486,8 @@ u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLength
void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc);
u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes);
s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state);
s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, s16* mcu, s16* unk);
s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, u8* outZeroCount);
s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk);
s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount);
u16 JpegDecoder_ReadBits(u8 len);
s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes);
void guScale(Mtx* m, f32 x, f32 y, f32 z);
@ -2492,15 +2499,15 @@ void osSpTaskStartGo(OSTask* task);
s32 osSetRumble(OSPfs* pfs, u32 vibrate);
void osSetUpMempakWrite(s32 channel, OSPifRam* buf);
s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel);
void __osSiCreateAccessQueue();
void __osSiGetAccess();
void __osSiRelAccess();
void __osSiCreateAccessQueue(void);
void __osSiGetAccess(void);
void __osSiRelAccess(void);
s32 osContInit(OSMesgQueue* mq, u8* ctl_present_bitfield, OSContStatus* status);
void __osContGetInitData(u8* ctl_present_bitfield, OSContStatus* status);
void __osPackRequestData(u8 poll);
s32 osContStartReadData(OSMesgQueue* mq);
void osContGetReadData(OSContPad* pad);
void __osPackReadData();
void __osPackReadData(void);
void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale);
void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale);
s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, u32 size);
@ -2521,7 +2528,7 @@ s32 osStopTimer(OSTimer* timer);
u16 __osSumcalc(u8* ptr, s32 length);
s32 __osIdCheckSum(u16* ptr, u16* csum, u16* icsum);
s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid);
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp);
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check);
s32 __osGetId(OSPfs* pfs);
s32 __osCheckId(OSPfs* pfs);
s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank);
@ -2536,15 +2543,15 @@ void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32
void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp,
f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth,
s32 hiliteHeight);
u32 __osSpDeviceBusy();
void guMtxIdent(f32 m[4][4]);
u32 __osSpDeviceBusy(void);
void guMtxIdent(Mtx*);
void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z);
void guPosition(Mtx*, f32, f32, f32, f32, f32, f32, f32);
OSYieldResult osSpTaskYielded(OSTask* task);
void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z);
void guRotate(Mtx*, f32 angle, f32 x, f32 y, f32 z);
s32 osAiSetFrequency(u32 frequency);
OSThread* __osGetActiveQueue();
OSThread* __osGetActiveQueue(void);
void guNormalize(f32* x, f32* y, f32* z);
u32 osDpGetStatus(void);
void osDpSetStatus(u32 status);
@ -2574,10 +2581,10 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data);
u8 __osContAddressCrc(u16 addr);
u8 __osContDataCrc(u8* data);
s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg);
u32 __osSpGetStatus();
u32 __osSpGetStatus(void);
void __osSpSetStatus(u32 status);
void osWritebackDCacheAll(void);
OSThread* __osGetCurrFaultedThread();
OSThread* __osGetCurrFaultedThread(void);
void guMtxF2L(MtxF* m1, Mtx* m2);
// ? __d_to_ll(?);
// ? __f_to_ll(?);
@ -2621,12 +2628,12 @@ u8 func_8010BDBC(MessageContext* msgCtx);
// ? func_8010C39C(?);
// ? func_8010F2CC(?);
// ? func_8010F494(?);
// ? func_8010F58C(?);
// ? func_8010F6F0(?);
void func_8010F58C(GlobalContext* globalCtx);
void func_8010F6F0(GlobalContext* globalCtx);
void func_8011040C(void);
// ? func_80110450(?);
// ? func_80110460(?);
// ? func_801104C8(?);
void func_80110450(GlobalContext* globalCtx);
void func_80110460(GlobalContext* globalCtx);
void func_801104C8(GlobalContext* globalCtx);
void func_80110990(GlobalContext* globalCtx);
void func_801109B0(GlobalContext* globalCtx);
void func_80110F68(GlobalContext* globalCtx);

View file

@ -103,6 +103,7 @@ extern GraphicsContext* __gfxCtx;
GraphicsContext* __gfxCtx; \
Gfx* dispRefs[4]; \
__gfxCtx = gfxCtx; \
(void)__gfxCtx; \
Graph_OpenDisps(dispRefs, gfxCtx, file, line)
#define CLOSE_DISPS(gfxCtx, file, line) \

View file

@ -1,7 +1,7 @@
#ifndef _ULTRA64_HARDWARE_H_
#define _ULTRA64_HARDWARE_H_
#define HW_REG(reg, type) *(volatile type*)(reg | 0xa0000000)
#define HW_REG(reg, type) *(volatile type*)((reg) | 0xa0000000)
#define AI_DRAM_ADDR_REG 0x04500000
#define AI_LEN_REG 0x04500004

View file

@ -21,6 +21,8 @@ typedef struct {
/* 0x34 */ u8 qual;
} _Pft; // size = 0x38
typedef void* (*PrintCallback)(void*, const char*, u32);
#define FLAGS_SPACE 1
#define FLAGS_PLUS 2
#define FLAGS_MINUS 4

View file

@ -106,7 +106,7 @@ extern DmaEntry gDmaDataTable[0x60C];
//extern ? D_800D7288;
extern u8 D_801120C0[];
extern u8 D_80113070[];
extern u8 D_80114930[];
extern u64 D_80114930[];
//extern ? D_80115440;
//extern ? D_80115760;
//extern ? D_80115770;
@ -3165,7 +3165,7 @@ extern s16 gTatumsPerBeat;
extern u8 D_80155F50[];
extern u8 D_80157580[];
extern u8 D_801579A0[];
extern u8 D_80157D30[];
extern u64 D_80157D30[];
//extern ? D_8015BC30;
//extern ? D_8015BC3C;
//extern ? D_8015BC48;
@ -3520,7 +3520,7 @@ extern u8 __osMaxControllers;
extern OSMesgQueue __osContMesgQueue;
extern OSMesg __osContMesgBuff[4];
extern __OSInode __osPfsInodeCache;
extern OSPifRam pifMempakBuf;
extern OSPifRam gPifMempakBuf;
//extern ? D_801759A0;
//extern ? D_801759A4;
//extern ? D_801759A8;

View file

@ -719,7 +719,7 @@ typedef struct {
TransitionWipe wipe;
char data[0x228];
};
/* 0x228 */ s32 transitionType;
/* 0x228 */ s32 transitionType;
/* 0x22C */ void* (*init)(void* transition);
/* 0x230 */ void (*destroy)(void* transition);
/* 0x234 */ void (*update)(void* transition, s32 updateRate);
@ -1233,7 +1233,7 @@ typedef struct {
/* 0x14 */ u16 backColor;
/* 0x14 */ u16 cursorX;
/* 0x16 */ u16 cursorY;
/* 0x18 */ u32* fontData;
/* 0x18 */ const u32* fontData;
/* 0x1C */ u8 charW;
/* 0x1D */ u8 charH;
/* 0x1E */ s8 charWPad;
@ -1245,7 +1245,7 @@ typedef struct {
} FaultDrawer; // size = 0x3C
typedef struct GfxPrint {
/* 0x00 */ struct GfxPrint*(*callback)(struct GfxPrint*, const char*, size_t);
/* 0x00 */ struct GfxPrint *(*callback)(struct GfxPrint*, const char*, size_t);
/* 0x04 */ Gfx* dlist;
/* 0x08 */ u16 posX;
/* 0x0A */ u16 posY;
@ -1335,7 +1335,7 @@ typedef struct {
/* 0x278 */ OSTime retraceTime;
} IrqMgr; // size = 0x280
typedef struct {
typedef struct PadMgr {
/* 0x0000 */ OSContStatus padStatus[4];
/* 0x0010 */ OSMesg serialMsgBuf[1];
/* 0x0014 */ OSMesg lockMsgBuf[1];
@ -1349,7 +1349,7 @@ typedef struct {
/* 0x0230 */ Input inputs[4];
/* 0x0290 */ OSContPad pads[4];
/* 0x02A8 */ vu8 validCtrlrsMask;
/* 0x02A9 */ u8 ncontrollers;
/* 0x02A9 */ u8 nControllers;
/* 0x02AA */ u8 ctrlrIsConnected[4]; // "Key_switch" originally
/* 0x02AE */ u8 pakType[4]; // 1 if rumble pack, 2 if mempak?
/* 0x02B2 */ vu8 rumbleEnable[4];
@ -1358,7 +1358,7 @@ typedef struct {
/* 0x045C */ vu8 rumbleOffFrames;
/* 0x045D */ vu8 rumbleOnFrames;
/* 0x045E */ u8 preNMIShutdown;
/* 0x0460 */ void (*retraceCallback)(void* padmgr, u32 unk464);
/* 0x0460 */ void (*retraceCallback)(struct PadMgr* padmgr, s32 unk464);
/* 0x0464 */ u32 retraceCallbackValue;
} PadMgr; // size = 0x468
@ -1645,6 +1645,13 @@ typedef struct {
/* 0x10 */ s16 unk_10;
} JpegDecoderState; // size = 0x14
typedef struct {
/* 0x0000 */ OSViMode viMode;
/* 0x0050 */ char unk_50[0x30];
/* 0x0080 */ u32 viFeatures;
/* 0x0084 */ char unk_84[4];
} unk_80166528;
// Vis...
typedef struct {
/* 0x00 */ u32 type;
@ -1704,7 +1711,7 @@ typedef struct {
} SpeedMeterAllocEntry; // size = 0x1C
typedef struct {
/* 0x00 */ OSTime* time;
/* 0x00 */ volatile OSTime* time;
/* 0x04 */ u8 x;
/* 0x05 */ u8 y;
/* 0x06 */ u16 color;

View file

@ -845,7 +845,7 @@ typedef struct {
/* 0x000C */ Vec3f norm;
/* 0x0018 */ CollisionPoly* poly;
/* 0x001C */ VecSph sphNorm;
/* 0x0024 */ u32 bgId;
/* 0x0024 */ s32 bgId;
} CamColChk; // size = 0x28
typedef struct {

View file

@ -7,7 +7,7 @@ typedef struct {
/* 0x00 */ u32 vromAddr; // VROM address (source)
/* 0x04 */ void* dramAddr; // DRAM address (destination)
/* 0x08 */ u32 size; // File Transfer size
/* 0x0C */ char* filename; // Filename for debugging
/* 0x0C */ const char* filename; // Filename for debugging
/* 0x10 */ s32 line; // Line for debugging
/* 0x14 */ s32 unk_14;
/* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message

View file

@ -2,6 +2,7 @@
void __assert(const char* exp, const char* file, s32 line) {
char msg[256];
osSyncPrintf("Assertion failed: %s, file %s, line %d, thread %d\n", exp, file, line, osGetThreadId(NULL));
sprintf(msg, "ASSERT: %s:%d(%d)", file, line, osGetThreadId(NULL));
Fault_AddHungupAndCrashImpl(msg, exp);

View file

@ -24,6 +24,7 @@ void bootproc(void) {
Locale_Init();
StackCheck_Init(&sIdleThreadInfo, sIdleThreadStack, sIdleThreadStack + sizeof(sIdleThreadStack), 0, 256, "idle");
osCreateThread(&sIdleThread, 1, Idle_ThreadEntry, 0, sIdleThreadStack + sizeof(sIdleThreadStack), Z_PRIORITY_MAIN);
osCreateThread(&sIdleThread, 1, Idle_ThreadEntry, NULL, sIdleThreadStack + sizeof(sIdleThreadStack),
Z_PRIORITY_MAIN);
osStartThread(&sIdleThread);
}

View file

@ -16,25 +16,25 @@ u32 gViConfigFeatures = OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF;
f32 gViConfigXScale = 1.0;
f32 gViConfigYScale = 1.0;
void Main_ThreadEntry(void* arg0) {
OSTime var1;
void Main_ThreadEntry(void* arg) {
OSTime time;
osSyncPrintf("mainx 実行開始\n");
DmaMgr_Init();
osSyncPrintf("codeセグメントロード中...");
var1 = osGetTime();
time = osGetTime();
DmaMgr_SendRequest1(_codeSegmentStart, (u32)_codeSegmentRomStart, _codeSegmentRomEnd - _codeSegmentRomStart,
"../idle.c", 238);
var1 -= osGetTime();
time -= osGetTime();
osSyncPrintf("\rcodeセグメントロード中...完了\n");
osSyncPrintf("転送時間 %6.3f\n");
bzero(_codeSegmentBssStart, _codeSegmentBssEnd - _codeSegmentBssStart);
osSyncPrintf("codeセグメントBSSクリア完了\n");
Main(arg0);
Main(arg);
osSyncPrintf("mainx 実行終了\n");
}
void Idle_ThreadEntry(void* a0) {
void Idle_ThreadEntry(void* arg) {
osSyncPrintf("アイドルスレッド(idleproc)実行開始\n");
osSyncPrintf("作製者 : %s\n", gBuildTeam);
osSyncPrintf("作成日時 : %s\n", gBuildDate);
@ -80,7 +80,7 @@ void Idle_ThreadEntry(void* a0) {
osViSwapBuffer(0x803DA80); //! @bug Invalid vram address (probably intended to be 0x803DA800)
osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQ, sPiMgrCmdBuff, 50);
StackCheck_Init(&sMainStackInfo, sMainStack, sMainStack + sizeof(sMainStack), 0, 0x400, "main");
osCreateThread(&gMainThread, 3, Main_ThreadEntry, a0, sMainStack + sizeof(sMainStack), Z_PRIORITY_MAIN);
osCreateThread(&gMainThread, 3, Main_ThreadEntry, arg, sMainStack + sizeof(sMainStack), Z_PRIORITY_MAIN);
osStartThread(&gMainThread);
osSetThreadPri(NULL, OS_PRIORITY_IDLE);

View file

@ -5,7 +5,7 @@ OSPiHandle* sISVHandle; // official name : is_Handle
#define gISVDbgPrnAdrs ((ISVDbg*)0xb3ff0000)
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
void isPrintfInit() {
void isPrintfInit(void) {
sISVHandle = osCartRomInit();
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, 0);
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->get, 0);
@ -16,14 +16,14 @@ void osSyncPrintfUnused(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
_Printf(&is_proutSyncPrintf, NULL, fmt, args);
_Printf(is_proutSyncPrintf, NULL, fmt, args);
}
void osSyncPrintf(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
_Printf(&is_proutSyncPrintf, NULL, fmt, args);
_Printf(is_proutSyncPrintf, NULL, fmt, args);
}
// assumption
@ -31,10 +31,10 @@ void rmonPrintf(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
_Printf(&is_proutSyncPrintf, NULL, fmt, args);
_Printf(is_proutSyncPrintf, NULL, fmt, args);
}
u32 is_proutSyncPrintf(void* arg0, const char* str, s32 count) {
void* is_proutSyncPrintf(void* arg, const char* str, u32 count) {
u32 data;
s32 pos;
s32 start;
@ -75,6 +75,7 @@ u32 is_proutSyncPrintf(void* arg0, const char* str, s32 count) {
str++;
}
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, start);
return 1;
}

View file

@ -1,22 +1,22 @@
#include "global.h"
#include "vt.h"
f32 LogUtils_CheckFloatRange(const char* exp, s32 arg1, const char* var1Name, f32 var1, const char* var2Name, f32 var2,
const char* var3Name, f32 var3) {
if (var1 < var2 || var3 < var1) {
osSyncPrintf("%s %d: range error %s(%f) < %s(%f) < %s(%f)\n", exp, arg1, var2Name, var2, var1Name, var1,
var3Name, var3);
f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min,
const char* maxName, f32 max) {
if (value < min || max < value) {
osSyncPrintf("%s %d: range error %s(%f) < %s(%f) < %s(%f)\n", exp, line, minName, min, valueName, value,
maxName, max);
}
return var1;
return value;
}
s32 LogUtils_CheckIntRange(const char* exp, s32 arg1, const char* var1Name, s32 var1, const char* var2Name, s32 var2,
const char* var3Name, s32 var3) {
if (var1 < var2 || var3 < var1) {
osSyncPrintf("%s %d: range error %s(%d) < %s(%d) < %s(%d)\n", exp, arg1, var2Name, var2, var1Name, var1,
var3Name, var3);
s32 LogUtils_CheckIntRange(const char* exp, s32 line, const char* valueName, s32 value, const char* minName, s32 min,
const char* maxName, s32 max) {
if (value < min || max < value) {
osSyncPrintf("%s %d: range error %s(%d) < %s(%d) < %s(%d)\n", exp, line, minName, min, valueName, value,
maxName, max);
}
return var1;
return value;
}
void LogUtils_LogHexDump(void* ptr, s32 size0) {
@ -84,14 +84,13 @@ void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* fi
}
void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, s32 line) {
if (!ptr) {
if (ptr == NULL) {
osSyncPrintf(VT_COL(RED, WHITE) "%s %d:%s は はヌルポインタです\n" VT_RST, file, line, exp);
}
}
void LogUtils_CheckValidPointer(const char* exp, void* ptr0, const char* file, s32 line) {
u32 ptr = (u32)ptr0;
if (!ptr || ptr < 0x80000000U || (0x80000000U + osMemSize) <= ptr) {
void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, s32 line) {
if (ptr == NULL || (u32)ptr < 0x80000000 || (0x80000000 + osMemSize) <= (u32)ptr) {
osSyncPrintf(VT_COL(RED, WHITE) "%s %d:ポインタ %s(%08x) が異常です\n" VT_RST, file, line, exp, ptr);
}
}
@ -105,7 +104,7 @@ void LogUtils_HungupThread(const char* name, s32 line) {
Fault_AddHungupAndCrash(name, line);
}
void LogUtils_ResetHungup() {
void LogUtils_ResetHungup(void) {
osSyncPrintf("*** Reset ***\n");
Fault_AddHungupAndCrash("Reset", 0);
}

View file

@ -9,7 +9,7 @@ void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 i
StackEntry* iter;
u32* addr;
if (!entry) {
if (entry == NULL) {
sStackInfoListStart = NULL;
} else {
entry->head = (u32)stackTop;
@ -90,7 +90,7 @@ StackStatus StackCheck_GetState(StackEntry* entry) {
if (free == 0) {
ret = STACK_STATUS_OVERFLOW;
osSyncPrintf(VT_FGCOL(RED));
} else if (free < entry->minSpace && entry->minSpace != -1) {
} else if (free < (u32)entry->minSpace && entry->minSpace != -1) {
ret = STACK_STATUS_WARNING;
osSyncPrintf(VT_FGCOL(YELLOW));
} else {
@ -109,10 +109,10 @@ StackStatus StackCheck_GetState(StackEntry* entry) {
return ret;
}
u32 StackCheck_CheckAll() {
u32 StackCheck_CheckAll(void) {
u32 ret = 0;
StackEntry* iter = sStackInfoListStart;
while (iter) {
u32 state = StackCheck_GetState(iter);
if (state != STACK_STATUS_OK) {
@ -125,7 +125,7 @@ u32 StackCheck_CheckAll() {
}
u32 StackCheck_Check(StackEntry* entry) {
if (!entry) {
if (entry == NULL) {
return StackCheck_CheckAll();
} else {
return StackCheck_GetState(entry);

View file

@ -4,8 +4,8 @@
// this should probably go elsewhere but right now viconfig.o is the only object between idle and z_std_dma
OSPiHandle* gCartHandle = 0;
void ViConfig_UpdateVi(u32 arg0) {
if (arg0 != 0) {
void ViConfig_UpdateVi(u32 mode) {
if (mode != 0) {
osSyncPrintf(VT_COL(YELLOW, BLACK) "osViSetYScale1(%f);\n" VT_RST, 1.0f);
if (osTvType == 0) {
@ -34,10 +34,10 @@ void ViConfig_UpdateVi(u32 arg0) {
}
}
gViConfigUseDefault = arg0;
gViConfigUseDefault = mode;
}
void ViConfig_UpdateBlack() {
void ViConfig_UpdateBlack(void) {
if (gViConfigUseDefault != 0) {
osViBlack(1);
} else {

View file

@ -6,7 +6,7 @@ u32 sYaz0CurRomStart;
u32 sYaz0CurSize;
u32 sYaz0MaxPtr;
void* Yaz0_FirstDMA() {
void* Yaz0_FirstDMA(void) {
u32 pad0;
u32 pad1;
u32 dmaSize;
@ -29,7 +29,6 @@ void* Yaz0_NextDMA(void* curSrcPos) {
u32 dmaSize;
restSize = sYaz0CurDataEnd - (u32)curSrcPos;
dst = (restSize & 7) ? (sYaz0DataBuffer - (restSize & 7)) + 8 : sYaz0DataBuffer;
bcopy(curSrcPos, dst, restSize);
@ -51,19 +50,15 @@ void* Yaz0_NextDMA(void* curSrcPos) {
}
void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) {
u32 bitIdx;
u8* src;
u8* dstEnd;
u32 bitIdx = 0;
u8* src = (u8*)hdr->data;
u8* dstEnd = dst + hdr->decSize;
u32 chunkHeader;
u32 nibble;
u8* backPtr;
s32 chunkSize;
u32 chunkSize;
u32 off;
bitIdx = 0;
src = (u8*)hdr->data;
dstEnd = dst + hdr->decSize;
do {
if (bitIdx == 0) {
if ((sYaz0MaxPtr < (u32)src) && (sYaz0CurSize != 0)) {
@ -84,9 +79,9 @@ void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) {
backPtr = dst - off;
src += 2;
chunkSize = (nibble == 0) // N = chunkSize; B = back offset
? *src++ + 0x12 // 3 bytes 0B BB NN
: nibble + 2; // 2 bytes NB BB
chunkSize = (nibble == 0) // N = chunkSize; B = back offset
? (u32)(*src++ + 0x12) // 3 bytes 0B BB NN
: nibble + 2; // 2 bytes NB BB
do {
*dst++ = *(backPtr++ - 1);

View file

@ -4,7 +4,7 @@
u32 gCurrentRegion = 0;
LocaleCartInfo sCartInfo;
void Locale_Init() {
void Locale_Init(void) {
osEPiReadIo(gCartHandle, 0x38, &sCartInfo.mediaFormat);
osEPiReadIo(gCartHandle, 0x3C, &sCartInfo.regionInfo);
@ -29,11 +29,11 @@ void Locale_Init() {
osSyncPrintf("z_locale_init:日本用かアメリカ用か3コンで判断させる\n");
}
void Locale_ResetRegion() {
void Locale_ResetRegion(void) {
gCurrentRegion = REGION_NULL;
}
u32 func_80001F48() {
u32 func_80001F48(void) {
if (gCurrentRegion == REGION_NATIVE) {
return 0;
}
@ -45,7 +45,7 @@ u32 func_80001F48() {
return 1;
}
u32 func_80001F8C() {
u32 func_80001F8C(void) {
if (gCurrentRegion == REGION_NATIVE) {
return 0;
}
@ -58,6 +58,6 @@ u32 func_80001F8C() {
}
// This function appears to be unused?
u32 Locale_IsRegionNative() {
u32 Locale_IsRegionNative(void) {
return gCurrentRegion == REGION_NATIVE;
}

View file

@ -12,6 +12,7 @@ s32 sDmaMgrCurFileLine;
u32 D_80009460 = 0;
u32 gDmaMgrDmaBuffSize = 0x2000;
u32 sDmaMgrDataExistError = 0;
const char* sDmaMgrFileNames[0x5FC] = {
"makerom",
"boot",
@ -1573,10 +1574,9 @@ s32 DmaMgr_DMARomToRam(u32 rom, u32 ram, u32 size) {
OSMesgQueue queue;
OSMesg msg;
s32 ret;
u32 buffSize;
u32 buffSize = gDmaMgrDmaBuffSize;
s32 pad[2];
buffSize = gDmaMgrDmaBuffSize;
if (buffSize == 0) {
buffSize = 0x2000;
}
@ -1676,12 +1676,11 @@ s32 DmaMgr_DmaCallback0(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
}
void DmaMgr_DmaCallback1(u32 ram, u32 rom, u32 size) {
OSPiHandle* handle;
OSPiHandle* handle = osDriveRomInit();
OSMesgQueue queue;
OSMesg msg;
OSIoMesg ioMsg;
handle = osDriveRomInit();
osInvalICache((void*)ram, size);
osInvalDCache((void*)ram, size);
osCreateMesgQueue(&queue, &msg, 1);
@ -1694,21 +1693,17 @@ void DmaMgr_DmaCallback1(u32 ram, u32 rom, u32 size) {
handle->transferInfo.cmdType = 2;
osEPiStartDma(handle, &ioMsg, 0);
osRecvMesg(&queue, NULL, 1);
osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
return;
}
void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) {
u32 vrom;
u32 ram;
u32 size;
u32 vrom = req->vromAddr;
u32 ram = (u32)req->dramAddr;
u32 size = req->size;
char buff1[80];
char buff2[80];
vrom = req->vromAddr;
ram = (u32)req->dramAddr;
size = req->size;
osSyncPrintf("%c", 7);
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("DMA致命的エラー(%s)\nROM:%X RAM:%X SIZE:%X %s\n",
@ -1735,11 +1730,8 @@ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, cons
}
const char* DmaMgr_GetFileNameImpl(u32 vrom) {
DmaEntry* iter;
const char** name;
iter = gDmaDataTable;
name = sDmaMgrFileNames;
DmaEntry* iter = gDmaDataTable;
const char** name = sDmaMgrFileNames;
while (iter->vromEnd) {
if (vrom >= iter->vromStart && vrom < iter->vromEnd) {
@ -1755,7 +1747,8 @@ const char* DmaMgr_GetFileNameImpl(u32 vrom) {
const char* DmaMgr_GetFileName(u32 vrom) {
const char* ret = DmaMgr_GetFileNameImpl(vrom);
if (!ret) {
if (ret == NULL) {
return "(unknown)";
}
@ -1767,25 +1760,26 @@ const char* DmaMgr_GetFileName(u32 vrom) {
}
void DmaMgr_ProcessMsg(DmaRequest* req) {
u32 vrom;
void* ram;
u32 size;
u32 vrom = req->vromAddr;
void* ram = req->dramAddr;
u32 size = req->size;
u32 romStart;
u32 romSize;
u8 found;
u8 found = false;
DmaEntry* iter;
const char* filename;
vrom = req->vromAddr;
ram = req->dramAddr;
size = req->size;
found = false;
if (0) {
// the string is defined in .rodata but not used, suggesting
// a debug print is here but optimized out in some way
osSyncPrintf("DMA ROM:%08X RAM:%08X SIZE:%08X %s\n");
// the last arg of this print looks like it may be filename, but
// filename above this block does not match
}
filename = DmaMgr_GetFileName(vrom);
iter = gDmaDataTable;
// defined in .rodata but not used
"DMA ROM:%08X RAM:%08X SIZE:%08X %s\n";
while (iter->vromEnd) {
if (vrom >= iter->vromStart && vrom < iter->vromEnd) {
if (1) {} // Necessary to match
@ -1799,7 +1793,9 @@ void DmaMgr_ProcessMsg(DmaRequest* req) {
DmaMgr_DMARomToRam(iter->romStart + (vrom - iter->vromStart), (u32)ram, size);
found = true;
"No Press ROM:%08X RAM:%08X SIZE:%08X\n";
if (0) {
osSyncPrintf("No Press ROM:%08X RAM:%08X SIZE:%08X\n", vrom, ram, size);
}
} else {
romStart = iter->romStart;
romSize = iter->romEnd - iter->romStart;
@ -1819,7 +1815,9 @@ void DmaMgr_ProcessMsg(DmaRequest* req) {
osSetThreadPri(NULL, Z_PRIORITY_DMAMGR);
found = true;
" Press ROM:%X RAM:%X SIZE:%X\n";
if (0) {
osSyncPrintf(" Press ROM:%X RAM:%X SIZE:%X\n", vrom, ram, size);
}
}
break;
}
@ -1834,7 +1832,9 @@ void DmaMgr_ProcessMsg(DmaRequest* req) {
DmaMgr_DMARomToRam(vrom, (u32)ram, size);
"No Press ROM:%08X RAM:%08X SIZE:%08X (非公式)\n";
if (0) {
osSyncPrintf("No Press ROM:%08X RAM:%08X SIZE:%08X (非公式)\n", vrom, ram, size);
}
}
}
@ -1846,17 +1846,20 @@ void DmaMgr_ThreadEntry(void* arg0) {
while (true) {
osRecvMesg(&sDmaMgrMsgQueue, &msg, 1);
req = (DmaRequest*)msg;
if (!req) {
if (req == NULL) {
break;
}
// strings present in .rodata but not actually used in the function, probably a removed function
"DMA登録受付 dmap=%08x\n";
if (0) {
osSyncPrintf("DMA登録受付 dmap=%08x\n", req);
}
DmaMgr_ProcessMsg(req);
if (req->notifyQueue) {
osSendMesg(req->notifyQueue, req->notifyMsg, 0);
"osSendMesg: dmap=%08x, mq=%08x, m=%08x \n";
osSendMesg(req->notifyQueue, req->notifyMsg, OS_MESG_NOBLOCK);
if (0) {
osSyncPrintf("osSendMesg: dmap=%08x, mq=%08x, m=%08x \n", req, req->notifyQueue, req->notifyMsg);
}
}
}
osSyncPrintf("DMAマネージャスレッド実行終了\n");
@ -1889,7 +1892,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk
}
}
osSendMesg(&sDmaMgrMsgQueue, req, 1);
osSendMesg(&sDmaMgrMsgQueue, req, OS_MESG_BLOCK);
return 0;
}
@ -1905,19 +1908,17 @@ s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size) {
return ret;
}
osRecvMesg(&queue, NULL, 1);
osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
return 0;
}
void DmaMgr_Init() {
void DmaMgr_Init(void) {
const char** name;
s32 idx;
DmaEntry* iter;
if (_dmadataSegmentRomStart) {} // Necessary to match
DmaMgr_DMARomToRam((u32)_dmadataSegmentRomStart, (u32)_dmadataSegmentStart,
(u32)_dmadataSegmentRomEnd - (u32)_dmadataSegmentRomStart);
(u32)(_dmadataSegmentRomEnd - _dmadataSegmentRomStart));
osSyncPrintf("dma_rom_ad[]\n");
sDmaMgrDataExistError = 0;
@ -1949,7 +1950,7 @@ void DmaMgr_Init() {
Fault_AddHungupAndCrash("../z_std_dma.c", 1055);
}
osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgs, sizeof(sDmaMgrMsgs) / sizeof(sDmaMgrMsgs[0]));
osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgs, ARRAY_COUNT(sDmaMgrMsgs));
StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, sDmaMgrStack + sizeof(sDmaMgrStack), 0, 0x100, "dmamgr");
osCreateThread(&sDmaMgrThread, 0x12, &DmaMgr_ThreadEntry, 0, sDmaMgrStack + sizeof(sDmaMgrStack),
Z_PRIORITY_DMAMGR);
@ -1968,7 +1969,6 @@ s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 li
s32 ret;
OSMesgQueue queue;
OSMesg msg;
u32 ram = (u32)ram0;
req.filename = file;

View file

@ -276,9 +276,7 @@ void func_800C1F20(PreRenderContext* this, Gfx** gfxp) {
}
void func_800C1FA4(PreRenderContext* this, Gfx** gfxp) {
Gfx* gfx;
gfx = *gfxp;
Gfx* gfx = *gfxp;
gDPPipeSync(gfx++);
gDPSetBlendColor(gfx++, 255, 255, 255, 8);

View file

@ -78,6 +78,7 @@ void* THA_GetTail(TwoHeadArena* tha) {
void* THA_AllocStart(TwoHeadArena* tha, u32 size) {
void* start = tha->head;
tha->head = (u32)tha->head + size;
return start;
}

View file

@ -68,44 +68,39 @@ void ArenaImpl_Unlock(Arena* arena) {
}
ArenaNode* ArenaImpl_GetNextBlock(ArenaNode* node) {
ArenaNode* ret;
ArenaNode* next = node->next;
ret = node->next;
if (ret && (!ret || (ret->magic != NODE_MAGIC))) {
osSyncPrintf(VT_COL(RED, WHITE) "緊急事態!メモリリーク発見! (block=%08x)\n" VT_RST, ret);
ret = NULL;
if (next != NULL && (next == NULL || (next->magic != NODE_MAGIC))) {
osSyncPrintf(VT_COL(RED, WHITE) "緊急事態!メモリリーク発見! (block=%08x)\n" VT_RST, next);
next = NULL;
node->next = NULL;
}
return ret;
return next;
}
ArenaNode* ArenaImpl_GetPrevBlock(ArenaNode* node) {
ArenaNode* ret;
ArenaNode* prev = node->prev;
ret = node->prev;
if (ret && (!ret || (ret->magic != NODE_MAGIC))) {
osSyncPrintf(VT_COL(RED, WHITE) "緊急事態!メモリリーク発見! (block=%08x)\n" VT_RST, ret);
ret = NULL;
if (prev != NULL && (prev == NULL || (prev->magic != NODE_MAGIC))) {
osSyncPrintf(VT_COL(RED, WHITE) "緊急事態!メモリリーク発見! (block=%08x)\n" VT_RST, prev);
prev = NULL;
node->prev = NULL;
}
return ret;
return prev;
}
ArenaNode* ArenaImpl_GetLastBlock(Arena* arena) {
ArenaNode* ret = NULL;
ArenaNode* last = NULL;
ArenaNode* iter;
if (arena && arena->head && arena->head->magic == NODE_MAGIC) {
if (arena != NULL && arena->head != NULL && arena->head->magic == NODE_MAGIC) {
iter = arena->head;
while (iter) {
ret = iter;
while (iter != NULL) {
last = iter;
iter = ArenaImpl_GetNextBlock(iter);
}
}
return ret;
return last;
}
void __osMallocInit(Arena* arena, void* start, u32 size) {
@ -121,10 +116,11 @@ void __osMallocAddBlock(Arena* arena, void* start, s32 size) {
ArenaNode* firstNode;
ArenaNode* lastNode;
if (start) {
if (start != NULL) {
firstNode = (ArenaNode*)ALIGN16((u32)start);
diff = (s32)firstNode - (s32)start;
size2 = (size - diff) & ~0xF;
if (size2 > (s32)sizeof(ArenaNode)) {
func_80106860(firstNode, BLOCK_UNINIT_MAGIC, size2); // memset
firstNode->next = NULL;
@ -134,7 +130,7 @@ void __osMallocAddBlock(Arena* arena, void* start, s32 size) {
firstNode->magic = NODE_MAGIC;
ArenaImpl_Lock(arena);
lastNode = ArenaImpl_GetLastBlock(arena);
if (!lastNode) {
if (lastNode == NULL) {
arena->head = firstNode;
arena->start = start;
} else {
@ -151,8 +147,9 @@ void ArenaImpl_RemoveAllBlocks(Arena* arena) {
ArenaNode* next;
ArenaImpl_Lock(arena);
iter = arena->head;
while (iter) {
while (iter != NULL) {
next = ArenaImpl_GetNextBlock(iter);
func_80106860(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); // memset
iter = next;
@ -171,17 +168,16 @@ u8 __osMallocIsInitalized(Arena* arena) {
}
void __osMalloc_FreeBlockTest(Arena* arena, ArenaNode* node) {
ArenaNode* node2;
ArenaNode* node2 = node;
u32* start;
u32* end;
u32* iter;
node2 = node;
if (__osMalloc_FreeBlockTest_Enable) {
start = (u32*)((u32)node + sizeof(ArenaNode));
end = (u32*)((u32)start + node2->size);
iter = start;
while (iter < end) {
if (*iter != BLOCK_UNINIT_MAGIC_32 && *iter != BLOCK_FREE_MAGIC_32) {
osSyncPrintf(
@ -199,15 +195,14 @@ void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line)
ArenaNode* iter;
u32 blockSize;
ArenaNode* newNode;
void* ret;
void* alloc = NULL;
ArenaNode* next;
ret = NULL;
iter = arena->head;
size = ALIGN16(size);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
while (iter) {
while (iter != NULL) {
if (iter->isFree && iter->size >= size) {
if (arena->flag & CHECK_FREE_BLOCK) {
__osMalloc_FreeBlockTest(arena, iter);
@ -231,9 +226,9 @@ void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line)
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, file, line, arena);
ret = (void*)((u32)iter + sizeof(ArenaNode));
alloc = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
func_80106860(alloc, BLOCK_ALLOC_MAGIC, size);
}
break;
@ -242,15 +237,17 @@ void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line)
iter = ArenaImpl_GetNextBlock(iter);
}
return ret;
return alloc;
}
void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line) {
void* ret;
void* alloc;
ArenaImpl_Lock(arena);
ret = __osMalloc_NoLockDebug(arena, size, file, line);
alloc = __osMalloc_NoLockDebug(arena, size, file, line);
ArenaImpl_Unlock(arena);
return ret;
return alloc;
}
void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) {
@ -258,14 +255,13 @@ void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) {
ArenaNode* newNode;
u32 blockSize;
ArenaNode* next;
void* ret;
void* allocR = NULL;
ret = NULL;
size = ALIGN16(size);
ArenaImpl_Lock(arena);
iter = ArenaImpl_GetLastBlock(arena);
while (iter) {
while (iter != NULL) {
if (iter->isFree && iter->size >= size) {
if (arena->flag & CHECK_FREE_BLOCK) {
__osMalloc_FreeBlockTest(arena, iter);
@ -285,15 +281,14 @@ void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) {
if (next) {
next->prev = newNode;
}
iter = newNode;
}
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, file, line, arena);
ret = (void*)((u32)iter + sizeof(ArenaNode));
allocR = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
func_80106860(allocR, BLOCK_ALLOC_MAGIC, size);
}
break;
@ -301,24 +296,23 @@ void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) {
iter = ArenaImpl_GetPrevBlock(iter);
}
ArenaImpl_Unlock(arena);
return ret;
return allocR;
}
void* __osMalloc_NoLock(Arena* arena, u32 size) {
ArenaNode* iter;
u32 blockSize;
ArenaNode* newNode;
void* ret;
void* alloc = NULL;
ArenaNode* next;
ret = NULL;
iter = arena->head;
size = ALIGN16(size);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
while (iter) {
while (iter != NULL) {
if (iter->isFree && iter->size >= size) {
if (arena->flag & CHECK_FREE_BLOCK) {
@ -343,26 +337,27 @@ void* __osMalloc_NoLock(Arena* arena, u32 size) {
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, NULL, 0, arena);
ret = (void*)((u32)iter + sizeof(ArenaNode));
alloc = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
func_80106860(alloc, BLOCK_ALLOC_MAGIC, size);
}
break;
}
iter = ArenaImpl_GetNextBlock(iter);
}
return ret;
return alloc;
}
void* __osMalloc(Arena* arena, u32 size) {
void* ret;
void* alloc;
ArenaImpl_Lock(arena);
ret = __osMalloc_NoLock(arena, size);
alloc = __osMalloc_NoLock(arena, size);
ArenaImpl_Unlock(arena);
return ret;
return alloc;
}
void* __osMallocR(Arena* arena, u32 size) {
@ -370,14 +365,13 @@ void* __osMallocR(Arena* arena, u32 size) {
ArenaNode* newNode;
u32 blockSize;
ArenaNode* next;
void* ret;
void* alloc = NULL;
ret = NULL;
size = ALIGN16(size);
ArenaImpl_Lock(arena);
iter = ArenaImpl_GetLastBlock(arena);
while (iter) {
while (iter != NULL) {
if (iter->isFree && iter->size >= size) {
if (arena->flag & CHECK_FREE_BLOCK) {
__osMalloc_FreeBlockTest(arena, iter);
@ -397,25 +391,22 @@ void* __osMallocR(Arena* arena, u32 size) {
if (next) {
next->prev = newNode;
}
iter = newNode;
}
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, NULL, 0, arena);
ret = (void*)((u32)iter + sizeof(ArenaNode));
alloc = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
func_80106860(alloc, BLOCK_ALLOC_MAGIC, size);
}
break;
}
iter = ArenaImpl_GetPrevBlock(iter);
}
ArenaImpl_Unlock(arena);
return ret;
return alloc;
}
void __osFree_NoLock(Arena* arena, void* ptr) {
@ -424,56 +415,59 @@ void __osFree_NoLock(Arena* arena, void* ptr) {
ArenaNode* prev;
ArenaNode* newNext;
if (ptr) {
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x)\n" VT_RST,
ptr); // __osFree: Unauthorized release (%08x)
return;
}
if (node->isFree) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x)\n" VT_RST, ptr); // __osFree: Double release (%08x)
return;
}
if (arena != node->arena && arena != NULL) {
// __osFree:Tried to release in a different way than when it was secured (%08x:%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n" VT_RST, arena,
node->arena);
return;
if (ptr == NULL) {
return;
}
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x)\n" VT_RST,
ptr); // __osFree: Unauthorized release (%08x)
return;
}
if (node->isFree) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x)\n" VT_RST, ptr); // __osFree: Double release (%08x)
return;
}
if (arena != node->arena && arena != NULL) {
// __osFree:Tried to release in a different way than when it was secured (%08x:%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n" VT_RST, arena,
node->arena);
return;
}
next = ArenaImpl_GetNextBlock(node);
prev = ArenaImpl_GetPrevBlock(node);
node->isFree = true;
ArenaImpl_SetDebugInfo(node, NULL, 0, arena);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
}
newNext = next;
if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree) {
newNext = ArenaImpl_GetNextBlock(next);
if (newNext != NULL) {
newNext->prev = node;
}
next = ArenaImpl_GetNextBlock(node);
prev = ArenaImpl_GetPrevBlock(node);
node->isFree = true;
ArenaImpl_SetDebugInfo(node, NULL, 0, arena);
node->size += next->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
node->next = newNext;
next = newNext;
}
newNext = next;
if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree) {
newNext = ArenaImpl_GetNextBlock(next);
if (newNext) {
newNext->prev = node;
}
node->size += next->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
node->next = newNext;
next = newNext;
if (prev != NULL && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size) {
if (next) {
next->prev = prev;
}
if (prev && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size) {
if (next) {
next->prev = prev;
}
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
}
}
@ -490,57 +484,60 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) {
ArenaNode* prev;
ArenaNode* newNext;
if (ptr) {
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x) [%s:%d ]\n" VT_RST, ptr, file,
line); // __osFree: Unauthorized release (%08x)
return;
}
if (node->isFree) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x) [%s:%d ]\n" VT_RST, ptr, file,
line); // __osFree: Double release (%08x)
return;
}
if (arena != node->arena && arena != NULL) {
// __osFree:Tried to release in a different way than when it was secured (%08x:%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n" VT_RST, arena,
node->arena);
return;
if (ptr == NULL) {
return;
}
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x) [%s:%d ]\n" VT_RST, ptr, file,
line); // __osFree: Unauthorized release (%08x)
return;
}
if (node->isFree) {
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x) [%s:%d ]\n" VT_RST, ptr, file,
line); // __osFree: Double release (%08x)
return;
}
if (arena != node->arena && arena != NULL) {
// __osFree:Tried to release in a different way than when it was secured (%08x:%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:確保時と違う方法で解放しようとした (%08x:%08x)\n" VT_RST, arena,
node->arena);
return;
}
next = ArenaImpl_GetNextBlock(node);
prev = ArenaImpl_GetPrevBlock(node);
node->isFree = true;
ArenaImpl_SetDebugInfo(node, file, line, arena);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
}
newNext = node->next;
if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree) {
newNext = ArenaImpl_GetNextBlock(next);
if (newNext != NULL) {
newNext->prev = node;
}
next = ArenaImpl_GetNextBlock(node);
prev = ArenaImpl_GetPrevBlock(node);
node->isFree = true;
ArenaImpl_SetDebugInfo(node, file, line, arena);
node->size += next->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
node->next = newNext;
next = newNext;
}
newNext = node->next;
if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree) {
newNext = ArenaImpl_GetNextBlock(next);
if (newNext) {
newNext->prev = node;
}
node->size += next->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
node->next = newNext;
next = newNext;
if (prev != NULL && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size) {
if (next != NULL) {
next->prev = prev;
}
if (prev && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size) {
if (next) {
next->prev = prev;
}
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
}
}
@ -568,9 +565,10 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
newSize = ALIGN16(newSize);
osSyncPrintf("__osRealloc(%08x, %d)\n", ptr, newSize);
ArenaImpl_Lock(arena);
if (!ptr) {
if (ptr == NULL) {
ptr = __osMalloc_NoLock(arena, newSize);
} else if (!newSize) {
} else if (newSize == 0) {
__osFree_NoLock(arena, ptr);
ptr = NULL;
} else {
@ -587,7 +585,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
next->size -= sizeDiff;
overNext = ArenaImpl_GetNextBlock(next);
newNext = (ArenaNode*)((u32)next + sizeDiff);
if (overNext) {
if (overNext != NULL) {
overNext->prev = newNext;
}
node->next = newNext;
@ -597,7 +595,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
// Allocate a new memory block and move the contents
osSyncPrintf("新たにメモリブロックを確保して内容を移動します\n");
newAlloc = __osMalloc_NoLock(arena, newSize);
if (newAlloc) {
if (newAlloc != NULL) {
bcopy(ptr, newAlloc, node->size);
__osFree_NoLock(arena, ptr);
}
@ -605,7 +603,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
}
} else if (newSize < node->size) {
next2 = ArenaImpl_GetNextBlock(node);
if (next2 && next2->isFree) {
if (next2 != NULL && next2->isFree) {
blockSize = ALIGN16(newSize) + sizeof(ArenaNode);
// Increased free block behind current memory block
osSyncPrintf("現メモリブロックの後ろのフリーブロックを大きくしました\n");
@ -616,7 +614,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
node->next = newNext2;
node->size = newSize;
overNext2 = ArenaImpl_GetNextBlock(newNext2);
if (overNext2) {
if (overNext2 != NULL) {
overNext2->prev = newNext2;
}
} else if (newSize + sizeof(ArenaNode) < node->size) {
@ -632,7 +630,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
node->next = newNext2;
node->size = newSize;
overNext2 = ArenaImpl_GetNextBlock(newNext2);
if (overNext2) {
if (overNext2 != NULL) {
overNext2->prev = newNext2;
}
} else {
@ -642,8 +640,8 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
}
}
}
ArenaImpl_Unlock(arena);
return ptr;
}
@ -661,7 +659,7 @@ void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAll
*outAlloc = 0;
iter = arena->head;
while (iter) {
while (iter != NULL) {
if (iter->isFree) {
*outFree += iter->size;
if (*outMaxFree < iter->size) {
@ -702,11 +700,11 @@ void __osDisplayArena(Arena* arena) {
osSyncPrintf("メモリブロック範囲 status サイズ [時刻 s ms us ns: TID:src:行]\n");
iter = arena->head;
while (iter) {
if (iter && iter->magic == NODE_MAGIC) {
while (iter != NULL) {
if (iter != NULL && iter->magic == NODE_MAGIC) {
next = iter->next;
osSyncPrintf("%08x-%08x%c %s %08x", iter, ((u32)iter + sizeof(ArenaNode) + iter->size),
(!next) ? '$' : (iter != next->prev ? '!' : ' '),
(next == NULL) ? '$' : (iter != next->prev ? '!' : ' '),
iter->isFree ? "空き" : "確保", //? "Free" : "Secure"
iter->size);
@ -729,7 +727,6 @@ void __osDisplayArena(Arena* arena) {
osSyncPrintf("%08x Block Invalid\n", iter);
next = NULL;
}
iter = next;
}
@ -760,8 +757,8 @@ void ArenaImpl_FaultClient(Arena* arena) {
FaultDrawer_Printf("Memory Block Region status size\n");
iter = arena->head;
while (iter) {
if (iter && iter->magic == NODE_MAGIC) {
while (iter != NULL) {
if (iter != NULL && iter->magic == NODE_MAGIC) {
next = iter->next;
FaultDrawer_Printf("%08x-%08x%c %s %08x", iter, ((u32)iter + sizeof(ArenaNode) + iter->size),
(!next) ? '$' : (iter != next->prev ? '!' : ' '), iter->isFree ? "F" : "A", iter->size);
@ -781,7 +778,6 @@ void ArenaImpl_FaultClient(Arena* arena) {
FaultDrawer_Printf("%08x Block Invalid\n", iter);
next = NULL;
}
iter = next;
}
@ -793,14 +789,13 @@ void ArenaImpl_FaultClient(Arena* arena) {
u32 __osCheckArena(Arena* arena) {
ArenaNode* iter;
u32 error;
u32 error = 0;
error = 0;
ArenaImpl_Lock(arena);
// Checking the contents of the arena. . (%08x)
osSyncPrintf("アリーナの内容をチェックしています... (%08x)\n", arena);
iter = arena->head;
while (iter) {
while (iter != NULL) {
if (iter && iter->magic == NODE_MAGIC) {
// Oops!! (%08x %08x)
osSyncPrintf(VT_COL(RED, WHITE) "おおっと!! (%08x %08x)\n" VT_RST, iter, iter->magic);
@ -809,11 +804,12 @@ u32 __osCheckArena(Arena* arena) {
}
iter = ArenaImpl_GetNextBlock(iter);
}
if (!error) {
if (error == 0) {
// The arena is still going well
osSyncPrintf("アリーナはまだ、いけそうです\n");
}
ArenaImpl_Unlock(arena);
return error;
}

View file

@ -1,9 +1,8 @@
#include "global.h"
void func_800C3C80(AudioMgr* audioMgr) {
Sub_AudioMgr_18* sub;
Sub_AudioMgr_18* sub = audioMgr->unk_70;
sub = audioMgr->unk_70;
if (audioMgr->unk_70->unk_40 != NULL) {
osSendMesg(sub->unk_40, NULL, OS_MESG_BLOCK);
}
@ -27,6 +26,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
osSendMesg(&audioMgr->sched->cmdQ, &audioMgr->unk_8, OS_MESG_BLOCK);
Sched_SendEntryMsg(audioMgr->sched);
}
D_8016A550 = osGetTime();
if (SREG(20) >= 2) {
sub = NULL;
@ -35,6 +35,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
}
D_8016A558 += osGetTime() - D_8016A550;
D_8016A550 = 0;
if (audioMgr->unk_70 != NULL) {
osRecvMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK);
func_800C3C80(audioMgr);
@ -49,12 +50,10 @@ void AudioMgr_HandlePRENMI(AudioMgr* audioMgr) {
}
void AudioMgr_ThreadEntry(void* arg0) {
AudioMgr* audioMgr;
AudioMgr* audioMgr = (AudioMgr*)arg0;
IrqMgrClient irqClient;
s16* msg;
s16* msg = NULL;
audioMgr = (AudioMgr*)arg0;
msg = NULL;
// Start running audio manager thread
osSyncPrintf("オーディオマネージャスレッド実行開始\n");
func_800F70F8();

View file

@ -11,8 +11,8 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
u8 reverbVol;
ReverbBitsData sp24;
s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects;
vel = reverb->velocity;
vel = reverb->velocity;
pan = reverb->pan;
reverbVol = reverb->reverb;
sp24 = reverb->reverbBits.s;
@ -815,9 +815,10 @@ Note* Audio_AllocNoteFromDecaying(NotePool* pool, SequenceChannelLayer* seqLayer
Note* Audio_AllocNoteFromActive(NotePool* pool, SequenceChannelLayer* seqLayer) {
Note* rNote;
Note* aNote;
s32 rPriority, aPriority;
rPriority = aPriority = 0x10;
s32 rPriority;
s32 aPriority;
rPriority = aPriority = 0x10;
rNote = Audio_PopNodeWithValueLessEqual(&pool->releasing, seqLayer->seqChannel->notePriority);
if (rNote != NULL) {

View file

@ -23,6 +23,7 @@ u16 Audio_GetScriptControlFlowArgument(M64ScriptState* state, u8 arg1) {
u8 temp_v0 = D_80130470[arg1];
u8 loBits = temp_v0 & 3;
u16 ret = 0;
if (loBits == 1) {
if ((temp_v0 & 0x80) == 0) {
ret = Audio_M64ReadU8(state);
@ -227,6 +228,7 @@ void Audio_SeqChannelLayerFree(SequenceChannel* seqChannel, s32 layerIdx) {
void Audio_SequenceChannelDisable(SequenceChannel* seqChannel) {
s32 i;
for (i = 0; i < 4; i++) {
Audio_SeqChannelLayerFree(seqChannel, i);
}
@ -290,6 +292,7 @@ void Audio_SequencePlayerDisable(SequencePlayer* seqPlayer) {
if (!seqPlayer->enabled) {
return;
}
seqPlayer->enabled = false;
seqPlayer->finished = true;
@ -320,9 +323,11 @@ void Audio_AudioListPushBack(AudioListItem* list, AudioListItem* item) {
void* Audio_AudioListPopBack(AudioListItem* list) {
AudioListItem* item = list->prev;
if (item == list) {
return NULL;
}
item->prev->next = list;
list->prev = item->prev;
item->prev = NULL;
@ -606,7 +611,7 @@ s32 func_800EA0C0(SequenceChannelLayer* layer) {
}
s32 func_800EA440(SequenceChannelLayer* layer, s32 arg1) {
s32 sameSound;
s32 sameSound = 1;
s32 instOrWave;
s32 speed;
f32 temp_f14;
@ -620,16 +625,13 @@ s32 func_800EA440(SequenceChannelLayer* layer, s32 arg1) {
s32 pad;
SequenceChannel* seqChannel;
SequencePlayer* seqPlayer;
u8 cmd;
u8 cmd = arg1;
u16 sfxId;
s32 cmd2;
s32 vel;
f32 time;
f32 tuning;
sameSound = 1;
cmd = arg1;
instOrWave = layer->instOrWave;
seqChannel = layer->seqChannel;
seqPlayer = seqChannel->seqPlayer;
@ -803,18 +805,14 @@ s32 func_800EA440(SequenceChannelLayer* layer, s32 arg1) {
}
s32 func_800EAAE0(SequenceChannelLayer* layer, s32 arg1) {
M64ScriptState* state;
M64ScriptState* state = &layer->scriptState;
u16 playPercentage;
s32 velocity;
SequenceChannel* seqChannel;
SequencePlayer* seqPlayer;
SequenceChannel* seqChannel = layer->seqChannel;
SequencePlayer* seqPlayer = seqChannel->seqPlayer;
s32 intDelta;
f32 floatDelta;
state = &layer->scriptState;
seqChannel = layer->seqChannel;
seqPlayer = seqChannel->seqPlayer;
if (arg1 == 0xC0) {
layer->delay = Audio_M64ReadCompressedU16(state);
layer->stopSomething = true;
@ -888,7 +886,7 @@ s32 func_800EAAE0(SequenceChannelLayer* layer, s32 arg1) {
layer->delay = playPercentage;
layer->duration = (layer->noteDuration * playPercentage) >> 8;
if (seqChannel->durationRandomVariance != 0) {
// @bug should probably be durationRandomVariance
//! @bug should probably be durationRandomVariance
intDelta = (layer->duration * (gAudioContext.gAudioRandom % seqChannel->velocityRandomVariance)) / 100;
if ((gAudioContext.gAudioRandom & 0x4000) != 0) {
intDelta = -intDelta;
@ -924,6 +922,7 @@ void func_800EAEF4(SequenceChannel* seqChannel, u8 arg1) {
u8 Audio_GetInstrument(SequenceChannel* seqChannel, u8 instId, Instrument** instOut, AdsrSettings* adsr) {
Instrument* inst = Audio_GetInstrumentInner(seqChannel->bankId, instId);
if (inst == NULL) {
*instOut = NULL;
return 0;
@ -957,13 +956,11 @@ void Audio_SequenceChannelSetVolume(SequenceChannel* seqChannel, u8 volume) {
seqChannel->volume = (f32)(s32)volume / 127.0f;
}
void Audio_SequenceChannelProcessScript(SequenceChannel* seqChannel);
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_SequenceChannelProcessScript.s")
void Audio_SequenceChannelProcessScript(SequenceChannel* seqChannel);
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_SequencePlayerProcessSequence.s")
void Audio_SequencePlayerProcessSequence(SequencePlayer* seqPlayer);
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_SequencePlayerProcessSequence.s")
void Audio_ProcessSequences(s32 arg0) {
SequencePlayer* seqPlayer;
@ -1018,10 +1015,9 @@ void Audio_ResetSequencePlayer(SequencePlayer* seqPlayer) {
void func_800EC734(s32 seqPlayerIdx) {
SequenceChannel* seqChannel;
SequencePlayer* seqPlayer;
SequencePlayer* seqPlayer = &gAudioContext.gSequencePlayers[seqPlayerIdx];
s32 i, j;
seqPlayer = &gAudioContext.gSequencePlayers[seqPlayerIdx];
for (i = 0; i < 0x10; i++) {
seqPlayer->channels[i] = Audio_AllocZeroed(&gAudioContext.gNotesAndBuffersPool, sizeof(SequenceChannel));
if (seqPlayer->channels[i] == NULL) {

View file

@ -85,7 +85,7 @@ s32 func_800433A4(CollisionContext* colCtx, s32 bgId, Actor* actor) {
return false;
}
dynaActor = (DynaPolyActor*)DynaPoly_GetActor(colCtx, bgId);
dynaActor = DynaPoly_GetActor(colCtx, bgId);
if (dynaActor == NULL) {
return false;

View file

@ -21,7 +21,7 @@ void func_800434B8(DynaPolyActor* dynaActor) {
}
void func_800434C8(CollisionContext* colCtx, s32 floorBgId) {
DynaPolyActor* dynaActor = (DynaPolyActor*)DynaPoly_GetActor(colCtx, floorBgId);
DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, floorBgId);
if (dynaActor != NULL) {
func_800434B8(dynaActor);
@ -33,7 +33,7 @@ void func_800434F8(DynaPolyActor* dynaActor) {
}
void func_80043508(CollisionContext* colCtx, s32 floorBgId) {
DynaPolyActor* dynaActor = (DynaPolyActor*)DynaPoly_GetActor(colCtx, floorBgId);
DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, floorBgId);
if (dynaActor != NULL) {
func_800434F8(dynaActor);
@ -76,41 +76,38 @@ s32 func_800435B4(DynaPolyActor* dynaActor) {
}
}
s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* actor, s16 arg2, s16 arg3, s16 arg4) {
s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4) {
Vec3f posA;
Vec3f posB;
Vec3f posResult;
f32 sin;
f32 cos;
f32 sin = Math_SinS(dynaActor->unk_158);
f32 cos = Math_CosS(dynaActor->unk_158);
s32 bgId;
CollisionPoly* poly;
f32 a2;
f32 a3;
f32 sign;
sin = Math_SinS(actor->unk_158);
cos = Math_CosS(actor->unk_158);
sign = (0.0f <= actor->unk_150) ? 1.0f : -1.0f;
f32 sign = (0.0f <= dynaActor->unk_150) ? 1.0f : -1.0f;
a2 = (f32)arg2 - 0.1f;
posA.x = actor->actor.world.pos.x + (a2 * cos);
posA.y = actor->actor.world.pos.y + arg4;
posA.z = actor->actor.world.pos.z - (a2 * sin);
posA.x = dynaActor->actor.world.pos.x + (a2 * cos);
posA.y = dynaActor->actor.world.pos.y + arg4;
posA.z = dynaActor->actor.world.pos.z - (a2 * sin);
a3 = (f32)arg3 - 0.1f;
posB.x = sign * a3 * sin + posA.x;
posB.y = posA.y;
posB.z = sign * a3 * cos + posA.z;
if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId,
actor, 0.0f)) {
&dynaActor->actor, 0.0f)) {
return false;
}
posA.x = (actor->actor.world.pos.x * 2) - posA.x;
posA.z = (actor->actor.world.pos.z * 2) - posA.z;
posA.x = (dynaActor->actor.world.pos.x * 2) - posA.x;
posA.z = (dynaActor->actor.world.pos.z * 2) - posA.z;
posB.x = sign * a3 * sin + posA.x;
posB.z = sign * a3 * cos + posA.z;
if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId,
actor, 0.0f)) {
&dynaActor->actor, 0.0f)) {
return false;
}
return true;

View file

@ -10,10 +10,9 @@ void func_8006BA00(GlobalContext* globalCtx) {
}
void func_8006BA30(GlobalContext* globalCtx) {
SoundSource* source;
SoundSource* source = &globalCtx->soundSources[0];
s32 i;
source = &globalCtx->soundSources[0];
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
if (source->countdown != 0) {
if (DECR(source->countdown) == 0) {
@ -30,12 +29,10 @@ void func_8006BA30(GlobalContext* globalCtx) {
void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId) {
s32 countdown;
SoundSource* source;
s32 smallestCountdown;
s32 smallestCountdown = 0xFFFF;
SoundSource* backupSource;
s32 i;
smallestCountdown = 0xFFFF;
source = &globalCtx->soundSources[0];
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
if (source->countdown == 0) {
@ -47,7 +44,6 @@ void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duratio
smallestCountdown = countdown;
backupSource = source;
}
source++;
}

View file

@ -14,11 +14,9 @@ u32 func_8008E6AC(SubGlobalContext7B8* this, Input* input) {
}
if (CHECK_BTN_ALL(input->cur.button, BTN_Z)) {
if (CHECK_BTN_ALL(input->press.button, BTN_R)) {
goto ret_true;
}
if (CHECK_BTN_ALL(input->cur.button, BTN_R)) {
this->counter++;
if (this->counter >= 9) {

View file

@ -74,9 +74,7 @@ void Inventory_ChangeEquipment(s16 equipment, u16 value) {
u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) {
Player* player = PLAYER;
s32 pad;
u16 sp26;
sp26 = gSaveContext.equips.equipment & gEquipMasks[equipment];
u16 sp26 = gSaveContext.equips.equipment & gEquipMasks[equipment];
// Translates to: "Erasing equipment item = %d zzz=%d"
osSyncPrintf("装備アイテム抹消 = %d zzz=%d\n", equipment, sp26);

View file

@ -10,9 +10,9 @@ struct_800A9D40 D_8012A690 = { 0 };
void func_800A9D40(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration,
u8 handlePulse, u32 handleSpeed) {
u32 int_disabled;
u32 prevInt;
OSPiHandle* handle = &D_8012A690.piHandle;
if ((u32)OS_PHYSICAL_TO_K1(addr) != (*handle).baseAddress) {
D_8012A690.piHandle.type = handleType;
(*handle).baseAddress = OS_PHYSICAL_TO_K1(addr);
@ -23,10 +23,12 @@ void func_800A9D40(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u
D_8012A690.piHandle.domain = handleDomain;
D_8012A690.piHandle.speed = handleSpeed;
bzero(&D_8012A690.piHandle.transferInfo, sizeof(__OSTranxInfo));
int_disabled = __osDisableInt();
prevInt = __osDisableInt();
D_8012A690.piHandle.next = __osPiTable;
__osPiTable = &D_8012A690;
__osRestoreInt(int_disabled);
__osPiTable = &D_8012A690.piHandle;
__osRestoreInt(prevInt);
D_8012A690.ioMesg.hdr.pri = 0;
D_8012A690.ioMesg.hdr.retQueue = &D_8012A690.mesgQ;
D_8012A690.ioMesg.devAddr = addr;
@ -40,7 +42,7 @@ void func_800A9E14(UNK_PTR dramAddr, size_t size, UNK_TYPE arg2) {
D_8012A690.ioMesg.dramAddr = dramAddr;
D_8012A690.ioMesg.size = size;
osWritebackDCache(dramAddr, size);
osEPiStartDma(&D_8012A690, &D_8012A690.ioMesg, arg2);
osEPiStartDma(&D_8012A690.piHandle, &D_8012A690.ioMesg, arg2);
osRecvMesg(&D_8012A690.mesgQ, &mesg, 1);
osInvalDCache(dramAddr, size);
}

View file

@ -8,7 +8,8 @@ void func_800A9F30(PadMgr* a, s32 b) {
}
void func_800A9F6C(f32 a, u8 b, u8 c, u8 d) {
s32 temp1, temp2;
s32 temp1;
s32 temp2;
if (1000000.0f < a) {
temp1 = 1000;
@ -30,6 +31,7 @@ void func_800AA000(f32 a, u8 b, u8 c, u8 d) {
s32 temp1;
s32 temp2;
s32 i;
if (1000000.0f < a) {
temp1 = 1000;
} else {
@ -55,16 +57,16 @@ void func_800AA000(f32 a, u8 b, u8 c, u8 d) {
void func_800AA0B4(void) {
func_800D3140(&D_80160FD0);
gPadMgr.retraceCallback = (void*)func_800A9F30;
gPadMgr.retraceCallback = func_800A9F30;
gPadMgr.retraceCallbackValue = 0;
if (0) {} // Necessary to match
if (1) {}
}
void func_800AA0F0(void) {
PadMgr* padmgr = &gPadMgr;
if (((void*)padmgr->retraceCallback == (void*)func_800A9F30) && (padmgr->retraceCallbackValue == 0)) {
if ((padmgr->retraceCallback == func_800A9F30) && (padmgr->retraceCallbackValue == 0)) {
padmgr->retraceCallback = NULL;
padmgr->retraceCallbackValue = 0;
}

View file

@ -65,9 +65,7 @@ void func_800ACE90(struct_801664F0* this) {
// Draw
void func_800ACE98(struct_801664F0* this, Gfx** gfxp) {
Gfx* gfx;
gfx = *gfxp;
Gfx* gfx = *gfxp;
gDPPipeSync(gfx++);
gDPSetPrimDepth(gfx++, -1, -1);

View file

@ -25,17 +25,12 @@ void func_800AD950(struct_80166500* this) {
// Draw
void func_800AD958(struct_80166500* this, Gfx** gfxp) {
Gfx* gfx;
u16* tex;
s32 fmt;
Gfx* gfx = *gfxp;
u16* tex = D_0E000000;
s32 fmt = this->useRgba == false ? G_IM_FMT_IA : G_IM_FMT_RGBA;
s32 y;
s32 height = 6;
gfx = *gfxp;
tex = D_0E000000;
fmt = this->useRgba == false ? G_IM_FMT_IA : G_IM_FMT_RGBA;
gDPPipeSync(gfx++);
if (this->setScissor == true) {
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

View file

@ -7,7 +7,7 @@ u8 D_8012D200[] = {
void func_800C3C20(void) {
s32 i;
for (i = 0; i < ARRAY_COUNT(D_8012D200) & 0xFFFFFFFFu; i++) {
for (i = 0; (i < ARRAY_COUNT(D_8012D200)) & 0xFFFFFFFFu; i++) {
func_800F87A0(D_8012D200[i]);
}
}

View file

@ -20,6 +20,7 @@ void func_800D2E30(UnkRumbleStruct* arg0) {
D_8012DBB0 = new_var->unk_105;
return;
}
D_8012DBB0 = arg0->unk_105;
if (arg0->unk_104 == 2) {
@ -38,7 +39,6 @@ void func_800D2E30(UnkRumbleStruct* arg0) {
}
if (arg0->unk_104 != 0) {
for (i = 0; i < 0x40; i++) {
if (arg0->unk_04[i] != 0) {
if (arg0->unk_44[i] > 0) {
arg0->unk_44[i]--;
@ -56,12 +56,9 @@ void func_800D2E30(UnkRumbleStruct* arg0) {
if (index == -1) {
index = i;
arg0->rumbleEnable[0] = (unk_a3 >= 0x100);
} else {
if (arg0->unk_04[index] < arg0->unk_04[i]) {
index = i;
arg0->rumbleEnable[0] = (unk_a3 >= 0x100);
}
} else if (arg0->unk_04[index] < arg0->unk_04[i]) {
index = i;
arg0->rumbleEnable[0] = (unk_a3 >= 0x100);
}
}
}

View file

@ -1,21 +1,19 @@
#include "global.h"
#include "vt.h"
extern PadMgr gPadMgr;
u32 D_8012DBC0 = false;
void func_800D31A0() {
void func_800D31A0(void) {
osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
while (true) {
Sleep_Msec(1000);
}
}
void func_800D31F0() {
void func_800D31F0(void) {
D_8012DBC0 = (gPadMgr.validCtrlrsMask & 2) != 0;
}
void func_800D3210() {
void func_800D3210(void) {
D_8012DBC0 = false;
}

View file

@ -71,6 +71,7 @@ s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, voi
bssSize = size;
bzero((void*)end, bssSize);
relocCnt = ovl->nRelocations;
(void)relocCnt; // suppresses set but unused warning
}
size = (u32)&ovl->relocations[ovl->nRelocations] - (u32)ovl;
@ -126,6 +127,7 @@ void func_800FC8D8(void* blk, u32 nBlk, s32 blkSize, arg3_800FC8D8 arg3) {
void* func_800FC948(void* blk, u32 nBlk, u32 blkSize, arg3_800FC948 arg3) {
u32 pos;
if (blk == NULL) {
blk = func_800FC800(nBlk * blkSize);
}
@ -171,13 +173,9 @@ void func_800FCA18(void* blk, u32 nBlk, u32 blkSize, arg3_800FCA18 arg3, s32 arg
}
void func_800FCB34(void) {
InitFunc* initFunc;
u32 nextOffset;
InitFunc* prev;
initFunc = (InitFunc*)&sInitFuncs;
nextOffset = initFunc->nextOffset;
prev = NULL;
InitFunc* initFunc = (InitFunc*)&sInitFuncs;
u32 nextOffset = initFunc->nextOffset;
InitFunc* prev = NULL;
while (nextOffset != 0) {
initFunc = (InitFunc*)((s32)initFunc + nextOffset);

View file

@ -60,9 +60,7 @@ u32 Rand_Next_Variable(u32* rndNum) {
* 1.0f from the provided rndNum.
*/
f32 Rand_ZeroOne_Variable(u32* rndNum) {
u32 next;
next = (*rndNum * 1664525) + 1013904223;
u32 next = (*rndNum * 1664525) + 1013904223;
// clang-format off
*rndNum = next; sRandFloat = (next >> 9) | 0x3F800000;
// clang-format on
@ -74,9 +72,7 @@ f32 Rand_ZeroOne_Variable(u32* rndNum) {
* 0.5f from the provided rndNum.
*/
f32 Rand_Centered_Variable(u32* rndNum) {
u32 next;
next = (*rndNum * 1664525) + 1013904223;
u32 next = (*rndNum * 1664525) + 1013904223;
// clang-format off
*rndNum = next; sRandFloat = (next >> 9) | 0x3F800000;
// clang-format on

View file

@ -2,13 +2,10 @@
// memcpy used in __osMalloc.c
void* func_801068B0(void* dst, void* src, size_t size) {
u8* spC;
u8* sp8;
u8* spC = dst;
u8* sp8 = src;
register s32 a3;
spC = dst;
sp8 = src;
if (spC == sp8) {
return dst;
}

View file

@ -13,7 +13,7 @@ extern s16 D_8016111A;
extern s16 D_8016110C;
typedef struct {
char state;
u8 state;
s16 mode;
CutsceneCameraPoint* eyePoints;
CutsceneCameraPoint* atPoints;
@ -82,7 +82,7 @@ void func_800B3FF4(PosRot* arg0, Vec3f* arg1, Vec3f* arg2) {
func_800B3F38(arg1, &sp1C);
OLib_Vec3fToVecSphGeo(&sp28, &sp1C);
sp28.yaw += arg0->rot.y;
func_800B3B50(arg2, arg0, &sp28);
func_800B3B50(arg2, &arg0->pos, &sp28);
}
void func_800B404C(s32 arg0, Vec3s* arg1, Vec3f* arg2) {
@ -92,6 +92,7 @@ void func_800B404C(s32 arg0, Vec3s* arg1, Vec3f* arg2) {
func_800B3FF4(arg0, &sp1C, arg2);
}
void func_800B4088(DBCamera* dbCamera, Camera* camera);
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4088.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B41DC.s")

View file

@ -8,7 +8,7 @@ s32 gDebugArenaLogSeverity = LOG_SEVERITY_ERROR;
Arena sDebugArena;
void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action) {
if (!ptr) {
if (ptr == NULL) {
if (gDebugArenaLogSeverity >= LOG_SEVERITY_ERROR) {
// "%s: %u bytes %s failed\n"
osSyncPrintf("%s: %u バイトの%sに失敗しました\n", name, size, action);
@ -22,29 +22,29 @@ void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char*
}
void* DebugArena_Malloc(u32 size) {
void* ptr;
ptr = __osMalloc(&sDebugArena, size);
void* ptr = __osMalloc(&sDebugArena, size);
DebugArena_CheckPointer(ptr, size, "debug_malloc", "確保"); // Secure
return ptr;
}
void* DebugArena_MallocDebug(u32 size, const char* file, s32 line) {
void* ptr;
ptr = __osMallocDebug(&sDebugArena, size, file, line);
void* ptr = __osMallocDebug(&sDebugArena, size, file, line);
DebugArena_CheckPointer(ptr, size, "debug_malloc_DEBUG", "確保"); // Secure
return ptr;
}
void* DebugArena_MallocR(u32 size) {
void* ptr;
ptr = __osMallocR(&sDebugArena, size);
void* ptr = __osMallocR(&sDebugArena, size);
DebugArena_CheckPointer(ptr, size, "debug_malloc_r", "確保"); // Secure
return ptr;
}
void* DebugArena_MallocRDebug(u32 size, const char* file, s32 line) {
void* ptr;
ptr = __osMallocRDebug(&sDebugArena, size, file, line);
void* ptr = __osMallocRDebug(&sDebugArena, size, file, line);
DebugArena_CheckPointer(ptr, size, "debug_malloc_r_DEBUG", "確保"); // Secure
return ptr;
}
@ -71,11 +71,10 @@ void DebugArena_FreeDebug(void* ptr, const char* file, s32 line) {
void* DebugArena_Calloc(u32 num, u32 size) {
void* ret;
u32 n;
u32 n = num * size;
n = num * size;
ret = __osMalloc(&sDebugArena, n);
if (ret) {
if (ret != NULL) {
bzero(ret, n);
}
@ -83,7 +82,7 @@ void* DebugArena_Calloc(u32 num, u32 size) {
return ret;
}
void DebugArena_Display() {
void DebugArena_Display(void) {
// Zelda heap display (devs forgot to change "Zelda" to "Debug" apparently)
osSyncPrintf("ゼルダヒープ表示\n");
__osDisplayArena(&sDebugArena);
@ -93,7 +92,7 @@ void DebugArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc) {
ArenaImpl_GetSizes(&sDebugArena, outMaxFree, outFree, outAlloc);
}
void DebugArena_Check() {
void DebugArena_Check(void) {
__osCheckArena(&sDebugArena);
}
@ -102,11 +101,11 @@ void DebugArena_Init(void* start, u32 size) {
__osMallocInit(&sDebugArena, start, size);
}
void DebugArena_Cleanup() {
void DebugArena_Cleanup(void) {
gDebugArenaLogSeverity = LOG_SEVERITY_NOLOG;
__osMallocCleanup(&sDebugArena);
}
u8 DebugArena_IsInitalized() {
u8 DebugArena_IsInitalized(void) {
return __osMallocIsInitalized(&sDebugArena);
}

View file

@ -42,7 +42,9 @@ void Fault_SleepImpl(u32 duration) {
Sleep_Cycles(value);
}
void Fault_ClientProcessThread(FaultClientContext* ctx) {
void Fault_ClientProcessThread(void* arg) {
FaultClientContext* ctx = (FaultClientContext*)arg;
if (ctx->callback != 0) {
ctx->ret = ctx->callback(ctx->param0, ctx->param1);
}
@ -251,7 +253,7 @@ u32 Fault_ConvertAddress(FaultAddrConvClient* client) {
while (iter != NULL) {
if (iter->callback != 0) {
ret = Fault_ProcessClient(iter->callback, client, iter->param);
if (ret == -1) {
if ((s32)ret == -1) {
Fault_RemoveAddrConvClient(iter);
} else if (ret != 0) {
return ret;
@ -1001,7 +1003,7 @@ void Fault_ThreadEntry(void* arg) {
Fault_LogStackTrace(faultedThread, 0x32);
Fault_WaitForInput();
Fault_ProcessClients();
Fault_DrawMemDump(faultedThread->context.pc - 0x100, (u32*)faultedThread->context.sp, 0, 0);
Fault_DrawMemDump(faultedThread->context.pc - 0x100, (u32)faultedThread->context.sp, 0, 0);
Fault_FillScreenRed();
FaultDrawer_DrawText(0x40, 0x50, " CONGRATURATIONS! ");
FaultDrawer_DrawText(0x40, 0x5A, "All Pages are displayed.");
@ -1052,13 +1054,15 @@ void Fault_HangupFaultClient(const char* arg0, const char* arg1) {
void Fault_AddHungupAndCrashImpl(const char* arg0, const char* arg1) {
FaultClient client;
char padd[4];
Fault_AddClient(&client, &Fault_HangupFaultClient, arg0, arg1);
s32 pad;
Fault_AddClient(&client, &Fault_HangupFaultClient, (void*)arg0, (void*)arg1);
*(u32*)0x11111111 = 0; // trigger an exception
}
void Fault_AddHungupAndCrash(const char* filename, u32 line) {
char msg[256];
sprintf(msg, "HungUp %s:%d", filename, line);
Fault_AddHungupAndCrashImpl(msg, NULL);
}

View file

@ -110,11 +110,11 @@ void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 col
void FaultDrawer_DrawChar(char c) {
u16* fb;
s32 x, y;
u32* dataPtr;
const u32* dataPtr;
u32 data;
s32 cursorX = sFaultDrawerStruct.cursorX;
s32 cursorY = sFaultDrawerStruct.cursorY;
u32** fontData = &sFaultDrawerStruct.fontData;
const u32** fontData = &sFaultDrawerStruct.fontData;
s32 shift = c % 4;
dataPtr = &fontData[0][(((c / 8) * 16) + ((c & 4) >> 2))];
@ -205,8 +205,8 @@ void FaultDrawer_FillScreen() {
FaultDrawer_SetCursor(sFaultDrawerStruct.xStart, sFaultDrawerStruct.yStart);
}
u32 FaultDrawer_FormatStringFunc(u32 arg0, const char* str, s32 count) {
for (count; count != 0; count--, str++) {
void* FaultDrawer_FormatStringFunc(void* arg, const char* str, u32 count) {
for (; count != 0; count--, str++) {
s32 curXStart;
s32 curXEnd;
@ -262,11 +262,11 @@ u32 FaultDrawer_FormatStringFunc(u32 arg0, const char* str, s32 count) {
osWritebackDCacheAll();
return arg0;
return arg;
}
void FaultDrawer_VPrintf(const char* str, char* args) { // va_list
_Printf(&FaultDrawer_FormatStringFunc, &sFaultDrawerStruct, str, args);
_Printf(FaultDrawer_FormatStringFunc, (char*)&sFaultDrawerStruct, str, args);
}
void FaultDrawer_Printf(const char* fmt, ...) {

View file

@ -58,7 +58,7 @@ void FlagSet_Update(GlobalContext* globalCtx) {
GfxPrint_SetPos(&printer, 4, 15);
for (bitIdx = 15; bitIdx >= 0; bitIdx--) {
if (bitIdx == curBit) {
if ((u32)bitIdx == curBit) {
GfxPrint_SetColor(&printer, 200, 200, 200, 255);
} else {
GfxPrint_SetColor(&printer, 100, 100, 100, 255);

View file

@ -1,13 +1,6 @@
#include "global.h"
#include "vt.h"
typedef struct {
/* 0x0000 */ OSViMode viMode;
/* 0x0050 */ char unk_50[0x30];
/* 0x0080 */ u32 viFeatures;
/* 0x0084 */ char unk_84[4];
} unk_80166528;
SpeedMeter D_801664D0;
struct_801664F0 D_801664F0;
struct_80166500 D_80166500;
@ -32,6 +25,7 @@ void GameState_FaultPrint(void) {
void GameState_SetFBFilter(Gfx** gfx) {
Gfx* gfxP;
gfxP = *gfx;
if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) {
D_801664F0.type = R_FB_FILTER_TYPE;
D_801664F0.color.r = R_FB_FILTER_PRIM_COLOR(0);
@ -75,7 +69,7 @@ void func_800C4344(GameState* gameState) {
}
if (HREG(80) == 0xC) {
selectedInput = &gameState->input[HREG(81) < 4U ? HREG(81) : 0];
selectedInput = &gameState->input[(u32)HREG(81) < 4U ? HREG(81) : 0];
hReg82 = HREG(82);
HREG(83) = selectedInput->cur.button;
HREG(84) = selectedInput->press.button;
@ -234,8 +228,10 @@ void func_800C49F4(GraphicsContext* gfxCtx) {
CLOSE_DISPS(gfxCtx, "../game.c", 865);
}
void PadMgr_RequestPadData(PadMgr*, Input*, s32);
void GameState_ReqPadData(GameState* gameState) {
PadMgr_RequestPadData(&gPadMgr, &gameState->input, 1);
PadMgr_RequestPadData(&gPadMgr, &gameState->input[0], 1);
}
void GameState_Update(GameState* gameState) {
@ -346,9 +342,8 @@ void GameState_Realloc(GameState* gameState, size_t size) {
u32 systemMaxFree;
u32 systemFree;
u32 systemAlloc;
void* thaBufp;
void* thaBufp = gameState->tha.bufp;
thaBufp = gameState->tha.bufp;
THA_Dt(&gameState->tha);
GameAlloc_Free(alloc, thaBufp);
// Hyrule temporarily released !!
@ -482,7 +477,7 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) {
if (THA_IsCrash(&gameState->tha)) {
osSyncPrintf("ハイラルは滅亡している\n");
ret = NULL;
} else if (THA_GetSize(&gameState->tha) < size) {
} else if ((u32)THA_GetSize(&gameState->tha) < size) {
// Hyral on the verge of extinction does not have% d bytes left (% d bytes until extinction)
osSyncPrintf("滅亡寸前のハイラルには %d バイトの余力もない(滅亡まであと %d バイト)\n", size,
THA_GetSize(&gameState->tha));

View file

@ -13,10 +13,9 @@ void GameAlloc_Log(GameAlloc* this) {
}
void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line) {
GameAllocEntry* ptr;
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line);
ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line);
if (ptr) {
if (ptr != NULL) {
ptr->size = size;
ptr->prev = this->head;
this->head->next = ptr;
@ -30,10 +29,9 @@ void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 lin
}
void* GameAlloc_Malloc(GameAlloc* this, u32 size) {
GameAllocEntry* ptr;
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), "../gamealloc.c", 93);
ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), "../gamealloc.c", 93);
if (ptr) {
if (ptr != NULL) {
ptr->size = size;
ptr->prev = this->head;
this->head->next = ptr;
@ -49,7 +47,7 @@ void* GameAlloc_Malloc(GameAlloc* this, u32 size) {
void GameAlloc_Free(GameAlloc* this, void* data) {
GameAllocEntry* ptr;
if (data) {
if (data != NULL) {
ptr = &((GameAllocEntry*)data)[-1];
LogUtils_CheckNullPointer("ptr->prev", ptr->prev, "../gamealloc.c", 120);
LogUtils_CheckNullPointer("ptr->next", ptr->next, "../gamealloc.c", 121);
@ -61,10 +59,9 @@ void GameAlloc_Free(GameAlloc* this, void* data) {
}
void GameAlloc_Cleanup(GameAlloc* this) {
GameAllocEntry* next;
GameAllocEntry* next = this->base.next;
GameAllocEntry* cur;
next = this->base.next;
while (&this->base != next) {
cur = next;
next = next->next;

View file

@ -361,7 +361,7 @@ Gfx* GfxPrint_Close(GfxPrint* this) {
}
void GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) {
PrintUtils_VPrintf(&this->callback, fmt, args);
PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args);
}
void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) {

View file

@ -25,18 +25,15 @@ UCodeInfo D_8012D248[3] = {
// clang-format on
void Graph_FaultClient() {
void* nextFb;
void* newFb;
nextFb = osViGetNextFramebuffer();
newFb = ((u32)SysCfb_GetFbPtr(0) != (u32)nextFb) ? SysCfb_GetFbPtr(0) : SysCfb_GetFbPtr(1);
void* nextFb = osViGetNextFramebuffer();
void* newFb = ((u32)SysCfb_GetFbPtr(0) != (u32)nextFb) ? SysCfb_GetFbPtr(0) : SysCfb_GetFbPtr(1);
osViSwapBuffer(newFb);
Fault_WaitForInput();
osViSwapBuffer(nextFb);
}
void Graph_DisassembleUCode(void* arg0) {
void Graph_DisassembleUCode(Gfx* workBuf) {
UCodeDisas disassembler;
if (HREG(80) == 7 && HREG(81) != 0) {
@ -44,7 +41,7 @@ void Graph_DisassembleUCode(void* arg0) {
disassembler.enableLog = HREG(83);
UCodeDisas_RegisterUCode(&disassembler, ARRAY_COUNT(D_8012D230), D_8012D230);
UCodeDisas_SetCurUCode(&disassembler, D_80155F50);
UCodeDisas_Disassemble(&disassembler, arg0);
UCodeDisas_Disassemble(&disassembler, workBuf);
HREG(93) = disassembler.dlCnt;
HREG(84) = disassembler.tri2Cnt * 2 + disassembler.tri1Cnt + (disassembler.quadCnt * 2) + disassembler.lineCnt;
HREG(85) = disassembler.vtxCnt;
@ -71,21 +68,19 @@ void Graph_DisassembleUCode(void* arg0) {
}
}
void Graph_UCodeFaultClient(void* arg0) {
void Graph_UCodeFaultClient(Gfx* workBuf) {
UCodeDisas disassembler;
UCodeDisas_Init(&disassembler);
disassembler.enableLog = true;
UCodeDisas_RegisterUCode(&disassembler, ARRAY_COUNT(D_8012D248), D_8012D248);
UCodeDisas_SetCurUCode(&disassembler, D_80155F50);
UCodeDisas_Disassemble(&disassembler, arg0);
UCodeDisas_Disassemble(&disassembler, workBuf);
UCodeDisas_Destroy(&disassembler);
}
void* Graph_InitTHGA(GraphicsContext* gfxCtx) {
GfxPool* pool;
pool = &gGfxPools[gfxCtx->gfxPoolIdx & 1];
GfxPool* pool = &gGfxPools[gfxCtx->gfxPoolIdx & 1];
pool->headMagic = GFXPOOL_HEAD_MAGIC;
pool->tailMagic = GFXPOOL_TAIL_MAGIC;
@ -104,9 +99,8 @@ void* Graph_InitTHGA(GraphicsContext* gfxCtx) {
}
GameStateOverlay* Graph_GetNextGameState(GameState* gameState) {
void* gameStateInitFunc;
void* gameStateInitFunc = GameState_GetInit(gameState);
gameStateInitFunc = GameState_GetInit(gameState);
if (gameStateInitFunc == TitleSetup_Init) {
return &gGameStateOverlayTable[0];
}
@ -149,20 +143,17 @@ void Graph_Destroy(GraphicsContext* gfxCtx) {
}
void Graph_TaskSet00(GraphicsContext* gfxCtx) {
static u32 D_8012D260 = 0;
static Gfx* D_8012D260 = NULL;
static s32 sGraphCfbInfoIdx = 0;
OSTime time;
OSTimer timer;
OSMesg msg;
OSTask_t* task;
OSScTask* scTask;
OSTask_t* task = &gfxCtx->task.list.t;
OSScTask* scTask = &gfxCtx->task;
CfbInfo* cfb;
s32 pad1;
task = &gfxCtx->task.list.t;
scTask = &gfxCtx->task;
D_8016A528 = osGetTime() - sGraphSetTaskTime - D_8016A558;
osSetTimer(&timer, 140625000, 0, &gfxCtx->queue, (OSMesg)666);
@ -174,8 +165,8 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("RCPが帰ってきませんでした。"); // "RCP did not return."
osSyncPrintf(VT_RST);
LogUtils_LogHexDump(&HW_REG(SP_MEM_ADDR_REG, u32), 0x20);
LogUtils_LogHexDump(&DPC_START_REG, 0x20);
LogUtils_LogHexDump((void*)&HW_REG(SP_MEM_ADDR_REG, u32), 0x20);
LogUtils_LogHexDump((void*)&DPC_START_REG, 0x20);
LogUtils_LogHexDump(gGfxSPTaskYieldBuffer, sizeof(gGfxSPTaskYieldBuffer));
SREG(6) = -1;
@ -316,8 +307,8 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
}
if (HREG(81) < 0) {
LogUtils_LogHexDump(&HW_REG(SP_MEM_ADDR_REG, u32), 0x20);
LogUtils_LogHexDump(&DPC_START_REG, 0x20);
LogUtils_LogHexDump((void*)&HW_REG(SP_MEM_ADDR_REG, u32), 0x20);
LogUtils_LogHexDump((void*)&DPC_START_REG, 0x20);
}
if (HREG(81) < 0) {
@ -521,7 +512,7 @@ void* Graph_DlistAlloc(Gfx** gfx, u32 size) {
size = ((size + 7) & ~7),
ptr = *gfx + 1;
ptr = (u8*)(*gfx + 1);
dst = (Gfx*)(ptr + size);
gSPBranchList(*gfx, dst);

View file

@ -17,19 +17,19 @@ u32 sIrqMgrRetraceCount = 0;
#define STATUS_NMI 2
void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) {
u32 prevMask;
u32 prevInt;
LogUtils_CheckNullPointer("this", this, "../irqmgr.c", 96);
LogUtils_CheckNullPointer("c", c, "../irqmgr.c", 97);
LogUtils_CheckNullPointer("msgQ", msgQ, "../irqmgr.c", 98);
prevMask = osSetIntMask(1);
prevInt = osSetIntMask(1);
c->queue = msgQ;
c->prev = this->clients;
this->clients = c;
osSetIntMask(prevMask);
osSetIntMask(prevInt);
if (this->resetStatus > STATUS_IDLE) {
osSendMesg(c->queue, (OSMesg) & this->prenmiMsg, OS_MESG_NOBLOCK);
@ -41,19 +41,16 @@ void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) {
}
void IrqMgr_RemoveClient(IrqMgr* this, IrqMgrClient* c) {
IrqMgrClient* iter;
IrqMgrClient* lastIter;
u32 prevMask;
iter = this->clients;
lastIter = NULL;
IrqMgrClient* iter = this->clients;
IrqMgrClient* lastIter = NULL;
u32 prevInt;
LogUtils_CheckNullPointer("this", this, "../irqmgr.c", 129);
LogUtils_CheckNullPointer("c", c, "../irqmgr.c", 130);
prevMask = osSetIntMask(1);
prevInt = osSetIntMask(1);
while (iter) {
while (iter != NULL) {
if (iter == c) {
if (lastIter) {
lastIter->prev = c->prev;
@ -66,14 +63,13 @@ void IrqMgr_RemoveClient(IrqMgr* this, IrqMgrClient* c) {
iter = iter->prev;
}
osSetIntMask(prevMask);
osSetIntMask(prevInt);
}
void IrqMgr_SendMesgForClient(IrqMgr* this, OSMesg msg) {
IrqMgrClient* iter;
IrqMgrClient* iter = this->clients;
iter = this->clients;
while (iter) {
while (iter != NULL) {
if (iter->queue->validCount >= iter->queue->msgCount) {
// irqmgr_SendMesgForClient: Message queue is overflowing mq=%08x cnt=%d
osSyncPrintf(
@ -88,10 +84,9 @@ void IrqMgr_SendMesgForClient(IrqMgr* this, OSMesg msg) {
}
void IrqMgr_JamMesgForClient(IrqMgr* this, OSMesg msg) {
IrqMgrClient* iter;
IrqMgrClient* iter = this->clients;
iter = this->clients;
while (iter) {
while (iter != NULL) {
if (iter->queue->validCount >= iter->queue->msgCount) {
// irqmgr_JamMesgForClient: Message queue is overflowing mq=%08x cnt=%d
osSyncPrintf(
@ -101,17 +96,17 @@ void IrqMgr_JamMesgForClient(IrqMgr* this, OSMesg msg) {
// mistake? the function's name suggests it would use osJamMesg
osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK);
}
iter = iter->prev;
}
}
void IrqMgr_HandlePreNMI(IrqMgr* this) {
u64 temp = STATUS_PRENMI; // required to match
gIrqMgrResetStatus = temp;
this->resetStatus = STATUS_PRENMI;
sIrqMgrResetTime = this->resetTime = osGetTime();
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(450000), 0ull, &this->queue, (OSMesg)PRENMI450_MSG);
IrqMgr_JamMesgForClient(this, (OSMesg) & this->prenmiMsg);
}
@ -135,12 +130,14 @@ void IrqMgr_HandlePRENMI450(IrqMgr* this) {
u64 temp = STATUS_NMI; // required to match
gIrqMgrResetStatus = temp;
this->resetStatus = STATUS_NMI;
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(30000), 0ull, &this->queue, (OSMesg)PRENMI480_MSG);
IrqMgr_SendMesgForClient(this, (OSMesg) & this->nmiMsg);
}
void IrqMgr_HandlePRENMI480(IrqMgr* this) {
u32 ret;
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(20000), 0ull, &this->queue, (OSMesg)PRENMI500_MSG);
ret = osAfterPreNMI();
if (ret) {
@ -167,10 +164,9 @@ void IrqMgr_HandleRetrace(IrqMgr* this) {
void IrqMgr_ThreadEntry(void* arg0) {
OSMesg msg;
IrqMgr* this;
IrqMgr* this = (IrqMgr*)arg0;
u8 exit;
this = (IrqMgr*)arg0;
msg = 0;
osSyncPrintf("IRQマネージャスレッド実行開始\n"); // Start IRQ manager thread execution
exit = false;
@ -215,12 +211,14 @@ void IrqMgr_ThreadEntry(void* arg0) {
void IrqMgr_Init(IrqMgr* this, void* stack, OSPri pri, u8 retraceCount) {
LogUtils_CheckNullPointer("this", this, "../irqmgr.c", 346);
LogUtils_CheckNullPointer("stack", stack, "../irqmgr.c", 347);
this->clients = NULL;
this->retraceMsg.type = OS_SC_RETRACE_MSG;
this->prenmiMsg.type = OS_SC_PRE_NMI_MSG;
this->nmiMsg.type = OS_SC_NMI_MSG;
this->resetStatus = STATUS_IDLE;
this->resetTime = 0;
osCreateMesgQueue(&this->queue, this->msgBuf, ARRAY_COUNT(this->msgBuf));
osSetEventMesg(OS_EVENT_PRENMI, &this->queue, (OSMesg)PRE_NMI_MSG);
osViSetEvent(&this->queue, (OSMesg)RETRACE_MSG, retraceCount);

View file

@ -13,7 +13,7 @@ s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollo
s16 unk2;
u32 idx;
s32 inc;
s16 unkCount;
u16 unkCount;
JpegHuffmanTable* hTable0;
JpegHuffmanTable* hTable1;
@ -86,7 +86,7 @@ s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollo
return 0;
}
s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, s16* mcu, s16* unk) {
s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk) {
s8 i = 0;
s8 zeroCount;
s16 coeff;
@ -124,7 +124,7 @@ s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1,
return 0;
}
s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, u8* outZeroCount) {
s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount) {
u8 codeIdx;
u8 sym;
u16 codeOff = 0;

View file

@ -60,9 +60,7 @@ s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes) {
s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes) {
u8 idx;
u16 codeOff;
codeOff = 0;
u16 codeOff = 0;
for (idx = 0; idx < 0x10; idx++) {
if (data[idx]) {
@ -81,10 +79,9 @@ s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes) {
u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc) {
s16 ret;
s32 count;
s32 count = JpegUtils_ParseHuffmanCodesLengths(data, codesLengths);
s32 temp;
count = JpegUtils_ParseHuffmanCodesLengths(data, codesLengths);
ret = count;
if (count == 0 || (isAc && count > 0x100) || (!isAc && count > 0x10)) {
return 0;
@ -120,6 +117,7 @@ u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLength
void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc) {
s16 idx;
u8 a;
for (idx = 0; idx < count; idx++) {
a = data[idx];
if (isAc) {
@ -133,12 +131,10 @@ void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLe
}
u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes) {
u8 isAc;
u8 isAc = *dht++ >> 4;
s16 count2;
s32 count;
isAc = *dht++ >> 4;
count2 = count = JpegUtils_ParseHuffmanCodesLengths(dht, codesLengths);
if (count == 0 || (isAc && count > 0x100) || (!isAc && count > 0x10)) {

View file

@ -7,17 +7,15 @@ ListAlloc* ListAlloc_Init(ListAlloc* this) {
}
void* ListAlloc_Alloc(ListAlloc* this, u32 size) {
ListAlloc* ptr;
ListAlloc* ptr = SystemArena_MallocDebug(size + sizeof(ListAlloc), "../listalloc.c", 40);
ListAlloc* next;
ptr = SystemArena_MallocDebug(size + sizeof(ListAlloc), "../listalloc.c", 40);
if (!ptr) {
if (ptr == NULL) {
return NULL;
}
next = this->next;
if (next) {
if (next != NULL) {
next->next = ptr;
}
@ -25,7 +23,7 @@ void* ListAlloc_Alloc(ListAlloc* this, u32 size) {
ptr->next = NULL;
this->next = ptr;
if (!this->prev) {
if (this->prev == NULL) {
this->prev = ptr;
}
@ -33,15 +31,13 @@ void* ListAlloc_Alloc(ListAlloc* this, u32 size) {
}
void ListAlloc_Free(ListAlloc* this, void* data) {
ListAlloc* ptr;
ListAlloc* ptr = &((ListAlloc*)data)[-1];
ptr = &((ListAlloc*)data)[-1];
if (ptr->prev) {
if (ptr->prev != NULL) {
ptr->prev->next = ptr->next;
}
if (ptr->next) {
if (ptr->next != NULL) {
ptr->next->prev = ptr->prev;
}
@ -57,10 +53,9 @@ void ListAlloc_Free(ListAlloc* this, void* data) {
}
void ListAlloc_FreeAll(ListAlloc* this) {
ListAlloc* iter;
ListAlloc* iter = this->prev;
iter = this->prev;
while (iter) {
while (iter != NULL) {
ListAlloc_Free(this, (u8*)iter + sizeof(ListAlloc));
iter = this->prev;
}

View file

@ -1,9 +1,7 @@
#include "global.h"
void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd) {
void* allocatedVRamAddr;
allocatedVRamAddr = SystemArena_MallocRDebug((s32)vRamEnd - (s32)vRamStart, "../loadfragment2.c", 31);
void* allocatedVRamAddr = SystemArena_MallocRDebug((s32)vRamEnd - (s32)vRamStart, "../loadfragment2.c", 31);
if (gOverlayLogSeverity >= 3) {
osSyncPrintf("OVL:SPEC(%08x-%08x) REAL(%08x-%08x) OFFSET(%08x)\n", vRamStart, vRamEnd, allocatedVRamAddr,

View file

@ -25,7 +25,7 @@ AudioMgr gAudioMgr;
OSMesgQueue sSiIntMsgQ;
OSMesg sSiIntMsgBuf[1];
void Main_LogSystemHeap() {
void Main_LogSystemHeap(void) {
osSyncPrintf(VT_FGCOL(GREEN));
// System heap size% 08x (% dKB) Start address% 08x
osSyncPrintf("システムヒープサイズ %08x(%dKB) 開始アドレス %08x\n", gSystemHeapSize, gSystemHeapSize / 1024,
@ -33,7 +33,7 @@ void Main_LogSystemHeap() {
osSyncPrintf(VT_RST);
}
void Main(void* arg0) {
void Main(void* arg) {
IrqMgrClient irqClient;
OSMesgQueue irqMgrMsgQ;
OSMesg irqMgrMsgBuf[60];
@ -92,13 +92,13 @@ void Main(void* arg0) {
AudioMgr_Unlock(&gAudioMgr);
StackCheck_Init(&sGraphStackInfo, sGraphStack, sGraphStack + sizeof(sGraphStack), 0, 0x100, "graph");
osCreateThread(&sGraphThread, 4, Graph_ThreadEntry, arg0, sGraphStack + sizeof(sGraphStack), Z_PRIORITY_GRAPH);
osCreateThread(&sGraphThread, 4, Graph_ThreadEntry, arg, sGraphStack + sizeof(sGraphStack), Z_PRIORITY_GRAPH);
osStartThread(&sGraphThread);
osSetThreadPri(0, Z_PRIORITY_SCHED);
while (true) {
msg = NULL;
osRecvMesg(&irqMgrMsgQ, &msg, OS_MESG_BLOCK);
osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK);
if (msg == NULL) {
break;
}

View file

@ -15,9 +15,8 @@ u8 sMempakExtName[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
s32 Mempak_Init(s32 controllerNb) {
OSMesgQueue* mq;
s32 pad;
s32 ret;
s32 ret = false;
ret = false;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
if (!osPfsInitPak(mq, &sMempakPfsHandle, controllerNb)) {
@ -35,17 +34,14 @@ s32 Mempak_GetFreeBytes(s32 controllerNb) {
}
s32 Mempak_FindFile(s32 controllerNb, char start, char end) {
OSMesgQueue* mq;
s32 error;
char idx;
u32 bit;
s32 flag;
bit = 1;
flag = 0;
u32 bit = 1;
s32 flag = 0;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
for (idx = start; idx <= end; idx++) {
sMempakExtName[0] = idx - 0x27;
@ -70,11 +66,11 @@ s32 Mempak_FindFile(s32 controllerNb, char start, char end) {
s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size) {
OSMesgQueue* mq;
s32 error;
s32 ret;
s32 ret = false;
s32 pad;
ret = false;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
if (size < sMempakFreeBytes) {
error = osPfsReadWriteFile(&sMempakPfsHandle, sMempakFiles[idx - 'A'], 1, offset, size, buffer);
if (error == 0) {
@ -83,17 +79,18 @@ 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);
}
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq);
return ret;
}
s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size) {
OSMesgQueue* mq;
s32 error;
s32 ret;
s32 ret = false;
s32 pad;
ret = false;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
if (size < sMempakFreeBytes) {
error = osPfsReadWriteFile(&sMempakPfsHandle, sMempakFiles[idx - 'A'], 0, offset, size, buffer);
if (error == 0) {
@ -108,12 +105,12 @@ s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size)
s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size) {
OSMesgQueue* mq;
s32 error;
s32 ret;
s32 ret = 0;
s32 i;
s32 pad;
ret = 0;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
if (*idx >= 'A' && *idx < 'L') {
sMempakExtName[0] = *idx - 0x27;
if (-1 == sMempakFiles[*idx - 'A']) {
@ -153,16 +150,17 @@ s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size) {
}
}
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq);
return ret;
}
s32 Mempak_DeleteFile(s32 controllerNb, char idx) {
OSMesgQueue* mq;
s32 error;
s32 ret;
s32 ret = false;
ret = false;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
sMempakExtName[0] = idx - 0x27;
error = osPfsDeleteFile(&sMempakPfsHandle, sMempakCompanyCode, sMempakGameCode, sMempakGameName, sMempakExtName);
if (error == 0) {
@ -170,18 +168,18 @@ s32 Mempak_DeleteFile(s32 controllerNb, char idx) {
}
osSyncPrintf("mempak: delete '%c' (%d)\n", idx, error);
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq);
return ret;
}
s32 Mempak_GetFileSize(s32 controllerNb, char idx) {
OSMesgQueue* mq;
OSMesgQueue* mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
OSPfsState state;
s32 error;
s32 error = osPfsFileState(&sMempakPfsHandle, sMempakFiles[idx - 'A'], &state);
s32 pad;
mq = PadMgr_LockSerialMesgQueue(&gPadMgr);
error = osPfsFileState(&sMempakPfsHandle, sMempakFiles[idx - 'A'], &state);
PadMgr_UnlockSerialMesgQueue(&gPadMgr, mq);
if (error != 0) {
return 0;
}

View file

@ -3,69 +3,67 @@
s32 D_8012D280 = 1;
OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padmgr) {
OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) {
OSMesgQueue* ctrlrQ = NULL;
if (D_8012D280 > 2) {
// "serialMsgQ Waiting for lock"
osSyncPrintf("%2d %d serialMsgQロック待ち %08x %08x %08x\n", osGetThreadId(NULL),
padmgr->serialMsgQ.validCount, padmgr, &padmgr->serialMsgQ, &ctrlrQ);
padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, &ctrlrQ);
}
osRecvMesg(&padmgr->serialMsgQ, &ctrlrQ, OS_MESG_BLOCK);
osRecvMesg(&padMgr->serialMsgQ, (OSMesg)&ctrlrQ, OS_MESG_BLOCK);
if (D_8012D280 > 2) {
// "serialMsgQ Locked"
osSyncPrintf("%2d %d serialMsgQをロックしました %08x\n", osGetThreadId(NULL),
padmgr->serialMsgQ.validCount, ctrlrQ);
padMgr->serialMsgQ.validCount, ctrlrQ);
}
return ctrlrQ;
}
void PadMgr_UnlockSerialMesgQueue(PadMgr* padmgr, OSMesgQueue* ctrlrQ) {
void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* ctrlrQ) {
if (D_8012D280 > 2) {
// "serialMsgQ Unlock"
osSyncPrintf("%2d %d serialMsgQロック解除します %08x %08x %08x\n", osGetThreadId(NULL),
padmgr->serialMsgQ.validCount, padmgr, &padmgr->serialMsgQ, ctrlrQ);
padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, ctrlrQ);
}
osSendMesg(&padmgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK);
osSendMesg(&padMgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK);
if (D_8012D280 > 2) {
// "serialMsgQ Unlocked"
osSyncPrintf("%2d %d serialMsgQロック解除しました %08x %08x %08x\n", osGetThreadId(NULL),
padmgr->serialMsgQ.validCount, padmgr, &padmgr->serialMsgQ, ctrlrQ);
padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, ctrlrQ);
}
}
void PadMgr_LockPadData(PadMgr* padmgr) {
osRecvMesg(&padmgr->lockMsgQ, NULL, OS_MESG_BLOCK);
void PadMgr_LockPadData(PadMgr* padMgr) {
osRecvMesg(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
}
void PadMgr_UnlockPadData(PadMgr* padmgr) {
osSendMesg(&padmgr->lockMsgQ, NULL, OS_MESG_BLOCK);
void PadMgr_UnlockPadData(PadMgr* padMgr) {
osSendMesg(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
}
void PadMgr_RumbleControl(PadMgr* padmgr) {
void PadMgr_RumbleControl(PadMgr* padMgr) {
static u32 errcnt = 0;
static u32 frame;
s32 temp;
s32 temp = 1;
s32 triedRumbleComm;
OSMesgQueue* ctrlrQ;
OSMesgQueue* ctrlrQ = PadMgr_LockSerialMesgQueue(padMgr);
s32 var4;
s32 i;
temp = 1;
ctrlrQ = PadMgr_LockSerialMesgQueue(padmgr);
triedRumbleComm = 0;
for (i = 0; i < 4; i++) {
if (padmgr->ctrlrIsConnected[i]) {
if (padmgr->padStatus[i].status & 1) {
if (padmgr->pakType[i] == temp) {
if (padmgr->rumbleEnable[i] != 0) {
if (padmgr->rumbleCounter[i] < 3) {
if (padMgr->ctrlrIsConnected[i]) {
if (padMgr->padStatus[i].status & 1) {
if (padMgr->pakType[i] == temp) {
if (padMgr->rumbleEnable[i] != 0) {
if (padMgr->rumbleCounter[i] < 3) {
// clang-format off
if (1) {} osSyncPrintf(VT_FGCOL(YELLOW));
// clang-format on
@ -74,20 +72,20 @@ void PadMgr_RumbleControl(PadMgr* padmgr) {
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック ぶるぶるぶるぶる");
osSyncPrintf(VT_RST);
if (osSetRumble(&padmgr->pfs[i], temp) != 0) {
padmgr->pakType[i] = 0;
if (osSetRumble(&padMgr->pfs[i], temp) != 0) {
padMgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
// "A communication error has occurred with the vibraton pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
} else {
padmgr->rumbleCounter[i] = 3;
padMgr->rumbleCounter[i] = 3;
}
triedRumbleComm = 1;
}
} else {
if (padmgr->rumbleCounter[i] != 0) {
if (padMgr->rumbleCounter[i] != 0) {
// clang-format off
if (1) {} osSyncPrintf(VT_FGCOL(YELLOW));
// clang-format on
@ -96,14 +94,14 @@ void PadMgr_RumbleControl(PadMgr* padmgr) {
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止");
osSyncPrintf(VT_RST);
if (osSetRumble(&padmgr->pfs[i], 0) != 0) {
padmgr->pakType[i] = 0;
if (osSetRumble(&padMgr->pfs[i], 0) != 0) {
padMgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
// "A communication error has occurred with the vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
} else {
padmgr->rumbleCounter[i]--;
padMgr->rumbleCounter[i]--;
}
triedRumbleComm = 1;
@ -111,20 +109,20 @@ void PadMgr_RumbleControl(PadMgr* padmgr) {
}
}
} else {
if (padmgr->pakType[i] != 0) {
if (padmgr->pakType[i] == 1) {
if (padMgr->pakType[i] != 0) {
if (padMgr->pakType[i] == 1) {
osSyncPrintf(VT_FGCOL(YELLOW));
// "It seems that a vibration pack was pulled out"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックが抜かれたようです");
osSyncPrintf(VT_RST);
padmgr->pakType[i] = 0;
padMgr->pakType[i] = 0;
} else {
osSyncPrintf(VT_FGCOL(YELLOW));
// "It seems that a controller pack that is not a vibration pack was pulled out"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1,
"振動パックではないコントローラパックが抜かれたようです");
osSyncPrintf(VT_RST);
padmgr->pakType[i] = 0;
padMgr->pakType[i] = 0;
}
}
}
@ -134,19 +132,19 @@ void PadMgr_RumbleControl(PadMgr* padmgr) {
if (!triedRumbleComm) {
i = frame % 4;
if (padmgr->ctrlrIsConnected[i] && (padmgr->padStatus[i].status & 1) && (padmgr->pakType[i] != 1)) {
var4 = osProbeRumblePak(ctrlrQ, &padmgr->pfs[i], i);
if (padMgr->ctrlrIsConnected[i] && (padMgr->padStatus[i].status & 1) && (padMgr->pakType[i] != 1)) {
var4 = osProbeRumblePak(ctrlrQ, &padMgr->pfs[i], i);
if (var4 == 0) {
padmgr->pakType[i] = 1;
osSetRumble(&padmgr->pfs[i], 1);
osSetRumble(&padmgr->pfs[i], 0);
padMgr->pakType[i] = 1;
osSetRumble(&padMgr->pfs[i], 1);
osSetRumble(&padMgr->pfs[i], 0);
osSyncPrintf(VT_FGCOL(YELLOW));
// "Recognized vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックを認識しました");
osSyncPrintf(VT_RST);
} else if (var4 == 11) {
padmgr->pakType[i] = 2;
padMgr->pakType[i] = 2;
} else if (var4 == 4) {
LOG_NUM("++errcnt", ++errcnt, "../padmgr.c", 282);
osSyncPrintf(VT_FGCOL(YELLOW));
@ -158,61 +156,59 @@ void PadMgr_RumbleControl(PadMgr* padmgr) {
}
frame++;
PadMgr_UnlockSerialMesgQueue(padmgr, ctrlrQ);
PadMgr_UnlockSerialMesgQueue(padMgr, ctrlrQ);
}
void PadMgr_RumbleStop(PadMgr* padmgr) {
void PadMgr_RumbleStop(PadMgr* padMgr) {
s32 i;
OSMesgQueue* ctrlrQ;
ctrlrQ = PadMgr_LockSerialMesgQueue(padmgr);
OSMesgQueue* ctrlrQ = PadMgr_LockSerialMesgQueue(padMgr);
for (i = 0; i < 4; i++) {
if (osProbeRumblePak(ctrlrQ, &padmgr->pfs[i], i) == 0) {
if ((gFaultStruct.msgId == 0) && (padmgr->rumbleOnFrames != 0)) {
if (osProbeRumblePak(ctrlrQ, &padMgr->pfs[i], i) == 0) {
if ((gFaultStruct.msgId == 0) && (padMgr->rumbleOnFrames != 0)) {
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止"); // "Stop vibration pack"
osSyncPrintf(VT_RST);
}
osSetRumble(&padmgr->pfs[i], 0);
osSetRumble(&padMgr->pfs[i], 0);
}
}
PadMgr_UnlockSerialMesgQueue(padmgr, ctrlrQ);
PadMgr_UnlockSerialMesgQueue(padMgr, ctrlrQ);
}
void PadMgr_RumbleReset(PadMgr* padmgr) {
padmgr->rumbleOffFrames = 3;
void PadMgr_RumbleReset(PadMgr* padMgr) {
padMgr->rumbleOffFrames = 3;
}
void PadMgr_RumbleSetSingle(PadMgr* padmgr, u32 ctrlr, u32 rumble) {
padmgr->rumbleEnable[ctrlr] = rumble;
padmgr->rumbleOnFrames = 240;
void PadMgr_RumbleSetSingle(PadMgr* padMgr, u32 ctrlr, u32 rumble) {
padMgr->rumbleEnable[ctrlr] = rumble;
padMgr->rumbleOnFrames = 240;
}
void PadMgr_RumbleSet(PadMgr* padmgr, u8* ctrlrRumbles) {
void PadMgr_RumbleSet(PadMgr* padMgr, u8* ctrlrRumbles) {
s32 i;
for (i = 0; i < 4; i++) {
padmgr->rumbleEnable[i] = ctrlrRumbles[i];
padMgr->rumbleEnable[i] = ctrlrRumbles[i];
}
padmgr->rumbleOnFrames = 240;
padMgr->rumbleOnFrames = 240;
}
void PadMgr_ProcessInputs(PadMgr* padmgr) {
void PadMgr_ProcessInputs(PadMgr* padMgr) {
s32 i;
Input* input;
OSContPad* padnow1; // original name
s32 buttonDiff;
PadMgr_LockPadData(padmgr);
PadMgr_LockPadData(padMgr);
input = &padmgr->inputs[0];
padnow1 = &padmgr->pads[0];
input = &padMgr->inputs[0];
padnow1 = &padMgr->pads[0];
for (i = 0; i < padmgr->ncontrollers; i++, input++, padnow1++) {
for (i = 0; i < padMgr->nControllers; i++, input++, padnow1++) {
input->prev = input->cur;
if (1) {} // Necessary to match
@ -220,8 +216,8 @@ void PadMgr_ProcessInputs(PadMgr* padmgr) {
switch (padnow1->errno) {
case 0:
input->cur = *padnow1;
if (!padmgr->ctrlrIsConnected[i]) {
padmgr->ctrlrIsConnected[i] = true;
if (!padMgr->ctrlrIsConnected[i]) {
padMgr->ctrlrIsConnected[i] = true;
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "認識しました"); // "Recognized"
osSyncPrintf(VT_RST);
@ -229,7 +225,7 @@ void PadMgr_ProcessInputs(PadMgr* padmgr) {
break;
case 4:
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));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "オーバーランエラーが発生"); // "Overrun error occurred"
osSyncPrintf(VT_RST);
@ -239,10 +235,10 @@ void PadMgr_ProcessInputs(PadMgr* padmgr) {
input->cur.stick_x = 0;
input->cur.stick_y = 0;
input->cur.errno = padnow1->errno;
if (padmgr->ctrlrIsConnected[i]) {
padmgr->ctrlrIsConnected[i] = false;
padmgr->pakType[i] = 0;
padmgr->rumbleCounter[i] = 0xFF;
if (padMgr->ctrlrIsConnected[i]) {
padMgr->ctrlrIsConnected[i] = false;
padMgr->pakType[i] = 0;
padMgr->rumbleCounter[i] = 0xFF;
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "応答しません"); // "Do not respond"?
osSyncPrintf(VT_RST);
@ -261,72 +257,71 @@ void PadMgr_ProcessInputs(PadMgr* padmgr) {
input->press.stick_y += (s8)(input->cur.stick_y - input->prev.stick_y);
}
PadMgr_UnlockPadData(padmgr);
PadMgr_UnlockPadData(padMgr);
}
void PadMgr_HandleRetraceMsg(PadMgr* padmgr) {
void PadMgr_HandleRetraceMsg(PadMgr* padMgr) {
s32 i;
OSMesgQueue* queue;
OSMesgQueue* queue = PadMgr_LockSerialMesgQueue(padMgr);
u32 mask;
queue = PadMgr_LockSerialMesgQueue(padmgr);
osContStartReadData(queue);
if (padmgr->retraceCallback) {
padmgr->retraceCallback(padmgr, padmgr->retraceCallbackValue);
if (padMgr->retraceCallback) {
padMgr->retraceCallback(padMgr, padMgr->retraceCallbackValue);
}
osRecvMesg(queue, NULL, OS_MESG_BLOCK);
osContGetReadData(padmgr->pads);
if (padmgr->preNMIShutdown) {
bzero(padmgr->pads, sizeof(padmgr->pads));
osContGetReadData(padMgr->pads);
if (padMgr->preNMIShutdown) {
bzero(padMgr->pads, sizeof(padMgr->pads));
}
PadMgr_ProcessInputs(padmgr);
PadMgr_ProcessInputs(padMgr);
osContStartQuery(queue);
osRecvMesg(queue, NULL, OS_MESG_BLOCK);
osContGetQuery(padmgr->padStatus);
PadMgr_UnlockSerialMesgQueue(padmgr, queue);
osContGetQuery(padMgr->padStatus);
PadMgr_UnlockSerialMesgQueue(padMgr, queue);
mask = 0;
for (i = 0; i < 4; i++) {
if (padmgr->padStatus[i].errno == 0) {
if (padmgr->padStatus[i].type == 5) {
if (padMgr->padStatus[i].errno == 0) {
if (padMgr->padStatus[i].type == 5) {
mask |= 1 << i;
} else {
LOG_HEX("this->pad_status[i].type", padmgr->padStatus[i].type, "../padmgr.c", 458);
LOG_HEX("this->pad_status[i].type", padMgr->padStatus[i].type, "../padmgr.c", 458);
// "An unknown type of controller is connected"
osSyncPrintf("知らない種類のコントローラが接続されています\n");
}
}
}
padmgr->validCtrlrsMask = mask;
padMgr->validCtrlrsMask = mask;
if (gFaultStruct.msgId) {
PadMgr_RumbleStop(padmgr);
} else if (padmgr->rumbleOffFrames > 0) {
--padmgr->rumbleOffFrames;
PadMgr_RumbleStop(padmgr);
} else if (padmgr->rumbleOnFrames == 0) {
PadMgr_RumbleStop(padmgr);
} else if (!padmgr->preNMIShutdown) {
PadMgr_RumbleControl(padmgr);
--padmgr->rumbleOnFrames;
PadMgr_RumbleStop(padMgr);
} else if (padMgr->rumbleOffFrames > 0) {
--padMgr->rumbleOffFrames;
PadMgr_RumbleStop(padMgr);
} else if (padMgr->rumbleOnFrames == 0) {
PadMgr_RumbleStop(padMgr);
} else if (!padMgr->preNMIShutdown) {
PadMgr_RumbleControl(padMgr);
--padMgr->rumbleOnFrames;
}
}
void PadMgr_HandlePreNMI(PadMgr* padmgr) {
void PadMgr_HandlePreNMI(PadMgr* padMgr) {
osSyncPrintf("padmgr_HandlePreNMI()\n");
padmgr->preNMIShutdown = true;
PadMgr_RumbleReset(padmgr);
padMgr->preNMIShutdown = true;
PadMgr_RumbleReset(padMgr);
}
void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode) {
void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 mode) {
s32 i;
Input* ogInput;
Input* newInput;
s32 buttonDiff;
PadMgr_LockPadData(padmgr);
PadMgr_LockPadData(padMgr);
ogInput = &padmgr->inputs[0];
ogInput = &padMgr->inputs[0];
newInput = &inputs[0];
for (i = 0; i < 4; i++) {
if (mode != 0) {
@ -349,10 +344,10 @@ void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode) {
newInput++;
}
PadMgr_UnlockPadData(padmgr);
PadMgr_UnlockPadData(padMgr);
}
void PadMgr_ThreadEntry(PadMgr* padmgr) {
void PadMgr_ThreadEntry(PadMgr* padMgr) {
s16* mesg = NULL;
s32 exit;
@ -361,12 +356,12 @@ void PadMgr_ThreadEntry(PadMgr* padmgr) {
exit = false;
while (!exit) {
if ((D_8012D280 > 2) && (padmgr->interruptMsgQ.validCount == 0)) {
if ((D_8012D280 > 2) && (padMgr->interruptMsgQ.validCount == 0)) {
// "Waiting for controller thread event"
osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
}
osRecvMesg(&padmgr->interruptMsgQ, &mesg, OS_MESG_BLOCK);
osRecvMesg(&padMgr->interruptMsgQ, (OSMesg)&mesg, OS_MESG_BLOCK);
LogUtils_CheckNullPointer("msg", mesg, "../padmgr.c", 563);
switch (*mesg) {
@ -375,7 +370,7 @@ void PadMgr_ThreadEntry(PadMgr* padmgr) {
osSyncPrintf("padmgr_HandleRetraceMsg START %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
}
PadMgr_HandleRetraceMsg(padmgr);
PadMgr_HandleRetraceMsg(padMgr);
if (D_8012D280 > 2) {
osSyncPrintf("padmgr_HandleRetraceMsg END %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
@ -383,7 +378,7 @@ void PadMgr_ThreadEntry(PadMgr* padmgr) {
break;
case OS_SC_PRE_NMI_MSG:
PadMgr_HandlePreNMI(padmgr);
PadMgr_HandlePreNMI(padMgr);
break;
case OS_SC_NMI_MSG:
exit = true;
@ -391,30 +386,30 @@ void PadMgr_ThreadEntry(PadMgr* padmgr) {
}
}
IrqMgr_RemoveClient(padmgr->irqMgr, &padmgr->irqClient);
IrqMgr_RemoveClient(padMgr->irqMgr, &padMgr->irqClient);
// "Controller thread execution end"
osSyncPrintf("コントローラスレッド実行終了\n");
}
void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* siIntMsgQ, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack) {
void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* siIntMsgQ, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack) {
// "Pad Manager creation"
osSyncPrintf("パッドマネージャ作成 padmgr_Create()\n");
bzero(padmgr, sizeof(PadMgr));
padmgr->irqMgr = irqMgr;
bzero(padMgr, sizeof(PadMgr));
padMgr->irqMgr = irqMgr;
osCreateMesgQueue(&padmgr->interruptMsgQ, padmgr->interruptMsgBuf, 4);
IrqMgr_AddClient(padmgr->irqMgr, &padmgr->irqClient, &padmgr->interruptMsgQ);
osCreateMesgQueue(&padmgr->serialMsgQ, padmgr->serialMsgBuf, 1);
PadMgr_UnlockSerialMesgQueue(padmgr, siIntMsgQ);
osCreateMesgQueue(&padmgr->lockMsgQ, padmgr->lockMsgBuf, 1);
PadMgr_UnlockPadData(padmgr);
PadSetup_Init(siIntMsgQ, &padmgr->validCtrlrsMask, padmgr->padStatus);
osCreateMesgQueue(&padMgr->interruptMsgQ, padMgr->interruptMsgBuf, 4);
IrqMgr_AddClient(padMgr->irqMgr, &padMgr->irqClient, &padMgr->interruptMsgQ);
osCreateMesgQueue(&padMgr->serialMsgQ, padMgr->serialMsgBuf, 1);
PadMgr_UnlockSerialMesgQueue(padMgr, siIntMsgQ);
osCreateMesgQueue(&padMgr->lockMsgQ, padMgr->lockMsgBuf, 1);
PadMgr_UnlockPadData(padMgr);
PadSetup_Init(siIntMsgQ, (u8*)&padMgr->validCtrlrsMask, padMgr->padStatus);
padmgr->ncontrollers = 4;
osContSetCh(padmgr->ncontrollers);
padMgr->nControllers = 4;
osContSetCh(padMgr->nControllers);
osCreateThread(&padmgr->thread, id, PadMgr_ThreadEntry, padmgr, stack, priority);
osStartThread(&padmgr->thread);
osCreateThread(&padMgr->thread, id, (void (*)(void*))PadMgr_ThreadEntry, padMgr, stack, priority);
osStartThread(&padMgr->thread);
}

View file

@ -13,6 +13,7 @@ s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status) {
if (osContStartQuery(mq) != 0) {
return 1;
}
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
osContGetQuery(status);

View file

@ -4,7 +4,7 @@ void PadUtils_Init(Input* input) {
bzero(input, sizeof(Input));
}
void func_800FCB70() {
void func_800FCB70(void) {
}
void PadUtils_ResetPressRel(Input* input) {
@ -66,11 +66,10 @@ s8 PadUtils_GetRelY(Input* input) {
}
void PadUtils_UpdateRelXY(Input* input) {
s32 curX, curY;
s32 relX, relY;
curX = PadUtils_GetCurX(input);
curY = PadUtils_GetCurY(input);
s32 curX = PadUtils_GetCurX(input);
s32 curY = PadUtils_GetCurY(input);
s32 relX;
s32 relY;
if (curX > 7) {
relX = (curX < 0x43) ? curX - 7 : 0x43 - 7;

View file

@ -1,12 +1,12 @@
#include "global.h"
void PrintUtils_VPrintf(char** arg0, const char* fmt, va_list args) {
_Printf(*arg0, arg0, fmt, args);
void PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args) {
_Printf(*pfn, pfn, fmt, args);
}
void PrintUtils_Printf(void* arg0, const char* fmt, ...) {
void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
PrintUtils_VPrintf(arg0, fmt, args);
PrintUtils_VPrintf(pfn, fmt, args);
}

View file

@ -86,7 +86,8 @@ void Overlay_Relocate(void* allocatedVRamAddress, OverlayRelocationSection* over
vaddr = (s16)relocData;
isLoNeg = (((relocOffset + allocu32) & 0x8000) ? 1 : 0);
unrelocatedAddress = (*luiInstRef << 0x10) + vaddr;
*luiInstRef = *luiInstRef & 0xFFFF0000 | ((((relocOffset + allocu32) >> 0x10) & 0xFFFF) + isLoNeg);
*luiInstRef =
(*luiInstRef & 0xFFFF0000) | ((((relocOffset + allocu32) >> 0x10) & 0xFFFF) + isLoNeg);
relocatedValue = (*relocDataP & 0xFFFF0000) | ((relocOffset + allocu32) & 0xFFFF);
relocatedAddress = (*luiInstRef << 0x10) + (s16)relocatedValue;

View file

@ -15,16 +15,19 @@ OSTime sRDPStartTime;
void Sched_SwapFrameBuffer(CfbInfo* cfbInfo) {
u16 width;
LogUtils_CheckValidPointer("cfbinfo->swapbuffer", cfbInfo->swapBuffer, "../sched.c", 340);
if (cfbInfo->swapBuffer != NULL) {
osViSwapBuffer(cfbInfo->swapBuffer);
cfbInfo->updateRate2 = cfbInfo->updateRate;
if (sLogScheduler) {
osSyncPrintf("osViSwapBuffer %08x %08x %08x\n", osViGetCurrentFramebuffer(), osViGetNextFramebuffer(),
(cfbInfo != NULL ? cfbInfo->swapBuffer : NULL));
}
width = cfbInfo->viMode != NULL ? cfbInfo->viMode->comRegs.width : gScreenWidth;
width = cfbInfo->viMode != NULL ? cfbInfo->viMode->comRegs.width : (u32)gScreenWidth;
Fault_SetFB(cfbInfo->swapBuffer, width, 0x10);
if (HREG(80) == 0xD && HREG(95) != 0xD) {
HREG(81) = 0;
HREG(82) = 0;
@ -66,8 +69,10 @@ void func_800C84E4(SchedContext* sc, CfbInfo* cfbInfo) {
void Sched_HandleReset(SchedContext* sc) {
OSTime now;
if (sc->curRSPTask != NULL) {
now = osGetTime();
if (sc->curRSPTask->framebuffer == NULL) {
LOG_TIME("(((u64)(now - audio_rsp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))",
OS_CYCLES_TO_USEC(now - sRSPAudioStartTime), "../sched.c", 421);
@ -94,6 +99,7 @@ void Sched_HandleStart(SchedContext* sc) {
void Sched_QueueTask(SchedContext* sc, OSScTask* task) {
s32 type = task->list.t.type;
if (!((type == M_AUDTASK) || (type == M_GFXTASK) || (type == M_NJPEGTASK) || (type == M_NULTASK))) {
__assert("(type == M_AUDTASK) || (type == M_GFXTASK) || (type == M_NJPEGTASK) || (type == M_NULTASK)",
"../sched.c", 463);
@ -244,7 +250,6 @@ u32 Sched_IsComplete(SchedContext* sc, OSScTask* task) {
}
void Sched_RunTask(SchedContext* sc, OSScTask* spTask, OSScTask* dpTask) {
if (sc->curRSPTask != NULL) {
__assert("sc->curRSPTask == NULL", "../sched.c", 663);
}
@ -261,6 +266,7 @@ void Sched_RunTask(SchedContext* sc, OSScTask* spTask, OSScTask* dpTask) {
Sched_IsComplete(sc, spTask);
return;
}
spTask->state &= ~(OS_SC_YIELD | OS_SC_YIELDED);
osWritebackDCacheAll();
osSpTaskLoad(&spTask->list);
@ -280,6 +286,7 @@ void Sched_RunTask(SchedContext* sc, OSScTask* spTask, OSScTask* dpTask) {
(spTask->list.t.type == M_AUDTASK ? "AUDIO" : (spTask->list.t.type == M_GFXTASK ? "GRAPH" : "OTHER")));
}
sc->curRSPTask = spTask;
if (spTask == dpTask && sc->curRDPTask == NULL) {
sc->curRDPTask = dpTask;
sRDPStartTime = sRSPGFXStartTime;
@ -288,14 +295,11 @@ void Sched_RunTask(SchedContext* sc, OSScTask* spTask, OSScTask* dpTask) {
}
void Sched_HandleEntry(SchedContext* sc) {
OSScTask* nextRSP;
OSScTask* nextRDP;
u32 state;
OSMesg msg;
OSScTask* nextRSP = NULL;
OSScTask* nextRDP = NULL;
s32 state;
OSMesg msg = NULL;
nextRSP = NULL;
nextRDP = NULL;
msg = NULL;
while (osRecvMesg(&sc->cmdQ, &msg, OS_MESG_NOBLOCK) != -1) {
Sched_QueueTask(sc, msg);
}
@ -307,6 +311,7 @@ void Sched_HandleEntry(SchedContext* sc) {
Sched_Yield(sc);
return;
}
state = ((sc->curRSPTask == 0) * 2) | (sc->curRDPTask == 0);
if (Sched_Schedule(sc, &nextRSP, &nextRDP, state) != state) {
Sched_RunTask(sc, nextRSP, nextRDP);
@ -322,6 +327,7 @@ void Sched_HandleRetrace(SchedContext* sc) {
}
ViConfig_UpdateBlack();
sc->retraceCnt++;
if (osViGetCurrentFramebuffer() == (u32*)(sc->pendingSwapBuf1 != NULL ? sc->pendingSwapBuf1->swapBuffer : NULL)) {
if (sc->curBuf != NULL) {
sc->curBuf->unk_10 = 0;
@ -338,7 +344,6 @@ void Sched_HandleRetrace(SchedContext* sc) {
if (sc->curBuf->updateRate2 > 0) {
sc->curBuf->updateRate2--;
}
if ((sc->curBuf->updateRate2 <= 0) && (sc->pendingSwapBuf1 != NULL)) {
func_800C84E4(sc, sc->pendingSwapBuf1);
}
@ -353,12 +358,10 @@ void Sched_HandleRetrace(SchedContext* sc) {
void Sched_HandleRSPDone(SchedContext* sc) {
OSScTask* curRSPTask;
OSScTask* nextRSP;
OSScTask* nextRDP;
OSScTask* nextRSP = NULL;
OSScTask* nextRDP = NULL;
s32 state;
nextRSP = NULL;
nextRDP = NULL;
if (sc->curRSPTask == NULL) {
__assert("sc->curRSPTask", "../sched.c", 819);
}
@ -393,6 +396,7 @@ void Sched_HandleRSPDone(SchedContext* sc) {
curRSPTask->state &= ~OS_SC_SP;
Sched_IsComplete(sc, curRSPTask);
}
state = ((sc->curRSPTask == NULL) << 1) | (sc->curRDPTask == NULL);
if (Sched_Schedule(sc, &nextRSP, &nextRDP, state) != state) {
Sched_RunTask(sc, nextRSP, nextRDP);
@ -404,13 +408,10 @@ void Sched_HandleRSPDone(SchedContext* sc) {
void Sched_HandleRDPDone(SchedContext* sc) {
OSScTask* curTask;
OSScTask* nextRSP;
OSScTask* nextRDP;
OSScTask* nextRSP = NULL;
OSScTask* nextRDP = NULL;
s32 state;
nextRSP = NULL;
nextRDP = NULL;
gRDPTotalTime = osGetTime() - sRDPStartTime;
if (sc->curRDPTask == NULL) {
__assert("sc->curRDPTask", "../sched.c", 878);
@ -431,12 +432,12 @@ void Sched_HandleRDPDone(SchedContext* sc) {
}
}
void Sched_SendEntryMsg(OSMesgQueue* mq) {
void Sched_SendEntryMsg(SchedContext* sc) {
if (sLogScheduler) {
osSyncPrintf("osScKickEntryMsg\n");
}
osSendMesg(mq, ENTRY_MSG, OS_MESG_BLOCK);
osSendMesg(&sc->interruptQ, ENTRY_MSG, OS_MESG_BLOCK);
}
void Sched_ThreadEntry(void* arg) {
@ -444,7 +445,8 @@ void Sched_ThreadEntry(void* arg) {
SchedContext* sc = (SchedContext*)arg;
msg = NULL;
while (1) {
while (true) {
if (sLogScheduler) {
// %08d: standby
osSyncPrintf("%08d:待機中\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));

View file

@ -3,11 +3,9 @@
s32 D_8012CED0 = 0;
s32 sShrinkWindowVal = 0;
s32 sShrinkWindowCurrentVal = 0;
void ShrinkWindow_SetVal(s32 value) {
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_setval(%d)\n", value);
}

View file

@ -62,9 +62,9 @@ void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) {
return;
}
gSpeedMeterTimeEntryPtr = &sSpeedMeterTimeEntryArray;
gSpeedMeterTimeEntryPtr = &sSpeedMeterTimeEntryArray[0];
for (i = 0; i < ARRAY_COUNT(sSpeedMeterTimeEntryArray); i++) {
temp = ((f64)*gSpeedMeterTimeEntryPtr->time / gIrqMgrRetraceTime) * 64.0;
temp = ((f64) * (gSpeedMeterTimeEntryPtr->time) / gIrqMgrRetraceTime) * 64.0;
gSpeedMeterTimeEntryPtr->x = temp + baseX;
gSpeedMeterTimeEntryPtr++;
}
@ -88,7 +88,7 @@ void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) {
DrawRec(gfx++, GPACK_RGBA5551(255, 0, 0, 1), baseX + 64 * 2, uly, baseX + 64 * 3, lry);
DrawRec(gfx++, GPACK_RGBA5551(255, 0, 255, 1), baseX + 64 * 3, uly, baseX + 64 * 4, lry);
gSpeedMeterTimeEntryPtr = sSpeedMeterTimeEntryArray;
gSpeedMeterTimeEntryPtr = &sSpeedMeterTimeEntryArray[0];
for (i = 0; i < ARRAY_COUNT(sSpeedMeterTimeEntryArray); i++) {
DrawRec(gfx++, gSpeedMeterTimeEntryPtr->color, baseX, lry + gSpeedMeterTimeEntryPtr->y,
gSpeedMeterTimeEntryPtr->x, lry + gSpeedMeterTimeEntryPtr->y + 1);
@ -178,7 +178,7 @@ void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, Gam
}
if (SREG(0) > 1) {
SystemArena_GetSizes(&sysFreeMax, &sysFree, &sysAlloc);
SystemArena_GetSizes((u32*)&sysFreeMax, (u32*)&sysFree, (u32*)&sysAlloc);
SpeedMeter_InitAllocEntry(&entry, sysFree + sysAlloc - state->tha.size, sysAlloc - state->tha.size,
GPACK_RGBA5551(0, 0, 255, 1), GPACK_RGBA5551(255, 128, 128, 1), ulx, lrx, y, y);
SpeedMeter_DrawAllocEntry(&entry, gfxCtx);

View file

@ -6,6 +6,7 @@ u32 sSysCfbEnd;
void SysCfb_Init(s32 n64dd) {
u32 screenSize;
u32 tmpFbEnd;
if (osMemSize >= 0x800000U) {
// 8MB or more memory is installed
osSyncPrintf("8Mバイト以上のメモリが搭載されています\n");

View file

@ -17,7 +17,7 @@ f32 Math_Factorial(s32 n) {
f32 ret;
s32 i;
if (n > 12U) {
if ((u32)n > 12U) {
ret = sFactorialTbl[12];
for (i = 13; i <= n; i++) {
ret *= i;

View file

@ -201,7 +201,7 @@ s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC,
static Linef planeIntersect;
if (!Math3D_PlaneVsPlaneNewLine(planeAA, planeAB, planeAC, planeADist, planeBA, planeBB, planeBC, planeBDist,
&planeIntersect)) {
(InfiniteLine*)&planeIntersect)) {
return false;
}
Math3D_LineClosestToPoint(&planeIntersect, point, closestPoint);

View file

@ -78,11 +78,9 @@ static u16 sATan2Tbl[] = {
};
u16 Math_GetAtan2Tbl(f32 x, f32 y) {
s32 tblIdx;
s32 tblIdx = ((x / y) * 1024.0f) + 0.5f;
u16 ret;
tblIdx = ((x / y) * 1024.0f) + 0.5f;
if (y == 0.0f) {
ret = sATan2Tbl[0];
} else if (tblIdx >= ARRAY_COUNT(sATan2Tbl)) {

View file

@ -294,7 +294,7 @@ void Matrix_RotateZ(f32 z, u8 mode) {
}
}
/*
/**
* Rotates the top of the matrix stack by `z` degrees, then
* rotates that matrix by `y` degrees, then rotates that matrix
* by `x` degrees. (roll-pitch-yaw)
@ -385,19 +385,16 @@ void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
}
}
/*
/**
* Roll-pitch-yaw rotation and position
*/
void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
MtxF* cmf = sCurrentMatrix;
f32 sin;
f32 cos;
f32 sin = Math_SinS(rotation->z);
f32 cos = Math_CosS(rotation->z);
f32 temp1;
f32 temp2;
sin = Math_SinS(rotation->z);
cos = Math_CosS(rotation->z);
temp1 = cmf->xx;
temp2 = cmf->yx;
cmf->wx += temp1 * position->x + temp2 * position->y + cmf->zx * position->z;
@ -475,14 +472,11 @@ void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec) {
MtxF* cmf = sCurrentMatrix;
f32 sp30;
f32 sp2C;
f32 sp30 = Math_SinS(vec->y);
f32 sp2C = Math_CosS(vec->y);
f32 sp28;
f32 sp24;
sp30 = Math_SinS(vec->y);
sp2C = Math_CosS(vec->y);
cmf->xx = sp2C;
cmf->xz = -sp30;
cmf->wx = x;

View file

@ -3,18 +3,18 @@
u32 D_8012DBA0 = (u32)&D_80155F50;
u32 D_8012DBA4 = (u32)&D_80157580;
u32 SysUcode_GetUCodeBoot() {
u32 SysUcode_GetUCodeBoot(void) {
return &D_80009320;
}
u32 SysUcode_GetUCodeBootSize() {
u32 SysUcode_GetUCodeBootSize(void) {
return (u32)&D_800093F0 - (u32)&D_80009320;
}
u32 SysUcode_GetUCode() {
u32 SysUcode_GetUCode(void) {
return D_8012DBA0;
}
u32 SysUcode_GetUCodeData() {
u32 SysUcode_GetUCodeData(void) {
return D_8012DBA4;
}

View file

@ -8,7 +8,7 @@ s32 gSystemArenaLogSeverity = LOG_SEVERITY_NOLOG;
Arena gSystemArena;
void SystemArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action) {
if (!ptr) {
if (ptr == NULL) {
if (gSystemArenaLogSeverity >= LOG_SEVERITY_ERROR) {
// "%s: %u bytes %s failed\n"
osSyncPrintf("%s: %u バイトの%sに失敗しました\n", name, size, action);
@ -22,29 +22,29 @@ void SystemArena_CheckPointer(void* ptr, u32 size, const char* name, const char*
}
void* SystemArena_Malloc(u32 size) {
void* ptr;
ptr = __osMalloc(&gSystemArena, size);
void* ptr = __osMalloc(&gSystemArena, size);
SystemArena_CheckPointer(ptr, size, "malloc", "確保"); // Secure
return ptr;
}
void* SystemArena_MallocDebug(u32 size, const char* file, s32 line) {
void* ptr;
ptr = __osMallocDebug(&gSystemArena, size, file, line);
void* ptr = __osMallocDebug(&gSystemArena, size, file, line);
SystemArena_CheckPointer(ptr, size, "malloc_DEBUG", "確保"); // Secure
return ptr;
}
void* SystemArena_MallocR(u32 size) {
void* ptr;
ptr = __osMallocR(&gSystemArena, size);
void* ptr = __osMallocR(&gSystemArena, size);
SystemArena_CheckPointer(ptr, size, "malloc_r", "確保"); // Secure
return ptr;
}
void* SystemArena_MallocRDebug(u32 size, const char* file, s32 line) {
void* ptr;
ptr = __osMallocRDebug(&gSystemArena, size, file, line);
void* ptr = __osMallocRDebug(&gSystemArena, size, file, line);
SystemArena_CheckPointer(ptr, size, "malloc_r_DEBUG", "確保"); // Secure
return ptr;
}
@ -71,11 +71,10 @@ void SystemArena_FreeDebug(void* ptr, const char* file, s32 line) {
void* SystemArena_Calloc(u32 num, u32 size) {
void* ret;
u32 n;
u32 n = num * size;
n = num * size;
ret = __osMalloc(&gSystemArena, n);
if (ret) {
if (ret != NULL) {
bzero(ret, n);
}
@ -83,7 +82,7 @@ void* SystemArena_Calloc(u32 num, u32 size) {
return ret;
}
void SystemArena_Display() {
void SystemArena_Display(void) {
// System heap display
osSyncPrintf("システムヒープ表示\n");
__osDisplayArena(&gSystemArena);
@ -93,7 +92,7 @@ void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc) {
ArenaImpl_GetSizes(&gSystemArena, outMaxFree, outFree, outAlloc);
}
void SystemArena_Check() {
void SystemArena_Check(void) {
__osCheckArena(&gSystemArena);
}
@ -102,11 +101,11 @@ void SystemArena_Init(void* start, u32 size) {
__osMallocInit(&gSystemArena, start, size);
}
void SystemArena_Cleanup() {
void SystemArena_Cleanup(void) {
gSystemArenaLogSeverity = LOG_SEVERITY_NOLOG;
__osMallocCleanup(&gSystemArena);
}
u8 SystemArena_IsInitalized() {
u8 SystemArena_IsInitalized(void) {
return __osMallocIsInitalized(&gSystemArena);
}

View file

@ -1278,13 +1278,13 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 arg2, f
}
}
s32 D_8015BBA8[16];
Mtx D_8015BBA8;
Gfx* func_8002E830(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx, Gfx* gfx, Hilite** hilite) {
Gfx* lookAt;
LookAt* lookAt;
f32 correctedEyeX;
lookAt = Graph_Alloc(gfxCtx, 4 * sizeof(Gfx));
lookAt = Graph_Alloc(gfxCtx, sizeof(LookAt));
correctedEyeX = (eye->x == object->x) && (eye->z == object->z) ? eye->x + 0.001f : eye->x;
@ -1777,8 +1777,8 @@ void func_8002FA60(GlobalContext* globalCtx) {
Vec3f D_80116048 = { 0.0f, -0.05f, 0.0f };
Vec3f D_80116054 = { 0.0f, -0.025f, 0.0f };
Color_RGB8 D_80116060 = { 255, 255, 255 };
Color_RGB8 D_80116064 = { 100, 200, 0 };
Color_RGBA8 D_80116060 = { 255, 255, 255, 0 };
Color_RGBA8 D_80116064 = { 100, 200, 0, 0 };
#ifdef NON_MATCHING
// saved register, stack usage and minor ordering differences
@ -2754,7 +2754,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId
osSyncPrintf("アクタークライアントは %d 個目です\n", overlayEntry->nbLoaded);
}
Lib_MemSet(actor, actorInit->instanceSize, 0);
Lib_MemSet((u8*)actor, actorInit->instanceSize, 0);
actor->overlayEntry = overlayEntry;
actor->id = actorInit->id;
actor->flags = actorInit->flags;
@ -2982,7 +2982,7 @@ Actor* func_80032AF0(GlobalContext* globalCtx, ActorContext* actorCtx, Actor** a
}
if (D_8015BBE8 == NULL) {
for (i; i < ARRAY_COUNT(D_801160A0); i++) {
for (; i < ARRAY_COUNT(D_801160A0); i++) {
func_800328D4(globalCtx, actorCtx, player, *entry);
entry++;
}
@ -3062,9 +3062,9 @@ void func_80032E24(struct_80032E24* arg0, s32 arg1, GlobalContext* globalCtx) {
sp20 = (arg1 * sizeof(*arg0->unk_04)) + sizeof(*arg0->unk_04);
arg0->unk_04 = ZeldaArena_MallocDebug(sp20, "../z_actor.c", 7546);
if (arg0->unk_04 != NULL) {
Lib_MemSet(arg0->unk_00, sp28, 0);
Lib_MemSet(arg0->unk_0C, sp24, 0);
Lib_MemSet(arg0->unk_04, sp20, 0);
Lib_MemSet((u8*)arg0->unk_00, sp28, 0);
Lib_MemSet((u8*)arg0->unk_0C, sp24, 0);
Lib_MemSet((u8*)arg0->unk_04, sp20, 0);
arg0->unk_10 = 1;
return;
}
@ -3099,7 +3099,7 @@ void func_80032F54(struct_80032E24* arg0, s32 arg1, s32 arg2, s32 arg3, u32 arg4
arg0->unk_08++;
}
if (arg0->unk_08 >= arg4) {
if ((u32)arg0->unk_08 >= arg4) {
arg0->unk_08 = arg0->unk_10 - 1;
arg0->unk_10 = -1;
}
@ -3964,8 +3964,8 @@ s32 func_800354B4(GlobalContext* globalCtx, Actor* actor, f32 range, s16 arg3, s
}
void func_8003555C(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) {
Color_RGB8 color1;
Color_RGB8 color2;
Color_RGBA8 color1;
Color_RGBA8 color2;
color1.r = 200;
color1.g = 160;
@ -3975,6 +3975,7 @@ void func_8003555C(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar
color2.g = 90;
color2.b = 50;
//! @bug color1 and color2 alpha components not set before being passed on
EffectSsKiraKira_SpawnSmall(globalCtx, arg1, arg2, arg3, &color1, &color2);
}

View file

@ -498,7 +498,7 @@ void ActorOverlayTable_LogPrint(void) {
osSyncPrintf("actor_dlftbls %u\n", gMaxActorId);
osSyncPrintf("RomStart RomEnd SegStart SegEnd allocp profile segname\n");
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) {
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < (u32)gMaxActorId; i++, overlayEntry++) {
osSyncPrintf("%08x %08x %08x %08x %08x %08x %s\n", overlayEntry->vromStart, overlayEntry->vromEnd,
overlayEntry->vramStart, overlayEntry->vramEnd, overlayEntry->loadedRamAddr,
&overlayEntry->initInfo->id, overlayEntry->name != NULL ? overlayEntry->name : "?");

View file

@ -154,7 +154,9 @@ void BgCheck_Vec3fToVec3s(Vec3s* dst, Vec3f* src) {
* Get CollisionPoly's lowest y point
*/
s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vtxList) {
s32 a, b, c;
s32 a;
s32 b;
s32 c;
s16 min;
if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) {
@ -698,6 +700,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
}
(!IS_ZERO(normalXZ)) ? (void)0 : __assert("!IS_ZERO(ac_size)", "../z_bgcheck.c", 2854);
invNormalXZ = 1.0f / normalXZ;
temp_f16 = fabsf(nz) * invNormalXZ;
if (temp_f16 < 0.4f) {
@ -778,6 +781,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
}
(!IS_ZERO(normalXZ)) ? (void)0 : __assert("!IS_ZERO(ac_size)", "../z_bgcheck.c", 2964);
invNormalXZ = 1.0f / normalXZ;
temp_f16 = fabsf(nx) * invNormalXZ;
if (temp_f16 < 0.4f) {
@ -876,9 +880,11 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte
}
}
curPoly = &polyList[curPolyId];
if (CollisionPoly_CheckYIntersectApprox2(curPoly, vtxList, pos->x, pos->z, &ceilingY)) {
f32 intersectDist = ceilingY - *outY;
f32 ny = COLPOLY_GET_NORMAL(curPoly->normal.y);
if (intersectDist > 0.0f && intersectDist < checkHeight && intersectDist * ny <= 0) {
*outY = ceilingY - checkHeight;
*outPoly = curPoly;
@ -971,6 +977,7 @@ s32 func_8003A5B8(SSList* ssList, CollisionContext* colCtx, u16 xpFlags1, u16 xp
s32 func_8003A7D8(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
Vec3f* outPos, CollisionPoly** outPoly, f32 chkDist, f32* outDistSq, u32 bccFlags) {
s32 result = false;
if ((bccFlags & BGCHECK_CHECK_FLOOR) && lookup->floor.head != SS_NULL) {
if (func_8003A5B8(&lookup->floor, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly, outDistSq, chkDist,
bccFlags)) {
@ -1001,15 +1008,12 @@ s32 func_8003A7D8(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags1,
*/
s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius,
CollisionPoly** outPoly) {
CollisionPoly* polyList;
Vec3s* vtxList;
CollisionPoly* polyList = colCtx->colHeader->polyList;
Vec3s* vtxList = colCtx->colHeader->vtxList;
CollisionPoly* curPoly;
u16 nextId;
s16 curPolyId;
polyList = colCtx->colHeader->polyList;
vtxList = colCtx->colHeader->vtxList;
while (true) {
curPolyId = node->polyId;
curPoly = &polyList[curPolyId];
@ -1027,6 +1031,7 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext
center->y + radius < vtxList[curPoly->vIC].y) {
break;
}
if (CollisionPoly_SphVsPoly(curPoly, vtxList, center, radius)) {
*outPoly = curPoly;
return true;
@ -1195,12 +1200,11 @@ void func_8003B218(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* poly
f32 z;
Vec3s* vtx;
s16 vtxId;
vtxId = COLPOLY_VTX_INDEX(polyList[polyId].vtxData[0]);
s16 vtxId = COLPOLY_VTX_INDEX(polyList[polyId].vtxData[0]);
Math_Vec3s_ToVec3f(&maxVtx, &vtxList[vtxId]);
Math_Vec3f_Copy(&minVtx, &maxVtx);
for (vtxDataTemp = polyList[polyId].vtxData + 1; vtxDataTemp < polyList[polyId].vtxData + 3; vtxDataTemp++) {
vtxId = COLPOLY_VTX_INDEX(*vtxDataTemp);
vtx = &vtxList[vtxId];
@ -1257,16 +1261,19 @@ s32 func_8003B3C8(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxLis
if (flags[0] == 0) {
return true;
}
BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)], &vb);
flags[1] = Math3D_PointRelativeToCubeFaces(&vb, min, max);
if (flags[1] == 0) {
return true;
}
BgCheck_Vec3sToVec3f(&vtxList[poly->vIC], &vc);
flags[2] = Math3D_PointRelativeToCubeFaces(&vc, min, max);
if (flags[2] == 0) {
return true;
}
if (flags[0] & flags[1] & flags[2]) {
return false;
}
@ -1287,6 +1294,7 @@ s32 func_8003B3C8(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxLis
CollisionPoly_GetNormalF(poly, &nx, &ny, &nz);
dist = poly->dist;
if (Math3D_TriChkLineSegParaYIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->z, min->x, &intersect, min->y,
max->y) ||
Math3D_TriChkLineSegParaYIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->z, min->x, &intersect, min->y,
@ -1317,6 +1325,7 @@ s32 func_8003B3C8(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxLis
max->x)) {
return true;
}
BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)], &va2);
BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)], &vb2);
BgCheck_Vec3sToVec3f(&vtxList[poly->vIC], &vc2);
@ -1350,7 +1359,7 @@ u32 func_8003BB18(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLook
// subdiv min/max bounds for adding a poly
Vec3f curSubdivMin;
Vec3f curSubdivMax;
CollisionHeader* colHeader;
CollisionHeader* colHeader = colCtx->colHeader;
StaticLookup* spA4;
StaticLookup* phi_fp;
StaticLookup* phi_s0;
@ -1359,14 +1368,13 @@ u32 func_8003BB18(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLook
f32 subdivLengthY;
f32 subdivLengthZ;
colHeader = colCtx->colHeader;
for (spA4 = lookupTbl;
spA4 < (colCtx->subdivAmount.x * colCtx->subdivAmount.y * colCtx->subdivAmount.z + lookupTbl); spA4++) {
spA4->floor.head = SS_NULL;
spA4->wall.head = SS_NULL;
spA4->ceiling.head = SS_NULL;
}
polyMax = colHeader->nbPolygons;
vtxList = colHeader->vtxList;
polyList = colHeader->polyList;
@ -1377,7 +1385,6 @@ u32 func_8003BB18(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLook
for (polyIdx = 0; polyIdx < polyMax; polyIdx++) {
func_8003B218(colCtx, vtxList, polyList, &sxMin, &syMin, &szMin, &sxMax, &syMax, &szMax, polyIdx);
spA4 = szMin * sp98 + lookupTbl;
curSubdivMin.z = (colCtx->subdivLength.z * szMin + colCtx->minBounds.z) - BGCHECK_SUBDIV_OVERLAP;
curSubdivMax.z = curSubdivMin.z + subdivLengthZ;
@ -1446,6 +1453,7 @@ s32 BgCheck_TryGetCustomMemsize(s32 sceneId, u32* memSize) {
{ SCENE_HIDAN, 0x198C8 }, { SCENE_GANON_BOSS, 0x84C8 },
};
s32 i;
for (i = 0; i < ARRAY_COUNT(sceneMemList); i++) {
if (sceneId == sceneMemList[i].sceneId) {
*memSize = sceneMemList[i].memSize;
@ -1493,17 +1501,18 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
colCtx->colHeader = colHeader;
customNodeListMax = -1;
osSyncPrintf("/*---------------- BGCheck バッファーメモリサイズ -------------*/\n");
// /*---------------- BGCheck Buffer Memory Size -------------*/\n
osSyncPrintf("/*---------------- BGCheck バッファーメモリサイズ -------------*/\n");
if (YREG(15) == 0x10 || YREG(15) == 0x20 || YREG(15) == 0x30 || YREG(15) == 0x40) {
if (globalCtx->sceneNum == SCENE_MALON_STABLE) {
osSyncPrintf("/* BGCheck LonLonサイズ %dbyte */\n", 0x3520);
// /* BGCheck LonLon Size %dbyte */\n
osSyncPrintf("/* BGCheck LonLonサイズ %dbyte */\n", 0x3520);
colCtx->memSize = 0x3520;
} else {
osSyncPrintf("/* BGCheck ミニサイズ %dbyte */\n", 0x4E20);
// /* BGCheck Mini Size %dbyte */\n
osSyncPrintf("/* BGCheck ミニサイズ %dbyte */\n", 0x4E20);
colCtx->memSize = 0x4E20;
}
colCtx->dyna.polyNodesMax = 500;
@ -1514,8 +1523,8 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
colCtx->subdivAmount.z = 2;
} else if (BgCheck_IsSpotScene(globalCtx) == true) {
colCtx->memSize = 0xF000;
osSyncPrintf("/* BGCheck Spot用サイズ %dbyte */\n", 0xF000);
// /* BGCheck Spot Size %dbyte */\n
osSyncPrintf("/* BGCheck Spot用サイズ %dbyte */\n", 0xF000);
colCtx->dyna.polyNodesMax = 1000;
colCtx->dyna.polyListMax = 512;
colCtx->dyna.vtxListMax = 512;
@ -1528,8 +1537,8 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
} else {
colCtx->memSize = 0x1CC00;
}
osSyncPrintf("/* BGCheck ノーマルサイズ %dbyte */\n", colCtx->memSize);
// /* BGCheck Normal Size %dbyte */\n
osSyncPrintf("/* BGCheck ノーマルサイズ %dbyte */\n", colCtx->memSize);
colCtx->dyna.polyNodesMax = 1000;
colCtx->dyna.polyListMax = 512;
colCtx->dyna.vtxListMax = 512;
@ -1781,6 +1790,7 @@ f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, V
s32 bgId;
result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, &bgId, pos, NULL, 0x1C, 1.0f);
if (tempPoly != NULL) {
*outPoly = *tempPoly;
}
@ -1793,9 +1803,8 @@ f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, V
*/
f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos) {
CollisionPoly* tempPoly;
f32 result;
f32 result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, bgId, pos, NULL, 0x1C, 1.0f);
result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, bgId, pos, NULL, 0x1C, 1.0f);
if (tempPoly != NULL) {
*outPoly = *tempPoly;
}
@ -1866,12 +1875,14 @@ s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
dx = posNext->x - posPrev->x;
dy = posNext->y - posPrev->y;
dz = posNext->z - posPrev->z;
if (BgCheck_PosErrorCheck(posNext, "../z_bgcheck.c", 4831) == true ||
BgCheck_PosErrorCheck(posPrev, "../z_bgcheck.c", 4832) == true) {
if (actor != NULL) {
osSyncPrintf("こいつ,pself_actor->name %d\n", actor->id);
}
}
// if there's movement on the xz plane, and argA flag is 0,
if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) {
if ((checkHeight + dy) < 5.0f) {
@ -1934,6 +1945,7 @@ s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
}
}
}
sphCenter = *posResult;
dynaPolyCollision = false;
sphCenter.y += checkHeight;
@ -2109,14 +2121,14 @@ s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos,
s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 chkDist,
u32 bccFlags) {
StaticLookup* lookupTbl;
StaticLookup* lookupTbl = colCtx->lookupTbl;
StaticLookup* iLookup;
s32 subdivMin[3];
s32 subdivMax[3];
s32 i;
s32 result;
f32 distSq;
Vec3f posBTemp;
Vec3f posBTemp = *posB;
Vec3f sectorMin;
Vec3f sectorMax;
s32 k;
@ -2125,8 +2137,6 @@ s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, V
StaticLookup* jLookup;
s32 temp_lo;
lookupTbl = colCtx->lookupTbl;
posBTemp = *posB;
*outBgId = BGCHECK_SCENE;
if (BgCheck_PosErrorCheck(posA, "../z_bgcheck.c", 5334) == true ||
BgCheck_PosErrorCheck(posB, "../z_bgcheck.c", 5335) == true) {
@ -2138,8 +2148,8 @@ s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, V
}
BgCheck_ResetPolyCheckTbl(&colCtx->polyNodes, colCtx->colHeader->nbPolygons);
BgCheck_GetStaticLookupIndicesFromPos(colCtx, posA, &subdivMin);
BgCheck_GetStaticLookupIndicesFromPos(colCtx, &posBTemp, &subdivMax);
BgCheck_GetStaticLookupIndicesFromPos(colCtx, posA, (Vec3i*)&subdivMin);
BgCheck_GetStaticLookupIndicesFromPos(colCtx, &posBTemp, (Vec3i*)&subdivMax);
*posResult = *posB;
result = false;
distSq = 1.0e38f;
@ -2209,9 +2219,8 @@ s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, V
* Get bccFlags
*/
u32 BgCheck_GetBccFlags(s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32 chkDyna) {
u32 result;
u32 result = 0;
result = 0;
if (chkWall) {
result = BGCHECK_CHECK_WALL;
}
@ -2345,14 +2354,13 @@ s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionP
osSyncPrintf("こいつ,pself_actor->name %d\n", actor->id);
}
}
lookup = BgCheck_GetStaticLookup(colCtx, colCtx->lookupTbl, center);
if (lookup == NULL) {
return false;
} else {
if (BgCheck_SphVsFirstStaticPoly(lookup, xpFlags, colCtx, center, radius, outPoly, bciFlags) ||
BgCheck_SphVsFirstDynaPoly(colCtx, xpFlags, outPoly, outBgId, center, radius, actor, bciFlags)) {
return true;
}
} else if (BgCheck_SphVsFirstStaticPoly(lookup, xpFlags, colCtx, center, radius, outPoly, bciFlags) ||
BgCheck_SphVsFirstDynaPoly(colCtx, xpFlags, outPoly, outBgId, center, radius, actor, bciFlags)) {
return true;
}
return false;
}
@ -2604,9 +2612,8 @@ void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor,
CollisionHeader* colHeader) {
s32 bgId;
s32 foundSlot;
s32 foundSlot = false;
foundSlot = false;
for (bgId = 0; bgId < BG_ACTOR_MAX; bgId++) {
if (!(dyna->bgActorFlags[bgId] & 1)) {
dyna->bgActorFlags[bgId] |= 1;
@ -2636,12 +2643,12 @@ s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Ac
* Gets the actor assigned to `bgId`
* possible orginal name: DynaPolyInfo_getActor
*/
Actor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) {
DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) {
if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & 1) ||
colCtx->dyna.bgActorFlags[bgId] & 2) {
return NULL;
}
return colCtx->dyna.bgActors[bgId].actor;
return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor;
}
void func_8003EBF8(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
@ -2700,7 +2707,7 @@ void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna
return;
}
}
actor = (DynaPolyActor*)DynaPoly_GetActor(&globalCtx->colCtx, bgId);
actor = DynaPoly_GetActor(&globalCtx->colCtx, bgId);
if (actor != NULL) {
actor->bgId = BGACTOR_NEG_ONE;
@ -2768,6 +2775,7 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3
(dyna->polyListMax >= *polyStartIndex + pbgdata->nbPolygons)
? (void)0
: __assert("pdyna_poly_info->poly_num >= *pstart_poly_index + pbgdata->poly_num", "../z_bgcheck.c", 6687);
(dyna->vtxListMax >= *vtxStartIndex + pbgdata->nbVertices)
? (void)0
: __assert("pdyna_poly_info->vert_num >= *pstart_vert_index + pbgdata->vtx_num", "../z_bgcheck.c", 6688);
@ -2898,13 +2906,13 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3
}
void func_8003F8EC(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor) {
Actor* dynaActor;
DynaPolyActor* dynaActor;
s32 i;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if ((dyna->bgActorFlags[i] & 1)) {
dynaActor = DynaPoly_GetActor(&globalCtx->colCtx, i);
if (dynaActor != NULL && dynaActor == actor) {
if (dynaActor != NULL && &dynaActor->actor == actor) {
func_800434A0((DynaPolyActor*)actor);
return;
}
@ -2943,7 +2951,7 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("DynaPolyInfo_setup():削除 index=%d\n", i);
osSyncPrintf(VT_RST);
actor = (DynaPolyActor*)DynaPoly_GetActor(&globalCtx->colCtx, i);
actor = DynaPoly_GetActor(&globalCtx->colCtx, i);
if (actor == NULL) {
return;
}
@ -3044,7 +3052,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
f32 intersect2;
s32 i2;
s32 pauseState;
Actor* actor;
DynaPolyActor* dynaActor;
s32 pad;
Vec3f polyVtx[3];
Vec3f polyNorm;
@ -3110,8 +3118,8 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
}
}
actor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId);
if ((result != BGCHECK_Y_MIN) && (actor != NULL) && (dynaRaycast->globalCtx != NULL)) {
dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId);
if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->globalCtx != NULL)) {
pauseState = dynaRaycast->globalCtx->pauseCtx.state != 0;
if (pauseState == 0) {
pauseState = dynaRaycast->globalCtx->pauseCtx.flag != 0;
@ -3192,6 +3200,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo
if (ssList->head == SS_NULL) {
return result;
}
resultPos = *pos;
curNode = &dyna->polyNodes.tbl[ssList->head];
@ -3419,12 +3428,10 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl
f32 nx;
f32 ny;
f32 nz;
s32 result;
s32 result = false;
f32 intersectDist;
u16 padding;
result = false;
if (ssList->head == SS_NULL) {
return false;
}
@ -3482,11 +3489,10 @@ s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, V
s32 i = 0;
s32 result = false;
f32 resultY;
f32 tempY;
f32 tempY = chkDist + pos->y;
BgActor* bgActor;
CollisionPoly* poly;
tempY = chkDist + pos->y;
resultY = tempY;
for (i = 0; i < BG_ACTOR_MAX; i++) {
@ -3620,7 +3626,8 @@ s32 func_80041240(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* pos
s32 i;
s32 result = false;
Linef line;
f32 ay, by;
f32 ay;
f32 by;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if (colCtx->dyna.bgActorFlags[i] & 1) {
@ -3770,11 +3777,10 @@ void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) {
* SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders
*/
void func_800418D0(CollisionContext* colCtx, GlobalContext* globalCtx) {
DynaCollisionContext* dyna;
DynaCollisionContext* dyna = &colCtx->dyna;
s32 i;
u16 flag;
dyna = &colCtx->dyna;
for (i = 0; i < BG_ACTOR_MAX; i++) {
flag = dyna->bgActorFlags[i];
if ((flag & 1) && !(flag & 2)) {
@ -3842,11 +3848,10 @@ u16 func_80041A4C(CollisionContext* colCtx, u32 camId, s32 bgId) {
* SurfaceType return cameraSType
*/
u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
CamData* camData;
SurfaceType* surfaceTypes;
colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
if (colHeader == NULL) {
return 0;
}
@ -3865,10 +3870,9 @@ u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s3
* CamData Get number of cameras
*/
u16 func_80041B24(CollisionContext* colCtx, u32 camId, s32 bgId) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
CamData* camData;
colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
if (colHeader == NULL) {
return 0;
}
@ -3884,11 +3888,10 @@ u16 func_80041B24(CollisionContext* colCtx, u32 camId, s32 bgId) {
* SurfaceType Get number of cameras
*/
u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
CamData* camData;
SurfaceType* surfaceTypes;
colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
if (colHeader == NULL) {
return 0;
}
@ -3907,10 +3910,9 @@ u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32
* CamData Get camPosData
*/
Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
CamData* cameraDataList;
colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
if (colHeader == NULL) {
return NULL;
}
@ -3925,11 +3927,10 @@ Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId) {
* SurfaceType Get camPosData
*/
Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
CamData* camData;
SurfaceType* surfaceTypes;
colHeader = BgCheck_GetCollisionHeader(colCtx, bgId);
if (colHeader == NULL) {
return NULL;
}
@ -4036,9 +4037,8 @@ u32 func_80041F10(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
* SurfaceType Get Poly Sfx
*/
u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
s32 id;
s32 id = func_80041F10(colCtx, poly, bgId);
id = func_80041F10(colCtx, poly, bgId);
if (id < 0 || id > 13) {
return NA_SE_PL_WALK_GROUND - SFX_FLAG;
}
@ -4079,6 +4079,7 @@ u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly,
*/
s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
u32 flags;
if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) {
return true;
}
@ -4092,6 +4093,7 @@ s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* pol
*/
s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
u32 flags;
if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) {
return true;
}
@ -4105,6 +4107,7 @@ s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly*
*/
s32 SurfaceType_IsConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
u32 flags;
if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) {
return true;
}
@ -4174,11 +4177,10 @@ s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32
*/
s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = colCtx->colHeader;
u32 room;
WaterBox* curWaterBox;
colHeader = colCtx->colHeader;
if (colHeader->nbWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) {
return false;
}
@ -4186,7 +4188,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->nbWaterBoxes;
curWaterBox++) {
room = (curWaterBox->properties >> 13) & 0x3F;
if (room == globalCtx->roomCtx.curRoom.num || room == 0x3F) {
if (room == (u32)globalCtx->roomCtx.curRoom.num || room == 0x3F) {
if ((curWaterBox->properties & 0x80000) == 0) {
if (curWaterBox->xMin < x && x < curWaterBox->xMin + curWaterBox->xLength) {
if (curWaterBox->zMin < z && z < curWaterBox->zMin + curWaterBox->zLength) {
@ -4209,14 +4211,12 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
*/
s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist,
WaterBox** outWaterBox) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = colCtx->colHeader;
s32 room;
s32 i;
WaterBox* waterBox;
WaterBox* waterBoxList; // unused, needed for matching
WaterBox* waterBoxList = colHeader->waterBoxes; // unused, needed for matching
colHeader = colCtx->colHeader;
waterBoxList = colHeader->waterBoxes;
if (colHeader->nbWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) {
*outWaterBox = NULL;
return -1;
@ -4253,6 +4253,7 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec
*/
u32 WaterBox_GetCamDataIndex(CollisionContext* colCtx, WaterBox* waterBox) {
u32 prop = waterBox->properties >> 0;
return prop & 0xFF;
}
@ -4260,12 +4261,9 @@ u32 WaterBox_GetCamDataIndex(CollisionContext* colCtx, WaterBox* waterBox) {
* WaterBox get CamData cameraSType
*/
u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox) {
s32 camId;
CamData* camData;
s32 camId = WaterBox_GetCamDataIndex(colCtx, waterBox);
CamData* camData = colCtx->colHeader->cameraDataList;
camId = WaterBox_GetCamDataIndex(colCtx, waterBox);
camData = colCtx->colHeader->cameraDataList;
if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) {
return 0;
}
@ -4289,11 +4287,10 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox)
*/
s32 func_800425B0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) {
CollisionHeader* colHeader;
CollisionHeader* colHeader = colCtx->colHeader;
u32 room;
WaterBox* curWaterBox;
colHeader = colCtx->colHeader;
if (colHeader->nbWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) {
return false;
}
@ -4301,7 +4298,7 @@ s32 func_800425B0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->nbWaterBoxes;
curWaterBox++) {
room = (curWaterBox->properties >> 0xD) & 0x3F;
if ((room == globalCtx->roomCtx.curRoom.num) || (room == 0x3F)) {
if ((room == (u32)globalCtx->roomCtx.curRoom.num) || (room == 0x3F)) {
if ((curWaterBox->properties & 0x80000) != 0) {
if (curWaterBox->xMin < x && x < (curWaterBox->xMin + curWaterBox->xLength)) {
if (curWaterBox->zMin < z && z < (curWaterBox->zMin + curWaterBox->zLength)) {
@ -4470,10 +4467,9 @@ void BgCheck_DrawStaticPoly(GlobalContext* globalCtx, CollisionContext* colCtx,
*/
void BgCheck_DrawStaticPolyList(GlobalContext* globalCtx, CollisionContext* colCtx, SSList* ssList, u8 r, u8 g, u8 b) {
SSNode* curNode;
CollisionPoly* polyList;
CollisionPoly* polyList = colCtx->colHeader->polyList;
s16 curPolyId;
polyList = colCtx->colHeader->polyList;
if (ssList->head != SS_NULL) {
curNode = &colCtx->polyNodes.tbl[ssList->head];
while (true) {
@ -4491,11 +4487,9 @@ void BgCheck_DrawStaticPolyList(GlobalContext* globalCtx, CollisionContext* colC
* Draw scene collision
*/
void BgCheck_DrawStaticCollision(GlobalContext* globalCtx, CollisionContext* colCtx) {
Player* player;
StaticLookup* lookup;
Player* player = PLAYER;
StaticLookup* lookup = BgCheck_GetNearestStaticLookup(colCtx, colCtx->lookupTbl, &player->actor.world.pos);
player = PLAYER;
lookup = BgCheck_GetNearestStaticLookup(colCtx, colCtx->lookupTbl, &player->actor.world.pos);
if (AREG(23) != 0) {
BgCheck_DrawStaticPolyList(globalCtx, colCtx, &lookup->floor, 0, 0, 255);
}

View file

@ -403,7 +403,7 @@ f32 Camera_GetFloorY(Camera* camera, Vec3f* pos) {
* Gets the position of the floor from `pos`, and if the floor is considered not solid,
* it checks the next floor below that up to 3 times. Returns the normal of the floor into `norm`
*/
f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, u32* bgId) {
f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) {
CollisionPoly* floorPoly;
CollisionContext* colCtx = &camera->globalCtx->colCtx;
f32 floorY;
@ -454,7 +454,7 @@ Vec3s* Camera_GetCamBGData(Camera* camera) {
* Gets the scene's camera index for the poly `poly`, returns -1 if
* there is no camera data for that poly.
*/
s32 Camera_GetDataIdxForPoly(Camera* camera, u32* bgId, CollisionPoly* poly) {
s32 Camera_GetDataIdxForPoly(Camera* camera, s32* bgId, CollisionPoly* poly) {
s32 camDataIdx;
PosRot playerPosRot;
s32 ret;
@ -577,7 +577,7 @@ s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) {
f32 phi_f18;
f32 sinYaw;
f32 cosYaw;
u32 bgId;
s32 bgId;
f32 sp30;
f32 sp2C;
f32 phi_f16;
@ -2576,8 +2576,8 @@ s32 Camera_Jump3(Camera* camera) {
break;
}
// unused
spB0 = *eye;
spB0 = *eye; // unused
(void)spB0; // suppresses set but unused warning
spC4 = PCT(OREG(25)) * camera->speedRatio;
spC0 = camera->speedRatio * PCT(OREG(26));
@ -3332,7 +3332,7 @@ s32 Camera_KeepOn3(Camera* camera) {
sCameraInterfaceFlags = keep3->flags;
if (camera->animState == 0 || camera->animState == 0xA || camera->animState == 0x14) {
colChkActors[0] = camera->target;
colChkActors[1] = camera->player;
colChkActors[1] = &camera->player->actor;
camera->animState++;
anim->target = camera->target;
temp_f0 = (keep3->maxDist < targetToPlayerDir.r ? 1.0f : targetToPlayerDir.r / keep3->maxDist);
@ -3383,7 +3383,7 @@ s32 Camera_KeepOn3(Camera* camera) {
if (!(keep3->flags & 0x80)) {
while (i < angleCnt) {
if (!CollisionCheck_LineOCCheck(camera->globalCtx, &camera->globalCtx->colChkCtx, &anim->atTarget,
&lineChkPointB, &colChkActors, 2) &&
&lineChkPointB, colChkActors, 2) &&
!Camera_BGCheck(camera, &anim->atTarget, &lineChkPointB)) {
break;
}
@ -3770,6 +3770,7 @@ s32 Camera_KeepOn0(Camera* camera) {
*eye = *eyeNext;
sceneCamRot = BGCAM_ROT(sceneCamData); // unused
(void)sceneCamRot; // suppresses set but unused warning
fov = BGCAM_FOV(sceneCamData);
if (fov == -1) {
@ -4949,7 +4950,8 @@ s32 Camera_Unique7(Camera* camera) {
Camera_Vec3sToVec3f(eyeNext, &BGCAM_POS(sceneCamData));
*eye = *eyeNext;
sceneCamRot = BGCAM_ROT(sceneCamData);
sceneCamRot = BGCAM_ROT(sceneCamData); // unused
(void)sceneCamRot; // suppresses set but unused warning
OLib_Vec3fDiffToVecSphGeo(&playerPosEyeOffset, eye, &playerPosRot->pos);
@ -7307,7 +7309,7 @@ Vec3s* Camera_Update(Vec3s* outVec, Camera* camera) {
Vec3f viewUp;
f32 viewFov;
Vec3f spAC;
u32 bgCheckId;
s32 bgId;
f32 playerGroundY;
f32 playerXZSpeed;
VecSph eyeAtAngle;
@ -7344,14 +7346,14 @@ Vec3s* Camera_Update(Vec3s* outVec, Camera* camera) {
spAC.y += Player_GetHeight(camera->player);
playerGroundY = BgCheck_EntityRaycastFloor5(camera->globalCtx, &camera->globalCtx->colCtx, &playerFloorPoly,
&bgCheckId, &camera->player->actor, &spAC);
&bgId, &camera->player->actor, &spAC);
if (playerGroundY != BGCHECK_Y_MIN) {
// player is above ground.
sOOBTimer = 0;
camera->floorNorm.x = COLPOLY_GET_NORMAL(playerFloorPoly->normal.x);
camera->floorNorm.y = COLPOLY_GET_NORMAL(playerFloorPoly->normal.y);
camera->floorNorm.z = COLPOLY_GET_NORMAL(playerFloorPoly->normal.z);
camera->bgCheckId = bgCheckId;
camera->bgCheckId = bgId;
camera->playerGroundY = playerGroundY;
} else {
// player is not above ground.
@ -7376,10 +7378,10 @@ Vec3s* Camera_Update(Vec3s* outVec, Camera* camera) {
if ((camera->unk_14C & 1) && (camera->unk_14C & 4) && (!(camera->unk_14C & 0x400)) &&
(!(camera->unk_14C & 0x200) || (player->currentBoots == PLAYER_BOOTS_IRON)) &&
(!(camera->unk_14C & (s16)0x8000)) && (playerGroundY != BGCHECK_Y_MIN)) {
camDataIdx = Camera_GetDataIdxForPoly(camera, &bgCheckId, playerFloorPoly);
camDataIdx = Camera_GetDataIdxForPoly(camera, &bgId, playerFloorPoly);
if (camDataIdx != -1) {
camera->nextBGCheckId = bgCheckId;
if (bgCheckId == BGCHECK_SCENE) {
camera->nextBGCheckId = bgId;
if (bgId == BGCHECK_SCENE) {
camera->nextCamDataIdx = camDataIdx;
}
}
@ -7481,7 +7483,7 @@ Vec3s* Camera_Update(Vec3s* outVec, Camera* camera) {
// setting bgCheckId to the ret of Quake_Calc, and checking that
// is required, it doesn't make too much sense though.
if ((bgCheckId = Quake_Calc(camera, &quake), bgCheckId != 0) && (camera->setting != CAM_SET_ITEM2)) {
if ((bgId = Quake_Calc(camera, &quake), bgId != 0) && (camera->setting != CAM_SET_ITEM2)) {
viewAt.x = camera->at.x + quake.atOffset.x;
viewAt.y = camera->at.y + quake.atOffset.y;
viewAt.z = camera->at.z + quake.atOffset.z;

View file

@ -1293,7 +1293,6 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colChk
*/
s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider,
s32 index) {
if (!(collider->shape <= COLSHAPE_QUAD)) {
__assert("pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3153);
}
@ -1367,7 +1366,6 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colChk
*/
s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider,
s32 index) {
if (func_800C0D28(globalCtx) == 1) {
return -1;
}
@ -1591,9 +1589,8 @@ void CollisionCheck_RedBloodUnused(GlobalContext* globalCtx, Collider* collider,
* Plays sound effects and displays hitmarks for solid-type AC colliders (METAL, WOOD, HARD, and TREE)
*/
void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Collider* collider, Vec3f* hitPos) {
s32 flags;
s32 flags = info->toucherFlags & TOUCH_SFX_NONE;
flags = info->toucherFlags & TOUCH_SFX_NONE;
if (flags == TOUCH_SFX_NORMAL && collider->colType != COLTYPE_METAL) {
EffectSsHitMark_SpawnFixedScale(globalCtx, EFFECT_HITMARK_WHITE, hitPos);
if (collider->actor == NULL) {
@ -1715,7 +1712,6 @@ void CollisionCheck_SetBounce(Collider* at, Collider* ac) {
*/
s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac,
ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos) {
if (ac->acFlags & AC_HARD && at->actor != NULL && ac->actor != NULL) {
CollisionCheck_SetBounce(at, ac);
}
@ -2477,10 +2473,12 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex
if (CollisionCheck_NoSharedFlags(&at->info, &ac->info) == 1) {
return;
}
Math3D_TriNorm(&D_8015E5A8[0], &at->dim.quad[2], &at->dim.quad[3], &at->dim.quad[1]);
Math3D_TriNorm(&D_8015E5A8[1], &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]);
Math3D_TriNorm(&D_8015E530[0], &ac->dim.quad[2], &ac->dim.quad[3], &ac->dim.quad[1]);
Math3D_TriNorm(&D_8015E530[1], &ac->dim.quad[2], &ac->dim.quad[1], &ac->dim.quad[0]);
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (Math3D_TriVsTriIntersect(&D_8015E5A8[j], &D_8015E530[i], &D_8015E598) == 1) {

View file

@ -34,7 +34,7 @@ InputCombo inputCombos[REG_GROUPS] = {
char regChar[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb";
// initialize GameInfo
void func_800636C0() {
void func_800636C0(void) {
s32 i;
gGameInfo = (GameInfo*)SystemArena_MallocDebug(sizeof(GameInfo), "../z_debug.c", 260);
@ -67,7 +67,7 @@ void func_8006376C(u8 x, u8 y, u8 colorId, const char* text) {
i = 0;
bufText = buf->text;
while (*bufText++ = *text++) {
while ((*bufText++ = *text++)) {
if (i++ > 0x14) {
break;
}
@ -188,14 +188,11 @@ void func_8006390C(Input* input) {
// Draw Memory Viewer
void func_80063C04(GfxPrint* gfxPrint) {
s32 i;
s32 page;
s32 regGroup;
s32 test; // removing affects stack
s32 page = (gGameInfo->regPage * REG_PER_PAGE) - REG_PER_PAGE;
s32 regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
s32 pad;
char name[3];
page = (gGameInfo->regPage * REG_PER_PAGE) - REG_PER_PAGE;
regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
// set up register name string
name[0] = 'R';
name[1] = regChar[gGameInfo->regGroup]; // r_group type char
@ -242,7 +239,7 @@ void func_80063D7C(GraphicsContext* gfxCtx) {
Graph_BranchDlist(sp78, sp7C);
POLY_OPA_DISP = sp7C;
if (0) {}
if (1) {}
CLOSE_DISPS(gfxCtx, "../z_debug.c", 664);

View file

@ -372,7 +372,7 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
}
break;
case 35:
func_800EE824(csCtx);
func_800EE824();
csCtx->frames = cmd->startFrame - 1;
break;
}

View file

@ -113,10 +113,9 @@ s32 EffectShieldParticle_Update(void* thisx) {
}
void EffectShieldParticle_GetColors(EffectShieldParticle* this, Color_RGBA8* primColor, Color_RGBA8* envColor) {
s32 halfDuration;
s32 halfDuration = this->duration * 0.5f;
f32 ratio;
halfDuration = this->duration * 0.5f;
if (halfDuration == 0) {
primColor->r = this->primColorStart.r;
primColor->g = this->primColorStart.g;
@ -186,14 +185,10 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) {
MtxF sp104;
MtxF spC4;
MtxF sp84;
f32 temp1;
f32 temp2;
f32 temp3;
f32 temp1 = (s16)((elem->endX + elem->startX) * 0.5f);
f32 temp2 = elem->endX - elem->startX;
f32 temp3 = (s16)((temp2 * (1.0f / 64.0f)) / 0.02f);
temp1 = (s16)((elem->endX + elem->startX) * 0.5f);
temp2 = elem->endX - elem->startX;
temp3 = (s16)((temp2 * (1.0f / 64.0f)) / 0.02f);
if (temp3 < 1.0f) {
temp3 = 1.0f;
}

View file

@ -132,7 +132,7 @@ s32 EffectSpark_Update(void* thisx) {
void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
Vtx* vertices;
EffectSpark* this = (EffectSpark*)thisx;
GlobalContext* globalCtx;
GlobalContext* globalCtx = Effect_GetGlobalCtx();
s32 i;
s32 j;
u8 sp1D3;
@ -153,8 +153,6 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
u8 sp1C4;
f32 ratio;
globalCtx = Effect_GetGlobalCtx();
if (1) {}
OPEN_DISPS(gfxCtx, "../z_eff_spark.c", 293);
@ -208,12 +206,10 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
MtxF spEC;
MtxF spAC;
MtxF sp6C;
EffectSparkElement* elem;
EffectSparkElement* elem = &this->elements[i];
Mtx* mtx;
f32 temp;
elem = &this->elements[i];
SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z);
temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) * 0.015625f;
SkinMatrix_SetScale(&spAC, temp, temp, 1.0f);

View file

@ -99,11 +99,9 @@ void Effect_InitContext(GlobalContext* globalCtx) {
void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) {
s32 i;
u32 slotFound;
void* effect;
EffectStatus* status;
void* effect = NULL;
EffectStatus* status = NULL;
effect = NULL;
status = NULL;
*pIndex = TOTAL_EFFECT_COUNT;
if (func_800C0D28(globalCtx) != 1) {

View file

@ -294,10 +294,9 @@ void EffectSs_Draw(GlobalContext* globalCtx, s32 index) {
// original name: "EffectSoftSprite2_disp"
void EffectSs_DrawAll(GlobalContext* globalCtx) {
Lights* lights;
Lights* lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx);
s32 i;
lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx);
Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL);
Lights_Draw(lights, globalCtx->state.gfxCtx);

View file

@ -49,9 +49,7 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur
MtxF mfTrans11DA0;
s32 pad1;
Mtx* mtx;
void* object;
object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment;
void* object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment;
OPEN_DISPS(gfxCtx, "../z_effect_soft_sprite_old_init.c", 196);
@ -180,9 +178,8 @@ void func_80028858(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f*
void func_80028894(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel) {
s16 randAngle;
f32 rand;
f32 rand = Rand_ZeroOne() * randScale;
rand = Rand_ZeroOne() * randScale;
randAngle = (Rand_ZeroOne() * 65536.0f);
*newPos = *srcPos;
@ -408,9 +405,7 @@ void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f*
s16 scale, s16 scaleStep) {
Color_RGBA8 primColor = { 255, 255, 150, 255 };
Color_RGBA8 envColor = { 255, 0, 0, 0 };
s32 randOffset;
randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f;
s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f;
primColor.r += randOffset;
primColor.g += randOffset;

View file

@ -70,15 +70,12 @@ u32 func_8006BE88(ElfMessage** msgp) {
}
u32 func_8006BF1C(ElfMessage** msgp) {
ElfMessage* msg;
ElfMessage* msg = *msgp;
u32 sp44[10];
s32 temp1;
s32 temp2;
s32 temp1 = 0;
s32 temp2 = 0;
s32 temp3;
msg = *msgp;
temp1 = 0;
temp2 = 0;
do {
sp44[temp2] = ElfMessage_CheckCondition(msg);
temp1 += sp44[temp2];

View file

@ -83,9 +83,7 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
CollisionHeader* colHeader = NULL;
s32 pad;
EnAObj* this = THIS;
f32 sp28;
sp28 = 6.0f;
f32 sp28 = 6.0f;
this->textId = (thisx->params >> 8) & 0xFF;
thisx->params &= 0xFF;
@ -276,10 +274,9 @@ void func_8001D4A8(EnAObj* this, GlobalContext* globalCtx) {
this->dyna.actor.shape.rot.z = this->dyna.actor.shape.rot.z + (this->dyna.actor.world.rot.z >> 1);
if ((this->dyna.actor.speedXZ != 0.0f) && (this->dyna.actor.bgCheckFlags & 0x8)) {
if (1) { // Necessary to match
this->dyna.actor.world.rot.y =
((this->dyna.actor.wallYaw - this->dyna.actor.world.rot.y) + this->dyna.actor.wallYaw) - 0x8000;
}
this->dyna.actor.world.rot.y =
((this->dyna.actor.wallYaw - this->dyna.actor.world.rot.y) + this->dyna.actor.wallYaw) - 0x8000;
if (1) {} // Necessary to match
this->dyna.actor.bgCheckFlags &= ~0x8;
}

View file

@ -32,10 +32,10 @@ const ActorInit En_Item00_InitVars = {
// TODO: Define this section of .data here and rename the symbols
extern ColliderCylinderInit D_801154E0; // rename to sCylinderInit when data is moved
extern InitChainEntry D_8011550C[]; // rename to sInitChain when data is moved
extern Color_RGB8 D_80115510;
extern Color_RGB8 D_80115514;
extern UNK_TYPE D_80115518;
extern UNK_TYPE D_80115524;
extern Color_RGBA8 D_80115510;
extern Color_RGBA8 D_80115514;
extern Vec3f D_80115518;
extern Vec3f D_80115524;
extern u32 D_80115530[];
extern u32 D_80115544[];
extern u8 D_80115574[];
@ -50,16 +50,12 @@ void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc) {
void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
EnItem00* this = THIS;
s32 pad2;
f32 sp34;
f32 sp30;
s32 getItemId;
f32 sp34 = 980.0f;
f32 sp30 = 6.0f;
s32 getItemId = 0;
s16 spawnParam8000;
s32 pad3;
sp34 = 980.0f;
sp30 = 6.0f;
getItemId = 0;
spawnParam8000 = this->actor.params & 0x8000;
this->collectibleFlag = (this->actor.params & 0x3F00) >> 8;
@ -444,14 +440,11 @@ extern s16 D_80157D94;
void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
EnItem00* this = THIS;
s16* params;
s32 getItemId;
s16 sp3A;
s32 getItemId = 0;
s16 sp3A = 0;
Actor* dynaActor;
s16 i;
getItemId = 0;
sp3A = 0;
if (this->unk_15A > 0) {
this->unk_15A--;
}
@ -469,7 +462,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if (this->actor.gravity) {
if (this->actor.bgCheckFlags & 0x0003) {
// Separate symbols seem to be used here for 0x80157D90 since the loads and stores are completely separate
if (D_80157D90 != globalCtx->gameplayFrames) {
if ((u32)D_80157D90 != globalCtx->gameplayFrames) {
D_80157D90_ = globalCtx->gameplayFrames;
D_80157D94 = 0;
for (i = 0; i < BG_ACTOR_MAX; i++) {
@ -506,6 +499,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if ((this->actor.params == ITEM00_SHIELD_DEKU) || (this->actor.params == ITEM00_SHIELD_HYLIAN) ||
(this->actor.params == ITEM00_TUNIC_ZORA) || (this->actor.params == ITEM00_TUNIC_GORON)) {
f32 newUnkBC = Math_CosS(this->actor.shape.rot.x) * 37.0f;
this->actor.shape.yOffset = newUnkBC;
if (newUnkBC >= 0.0f) {
this->actor.shape.yOffset = this->actor.shape.yOffset;
@ -741,13 +735,12 @@ void func_8001EF30(EnItem00* this, GlobalContext* globalCtx) {
func_80093D18(globalCtx->state.gfxCtx);
func_8002EBCC(&this->actor, globalCtx, 0);
if (1) { // Necessary to match
if (this->actor.params <= ITEM00_RUPEE_RED) {
iconNb = this->actor.params;
} else {
iconNb = this->actor.params - 0x10;
}
if (this->actor.params <= ITEM00_RUPEE_RED) {
iconNb = this->actor.params;
} else {
iconNb = this->actor.params - 0x10;
}
if (1) {} // Necessary to match
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1562),
G_MTX_MODELVIEW | G_MTX_LOAD);
@ -763,9 +756,7 @@ void func_8001EF30(EnItem00* this, GlobalContext* globalCtx) {
* Draw Function used for most collectible types of En_Item00 (ammo, bombs, sticks, nuts, magic...).
*/
void func_8001F080(EnItem00* this, GlobalContext* globalCtx) {
s32 iconNb;
iconNb = this->actor.params - 3;
s32 iconNb = this->actor.params - 3;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1594);
@ -871,7 +862,7 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 pa
s16 param8000 = params & 0x8000;
s16 param3F00 = params & 0x3F00;
params = params & 0x3FFF;
params &= 0x3FFF;
if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) {
// TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf)
@ -915,7 +906,7 @@ EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 p
s16 param8000 = params & 0x8000;
s16 param3F00 = params & 0x3F00;
params = params & 0x3FFF;
params &= 0x3FFF;
if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) {
// TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf)
@ -946,12 +937,11 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
EnItem00* spawnedActor;
s16 dropQuantity;
s16 param8000;
s16 dropTableIndex;
s16 dropTableIndex = Rand_ZeroOne() * 16.0f;
u8 dropId;
dropTableIndex = Rand_ZeroOne() * 16.0f;
param8000 = params & 0x8000;
params = params & 0x7FFF;
params &= 0x7FFF;
if (fromActor != NULL) {
if (fromActor->dropFlag) {

View file

@ -64,6 +64,7 @@ void TransitionUnk_InitGraphics(TransitionUnk* this) {
}
}
}
gfx = this->gfx;
for (colTex = 0, col = 0; col < this->col; colTex += 0x20, col++) {
@ -83,6 +84,7 @@ void TransitionUnk_InitGraphics(TransitionUnk* this) {
row++;
}
}
gDPPipeSync(gfx++);
gSPEndDisplayList(gfx++);
@ -107,6 +109,7 @@ void TransitionUnk_Destroy(TransitionUnk* this) {
osSyncPrintf("fbdemo_cleanup(%08x)\n", this);
osSyncPrintf("msleep(100);\n");
Sleep_Msec(100);
if (this->unk_0C != NULL) {
SystemArena_FreeDebug(this->unk_0C, "../z_fbdemo.c", 180);
this->unk_0C = NULL;
@ -135,6 +138,7 @@ TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col) {
this->vtxFrame1 = SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 196);
this->vtxFrame2 = SystemArena_MallocDebug((row + 1) * sizeof(Vtx) * (col + 1), "../z_fbdemo.c", 197);
this->gfx = SystemArena_MallocDebug((this->col * (1 + this->row * 9) + 2) * sizeof(Gfx), "../z_fbdemo.c", 198);
if (this->unk_0C == NULL || this->vtxFrame1 == NULL || this->vtxFrame2 == NULL || this->gfx == NULL) {
osSyncPrintf("fbdemo_init allocation error\n");
if (this->unk_0C != NULL) {
@ -158,6 +162,7 @@ TransitionUnk* TransitionUnk_Init(TransitionUnk* this, s32 row, s32 col) {
TransitionUnk_InitGraphics(this);
TransitionUnk_InitData(this);
this->frame = 0;
return this;
}

View file

@ -280,8 +280,13 @@ Gfx sCircleDList[] = {
gsSPEndDisplayList(),
};
void TransitionCircle_Start(TransitionCircle* this) {
#define THIS ((TransitionCircle*)thisx)
void TransitionCircle_Start(void* thisx) {
TransitionCircle* this = THIS;
this->isDone = 0;
switch (this->effect) {
case 1:
this->texture = sCircleTexWave;
@ -332,15 +337,18 @@ void TransitionCircle_Start(TransitionCircle* this) {
guLookAt(&this->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
}
TransitionCircle* TransitionCircle_Init(TransitionCircle* this) {
void* TransitionCircle_Init(void* thisx) {
TransitionCircle* this = THIS;
bzero(this, sizeof(*this));
return this;
}
void TransitionCircle_Destroy(TransitionCircle* this) {
void TransitionCircle_Destroy(void* thisx) {
}
void TransitionCircle_Update(TransitionCircle* this, s32 updateRate) {
void TransitionCircle_Update(void* thisx, s32 updateRate) {
TransitionCircle* this = THIS;
s32 temp_t2;
s32 temp_t3;
@ -371,17 +379,18 @@ void TransitionCircle_Update(TransitionCircle* this, s32 updateRate) {
}
}
void TransitionCircle_Draw(TransitionCircle* this, Gfx** gfxP) {
void TransitionCircle_Draw(void* thisx, Gfx** gfxP) {
Gfx* gfx = *gfxP;
Mtx* modelView = this->modelView[this->frame];
char pad[4];
Mtx* modelView;
TransitionCircle* this = THIS;
Gfx* texScroll;
// These variables are a best guess based on the other transition types.
f32 tPos = 0.0f;
f32 rot = 0.0f;
f32 scale = 14.8f;
modelView = this->modelView[this->frame];
this->frame ^= 1;
gDPPipeSync(gfx++);
texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0x10, 0x40);
@ -412,11 +421,15 @@ void TransitionCircle_Draw(TransitionCircle* this, Gfx** gfxP) {
*gfxP = gfx;
}
s32 TransitionCircle_IsDone(TransitionCircle* this) {
s32 TransitionCircle_IsDone(void* thisx) {
TransitionCircle* this = THIS;
return this->isDone;
}
void TransitionCircle_SetType(TransitionCircle* this, s32 type) {
void TransitionCircle_SetType(void* thisx, s32 type) {
TransitionCircle* this = THIS;
if (type & 0x80) {
this->unk_14 = (type >> 5) & 0x1;
this->typeColor = (type >> 3) & 0x3;
@ -429,10 +442,14 @@ void TransitionCircle_SetType(TransitionCircle* this, s32 type) {
}
}
void TransitionCircle_SetColor(TransitionCircle* this, u32 color) {
void TransitionCircle_SetColor(void* thisx, u32 color) {
TransitionCircle* this = THIS;
this->color.rgba = color;
}
void TransitionCircle_SetEnvColor(TransitionCircle* this, u32 envColor) {
void TransitionCircle_SetEnvColor(void* thisx, u32 envColor) {
TransitionCircle* this = THIS;
this->envColor.rgba = envColor;
}

View file

@ -12,7 +12,11 @@ static Gfx sRCPSetupFade[] = {
gsSPEndDisplayList(),
};
void TransitionFade_Start(TransitionFade* this) {
#define THIS ((TransitionFade*)thisx)
void TransitionFade_Start(void* thisx) {
TransitionFade* this = THIS;
switch (this->fadeType) {
case 0:
break;
@ -27,17 +31,20 @@ void TransitionFade_Start(TransitionFade* this) {
this->isDone = 0;
}
TransitionFade* TransitionFade_Init(TransitionFade* this) {
void* TransitionFade_Init(void* thisx) {
TransitionFade* this = THIS;
bzero(this, sizeof(*this));
return this;
}
void TransitionFade_Destroy(TransitionFade* this) {
void TransitionFade_Destroy(void* thisx) {
}
void TransitionFade_Update(TransitionFade* this, s32 updateRate) {
void TransitionFade_Update(void* thisx, s32 updateRate) {
s32 alpha;
s16 newAlpha;
TransitionFade* this = THIS;
switch (this->fadeType) {
case 0:
@ -53,7 +60,7 @@ void TransitionFade_Update(TransitionFade* this, s32 updateRate) {
osSyncPrintf(VT_COL(RED, WHITE) "0除算! ZCommonGet fade_speed に0がはいってる" VT_RST);
}
alpha = (255.0f * this->fadeTimer) / (0, gSaveContext.fadeDuration);
alpha = (255.0f * this->fadeTimer) / ((void)0, gSaveContext.fadeDuration);
this->fadeColor.a = (this->fadeDirection != 0) ? 255 - alpha : alpha;
break;
case 2:
@ -76,11 +83,12 @@ void TransitionFade_Update(TransitionFade* this, s32 updateRate) {
}
}
void TransitionFade_Draw(TransitionFade* this, Gfx** gfxP) {
void TransitionFade_Draw(void* thisx, Gfx** gfxP) {
TransitionFade* this = THIS;
Gfx* gfx;
Color_RGBA8_u32* color;
if (this->fadeColor.a > 0) {
color = &this->fadeColor;
Color_RGBA8_u32* color = &this->fadeColor;
if (color->a > 0) {
gfx = *gfxP;
gSPDisplayList(gfx++, sRCPSetupFade);
gDPSetPrimColor(gfx++, 0, 0, color->r, color->g, color->b, color->a);
@ -90,15 +98,21 @@ void TransitionFade_Draw(TransitionFade* this, Gfx** gfxP) {
}
}
s32 TransitionFade_IsDone(TransitionFade* this) {
s32 TransitionFade_IsDone(void* thisx) {
TransitionFade* this = THIS;
return this->isDone;
}
void TransitionFade_SetColor(TransitionFade* this, u32 color) {
void TransitionFade_SetColor(void* thisx, u32 color) {
TransitionFade* this = THIS;
this->fadeColor.rgba = color;
}
void TransitionFade_SetType(TransitionFade* this, s32 type) {
void TransitionFade_SetType(void* thisx, s32 type) {
TransitionFade* this = THIS;
if (type == 1) {
this->fadeType = 1;
this->fadeDirection = 1;

View file

@ -20,7 +20,11 @@ Vtx sTriforceVTX[] = {
VTX(32000, -32000, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), VTX(-32000, -32000, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF),
};
void TransitionTriforce_Start(TransitionTriforce* this) {
#define THIS ((TransitionTriforce*)thisx)
void TransitionTriforce_Start(void* thisx) {
TransitionTriforce* this = THIS;
switch (this->state) {
case 1:
case 2:
@ -30,7 +34,9 @@ void TransitionTriforce_Start(TransitionTriforce* this) {
this->transPos = 0.03f;
}
TransitionTriforce* TransitionTriforce_Init(TransitionTriforce* this) {
void* TransitionTriforce_Init(void* thisx) {
TransitionTriforce* this = THIS;
bzero(this, sizeof(*this));
guOrtho(&this->projection, -160.0f, 160.0f, -120.0f, 120.0f, -1000.0f, 1000.0f, 1.0f);
this->transPos = 1.0f;
@ -40,12 +46,14 @@ TransitionTriforce* TransitionTriforce_Init(TransitionTriforce* this) {
return this;
}
void TransitionTriforce_Destroy(TransitionTriforce* this) {
void TransitionTriforce_Destroy(void* thisx) {
}
void TransitionTriforce_Update(TransitionTriforce* this, s32 updateRate) {
void TransitionTriforce_Update(void* thisx, s32 updateRate) {
TransitionTriforce* this = THIS;
f32 temp_f0;
s32 i;
for (i = updateRate; i > 0; i--) {
if (this->state == 1) {
this->transPos = CLAMP_MIN(this->transPos * (1.0f - this->step), 0.03f);
@ -59,30 +67,33 @@ void TransitionTriforce_Update(TransitionTriforce* this, s32 updateRate) {
}
}
void TransitionTriforce_SetColor(TransitionTriforce* this, u32 color) {
void TransitionTriforce_SetColor(void* thisx, u32 color) {
TransitionTriforce* this = THIS;
this->color.rgba = color;
}
void TransitionTriforce_SetType(TransitionTriforce* this, s32 type) {
void TransitionTriforce_SetType(void* thisx, s32 type) {
TransitionTriforce* this = THIS;
this->fadeDirection = type;
}
// unused
void TransitionTriforce_SetState(TransitionTriforce* this, s32 state) {
void TransitionTriforce_SetState(void* thisx, s32 state) {
TransitionTriforce* this = THIS;
this->state = state;
}
void TransitionTriforce_Draw(TransitionTriforce* this, Gfx** gfxP) {
void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) {
Gfx* gfx = *gfxP;
Mtx* modelView;
f32 scale;
char pad[4];
TransitionTriforce* this = THIS;
s32 pad;
f32 rotation = this->transPos * 360.0f;
char pad2[4];
f32 rotation;
rotation = this->transPos * 360.0f;
modelView = this->modelView[this->frame];
scale = this->transPos * 0.625f;
this->frame ^= 1;
@ -125,8 +136,11 @@ void TransitionTriforce_Draw(TransitionTriforce* this, Gfx** gfxP) {
*gfxP = gfx;
}
s32 TransitionTriforce_IsDone(TransitionTriforce* this) {
s32 TransitionTriforce_IsDone(void* thisx) {
TransitionTriforce* this = THIS;
s32 ret = 0;
if (this->state == 1 || this->state == 2) {
return this->transPos <= 0.03f;

View file

@ -161,8 +161,13 @@ Gfx sWipeSyncDList[] = {
gsSPEndDisplayList(),
};
void TransitionWipe_Start(TransitionWipe* this) {
#define THIS ((TransitionWipe*)thisx)
void TransitionWipe_Start(void* thisx) {
TransitionWipe* this = THIS;
this->isDone = 0;
if (this->direction) {
this->texY = 0x14D;
} else {
@ -173,15 +178,18 @@ void TransitionWipe_Start(TransitionWipe* this) {
guLookAt(&this->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
}
TransitionWipe* TransitionWipe_Init(TransitionWipe* this) {
void* TransitionWipe_Init(void* thisx) {
TransitionWipe* this = THIS;
bzero(this, sizeof(*this));
return this;
}
void TransitionWipe_Destroy(TransitionWipe* this) {
void TransitionWipe_Destroy(void* thisx) {
}
void TransitionWipe_Update(TransitionWipe* this, s32 updateRate) {
void TransitionWipe_Update(void* thisx, s32 updateRate) {
TransitionWipe* this = THIS;
u8 unk1419;
if (this->direction != 0) {
@ -201,13 +209,15 @@ void TransitionWipe_Update(TransitionWipe* this, s32 updateRate) {
}
}
void TransitionWipe_Draw(TransitionWipe* this, Gfx** gfxP) {
void TransitionWipe_Draw(void* thisx, Gfx** gfxP) {
Gfx* gfx = *gfxP;
Mtx* modelView;
char pad[0x14];
TransitionWipe* this = THIS;
s32 pad[4];
Gfx* tex;
modelView = this->modelView[this->frame];
this->frame ^= 1;
guScale(&modelView[0], 0.56f, 0.56f, 1.0f);
guRotate(&modelView[1], 0.0f, 0.0f, 0.0f, 1.0f);
@ -227,11 +237,15 @@ void TransitionWipe_Draw(TransitionWipe* this, Gfx** gfxP) {
*gfxP = gfx;
}
s32 TransitionWipe_IsDone(TransitionWipe* this) {
s32 TransitionWipe_IsDone(void* thisx) {
TransitionWipe* this = THIS;
return this->isDone;
}
void TransitionWipe_SetType(TransitionWipe* this, s32 type) {
void TransitionWipe_SetType(void* thisx, s32 type) {
TransitionWipe* this = THIS;
if (type == 1) {
this->direction = 1;
} else {
@ -245,10 +259,14 @@ void TransitionWipe_SetType(TransitionWipe* this, s32 type) {
}
}
void TransitionWipe_SetColor(TransitionWipe* this, u32 color) {
void TransitionWipe_SetColor(void* thisx, u32 color) {
TransitionWipe* this = THIS;
this->color.rgba = color;
}
void TransitionWipe_SetEnvColor(TransitionWipe* this, u32 color) {
void TransitionWipe_SetEnvColor(void* thisx, u32 color) {
TransitionWipe* this = THIS;
this->envColor.rgba = color;
}

View file

@ -51,15 +51,13 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) {
TransformUpdateIndex* transformIndex;
u16* transformCopyValues;
s32 i;
s32 ret;
s32 ret = 0;
s32 k;
TransformData* transData;
f32 transformValue;
s32 j;
ret = 0;
transformIndex = SEGMENTED_TO_VIRTUAL(skelCurve->transUpdIdx);
transformRefIdx = SEGMENTED_TO_VIRTUAL(transformIndex->refIndex);
transData = SEGMENTED_TO_VIRTUAL(transformIndex->transformData);
transformCopyValues = SEGMENTED_TO_VIRTUAL(transformIndex->copyValues);
@ -112,9 +110,8 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve*
Vec3s rot;
Vec3f pos;
Gfx* dList;
Vec3s* transform;
Vec3s* transform = (Vec3s*)&skelCurve->transforms[limbIndex];
transform = &skelCurve->transforms[limbIndex];
scale.x = transform->x / 1024.0f;
scale.y = transform->y / 1024.0f;
scale.z = transform->z / 1024.0f;

View file

@ -69,8 +69,7 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 3586.0f, 1413.0f, -402.0f, 0, 0x4000, 0, 1);
horseActor->room = -1;
} else if ((gSaveContext.entranceIndex == 1230) && (gSaveContext.eventChkInf[1] & 0x100)) {
Actor* horseActor;
horseActor =
Actor* horseActor =
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -25.0f, 0.0f, -1600.0f, 0, -0x4000, 0, 1);
if (horseActor == NULL) {
__assert("horse_actor != NULL", "../z_horse.c", 389);
@ -82,10 +81,9 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) {
DREG(1));
if (func_8006CFC0(gSaveContext.horseData.scene)) {
Actor* horseActor;
horseActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, gSaveContext.horseData.pos.x,
gSaveContext.horseData.pos.y, gSaveContext.horseData.pos.z, 0,
gSaveContext.horseData.angle, 0, 1);
Actor* horseActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE,
gSaveContext.horseData.pos.x, gSaveContext.horseData.pos.y,
gSaveContext.horseData.pos.z, 0, gSaveContext.horseData.angle, 0, 1);
if (horseActor == NULL) {
__assert("horse_actor != NULL", "../z_horse.c", 414);
}
@ -101,17 +99,16 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) {
func_8006D074(globalCtx);
}
} else if ((globalCtx->sceneNum == SCENE_SPOT20) && !Flags_GetEventChkInf(0x18) && (DREG(1) == 0)) {
Actor* horseActor;
horseActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 0.0f, 0.0f, -500.0f, 0, 0, 0, 1);
if (horseActor == 0) {
Actor* horseActor =
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 0.0f, 0.0f, -500.0f, 0, 0, 0, 1);
if (horseActor == NULL) {
__assert("horse_actor != NULL", "../z_horse.c", 443);
}
} else if (Flags_GetEventChkInf(0x18) || (DREG(1) != 0)) {
for (i = 0; i < ARRAY_COUNT(horseSpawns); i++) {
HorseSpawn* horseSpawn = &horseSpawns[i];
if (horseSpawn->scene == globalCtx->sceneNum) {
Actor* horseActor;
horseActor =
Actor* horseActor =
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, horseSpawn->pos.x, horseSpawn->pos.y,
horseSpawn->pos.z, 0, horseSpawn->angle, 0, horseSpawn->type);
if (horseActor == NULL) {
@ -218,9 +215,8 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) {
func_8002DE74(globalCtx, player);
} else if ((D_8011F9B8[i].type == 5) || (D_8011F9B8[i].type == 6) || (D_8011F9B8[i].type == 8)) {
Vec3f sp54;
s32 temp;
s32 temp = 0;
temp = 0;
if (((gSaveContext.eventInf[0] & 0x10) >> 4) && D_8011F9B8[i].type == 6) {
temp = 0x8000;
}

View file

@ -48,8 +48,8 @@ u32 Jpeg_SendTask(JpegContext* ctx) {
sJpegTask.flags = 0;
sJpegTask.ucode_boot = SysUcode_GetUCodeBoot();
sJpegTask.ucode_boot_size = SysUcode_GetUCodeBootSize();
sJpegTask.yield_data_ptr = &workBuf->yieldData;
sJpegTask.data_ptr = &workBuf->taskData;
sJpegTask.yield_data_ptr = (u64*)&workBuf->yieldData;
sJpegTask.data_ptr = (u64*)&workBuf->taskData;
ctx->scTask.next = NULL;
ctx->scTask.flags = OS_SC_NEEDS_RSP;
@ -64,11 +64,9 @@ u32 Jpeg_SendTask(JpegContext* ctx) {
}
void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y) {
u16* dst;
u16* dst = zbuffer + (((y * SCREEN_WIDTH) + x) * 16);
s32 i;
dst = zbuffer + (((y * SCREEN_WIDTH) + x) * 16);
for (i = 0; i < 16; i++) {
dst[0] = src[0];
dst[1] = src[1];
@ -101,9 +99,8 @@ u16 Jpeg_GetU16(u8* ptr) {
}
void Jpeg_ParseMarkers(u8* ptr, JpegContext* ctx) {
u32 exit;
u32 exit = false;
exit = false;
ctx->dqtCount = 0;
ctx->dhtCount = 0;
@ -203,9 +200,9 @@ void Jpeg_ParseMarkers(u8* ptr, JpegContext* ctx) {
}
}
#ifdef NON_MATCHING
// the time diff isn't correct, workBuff->unk_6C0 is kept in a temp register instead of being stored in the stack and
// regalloc differences
#ifdef NON_MATCHING
s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) {
s32 y;
s32 x;
@ -273,27 +270,22 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) {
switch (ctx.dhtCount) {
case 1: {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[0], &hTables[0], &workBuff->codesLengths, &workBuff->codes,
4)) {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[0], &hTables[0], workBuff->codesLengths, workBuff->codes, 4)) {
osSyncPrintf("Error : Cant' make huffman table.\n");
}
break;
}
case 4: {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[0], &hTables[0], &workBuff->codesLengths, &workBuff->codes,
1)) {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[0], &hTables[0], workBuff->codesLengths, workBuff->codes, 1)) {
osSyncPrintf("Error : Cant' make huffman table.\n");
}
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[1], &hTables[1], &workBuff->codesLengths, &workBuff->codes,
1)) {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[1], &hTables[1], workBuff->codesLengths, workBuff->codes, 1)) {
osSyncPrintf("Error : Cant' make huffman table.\n");
}
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[2], &hTables[2], &workBuff->codesLengths, &workBuff->codes,
1)) {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[2], &hTables[2], workBuff->codesLengths, workBuff->codes, 1)) {
osSyncPrintf("Error : Cant' make huffman table.\n");
}
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[3], &hTables[3], &workBuff->codesLengths, &workBuff->codes,
1)) {
if (JpegUtils_ProcessHuffmanTable(ctx.dhtPtr[3], &hTables[3], workBuff->codesLengths, workBuff->codes, 1)) {
osSyncPrintf("Error : Cant' make huffman table.\n");
}
break;
@ -321,7 +313,7 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) {
y = 0;
x = 0;
for (i = 0; i < 300; i += 4) {
if (JpegDecoder_Decode(&decoder, &workBuff->unk_6C0, 4, i != 0, &state)) {
if (JpegDecoder_Decode(&decoder, (u16*)workBuff->unk_6C0, 4, i != 0, &state)) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("Error : Can't decode jpeg\n");
osSyncPrintf(VT_RST);
@ -329,9 +321,9 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) {
Jpeg_SendTask(&ctx);
osInvalDCache(&workBuff->unk_6C0, sizeof(workBuff->unk_6C0[0]));
src = &workBuff->unk_6C0;
src = workBuff->unk_6C0;
for (j = 0; j < ARRAY_COUNT(workBuff->unk_6C0); j++) {
Jpeg_CopyToZbuffer(&src[j], zbuffer, x, y);
Jpeg_CopyToZbuffer(src[j], zbuffer, x, y);
x++;
if (x >= 20) {

View file

@ -39,11 +39,10 @@ void KaleidoManager_ClearOvl(KaleidoManagerOvl* ovl) {
}
void KaleidoManager_Init(GlobalContext* globalCtx) {
s32 largestOvl;
s32 largestOvl = 0;
s32 vramSize;
u32 idx;
largestOvl = 0;
for (idx = 0; idx < ARRAY_COUNT(gKaleidoMgrOverlayTable); idx++) {
vramSize = gKaleidoMgrOverlayTable[idx].vramEnd - (u32)gKaleidoMgrOverlayTable[idx].vramStart;
if (largestOvl < vramSize) {
@ -60,6 +59,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) {
osSyncPrintf(VT_RST);
gKaleidoMgrCurOvl = 0;
}
void KaleidoManager_Destroy() {
if (gKaleidoMgrCurOvl) {
KaleidoManager_ClearOvl(gKaleidoMgrCurOvl);
@ -70,13 +70,11 @@ void KaleidoManager_Destroy() {
// NOTE: this function looks messed up and probably doesn't work like how the devs wanted it to work
void* KaleidoManager_GetRamAddr(void* vram) {
KaleidoManagerOvl* iter;
KaleidoManagerOvl* ovl;
KaleidoManagerOvl* iter = gKaleidoMgrCurOvl;
KaleidoManagerOvl* ovl = iter;
u32 idx;
iter = gKaleidoMgrCurOvl;
ovl = iter;
if (!ovl) {
if (ovl == NULL) {
iter = &gKaleidoMgrOverlayTable[0];
for (idx = 0; idx != ARRAY_COUNT(gKaleidoMgrOverlayTable); idx++) {
if ((u32)vram >= (u32)iter->vramStart && (u32)iter->vramEnd >= (u32)vram) {
@ -92,7 +90,7 @@ void* KaleidoManager_GetRamAddr(void* vram) {
}
KaleidoManager_GetRamAddr_end:
if (!ovl || (u32)vram < (u32)ovl->vramStart || (u32)vram >= (u32)ovl->vramEnd) {
if (ovl == NULL || (u32)vram < (u32)ovl->vramStart || (u32)vram >= (u32)ovl->vramEnd) {
return NULL;
}

View file

@ -345,11 +345,8 @@ void IChain_Apply_f32div1000(u8* ptr, InitChainEntry* ichain) {
}
void IChain_Apply_Vec3f(u8* ptr, InitChainEntry* ichain) {
Vec3f* vec;
f32 val;
vec = (Vec3f*)(ptr + ichain->offset);
val = ichain->value;
Vec3f* vec = (Vec3f*)(ptr + ichain->offset);
f32 val = ichain->value;
vec->z = val;
vec->y = val;
@ -357,10 +354,9 @@ void IChain_Apply_Vec3f(u8* ptr, InitChainEntry* ichain) {
}
void IChain_Apply_Vec3fdiv1000(u8* ptr, InitChainEntry* ichain) {
Vec3f* vec;
Vec3f* vec = (Vec3f*)(ptr + ichain->offset);
f32 val;
vec = (Vec3f*)(ptr + ichain->offset);
osSyncPrintf("pp=%x data=%f\n", vec, ichain->value / 1000.0f);
val = ichain->value / 1000.0f;
@ -370,11 +366,8 @@ void IChain_Apply_Vec3fdiv1000(u8* ptr, InitChainEntry* ichain) {
}
void IChain_Apply_Vec3s(u8* ptr, InitChainEntry* ichain) {
Vec3s* vec;
s16 val;
vec = (Vec3s*)(ptr + ichain->offset);
val = ichain->value;
Vec3s* vec = (Vec3s*)(ptr + ichain->offset);
s16 val = ichain->value;
vec->z = val;
vec->y = val;

View file

@ -137,6 +137,7 @@ void HealthMeter_Update(GlobalContext* globalCtx) {
s16 bFactor;
if (interfaceCtx) {}
if (interfaceCtx->unk_200 != 0) {
interfaceCtx->unk_1FE--;
if (interfaceCtx->unk_1FE <= 0) {

View file

@ -8,12 +8,11 @@ s32 gZeldaArenaLogSeverity = LOG_SEVERITY_ERROR;
Arena sZeldaArena;
void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action) {
if (!ptr) {
if (ptr == NULL) {
if (gZeldaArenaLogSeverity >= LOG_SEVERITY_ERROR) {
// "%s: %u bytes %s failed\n"
osSyncPrintf("%s: %u バイトの%sに失敗しました\n", name, size, action);
__osDisplayArena(&sZeldaArena);
return;
}
} else if (gZeldaArenaLogSeverity >= LOG_SEVERITY_VERBOSE) {
// "%s: %u bytes %s succeeded\n"
@ -22,29 +21,29 @@ void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char*
}
void* ZeldaArena_Malloc(u32 size) {
void* ptr;
ptr = __osMalloc(&sZeldaArena, size);
void* ptr = __osMalloc(&sZeldaArena, size);
ZeldaArena_CheckPointer(ptr, size, "zelda_malloc", "確保"); // Secure
return ptr;
}
void* ZeldaArena_MallocDebug(u32 size, const char* file, s32 line) {
void* ptr;
ptr = __osMallocDebug(&sZeldaArena, size, file, line);
void* ptr = __osMallocDebug(&sZeldaArena, size, file, line);
ZeldaArena_CheckPointer(ptr, size, "zelda_malloc_DEBUG", "確保"); // Secure
return ptr;
}
void* ZeldaArena_MallocR(u32 size) {
void* ptr;
ptr = __osMallocR(&sZeldaArena, size);
void* ptr = __osMallocR(&sZeldaArena, size);
ZeldaArena_CheckPointer(ptr, size, "zelda_malloc_r", "確保"); // Secure
return ptr;
}
void* ZeldaArena_MallocRDebug(u32 size, const char* file, s32 line) {
void* ptr;
ptr = __osMallocRDebug(&sZeldaArena, size, file, line);
void* ptr = __osMallocRDebug(&sZeldaArena, size, file, line);
ZeldaArena_CheckPointer(ptr, size, "zelda_malloc_r_DEBUG", "確保"); // Secure
return ptr;
}
@ -71,11 +70,10 @@ void ZeldaArena_FreeDebug(void* ptr, const char* file, s32 line) {
void* ZeldaArena_Calloc(u32 num, u32 size) {
void* ret;
u32 n;
u32 n = num * size;
n = num * size;
ret = __osMalloc(&sZeldaArena, n);
if (ret) {
if (ret != NULL) {
bzero(ret, n);
}

View file

@ -537,13 +537,12 @@ void Map_Update(GlobalContext* globalCtx) {
}
}
if (1) { // Appears to be necessary to match
gSaveContext.sceneFlags[mapIndex].floors |= gBitFlags[floor];
VREG(30) = floor;
if (R_MAP_TEX_INDEX != (R_MAP_TEX_INDEX_BASE + Map_GetFloorTextIndexOffset(mapIndex, floor))) {
R_MAP_TEX_INDEX = R_MAP_TEX_INDEX_BASE + Map_GetFloorTextIndexOffset(mapIndex, floor);
}
gSaveContext.sceneFlags[mapIndex].floors |= gBitFlags[floor];
VREG(30) = floor;
if (R_MAP_TEX_INDEX != (R_MAP_TEX_INDEX_BASE + Map_GetFloorTextIndexOffset(mapIndex, floor))) {
R_MAP_TEX_INDEX = R_MAP_TEX_INDEX_BASE + Map_GetFloorTextIndexOffset(mapIndex, floor);
}
if (1) {} // Appears to be necessary to match
if (interfaceCtx->mapRoomNum != sLastRoomNum) {
// Translates to "Current floor = %d Current room = %x Number of rooms = %d"

Some files were not shown because too many files have changed in this diff Show more