From 0832b5af6820c231c411cf7029db234e85ff857b Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Mon, 13 Jun 2022 08:38:20 -0700 Subject: [PATCH] Fix misc 14 (#1279) * Remove fake temp in `BossDodongo_DrawEffects` * `OS_WRITE` for `__osSpRawStartDma` `direction` * remove outdated comment * fixup osRecvMesg * make sShopkeeperStores static * `PHYSICAL_TO_VIRTUAL(gSegments[0])` -> `SEGMENTED_TO_VIRTUAL(NULL)` (mimics `CollisionHeader_SegmentedToVirtual`) * Run formatter * Remove assets from include path in suggested vscode properties * Fix `osCreateMesgQueue` getting `OS_MESG_BLOCK` as `count` instead of `1` --- docs/vscode.md | 1 - src/code/audio_heap.c | 7 +++-- src/code/sleep.c | 2 +- src/code/z_bgcheck.c | 26 +++++++++---------- src/code/z_en_item00.c | 3 ++- src/code/z_parameter.c | 8 +++--- src/code/z_sram.c | 1 - src/libultra/io/sptask.c | 4 +-- src/libultra/os/recvmesg.c | 2 +- .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 5 ++-- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 2 +- 11 files changed, 29 insertions(+), 32 deletions(-) diff --git a/docs/vscode.md b/docs/vscode.md index dcdaa9ac0d..45ad9097d0 100644 --- a/docs/vscode.md +++ b/docs/vscode.md @@ -50,7 +50,6 @@ You can create a `.vscode/c_cpp_properties.json` file with `C/C++: Edit Configur "includePath": [ // Matches makefile's includes "${workspaceFolder}/**", "src", - "assets", "build", "include" ], diff --git a/src/code/audio_heap.c b/src/code/audio_heap.c index 905e69649c..892ec37555 100644 --- a/src/code/audio_heap.c +++ b/src/code/audio_heap.c @@ -283,10 +283,9 @@ void AudioHeap_InitMainPools(s32 initPoolSize) { void AudioHeap_SessionPoolsInit(AudioSessionPoolSplit* split) { gAudioContext.sessionPool.curRamAddr = gAudioContext.sessionPool.startRamAddr; - AudioHeap_AllocPoolInit(&gAudioContext.miscPool, - AudioHeap_Alloc(&gAudioContext.sessionPool, split->miscPoolSize), split->miscPoolSize); - AudioHeap_AllocPoolInit(&gAudioContext.cachePool, - AudioHeap_Alloc(&gAudioContext.sessionPool, split->cachePoolSize), + AudioHeap_AllocPoolInit(&gAudioContext.miscPool, AudioHeap_Alloc(&gAudioContext.sessionPool, split->miscPoolSize), + split->miscPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.cachePool, AudioHeap_Alloc(&gAudioContext.sessionPool, split->cachePoolSize), split->cachePoolSize); } diff --git a/src/code/sleep.c b/src/code/sleep.c index f08129701e..2b67088a1b 100644 --- a/src/code/sleep.c +++ b/src/code/sleep.c @@ -5,7 +5,7 @@ void Sleep_Cycles(OSTime cycles) { OSMesg msg; OSTimer timer; - osCreateMesgQueue(&mq, &msg, OS_MESG_BLOCK); + osCreateMesgQueue(&mq, &msg, 1); osSetTimer(&timer, cycles, 0, &mq, NULL); osRecvMesg(&mq, NULL, OS_MESG_BLOCK); } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 4d871982f0..c2d73cb479 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -3822,7 +3822,7 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, return 0; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } return surfaceTypes[poly->type].data[dataIdx]; @@ -3865,11 +3865,11 @@ u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s3 return 0; } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } return func_80041A4C(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); @@ -3887,7 +3887,7 @@ u16 func_80041B24(CollisionContext* colCtx, u32 camId, s32 bgId) { } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } return camData[camId].numCameras; @@ -3905,11 +3905,11 @@ u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 return 0; } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } return func_80041B24(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); @@ -3926,7 +3926,7 @@ Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId) { return NULL; } cameraDataList = colHeader->cameraDataList; - if (cameraDataList == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (cameraDataList == SEGMENTED_TO_VIRTUAL(NULL)) { return NULL; } return (Vec3s*)SEGMENTED_TO_VIRTUAL(cameraDataList[camId].camPosData); @@ -3944,11 +3944,11 @@ Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, return NULL; } camData = colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == SEGMENTED_TO_VIRTUAL(NULL)) { return NULL; } surfaceTypes = colHeader->surfaceTypeList; - if (surfaceTypes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (surfaceTypes == SEGMENTED_TO_VIRTUAL(NULL)) { return NULL; } return func_80041C10(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); @@ -4195,7 +4195,7 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 u32 room; WaterBox* curWaterBox; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == SEGMENTED_TO_VIRTUAL(NULL)) { return false; } @@ -4231,7 +4231,7 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, WaterBox* waterBox; WaterBox* waterBoxList = colHeader->waterBoxes; // unused, needed for matching - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == SEGMENTED_TO_VIRTUAL(NULL)) { *outWaterBox = NULL; return -1; } @@ -4278,7 +4278,7 @@ u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox) { s32 camId = WaterBox_GetCamDataIndex(colCtx, waterBox); CamData* camData = colCtx->colHeader->cameraDataList; - if (camData == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (camData == SEGMENTED_TO_VIRTUAL(NULL)) { return 0; } @@ -4305,7 +4305,7 @@ s32 func_800425B0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* u32 room; WaterBox* curWaterBox; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == PHYSICAL_TO_VIRTUAL(gSegments[0])) { + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == SEGMENTED_TO_VIRTUAL(NULL)) { return false; } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index c481c12f7f..b5ef85d817 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -365,7 +365,8 @@ void EnItem00_Destroy(Actor* thisx, PlayState* play) { } void func_8001DFC8(EnItem00* this, PlayState* play) { - if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->despawnTimer < 0)) || + if ((this->actor.params <= ITEM00_RUPEE_RED) || + ((this->actor.params == ITEM00_HEART) && (this->despawnTimer < 0)) || (this->actor.params == ITEM00_HEART_PIECE)) { this->actor.shape.rot.y += 960; } else { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 4ec18010da..995500e548 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1275,7 +1275,7 @@ void func_800849EC(PlayState* play) { void Interface_LoadItemIcon1(PlayState* play, u16 button) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); + osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * 0x1000, (u32)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000), 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1171); @@ -1285,7 +1285,7 @@ void Interface_LoadItemIcon1(PlayState* play, u16 button) { void Interface_LoadItemIcon2(PlayState* play, u16 button) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); + osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * 0x1000, (u32)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000), 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1193); @@ -2082,7 +2082,7 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 l if ((action != DO_ACTION_NONE) && (action != DO_ACTION_MAX + DO_ACTION_NONE) && (action != 2 * DO_ACTION_MAX + DO_ACTION_NONE)) { - osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); + osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + (loadOffset * DO_ACTION_TEX_SIZE), (u32)_do_action_staticSegmentRomStart + (action * DO_ACTION_TEX_SIZE), DO_ACTION_TEX_SIZE, @@ -2146,7 +2146,7 @@ void Interface_LoadActionLabelB(PlayState* play, u16 action) { interfaceCtx->unk_1FC = action; - osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); + osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE, (u32)_do_action_staticSegmentRomStart + (action * DO_ACTION_TEX_SIZE), DO_ACTION_TEX_SIZE, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2228); diff --git a/src/code/z_sram.c b/src/code/z_sram.c index a0d58fbff5..6041503d67 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -448,7 +448,6 @@ void Sram_OpenSave(SramContext* sramCtx) { } } - // check for owning master sword.. to restore master sword? bug or debug feature? if (LINK_AGE_IN_YEARS == YEARS_ADULT && !CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER); gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; diff --git a/src/libultra/io/sptask.c b/src/libultra/io/sptask.c index 84a9624fbd..3c923c13b6 100644 --- a/src/libultra/io/sptask.c +++ b/src/libultra/io/sptask.c @@ -41,13 +41,13 @@ void osSpTaskLoad(OSTask* intp) { while (__osSpSetPc((void*)SP_IMEM_START) == -1) { ; } - while (__osSpRawStartDma(1, (void*)(SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) { + while (__osSpRawStartDma(OS_WRITE, (void*)(SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) { ; } while (__osSpDeviceBusy()) { ; } - while (__osSpRawStartDma(1, (void*)SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) { + while (__osSpRawStartDma(OS_WRITE, (void*)SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) { ; } } diff --git a/src/libultra/os/recvmesg.c b/src/libultra/os/recvmesg.c index 48737c1c65..f065188cd0 100644 --- a/src/libultra/os/recvmesg.c +++ b/src/libultra/os/recvmesg.c @@ -9,7 +9,7 @@ s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) { return -1; } __osRunningThread->state = OS_STATE_WAITING; - __osEnqueueAndYield((OSThread**)mq); + __osEnqueueAndYield(&mq->mtqueue); } if (msg != NULL) { diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index bbab97ad5c..8c737b1c04 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -1667,7 +1667,7 @@ void BossDodongo_UpdateEffects(PlayState* play) { } void BossDodongo_DrawEffects(PlayState* play) { - MtxF* unkMtx; + s32 pad; s16 i; u8 materialFlag = 0; BossDodongoEffect* eff; @@ -1678,7 +1678,6 @@ void BossDodongo_DrawEffects(PlayState* play) { OPEN_DISPS(gfxCtx, "../z_boss_dodongo.c", 5228); Gfx_SetupDL_25Xlu(play->state.gfxCtx); - unkMtx = &play->billboardMtxF; for (i = 0; i < BOSS_DODONGO_EFFECT_COUNT; i++, eff++) { if (eff->unk_24 == 1) { @@ -1691,7 +1690,7 @@ void BossDodongo_DrawEffects(PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, eff->color.r, eff->color.g, eff->color.b, eff->alpha); Matrix_Translate(eff->unk_00.x, eff->unk_00.y, eff->unk_00.z, MTXMODE_NEW); - Matrix_ReplaceRotation(unkMtx); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(eff->unk_2C, eff->unk_2C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_boss_dodongo.c", 5253), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 3448f85daa..a1f2ef3cd4 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -193,7 +193,7 @@ typedef struct { /* 0x06 */ s16 zOffset; } ShopItem; // size 0x08 -ShopItem sShopkeeperStores[][8] = { +static ShopItem sShopkeeperStores[][8] = { { { SI_DEKU_SHIELD, 50, 52, -20 }, { SI_DEKU_NUTS_5, 50, 76, -20 }, { SI_DEKU_NUTS_10, 80, 52, -3 },