From a487014623003512e8cd385ee8b4fc8c612ac092 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Sun, 3 Dec 2023 13:14:54 -0500 Subject: [PATCH] Made RT64 into a submodule, redid UI patching using new extended gbi alignment commands --- .gitmodules | 10 +- CMakeLists.txt | 28 +- lib/RT64-HLE | 1 + {thirdparty => lib}/RmlUi | 0 .../blockingconcurrentqueue.h | 0 .../concurrentqueue}/concurrentqueue.h | 0 .../concurrentqueue}/lightweightsemaphore.h | 0 {thirdparty => lib}/nativefiledialog-extended | 0 patches/Makefile | 2 +- patches/ui_patches.c | 1137 ++--------------- 10 files changed, 116 insertions(+), 1062 deletions(-) create mode 160000 lib/RT64-HLE rename {thirdparty => lib}/RmlUi (100%) rename {thirdparty => lib/concurrentqueue}/blockingconcurrentqueue.h (100%) rename {thirdparty => lib/concurrentqueue}/concurrentqueue.h (100%) rename {thirdparty => lib/concurrentqueue}/lightweightsemaphore.h (100%) rename {thirdparty => lib}/nativefiledialog-extended (100%) diff --git a/.gitmodules b/.gitmodules index ef3d8ff..2a8708b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "lib/RmlUi"] path = lib/RmlUi url = https://github.com/mikke89/RmlUi/ -[submodule "thirdparty/RmlUi"] - path = thirdparty/RmlUi - url = https://github.com/mikke89/RmlUi -[submodule "thirdparty/nativefiledialog-extended"] - path = thirdparty/nativefiledialog-extended +[submodule "lib/nativefiledialog-extended"] + path = lib/nativefiledialog-extended url = https://github.com/btzy/nativefiledialog-extended +[submodule "lib/RT64-HLE"] + path = lib/RT64-HLE + url = https://github.com/DarioSamo/RT64-HLE/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 321d1e1..beacf4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,9 +15,9 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) find_package(Freetype REQUIRED) -add_subdirectory(${CMAKE_SOURCE_DIR}/../mupen_rt64/mupen64plus-video-rt64 ${CMAKE_BINARY_DIR}/rt64) -add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/RmlUi) -add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/nativefiledialog-extended) +add_subdirectory(${CMAKE_SOURCE_DIR}/lib/RT64-HLE ${CMAKE_BINARY_DIR}/rt64) +add_subdirectory(${CMAKE_SOURCE_DIR}/lib/RmlUi) +add_subdirectory(${CMAKE_SOURCE_DIR}/lib/nativefiledialog-extended) target_include_directories(rt64 PRIVATE ${CMAKE_BINARY_DIR}/rt64/src) get_target_property(RT64_BASENAME rt64 OUTPUT_NAME) @@ -119,18 +119,18 @@ set (SOURCES ${CMAKE_SOURCE_DIR}/rsp/aspMain.cpp ${CMAKE_SOURCE_DIR}/rsp/njpgdspMain.cpp - ${CMAKE_SOURCE_DIR}/thirdparty/RmlUi/Backends/RmlUi_Platform_SDL.cpp + ${CMAKE_SOURCE_DIR}/lib/RmlUi/Backends/RmlUi_Platform_SDL.cpp ) target_include_directories(MMRecomp PRIVATE ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/thirdparty - ${CMAKE_SOURCE_DIR}/thirdparty/RmlUi/Include - ${CMAKE_SOURCE_DIR}/thirdparty/RmlUi/Backends - ${CMAKE_SOURCE_DIR}/../mupen_rt64/mupen64plus-win32-deps/SDL2-2.26.3/include - ${CMAKE_SOURCE_DIR}/../mupen_rt64/mupen64plus-video-rt64/src - ${CMAKE_SOURCE_DIR}/../mupen_rt64/mupen64plus-video-rt64/src/rhi - ${CMAKE_SOURCE_DIR}/../mupen_rt64/mupen64plus-video-rt64/src/render + ${CMAKE_SOURCE_DIR}/lib/concurrentqueue + ${CMAKE_SOURCE_DIR}/lib/RmlUi/Include + ${CMAKE_SOURCE_DIR}/lib/RmlUi/Backends + ${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/contrib/mupen64plus-win32-deps/SDL2-2.26.3/include + ${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src + ${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/rhi + ${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/render ${CMAKE_BINARY_DIR}/shaders ) @@ -141,7 +141,7 @@ target_compile_options(MMRecomp PRIVATE ) target_link_directories(MMRecomp PRIVATE - ${CMAKE_SOURCE_DIR}/../mupen_rt64/mupen64plus-win32-deps/SDL2-2.26.3/lib/x64 + ${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/contrib/mupen64plus-win32-deps/SDL2-2.26.3/lib/x64 ) target_link_libraries(MMRecomp PRIVATE @@ -167,10 +167,10 @@ set (DXC_GS_OPTS "${DXC_COMMON_OPTS}" "-E" "GSMain" "-T gs_6_0") set (DXC_RT_OPTS "${DXC_COMMON_OPTS}" "-D" "RT_SHADER" "-T" "lib_6_3" "-fspv-target-env=vulkan1.1spirv1.4" "-fspv-extension=SPV_KHR_ray_tracing" "-fspv-extension=SPV_EXT_descriptor_indexing") if (${WIN32}) - set (DXC "${PROJECT_SOURCE_DIR}/../mupen_rt64/mupen64plus-video-rt64/src/contrib/dxc/bin/x64/dxc.exe") + set (DXC "${PROJECT_SOURCE_DIR}/lib/RT64-HLE/src/contrib/dxc/bin/x64/dxc.exe") add_compile_definitions(NOMINMAX) else() - set (DXC "LD_LIBRARY_PATH=${PROJECT_SOURCE_DIR}/../mupen_rt64/mupen64plus-video-rt64/src/contrib/dxc/lib/x64" "${PROJECT_SOURCE_DIR}/src/contrib/dxc/bin/x64/dxc") + set (DXC "LD_LIBRARY_PATH=${PROJECT_SOURCE_DIR}/lib/RT64-HLE/src/src/contrib/dxc/lib/x64" "${PROJECT_SOURCE_DIR}/src/contrib/dxc/bin/x64/dxc") endif() build_vertex_shader(MMRecomp "shaders/InterfaceVS.hlsl" "shaders/InterfaceVS.hlsl") diff --git a/lib/RT64-HLE b/lib/RT64-HLE new file mode 160000 index 0000000..0edd928 --- /dev/null +++ b/lib/RT64-HLE @@ -0,0 +1 @@ +Subproject commit 0edd928a3d0843092e968189c45b56a8e41e1efd diff --git a/thirdparty/RmlUi b/lib/RmlUi similarity index 100% rename from thirdparty/RmlUi rename to lib/RmlUi diff --git a/thirdparty/blockingconcurrentqueue.h b/lib/concurrentqueue/blockingconcurrentqueue.h similarity index 100% rename from thirdparty/blockingconcurrentqueue.h rename to lib/concurrentqueue/blockingconcurrentqueue.h diff --git a/thirdparty/concurrentqueue.h b/lib/concurrentqueue/concurrentqueue.h similarity index 100% rename from thirdparty/concurrentqueue.h rename to lib/concurrentqueue/concurrentqueue.h diff --git a/thirdparty/lightweightsemaphore.h b/lib/concurrentqueue/lightweightsemaphore.h similarity index 100% rename from thirdparty/lightweightsemaphore.h rename to lib/concurrentqueue/lightweightsemaphore.h diff --git a/thirdparty/nativefiledialog-extended b/lib/nativefiledialog-extended similarity index 100% rename from thirdparty/nativefiledialog-extended rename to lib/nativefiledialog-extended diff --git a/patches/Makefile b/patches/Makefile index bc1fc38..b4b538f 100644 --- a/patches/Makefile +++ b/patches/Makefile @@ -5,7 +5,7 @@ LD := ld.lld OBJCOPY := llvm-objcopy CFLAGS := -target mips -mips2 -mabi=32 -O2 -mno-abicalls -mno-odd-spreg -fomit-frame-pointer -mno-check-zero-division -G0 -Wall -Wextra -Wno-incompatible-library-redeclaration -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-variable -Wno-missing-braces -CPPFLAGS := -nostdinc -D_LANGUAGE_C -DMIPS -I ../../mm/include -I ../../mm/src -I ../../mm/build -I ../../mm/assets -I../../mupen_rt64/mupen64plus-video-rt64/include +CPPFLAGS := -nostdinc -D_LANGUAGE_C -DMIPS -I ../../mm/include -I ../../mm/src -I ../../mm/build -I ../../mm/assets -I../lib/RT64-HLE/include LDFLAGS := -nostdlib -T patches.ld -T syms.ld --just-symbols=../mm.us.rev1.elf --allow-multiple-definition BINFLAGS := -O binary diff --git a/patches/ui_patches.c b/patches/ui_patches.c index d0eca0a..275bd6e 100644 --- a/patches/ui_patches.c +++ b/patches/ui_patches.c @@ -40,281 +40,13 @@ void Graph_SetNextGfxPool(GraphicsContext* gfxCtx) { gSPEndDisplayList(&gGfxMasterDL->disps[4]); gSPBranchList(&gGfxMasterDL->debugDisp[0], pool->debugBuffer); - // Enable RT64 extended GBI mode + // @recomp Enable RT64 extended GBI mode OPEN_DISPS(gfxCtx); gEXEnable(POLY_OPA_DISP++); // gEXPrint(POLY_OPA_DISP++); CLOSE_DISPS(gfxCtx); } -// Adjusts an x-coordinate to the relative to be given origin -s16 adjust_x(s16 xPos, u32 origin) { - switch (origin) { - default: - return xPos - margin_reduction; - case G_EX_ORIGIN_RIGHT: - return xPos - SCREEN_WIDTH + margin_reduction; - case G_EX_ORIGIN_CENTER: - return xPos - (SCREEN_WIDTH / 2); - } -} - -// Adjusts an x-coordinate with 2 fractional bits to be relative to the given origin -s16 adjust_x_fractional(s16 xPos, u32 origin) { - switch (origin) { - default: - return xPos - (margin_reduction << 2); - case G_EX_ORIGIN_RIGHT: - return xPos - (SCREEN_WIDTH << 2) + (margin_reduction << 2); - case G_EX_ORIGIN_CENTER: - return xPos - ((SCREEN_WIDTH / 2) << 2); - } -} - -typedef enum { - Y_ORIGIN_TOP, - Y_ORIGIN_CENTER, - Y_ORIGIN_BOTTOM -} YOrigin; - -// Adjusts a top y-coordinate to be relative to the given origin -s16 adjust_y(s16 yPos, YOrigin origin) { - switch (origin) { - default: - return yPos - margin_reduction; - case Y_ORIGIN_CENTER: - return yPos; - case Y_ORIGIN_BOTTOM: - return yPos + margin_reduction; - } -} - -// Adjusts a y-coordinate with 2 fractional bits to be relative to the given origin -s16 adjust_y_fractional(s16 yPos, YOrigin origin) { - switch (origin) { - default: - return yPos - (margin_reduction << 2); - case Y_ORIGIN_CENTER: - return yPos; - case Y_ORIGIN_BOTTOM: - return yPos + (margin_reduction << 2); - } -} - -/** - * Draw an IA8 texture on a rectangle with a shadow slightly offset to the bottom-right - * - * @param gfx the display list pointer - * @param texture - * @param textureWidth texture image width in texels - * @param textureHeight texture image height in texels - * @param rectLeft the x-coordinate of upper-left corner of rectangle - * @param rectTop the y-coordinate of upper-left corner of rectangle - * @param rectWidth rectangle width in texels - * @param rectHeight rectangle height in texels - * @param dsdx the change in s for each change in x (s5.10) - * @param dtdy the change in t for each change in y (s5.10) - * @param r texture red - * @param g texture green - * @param b texture blue - * @param a texture alpha - * @return Gfx* the display list pointer - */ -Gfx* GfxEx_DrawTexRectIA8_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, - s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, s16 r, s16 g, s16 b, - s16 a, u32 origin_x, u32 origin_y) { - s16 dropShadowAlpha = a; - - if (a > 100) { - dropShadowAlpha = 100; - } - - rectLeft = adjust_x(rectLeft, origin_x); - rectTop = adjust_x(rectTop, origin_y); - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); - - gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, 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); - - gEXTextureRectangle(gfx++, origin_x, origin_x, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); - - gEXTextureRectangle(gfx++, origin_x, origin_x, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - - return gfx; -} - -/** - * Draw a colored rectangle with a shadow slightly offset to the bottom-right - * - * @param gfx the display list pointer - * @param rectLeft the x-coordinate of upper-left corner of rectangle - * @param rectTop the y-coordinate of upper-left corner of rectangle - * @param rectWidth rectangle width in texels - * @param rectHeight rectangle height in texels - * @param dsdx the change in s for each change in x (s5.10) - * @param dtdy the change in t for each change in y (s5.10) - * @param r // rectangle red - * @param g // rectangle green - * @param b // rectangle blue - * @param a // rectangle alpha - * @return Gfx* the display list pointer - */ -Gfx* GfxEx_DrawRect_DropShadow(Gfx* gfx, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, - s16 r, s16 g, s16 b, s16 a, u32 origin_x, u32 origin_y) { - s16 dropShadowAlpha = a; - - if (a > 100) { - dropShadowAlpha = 100; - } - - rectLeft = adjust_x(rectLeft, origin_x); - rectTop = adjust_x(rectTop, origin_y); - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); - gEXTextureRectangle(gfx++, origin_x, origin_x, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); - - gEXTextureRectangle(gfx++, origin_x, origin_x, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - - return gfx; -} - - -/** - * Draw an IA8 texture on a rectangle with a shadow slightly offset to the bottom-right with additional texture offsets - * - * @param gfx the display list pointer - * @param texture - * @param textureWidth texture image width in texels - * @param textureHeight texture image height in texels - * @param rectLeft the x-coordinate of upper-left corner of rectangle - * @param rectTop the y-coordinate of upper-left corner of rectangle - * @param rectWidth rectangle width in texels - * @param rectHeight rectangle height in texels - * @param dsdx the change in s for each change in x (s5.10) - * @param dtdy the change in t for each change in y (s5.10) - * @param r // texture red - * @param g // texture green - * @param b // texture blue - * @param a // texture alpha - * @param masks specify the mask for the s axis - * @param rects the texture coordinate s of upper-left corner of rectangle (s10.5) - * @return Gfx* the display list pointer - */ -Gfx* GfxEx_DrawTexRectIA8_DropShadowOffset(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, - s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, - s16 r, s16 g, s16 b, s16 a, s32 masks, s32 rects, u32 origin_x, u32 origin_y) { - s16 dropShadowAlpha = a; - - if (a > 100) { - dropShadowAlpha = 100; - } - - rectLeft = adjust_x(rectLeft, origin_x); - rectTop = adjust_x(rectTop, origin_y); - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); - - gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, textureHeight, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - - gEXTextureRectangle(gfx++, origin_x, origin_x, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, rects, 0, dsdx, dtdy); - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); - - gEXTextureRectangle(gfx++, origin_x, origin_x, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, rects, 0, dsdx, dtdy); - - return gfx; -} - -/** - * Draw an IA8 texture on a rectangle - * - * @param gfx the display list pointer - * @param texture - * @param textureWidth texture image width in texels - * @param textureHeight texture image height in texels - * @param rectLeft the x-coordinate of upper-left corner of rectangle - * @param rectTop the y-coordinate of upper-left corner of rectangle - * @param rectWidth rectangle width in texels - * @param rectHeight rectangle height in texels - * @param dsdx the change in s for each change in x (s5.10) - * @param dtdy the change in t for each change in y (s5.10) - * @return Gfx* the display list pointer - */ -Gfx* GfxEx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, - s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, u32 origin_x, u32 origin_y) { - gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, 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 = adjust_x(rectLeft, origin_x); - rectTop = adjust_y(rectTop, origin_y); - - gEXTextureRectangle(gfx++, origin_x, origin_x, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - - return gfx; -} - -/** - * Draw an I8 texture on a rectangle - * - * @param gfx the display list pointer - * @param texture - * @param textureWidth texture image width in texels - * @param textureHeight texture image height in texels - * @param rectLeft the x-coordinate of upper-left corner of rectangle - * @param rectTop the y-coordinate of upper-left corner of rectangle - * @param rectWidth rectangle width in texels - * @param rectHeight rectangle height in texels - * @param dsdx the change in s for each change in x (s5.10) - * @param dtdy the change in t for each change in y (s5.10) - * @return Gfx* the display list pointer - */ -Gfx* GfxEx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, - s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, u32 origin_x, u32 origin_y) { - gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_I, G_IM_SIZ_8b, textureWidth, 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 = adjust_x(rectLeft, origin_x); - rectTop = adjust_y(rectTop, origin_y); - - gEXTextureRectangle(gfx++, origin_x, origin_x, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - - return gfx; -} - -extern u8 gTatlCUpENGTex[]; -extern u8 gTatlCUpGERTex[]; -extern u8 gTatlCUpFRATex[]; -extern u8 gTatlCUpESPTex[]; -extern u8 gButtonBackgroundTex[]; -extern s16 D_801BF9D4[]; -extern s16 D_801BF9DC[]; -extern s16 D_801BF9E4[]; -extern s16 D_801BF9BC[]; -extern u8 gAmmoDigit0Tex[]; - typedef enum { /* 0 */ PICTO_BOX_STATE_OFF, // Not using the pictograph /* 1 */ PICTO_BOX_STATE_LENS, // Looking through the lens of the pictograph @@ -323,740 +55,6 @@ typedef enum { } PictoBoxState; extern s16 sPictoState; -extern u16 sCUpInvisible; -extern u16 sCUpTimer; - -#define DO_ACTION_TEX_WIDTH 48 -#define DO_ACTION_TEX_HEIGHT 16 -#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) - -// Modify item button drawing to use the extended GBI texture rectangles for widescreen support -void Interface_DrawItemButtons(PlayState* play) { - static TexturePtr cUpLabelTextures[] = { - gTatlCUpENGTex, gTatlCUpENGTex, gTatlCUpGERTex, gTatlCUpFRATex, gTatlCUpESPTex, - }; - static s16 startButtonLeftPos[] = { - // Remnant of OoT - 130, 136, 136, 136, 136, - }; - static s16 D_801BFAF4[] = { - 0x1D, // EQUIP_SLOT_B - 0x1B, // EQUIP_SLOT_C_LEFT - 0x1B, // EQUIP_SLOT_C_DOWN - 0x1B, // EQUIP_SLOT_C_RIGHT - }; - InterfaceContext* interfaceCtx = &play->interfaceCtx; - Player* player = GET_PLAYER(play); - PauseContext* pauseCtx = &play->pauseCtx; - MessageContext* msgCtx = &play->msgCtx; - s16 temp; // Used as both an alpha value and a button index - s32 pad; - - OPEN_DISPS(play->state.gfxCtx); - - gDPPipeSync(OVERLAY_DISP++); - gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - - // B Button Color & Texture - OVERLAY_DISP = GfxEx_DrawTexRectIA8_DropShadow( - OVERLAY_DISP, gButtonBackgroundTex, 0x20, 0x20, D_801BF9D4[EQUIP_SLOT_B], D_801BF9DC[EQUIP_SLOT_B], - D_801BFAF4[EQUIP_SLOT_B], D_801BFAF4[EQUIP_SLOT_B], D_801BF9E4[EQUIP_SLOT_B] * 2, D_801BF9E4[EQUIP_SLOT_B] * 2, - 100, 255, 120, interfaceCtx->bAlpha, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - gDPPipeSync(OVERLAY_DISP++); - - // C-Left Button Color & Texture - OVERLAY_DISP = GfxEx_DrawRect_DropShadow(OVERLAY_DISP, D_801BF9D4[EQUIP_SLOT_C_LEFT], D_801BF9DC[EQUIP_SLOT_C_LEFT], - D_801BFAF4[EQUIP_SLOT_C_LEFT], D_801BFAF4[EQUIP_SLOT_C_LEFT], - D_801BF9E4[EQUIP_SLOT_C_LEFT] * 2, D_801BF9E4[EQUIP_SLOT_C_LEFT] * 2, 255, - 240, 0, interfaceCtx->cLeftAlpha, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - // C-Down Button Color & Texture - OVERLAY_DISP = GfxEx_DrawRect_DropShadow(OVERLAY_DISP, D_801BF9D4[EQUIP_SLOT_C_DOWN], D_801BF9DC[EQUIP_SLOT_C_DOWN], - D_801BFAF4[EQUIP_SLOT_C_DOWN], D_801BFAF4[EQUIP_SLOT_C_DOWN], - D_801BF9E4[EQUIP_SLOT_C_DOWN] * 2, D_801BF9E4[EQUIP_SLOT_C_DOWN] * 2, 255, - 240, 0, interfaceCtx->cDownAlpha, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - // C-Right Button Color & Texture - OVERLAY_DISP = GfxEx_DrawRect_DropShadow(OVERLAY_DISP, D_801BF9D4[EQUIP_SLOT_C_RIGHT], D_801BF9DC[EQUIP_SLOT_C_RIGHT], - D_801BFAF4[EQUIP_SLOT_C_RIGHT], D_801BFAF4[EQUIP_SLOT_C_RIGHT], - D_801BF9E4[EQUIP_SLOT_C_RIGHT] * 2, D_801BF9E4[EQUIP_SLOT_C_RIGHT] * 2, 255, - 240, 0, interfaceCtx->cRightAlpha, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - - if (!IS_PAUSE_STATE_GAMEOVER) { - if ((play->pauseCtx.state != PAUSE_STATE_OFF) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { - OVERLAY_DISP = GfxEx_DrawRect_DropShadow(OVERLAY_DISP, 0x88, 0x11, 0x16, 0x16, 0x5B6, 0x5B6, 0xFF, 0x82, 0x3C, - interfaceCtx->startAlpha, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - // Start Button Texture, Color & Label - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->startAlpha); - gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); - gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE * 2, G_IM_FMT_IA, - DO_ACTION_TEX_WIDTH, DO_ACTION_TEX_HEIGHT, 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); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, G_EX_ORIGIN_RIGHT, - adjust_x(126, G_EX_ORIGIN_RIGHT) * 4, adjust_y(21, Y_ORIGIN_TOP) * 4, - adjust_x(181, G_EX_ORIGIN_RIGHT) * 4, adjust_y(39, Y_ORIGIN_TOP) * 4, - G_TX_RENDERTILE, 0, 0, 0x04A6, 0x04A6); - } - } - - if (interfaceCtx->tatlCalling && (play->pauseCtx.state == PAUSE_STATE_OFF) && - (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && (play->csCtx.state == CS_STATE_IDLE) && - (sPictoState == PICTO_BOX_STATE_OFF)) { - if (sCUpInvisible == 0) { - // C-Up Button Texture, Color & Label (Tatl Text) - gDPPipeSync(OVERLAY_DISP++); - - if ((gSaveContext.hudVisibility == HUD_VISIBILITY_NONE) || - (gSaveContext.hudVisibility == HUD_VISIBILITY_NONE_ALT) || - (gSaveContext.hudVisibility == HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE) || - (msgCtx->msgMode != MSGMODE_NONE)) { - temp = 0; - } else if (player->stateFlags1 & PLAYER_STATE1_200000) { - temp = 70; - } else { - temp = interfaceCtx->aAlpha; - } - - OVERLAY_DISP = - GfxEx_DrawRect_DropShadow(OVERLAY_DISP, 0xFE, 0x10, 0x10, 0x10, 0x800, 0x800, 0xFF, 0xF0, 0, temp, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, temp); - gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); - gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, - PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, cUpLabelTextures[gSaveContext.options.language], G_IM_FMT_IA, 32, 12, - 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); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, G_EX_ORIGIN_RIGHT, - adjust_x(247, G_EX_ORIGIN_RIGHT) * 4, adjust_y(18, Y_ORIGIN_TOP) * 4, - adjust_x(279, G_EX_ORIGIN_RIGHT) * 4, adjust_y(30, Y_ORIGIN_TOP) * 4, G_TX_RENDERTILE, 0, 0, 1 << 10, - 1 << 10); - } - - sCUpTimer--; - if (sCUpTimer == 0) { - sCUpInvisible ^= 1; - sCUpTimer = 10; - } - } - - gDPPipeSync(OVERLAY_DISP++); - - // Empty C Button Arrows - for (temp = EQUIP_SLOT_C_LEFT; temp <= EQUIP_SLOT_C_RIGHT; temp++) { - if (GET_CUR_FORM_BTN_ITEM(temp) > 0xF0) { - if (temp == EQUIP_SLOT_C_LEFT) { - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cLeftAlpha); - } else if (temp == EQUIP_SLOT_C_DOWN) { - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cDownAlpha); - } else { // EQUIP_SLOT_C_RIGHT - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cRightAlpha); - } - OVERLAY_DISP = GfxEx_DrawTexRectIA8(OVERLAY_DISP, ((u8*)gButtonBackgroundTex + ((32 * 32) * (temp + 1))), - 0x20, 0x20, D_801BF9D4[temp], D_801BF9DC[temp], D_801BFAF4[temp], - D_801BFAF4[temp], D_801BF9E4[temp] * 2, D_801BF9E4[temp] * 2, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - } - } - - CLOSE_DISPS(play->state.gfxCtx); -} - -// Modify item icon drawing to use the extended GBI texture rectangles for widescreen support -void Interface_DrawItemIconTexture(PlayState* play, TexturePtr texture, s16 button) { - static s16 D_801BFAFC[] = { 30, 24, 24, 24 }; - - OPEN_DISPS(play->state.gfxCtx); - - gDPLoadTextureBlock(OVERLAY_DISP++, texture, G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, 32, 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); - - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, G_EX_ORIGIN_RIGHT, - adjust_x(D_801BF9D4[button], G_EX_ORIGIN_RIGHT) * 4, adjust_y(D_801BF9DC[button], Y_ORIGIN_TOP) * 4, - adjust_x(D_801BF9D4[button] + D_801BFAFC[button], G_EX_ORIGIN_RIGHT) * 4, adjust_y(D_801BF9DC[button] + D_801BFAFC[button], Y_ORIGIN_TOP) * 4, - G_TX_RENDERTILE, 0, 0, D_801BF9BC[button] << 1, D_801BF9BC[button] << 1); - - CLOSE_DISPS(play->state.gfxCtx); -} - -// Modify drawing A button for widescreen -extern f32 D_801BF9CC[]; - -void Interface_SetPerspectiveView(PlayState* play, s32 topY, s32 bottomY, s32 leftX, s32 rightX); -void View_ViewportToVp(Vp* dest, Viewport* src); - -void ViewEx_SetScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 lorigin, u32 rorigin) { - Gfx* gfxp = *gfx; - - ulx = adjust_x(ulx, lorigin); - lrx = adjust_x(lrx, rorigin); - - gEXSetScissor(gfxp++, G_SC_NON_INTERLACE, lorigin, rorigin, ulx, uly, lrx, lry); - - *gfx = gfxp; -} - - -void View_SetScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry); - -/** - * Apply scissor, viewport, view and projection (perspective) to OVERLAY_DISP. - */ -s32 ViewEx_ApplyPerspectiveToOverlay(View* view, u32 origin_x, u32 origin_y) { - f32 aspect; - s32 width; - s32 height; - Vp* vp; - Mtx* projection; - Mtx* viewing; - GraphicsContext* gfxCtx; - s32 pad; - - gfxCtx = view->gfxCtx; - - OPEN_DISPS(gfxCtx); - - vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); - View_ViewportToVp(vp, &view->viewport); - view->vp = *vp; - - gDPPipeSync(OVERLAY_DISP++); - { - s32 pad; - Gfx* overlay; - - overlay = OVERLAY_DISP; - ViewEx_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY, origin_x, origin_x); - OVERLAY_DISP = overlay; - } - - vp->vp.vtrans[0] = adjust_x_fractional(vp->vp.vtrans[0], origin_x); - vp->vp.vtrans[1] = adjust_y_fractional(vp->vp.vtrans[1], origin_y); - - gEXViewport(OVERLAY_DISP++, origin_x, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - view->projectionPtr = projection; - - width = view->viewport.rightX - view->viewport.leftX; - height = view->viewport.bottomY - view->viewport.topY; - aspect = (f32)width / (f32)height; - - guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); - - view->projection = *projection; - - gSPPerspNormalize(OVERLAY_DISP++, view->perspNorm); - gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - - viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - view->viewingPtr = viewing; - - // This check avoids a divide-by-zero in guLookAt if eye == at - if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { - view->eye.z += 2.0f; - } - - guLookAt(viewing, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, - view->up.z); - - view->viewing = *viewing; - - gSPMatrix(OVERLAY_DISP++, viewing, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - - CLOSE_DISPS(gfxCtx); - - return 1; -} - -void InterfaceEx_SetPerspectiveView(PlayState* play, s32 topY, s32 bottomY, s32 leftX, s32 rightX, u32 origin_x, u32 origin_y) { - InterfaceContext* interfaceCtx = &play->interfaceCtx; - Vec3f eye; - Vec3f at; - Vec3f up; - - eye.x = eye.y = eye.z = 0.0f; - at.x = at.y = 0.0f; - at.z = -1.0f; - up.x = up.z = 0.0f; - up.y = 1.0f; - - View_LookAt(&interfaceCtx->view, &eye, &at, &up); - - interfaceCtx->viewport.topY = topY; - interfaceCtx->viewport.bottomY = bottomY; - interfaceCtx->viewport.leftX = leftX; - interfaceCtx->viewport.rightX = rightX; - View_SetViewport(&interfaceCtx->view, &interfaceCtx->viewport); - - View_SetPerspective(&interfaceCtx->view, 60.0f, 10.0f, 60.0f); - ViewEx_ApplyPerspectiveToOverlay(&interfaceCtx->view, origin_x, origin_y); -} - -void Interface_DrawAButton(PlayState* play) { - InterfaceContext* interfaceCtx = &play->interfaceCtx; - s16 aAlpha; - - OPEN_DISPS(play->state.gfxCtx); - - aAlpha = interfaceCtx->aAlpha; - - if (aAlpha > 100) { - aAlpha = 100; - } - - Gfx_SetupDL42_Overlay(play->state.gfxCtx); - - InterfaceEx_SetPerspectiveView(play, 25 + R_A_BTN_Y_OFFSET, 70 + R_A_BTN_Y_OFFSET, 192, 237, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - - gSPClearGeometryMode(OVERLAY_DISP++, G_CULL_BOTH); - gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); - - Matrix_Translate(0.0f, 0.0f, -38.0f, MTXMODE_NEW); - Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateXFApply(interfaceCtx->aButtonRoll / 10000.0f); - - // Draw A button Shadow - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPPipeSync(OVERLAY_DISP++); - gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[4], 4, 0); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, aAlpha); - - OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, gButtonBackgroundTex, 32, 32, 0); - - // Draw A Button Colored - gDPPipeSync(OVERLAY_DISP++); - InterfaceEx_SetPerspectiveView(play, 23 + R_A_BTN_Y_OFFSET, 68 + R_A_BTN_Y_OFFSET, 190, 235, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[0], 4, 0); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 200, 255, interfaceCtx->aAlpha); - gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); - - // Draw A Button Do-Action - gDPPipeSync(OVERLAY_DISP++); - InterfaceEx_SetPerspectiveView(play, 23 + R_A_BTN_Y_OFFSET, 68 + R_A_BTN_Y_OFFSET, 190, 235, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - gSPSetGeometryMode(OVERLAY_DISP++, G_CULL_BACK); - gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, - ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->aAlpha); - gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); - - Matrix_Translate(0.0f, 0.0f, D_801BF9CC[gSaveContext.options.language] / 10.0f, MTXMODE_NEW); - Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateXFApply(interfaceCtx->aButtonRoll / 10000.0f); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[8], 4, 0); - - // Draw Action Label - if (((interfaceCtx->aButtonState <= A_BTN_STATE_1) || (interfaceCtx->aButtonState == A_BTN_STATE_3))) { - OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, interfaceCtx->doActionSegment, 3, DO_ACTION_TEX_WIDTH, - DO_ACTION_TEX_HEIGHT, 0); - } else { - OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE, 3, - DO_ACTION_TEX_WIDTH, DO_ACTION_TEX_HEIGHT, 0); - } - - CLOSE_DISPS(play->state.gfxCtx); -} - -extern s16 D_801BFB04[]; -extern s16 D_801BFB0C[]; - -// Modify item ammo count drawing to use the extended GBI texture rectangles for widescreen support -void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { - u8 i; - u16 ammo; - - OPEN_DISPS(play->state.gfxCtx); - - i = ((void)0, GET_CUR_FORM_BTN_ITEM(button)); - - if ((i == ITEM_DEKU_STICK) || (i == ITEM_DEKU_NUT) || (i == ITEM_BOMB) || (i == ITEM_BOW) || - ((i >= ITEM_BOW_FIRE) && (i <= ITEM_BOW_LIGHT)) || (i == ITEM_BOMBCHU) || (i == ITEM_POWDER_KEG) || - (i == ITEM_MAGIC_BEANS) || (i == ITEM_PICTOGRAPH_BOX)) { - - if ((i >= ITEM_BOW_FIRE) && (i <= ITEM_BOW_LIGHT)) { - i = ITEM_BOW; - } - - ammo = AMMO(i); - - if (i == ITEM_PICTOGRAPH_BOX) { - if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { - ammo = 0; - } else { - ammo = 1; - } - } - - gDPPipeSync(OVERLAY_DISP++); - - if ((button == EQUIP_SLOT_B) && (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE)) { - ammo = play->interfaceCtx.minigameAmmo; - } else if ((button == EQUIP_SLOT_B) && (play->unk_1887C > 1)) { - ammo = play->unk_1887C - 1; - } else if (((i == ITEM_BOW) && (AMMO(i) == CUR_CAPACITY(UPG_QUIVER))) || - ((i == ITEM_BOMB) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || - ((i == ITEM_DEKU_STICK) && (AMMO(i) == CUR_CAPACITY(UPG_DEKU_STICKS))) || - ((i == ITEM_DEKU_NUT) && (AMMO(i) == CUR_CAPACITY(UPG_DEKU_NUTS))) || - ((i == ITEM_BOMBCHU) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || - ((i == ITEM_POWDER_KEG) && (ammo == 1)) || ((i == ITEM_PICTOGRAPH_BOX) && (ammo == 1)) || - ((i == ITEM_MAGIC_BEANS) && (ammo == 20))) { - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, alpha); - } - - if ((u32)ammo == 0) { - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 100, 100, alpha); - } - - for (i = 0; ammo >= 10; i++) { - ammo -= 10; - } - - // Draw upper digit (tens) - if ((u32)i != 0) { - OVERLAY_DISP = GfxEx_DrawTexRectIA8(OVERLAY_DISP, ((u8*)gAmmoDigit0Tex + ((8 * 8) * i)), 8, 8, - D_801BFB04[button], D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - } - - // Draw lower digit (ones) - OVERLAY_DISP = GfxEx_DrawTexRectIA8(OVERLAY_DISP, ((u8*)gAmmoDigit0Tex + ((8 * 8) * ammo)), 8, 8, - D_801BFB04[button] + 6, D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10, G_EX_ORIGIN_RIGHT, Y_ORIGIN_TOP); - } - - CLOSE_DISPS(play->state.gfxCtx); -} - -// Modify magic meter drawing -extern u8 gMagicMeterEndTex[]; -extern u8 gMagicMeterFillTex[]; -extern u8 gMagicMeterMidTex[]; - -extern s16 sMagicMeterOutlinePrimBlue; -extern s16 sMagicMeterOutlinePrimGreen; -extern s16 sMagicMeterOutlinePrimRed; - -void Magic_DrawMeter(PlayState* play) { - InterfaceContext* interfaceCtx = &play->interfaceCtx; - s16 magicBarY; - - OPEN_DISPS(play->state.gfxCtx); - - if (gSaveContext.save.saveInfo.playerData.magicLevel != 0) { - if (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) { - magicBarY = 42; // two rows of hearts - } else { - magicBarY = 34; // one row of hearts - } - - Gfx_SetupDL39_Overlay(play->state.gfxCtx); - - gDPSetEnvColor(OVERLAY_DISP++, 100, 50, 50, 255); - - OVERLAY_DISP = GfxEx_DrawTexRectIA8_DropShadow( - OVERLAY_DISP, gMagicMeterEndTex, 8, 16, 18, magicBarY, 8, 16, 1 << 10, 1 << 10, sMagicMeterOutlinePrimRed, - sMagicMeterOutlinePrimGreen, sMagicMeterOutlinePrimBlue, interfaceCtx->magicAlpha, G_EX_ORIGIN_LEFT, Y_ORIGIN_TOP); - OVERLAY_DISP = GfxEx_DrawTexRectIA8_DropShadow(OVERLAY_DISP, gMagicMeterMidTex, 24, 16, 26, magicBarY, - ((void)0, gSaveContext.magicCapacity), 16, 1 << 10, 1 << 10, - sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, - sMagicMeterOutlinePrimBlue, interfaceCtx->magicAlpha, G_EX_ORIGIN_LEFT, Y_ORIGIN_TOP); - OVERLAY_DISP = GfxEx_DrawTexRectIA8_DropShadowOffset( - OVERLAY_DISP, gMagicMeterEndTex, 8, 16, ((void)0, gSaveContext.magicCapacity) + 26, magicBarY, 8, 16, - 1 << 10, 1 << 10, sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, sMagicMeterOutlinePrimBlue, - interfaceCtx->magicAlpha, 3, 0x100, G_EX_ORIGIN_LEFT, Y_ORIGIN_TOP); - - gDPPipeSync(OVERLAY_DISP++); - gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE, PRIMITIVE, - ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE); - gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); - - if (gSaveContext.magicState == MAGIC_STATE_METER_FLASH_2) { - // Yellow part of the meter indicating the amount of magic to be subtracted - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 250, 250, 0, interfaceCtx->magicAlpha); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 16, 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); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(26, G_EX_ORIGIN_LEFT) * 4, adjust_y(magicBarY + 3, Y_ORIGIN_TOP) << 2, - adjust_x(gSaveContext.save.saveInfo.playerData.magic + 26, G_EX_ORIGIN_LEFT) * 4, adjust_y(magicBarY + 10, Y_ORIGIN_TOP) << 2, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - - // Fill the rest of the meter with the normal magic color - gDPPipeSync(OVERLAY_DISP++); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - // Blue magic - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha); - } else { - // Green magic (default) - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 200, 0, interfaceCtx->magicAlpha); - } - - gEXTextureRectangle( - OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(26, G_EX_ORIGIN_LEFT) * 4, adjust_y(magicBarY + 3, Y_ORIGIN_TOP) << 2, - adjust_x(gSaveContext.save.saveInfo.playerData.magic - gSaveContext.magicToConsume + 26, G_EX_ORIGIN_LEFT) * 4, adjust_y(magicBarY + 10, Y_ORIGIN_TOP) << 2, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - } else { - // Fill the whole meter with the normal magic color - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - // Blue magic - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha); - } else { - // Green magic (default) - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 200, 0, interfaceCtx->magicAlpha); - } - - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 16, 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); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(26, G_EX_ORIGIN_LEFT) * 4, adjust_y(magicBarY + 3, Y_ORIGIN_TOP) << 2, - adjust_x(gSaveContext.save.saveInfo.playerData.magic + 26, G_EX_ORIGIN_LEFT) * 4, adjust_y(magicBarY + 10, Y_ORIGIN_TOP) << 2, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - } - } - - CLOSE_DISPS(play->state.gfxCtx); -} - -// Modify life meter drawing -extern u8 gHeartEmptyTex[]; -extern u8 gHeartFullTex[]; -extern u8 gHeartHalfTex[]; -extern u8 gHeartQuarterTex[]; -extern u8 gHeartShapeTex[]; -extern u8 gHeartThreeQuarterTex[]; - -static TexturePtr sHeartTextures[] = { - gHeartFullTex, gHeartQuarterTex, gHeartQuarterTex, gHeartQuarterTex, - gHeartQuarterTex, gHeartQuarterTex, gHeartHalfTex, gHeartHalfTex, - gHeartHalfTex, gHeartHalfTex, gHeartHalfTex, gHeartThreeQuarterTex, - gHeartThreeQuarterTex, gHeartThreeQuarterTex, gHeartThreeQuarterTex, gHeartThreeQuarterTex, -}; - -extern u8 gDefenseHeartEmptyTex[]; -extern u8 gDefenseHeartFullTex[]; -extern u8 gDefenseHeartHalfTex[]; -extern u8 gDefenseHeartQuarterTex[]; -extern u8 gDefenseHeartThreeQuarterTex[]; - -static TexturePtr sHeartDDTextures[] = { - gDefenseHeartFullTex, gDefenseHeartQuarterTex, gDefenseHeartQuarterTex, - gDefenseHeartQuarterTex, gDefenseHeartQuarterTex, gDefenseHeartQuarterTex, - gDefenseHeartHalfTex, gDefenseHeartHalfTex, gDefenseHeartHalfTex, - gDefenseHeartHalfTex, gDefenseHeartHalfTex, gDefenseHeartThreeQuarterTex, - gDefenseHeartThreeQuarterTex, gDefenseHeartThreeQuarterTex, gDefenseHeartThreeQuarterTex, - gDefenseHeartThreeQuarterTex, -}; - -extern s16 sBeatingHeartsDDPrim[3]; -extern s16 sBeatingHeartsDDEnv[3]; -extern s16 sHeartsDDPrim[2][3]; -extern s16 sHeartsDDEnv[2][3]; - -void LifeMeter_Draw(PlayState* play) { - s32 pad[5]; - TexturePtr heartTex; - s32 curColorSet; - f32 offsetX; - f32 offsetY; - s32 i; - f32 posY; - f32 posX; - f32 halfTexSize; - f32 temp_f4; - GraphicsContext* gfxCtx = play->state.gfxCtx; - InterfaceContext* interfaceCtx = &play->interfaceCtx; - Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; - s32 fractionHeartCount = gSaveContext.save.saveInfo.playerData.health % 0x10; - s16 healthCapacity = gSaveContext.save.saveInfo.playerData.healthCapacity / 0x10; - s16 fullHeartCount = gSaveContext.save.saveInfo.playerData.health / 0x10; - s32 pad2; - f32 lifesize = interfaceCtx->lifeSizeChange * 0.1f; - u32 curCombineModeSet = 0; - TexturePtr temp = NULL; - s32 ddCount = gSaveContext.save.saveInfo.inventory.defenseHearts - 1; - - OPEN_DISPS(gfxCtx); - - if ((gSaveContext.save.saveInfo.playerData.health % 0x10) == 0) { - fullHeartCount--; - } - - offsetY = 0.0f; - offsetX = 0.0f; - curColorSet = -1; - - for (i = 0; i < healthCapacity; i++) { - if ((ddCount < 0) || (ddCount < i)) { - if (i < fullHeartCount) { - if (curColorSet != 0) { - curColorSet = 0; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->heartsPrimR[0], interfaceCtx->heartsPrimG[0], - interfaceCtx->heartsPrimB[0], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->heartsEnvR[0], interfaceCtx->heartsEnvG[0], - interfaceCtx->heartsEnvB[0], 255); - } - } else if (i == fullHeartCount) { - if (curColorSet != 1) { - curColorSet = 1; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->beatingHeartPrim[0], - interfaceCtx->beatingHeartPrim[1], interfaceCtx->beatingHeartPrim[2], - interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->beatingHeartEnv[0], interfaceCtx->beatingHeartEnv[1], - interfaceCtx->beatingHeartEnv[2], 255); - } - } else if (fullHeartCount < i) { - if (curColorSet != 2) { - curColorSet = 2; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->heartsPrimR[0], interfaceCtx->heartsPrimG[0], - interfaceCtx->heartsPrimB[0], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->heartsEnvR[0], interfaceCtx->heartsEnvG[0], - interfaceCtx->heartsEnvB[0], 255); - } - } else { - if (curColorSet != 3) { - curColorSet = 3; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->heartsPrimR[1], interfaceCtx->heartsPrimG[1], - interfaceCtx->heartsPrimB[1], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->heartsEnvR[1], interfaceCtx->heartsEnvG[1], - interfaceCtx->heartsEnvB[1], 255); - } - } - - if (i < fullHeartCount) { - heartTex = gHeartFullTex; - } else if (i == fullHeartCount) { - heartTex = sHeartTextures[fractionHeartCount]; - } else { - heartTex = gHeartEmptyTex; - } - } else { - if (i < fullHeartCount) { - if (curColorSet != 4) { - curColorSet = 4; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0][0], sHeartsDDPrim[0][1], sHeartsDDPrim[0][2], - interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0][0], sHeartsDDEnv[0][1], sHeartsDDEnv[0][2], 255); - } - } else if (i == fullHeartCount) { - if (curColorSet != 5) { - curColorSet = 5; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sBeatingHeartsDDPrim[0], sBeatingHeartsDDPrim[1], - sBeatingHeartsDDPrim[2], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sBeatingHeartsDDEnv[0], sBeatingHeartsDDEnv[1], - sBeatingHeartsDDEnv[2], 255); - } - } else if (i > fullHeartCount) { - if (curColorSet != 6) { - curColorSet = 6; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0][0], sHeartsDDPrim[0][1], sHeartsDDPrim[0][2], - interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0][0], sHeartsDDEnv[0][1], sHeartsDDEnv[0][2], 255); - } - } else if (curColorSet != 7) { - curColorSet = 7; - gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[1][0], sHeartsDDPrim[1][1], sHeartsDDPrim[1][2], - interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[1][0], sHeartsDDEnv[1][1], sHeartsDDEnv[1][2], 255); - } - if (i < fullHeartCount) { - heartTex = gDefenseHeartFullTex; - } else if (i == fullHeartCount) { - heartTex = sHeartDDTextures[fractionHeartCount]; - } else { - heartTex = gDefenseHeartEmptyTex; - } - } - - if (temp != heartTex) { - temp = heartTex; - gDPLoadTextureBlock(OVERLAY_DISP++, heartTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 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); - } - - if (i != fullHeartCount) { - if ((ddCount < 0) || (i > ddCount)) { - if (curCombineModeSet != 1) { - curCombineModeSet = 1; - Gfx_SetupDL39_Overlay(gfxCtx); - gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, - 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - } - } else if (curCombineModeSet != 3) { - curCombineModeSet = 3; - Gfx_SetupDL39_Overlay(gfxCtx); - gDPSetCombineLERP(OVERLAY_DISP++, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, - ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - } - posY = 26.0f + offsetY; - posX = 30.0f + offsetX; - temp_f4 = 1.0f; - temp_f4 /= 0.68f; - temp_f4 *= 1 << 10; - halfTexSize = 8.0f; - halfTexSize *= 0.68f; - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(posX - halfTexSize, G_EX_ORIGIN_LEFT) * 4, adjust_y(posY - halfTexSize, Y_ORIGIN_TOP) * 4, - adjust_x(posX + halfTexSize, G_EX_ORIGIN_LEFT) * 4, adjust_y(posY + halfTexSize, Y_ORIGIN_TOP) * 4, - G_TX_RENDERTILE, 0, 0, (s32)temp_f4, (s32)temp_f4); - } else { - Mtx* mtx; - - if ((ddCount < 0) || (ddCount < i)) { - if (curCombineModeSet != 2) { - curCombineModeSet = 2; - Gfx_SetupDL42_Overlay(gfxCtx); - gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, - 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); - } - } else { - if (curCombineModeSet != 4) { - curCombineModeSet = 4; - Gfx_SetupDL42_Overlay(gfxCtx); - gDPSetCombineLERP(OVERLAY_DISP++, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, - 0, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); - } - } - mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - Vp* vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); - View_ViewportToVp(vp, &play->view.viewport); - - vp->vp.vtrans[0] = adjust_x_fractional(vp->vp.vtrans[0], G_EX_ORIGIN_LEFT); - vp->vp.vtrans[1] = adjust_y_fractional(vp->vp.vtrans[1], Y_ORIGIN_TOP); - - gEXViewport(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, vp); - - Mtx_SetTranslateScaleMtx(mtx, 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), - 1.0f - (0.32f * lifesize), -130.0f + offsetX, 94.5f - offsetY, 0.0f); - gSPMatrix(OVERLAY_DISP++, mtx, G_MTX_LOAD | G_MTX_MODELVIEW); - gSPVertex(OVERLAY_DISP++, beatingHeartVtx, 4, 0); - gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); - - // Restore the old viewport - Vp* old_vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); - View_ViewportToVp(old_vp, &play->view.viewport); - gSPViewport(OVERLAY_DISP++, old_vp); - } - - offsetX += 10.0f; - if (i == 9) { - offsetY += 10.0f; - offsetX = 0.0f; - } - } - CLOSE_DISPS(gfxCtx); -} // Modify interface drawing (rupees, key counter, etc.) extern TexturePtr sStoryTextures[]; @@ -1091,15 +89,18 @@ static Gfx sScreenFillSetupDL[] = { gsSPEndDisplayList(), }; +void Interface_DrawAButton(PlayState* play); void Interface_DrawBButtonIcons(PlayState* play); void Interface_DrawCButtonIcons(PlayState* play); void Interface_DrawClock(PlayState* play); +void Interface_DrawItemButtons(PlayState* play); void Interface_DrawMinigameIcons(PlayState* play); void Interface_DrawPauseMenuEquippingIcons(PlayState* play); void Interface_DrawPerfectLetters(PlayState* play); void Interface_DrawTimers(PlayState* play); void Interface_SetOrthoView(InterfaceContext* interfaceCtx); void Interface_SetVertices(PlayState* play); +void Magic_DrawMeter(PlayState* play); void Interface_Draw(PlayState* play) { s32 pad; @@ -1124,6 +125,8 @@ void Interface_Draw(PlayState* play) { if (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) { Interface_SetVertices(play); + // @recomp Adjust any scissors to cover the whole screen + gEXSetScissorAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_RIGHT, 0, -margin_reduction, -SCREEN_WIDTH, margin_reduction); Interface_SetOrthoView(interfaceCtx); // Draw Grandma's Story @@ -1152,11 +155,19 @@ void Interface_Draw(PlayState* play) { gDPFillRectangle(OVERLAY_DISP++, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } - gEXSetScissor(OVERLAY_DISP++, G_SC_NON_INTERLACE, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_RIGHT, 0, 0, 0, SCREEN_HEIGHT); + // @recomp Left align and shift left/up for life meter + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, -margin_reduction * 4, -margin_reduction * 4); + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, -margin_reduction * 4, -margin_reduction * 4, -margin_reduction * 4, -margin_reduction * 4); + Interface_SetOrthoView(interfaceCtx); + LifeMeter_Draw(play); Gfx_SetupDL39_Overlay(play->state.gfxCtx); + // @recomp Left align and shift left/down for key count, skulltula count, and rupee count + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, -margin_reduction * 4, margin_reduction * 4); + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, -margin_reduction * 4, margin_reduction * 4, -margin_reduction * 4, margin_reduction * 4); + // Draw Rupee Icon gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sRupeeCounterIconPrimColors[CUR_UPG_VALUE(UPG_WALLET)].r, sRupeeCounterIconPrimColors[CUR_UPG_VALUE(UPG_WALLET)].g, @@ -1165,7 +176,7 @@ void Interface_Draw(PlayState* play) { sRupeeCounterIconEnvColors[CUR_UPG_VALUE(UPG_WALLET)].g, sRupeeCounterIconEnvColors[CUR_UPG_VALUE(UPG_WALLET)].b, 255); OVERLAY_DISP = - GfxEx_DrawTexRectIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, 26, 206, 16, 16, 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + Gfx_DrawTexRectIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, 26, 206, 16, 16, 1 << 10, 1 << 10); switch (play->sceneId) { case SCENE_INISIE_N: @@ -1178,8 +189,8 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 230, 255, interfaceCtx->magicAlpha); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 20, 255); - OVERLAY_DISP = GfxEx_DrawTexRectIA8(OVERLAY_DISP, gSmallKeyCounterIconTex, 16, 16, 26, 190, 16, 16, - 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gSmallKeyCounterIconTex, 16, 16, 26, 190, 16, 16, + 1 << 10, 1 << 10); // Small Key Counter gDPPipeSync(OVERLAY_DISP++); @@ -1201,15 +212,13 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); OVERLAY_DISP = - GfxEx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[2]), 8, 16, - 43, 191, 8, 16, 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[2]), 8, 16, + 43, 191, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(42, G_EX_ORIGIN_LEFT) * 4, adjust_y(190, Y_ORIGIN_BOTTOM) * 4, - adjust_x(50, G_EX_ORIGIN_LEFT) * 4, adjust_y(206, Y_ORIGIN_BOTTOM) * 4, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, 168, 760, 200, 824, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); sp2CA += 8; } @@ -1217,15 +226,13 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); - OVERLAY_DISP = GfxEx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[3]), - 8, 16, sp2CA + 1, 191, 8, 16, 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[3]), + 8, 16, sp2CA + 1, 191, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(sp2CA, G_EX_ORIGIN_LEFT) * 4, adjust_y(190, Y_ORIGIN_BOTTOM) * 4, - adjust_x(sp2CA + 8, G_EX_ORIGIN_LEFT) * 4, adjust_y(206, Y_ORIGIN_BOTTOM) * 4, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 760, (sp2CA * 4) + 0x20, 824, G_TX_RENDERTILE, 0, 0, + 1 << 10, 1 << 10); } break; @@ -1239,10 +246,7 @@ void Interface_Draw(PlayState* play) { gDPLoadTextureBlock(OVERLAY_DISP++, gGoldSkulltulaCounterIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 24, 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); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(20, G_EX_ORIGIN_LEFT), adjust_y(187, Y_ORIGIN_BOTTOM) * 4, - adjust_x(44, G_EX_ORIGIN_LEFT), adjust_y(205, Y_ORIGIN_BOTTOM) * 4, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, 80, 748, 176, 820, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); // Gold Skulluta Counter gDPPipeSync(OVERLAY_DISP++); @@ -1263,15 +267,12 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); - OVERLAY_DISP = GfxEx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[2]), - 8, 16, 43, 191, 8, 16, 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[2]), + 8, 16, 43, 191, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(42, G_EX_ORIGIN_LEFT), adjust_y(190, Y_ORIGIN_BOTTOM) * 4, - adjust_x(50, G_EX_ORIGIN_LEFT), adjust_y(206, Y_ORIGIN_BOTTOM) * 4, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, 168, 760, 200, 824, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); sp2CA += 8; } @@ -1279,15 +280,13 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); - OVERLAY_DISP = GfxEx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[3]), 8, - 16, sp2CA + 1, 191, 8, 16, 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[3]), 8, + 16, sp2CA + 1, 191, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(sp2CA, G_EX_ORIGIN_LEFT) * 4, adjust_y(190, Y_ORIGIN_BOTTOM) * 4, - adjust_x(sp2CA + 8, G_EX_ORIGIN_LEFT) * 4, adjust_y(206, Y_ORIGIN_BOTTOM) * 4, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 760, (sp2CA * 4) + 0x20, 824, G_TX_RENDERTILE, 0, 0, + 1 << 10, 1 << 10); break; default: @@ -1328,8 +327,8 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, magicAlpha); - OVERLAY_DISP = GfxEx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[sp2CC]), 8, - 16, sp2CA + 1, 207, 8, 16, 1 << 10, 1 << 10, G_EX_ORIGIN_LEFT, Y_ORIGIN_BOTTOM); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[sp2CC]), 8, + 16, sp2CA + 1, 207, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); @@ -1341,19 +340,41 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 100, 100, interfaceCtx->magicAlpha); } - gEXTextureRectangle(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, - adjust_x(sp2CA, G_EX_ORIGIN_LEFT) * 4, adjust_y(206, Y_ORIGIN_BOTTOM) * 4, - adjust_x(sp2CA + 8, G_EX_ORIGIN_LEFT) * 4, adjust_y(222, Y_ORIGIN_BOTTOM) * 4, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 824, (sp2CA * 4) + 0x20, 888, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); } + // @recomp Left align and shift left/up for magic meter + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, -margin_reduction * 4, -margin_reduction * 4); + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, -margin_reduction * 4, -margin_reduction * 4, -margin_reduction * 4, -margin_reduction * 4); + Magic_DrawMeter(play); + + // @recomp Right align and shift right/down for minimap + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, G_EX_ORIGIN_RIGHT, + -(SCREEN_WIDTH - margin_reduction) * 4, margin_reduction * 4, + -(SCREEN_WIDTH - margin_reduction) * 4, margin_reduction * 4); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, -(SCREEN_WIDTH - margin_reduction) * 4, margin_reduction * 4); + Interface_SetOrthoView(interfaceCtx); + Minimap_Draw(play); + // @recomp Reset viewport alignment for drawing the target reticle + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, 0, 0, 0); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, 0, 0); + Interface_SetOrthoView(interfaceCtx); + if ((R_PAUSE_BG_PRERENDER_STATE != 2) && (R_PAUSE_BG_PRERENDER_STATE != 3)) { Target_Draw(&play->actorCtx.targetCtx, play); } + // @recomp Right align and shift right/up for equipped items and buttons + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, G_EX_ORIGIN_RIGHT, + -(SCREEN_WIDTH - margin_reduction) * 4, -margin_reduction * 4, + -(SCREEN_WIDTH - margin_reduction) * 4, -margin_reduction * 4); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_RIGHT, -(SCREEN_WIDTH - margin_reduction) * 4, -margin_reduction * 4); + Interface_SetOrthoView(interfaceCtx); + Gfx_SetupDL39_Overlay(play->state.gfxCtx); Interface_DrawItemButtons(play); @@ -1373,6 +394,10 @@ void Interface_Draw(PlayState* play) { (interfaceCtx->minigameState < MINIGAME_STATE_NO_COUNTDOWN_SETUP)) { // Minigame Countdown if (((u32)interfaceCtx->minigameState % 2) == 0) { + // @recomp Restore normal alignment and reset shift for minigame countdown + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, 0, 0, 0); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, 0, 0); + Interface_SetOrthoView(interfaceCtx); sp2CE = (interfaceCtx->minigameState >> 1) - 1; minigameCountdownScale = interfaceCtx->minigameCountdownScale / 100.0f; @@ -1405,17 +430,45 @@ void Interface_Draw(PlayState* play) { sMinigameCountdownTexWidths[sp2CE], 32, 0); } } else { + // @recomp Use normal alignment and shift down for clock + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, margin_reduction * 4, 0, margin_reduction * 4); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, 0, margin_reduction * 4); + Interface_SetOrthoView(interfaceCtx); + Interface_DrawClock(play); } } + + // @recomp Restore normal alignment and reset shift for minigame "Perfect" text + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, 0, 0, 0); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, 0, 0); + Interface_SetOrthoView(interfaceCtx); // Draw the letters of minigame perfect if (interfaceCtx->perfectLettersOn) { Interface_DrawPerfectLetters(play); } + // @recomp If carrots are being drawn, use default alignment and shift up + if (interfaceCtx->unk_212 == DO_ACTION_FASTER) { + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, -margin_reduction * 4, 0, -margin_reduction * 4); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, 0, -margin_reduction * 4); + } + // @recomp Otherwise align left and shift up + else { + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, G_EX_ORIGIN_LEFT, 0, -margin_reduction * 4, 0, -margin_reduction * 4); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_LEFT, 0, -margin_reduction * 4); + } + Interface_SetOrthoView(interfaceCtx); + Interface_DrawMinigameIcons(play); Interface_DrawTimers(play); + + // @recomp Restore normal alignment and shift down for minigame countdown or clock + gEXSetRectAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, 0, 0, 0); + gEXSetViewportAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, 0, 0); + gEXSetScissorAlign(OVERLAY_DISP++, G_EX_ORIGIN_NONE, G_EX_ORIGIN_NONE, 0, 0, 0, 0); + Interface_SetOrthoView(interfaceCtx); } // Draw pictograph focus icons @@ -1521,4 +574,4 @@ void Interface_Draw(PlayState* play) { } CLOSE_DISPS(play->state.gfxCtx); -} \ No newline at end of file +}