diff --git a/include/macros.h b/include/macros.h index c5264ba6a5..343484028d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -105,12 +105,12 @@ #define LOG_FLOAT(exp, value, file, line) LOG(exp, value, "%f", file, line) #define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ - do { \ + if (1) { \ GameState* state = curState; \ \ (state)->init = newInit; \ (state)->size = sizeof(newStruct); \ - } while (0) + } (void)0 #if DEBUG_FEATURES diff --git a/include/z64view.h b/include/z64view.h index 3eb3755a2c..5661a26402 100644 --- a/include/z64view.h +++ b/include/z64view.h @@ -15,10 +15,10 @@ typedef struct Viewport { #define SET_FULLSCREEN_VIEWPORT(view) \ { \ Viewport viewport; \ - viewport.bottomY = SCREEN_HEIGHT; \ - viewport.rightX = SCREEN_WIDTH; \ viewport.topY = 0; \ + viewport.bottomY = SCREEN_HEIGHT; \ viewport.leftX = 0; \ + viewport.rightX = SCREEN_WIDTH; \ View_SetViewport(view, &viewport); \ } \ (void)0 diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index e8c0a58a6e..f571cb1a66 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -24,7 +24,7 @@ void SaveContext_Init(void) { gSaveContext.dogIsLost = true; gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL; -#if OOT_NTSC && OOT_VERSION < GC_US +#if OOT_NTSC && OOT_VERSION < GC_US || PLATFORM_IQUE if (gCurrentRegion == REGION_JP) { gSaveContext.language = LANGUAGE_JPN; } diff --git a/src/code/z_construct.c b/src/code/z_construct.c index 374665d385..fa0f4a38d2 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -19,17 +19,17 @@ void Interface_Init(PlayState* play) { View_Init(&interfaceCtx->view, play->state.gfxCtx); interfaceCtx->unk_1EC = interfaceCtx->unk_1EE = interfaceCtx->unk_1F0 = 0; + interfaceCtx->unk_1F4 = 0.0f; interfaceCtx->unk_1FA = interfaceCtx->unk_261 = interfaceCtx->unk_1FC = 0; interfaceCtx->unk_22E = 0; interfaceCtx->lensMagicConsumptionTimer = 16; - interfaceCtx->unk_1F4 = 0.0f; interfaceCtx->unk_228 = XREG(95); - interfaceCtx->minimapAlpha = 0; - interfaceCtx->unk_260 = 0; interfaceCtx->unk_244 = interfaceCtx->aAlpha = interfaceCtx->bAlpha = interfaceCtx->cLeftAlpha = interfaceCtx->cDownAlpha = interfaceCtx->cRightAlpha = interfaceCtx->healthAlpha = interfaceCtx->startAlpha = interfaceCtx->magicAlpha = 0; + interfaceCtx->minimapAlpha = 0; + interfaceCtx->unk_260 = 0; parameterSize = (uintptr_t)_parameter_staticSegmentRomEnd - (uintptr_t)_parameter_staticSegmentRomStart; @@ -204,7 +204,7 @@ void Interface_Init(PlayState* play) { void Message_Init(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - s32 pad; + Font* font = &msgCtx->font; Message_SetTables(); @@ -224,7 +224,7 @@ void Message_Init(PlayState* play) { PRINTF(T("吹き出しgame_alloc=%x\n", "Textbox game_alloc=%x\n"), TEXTBOX_SEGMENT_SIZE); ASSERT(msgCtx->textboxSegment != NULL, "message->fukidashiSegment != NULL", "../z_construct.c", 352); - Font_LoadOrderedFont(&play->msgCtx.font); + Font_LoadOrderedFont(font); YREG(31) = 0; } @@ -484,7 +484,11 @@ void Regs_InitDataImpl(void) { R_TEXTBOX_X_TARGET = 54; R_TEXTBOX_Y_TARGET = 48; R_TEXTBOX_WIDTH_TARGET = 128; +#if !PLATFORM_IQUE R_TEXTBOX_HEIGHT_TARGET = 64; +#else + R_TEXTBOX_HEIGHT_TARGET = 74; +#endif R_TEXTBOX_TEXWIDTH_TARGET = 2048; R_TEXTBOX_TEXHEIGHT_TARGET = 512; XREG(78) = 96; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 7bd399d1e8..7d09da7e2e 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -639,9 +639,9 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } void func_80083108(PlayState* play) { - MessageContext* msgCtx = &play->msgCtx; - Player* player = GET_PLAYER(play); InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + MessageContext* msgCtx = &play->msgCtx; s16 i; s16 sp28 = false; @@ -1100,7 +1100,9 @@ void Interface_SetSceneRestrictions(PlayState* play) { InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 i = 0; u8 sceneId; +#if !PLATFORM_IQUE s32 pad[3]; +#endif interfaceCtx->restrictions.all = 0; interfaceCtx->restrictions.dinsNayrus = 0; @@ -1148,7 +1150,7 @@ void Interface_SetSceneRestrictions(PlayState* play) { interfaceCtx->restrictions.farores, interfaceCtx->restrictions.dinsNayrus, interfaceCtx->restrictions.all); PRINTF_RST(); - return; + break; } i++; } while (sRestrictionFlags[i].sceneId != 0xFF); @@ -1278,7 +1280,7 @@ void Inventory_SwapAgeEquipment(void) { } } - shieldEquipValue = gEquipMasks[EQUIP_TYPE_SHIELD] & gSaveContext.save.info.equips.equipment; + shieldEquipValue = gSaveContext.save.info.equips.equipment & gEquipMasks[EQUIP_TYPE_SHIELD]; if (shieldEquipValue) { shieldEquipValue >>= gEquipShifts[EQUIP_TYPE_SHIELD]; if (!CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, shieldEquipValue - 1)) { @@ -1641,8 +1643,7 @@ u8 Item_Give(PlayState* play, u8 item) { AMMO(ITEM_BOMBCHU) = 10; return ITEM_NONE; } else { - AMMO(ITEM_BOMBCHU) += 10; - if (AMMO(ITEM_BOMBCHU) > 50) { + if ((AMMO(ITEM_BOMBCHU) += 10) > 50) { AMMO(ITEM_BOMBCHU) = 50; } return ITEM_NONE; @@ -1653,8 +1654,7 @@ u8 Item_Give(PlayState* play, u8 item) { AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_5]; return ITEM_NONE; } else { - AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_5]; - if (AMMO(ITEM_BOMBCHU) > 50) { + if ((AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_5]) > 50) { AMMO(ITEM_BOMBCHU) = 50; } return ITEM_NONE; @@ -1801,15 +1801,15 @@ u8 Item_Give(PlayState* play, u8 item) { gSaveContext.save.info.equips.cButtonSlots[0], gSaveContext.save.info.equips.cButtonSlots[1], gSaveContext.save.info.equips.cButtonSlots[2], temp + i, item); - if ((temp + i) == gSaveContext.save.info.equips.cButtonSlots[0]) { + if (gSaveContext.save.info.equips.cButtonSlots[0] == temp + i) { gSaveContext.save.info.equips.buttonItems[1] = item; Interface_LoadItemIcon2(play, 1); gSaveContext.buttonStatus[1] = BTN_ENABLED; - } else if ((temp + i) == gSaveContext.save.info.equips.cButtonSlots[1]) { + } else if (gSaveContext.save.info.equips.cButtonSlots[1] == temp + i) { gSaveContext.save.info.equips.buttonItems[2] = item; Interface_LoadItemIcon2(play, 2); gSaveContext.buttonStatus[2] = BTN_ENABLED; - } else if ((temp + i) == gSaveContext.save.info.equips.cButtonSlots[2]) { + } else if (gSaveContext.save.info.equips.cButtonSlots[2] == temp + i) { gSaveContext.save.info.equips.buttonItems[3] = item; Interface_LoadItemIcon1(play, 3); gSaveContext.buttonStatus[3] = BTN_ENABLED; @@ -1838,7 +1838,7 @@ u8 Item_Give(PlayState* play, u8 item) { if (temp != ITEM_NONE) { for (i = 1; i < 4; i++) { - if (temp == gSaveContext.save.info.equips.buttonItems[i]) { + if (gSaveContext.save.info.equips.buttonItems[i] == temp) { if (item != ITEM_SOLD_OUT) { gSaveContext.save.info.equips.buttonItems[i] = item; Interface_LoadItemIcon1(play, i); @@ -2017,7 +2017,7 @@ s32 Inventory_ReplaceItem(PlayState* play, u16 oldItem, u16 newItem) { if (gSaveContext.save.info.equips.buttonItems[i] == oldItem) { gSaveContext.save.info.equips.buttonItems[i] = newItem; Interface_LoadItemIcon1(play, i); - break; + return true; } } return true; @@ -2349,6 +2349,8 @@ void Magic_Reset(PlayState* play) { * @return false if the request failed */ s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + if (!gSaveContext.save.info.playerData.isMagicAcquired) { return false; } @@ -2400,7 +2402,7 @@ s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type) { case MAGIC_CONSUME_LENS: if (gSaveContext.magicState == MAGIC_STATE_IDLE) { if (gSaveContext.save.info.playerData.magic != 0) { - play->interfaceCtx.lensMagicConsumptionTimer = 80; + interfaceCtx->lensMagicConsumptionTimer = 80; gSaveContext.magicState = MAGIC_STATE_CONSUME_LENS; return true; } else { @@ -2457,8 +2459,8 @@ void Magic_Update(PlayState* play) { static s16 sMagicBorderIndices[] = { 0, 1, 1, 0 }; static s16 sMagicBorderRatio = 2; static s16 sMagicBorderStep = 1; - MessageContext* msgCtx = &play->msgCtx; InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; s16 borderChangeR; s16 borderChangeG; s16 borderChangeB; @@ -2469,7 +2471,7 @@ void Magic_Update(PlayState* play) { // Step magicCapacity to the capacity determined by magicLevel // This changes the width of the magic meter drawn temp = gSaveContext.save.info.playerData.magicLevel * MAGIC_NORMAL_METER; - if (gSaveContext.magicCapacity != temp) { + if (temp != gSaveContext.magicCapacity) { if (gSaveContext.magicCapacity < temp) { gSaveContext.magicCapacity += 8; if (gSaveContext.magicCapacity > temp) { @@ -2659,11 +2661,12 @@ void Magic_DrawMeter(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 2650); if (gSaveContext.save.info.playerData.magicLevel != 0) { - if (gSaveContext.save.info.playerData.healthCapacity > 0xA0) { + // NOLINTBEGIN + if (gSaveContext.save.info.playerData.healthCapacity > 0xA0) magicMeterY = R_MAGIC_METER_Y_LOWER; // two rows of hearts - } else { + else magicMeterY = R_MAGIC_METER_Y_HIGHER; // one row of hearts - } + // NOLINTEND Gfx_SetupDL_39Overlay(play->state.gfxCtx); @@ -2679,8 +2682,8 @@ void Magic_DrawMeter(PlayState* play) { gDPLoadTextureBlock(OVERLAY_DISP++, gMagicMeterEndTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 16, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(OVERLAY_DISP++, (R_MAGIC_METER_X + gSaveContext.magicCapacity + 8) << 2, magicMeterY << 2, - (R_MAGIC_METER_X + gSaveContext.magicCapacity + 16) << 2, (magicMeterY + 16) << 2, + gSPTextureRectangle(OVERLAY_DISP++, (R_MAGIC_METER_X + 8 + gSaveContext.magicCapacity) << 2, magicMeterY << 2, + (R_MAGIC_METER_X + 8 + gSaveContext.magicCapacity + 8) << 2, (magicMeterY + 16) << 2, G_TX_RENDERTILE, 256, 0, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); @@ -2910,12 +2913,20 @@ void Interface_DrawItemButtons(PlayState* play) { gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); +#if !PLATFORM_IQUE gDPLoadTextureBlock_4b(OVERLAY_DISP++, cUpLabelTextures[gSaveContext.language], G_IM_FMT_IA, 32, 8, 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); - gSPTextureRectangle(OVERLAY_DISP++, R_C_UP_ICON_X << 2, R_C_UP_ICON_Y << 2, (R_C_UP_ICON_X + 32) << 2, (R_C_UP_ICON_Y + 8) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); +#else + gDPLoadTextureBlock_4b(OVERLAY_DISP++, cUpLabelTextures[gSaveContext.language], G_IM_FMT_IA, 48, 16, 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); + gSPTextureRectangle(OVERLAY_DISP++, (R_C_UP_ICON_X - 8) << 2, (R_C_UP_ICON_Y - 4) << 2, + (R_C_UP_ICON_X + 40) << 2, (R_C_UP_ICON_Y + 12) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); +#endif } sCUpTimer--; @@ -3006,7 +3017,9 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 100, 100, alpha); } - for (i = 0; ammo >= 10; i++) { + i = 0; + while (ammo >= 10) { + i++; ammo -= 10; } @@ -3446,11 +3459,11 @@ void Interface_Draw(PlayState* play) { pauseCtx->cursorVtx[16].v.ob[0] = pauseCtx->cursorVtx[18].v.ob[0] = pauseCtx->cursorVtx[16].v.ob[0] - svar1; pauseCtx->cursorVtx[17].v.ob[0] = pauseCtx->cursorVtx[19].v.ob[0] = - pauseCtx->cursorVtx[16].v.ob[0] + svar1 * 2 + 32; + pauseCtx->cursorVtx[16].v.ob[0] + 32 + svar1 * 2; pauseCtx->cursorVtx[16].v.ob[1] = pauseCtx->cursorVtx[17].v.ob[1] = pauseCtx->cursorVtx[16].v.ob[1] + svar1; pauseCtx->cursorVtx[18].v.ob[1] = pauseCtx->cursorVtx[19].v.ob[1] = - pauseCtx->cursorVtx[16].v.ob[1] - svar1 * 2 - 32; + pauseCtx->cursorVtx[16].v.ob[1] - 32 - svar1 * 2; } gSPVertex(OVERLAY_DISP++, &pauseCtx->cursorVtx[PAUSE_CURSOR_QUAD_4 * 4], 4, 0); @@ -3654,8 +3667,7 @@ void Interface_Draw(PlayState* play) { } if ((gSaveContext.timerState >= TIMER_STATE_ENV_HAZARD_MOVE) && (msgCtx->msgLength == 0)) { - sTimerNextSecondTimer--; - if (sTimerNextSecondTimer == 0) { + if (--sTimerNextSecondTimer == 0) { if (gSaveContext.timerSeconds != 0) { gSaveContext.timerSeconds--; } @@ -4008,8 +4020,8 @@ void Interface_Draw(PlayState* play) { void Interface_Update(PlayState* play) { static u8 D_80125B60 = false; static s16 sPrevTimeSpeed = 0; - MessageContext* msgCtx = &play->msgCtx; InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; Player* player = GET_PLAYER(play); s16 dimmingAlpha; s16 risingAlpha; diff --git a/src/overlays/actors/ovl_End_Title/z_end_title.c b/src/overlays/actors/ovl_End_Title/z_end_title.c index 0762c9c5e5..961f96f64f 100644 --- a/src/overlays/actors/ovl_End_Title/z_end_title.c +++ b/src/overlays/actors/ovl_End_Title/z_end_title.c @@ -46,18 +46,16 @@ void EndTitle_Update(Actor* thisx, PlayState* play) { // Used in the castle courtyard void EndTitle_DrawFull(Actor* thisx, PlayState* play) { - MtxF* mf; + PlayState* play2 = (PlayState*)play; EndTitle* this = (EndTitle*)thisx; - s32 csCurFrame = play->csCtx.curFrame; - Player* player = GET_PLAYER(play); - - mf = &player->mf_9E0; + s32 csCurFrame = play2->csCtx.curFrame; + Player* player = GET_PLAYER(play2); OPEN_DISPS(play->state.gfxCtx, "../z_end_title.c", 403); // Draw the Triforce on Link's left hand Gfx_SetupDL_25Xlu(play->state.gfxCtx); - Matrix_Mult(mf, MTXMODE_NEW); + Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); Matrix_Translate(0.0f, 150.0f, 170.0f, MTXMODE_APPLY); Matrix_Scale(0.13f, 0.13f, 0.13f, MTXMODE_APPLY); Matrix_RotateX(BINANG_TO_RAD(0xBB8), MTXMODE_APPLY); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 992cb945bd..416db5fe37 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -40,7 +40,7 @@ void ConsoleLogo_PrintBuildInfo(Gfx** gfxP) { #endif void ConsoleLogo_Calc(ConsoleLogoState* this) { -#if PLATFORM_N64 +#if !PLATFORM_GC if ((this->coverAlpha == 0) && (this->visibleDuration != 0)) { this->unk_1D4--; this->visibleDuration--; @@ -74,8 +74,8 @@ void ConsoleLogo_SetupView(ConsoleLogoState* this, f32 x, f32 y, f32 z) { eye.y = y; eye.z = z; up.x = up.z = 0.0f; - lookAt.x = lookAt.y = lookAt.z = 0.0f; up.y = 1.0f; + lookAt.x = lookAt.y = lookAt.z = 0.0f; View_SetPerspective(view, 30.0f, 10.0f, 12800.0f); View_LookAt(view, &eye, &lookAt, &up); @@ -92,7 +92,9 @@ void ConsoleLogo_Draw(ConsoleLogoState* this) { Vec3f v3; Vec3f v1; Vec3f v2; +#if !PLATFORM_IQUE s32 pad2[2]; +#endif OPEN_DISPS(this->state.gfxCtx, "../z_title.c", 395); @@ -165,6 +167,10 @@ void ConsoleLogo_Main(GameState* thisx) { } #endif +#if PLATFORM_IQUE + this->exit = true; +#endif + if (this->exit) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = 0xFF; @@ -221,7 +227,7 @@ void ConsoleLogo_Init(GameState* thisx) { this->state.destroy = ConsoleLogo_Destroy; this->exit = false; -#if OOT_VERSION < GC_US +#if OOT_VERSION < GC_US || PLATFORM_IQUE if (!(gPadMgr.validCtrlrsMask & 1)) { gSaveContext.fileNum = 0xFEDC; } else {