From d02153707ef8700b69cc9da79dae3abcbaedc67e Mon Sep 17 00:00:00 2001 From: Roman971 <32455037+Roman971@users.noreply.github.com> Date: Tue, 13 Oct 2020 18:32:19 +0200 Subject: [PATCH] A few minor fixes/cleanups (#449) --- src/code/code_80097A00.c | 4 +-- src/code/z_actor.c | 29 +++++++++---------- src/code/z_jpeg.c | 11 ++++--- src/code/z_kaleido_setup.c | 4 +-- src/code/z_lib.c | 2 +- src/code/z_room.c | 4 +-- src/code/z_scene.c | 12 ++++---- .../actors/ovl_En_Blkobj/z_en_blkobj.c | 10 +++---- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 2 +- .../actors/ovl_En_Ice_Hono/z_en_ice_hono.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 1 - 11 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/code/code_80097A00.c b/src/code/code_80097A00.c index 457fe72cef..3c8d870825 100644 --- a/src/code/code_80097A00.c +++ b/src/code/code_80097A00.c @@ -30,8 +30,8 @@ u16 gUpgradeCapacities[][4] = { { 0, 20, 30, 40 }, // Deku Nut Upgrades }; -u32 D_8012723C[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; // Unused -u32 D_8012724C[] = { 0, 8, 16, 24 }; // Unused +u32 D_8012723C[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; +u32 D_8012724C[] = { 0, 8, 16, 24 }; // TODO: use symbols for these icon textures once textures are properly in C u32 gItemIcons[] = { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 129463573b..000b012d8f 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -523,7 +523,7 @@ s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { return globalCtx->actorCtx.flags.swch & (1 << flag); } else { - return globalCtx->actorCtx.flags.tempSwch & (1 << flag); + return globalCtx->actorCtx.flags.tempSwch & (1 << (flag - 0x20)); } } @@ -534,7 +534,7 @@ void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { globalCtx->actorCtx.flags.swch |= (1 << flag); } else { - globalCtx->actorCtx.flags.tempSwch |= (1 << flag); + globalCtx->actorCtx.flags.tempSwch |= (1 << (flag - 0x20)); } } @@ -545,7 +545,7 @@ void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { globalCtx->actorCtx.flags.swch &= ~(1 << flag); } else { - globalCtx->actorCtx.flags.tempSwch &= ~(1 << flag); + globalCtx->actorCtx.flags.tempSwch &= ~(1 << (flag - 0x20)); } } @@ -556,7 +556,7 @@ s32 Flags_GetUnknown(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { return globalCtx->actorCtx.flags.unk0 & (1 << flag); } else { - return globalCtx->actorCtx.flags.unk1 & (1 << flag); + return globalCtx->actorCtx.flags.unk1 & (1 << (flag - 0x20)); } } @@ -567,7 +567,7 @@ void Flags_SetUnknown(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { globalCtx->actorCtx.flags.unk0 |= (1 << flag); } else { - globalCtx->actorCtx.flags.unk1 |= (1 << flag); + globalCtx->actorCtx.flags.unk1 |= (1 << (flag - 0x20)); } } @@ -578,7 +578,7 @@ void Flags_UnsetUnknown(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { globalCtx->actorCtx.flags.unk0 &= ~(1 << flag); } else { - globalCtx->actorCtx.flags.unk1 &= ~(1 << flag); + globalCtx->actorCtx.flags.unk1 &= ~(1 << (flag - 0x20)); } } @@ -628,7 +628,7 @@ s32 Flags_GetTempClear(GlobalContext* globalCtx, s32 flag) { * Sets current scene temp clear flag. */ void Flags_SetTempClear(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.tempClear |= 1 << flag; + globalCtx->actorCtx.flags.tempClear |= (1 << flag); } /** @@ -645,7 +645,7 @@ s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { if (flag < 0x20) { return globalCtx->actorCtx.flags.collect & (1 << flag); } else { - return globalCtx->actorCtx.flags.tempCollect & (1 << flag); + return globalCtx->actorCtx.flags.tempCollect & (1 << (flag - 0x20)); } } @@ -655,9 +655,9 @@ s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) { if (flag != 0) { if (flag < 0x20) { - globalCtx->actorCtx.flags.collect |= 1 << flag; + globalCtx->actorCtx.flags.collect |= (1 << flag); } else { - globalCtx->actorCtx.flags.tempCollect |= 1 << flag; + globalCtx->actorCtx.flags.tempCollect |= (1 << (flag - 0x20)); } } } @@ -1287,9 +1287,8 @@ Gfx* func_8002E830(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* *hilite = Graph_Alloc(gfxCtx, sizeof(Hilite)); if (HREG(80) == 6) { - osSyncPrintf("z_actor.c 3529 eye=[%f(%f) %f %f] object=[%f %f %f] light_direction=[%f %f %f]\n", - (f64)correctedEyeX, (f64)eye->x, (f64)eye->y, (f64)eye->z, (f64)object->x, (f64)object->y, - (f64)object->z, (f64)lightDir->x, (f64)lightDir->y, (f64)lightDir->z); + osSyncPrintf("z_actor.c 3529 eye=[%f(%f) %f %f] object=[%f %f %f] light_direction=[%f %f %f]\n", correctedEyeX, + eye->x, eye->y, eye->z, object->x, object->y, object->z, lightDir->x, lightDir->y, lightDir->z); } func_800ABE74(correctedEyeX, eye->y, eye->z); @@ -1338,8 +1337,8 @@ void func_8002EBCC(Actor* actor, GlobalContext* globalCtx, s32 flag) { lightDir.z = globalCtx->envCtx.unk_2C; if (HREG(80) == 6) { - osSyncPrintf("z_actor.c 3637 game_play->view.eye=[%f(%f) %f %f]\n", (f64)globalCtx->view.eye.x, - (f64)globalCtx->view.eye.y, (f64)globalCtx->view.eye.z); + osSyncPrintf("z_actor.c 3637 game_play->view.eye=[%f(%f) %f %f]\n", globalCtx->view.eye.x, + globalCtx->view.eye.y, globalCtx->view.eye.z); } hilite = func_8002EABC(&actor->posRot.pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 019f682160..a672f85262 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -233,7 +233,7 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) { diff = time2 - time; if (1) {} // Wait for synchronization of fifo buffer - osSyncPrintf("*** fifoバッファの同期待ち time = %6.3f ms ***\n", (f64)(OS_CYCLES_TO_USEC(diff) / 1000.0f)); + osSyncPrintf("*** fifoバッファの同期待ち time = %6.3f ms ***\n", OS_CYCLES_TO_USEC(diff) / 1000.0f); ctx.workBuf = workBuff; Jpeg_ParseMarkers(data, &ctx); @@ -242,8 +242,7 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) { diff = time - time2; if (1) {} // Check markers for each segment - osSyncPrintf("*** 各セグメントのマーカーのチェック time = %6.3f ms ***\n", - (f64)(OS_CYCLES_TO_USEC(diff) / 1000.0f)); + osSyncPrintf("*** 各セグメントのマーカーのチェック time = %6.3f ms ***\n", OS_CYCLES_TO_USEC(diff) / 1000.0f); switch (ctx.dqtCount) { case 1: { @@ -270,7 +269,7 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) { diff = time2 - time; if (1) {} // Create quantization table - osSyncPrintf("*** 量子化テーブル作成 time = %6.3f ms ***\n", (f64)(OS_CYCLES_TO_USEC(diff) / 1000.0f)); + osSyncPrintf("*** 量子化テーブル作成 time = %6.3f ms ***\n", OS_CYCLES_TO_USEC(diff) / 1000.0f); switch (ctx.dhtCount) { case 1: { @@ -307,7 +306,7 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) { diff = time - time2; if (1) {} // Huffman table creation - osSyncPrintf("*** ハフマンテーブル作成 time = %6.3f ms ***\n", (f64)(OS_CYCLES_TO_USEC(diff) / 1000.0f)); + osSyncPrintf("*** ハフマンテーブル作成 time = %6.3f ms ***\n", OS_CYCLES_TO_USEC(diff) / 1000.0f); decoder.unk_05 = 2; decoder.hTablePtrs[0] = &hTables[0]; @@ -347,7 +346,7 @@ s32 Jpeg_Decode(void* data, u16* zbuffer, JpegWork* workBuff, u32 workSize) { diff = time2 - time; if (1) {} // Unfold & draw - osSyncPrintf("*** 展開 & 描画 time = %6.3f ms ***\n", (f64)(OS_CYCLES_TO_USEC(diff) / 1000.0f)); + osSyncPrintf("*** 展開 & 描画 time = %6.3f ms ***\n", OS_CYCLES_TO_USEC(diff) / 1000.0f); return 0; } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index c2fc1b7579..e288119211 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -70,8 +70,8 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) { pauseCtx->mode = (u16)(pauseCtx->kscpPos * 2) + 1; // cast required pauseCtx->state = 1; - osSyncPrintf("Mode=%d eye.x=%f, eye.z=%f kscp_pos=%d\n", pauseCtx->mode, (f64)pauseCtx->eye.x, - (f64)pauseCtx->eye.z, pauseCtx->kscpPos); + osSyncPrintf("Mode=%d eye.x=%f, eye.z=%f kscp_pos=%d\n", pauseCtx->mode, pauseCtx->eye.x, + pauseCtx->eye.z, pauseCtx->kscpPos); } if (pauseCtx->state == 1) { diff --git a/src/code/z_lib.c b/src/code/z_lib.c index a69770ca2d..5c6336890f 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -331,7 +331,7 @@ void IChain_Apply_Vec3fdiv1000(u8* ptr, InitChainEntry* ichain) { f32 val; vec = (Vec3f*)(ptr + ichain->offset); - osSyncPrintf("pp=%x data=%f\n", vec, (f64)(ichain->value / 1000.0f)); + osSyncPrintf("pp=%x data=%f\n", vec, ichain->value / 1000.0f); val = ichain->value / 1000.0f; vec->z = val; diff --git a/src/code/z_room.c b/src/code/z_room.c index 9dbb122038..a959890136 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -240,7 +240,7 @@ s32 func_80096238(void* data) { time = osGetTime() - time; // Translates to: "SUCCESS... I THINK. time = %6.3f ms" - osSyncPrintf("成功…だと思う。 time = %6.3f ms \n", (f64)(OS_CYCLES_TO_USEC(time) / 1000.0f)); + osSyncPrintf("成功…だと思う。 time = %6.3f ms \n", OS_CYCLES_TO_USEC(time) / 1000.0f); // Translates to: "WRITING BACK TO ORIGINAL ADDRESS FROM WORK BUFFER." osSyncPrintf("ワークバッファから元のアドレスに書き戻します。\n"); // Translates to: "IF THE ORIGINAL BUFFER SIZE ISN'T AT LEAST 150KB, IT WILL BE OUT OF CONTROL." @@ -535,7 +535,7 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { osSyncPrintf(VT_FGCOL(YELLOW)); // Translates to: "ROOM BUFFER SIZE=%08x(%5.1fK)" - osSyncPrintf("部屋バッファサイズ=%08x(%5.1fK)\n", maxRoomSize, (f64)(maxRoomSize * 0.0009765625f)); + osSyncPrintf("部屋バッファサイズ=%08x(%5.1fK)\n", maxRoomSize, maxRoomSize * 0.0009765625f); roomCtx->bufPtrs[0] = GameState_Alloc(&globalCtx->state, maxRoomSize, "../z_room.c", 946); // Translates to: "ROOM BUFFER INITIAL POINTER=%08x" osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 04bcb358c2..b60a0529fe 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -9,8 +9,7 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) { objectCtx->status[objectCtx->num].id = objectId; size = gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart; - osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, (f64)(size / 1024.0f), - objectCtx->status[objectCtx->num].segment); + osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f, objectCtx->status[objectCtx->num].segment); osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[objectCtx->num].segment + size, objectCtx->spaceEnd); @@ -67,7 +66,7 @@ void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) { osSyncPrintf(VT_FGCOL(GREEN)); // Translates to: "OBJECT EXCHANGE BANK DATA %8.3fKB" - osSyncPrintf("オブジェクト入れ替えバンク情報 %8.3fKB\n", (f64)(spaceSize / 1024.0f)); + osSyncPrintf("オブジェクト入れ替えバンク情報 %8.3fKB\n", spaceSize / 1024.0f); osSyncPrintf(VT_RST); objectCtx->spaceStart = objectCtx->status[0].segment = @@ -91,8 +90,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) { osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1); objectFile = &gObjectTable[-status->id]; size = objectFile->vromEnd - objectFile->vromStart; - osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, (f64)(size / 1024.0f), - status->segment); + osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, status->segment); DmaMgr_SendRequest2(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0, &status->loadQueue, NULL, "../z_scene.c", 266); } else if (!osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK)) { @@ -131,7 +129,7 @@ void func_800981B8(ObjectContext* objectCtx) { for (i = 0; i < objectCtx->num; i++) { id = objectCtx->status[i].id; size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; - osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, (f64)(size / 1024.0f), + osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f, objectCtx->status[i].segment); osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[i].segment + size, objectCtx->spaceEnd); @@ -149,7 +147,7 @@ void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) { status->dmaRequest.vromAddr = 0; size = objectFile->vromEnd - objectFile->vromStart; - osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, (f64)(size / 1024.0f)); + osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, size / 1024.0f); if (1) { // Necessary to match nextPtr = (void*)ALIGN16((s32)status->segment + size); diff --git a/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c b/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c index 05358b8e36..5129b1a23f 100644 --- a/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c +++ b/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c @@ -109,14 +109,14 @@ void func_809C2218(EnBlkobj* this, GlobalContext* globalCtx) { this->unk_166 += 1; } } else { - if ((this->unk_166++ < 0x65) ^ 1) { - temp = (this->unk_166 - 0x64) >> 2; + if (this->unk_166++ > 100) { + temp = (this->unk_166 - 100) >> 2; if (temp > 5) { temp = 5; } this->unk_164 += temp; - if (this->unk_164 > 0xFF) { - this->unk_164 = 0xFF; + if (this->unk_164 > 255) { + this->unk_164 = 255; func_809C2060(this, func_809C22F4); DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId); } @@ -171,7 +171,7 @@ void EnBlkobj_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_164 != 0) { func_809C2324(globalCtx, D_060014E0, this->unk_164); } - temp_a3 = 0xFF - this->unk_164; + temp_a3 = 255 - this->unk_164; if (temp_a3 != 0) { func_809C2324(globalCtx, D_060053D0, temp_a3); } diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 410e08ce3d..8f9ba39f15 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -310,7 +310,7 @@ void func_80A4ED34(EnGs* this, GlobalContext* globalCtx) { } func_8002F974(&this->actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); - if ((this->unk_200++ < 0x28) ^ 1) { + if (this->unk_200++ >= 40) { this->unk_19E |= 0x10; this->actor.flags |= 0x10; this->actor.uncullZoneForward = 12000.0f; diff --git a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c index 425724a40f..1d08efb605 100644 --- a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c +++ b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c @@ -327,7 +327,7 @@ void EnIceHono_Update(Actor* thisx, GlobalContext* globalCtx) { intensity = (Math_Rand_ZeroOne() * 0.05f) + ((sin154 * 0.125f) + (sin156 * 0.1f)) + 0.425f; if ((intensity > 0.7f) || (intensity < 0.2f)) { // Translates to: "impossible value(ratio = %f)" - osSyncPrintf("ありえない値(ratio = %f)\n", (f64)intensity); + osSyncPrintf("ありえない値(ratio = %f)\n", intensity); } Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.posRot.pos.x, (s16)this->actor.posRot.pos.y + 10, this->actor.posRot.pos.z, (s32)(155.0f * intensity), (s32)(210.0f * intensity), diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 0db9dbde50..d93d4b343f 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -63,7 +63,6 @@ void Title_SetupView(TitleContext* this, f32 x, f32 y, f32 z) { void Title_Draw(TitleContext* this) { static s16 sTitleRotY = 0; - static u32 D_808009A4 = 0; static Lights1 sTitleLights = gdSPDefLights1(0x64, 0x64, 0x64, 0xFF, 0xFF, 0xFF, 0x45, 0x45, 0x45); u16 y;