summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorChristopher Leggett <chris@leggett.dev>2023-05-03 23:00:45 -0400
committerGitHub <noreply@github.com>2023-05-03 23:00:45 -0400
commit071a2d0418d6fb7464a1ddccd2b647683da38eff (patch)
treec433e99bdf8e8b398a0c0a1eb2a07bcc5dd61cc0 /soh/src/code
parent3f896f126ff7f36dff8afc2459104ff1adab548b (diff)
parentc02dcb598ad6132b4aa5a44aec64a80cea3da269 (diff)
Merge pull request #2826 from HarbourMasters/develop-spock
Spock -> Develop
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/gfxprint.c34
-rw-r--r--soh/src/code/z_parameter.c4
-rw-r--r--soh/src/code/z_scene_table.c34
3 files changed, 47 insertions, 25 deletions
diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c
index f7aa20a76..8637e86d5 100644
--- a/soh/src/code/gfxprint.c
+++ b/soh/src/code/gfxprint.c
@@ -128,7 +128,25 @@ u8 sGfxPrintFontData[(16 * 256) / 2] = {
// Can be used to set GFXP_FLAG_ENLARGE by default
static u8 sDefaultSpecialFlags;
-static const char rGfxPrintFontData[] = "__OTR__alt/textures/font/sGfxPrintFontData";
+static const char rGfxPrintFontData[] = "__OTR__textures/font/sGfxPrintFontData";
+static const char rGfxPrintFontDataAlt[] = "__OTR__alt/textures/font/sGfxPrintFontData";
+
+// OTRTODO: this isn't as clean as it could be if we implemented
+// the GfxPrint texture extraction to `.otr` as described in
+// https://github.com/HarbourMasters/Shipwright/issues/2762
+typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t;
+font_texture_t GfxPrint_TextureToUse() {
+ if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) {
+ // If we have alt assets enabled, and we have alt prefixed font texture, use that
+ return otrAlt;
+ } else if (ResourceMgr_FileExists(rGfxPrintFontData)) {
+ // if we have a non alt prefixed font texture, use that
+ return otrDefault;
+ }
+
+ // default to hardcoded font
+ return hardcoded;
+}
void GfxPrint_Setup(GfxPrint* this) {
s32 width = 16;
@@ -142,19 +160,22 @@ void GfxPrint_Setup(GfxPrint* this) {
G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2);
gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA);
- bool useAltTexture = ResourceMgr_FileExists(rGfxPrintFontData) && CVarGetInteger("gAltAssets", 0);
- if (!useAltTexture) {
+
+
+ if (GfxPrint_TextureToUse() == hardcoded) {
gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, 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);
} else {
- gDPLoadTextureBlock_4b(this->dList++, rGfxPrintFontData, G_IM_FMT_CI, width * 4, height, 0, G_TX_NOMIRROR | G_TX_WRAP,
+ gDPLoadTextureBlock_4b(this->dList++,
+ GfxPrint_TextureToUse() == otrAlt ? rGfxPrintFontDataAlt : rGfxPrintFontData,
+ G_IM_FMT_CI, width * 4, 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);
}
gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT);
for (i = 1; i < 4; i++) {
- if (useAltTexture) {
+ if (GfxPrint_TextureToUse() != hardcoded) {
gDPSetTile(this->dList++, G_IM_FMT_RGBA, G_IM_SIZ_4b, 1, 0, i * 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
} else {
@@ -204,7 +225,6 @@ void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) {
void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
u32 tile = (c & 0xFF) * 2;
u8 offset = ((c * 2) & 0x7) / 2;
- u8 useAltTexture = ResourceMgr_FileExists(rGfxPrintFontData) && CVarGetInteger("gAltAssets", 0);
if (this->flags & GFXP_FLAG_UPDATE) {
this->flags &= ~GFXP_FLAG_UPDATE;
@@ -243,7 +263,7 @@ void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
(this->posY + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9, 1 << 9);
} else {
gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32,
- useAltTexture ? 0 : tile, (useAltTexture ? ((128 * 4) * offset) : 0) + (u16)((c & 4) * 64),
+ GfxPrint_TextureToUse() != hardcoded ? 0 : tile, (GfxPrint_TextureToUse() != hardcoded ? ((128 * 4) * offset) : 0) + (u16)((c & 4) * 64),
(u16)(c >> 3) * 256, 1 << 10, 1 << 10);
}
diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c
index 8198caebf..954ce1190 100644
--- a/soh/src/code/z_parameter.c
+++ b/soh/src/code/z_parameter.c
@@ -3,6 +3,7 @@
#include "textures/parameter_static/parameter_static.h"
#include "textures/do_action_static/do_action_static.h"
#include "textures/icon_item_static/icon_item_static.h"
+#include "soh_assets.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
#include "soh/Enhancements/randomizer/randomizer_entrance.h"
#include "libultraship/bridge.h"
@@ -2270,6 +2271,7 @@ u8 Item_Give(PlayState* play, u8 item) {
}
gSaveContext.inventory.items[temp + i] = item;
+ break;
}
}
} else {
@@ -5219,7 +5221,7 @@ void Interface_Draw(PlayState* play) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, dPadColor.r, dPadColor.g, dPadColor.b, dpadAlpha);
if (fullUi) {
- gDPLoadTextureBlock(OVERLAY_DISP++, "__OTR__textures/parameter_static/gDPad",
+ gDPLoadTextureBlock(OVERLAY_DISP++, gDPadTex,
G_IM_FMT_IA, G_IM_SIZ_16b, 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);
gSPWideTextureRectangle(OVERLAY_DISP++, DpadPosX << 2, DpadPosY << 2,
diff --git a/soh/src/code/z_scene_table.c b/soh/src/code/z_scene_table.c
index 33e58dbd0..9e4f845f5 100644
--- a/soh/src/code/z_scene_table.c
+++ b/soh/src/code/z_scene_table.c
@@ -1006,7 +1006,7 @@ void func_800995DC(PlayState* play) {
{ s32 pad; }
- gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8[gSaveContext.nightFlag]));
CLOSE_DISPS(play->state.gfxCtx);
}
@@ -1046,8 +1046,8 @@ void func_80099878(PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
gameplayFrames = play->gameplayFrames;
- gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures[gSaveContext.nightFlag]));
- gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sDCLavaFloorTextures[(s32)(gameplayFrames & 14) >> 1]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sDCLavaFloorTextures[(s32)(gameplayFrames & 14) >> 1]));
gSPSegment(POLY_XLU_DISP++, 0x09,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 0, 64, 32, 1, 0,
(gameplayFrames * 1) % 128, 64, 32));
@@ -1301,7 +1301,7 @@ void func_8009AFE0(PlayState* play) {
{ s32 pad[2]; }
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures[gSaveContext.nightFlag]));
CLOSE_DISPS(play->state.gfxCtx);
}
@@ -1323,7 +1323,7 @@ void func_8009B0FC(PlayState* play) {
spAC = play->roomCtx.unk_74[1] & 0xFF;
gameplayFrames = play->gameplayFrames;
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A330[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A330[gSaveContext.nightFlag]));
if (spB0 == 1) {
gSPSegment(POLY_OPA_DISP++, 0x08,
@@ -1548,7 +1548,7 @@ void func_8009C3EC(PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
gameplayFrames = play->gameplayFrames;
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures[gSaveContext.nightFlag]));
gSPSegment(POLY_OPA_DISP++, 0x09,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32,
32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32));
@@ -1650,7 +1650,7 @@ void func_8009CC00(PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
gameplayFrames = play->gameplayFrames;
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures[gSaveContext.nightFlag]));
gSPSegment(POLY_OPA_DISP++, 0x09,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32,
32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32));
@@ -1746,7 +1746,7 @@ void func_8009D31C(PlayState* play) {
{ s32 pad[2]; }
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonHouseEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonHouseEntranceTextures[gSaveContext.nightFlag]));
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
@@ -1778,8 +1778,8 @@ void func_8009D438(PlayState* play) {
var = gSaveContext.nightFlag;
}
- gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGuardHouseView1Textures[var]));
- gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sGuardHouseView2Textures[var]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGuardHouseView1Textures[var]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sGuardHouseView2Textures[var]));
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
@@ -1823,7 +1823,7 @@ void func_8009D758(PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
gameplayFrames = play->gameplayFrames;
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures[gSaveContext.nightFlag]));
gSPSegment(POLY_XLU_DISP++, 0x09,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32,
32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32));
@@ -1853,7 +1853,7 @@ void func_8009D974(PlayState* play) {
{ s32 pad[2]; }
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures[gSaveContext.nightFlag]));
CLOSE_DISPS(play->state.gfxCtx);
}
@@ -1915,7 +1915,7 @@ void func_8009DD5C(PlayState* play) {
{ s32 pad[2]; }
- gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sKakarikoWindowTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sKakarikoWindowTextures[gSaveContext.nightFlag]));
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
@@ -2051,7 +2051,7 @@ void func_8009E730(PlayState* play) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZorasDomainEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZorasDomainEntranceTextures[gSaveContext.nightFlag]));
{ s32 pad[2]; }
@@ -2183,7 +2183,7 @@ void func_8009F1B4(PlayState* play) {
{ s32 pad[2]; }
- gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380[gSaveContext.nightFlag]));
CLOSE_DISPS(play->state.gfxCtx);
}
@@ -2316,7 +2316,7 @@ void func_8009F9D0(PlayState* play) {
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);
- gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronCityEntranceTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronCityEntranceTextures[gSaveContext.nightFlag]));
{ s32 pad[2]; }
@@ -2334,7 +2334,7 @@ void func_8009FB74(PlayState* play) {
{ s32 pad[2]; }
- gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonRanchWindowTextures[gSaveContext.nightFlag]));
+ gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonRanchWindowTextures[gSaveContext.nightFlag]));
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);