diff --git a/Makefile b/Makefile index e241f8364d..5245a09b69 100644 --- a/Makefile +++ b/Makefile @@ -370,6 +370,7 @@ setup: venv # TODO: for now, we only extract assets from the Debug ROM ifeq ($(VERSION),gc-eu-mq-dbg) $(PYTHON) extract_assets.py -j$(N_THREADS) + $(PYTHON) tools/msgdis.py --text-out assets/text/message_data.h --staff-text-out assets/text/message_data_staff.h endif disasm: $(DISASM_O_FILES) diff --git a/extract_assets.py b/extract_assets.py index defac57dcd..ced7da4a1c 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -96,7 +96,7 @@ def processZAPDArgs(argsZ): def main(): parser = argparse.ArgumentParser(description="baserom asset extractor") parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep") - parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones, and text (overwriting current files).", action="store_true") + parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones (overwriting current files).", action="store_true") parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.") parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true") parser.add_argument("-Z", help="Pass the argument on to ZAPD, e.g. `-ZWunaccounted` to warn about unaccounted blocks in XMLs. Each argument should be passed separately, *without* the leading dash.", metavar="ZAPD_ARG", action="append") @@ -128,21 +128,6 @@ def main(): del extractedAssetsTracker[fullPath] ExtractFunc(fullPath) else: - extract_text_path = "assets/text/message_data.h" - extract_staff_text_path = "assets/text/message_data_staff.h" - - # Only extract text if the header does not already exist, or if --force was passed - if not args.force: - if os.path.isfile(extract_text_path): - extract_text_path = None - if os.path.isfile(extract_staff_text_path): - extract_staff_text_path = None - - if extract_text_path is not None or extract_staff_text_path is not None: - print("Extracting text") - from tools import msgdis - msgdis.extract_all_text(extract_text_path, extract_staff_text_path) - xmlFiles = [] for currentPath, _, files in os.walk(os.path.join("assets", "xml")): for file in files: diff --git a/include/functions.h b/include/functions.h index d8d09222c9..a7cf8c2eb8 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1155,10 +1155,10 @@ void Sram_WriteSramHeader(SramContext* sramCtx); void Sram_InitSram(GameState* gameState, SramContext* sramCtx); void Sram_Alloc(GameState* gameState, SramContext* sramCtx); void Sram_Init(PlayState* play, SramContext* sramCtx); -void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, +void SsSram_Init(s32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, u8 handlePulse, u32 handleSpeed); void SsSram_Dma(void* dramAddr, size_t size, s32 direction); -void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction); +void SsSram_ReadWrite(s32 addr, void* dramAddr, size_t size, s32 direction); View* View_New(GraphicsContext* gfxCtx); void View_Free(View* view); void View_Init(View*, GraphicsContext*); diff --git a/spec b/spec index f571845445..df4a354ac3 100644 --- a/spec +++ b/spec @@ -20,13 +20,17 @@ beginseg include "$(BUILD_DIR)/src/boot/z_std_dma.o" include "$(BUILD_DIR)/src/boot/yaz0.o" include "$(BUILD_DIR)/src/boot/z_locale.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/boot/assert.o" +#endif include "$(BUILD_DIR)/src/boot/is_debug.o" include "$(BUILD_DIR)/src/libultra/io/driverominit.o" include "$(BUILD_DIR)/src/boot/mio0.o" include "$(BUILD_DIR)/src/boot/stackcheck.o" include "$(BUILD_DIR)/src/boot/logutils.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/libc/sprintf.o" +#endif include "$(BUILD_DIR)/src/libultra/io/piacs.o" include "$(BUILD_DIR)/src/libultra/os/sendmesg.o" include "$(BUILD_DIR)/src/libultra/os/stopthread.o" @@ -57,10 +61,14 @@ beginseg include "$(BUILD_DIR)/src/libultra/os/probetlb.o" include "$(BUILD_DIR)/src/libultra/os/getmemsize.o" include "$(BUILD_DIR)/src/libultra/os/seteventmesg.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/libc/xprintf.o" +#endif include "$(BUILD_DIR)/src/libultra/os/unmaptlball.o" include "$(BUILD_DIR)/src/libultra/io/epidma.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/libc/string.o" +#endif include "$(BUILD_DIR)/src/libultra/os/invalicache.o" include "$(BUILD_DIR)/src/libultra/os/createmesgqueue.o" include "$(BUILD_DIR)/src/libultra/os/invaldcache.o" @@ -88,17 +96,23 @@ beginseg include "$(BUILD_DIR)/src/libultra/io/epiread.o" include "$(BUILD_DIR)/src/libultra/io/visetspecial.o" include "$(BUILD_DIR)/src/libultra/io/cartrominit.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/vimodefpallan1.o" +#endif include "$(BUILD_DIR)/src/libultra/os/setfpccsr.o" include "$(BUILD_DIR)/src/libultra/os/getfpccsr.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/epiwrite.o" +#endif include "$(BUILD_DIR)/src/libultra/os/maptlbrdb.o" include "$(BUILD_DIR)/src/libultra/os/yieldthread.o" include "$(BUILD_DIR)/src/libultra/os/getcause.o" include "$(BUILD_DIR)/src/libultra/io/epirawwrite.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/libc/xlitob.o" include "$(BUILD_DIR)/src/libultra/libc/ldiv.o" include "$(BUILD_DIR)/src/libultra/libc/xldtob.o" +#endif include "$(BUILD_DIR)/src/boot/build.o" include "$(BUILD_DIR)/src/libultra/io/sirawwrite.o" include "$(BUILD_DIR)/src/libultra/io/vimgr.o" @@ -342,7 +356,9 @@ beginseg include "$(BUILD_DIR)/src/code/z_lights.o" include "$(BUILD_DIR)/src/code/z_malloc.o" include "$(BUILD_DIR)/src/code/z_map_mark.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/code/z_moji.o" +#endif include "$(BUILD_DIR)/src/code/z_prenmi_buff.o" include "$(BUILD_DIR)/src/code/z_nulltask.o" include "$(BUILD_DIR)/src/code/z_olib.o" @@ -369,7 +385,9 @@ beginseg include "$(BUILD_DIR)/src/code/z_sram.o" include "$(BUILD_DIR)/src/code/z_ss_sram.o" include "$(BUILD_DIR)/src/code/z_rumble.o" +#if OOT_DEBUG include "$(BUILD_DIR)/data/z_text.data.o" +#endif include "$(BUILD_DIR)/data/unk_8012ABC0.data.o" include "$(BUILD_DIR)/src/code/z_view.o" include "$(BUILD_DIR)/src/code/z_vimode.o" @@ -385,9 +403,13 @@ beginseg include "$(BUILD_DIR)/src/code/z_fbdemo_circle.o" include "$(BUILD_DIR)/src/code/z_fbdemo_fade.o" include "$(BUILD_DIR)/src/code/shrink_window.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/code/db_camera.o" +#endif include "$(BUILD_DIR)/src/code/code_800BB0A0.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/code/mempak.o" +#endif include "$(BUILD_DIR)/src/code/z_kaleido_manager.o" include "$(BUILD_DIR)/src/code/z_kaleido_scope_call.o" include "$(BUILD_DIR)/src/code/z_play.o" @@ -415,7 +437,9 @@ beginseg include "$(BUILD_DIR)/src/code/sys_rumble.o" include "$(BUILD_DIR)/src/code/code_800D31A0.o" include "$(BUILD_DIR)/src/code/irqmgr.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/code/debug_malloc.o" +#endif include "$(BUILD_DIR)/src/code/fault.o" include "$(BUILD_DIR)/src/code/fault_drawer.o" #ifndef NON_MATCHING @@ -423,7 +447,9 @@ beginseg include "$(BUILD_DIR)/data/fault_drawer.bss.o" #endif include "$(BUILD_DIR)/src/code/kanread.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/code/ucode_disas.o" +#endif pad_text // audio library aligned to 32 bytes? include "$(BUILD_DIR)/src/audio/lib/data.o" include "$(BUILD_DIR)/src/audio/lib/synthesis.o" @@ -445,7 +471,9 @@ beginseg include "$(BUILD_DIR)/src/code/gfxprint.o" include "$(BUILD_DIR)/src/code/rcp_utils.o" include "$(BUILD_DIR)/src/code/loadfragment2.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/code/mtxuty-cvt.o" +#endif include "$(BUILD_DIR)/src/code/relocation.o" include "$(BUILD_DIR)/src/code/load.o" include "$(BUILD_DIR)/src/code/code_800FC620.o" @@ -456,11 +484,16 @@ beginseg include "$(BUILD_DIR)/src/code/system_malloc.o" include "$(BUILD_DIR)/src/code/code_800FD970.o" include "$(BUILD_DIR)/src/code/__osMalloc.o" +#if !OOT_DEBUG + include "$(BUILD_DIR)/src/libultra/libc/sprintf.o" +#endif include "$(BUILD_DIR)/src/code/printutils.o" include "$(BUILD_DIR)/src/code/sleep.o" include "$(BUILD_DIR)/src/code/jpegutils.o" include "$(BUILD_DIR)/src/code/jpegdecoder.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/pfsfreeblocks.o" +#endif include "$(BUILD_DIR)/src/libultra/mgu/scale.o" include "$(BUILD_DIR)/src/libultra/gu/sinf.o" include "$(BUILD_DIR)/src/libultra/gu/sins.o" @@ -473,19 +506,29 @@ beginseg include "$(BUILD_DIR)/src/libultra/io/sprawdma.o" include "$(BUILD_DIR)/src/libultra/io/sirawdma.o" include "$(BUILD_DIR)/src/libultra/io/sptaskyield.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/pfsreadwritefile.o" include "$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o" +#endif include "$(BUILD_DIR)/src/libultra/mgu/mtxidentf.o" include "$(BUILD_DIR)/src/libultra/gu/lookat.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/pfsallocatefile.o" +#endif include "$(BUILD_DIR)/src/libultra/os/stoptimer.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/contpfs.o" include "$(BUILD_DIR)/src/libultra/mgu/mtxl2f.o" include "$(BUILD_DIR)/src/libultra/io/pfsfindfile.o" +#endif include "$(BUILD_DIR)/src/libultra/gu/sqrtf.o" include "$(BUILD_DIR)/src/libultra/os/afterprenmi.o" include "$(BUILD_DIR)/src/libultra/io/contquery.o" include "$(BUILD_DIR)/src/libultra/gu/lookathil.o" +#if !OOT_DEBUG + include "$(BUILD_DIR)/src/libultra/libc/xprintf.o" + include "$(BUILD_DIR)/src/libultra/libc/string.o" +#endif include "$(BUILD_DIR)/src/libultra/io/sp.o" include "$(BUILD_DIR)/src/libultra/mgu/mtxident.o" include "$(BUILD_DIR)/src/libultra/gu/position.o" @@ -496,25 +539,44 @@ beginseg include "$(BUILD_DIR)/src/libultra/mgu/normalize.o" include "$(BUILD_DIR)/src/libultra/io/dpgetstat.o" include "$(BUILD_DIR)/src/libultra/io/dpsetstat.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/pfsdeletefile.o" +#endif include "$(BUILD_DIR)/src/libultra/gu/ortho.o" include "$(BUILD_DIR)/src/libultra/gu/cosf.o" include "$(BUILD_DIR)/src/libultra/gu/libm_vals.o" include "$(BUILD_DIR)/src/libultra/gu/coss.o" include "$(BUILD_DIR)/src/libultra/io/visetevent.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/pfsisplug.o" +#endif include "$(BUILD_DIR)/src/libultra/gu/us2dex.o" include "$(BUILD_DIR)/src/libultra/io/pfsselectbank.o" include "$(BUILD_DIR)/src/libultra/io/contsetch.o" +#if OOT_DEBUG include "$(BUILD_DIR)/src/libultra/io/pfsfilestate.o" include "$(BUILD_DIR)/src/libultra/io/pfsinitpak.o" include "$(BUILD_DIR)/src/libultra/io/pfschecker.o" +#endif include "$(BUILD_DIR)/src/libultra/io/aigetlen.o" include "$(BUILD_DIR)/src/libultra/mgu/translate.o" include "$(BUILD_DIR)/src/libultra/io/contramwrite.o" +#if !OOT_DEBUG + include "$(BUILD_DIR)/src/libultra/io/vimodefpallan1.o" + include "$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o" + include "$(BUILD_DIR)/src/libultra/io/contpfs.o" +#endif include "$(BUILD_DIR)/src/libultra/io/contramread.o" include "$(BUILD_DIR)/src/libultra/io/crc.o" +#if !OOT_DEBUG + include "$(BUILD_DIR)/src/libultra/io/pfsisplug.o" +#endif include "$(BUILD_DIR)/src/libultra/os/settimer.o" +#if !OOT_DEBUG + include "$(BUILD_DIR)/src/libultra/libc/xldtob.o" + include "$(BUILD_DIR)/src/libultra/libc/ldiv.o" + include "$(BUILD_DIR)/src/libultra/libc/xlitob.o" +#endif include "$(BUILD_DIR)/src/libultra/io/spgetstat.o" include "$(BUILD_DIR)/src/libultra/io/spsetstat.o" include "$(BUILD_DIR)/src/libultra/os/writebackdcacheall.o" @@ -2911,7 +2973,7 @@ beginseg name "ovl_En_Mb" compress include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/z_en_mb.o" - include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/ovl_En_Mb_reloc.o" + include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/ovl_En_Mb_reloc.o" endseg beginseg diff --git a/src/code/audio_thread_manager.c b/src/code/audio_thread_manager.c index bbec08dead..32c5826a5d 100644 --- a/src/code/audio_thread_manager.c +++ b/src/code/audio_thread_manager.c @@ -105,7 +105,7 @@ void AudioMgr_ThreadEntry(void* arg) { IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptQueue); // Spin waiting for events - while (true) { + for (;;) { osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK); switch (*msg) { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 488d9464f8..b3f0cd2a5c 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -79,6 +79,7 @@ u16 sSurfaceMaterialToSfxOffset[SURFACE_MATERIAL_MAX] = { SURFACE_SFX_OFFSET_CARPET, // SURFACE_MATERIAL_CARPET }; +#if OOT_DEBUG /** * original name: T_BGCheck_PosErrorCheck */ @@ -94,6 +95,7 @@ s32 BgCheck_PosErrorCheck(Vec3f* pos, char* file, s32 line) { } return false; } +#endif /** * Set SSNode @@ -194,30 +196,24 @@ void BgCheck_Vec3fToVec3s(Vec3s* dst, Vec3f* src) { * Get CollisionPoly's lowest y point */ s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vtxList) { - s32 a; - s32 b; - s32 c; - s16 min; - //! @bug Due to rounding errors, some polys with a slight slope have a y normal of 1.0f/-1.0f. As such, this //! optimization returns the wrong minimum y for a subset of these polys. if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) { return vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].y; - } + } else { + s32 a = COLPOLY_VTX_INDEX(poly->flags_vIA); + s32 b = COLPOLY_VTX_INDEX(poly->flags_vIB); + s32 c = poly->vIC; + s16 min = vtxList[a].y; - a = COLPOLY_VTX_INDEX(poly->flags_vIA); - b = COLPOLY_VTX_INDEX(poly->flags_vIB); - c = poly->vIC; - - min = vtxList[a].y; - - if (min > vtxList[b].y) { - min = vtxList[b].y; + if (min > vtxList[b].y) { + min = vtxList[b].y; + } + if (min < vtxList[c].y) { + return min; + } + return vtxList[c].y; } - if (min < vtxList[c].y) { - return min; - } - return vtxList[c].y; } /** @@ -491,8 +487,8 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll SSNode* curNode; SSNode* nextNode; s32 polyYMin; - u16 newNodeId; s16 curPolyId; + u16 newNodeId; // if list is null if (ssList->head == SS_NULL) { @@ -514,6 +510,8 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll while (true) { // if at the end of the list if (curNode->next == SS_NULL) { + s32 pad; + newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, SS_NULL); curNode->next = newNodeId; @@ -681,8 +679,8 @@ s32 BgCheck_ComputeWallDisplacement(CollisionContext* colCtx, CollisionPoly* pol s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius, CollisionPoly** outPoly) { Vec3f resultPos; - f32 temp_f2; - f32 temp_f2_2; + f32 zTemp; + f32 xTemp; f32 planeDist; f32 intersect; s32 result; @@ -690,17 +688,14 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 CollisionPoly* polyList; SSNode* curNode; f32 invNormalXZ; - f32 zTemp; - f32 xTemp; s32 polyId; f32 normalXZ; f32 nx; f32 ny; f32 nz; - f32 temp_f16; + s32 pad; Vec3s* vtxList; - u16 pad; - + f32 temp_f16; f32 zMin; f32 zMax; f32 xMin; @@ -780,8 +775,10 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 } } if (CollisionPoly_CheckZIntersectApprox(curPoly, vtxList, resultPos.x, pos->y, &intersect)) { - if (fabsf(intersect - resultPos.z) <= radius / temp_f16) { - if ((intersect - resultPos.z) * nz <= 4.0f) { + f32 zIntersectDist = intersect - resultPos.z; + + if (fabsf(zIntersectDist) <= radius / temp_f16) { + if (zIntersectDist * nz <= 4.0f) { BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz, invNormalXZ, planeDist, radius, outPoly); result = true; @@ -790,9 +787,8 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 } if (curNode->next == SS_NULL) { break; - } else { - curNode = &colCtx->polyNodes.tbl[curNode->next]; } + curNode = &colCtx->polyNodes.tbl[curNode->next]; } curNode = &colCtx->polyNodes.tbl[lookup->wall.head]; @@ -861,8 +857,10 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 } } if (CollisionPoly_CheckXIntersectApprox(curPoly, vtxList, pos->y, resultPos.z, &intersect)) { - if (fabsf(intersect - resultPos.x) <= radius / temp_f16) { - if ((intersect - resultPos.x) * nx <= 4.0f) { + f32 xIntersectDist = intersect - resultPos.x; + + if (fabsf(xIntersectDist) <= radius / temp_f16) { + if (xIntersectDist * nx <= 4.0f) { BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz, invNormalXZ, planeDist, radius, outPoly); result = true; @@ -871,10 +869,8 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 } if (curNode->next == SS_NULL) { break; - } else { - curNode = &colCtx->polyNodes.tbl[curNode->next]; - continue; } + curNode = &colCtx->polyNodes.tbl[curNode->next]; } *outX = resultPos.x; @@ -909,6 +905,9 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte *outY = pos->y; while (true) { + f32 intersectDist; + f32 ny; + curPolyId = curNode->polyId; if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { if (curNode->next == SS_NULL) { @@ -921,8 +920,8 @@ 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); + intersectDist = ceilingY - *outY; + ny = COLPOLY_GET_NORMAL(curPoly->normal.y); if (intersectDist > 0.0f && intersectDist < checkHeight && intersectDist * ny <= 0) { *outY = ceilingY - checkHeight; @@ -958,7 +957,6 @@ s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16 s32 result; f32 minY; f32 distSq; - s16 polyId; result = false; polyList = colCtx->colHeader->polyList; @@ -968,7 +966,8 @@ s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16 curNode = &colCtx->polyNodes.tbl[ssList->head]; while (true) { - polyId = curNode->polyId; + s16 polyId = curNode->polyId; + checkedPoly = &colCtx->polyNodes.polyCheckTbl[polyId]; if (*checkedPoly == true || COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[polyId].flags_vIA, xpFlags1) || @@ -1051,13 +1050,12 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext CollisionPoly** outPoly) { CollisionPoly* polyList = colCtx->colHeader->polyList; Vec3s* vtxList = colCtx->colHeader->vtxList; - CollisionPoly* curPoly; - u16 nextId; - s16 curPolyId; while (true) { - curPolyId = node->polyId; - curPoly = &polyList[curPolyId]; + u16 nextId; + s16 curPolyId = node->polyId; + CollisionPoly* curPoly = &polyList[curPolyId]; + if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { if (node->next == SS_NULL) { break; @@ -1542,10 +1540,10 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader u32 tblMax; u32 memSize; u32 lookupTblMemSize; - SSNodeList* nodeList; - s32 useCustomSubdivisions; - u32 customMemSize; s32 customNodeListMax; + SSNodeList* nodeList; + u32 customMemSize; + s32 useCustomSubdivisions; s32 i; colCtx->colHeader = colHeader; @@ -1717,11 +1715,15 @@ f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFla if (checkPos.y < colCtx->minBounds.y) { break; } + +#if OOT_DEBUG if (BgCheck_PosErrorCheck(&checkPos, "../z_bgcheck.c", 4410)) { if (actor != NULL) { PRINTF("こいつ,pself_actor->name %d\n", actor->id); } } +#endif + lookup = BgCheck_GetStaticLookup(colCtx, lookupTbl, &checkPos); if (lookup == NULL) { checkPos.y -= colCtx->subdivLength.y; @@ -1735,16 +1737,16 @@ f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFla checkPos.y -= colCtx->subdivLength.y; } + dynaRaycastDown.play = play; dynaRaycastDown.colCtx = colCtx; dynaRaycastDown.xpFlags = xpFlags; + dynaRaycastDown.resultPoly = outPoly; dynaRaycastDown.yIntersect = yIntersect; dynaRaycastDown.pos = pos; + dynaRaycastDown.bgId = outBgId; dynaRaycastDown.actor = actor; dynaRaycastDown.downChkFlags = downChkFlags; dynaRaycastDown.chkDist = chkDist; - dynaRaycastDown.play = play; - dynaRaycastDown.resultPoly = outPoly; - dynaRaycastDown.bgId = outBgId; yIntersectDyna = BgCheck_RaycastDownDyna(&dynaRaycastDown); @@ -1951,11 +1953,11 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul Vec3f checkLinePrev; f32 n2XZDist; f32 n3XZDist; - f32 nx3, nz3; s32 bccFlags; + f32 nx; + f32 nz; Vec3f posIntersect2; s32 bgId2; - f32 nx, ny, nz; // unit normal of polygon result = false; *outBgId = BGCHECK_SCENE; @@ -1966,12 +1968,14 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul dy = posNext->y - posPrev->y; dz = posNext->z - posPrev->z; +#if OOT_DEBUG if (BgCheck_PosErrorCheck(posNext, "../z_bgcheck.c", 4831) == true || BgCheck_PosErrorCheck(posPrev, "../z_bgcheck.c", 4832) == true) { if (actor != NULL) { PRINTF("こいつ,pself_actor->name %d\n", actor->id); } } +#endif // if there's movement on the xz plane, and argA flag is 0, if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { @@ -1980,7 +1984,8 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, &bgId, actor, 1.0f, BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING); if (result) { - ny = COLPOLY_GET_NORMAL(poly->normal.y); + f32 ny = COLPOLY_GET_NORMAL(poly->normal.y); + // if poly is floor, push result underneath the floor if (ny > 0.5f) { posResult->x = posIntersect.x; @@ -2061,8 +2066,9 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul if (dynaPolyCollision == true || *outBgId != BGCHECK_SCENE) { if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { - nx3 = COLPOLY_GET_NORMAL(poly->normal.x); - nz3 = COLPOLY_GET_NORMAL(poly->normal.z); + f32 nx3 = COLPOLY_GET_NORMAL(poly->normal.x); + f32 nz3 = COLPOLY_GET_NORMAL(poly->normal.z); + n3XZDist = sqrtf(SQ(nx3) + SQ(nz3)); // if poly is not a "flat" floor or "flat" ceiling @@ -2155,11 +2161,15 @@ s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, V *outBgId = BGCHECK_SCENE; *outY = pos->y; + +#if OOT_DEBUG if (BgCheck_PosErrorCheck(pos, "../z_bgcheck.c", 5206) == true) { if (actor != NULL) { PRINTF("こいつ,pself_actor->name %d\n", actor->id); } } +#endif + lookupTbl = colCtx->lookupTbl; if (!BgCheck_PosInStaticBoundingBox(colCtx, pos)) { return false; @@ -2222,13 +2232,10 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f posBTemp = *posB; Vec3f sectorMin; Vec3f sectorMax; - s32 k; - StaticLookup* lookup; - s32 j; - StaticLookup* jLookup; - s32 temp_lo; *outBgId = BGCHECK_SCENE; + +#if OOT_DEBUG if (BgCheck_PosErrorCheck(posA, "../z_bgcheck.c", 5334) == true || BgCheck_PosErrorCheck(posB, "../z_bgcheck.c", 5335) == true) { if (actor != NULL) { @@ -2237,6 +2244,7 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, PRINTF("pself_actor == NULLで犯人不明\n"); } } +#endif BgCheck_ResetPolyCheckTbl(&colCtx->polyNodes, colCtx->colHeader->numPolygons); BgCheck_GetStaticLookupIndicesFromPos(colCtx, posA, (Vec3i*)&subdivMin); @@ -2247,6 +2255,10 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, *outPoly = NULL; if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) { + s32 k; + s32 temp_lo; + s32 j; + for (i = 0; i < 3; i++) { if (subdivMax[i] < subdivMin[i]) { j = subdivMax[i]; @@ -2260,12 +2272,14 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, sectorMax.z = colCtx->subdivLength.z + sectorMin.z; for (i = subdivMin[2]; i < subdivMax[2] + 1; i++) { - jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x; + StaticLookup* jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x; + sectorMin.y = subdivMin[1] * colCtx->subdivLength.y + colCtx->minBounds.y; sectorMax.y = colCtx->subdivLength.y + sectorMin.y; for (j = subdivMin[1]; j < subdivMax[1] + 1; j++) { - lookup = jLookup + subdivMin[0]; + StaticLookup* lookup = jLookup + subdivMin[0]; + sectorMin.x = subdivMin[0] * colCtx->subdivLength.x + colCtx->minBounds.x; sectorMax.x = colCtx->subdivLength.x + sectorMin.x; @@ -2443,11 +2457,14 @@ s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionP StaticLookup* lookup; *outBgId = BGCHECK_SCENE; + +#if OOT_DEBUG if (BgCheck_PosErrorCheck(center, "../z_bgcheck.c", 5852) == true) { if (actor != NULL) { PRINTF("こいつ,pself_actor->name %d\n", actor->id); } } +#endif lookup = BgCheck_GetStaticLookup(colCtx, colCtx->lookupTbl, center); if (lookup == NULL) { @@ -2784,12 +2801,12 @@ void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgI PRINTF(VT_RST); if (!DynaPoly_IsBgIdBgActor(bgId)) { +#if OOT_DEBUG if (bgId == -1) { PRINTF(VT_FGCOL(GREEN)); // "The index that should have been deleted(? ) was(== -1), processing aborted." PRINTF("DynaPolyInfo_delReserve():削除されているはずの(?)\nインデックス(== -1)のため,処理を中止します。\n"); PRINTF(VT_RST); - return; } else { PRINTF(VT_FGCOL(RED)); // "Unable to deallocate index / index unallocated, processing aborted." @@ -2797,15 +2814,17 @@ void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgI "確保していない/出来なかったインデックスの解放のため、処理を中止します。index == %d\n", bgId); PRINTF(VT_RST); - return; } - } - actor = DynaPoly_GetActor(&play->colCtx, bgId); - if (actor != NULL) { +#endif - actor->bgId = BGACTOR_NEG_ONE; - dyna->bgActors[bgId].actor = NULL; - dyna->bgActorFlags[bgId] |= BGACTOR_1; + } else { + actor = DynaPoly_GetActor(&play->colCtx, bgId); + if (actor != NULL) { + + actor->bgId = BGACTOR_NEG_ONE; + dyna->bgActors[bgId].actor = NULL; + dyna->bgActorFlags[bgId] |= BGACTOR_1; + } } } @@ -2821,7 +2840,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 MtxF mtx; Actor* actor; s32 pad; - s32 pad2; + f32 radiusSq; f32 numVtxInverse; s32 i; Vec3f pos; @@ -2851,6 +2870,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 return; } +#if OOT_DEBUG if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) { PRINTF(VT_FGCOL(RED)); // "do not use if %d exceeds %d" @@ -2869,6 +2889,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 "pdyna_poly_info->poly_num >= *pstart_poly_index + pbgdata->poly_num", "../z_bgcheck.c", 6687); ASSERT(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices, "pdyna_poly_info->vert_num >= *pstart_vert_index + pbgdata->vtx_num", "../z_bgcheck.c", 6688); +#endif if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) && (BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) { @@ -2898,111 +2919,111 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 *polyStartIndex += pbgdata->numPolygons; *vtxStartIndex += pbgdata->numVertices; - } else { - SkinMatrix_SetTranslateRotateYXZScale( - &mtx, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y, - dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x, - dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z, - dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, - dyna->bgActors[bgId].curTransform.pos.z); - - numVtxInverse = 1.0f / pbgdata->numVertices; - newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; - for (i = 0; i < pbgdata->numVertices; i++) { - Vec3f vtx; - Vec3f vtxT; // Vtx after mtx transform - - Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]); - SkinMatrix_Vec3fMtxFMultXYZ(&mtx, &vtx, &vtxT); - BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &vtxT); - - if (i == 0) { - dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y; - } else if (vtxT.y < dyna->bgActors[bgId].minY) { - dyna->bgActors[bgId].minY = vtxT.y; - } else if (dyna->bgActors[bgId].maxY < vtxT.y) { - dyna->bgActors[bgId].maxY = vtxT.y; - } - newCenterPoint.x += vtxT.x; - newCenterPoint.y += vtxT.y; - newCenterPoint.z += vtxT.z; - } - - newCenterPoint.x *= numVtxInverse; - newCenterPoint.y *= numVtxInverse; - newCenterPoint.z *= numVtxInverse; - sphere->center.x = newCenterPoint.x; - sphere->center.y = newCenterPoint.y; - sphere->center.z = newCenterPoint.z; - newRadiusSq = -SQ(10.0f); - - for (i = 0; i < pbgdata->numVertices; i++) { - f32 radiusSq; - - newVtx.x = dyna->vtxList[*vtxStartIndex + i].x; - newVtx.y = dyna->vtxList[*vtxStartIndex + i].y; - newVtx.z = dyna->vtxList[*vtxStartIndex + i].z; - radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); - if (newRadiusSq < radiusSq) { - newRadiusSq = radiusSq; - } - } - - sphere->radius = sqrtf(newRadiusSq) * 1.1f; - - for (i = 0; i < pbgdata->numPolygons; i++) { - CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i]; - f32 newNormMagnitude; - - *newPoly = pbgdata->polyList[i]; - - // Yeah, this is all kinds of fake, but my God, it matches. - newPoly->flags_vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) | - COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIA); - newPoly->flags_vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex) | - COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIB); - newPoly->vIC = *vtxStartIndex + newPoly->vIC; - dVtxList = dyna->vtxList; - vtxA.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].x; - vtxA.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].y; - vtxA.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].z; - vtxB.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].x; - vtxB.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].y; - vtxB.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].z; - vtxC.x = dVtxList[newPoly->vIC].x; - vtxC.y = dVtxList[newPoly->vIC].y; - vtxC.z = dVtxList[newPoly->vIC].z; - Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal); - newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal); - - if (!IS_ZERO(newNormMagnitude)) { - newNormal.x *= (1.0f / newNormMagnitude); - newNormal.y *= (1.0f / newNormMagnitude); - newNormal.z *= (1.0f / newNormMagnitude); - newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x); - newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y); - newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); - } - - newPoly->dist = -DOTXYZ(newNormal, dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)]); - if (newNormal.y > 0.5f) { - s16 polyId = *polyStartIndex + i; - - DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId); - } else if (newNormal.y < -0.8f) { - s16 polyId = *polyStartIndex + i; - - DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId); - } else { - s16 polyId = *polyStartIndex + i; - - DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId); - } - } - - *polyStartIndex += pbgdata->numPolygons; - *vtxStartIndex += pbgdata->numVertices; + return; } + + SkinMatrix_SetTranslateRotateYXZScale( + &mtx, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y, + dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x, + dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z, + dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, + dyna->bgActors[bgId].curTransform.pos.z); + + numVtxInverse = 1.0f / pbgdata->numVertices; + newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; + for (i = 0; i < pbgdata->numVertices; i++) { + Vec3f vtx; + Vec3f vtxT; // Vtx after mtx transform + s32 pad2; + + Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]); + SkinMatrix_Vec3fMtxFMultXYZ(&mtx, &vtx, &vtxT); + BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &vtxT); + + if (i == 0) { + dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y; + } else if (vtxT.y < dyna->bgActors[bgId].minY) { + dyna->bgActors[bgId].minY = vtxT.y; + } else if (dyna->bgActors[bgId].maxY < vtxT.y) { + dyna->bgActors[bgId].maxY = vtxT.y; + } + newCenterPoint.x += vtxT.x; + newCenterPoint.y += vtxT.y; + newCenterPoint.z += vtxT.z; + } + + newCenterPoint.x *= numVtxInverse; + newCenterPoint.y *= numVtxInverse; + newCenterPoint.z *= numVtxInverse; + sphere->center.x = newCenterPoint.x; + sphere->center.y = newCenterPoint.y; + sphere->center.z = newCenterPoint.z; + newRadiusSq = -SQ(10.0f); + + for (i = 0; i < pbgdata->numVertices; i++) { + newVtx.x = dyna->vtxList[*vtxStartIndex + i].x; + newVtx.y = dyna->vtxList[*vtxStartIndex + i].y; + newVtx.z = dyna->vtxList[*vtxStartIndex + i].z; + radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); + if (newRadiusSq < radiusSq) { + newRadiusSq = radiusSq; + } + } + + sphere->radius = sqrtf(newRadiusSq) * 1.1f; + + for (i = 0; i < pbgdata->numPolygons; i++) { + CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i]; + f32 newNormMagnitude; + + *newPoly = pbgdata->polyList[i]; + + // Yeah, this is all kinds of fake, but my God, it matches. + newPoly->flags_vIA = + (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) | COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIA); + newPoly->flags_vIB = + (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex) | COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIB); + newPoly->vIC = *vtxStartIndex + newPoly->vIC; + dVtxList = dyna->vtxList; + vtxA.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].x; + vtxA.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].y; + vtxA.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].z; + vtxB.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].x; + vtxB.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].y; + vtxB.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].z; + vtxC.x = dVtxList[newPoly->vIC].x; + vtxC.y = dVtxList[newPoly->vIC].y; + vtxC.z = dVtxList[newPoly->vIC].z; + Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal); + newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal); + + if (!IS_ZERO(newNormMagnitude)) { + newNormal.x *= (1.0f / newNormMagnitude); + newNormal.y *= (1.0f / newNormMagnitude); + newNormal.z *= (1.0f / newNormMagnitude); + newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x); + newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y); + newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); + } + + newPoly->dist = -DOTXYZ(newNormal, dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)]); + if (newNormal.y > 0.5f) { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId); + } else if (newNormal.y < -0.8f) { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId); + } else { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId); + } + } + + *polyStartIndex += pbgdata->numPolygons; + *vtxStartIndex += pbgdata->numVertices; } void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, Actor* actor) { @@ -3155,7 +3176,7 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { s32 i2; s32 isPaused; DynaPolyActor* dynaActor; - s32 pad; + CollisionPoly* poly; Vec3f polyVtx[3]; Vec3f polyNorm; u32 polyIndex; @@ -3167,7 +3188,6 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { Vec3f vtx; f32 intersect; ScaleRotPos* curTransform; - CollisionPoly* poly; result = BGCHECK_Y_MIN; *dynaRaycastDown->bgId = BGCHECK_SCENE; @@ -3239,9 +3259,12 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { vtxList = dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->vtxList; for (i2 = 0; i2 < 3; i2++) { + s32 pad; + Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[i2])]); SkinMatrix_Vec3fMtxFMultXYZ(&srpMtx, &vtx, &polyVtx[i2]); } + Math3D_SurfaceNorm(&polyVtx[0], &polyVtx[1], &polyVtx[2], &polyNorm); magnitude = Math3D_Vec3fMagnitude(&polyNorm); @@ -3290,8 +3313,6 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo f32 invNormalXZ; f32 planeDist; f32 temp_f18; - f32 zIntersectDist; - f32 xIntersectDist; f32 zMin; f32 zMax; f32 xMin; @@ -3360,8 +3381,10 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo } } if (CollisionPoly_CheckZIntersectApprox(poly, dyna->vtxList, resultPos.x, pos->y, &intersect)) { - if (fabsf(intersect - resultPos.z) <= radius / temp_f18) { - if ((intersect - resultPos.z) * nz <= 4.0f) { + f32 zIntersectDist = intersect - resultPos.z; + + if (fabsf(zIntersectDist) <= radius / temp_f18) { + if (zIntersectDist * nz <= 4.0f) { if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, invNormalXZ, planeDist, radius, outPoly)) { *outBgId = bgId; @@ -3434,7 +3457,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo } if (CollisionPoly_CheckXIntersectApprox(poly, dyna->vtxList, pos->y, resultPos.z, &intersect)) { - xIntersectDist = intersect - resultPos.x; + f32 xIntersectDist = intersect - resultPos.x; + if (fabsf(xIntersectDist) <= radius / temp_f18) { if (xIntersectDist * nx <= 4.0f) { if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, @@ -4223,6 +4247,8 @@ f32 sZorasDomainWaterBoxMaxZ = -967.0f; s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { if (play->sceneId == SCENE_ZORAS_DOMAIN) { + s32 pad; + if (sZorasDomainWaterBoxMinX < x && x < sZorasDomainWaterBoxMaxX && sZorasDomainWaterBoxMinY < *ySurface && *ySurface < sZorasDomainWaterBoxMaxY && sZorasDomainWaterBoxMinZ < z && z < sZorasDomainWaterBoxMaxZ) { *outWaterBox = &sZorasDomainWaterBox; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 7db82ed358..7410dbb2e8 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -7048,12 +7048,16 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState R_CAM_DATA(i) = sCamDataRegsInit[i]; } +#if OOT_DEBUG DebugCamera_Reset(camera, &D_8015BD80); +#endif sInitRegs = false; PREG(88) = -1; } camera->play = D_8015BD7C = play; +#if OOT_DEBUG DebugCamera_Init(&D_8015BD80, camera); +#endif curUID = sNextUID; sNextUID++; while (curUID != 0) { @@ -7722,7 +7726,9 @@ Vec3s Camera_Update(Camera* camera) { if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_START)) { gDebugCamEnabled ^= 1; if (gDebugCamEnabled) { +#if OOT_DEBUG DebugCamera_Enable(&D_8015BD80, camera); +#endif } else if (camera->play->csCtx.state != CS_STATE_IDLE) { Cutscene_StopManual(camera->play, &camera->play->csCtx); } @@ -7731,7 +7737,9 @@ Vec3s Camera_Update(Camera* camera) { // Debug cam update if (gDebugCamEnabled) { camera->play->view.fovy = D_8015BD80.fov; +#if OOT_DEBUG DebugCamera_Update(&D_8015BD80, camera); +#endif View_LookAt(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); if (R_DEBUG_CAM_UPDATE) { PRINTF("camera: debug out\n"); diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c index b1ad5a2089..1a3916ffa0 100644 --- a/src/code/z_fbdemo.c +++ b/src/code/z_fbdemo.c @@ -40,6 +40,22 @@ Gfx sTransTileSetupDL[] = { gsSPEndDisplayList(), }; +#define SET_VERTEX(vtx, x, y, z, s, t, nx, ny, nz, alpha) \ + { \ + Vtx_tn* vtxn = &(vtx)->n; \ + vtxn->ob[0] = (x); \ + vtxn->ob[1] = (y); \ + vtxn->ob[2] = (z); \ + vtxn->flag = 0; \ + vtxn->tc[0] = (s); \ + vtxn->tc[1] = (t); \ + vtxn->n[0] = (nx); \ + vtxn->n[1] = (ny); \ + vtxn->n[2] = (nz); \ + vtxn->a = (alpha); \ + } \ + (void)0 + void TransitionTile_InitGraphics(TransitionTile* this) { s32 frame; s32 col; @@ -61,20 +77,7 @@ void TransitionTile_InitGraphics(TransitionTile* this) { for (row = 0; row < this->rows + 1; row++) { colTex = 0; for (col = 0; col < this->cols + 1; col++) { - Vtx_tn* vtxn = &vtx->n; - - vtx++; - vtxn->tc[0] = colTex << 6; - vtxn->ob[0] = col * 0x20; - vtxn->ob[1] = row * 0x20; - vtxn->ob[2] = -5; - vtxn->flag = 0; - vtxn->tc[1] = rowTex << 6; - vtxn->n[0] = 0; - vtxn->n[1] = 0; - vtxn->n[2] = 120; - vtxn->a = 255; - + SET_VERTEX(vtx++, col * 0x20, row * 0x20, -5, colTex << 6, rowTex << 6, 0, 0, 120, 255); colTex += 0x20; } diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c index 1d76e8ec71..1f0843176d 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.c @@ -62,7 +62,7 @@ void TransitionFade_Update(void* thisx, s32 updateRate) { break; case TRANS_FADE_TYPE_ONE_WAY: - this->timer += updateRate; + ((TransitionFade*)thisx)->timer += updateRate; if (this->timer >= gSaveContext.transFadeDuration) { this->timer = gSaveContext.transFadeDuration; this->isDone = true; diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index 2348fa13a4..e4d4b8a772 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -162,6 +162,8 @@ void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, Ov OPEN_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279); + if (1) {} + Matrix_Push(); if ((overrideLimbDraw == NULL) || diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 35a6bc4a7c..6792b34f92 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -80,9 +80,10 @@ void KaleidoManager_Destroy(void) { void* KaleidoManager_GetRamAddr(void* vram) { KaleidoMgrOverlay* iter = gKaleidoMgrCurOvl; KaleidoMgrOverlay* ovl = iter; - u32 i; if (ovl == NULL) { + u32 i; + iter = &gKaleidoMgrOverlayTable[0]; for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { if (((uintptr_t)vram >= (uintptr_t)iter->vramStart) && ((uintptr_t)iter->vramEnd >= (uintptr_t)vram)) { diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 79d9242f4c..be1d9aa59e 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -56,19 +56,25 @@ void KaleidoScopeCall_Update(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; PauseContext* pauseCtx = &play->pauseCtx; - if (IS_PAUSED(pauseCtx)) { + if (IS_PAUSED(&play->pauseCtx)) { if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) { if (Letterbox_GetSize() == 0) { +#if OOT_DEBUG R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_UCODE_DISAS_LOG_MODE = 3; +#endif + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->unk_1EC = 0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_WAIT_BG_PRERENDER } } else if (pauseCtx->state == PAUSE_STATE_8) { +#if OOT_DEBUG R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_UCODE_DISAS_LOG_MODE = 3; +#endif + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->unk_1EC = 0; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 6585ea54f1..871adabf13 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -20,7 +20,7 @@ void KaleidoSetup_Update(PlayState* play) { (play->sceneId != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) { if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) { - if (BREG(0)) { + if (OOT_DEBUG && BREG(0)) { pauseCtx->debugState = 3; } } else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { @@ -65,23 +65,20 @@ void KaleidoSetup_Update(PlayState* play) { void KaleidoSetup_Init(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; - u64 temp = 0; // Necessary to match pauseCtx->state = PAUSE_STATE_OFF; pauseCtx->debugState = 0; - pauseCtx->alpha = 0; - pauseCtx->unk_1EA = 0; - pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; - pauseCtx->mode = 0; - pauseCtx->pageIndex = PAUSE_ITEM; - pauseCtx->unk_1F4 = 160.0f; - pauseCtx->unk_1F8 = 160.0f; - pauseCtx->unk_1FC = 160.0f; - pauseCtx->unk_200 = 160.0f; + pauseCtx->eye.x = pauseCtx->eye.y = 0.0f; pauseCtx->eye.z = 64.0f; pauseCtx->unk_1F0 = 936.0f; - pauseCtx->eye.x = pauseCtx->eye.y = 0.0f; + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 160.0f; + + pauseCtx->alpha = 0; + + // mainState = PAUSE_MAIN_STATE_IDLE , pageIndex = PAUSE_ITEM + pauseCtx->unk_1EA = pauseCtx->mainState = pauseCtx->mode = pauseCtx->pageIndex = 0; + pauseCtx->unk_204 = -314.0f; pauseCtx->cursorPoint[PAUSE_ITEM] = 0; @@ -94,8 +91,8 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->cursorY[PAUSE_ITEM] = 0; pauseCtx->cursorX[PAUSE_MAP] = 0; pauseCtx->cursorY[PAUSE_MAP] = 0; - pauseCtx->cursorX[PAUSE_QUEST] = temp; - pauseCtx->cursorY[PAUSE_QUEST] = temp; + pauseCtx->cursorX[PAUSE_QUEST] = 0; + pauseCtx->cursorY[PAUSE_QUEST] = 0; pauseCtx->cursorX[PAUSE_EQUIP] = 1; pauseCtx->cursorY[PAUSE_EQUIP] = 0; diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c index e1ab29cef9..5b3bb2e670 100644 --- a/src/code/z_kanfont.c +++ b/src/code/z_kanfont.c @@ -9,8 +9,10 @@ void func_8006EE50(Font* font, u16 arg1, u16 arg2) { * at `codePointIndex`. The value of `character` is the ASCII codepoint subtract ' '/0x20. */ void Font_LoadChar(Font* font, u8 character, u16 codePointIndex) { + u8 charTmp = character; + DMA_REQUEST_SYNC(&font->charTexBuf[codePointIndex], - (uintptr_t)_nes_font_staticSegmentRomStart + character * FONT_CHAR_TEX_SIZE, FONT_CHAR_TEX_SIZE, + (uintptr_t)_nes_font_staticSegmentRomStart + charTmp * FONT_CHAR_TEX_SIZE, FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 93); } @@ -31,10 +33,7 @@ void Font_LoadMessageBoxIcon(Font* font, u16 icon) { * the font buffer. */ void Font_LoadOrderedFont(Font* font) { - u8* fontBuf; - uintptr_t fontStatic; s32 len; - s32 jj; s32 codePointIndex; s32 fontBufIndex; u32 offset; @@ -44,23 +43,22 @@ void Font_LoadOrderedFont(Font* font) { DMA_REQUEST_SYNC(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, len, "../z_kanfont.c", 122); - PRINTF("msg_data=%x, msg_data0=%x jj=%x\n", font->msgOffset, font->msgLength, jj = len); - len = jj; - for (fontBufIndex = 0, codePointIndex = 0; font->msgBuf[codePointIndex] != MESSAGE_END; codePointIndex++) { - if (codePointIndex > len) { + PRINTF("msg_data=%x, msg_data0=%x jj=%x\n", font->msgOffset, font->msgLength, len * 1); + + fontBufIndex = 0; + for (codePointIndex = 0; font->msgBuf[codePointIndex] != MESSAGE_END; codePointIndex++) { + if (codePointIndex > (len * 1)) { PRINTF("ERROR!! エラー!!! error───!!!!\n"); return; } if (font->msgBuf[codePointIndex] != MESSAGE_NEWLINE) { - fontBuf = font->fontBuf + fontBufIndex * 8; - fontStatic = (uintptr_t)_nes_font_staticSegmentRomStart; - PRINTF("nes_mes_buf[%d]=%d\n", codePointIndex, font->msgBuf[codePointIndex]); offset = (font->msgBuf[codePointIndex] - ' ') * FONT_CHAR_TEX_SIZE; - DMA_REQUEST_SYNC(fontBuf, fontStatic + offset, FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134); + DMA_REQUEST_SYNC(font->fontBuf + fontBufIndex * 8, (uintptr_t)_nes_font_staticSegmentRomStart + offset, + FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134); fontBufIndex += FONT_CHAR_TEX_SIZE / 8; } } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 771cc1d377..db80807355 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -252,7 +252,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) gSaveContext.sunsSongState = SUNSSONG_INACTIVE; - if (((void)0, gSaveContext.save.dayTime) > CLOCK_TIME(18, 0) || + //! FAKE: (void)0 on CLOCK_TIME(18, 0) + if (((void)0, gSaveContext.save.dayTime) > ((void)0, CLOCK_TIME(18, 0)) || ((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(6, 30)) { ((void)0, gSaveContext.save.nightFlag = 1); } else { @@ -335,12 +336,17 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) envCtx->lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE; envCtx->lightBlendRateOverride = LIGHT_BLENDRATE_OVERRIDE_NONE; - R_ENV_TIME_SPEED_OLD = gTimeSpeed = envCtx->sceneTimeSpeed = 0; + envCtx->sceneTimeSpeed = 0; + gTimeSpeed = envCtx->sceneTimeSpeed; + +#if OOT_DEBUG + R_ENV_TIME_SPEED_OLD = gTimeSpeed; R_ENV_DISABLE_DBG = true; if (CREG(3) != 0) { gSaveContext.chamberCutsceneNum = CREG(3) - 1; } +#endif play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0; @@ -405,6 +411,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) gSkyboxIsChanging = false; gSaveContext.retainWeatherMode = false; +#if OOT_DEBUG R_ENV_LIGHT1_DIR(0) = 80; R_ENV_LIGHT1_DIR(1) = 80; R_ENV_LIGHT1_DIR(2) = 80; @@ -419,6 +426,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) cREG(12) = 0; cREG(13) = 0; cREG(14) = 0; +#endif + gUseCutsceneCam = true; for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { @@ -512,10 +521,9 @@ u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minSt f32 Environment_LerpWeight(u16 max, u16 min, u16 val) { f32 diff = max - min; - f32 ret; if (diff != 0.0f) { - ret = 1.0f - (max - val) / diff; + f32 ret = 1.0f - (max - val) / diff; if (!(ret >= 1.0f)) { return ret; @@ -700,10 +708,12 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon } } +#if OOT_DEBUG if (newSkybox1Index == 0xFF) { // "Environment VR data acquisition failed! Report to Sasaki!" PRINTF(VT_COL(RED, WHITE) "\n環境VRデータ取得失敗! ささきまでご報告を!" VT_RST); } +#endif if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) { envCtx->skyboxDmaState = SKYBOX_DMA_TEXTURE1_START; @@ -815,6 +825,7 @@ void Environment_DisableUnderwaterLights(PlayState* play) { } } +#if OOT_DEBUG void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) { GfxPrint printer; s32 pad[2]; @@ -869,6 +880,7 @@ void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) { *gfx = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } +#endif void Environment_PlayTimeBasedSequence(PlayState* play); void Environment_UpdateRain(PlayState* play); @@ -881,7 +893,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex u16 j; u16 time; EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList; - s32 adjustment; + u8 blendRate; if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) && (((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) { @@ -951,6 +963,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex gSaveContext.save.nightFlag = 0; } +#if OOT_DEBUG if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) { Gfx* displayList; Gfx* prevDisplayList; @@ -967,249 +980,247 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex if (1) {} CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690); } +#endif if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) && (envCtx->lightBlendOverride != LIGHT_BLEND_OVERRIDE_FULL_CONTROL) && (envCtx->lightSetting != envCtx->lightSettingOverride) && (envCtx->lightBlend >= 1.0f) && (envCtx->lightSettingOverride <= LIGHT_SETTING_MAX)) { + envCtx->lightBlend = 0.0f; envCtx->prevLightSetting = envCtx->lightSetting; envCtx->lightSetting = envCtx->lightSettingOverride; - envCtx->lightBlend = 0.0f; } - if (envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_FULL_CONTROL) { - if ((envCtx->lightMode == LIGHT_MODE_TIME) && - (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { - for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) { - if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) && - ((gSaveContext.skyboxTime < sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime) || - sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime == 0xFFFF)) { - u8 blend8[2]; - s16 blend16[2]; + if (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_FULL_CONTROL) { + // Do nothing; Skip updating lights based on time or light settings + } else if ((envCtx->lightMode == LIGHT_MODE_TIME) && + (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { + for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) { + if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) && + ((gSaveContext.skyboxTime < sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime) || + sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime == 0xFFFF)) { + u8 blend8[2]; + s16 blend16[2]; - timeChangeBlend = - Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime, - sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime, - ((void)0, gSaveContext.skyboxTime)); + timeChangeBlend = Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime, + sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime, + ((void)0, gSaveContext.skyboxTime)); - sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3; - sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3; - sSandstormLerpScale = timeChangeBlend; + sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3; + sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3; + sSandstormLerpScale = timeChangeBlend; - if (envCtx->changeLightEnabled) { - configChangeBlend = - ((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration; - envCtx->changeLightTimer--; + if (envCtx->changeLightEnabled) { + configChangeBlend = + ((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration; + envCtx->changeLightTimer--; - if (envCtx->changeLightTimer <= 0) { - envCtx->changeLightEnabled = false; - envCtx->lightConfig = envCtx->changeLightNextConfig; - } + if (envCtx->changeLightTimer <= 0) { + envCtx->changeLightEnabled = false; + envCtx->lightConfig = envCtx->changeLightNextConfig; } + } - for (j = 0; j < 3; j++) { - // blend ambient color - blend8[0] = - LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] - .ambientColor[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] - .ambientColor[j], - timeChangeBlend); - blend8[1] = LERP( - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] - .ambientColor[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] - .nextLightSetting] - .ambientColor[j], - timeChangeBlend); - *(envCtx->lightSettings.ambientColor + j) = LERP(blend8[0], blend8[1], configChangeBlend); - } - - // set light1 direction for the sun - envCtx->lightSettings.light1Dir[0] = - -(Math_SinS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f); - envCtx->lightSettings.light1Dir[1] = - Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f; - envCtx->lightSettings.light1Dir[2] = - Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f; - - // set light2 direction for the moon - envCtx->lightSettings.light2Dir[0] = -envCtx->lightSettings.light1Dir[0]; - envCtx->lightSettings.light2Dir[1] = -envCtx->lightSettings.light1Dir[1]; - envCtx->lightSettings.light2Dir[2] = -envCtx->lightSettings.light1Dir[2]; - - for (j = 0; j < 3; j++) { - // blend light1Color - blend8[0] = - LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] - .light1Color[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] - .light1Color[j], - timeChangeBlend); - blend8[1] = LERP( - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] - .light1Color[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] - .nextLightSetting] - .light1Color[j], - timeChangeBlend); - *(envCtx->lightSettings.light1Color + j) = LERP(blend8[0], blend8[1], configChangeBlend); - - // blend light2Color - blend8[0] = - LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] - .light2Color[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] - .light2Color[j], - timeChangeBlend); - blend8[1] = LERP( - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] - .light2Color[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] - .nextLightSetting] - .light2Color[j], - timeChangeBlend); - *(envCtx->lightSettings.light2Color + j) = LERP(blend8[0], blend8[1], configChangeBlend); - } - - // blend fogColor - for (j = 0; j < 3; j++) { - blend8[0] = - LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] - .fogColor[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] - .fogColor[j], - timeChangeBlend); - blend8[1] = LERP( - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] - .fogColor[j], - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] - .nextLightSetting] - .fogColor[j], - timeChangeBlend); - *(envCtx->lightSettings.fogColor + j) = LERP(blend8[0], blend8[1], configChangeBlend); - } - - blend16[0] = LERP16( - ENV_LIGHT_SETTINGS_FOG_NEAR( - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] - .blendRateAndFogNear), - ENV_LIGHT_SETTINGS_FOG_NEAR( - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] - .blendRateAndFogNear), - timeChangeBlend); - blend16[1] = LERP16( - ENV_LIGHT_SETTINGS_FOG_NEAR( - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] - .blendRateAndFogNear), - ENV_LIGHT_SETTINGS_FOG_NEAR( - lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i] - .nextLightSetting] - .blendRateAndFogNear), - timeChangeBlend); - - envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend); - - blend16[0] = LERP16( - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar, - lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar, - timeChangeBlend); - blend16[1] = LERP16( + for (j = 0; j < 3; j++) { + // blend ambient color + blend8[0] = + LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] + .ambientColor[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] + .ambientColor[j], + timeChangeBlend); + blend8[1] = LERP( lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] - .zFar, + .ambientColor[j], lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] - .zFar, + .ambientColor[j], timeChangeBlend); - - envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend); - - if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >= - envCtx->numLightSettings) { - // "The color palette setting seems to be wrong!" - PRINTF(VT_COL(RED, WHITE) "\nカラーパレットの設定がおかしいようです!" VT_RST); - - // "Palette setting = [] Last palette number = []" - PRINTF(VT_COL(RED, WHITE) "\n設定パレット=[%d] 最後パレット番号=[%d]\n" VT_RST, - sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting, - envCtx->numLightSettings - 1); - } - break; - } - } - } else { - if (!envCtx->lightBlendEnabled) { - for (i = 0; i < 3; i++) { - envCtx->lightSettings.ambientColor[i] = lightSettingsList[envCtx->lightSetting].ambientColor[i]; - envCtx->lightSettings.light1Dir[i] = lightSettingsList[envCtx->lightSetting].light1Dir[i]; - envCtx->lightSettings.light1Color[i] = lightSettingsList[envCtx->lightSetting].light1Color[i]; - envCtx->lightSettings.light2Dir[i] = lightSettingsList[envCtx->lightSetting].light2Dir[i]; - envCtx->lightSettings.light2Color[i] = lightSettingsList[envCtx->lightSetting].light2Color[i]; - envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i]; + envCtx->lightSettings.ambientColor[j] = LERP(blend8[0], blend8[1], configChangeBlend); } - envCtx->lightSettings.fogNear = - ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); - envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar; - envCtx->lightBlend = 1.0f; - } else { - u8 blendRate = - ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); + // set light1 direction for the sun + envCtx->lightSettings.light1Dir[0] = + -(Math_SinS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f); + envCtx->lightSettings.light1Dir[1] = + Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f; + envCtx->lightSettings.light1Dir[2] = + Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f; - if (blendRate == 0) { - blendRate++; + // set light2 direction for the moon + envCtx->lightSettings.light2Dir[0] = -envCtx->lightSettings.light1Dir[0]; + envCtx->lightSettings.light2Dir[1] = -envCtx->lightSettings.light1Dir[1]; + envCtx->lightSettings.light2Dir[2] = -envCtx->lightSettings.light1Dir[2]; + + for (j = 0; j < 3; j++) { + // blend light1Color + blend8[0] = + LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] + .light1Color[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] + .light1Color[j], + timeChangeBlend); + blend8[1] = LERP( + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] + .light1Color[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] + .light1Color[j], + timeChangeBlend); + envCtx->lightSettings.light1Color[j] = LERP(blend8[0], blend8[1], configChangeBlend); + + // blend light2Color + blend8[0] = + LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] + .light2Color[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] + .light2Color[j], + timeChangeBlend); + blend8[1] = LERP( + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] + .light2Color[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] + .light2Color[j], + timeChangeBlend); + envCtx->lightSettings.light2Color[j] = LERP(blend8[0], blend8[1], configChangeBlend); } - if (envCtx->lightBlendRateOverride != LIGHT_BLENDRATE_OVERRIDE_NONE) { - blendRate = envCtx->lightBlendRateOverride; + // blend fogColor + for (j = 0; j < 3; j++) { + blend8[0] = LERP( + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].fogColor[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] + .fogColor[j], + timeChangeBlend); + blend8[1] = LERP( + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] + .fogColor[j], + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] + .fogColor[j], + timeChangeBlend); + envCtx->lightSettings.fogColor[j] = LERP(blend8[0], blend8[1], configChangeBlend); } - if (envCtx->lightBlendOverride == LIGHT_BLEND_OVERRIDE_NONE) { - envCtx->lightBlend += blendRate / 255.0f; + blend16[0] = + LERP16(ENV_LIGHT_SETTINGS_FOG_NEAR( + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] + .blendRateAndFogNear), + ENV_LIGHT_SETTINGS_FOG_NEAR( + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] + .blendRateAndFogNear), + timeChangeBlend); + blend16[1] = LERP16( + ENV_LIGHT_SETTINGS_FOG_NEAR( + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] + .blendRateAndFogNear), + ENV_LIGHT_SETTINGS_FOG_NEAR( + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] + .blendRateAndFogNear), + timeChangeBlend); + + envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend); + + blend16[0] = + LERP16(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar, + lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar, + timeChangeBlend); + blend16[1] = LERP16( + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting].zFar, + lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] + .zFar, + timeChangeBlend); + + envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend); + +#if OOT_DEBUG + if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >= + envCtx->numLightSettings) { + // "The color palette setting seems to be wrong!" + PRINTF(VT_COL(RED, WHITE) "\nカラーパレットの設定がおかしいようです!" VT_RST); + + // "Palette setting = [] Last palette number = []" + PRINTF(VT_COL(RED, WHITE) "\n設定パレット=[%d] 最後パレット番号=[%d]\n" VT_RST, + sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting, + envCtx->numLightSettings - 1); } +#endif - if (envCtx->lightBlend > 1.0f) { - envCtx->lightBlend = 1.0f; - } - - for (i = 0; i < 3; i++) { - envCtx->lightSettings.ambientColor[i] = - LERP(lightSettingsList[envCtx->prevLightSetting].ambientColor[i], - lightSettingsList[envCtx->lightSetting].ambientColor[i], envCtx->lightBlend); - envCtx->lightSettings.light1Dir[i] = - LERP16(lightSettingsList[envCtx->prevLightSetting].light1Dir[i], - lightSettingsList[envCtx->lightSetting].light1Dir[i], envCtx->lightBlend); - envCtx->lightSettings.light1Color[i] = - LERP(lightSettingsList[envCtx->prevLightSetting].light1Color[i], - lightSettingsList[envCtx->lightSetting].light1Color[i], envCtx->lightBlend); - envCtx->lightSettings.light2Dir[i] = - LERP16(lightSettingsList[envCtx->prevLightSetting].light2Dir[i], - lightSettingsList[envCtx->lightSetting].light2Dir[i], envCtx->lightBlend); - envCtx->lightSettings.light2Color[i] = - LERP(lightSettingsList[envCtx->prevLightSetting].light2Color[i], - lightSettingsList[envCtx->lightSetting].light2Color[i], envCtx->lightBlend); - envCtx->lightSettings.fogColor[i] = - LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i], - lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend); - } - envCtx->lightSettings.fogNear = LERP16( - ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear), - ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear), - envCtx->lightBlend); - envCtx->lightSettings.zFar = - LERP16(lightSettingsList[envCtx->prevLightSetting].zFar, - lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend); - } - - if (envCtx->lightSetting >= envCtx->numLightSettings) { - // "The color palette seems to be wrong!" - PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!"); - - // "Palette setting = [] Last palette number = []" - PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting, - envCtx->numLightSettings); + break; } } + } else { + if (!envCtx->lightBlendEnabled) { + for (i = 0; i < 3; i++) { + envCtx->lightSettings.ambientColor[i] = lightSettingsList[envCtx->lightSetting].ambientColor[i]; + envCtx->lightSettings.light1Dir[i] = lightSettingsList[envCtx->lightSetting].light1Dir[i]; + envCtx->lightSettings.light1Color[i] = lightSettingsList[envCtx->lightSetting].light1Color[i]; + envCtx->lightSettings.light2Dir[i] = lightSettingsList[envCtx->lightSetting].light2Dir[i]; + envCtx->lightSettings.light2Color[i] = lightSettingsList[envCtx->lightSetting].light2Color[i]; + envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i]; + } + + envCtx->lightSettings.fogNear = + ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); + envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar; + envCtx->lightBlend = 1.0f; + } else { + blendRate = + ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); + + if (blendRate == 0) { + blendRate++; + } + + if (envCtx->lightBlendRateOverride != LIGHT_BLENDRATE_OVERRIDE_NONE) { + blendRate = envCtx->lightBlendRateOverride; + } + + if (envCtx->lightBlendOverride == LIGHT_BLEND_OVERRIDE_NONE) { + envCtx->lightBlend += blendRate / 255.0f; + } + + if (envCtx->lightBlend > 1.0f) { + envCtx->lightBlend = 1.0f; + } + + for (i = 0; i < 3; i++) { + envCtx->lightSettings.ambientColor[i] = + LERP(lightSettingsList[envCtx->prevLightSetting].ambientColor[i], + lightSettingsList[envCtx->lightSetting].ambientColor[i], envCtx->lightBlend); + envCtx->lightSettings.light1Dir[i] = + LERP16(lightSettingsList[envCtx->prevLightSetting].light1Dir[i], + lightSettingsList[envCtx->lightSetting].light1Dir[i], envCtx->lightBlend); + envCtx->lightSettings.light1Color[i] = + LERP(lightSettingsList[envCtx->prevLightSetting].light1Color[i], + lightSettingsList[envCtx->lightSetting].light1Color[i], envCtx->lightBlend); + envCtx->lightSettings.light2Dir[i] = + LERP16(lightSettingsList[envCtx->prevLightSetting].light2Dir[i], + lightSettingsList[envCtx->lightSetting].light2Dir[i], envCtx->lightBlend); + envCtx->lightSettings.light2Color[i] = + LERP(lightSettingsList[envCtx->prevLightSetting].light2Color[i], + lightSettingsList[envCtx->lightSetting].light2Color[i], envCtx->lightBlend); + envCtx->lightSettings.fogColor[i] = + LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i], + lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend); + } + + envCtx->lightSettings.fogNear = + LERP16(ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear), + ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear), + envCtx->lightBlend); + envCtx->lightSettings.zFar = LERP16(lightSettingsList[envCtx->prevLightSetting].zFar, + lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend); + } + +#if OOT_DEBUG + if (envCtx->lightSetting >= envCtx->numLightSettings) { + // "The color palette seems to be wrong!" + PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!"); + + // "Palette setting = [] Last palette number = []" + PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting, + envCtx->numLightSettings); + } +#endif } envCtx->lightBlendEnabled = true; @@ -1261,22 +1272,20 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex envCtx->dirLight2.params.dir.z = envCtx->lightSettings.light2Dir[2]; // Adjust fog near and far if necessary - adjustment = envCtx->lightSettings.fogNear + envCtx->adjFogNear; - if (adjustment <= ENV_FOGNEAR_MAX) { - lightCtx->fogNear = adjustment; + if ((envCtx->lightSettings.fogNear + envCtx->adjFogNear) <= ENV_FOGNEAR_MAX) { + lightCtx->fogNear = envCtx->lightSettings.fogNear + envCtx->adjFogNear; } else { lightCtx->fogNear = ENV_FOGNEAR_MAX; } - adjustment = envCtx->lightSettings.zFar + envCtx->adjZFar; - - if (adjustment <= ENV_ZFAR_MAX) { - lightCtx->zFar = adjustment; + if ((envCtx->lightSettings.zFar + envCtx->adjZFar) <= ENV_ZFAR_MAX) { + lightCtx->zFar = envCtx->lightSettings.zFar + envCtx->adjZFar; } else { lightCtx->zFar = ENV_ZFAR_MAX; } +#if OOT_DEBUG // When environment debug is enabled, various environment related variables can be configured via the reg editor if (R_ENV_DISABLE_DBG) { R_ENV_AMBIENT_COLOR(0) = lightCtx->ambientColor[0]; @@ -1357,6 +1366,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex envCtx->windDirection.z = R_ENV_WIND_DIR(2); envCtx->windSpeed = R_ENV_WIND_SPEED; } +#endif if ((envCtx->dirLight1.params.dir.x == 0) && (envCtx->dirLight1.params.dir.y == 0) && (envCtx->dirLight1.params.dir.z == 0)) { @@ -2366,9 +2376,6 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) { Color_RGBA8 envColor; s32 pad; f32 sp98; - u16 sp96; - u16 sp94; - u16 sp92; switch (sandstormState) { case SANDSTORM_ACTIVE: @@ -2475,25 +2482,27 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) { envColor.g = ((envColor.g * sp98) + ((6.0f - sp98) * primColor.g)) * (1.0f / 6.0f); envColor.b = ((envColor.b * sp98) + ((6.0f - sp98) * primColor.b)) * (1.0f / 6.0f); - sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f)); - sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f)); - sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f)); + { + u16 sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f)); + u16 sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f)); + u16 sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f)); - OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044); + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044); - POLY_XLU_DISP = Gfx_SetupDL_64(POLY_XLU_DISP); + POLY_XLU_DISP = Gfx_SetupDL_64(POLY_XLU_DISP); - gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); - gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA); - gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1, (u32)sp94 % 4096, - 4095 - ((u32)sp92 % 4096), 256, 64)); - gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); - gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA); + gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1, + (u32)sp94 % 4096, 4095 - ((u32)sp92 % 4096), 256, 64)); + gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); + gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); - CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068); + } sSandstormScroll += (s32)sp98; } diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.c index 47d3d2bdae..31d9f93ad2 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.c @@ -118,8 +118,8 @@ void MapMark_DrawForDungeon(PlayState* play) { markInfo->textureWidth, markInfo->textureHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - rectLeft = (GREG(94) + markPoint->x + 204) << 2; - rectTop = (GREG(95) + markPoint->y + 140) << 2; + rectLeft = ((OOT_DEBUG ? GREG(94) : 0) + markPoint->x + 204) << 2; + rectTop = ((OOT_DEBUG ? GREG(95) : 0) + markPoint->y + 140) << 2; gSPTextureRectangle(OVERLAY_DISP++, rectLeft, rectTop, markInfo->rectWidth + rectLeft, rectTop + markInfo->rectHeight, G_TX_RENDERTILE, 0, 0, markInfo->dsdx, markInfo->dtdy); diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 946a786b8b..a4100700b5 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1246,23 +1246,33 @@ Gfx* Gfx_SetupDL_69NoCD(Gfx* gfx) { return gfx; } +#if OOT_DEBUG +#define HREG_21 HREG(21) +#define HREG_22 HREG(22) +#else +#define HREG_21 0 +#define HREG_22 0 +#endif + Gfx* func_800947AC(Gfx* gfx) { gSPDisplayList(gfx++, sSetupDL[SETUPDL_65]); gDPSetColorDither(gfx++, G_CD_DISABLE); // clang-format off - switch (HREG(21)) { + switch (HREG_21) { case 1: gDPSetAlphaDither(gfx++, G_AD_DISABLE); break; case 2: gDPSetAlphaDither(gfx++, G_AD_PATTERN); break; case 3: gDPSetAlphaDither(gfx++, G_AD_NOTPATTERN); break; case 4: gDPSetAlphaDither(gfx++, G_AD_NOISE); break; + default: break; } - switch (HREG(22)) { + switch (HREG_22) { case 1: gDPSetColorDither(gfx++, G_CD_DISABLE); break; case 2: gDPSetColorDither(gfx++, G_CD_MAGICSQ); break; case 3: gDPSetColorDither(gfx++, G_CD_BAYER); break; case 4: gDPSetColorDither(gfx++, G_CD_NOISE); break; + default: break; } // clang-format on @@ -1472,6 +1482,7 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (gTransitionTileState <= TRANS_TILE_SETUP)) { s32 letterboxSize = Letterbox_GetSize(); +#if OOT_DEBUG if (R_HREG_MODE == HREG_MODE_SETUP_FRAME) { if (R_SETUP_FRAME_INIT != HREG_MODE_SETUP_FRAME) { R_SETUP_FRAME_GET = (SETUP_FRAME_LETTERBOX_SIZE_FLAG | SETUP_FRAME_BASE_COLOR_FLAG); @@ -1514,6 +1525,7 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { b = R_SETUP_FRAME_BASE_COLOR_B; } } +#endif // Set the whole z buffer to maximum depth // Don't bother with pixels that are being covered by the letterbox diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 4be3f6735c..42dfa4e9bc 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -152,6 +152,7 @@ void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, } (*mtx)++; } else if (limbDList != NULL) { + if (1) {} MATRIX_TO_MTX(*mtx, "../z_skelanime.c", 954); (*mtx)++; } @@ -366,6 +367,7 @@ void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, gSPDisplayList(POLY_OPA_DISP++, newDList); (*limbMatrices)++; } else if (limbDList != NULL) { + if (1) {} MATRIX_TO_MTX(*limbMatrices, "../z_skelanime.c", 1249); (*limbMatrices)++; } @@ -467,7 +469,7 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount u16 staticIndexMax = animHeader->staticIndexMax; s32 i; - for (i = 0; i < limbCount; i++, frameTable++, jointIndices++) { + for (i = 0; i < limbCount; i++) { if ((frameTable == NULL) || (jointIndices == NULL) || (dynamicData == NULL) || (staticData == NULL)) { LOG_ADDRESS("out", frameTable, "../z_skelanime.c", 1392); LOG_ADDRESS("ref_tbl", jointIndices, "../z_skelanime.c", 1393); @@ -481,6 +483,8 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount (jointIndices->y >= staticIndexMax) ? dynamicData[jointIndices->y] : staticData[jointIndices->y]; frameTable->z = (jointIndices->z >= staticIndexMax) ? dynamicData[jointIndices->z] : staticData[jointIndices->z]; + jointIndices++; + frameTable++; } } @@ -1024,10 +1028,11 @@ void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx) { AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp, AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor, }; - AnimationEntry* entry; + AnimationEntry* entry = animationCtx->entries; - for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { + for (; animationCtx->animationCount != 0; animationCtx->animationCount--) { animFuncs[entry->type](play, &entry->data); + entry++; } sAnimQueueFlags = 1; diff --git a/src/code/z_sram.c b/src/code/z_sram.c index d5d72a664e..253ff4b304 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -511,8 +511,7 @@ void Sram_WriteSave(SramContext* sramCtx) { gSaveContext.save.info.checksum = 0; ptr = (u16*)&gSaveContext; - checksum = 0; - j = 0; + checksum = j = 0; for (offset = 0; offset < CHECKSUM_SIZE; offset++) { if (++j == 0x20) { @@ -618,6 +617,7 @@ void Sram_VerifyAndLoadAllSaves(FileSelectState* fileSelect, SramContext* sramCt bzero(&gSaveContext.save.totalDays, sizeof(s32)); bzero(&gSaveContext.save.bgsDayCount, sizeof(s32)); +#if OOT_DEBUG if (!slotNum) { Sram_InitDebugSave(); gSaveContext.save.info.playerData.newf[0] = 'Z'; @@ -633,6 +633,9 @@ void Sram_VerifyAndLoadAllSaves(FileSelectState* fileSelect, SramContext* sramCt } else { Sram_InitNewSave(); } +#else + Sram_InitNewSave(); +#endif ptr = (u16*)&gSaveContext; PRINTF("\n--------------------------------------------------------------\n"); @@ -718,20 +721,26 @@ void Sram_InitSave(FileSelectState* fileSelect, SramContext* sramCtx) { u16* ptr; u16 checksum; +#if OOT_DEBUG if (fileSelect->buttonIndex != 0) { Sram_InitNewSave(); } else { Sram_InitDebugSave(); } +#else + Sram_InitNewSave(); +#endif gSaveContext.save.entranceIndex = ENTR_LINKS_HOUSE_0; gSaveContext.save.linkAge = LINK_AGE_CHILD; gSaveContext.save.dayTime = CLOCK_TIME(10, 0); gSaveContext.save.cutsceneIndex = 0xFFF1; +#if OOT_DEBUG if (fileSelect->buttonIndex == 0) { gSaveContext.save.cutsceneIndex = 0; } +#endif for (offset = 0; offset < 8; offset++) { gSaveContext.save.info.playerData.playerName[offset] = fileSelect->fileNames[fileSelect->buttonIndex][offset]; @@ -753,10 +762,8 @@ void Sram_InitSave(FileSelectState* fileSelect, SramContext* sramCtx) { PRINTF("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); ptr = (u16*)&gSaveContext; - j = 0; - checksum = 0; - for (offset = 0; offset < CHECKSUM_SIZE; offset++) { + for (j = 0, checksum = 0, offset = 0; offset < CHECKSUM_SIZE; offset++) { PRINTF("%x ", *ptr); checksum += *ptr++; if (++j == 0x20) { @@ -893,6 +900,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { Sram_WriteSramHeader(sramCtx); } +#if OOT_DEBUG if (CHECK_BTN_ANY(gameState->input[2].cur.button, BTN_DRIGHT)) { bzero(sramCtx->readBuff, SRAM_SIZE); for (i = 0; i < CHECKSUM_SIZE; i++) { @@ -901,6 +909,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE); PRINTF("SRAM破壊!!!!!!\n"); // "SRAM destruction! ! ! ! ! !" } +#endif // "GOOD! GOOD! Size = %d + %d = %d" PRINTF("GOOD!GOOD! サイズ=%d + %d = %d\n", sizeof(SaveInfo), 4, sizeof(SaveInfo) + 4); diff --git a/src/code/z_ss_sram.c b/src/code/z_ss_sram.c index 8feef8ad1d..75c61539a2 100644 --- a/src/code/z_ss_sram.c +++ b/src/code/z_ss_sram.c @@ -9,7 +9,7 @@ typedef struct { SsSramContext sSsSramContext = { 0 }; -void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, +void SsSram_Init(s32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, u8 handlePulse, u32 handleSpeed) { u32 prevInt; OSPiHandle* handle = &sSsSramContext.piHandle; @@ -49,7 +49,7 @@ void SsSram_Dma(void* dramAddr, size_t size, s32 direction) { osInvalDCache(dramAddr, size); } -void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction) { +void SsSram_ReadWrite(s32 addr, void* dramAddr, size_t size, s32 direction) { PRINTF("ssSRAMReadWrite:%08x %08x %08x %d\n", addr, dramAddr, size, direction); SsSram_Init(addr, DEVICE_TYPE_SRAM, PI_DOMAIN2, 5, 0xD, 2, 0xC, 0); SsSram_Dma(dramAddr, size, direction); diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c index 90080b79cf..3e9f15eb52 100644 --- a/src/code/z_viszbuf.c +++ b/src/code/z_viszbuf.c @@ -47,14 +47,18 @@ extern u16 D_0E000000[]; void VisZBuf_Init(VisZBuf* this) { this->vis.type = VIS_ZBUF_TYPE_IA; this->vis.scissorType = VIS_NO_SETSCISSOR; + this->vis.primColor.r = 255; this->vis.primColor.g = 255; this->vis.primColor.b = 255; this->vis.primColor.a = 255; + + // clang-format off + this->vis.envColor.r = 0; \ + this->vis.envColor.g = 0; \ + this->vis.envColor.b = 0; \ this->vis.envColor.a = 255; - this->vis.envColor.r = 0; - this->vis.envColor.g = 0; - this->vis.envColor.b = 0; + // clang-format on } void VisZBuf_Destroy(VisZBuf* this) { diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 5b1e963064..d085142969 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -139,25 +139,6 @@ void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { Player* player = GET_PLAYER(play); - Actor* touchedActor; - Actor* grabbed; - Vec3f bodyDistDiffVec; - Vec3f newPos; - f32 bodyDistDiff; - f32 phi_f16; - DynaPolyActor* dynaPolyActor; - f32 curGrabbedDist; - f32 grabbedDist; - s32 pad; - CollisionPoly* poly; - s32 bgId; - Vec3f intersectPos; - Vec3f prevFrameDiff; - Vec3f sp60; - f32 polyNormalX; - f32 polyNormalZ; - f32 velocity; - s32 pad1; if ((this->actor.parent == NULL) || (!Player_HoldsHookshot(player))) { ArmsHook_DetachHookFromActor(this); @@ -170,7 +151,8 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { if ((this->timer != 0) && (this->collider.base.atFlags & AT_HIT) && (this->collider.elem.atHitElem->elemType != ELEMTYPE_UNK4)) { - touchedActor = this->collider.base.at; + Actor* touchedActor = this->collider.base.at; + if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_9 | ACTOR_FLAG_10))) { if (this->collider.elem.atHitElem->bumperFlags & BUMP_HOOKABLE) { ArmsHook_AttachHookToActor(this, touchedActor); @@ -182,7 +164,20 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { this->timer = 0; Audio_PlaySfxGeneral(NA_SE_IT_ARROW_STICK_CRE, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - } else if (DECR(this->timer) == 0) { + return; + } + + if (DECR(this->timer) == 0) { + Actor* grabbed; + Vec3f bodyDistDiffVec; + Vec3f newPos; + f32 bodyDistDiff; + f32 phi_f16; + s32 pad1; + f32 curGrabbedDist; + f32 grabbedDist; + f32 velocity; + grabbed = this->grabbed; if (grabbed != NULL) { if ((grabbed->update == NULL) || !CHECK_FLAG_ALL(grabbed->flags, ACTOR_FLAG_13)) { @@ -250,6 +245,12 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { } } } else { + CollisionPoly* poly; + s32 bgId; + Vec3f intersectPos; + Vec3f prevFrameDiff; + Vec3f sp60; + Actor_MoveXZGravity(&this->actor); Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff); Math_Vec3f_Sum(&this->unk_1E8, &prevFrameDiff, &this->unk_1E8); @@ -260,13 +261,17 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { if (BgCheck_EntityLineTest1(&play->colCtx, &sp60, &this->unk_1E8, &intersectPos, &poly, true, true, true, true, &bgId) && !func_8002F9EC(play, &this->actor, poly, bgId, &intersectPos)) { - polyNormalX = COLPOLY_GET_NORMAL(poly->normal.x); - polyNormalZ = COLPOLY_GET_NORMAL(poly->normal.z); + f32 polyNormalX = COLPOLY_GET_NORMAL(poly->normal.x); + f32 polyNormalZ = COLPOLY_GET_NORMAL(poly->normal.z); + s32 pad; + Math_Vec3f_Copy(&this->actor.world.pos, &intersectPos); this->actor.world.pos.x += 10.0f * polyNormalX; this->actor.world.pos.z += 10.0f * polyNormalZ; this->timer = 0; if (SurfaceType_CanHookshot(&play->colCtx, poly, bgId)) { + DynaPolyActor* dynaPolyActor; + if (bgId != BGCHECK_SCENE) { dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); if (dynaPolyActor != NULL) { @@ -308,6 +313,8 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { if ((player->actor.draw != NULL) && (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT)) { OPEN_DISPS(play->state.gfxCtx, "../z_arms_hook.c", 850); + if (1) {} + if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { Matrix_MultVec3f(&D_80865B70, &this->unk_1E8); Matrix_MultVec3f(&D_80865B88, &hookNewTip); diff --git a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c index 2220e8f546..d754036fb5 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c +++ b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c @@ -90,17 +90,21 @@ static InitChainEntry sInitChain[] = { static Vec3f D_8086E0E0 = { 0.0f, 140.0f, 0.0f }; void BgBdanSwitch_InitDynaPoly(BgBdanSwitch* this, PlayState* play, CollisionHeader* collision, s32 flag) { - s16 pad1; + s32 pad; CollisionHeader* colHeader = NULL; - s16 pad2; DynaPolyActor_Init(&this->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_bdan_switch.c", 325, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgBdanSwitch_InitCollision(BgBdanSwitch* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index f2779f3c61..4187b34023 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -252,7 +252,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, PlayState* play) { } if (givingReward) { - if (!IS_CUTSCENE_LAYER) { + if (!IS_CUTSCENE_LAYER || !OOT_DEBUG) { if (play->sceneId != SCENE_GREAT_FAIRYS_FOUNTAIN_MAGIC) { switch (this->fountainType) { case FAIRY_SPELL_FARORES_WIND: diff --git a/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c b/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c index 95f18f4b7c..7cf14989c1 100644 --- a/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c +++ b/src/overlays/actors/ovl_Bg_Ganon_Otyuka/z_bg_ganon_otyuka.c @@ -97,12 +97,11 @@ void BgGanonOtyuka_Destroy(Actor* thisx, PlayState* play2) { void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, PlayState* play) { Actor* thisx = &this->dyna.actor; Actor* prop; - BgGanonOtyuka* platform; + s16 i; f32 dx; f32 dy; f32 dz; Vec3f center; - s16 i; if (this->isFalling || ((play->actorCtx.unk_02 != 0) && (this->dyna.actor.xyzDistToPlayerSq < SQ(70.0f)))) { PRINTF("OTC O 1\n"); @@ -113,20 +112,19 @@ void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, PlayState* play) { if ((prop == thisx) || (prop->id != ACTOR_BG_GANON_OTYUKA)) { prop = prop->next; continue; - } - - platform = (BgGanonOtyuka*)prop; - - dx = platform->dyna.actor.world.pos.x - this->dyna.actor.world.pos.x + D_80876A68[i].x; - dy = platform->dyna.actor.world.pos.y - this->dyna.actor.world.pos.y; - dz = platform->dyna.actor.world.pos.z - this->dyna.actor.world.pos.z + D_80876A68[i].z; - - if ((fabsf(dx) < 10.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 10.0f)) { - platform->visibleSides |= sSides[i]; - break; } else { - prop = prop->next; + BgGanonOtyuka* platform = (BgGanonOtyuka*)prop; + + dx = platform->dyna.actor.world.pos.x - this->dyna.actor.world.pos.x + D_80876A68[i].x; + dy = platform->dyna.actor.world.pos.y - this->dyna.actor.world.pos.y; + dz = platform->dyna.actor.world.pos.z - this->dyna.actor.world.pos.z + D_80876A68[i].z; + + if ((fabsf(dx) < 10.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 10.0f)) { + platform->visibleSides |= sSides[i]; + break; + } } + prop = prop->next; } } diff --git a/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c b/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c index e7ea4f3655..e717fcc356 100644 --- a/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c +++ b/src/overlays/actors/ovl_Bg_Gnd_Soulmeiro/z_bg_gnd_soulmeiro.c @@ -125,15 +125,18 @@ void func_8087AF38(BgGndSoulmeiro* this, PlayState* play) { } else if ((this->unk_198 % 6) == 0) { s32 i; s16 temp_2 = Rand_ZeroOne() * (10922.0f); // This should be: 0x10000 / 6.0f + s16 temp_1; + f32 temp_3; + f32 temp_4; + f32 distXZ; vecA.y = 0.0f; vecB.y = thisx->world.pos.y; for (i = 0; i < 6; i++) { - s16 temp_1 = Rand_CenteredFloat(0x2800) + temp_2; - f32 temp_3 = Math_SinS(temp_1); - f32 temp_4 = Math_CosS(temp_1); - f32 distXZ; + temp_1 = Rand_CenteredFloat(0x2800) + temp_2; + temp_3 = Math_SinS(temp_1); + temp_4 = Math_CosS(temp_1); vecB.x = thisx->world.pos.x + (120.0f * temp_3); vecB.z = thisx->world.pos.z + (120.0f * temp_4); diff --git a/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c b/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c index 8e129ae40e..ed45e2cfc8 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c +++ b/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c @@ -315,8 +315,6 @@ void BgHakaGate_DrawFlame(BgHakaGate* this, PlayState* play) { if (this->vFlameScale > 0) { OPEN_DISPS(play->state.gfxCtx, "../z_bg_haka_gate.c", 716); - if (1) {} - Gfx_SetupDL_25Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 0x20, 0x40, 1, 0, @@ -327,6 +325,9 @@ void BgHakaGate_DrawFlame(BgHakaGate* this, PlayState* play) { Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y + 15.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_RotateY(BINANG_TO_RAD(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); scale = this->vFlameScale * 0.00001f; + + if (1) {} + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_bg_haka_gate.c", 744), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c index 8caf50d340..b7d3248962 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c +++ b/src/overlays/actors/ovl_Bg_Haka_Megane/z_bg_haka_megane.c @@ -85,14 +85,14 @@ void BgHakaMegane_Destroy(Actor* thisx, PlayState* play) { } void func_8087DB24(BgHakaMegane* this, PlayState* play) { - CollisionHeader* colHeader; - CollisionHeader* collision; - if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { this->dyna.actor.objectSlot = this->requiredObjectSlot; this->dyna.actor.draw = BgHakaMegane_Draw; Actor_SetObjectDependency(play, &this->dyna.actor); if (play->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { + CollisionHeader* colHeader; + CollisionHeader* collision; + this->actionFunc = func_8087DBF0; collision = sCollisionHeaders[this->dyna.actor.params]; if (collision != NULL) { diff --git a/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c b/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c index 4bd23fcaac..19e7e18a74 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c +++ b/src/overlays/actors/ovl_Bg_Haka_Ship/z_bg_haka_ship.c @@ -199,7 +199,11 @@ void BgHakaShip_Draw(Actor* thisx, PlayState* play) { f32 angleTemp; OPEN_DISPS(play->state.gfxCtx, "../z_bg_haka_ship.c", 528); + Gfx_SetupDL_25Opa(play->state.gfxCtx); + + if (1) {} + if (this->dyna.actor.params == 0) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_bg_haka_ship.c", 534), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -220,7 +224,9 @@ void BgHakaShip_Draw(Actor* thisx, PlayState* play) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00E910); } + CLOSE_DISPS(play->state.gfxCtx, "../z_bg_haka_ship.c", 568); + if (this->actionFunc == BgHakaShip_CutsceneStationary || this->actionFunc == BgHakaShip_Move) { s32 pad; Vec3f sp2C; diff --git a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c index 1e205a090f..5c0a4fc067 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c +++ b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c @@ -352,6 +352,7 @@ void func_808806BC(BgHakaTrap* this, PlayState* play) { f32 floorHeight; f32 yIntersect; s32 i; + s32 bgId; this->dyna.actor.velocity.y *= 1.6f; @@ -366,8 +367,6 @@ void func_808806BC(BgHakaTrap* this, PlayState* play) { floorHeight = this->dyna.actor.floorHeight; for (i = 0; i < 3; i++) { - s32 bgId; - yIntersect = BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &vector) - 25.0f; diff --git a/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c b/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c index c868ca72a1..85549a63d7 100644 --- a/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c +++ b/src/overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.c @@ -490,6 +490,8 @@ void BgHeavyBlock_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_bg_heavy_block.c", 904); + if (1) {} + if (BgHeavyBlock_LiftedUp == this->actionFunc) { Matrix_SetTranslateRotateYXZ(player->leftHandPos.x, player->leftHandPos.y, player->leftHandPos.z, &thisx->shape.rot); diff --git a/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c b/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c index e7ec041a3e..536a8abcdd 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Curtain/z_bg_hidan_curtain.c @@ -86,11 +86,12 @@ void BgHidanCurtain_Init(Actor* thisx, PlayState* play) { this->treasureFlag = (thisx->params >> 6) & 0x3F; thisx->params &= 0x3F; - if ((this->actor.params < 0) || (this->actor.params > 0x3F)) { + if (OOT_DEBUG && ((this->actor.params < 0) || (this->actor.params > 0x3F))) { // "Save bit is not set" PRINTF("Warning : object のセーブビットが設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_hidan_curtain.c", 373, this->actor.params); } + Actor_SetScale(&this->actor, hcParams->scale); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); diff --git a/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c b/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c index 441fe805f1..52f904432f 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Firewall/z_bg_hidan_firewall.c @@ -58,8 +58,7 @@ static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; void BgHidanFirewall_Init(Actor* thisx, PlayState* play) { BgHidanFirewall* this = (BgHidanFirewall*)thisx; - this->actor.scale.x = 0.12f; - this->actor.scale.z = 0.12f; + this->actor.scale.x = this->actor.scale.z = 0.12f; this->actor.scale.y = 0.01f; this->unk_150 = 0; diff --git a/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c b/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c index 2a862c4631..a3c81e8292 100644 --- a/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c +++ b/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c @@ -115,17 +115,20 @@ void BgIceShelter_InitColliders(BgIceShelter* this, PlayState* play) { void BgIceShelter_InitDynaPoly(BgIceShelter* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG registration failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_ice_shelter.c", 362, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgIceShelter_RotateY(Vec3f* dest, Vec3f* src, s16 angle) { @@ -144,7 +147,6 @@ static InitChainEntry sInitChain[] = { }; void BgIceShelter_Init(Actor* thisx, PlayState* play) { - static Vec3f kzIceScale = { 0.18f, 0.27f, 0.24f }; BgIceShelter* this = (BgIceShelter*)thisx; s16 type = BGICESHELTER_GET_TYPE(&this->dyna.actor); @@ -158,7 +160,9 @@ void BgIceShelter_Init(Actor* thisx, PlayState* play) { } if (type == RED_ICE_KING_ZORA) { - Math_Vec3f_Copy(&this->dyna.actor.scale, &kzIceScale); + static Vec3f sKingZoraRedIceScale = { 0.18f, 0.27f, 0.24f }; + + Math_Vec3f_Copy(&this->dyna.actor.scale, &sKingZoraRedIceScale); } else { Actor_SetScale(&this->dyna.actor, sRedIceScales[type]); } diff --git a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c index e9632360db..fa7d9a9dc5 100644 --- a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c +++ b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c @@ -69,17 +69,20 @@ static InitChainEntry sInitChain[] = { void BgJya1flift_InitDynapoly(BgJya1flift* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG login failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_1flift.c", 179, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgJya1flift_InitCollision(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c b/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c index 4df5b39ed3..87cb2807dc 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c +++ b/src/overlays/actors/ovl_Bg_Jya_Amishutter/z_bg_jya_amishutter.c @@ -45,15 +45,19 @@ static InitChainEntry sInitChain[] = { void BgJyaAmishutter_InitDynaPoly(BgJyaAmishutter* this, PlayState* play, CollisionHeader* collision, s32 flag) { s32 pad1; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_amishutter.c", 129, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgJyaAmishutter_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c index b03f841e3c..c8dfb31195 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c @@ -63,19 +63,22 @@ static InitChainEntry sInitChain[] = { }; void BgJyaBombiwa_SetupDynaPoly(BgJyaBombiwa* this, PlayState* play, CollisionHeader* collision, s32 flag) { - s16 pad1; + s32 pad1; CollisionHeader* colHeader = NULL; - s16 pad2; DynaPolyActor_Init(&this->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; // "Warning: move BG registration failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_bombiwa.c", 174, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgJyaBombiwa_InitCollider(BgJyaBombiwa* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c index 02b42c4ce8..78f5a1f5e4 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c +++ b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c @@ -118,27 +118,34 @@ void func_808958F0(Vec3f* dest, Vec3f* src, f32 arg2, f32 arg3) { void BgJyaCobra_InitDynapoly(BgJyaCobra* this, PlayState* play, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG Registration Failure" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_cobra.c", 247, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgJyaCobra_SpawnRay(BgJyaCobra* this, PlayState* play) { Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_MIR_RAY, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 57.0f, this->dyna.actor.world.pos.z, 0, 0, 0, 6); + +#if OOT_DEBUG if (this->dyna.actor.child == NULL) { PRINTF(VT_FGCOL(RED)); // "Error : Mir Ray occurrence failure" PRINTF("Error : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_cobra.c", 270); PRINTF(VT_RST); } +#endif } void func_80895A70(BgJyaCobra* this) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c index f8ef9d42de..4a56ed44e8 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c +++ b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c @@ -43,15 +43,19 @@ static InitChainEntry sInitChain[] = { void BgJyaKanaami_InitDynaPoly(BgJyaKanaami* this, PlayState* play, CollisionHeader* collision, s32 flag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_kanaami.c", 145, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgJyaKanaami_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c b/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c index 2a4181eefd..378116f72a 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c +++ b/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c @@ -62,15 +62,19 @@ static InitChainEntry sInitChain[] = { void BgJyaZurerukabe_InitDynaPoly(BgJyaZurerukabe* this, PlayState* play, CollisionHeader* collision, s32 flag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_zurerukabe.c", 194, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void func_8089B4C8(BgJyaZurerukabe* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c index 18e1eaaafd..9cb6034bc2 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c +++ b/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c @@ -53,17 +53,20 @@ void BgMoriBigst_SetupAction(BgMoriBigst* this, BgMoriBigstActionFunc actionFunc void BgMoriBigst_InitDynapoly(BgMoriBigst* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG login failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_bigst.c", 190, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgMoriBigst_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c index e4be790154..a31345545c 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hashigo/z_bg_mori_hashigo.c @@ -78,19 +78,21 @@ static InitChainEntry sInitChainLadder[] = { void BgMoriHashigo_InitDynapoly(BgMoriHashigo* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; - CollisionHeader* colHeader; - s32 pad2; + CollisionHeader* colHeader = NULL; - colHeader = NULL; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG login failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashigo.c", 164, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgMoriHashigo_InitCollider(BgMoriHashigo* this, PlayState* play) { @@ -260,9 +262,9 @@ void BgMoriHashigo_LadderFall(BgMoriHashigo* this, PlayState* play) { } void BgMoriHashigo_SetupLadderRest(BgMoriHashigo* this) { - this->actionFunc = NULL; this->dyna.actor.gravity = 0.0f; this->dyna.actor.velocity.y = 0.0f; + this->actionFunc = NULL; this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } diff --git a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c index e4b2a1217f..5f5af22350 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hashira4/z_bg_mori_hashira4.c @@ -50,19 +50,21 @@ void BgMoriHashira4_SetupAction(BgMoriHashira4* this, BgMoriHashira4ActionFunc a void BgMoriHashira4_InitDynaPoly(BgMoriHashira4* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; - CollisionHeader* colHeader; - s32 pad2; + CollisionHeader* colHeader = NULL; - colHeader = NULL; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG login failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_hashira4.c", 155, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgMoriHashira4_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c index f5ced0b3f6..3ad8321f17 100644 --- a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c +++ b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c @@ -41,16 +41,20 @@ void BgSpot08Iceblock_SetupAction(BgSpot08Iceblock* this, BgSpot08IceblockAction void BgSpot08Iceblock_InitDynaPoly(BgSpot08Iceblock* this, PlayState* play, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning: move BG registration failed" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 0xD9, this->dyna.actor.id, this->dyna.actor.params); } +#endif } // Sets params to 0x10 (medium, nonrotating) if not in the cases listed. diff --git a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c index e261a35239..2a62445f48 100644 --- a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c +++ b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c @@ -46,15 +46,19 @@ static InitChainEntry sInitChain[] = { void BgSpot12Gate_InitDynaPoly(BgSpot12Gate* this, PlayState* play, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_gate.c", 145, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgSpot12Gate_Init(Actor* thisx, PlayState* play) { @@ -105,17 +109,19 @@ void func_808B317C(BgSpot12Gate* this) { void func_808B318C(BgSpot12Gate* this, PlayState* play) { s32 pad; - s32 quakeIndex; Math_StepToF(&this->dyna.actor.velocity.y, 1.6f, 0.03f); if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y)) { func_808B3274(this); - quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quakeIndex, -0x3CB0); - Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); - Quake_SetDuration(quakeIndex, 12); + { + s32 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, -0x3CB0); + Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); + Quake_SetDuration(quakeIndex, 12); + } Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); } else { diff --git a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c index 9700367f4b..360464957c 100644 --- a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c +++ b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c @@ -43,15 +43,19 @@ static InitChainEntry sInitChain[] = { void func_808B3420(BgSpot12Saku* this, PlayState* play, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_saku.c", 140, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgSpot12Saku_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c index a2ce895d76..5a8560df82 100644 --- a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c +++ b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c @@ -58,17 +58,19 @@ static Vec3f sBoxGroundCheckPoints[] = { void func_808B3960(BgSpot15Rrbox* this, PlayState* play, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; - u32 pad2; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 171, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void BgSpot15Rrbox_RotatePoint(Vec3f* outPos, Vec3f* pos, f32 arg2, f32 arg3) { @@ -224,11 +226,9 @@ s32 func_808B4010(BgSpot15Rrbox* this, PlayState* play) { } void func_808B4084(BgSpot15Rrbox* this, PlayState* play) { - this->actionFunc = func_808B40AC; this->dyna.actor.gravity = 0.0f; - this->dyna.actor.velocity.x = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.velocity.z = 0.0f; + this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; + this->actionFunc = func_808B40AC; } void func_808B40AC(BgSpot15Rrbox* this, PlayState* play) { @@ -301,9 +301,7 @@ void func_808B4194(BgSpot15Rrbox* this, PlayState* play) { } void func_808B4380(BgSpot15Rrbox* this, PlayState* play) { - this->dyna.actor.velocity.x = 0.0f; - this->dyna.actor.velocity.y = 0.0f; - this->dyna.actor.velocity.z = 0.0f; + this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; this->dyna.actor.gravity = -1.0f; this->dyna.actor.floorHeight = BgSpot15Rrbox_GetFloorHeight(this, play); this->actionFunc = func_808B43D0; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 69351a718e..ba2521531d 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -135,19 +135,20 @@ void ObjBean_InitCollider(Actor* thisx, PlayState* play) { void ObjBean_InitDynaPoly(ObjBean* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; - CollisionHeader* colHeader; - s32 pad2; - - colHeader = NULL; + CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_bean.c", 374, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void ObjBean_FindFloor(ObjBean* this, PlayState* play) { @@ -240,14 +241,8 @@ void ObjBean_FollowPath(ObjBean* this, PlayState* play) { Path* path; Vec3f acell; Vec3f pathPointsFloat; - f32 speed; - Vec3s* nextPathPoint; - Vec3s* currentPoint; - Vec3s* sp4C; - Vec3f sp40; - Vec3f sp34; - f32 sp30; f32 mag; + Vec3s* nextPathPoint; Math_StepToF(&this->dyna.actor.speed, sBeanSpeeds[this->unk_1F6].velocity, sBeanSpeeds[this->unk_1F6].accel); path = &play->pathList[(this->dyna.actor.params >> 8) & 0x1F]; @@ -257,8 +252,13 @@ void ObjBean_FollowPath(ObjBean* this, PlayState* play) { Math_Vec3f_Diff(&pathPointsFloat, &this->pathPoints, &acell); mag = Math3D_Vec3fMagnitude(&acell); - speed = CLAMP_MIN(this->dyna.actor.speed, 0.5f); - if (speed > mag) { + if (CLAMP_MIN(this->dyna.actor.speed, 0.5f) > mag) { + Vec3s* currentPoint; + Vec3s* sp4C; + Vec3f sp40; + Vec3f sp34; + f32 sp30; + currentPoint = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->currentPointIndex]; Math_Vec3f_Copy(&this->pathPoints, &pathPointsFloat); diff --git a/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c b/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c index fa22cfaab4..0cd7062bdf 100644 --- a/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c +++ b/src/overlays/actors/ovl_Obj_Elevator/z_obj_elevator.c @@ -46,16 +46,19 @@ void ObjElevator_SetupAction(ObjElevator* this, ObjElevatorActionFunc actionFunc void func_80B92B08(ObjElevator* this, PlayState* play, CollisionHeader* collision, s32 flag) { s16 pad1; CollisionHeader* colHeader = NULL; - s16 pad2; - Actor* thisx = &this->dyna.actor; DynaPolyActor_Init(&this->dyna, flag); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { - PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_elevator.c", 136, thisx->id, - thisx->params); + s32 pad2; + + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_elevator.c", 136, + this->dyna.actor.id, this->dyna.actor.params); } +#endif } void ObjElevator_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c index f399f017ef..602502f9bb 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -55,15 +55,19 @@ void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc) { void func_80B93B68(ObjHsblock* this, PlayState* play, CollisionHeader* collision, s32 moveFlags) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2[2]; DynaPolyActor_Init(&this->dyna, moveFlags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_hsblock.c", 163, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void func_80B93BF0(ObjHsblock* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index 63f6635a30..52859a628c 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -64,16 +64,19 @@ void ObjLift_SetupAction(ObjLift* this, ObjLiftActionFunc actionFunc) { void ObjLift_InitDynaPoly(ObjLift* this, PlayState* play, CollisionHeader* collision, s32 flags) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_lift.c", 188, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void ObjLift_SpawnFragments(ObjLift* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index b8b6fbcf2f..6243acb0bd 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -87,17 +87,20 @@ static Vec2f sFaceDirection[] = { void ObjOshihiki_InitDynapoly(ObjOshihiki* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG registration failure" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_oshihiki.c", 280, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void ObjOshihiki_RotateXZ(Vec3f* out, Vec3f* in, f32 sn, f32 cs) { @@ -242,14 +245,13 @@ void ObjOshihiki_SetTexture(ObjOshihiki* this, PlayState* play) { } } -void ObjOshihiki_SetColor(ObjOshihiki* this, PlayState* play) { - Color_RGB8* src; +void ObjOshihiki_SetColor(ObjOshihiki* this, PlayState* play2) { + PlayState* play = play2; + s16 paramsColorIdx = (this->dyna.actor.params >> 6) & 3; Color_RGB8* color = &this->color; - s16 paramsColorIdx; + Color_RGB8* src; s32 i; - paramsColorIdx = (this->dyna.actor.params >> 6) & 3; - for (i = 0; i < ARRAY_COUNT(sSceneIds); i++) { if (sSceneIds[i] == play->sceneId) { break; @@ -315,14 +317,12 @@ void ObjOshihiki_Destroy(Actor* thisx, PlayState* play) { } void ObjOshihiki_SetFloors(ObjOshihiki* this, PlayState* play) { + s32 pad; + Vec3f colCheckPoint; + Vec3f colCheckOffset; s32 i; for (i = 0; i < 5; i++) { - Vec3f colCheckPoint; - Vec3f colCheckOffset; - CollisionPoly** floorPoly; - s32* floorBgId; - colCheckOffset.x = sColCheckPoints[i].x * (this->dyna.actor.scale.x * 10.0f); colCheckOffset.y = sColCheckPoints[i].y * (this->dyna.actor.scale.y * 10.0f); colCheckOffset.z = sColCheckPoints[i].z * (this->dyna.actor.scale.z * 10.0f); @@ -331,10 +331,8 @@ void ObjOshihiki_SetFloors(ObjOshihiki* this, PlayState* play) { colCheckPoint.y += this->dyna.actor.prevPos.y; colCheckPoint.z += this->dyna.actor.world.pos.z; - floorPoly = &this->floorPolys[i]; - floorBgId = &this->floorBgIds[i]; - this->floorHeights[i] = - BgCheck_EntityRaycastDown6(&play->colCtx, floorPoly, floorBgId, &this->dyna.actor, &colCheckPoint, 0.0f); + this->floorHeights[i] = BgCheck_EntityRaycastDown6(&play->colCtx, &this->floorPolys[i], &this->floorBgIds[i], + &this->dyna.actor, &colCheckPoint, 0.0f); } } @@ -445,9 +443,9 @@ s32 ObjOshihiki_MoveWithBlockUnder(ObjOshihiki* this, PlayState* play) { void ObjOshihiki_SetupOnScene(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_SETUP_ON_SCENE; - this->actionFunc = ObjOshihiki_OnScene; this->dyna.actor.gravity = 0.0f; this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; + this->actionFunc = ObjOshihiki_OnScene; } void ObjOshihiki_OnScene(ObjOshihiki* this, PlayState* play) { @@ -472,9 +470,9 @@ void ObjOshihiki_OnScene(ObjOshihiki* this, PlayState* play) { void ObjOshihiki_SetupOnActor(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_SETUP_ON_ACTOR; - this->actionFunc = ObjOshihiki_OnActor; this->dyna.actor.velocity.x = this->dyna.actor.velocity.y = this->dyna.actor.velocity.z = 0.0f; this->dyna.actor.gravity = -1.0f; + this->actionFunc = ObjOshihiki_OnActor; } void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { @@ -649,6 +647,7 @@ void ObjOshihiki_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_obj_oshihiki.c", 1308), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +#if OOT_DEBUG switch (play->sceneId) { case SCENE_DEKU_TREE: case SCENE_DODONGOS_CAVERN: @@ -664,6 +663,9 @@ void ObjOshihiki_Draw(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, mREG(13), mREG(14), mREG(15), 255); break; } +#else + gDPSetEnvColor(POLY_OPA_DISP++, this->color.r, this->color.g, this->color.b, 255); +#endif gSPDisplayList(POLY_OPA_DISP++, gPushBlockDL); CLOSE_DISPS(play->state.gfxCtx, "../z_obj_oshihiki.c", 1334); diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 089c781641..2d513f5c70 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -192,17 +192,20 @@ void ObjSwitch_RotateY(Vec3f* dest, Vec3f* src, s16 rotY) { void ObjSwitch_InitDynaPoly(ObjSwitch* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { s32 pad; CollisionHeader* colHeader = NULL; - s32 pad2; DynaPolyActor_Init(&this->dyna, moveFlag); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); +#if OOT_DEBUG if (this->dyna.bgId == BG_ACTOR_MAX) { + s32 pad2; + // "Warning : move BG registration failure" PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_obj_switch.c", 531, this->dyna.actor.id, this->dyna.actor.params); } +#endif } void ObjSwitch_InitJntSphCollider(ObjSwitch* this, PlayState* play, ColliderJntSphInit* colliderJntSphInit) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index d6a6677f0f..4cf51dacda 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -179,7 +179,6 @@ void func_80846978(PlayState* play, Player* this); void func_808469BC(PlayState* play, Player* this); void func_80846A68(PlayState* play, Player* this); void Player_UpdateCommon(Player* this, PlayState* play, Input* input); -s32 func_8084FCAC(Player* this, PlayState* play); void func_8084FF7C(Player* this); void Player_UpdateBunnyEars(Player* this); void func_80851008(PlayState* play, Player* this, void* anim); @@ -493,7 +492,7 @@ static PlayerAgeProperties sAgeProperties[] = { }, }; -static u32 D_808535D0 = false; +static u32 sNoclipEnabled = false; static f32 sControlStickMagnitude = 0.0f; static s16 sControlStickAngle = 0; static s16 D_808535DC = 0; @@ -1605,7 +1604,6 @@ static LinkAnimationHeader* D_808543D4[] = { &gPlayerAnim_link_hook_wait, }; -// return type can't be void due to regalloc in func_8084FCAC BAD_RETURN(s32) Player_ZeroSpeedXZ(Player* this) { this->actor.speed = 0.0f; this->speedXZ = 0.0f; @@ -5224,16 +5222,16 @@ void func_8083A5C4(PlayState* play, Player* this, CollisionPoly* arg2, f32 arg3, } s32 func_8083A6AC(Player* this, PlayState* play) { - CollisionPoly* sp84; - s32 sp80; - Vec3f sp74; - Vec3f sp68; - f32 temp1; - //! @bug `floorPitch` and `floorPitchAlt` are cleared to 0 before this function is called, because the player //! left the ground. The angles will always be zero and therefore will always pass these checks. //! The intention seems to be to prevent ledge hanging or vine grabbing when walking off of a steep enough slope. if ((this->actor.yDistToWater < -80.0f) && (ABS(this->floorPitch) < 0xAAA) && (ABS(this->floorPitchAlt) < 0xAAA)) { + CollisionPoly* sp84; + s32 sp80; + Vec3f sp74; + Vec3f sp68; + f32 temp1; + sp74.x = this->actor.prevPos.x - this->actor.world.pos.x; sp74.z = this->actor.prevPos.z - this->actor.world.pos.z; @@ -7847,7 +7845,6 @@ void Player_Action_808414F8(Player* this, PlayState* play) { f32 speedTarget; s16 yawTarget; s32 sp2C; - s16 sp2A; func_80841138(this, play); @@ -7871,7 +7868,7 @@ void Player_Action_808414F8(Player* this, PlayState* play) { } } } else { - sp2A = yawTarget - this->yaw; + s16 sp2A = yawTarget - this->yaw; Math_AsymStepToF(&this->speedXZ, speedTarget * 1.5f, 1.5f, 2.0f); Math_ScaledStepToS(&this->yaw, yawTarget, sp2A * 0.1f); @@ -8483,15 +8480,6 @@ s32 func_80842DF4(PlayState* play, Player* this) { } void Player_Action_80843188(Player* this, PlayState* play) { - f32 sp54; - f32 sp50; - s16 sp4E; - s16 sp4C; - s16 sp4A; - s16 sp48; - s16 sp46; - f32 sp40; - if (LinkAnimation_Update(play, &this->skelAnime)) { if (!Player_IsChildWithHylianShield(this)) { Player_AnimPlayLoop(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense_wait, this->modelAnimType)); @@ -8509,6 +8497,15 @@ void Player_Action_80843188(Player* this, PlayState* play) { func_8083721C(this); if (this->av2.actionVar2 != 0) { + f32 sp54; + f32 sp50; + s16 sp4E; + s16 sp4C; + s16 sp4A; + s16 sp48; + s16 sp46; + f32 sp40; + sp54 = sControlInput->rel.stick_y * 100; sp50 = sControlInput->rel.stick_x * -120; sp4E = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); @@ -11301,58 +11298,74 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Collider_ResetQuadAT(play, &this->shieldQuad.base); } -static Vec3f D_80854838 = { 0.0f, 0.0f, -30.0f }; +#if OOT_DEBUG +s32 Player_UpdateNoclip(Player* this, PlayState* play); +#endif void Player_Update(Actor* thisx, PlayState* play) { - static Vec3f sDogSpawnPos; Player* this = (Player*)thisx; s32 dogParams; s32 pad; - Input sp44; - Actor* dog; + Input input; - if (func_8084FCAC(this, play)) { - if (gSaveContext.dogParams < 0) { - if (Object_GetSlot(&play->objectCtx, OBJECT_DOG) < 0) { - gSaveContext.dogParams = 0; - } else { - gSaveContext.dogParams &= 0x7FFF; - Player_GetRelativePosition(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos); - dogParams = gSaveContext.dogParams; +#if OOT_DEBUG + if (!Player_UpdateNoclip(this, play)) { + goto skip_update; + } +#endif - dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, - 0, this->actor.shape.rot.y, 0, dogParams | 0x8000); - if (dog != NULL) { - dog->room = 0; - } - } - } + if (gSaveContext.dogParams < 0) { + static Vec3f sDogSpawnOffset = { 0.0f, 0.0f, -30.0f }; + static Vec3f sDogSpawnPos; - if ((this->interactRangeActor != NULL) && (this->interactRangeActor->update == NULL)) { - this->interactRangeActor = NULL; - } - - if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) { - Player_DetachHeldActor(play, this); - } - - if (this->stateFlags1 & (PLAYER_STATE1_5 | PLAYER_STATE1_29)) { - bzero(&sp44, sizeof(sp44)); + if (Object_GetSlot(&play->objectCtx, OBJECT_DOG) < 0) { + gSaveContext.dogParams = 0; } else { - sp44 = play->state.input[0]; - if (this->unk_88E != 0) { - sp44.cur.button &= ~(BTN_A | BTN_B | BTN_CUP); - sp44.press.button &= ~(BTN_A | BTN_B | BTN_CUP); + Actor* dog; + + gSaveContext.dogParams &= 0x7FFF; + Player_GetRelativePosition(this, &this->actor.world.pos, &sDogSpawnOffset, &sDogSpawnPos); + dogParams = gSaveContext.dogParams; + + dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, 0, + this->actor.shape.rot.y, 0, dogParams | 0x8000); + if (dog != NULL) { + dog->room = 0; } } - - Player_UpdateCommon(this, play, &sp44); } - MREG(52) = this->actor.world.pos.x; - MREG(53) = this->actor.world.pos.y; - MREG(54) = this->actor.world.pos.z; - MREG(55) = this->actor.world.rot.y; + if ((this->interactRangeActor != NULL) && (this->interactRangeActor->update == NULL)) { + this->interactRangeActor = NULL; + } + + if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) { + Player_DetachHeldActor(play, this); + } + + if (this->stateFlags1 & (PLAYER_STATE1_5 | PLAYER_STATE1_29)) { + bzero(&input, sizeof(input)); + } else { + input = play->state.input[0]; + + if (this->unk_88E != 0) { + input.cur.button &= ~(BTN_A | BTN_B | BTN_CUP); + input.press.button &= ~(BTN_A | BTN_B | BTN_CUP); + } + } + + Player_UpdateCommon(this, play, &input); + +skip_update:; + { + s32 pad; + + MREG(52) = this->actor.world.pos.x; + MREG(53) = this->actor.world.pos.y; + MREG(54) = this->actor.world.pos.z; + + MREG(55) = this->actor.world.rot.y; + } } typedef struct { @@ -13618,21 +13631,42 @@ void Player_Action_8084FBF4(Player* this, PlayState* play) { func_8002F8F0(&this->actor, NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG + this->ageProperties->unk_92); } -s32 func_8084FCAC(Player* this, PlayState* play) { +#if OOT_DEBUG +/** + * Updates the "Noclip" debug feature, which allows the player to fly around anywhere + * in the world and clip through any collision. + * + * Noclip can be toggled on and off with two different button combos: + * Hold L + R + A and press B + * or + * Hold L and press D-pad right + * + * To control Noclip mode: + * - Move horizontally with the 4 D-pad directions + * - Move up with B + * - Move down with A + * - Hold R to move faster + * + * With Noclip enabled, another button combination can be pressed to set all "temp clear" flags + * in the current room. To do so hold L and press D-pad left. + * + * @return true if Noclip is disabled, false if enabled + */ +s32 Player_UpdateNoclip(Player* this, PlayState* play) { sControlInput = &play->state.input[0]; - if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_A | BTN_L | BTN_R) && + if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_L | BTN_R | BTN_A) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B)) || (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) { - D_808535D0 ^= 1; + sNoclipEnabled ^= 1; - if (D_808535D0) { + if (sNoclipEnabled) { Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_AIM); } } - if (D_808535D0) { + if (sNoclipEnabled) { f32 speed; if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { @@ -13672,9 +13706,7 @@ s32 func_8084FCAC(Player* this, PlayState* play) { Player_ZeroSpeedXZ(this); this->actor.gravity = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.x = 0.0f; + this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) { Flags_SetTempClear(play, play->roomCtx.curRoom.num); @@ -13682,11 +13714,12 @@ s32 func_8084FCAC(Player* this, PlayState* play) { Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - return 0; + return false; } - return 1; + return true; } +#endif void func_8084FF7C(Player* this) { this->unk_858 += this->unk_85C; diff --git a/tools/msgdis.py b/tools/msgdis.py old mode 100644 new mode 100755 index a946779fac..1da85713ec --- a/tools/msgdis.py +++ b/tools/msgdis.py @@ -5,6 +5,7 @@ import re, struct from os import path +import argparse # =================================================== # Util @@ -404,3 +405,23 @@ def extract_all_text(text_out, staff_text_out): with open(staff_text_out, "w", encoding="utf8") as outfile: outfile.write(out.strip() + "\n") + + +def main(): + parser = argparse.ArgumentParser( + description="Extract text from the baserom into .h files" + ) + parser.add_argument("--text-out", help="Path to output .h file for text") + parser.add_argument( + "--staff-text-out", help="Path to output .h file for staff text" + ) + + args = parser.parse_args() + if not (args.text_out or args.staff_text_out): + parser.error("No output file requested") + + extract_all_text(args.text_out, args.staff_text_out) + + +if __name__ == "__main__": + main()