New Inventory Editor (#107)

* inventory editor

* fixed a bug where the menu was usable in special pause screens

* fixed most equipment screen issues

* draw page number on upgrade screen and minor improvements

* format

* fix build issues

* format

* fix build issues

* format

* various improvements

* fix build issues with non-debug

* small cleanup

* last improvements and bugfixes + cleanup and format
This commit is contained in:
Yanis
2025-11-04 17:23:27 +01:00
committed by GitHub
parent 90ca9c6ff9
commit af3dc71a5c
28 changed files with 1825 additions and 176 deletions

View File

@@ -72,7 +72,7 @@
/**** [INVENTORY EDITOR] ****/
// ``IS_INV_EDITOR_ENABLED``
#define ENABLE_INV_EDITOR false
#define ENABLE_INV_EDITOR true
/**** [EVENT EDITOR] ****/
// ``IS_EVENT_EDITOR_ENABLED``

View File

@@ -6,6 +6,7 @@
#include "padmgr.h"
#include "debug/print.h"
#include "debug/collision_view.h"
#include "debug/inventory_editor.h"
#include "debug/menu.h"
#include "debug/profiler.h"
#include "z_math.h"
@@ -19,11 +20,14 @@
#define COLOR_BLUE2 (0x0080FF)
#define COLOR_BLUE3 (0x00BFFF)
#define IS_INV_EDITOR_ACTIVE (IS_INV_EDITOR_ENABLED && gDebug.invDebug.state != INVEDITOR_STATE_OFF)
typedef struct Debug {
struct PlayState* play;
Input* input;
PrintUtils printer;
Menu menu;
InventoryEditor invDebug;
} Debug;
void Debug_DrawColorRectangle(Vec2s rectLeft, Vec2s rectRight, Color_RGBA8 rgba);

View File

@@ -0,0 +1,207 @@
#ifndef INVENTORY_EDITOR_H
#define INVENTORY_EDITOR_H
#include "config.h"
#include "pause.h"
typedef enum InvEditorMagicState {
INVEDITOR_MAGIC_STATE_NONE,
INVEDITOR_MAGIC_STATE_NORMAL,
INVEDITOR_MAGIC_STATE_DOUBLE,
} InvEditorMagicState;
typedef enum InvEditorInfosMiscTransState {
INVEDITOR_TRANS_STATE_DONE,
INVEDITOR_TRANS_STATE_INFO_REQUESTED,
INVEDITOR_TRANS_STATE_INFO_SWITCHING,
INVEDITOR_TRANS_STATE_MISC_REQUESTED,
INVEDITOR_TRANS_STATE_MISC_SWITCHING,
} InvEditorInfosMiscTransState;
typedef enum InvEditorCursorPos {
INVEDITOR_CURSOR_POS_MIN = -1,
INVEDITOR_CURSOR_POS_HEARTS,
INVEDITOR_CURSOR_POS_MAGIC,
INVEDITOR_CURSOR_POS_RUPEES,
INVEDITOR_CURSOR_POS_SMALL_KEYS,
INVEDITOR_CURSOR_POS_BOSS_KEY,
INVEDITOR_CURSOR_POS_COMPASS,
INVEDITOR_CURSOR_POS_MAP,
INVEDITOR_CURSOR_POS_MAX
} InvEditorCursorPos;
typedef enum InvEditorTitleState {
INVEDITOR_TITLE_STATE_MIN = -1,
INVEDITOR_TITLE_STATE_NAME,
INVEDITOR_TITLE_STATE_COMMANDS,
INVEDITOR_TITLE_STATE_MISCDBG
} InvEditorTitleState;
typedef enum InvEditorCommonState {
INVEDITOR_COMMON_STATE_MIN = -1,
INVEDITOR_COMMON_STATE_UNREADY,
INVEDITOR_COMMON_STATE_READY
} InvEditorCommonState;
typedef enum InvEditorState {
INVEDITOR_STATE_MIN = -1,
INVEDITOR_STATE_OFF,
INVEDITOR_STATE_INIT,
INVEDITOR_STATE_UPDATE,
INVEDITOR_STATE_DESTROY
} InvEditorState;
typedef struct InventoryEditorCommon {
InvEditorCommonState state;
u8 selectedItem;
u8 selectedSlot;
s8 changeBy;
} InvEditorCommon;
typedef struct InvEditorItems {
u8 childTradeItem;
u8 adultTradeItem;
u8 hookshotType;
u8 ocarinaType;
u8 bottleItems[4];
} InvEditorItems;
typedef struct InvEditorEquipment {
u8 showMiscUpgrades;
u8 upgradeSlots[8];
u8 upgradeValues[8];
u8 bgsFlag;
u16 swordHealth;
} InvEditorEquipment;
typedef struct InvEditorMisc {
u8 showMiscScreen;
u8 stickMoved;
u8 updateDefenseHearts;
InvEditorCursorPos hudCursorPos;
s8 hudDungeonIconIndex;
s16 hudTopPosY;
s16 hudBottomPosY;
s16 invertVal;
s16 mapIndex;
} InvEditorMisc;
struct GraphicsContext;
typedef struct InventoryEditor {
InvEditorState state;
GraphicsContext* gfxCtx;
PauseContext* pauseCtx;
InvEditorCommon common;
InvEditorItems itemDebug;
InvEditorEquipment equipDebug;
InvEditorMisc miscDebug;
u8 titleTimer;
InvEditorTitleState titleState;
s16 titlePosY;
s16 backgroundPosY;
u8 showInfoScreen;
s16 elementsAlpha;
s16 miscElementsAlpha;
} InventoryEditor;
Gfx* Gfx_TextureIA8(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop,
s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy);
u8 InventoryEditor_GetUpgradeType(u16 slotIndex);
void InventoryEditor_SetItemFromSlot(InventoryEditor* this);
void InventoryEditor_SetHUDAlpha(InventoryEditor* this);
void InventoryEditor_UpdateMiscScreen(InventoryEditor* this);
void InventoryEditor_UpdateQuestScreen(InventoryEditor* this);
void InventoryEditor_UpdateEquipmentScreen(InventoryEditor* this);
void InventoryEditor_UpdateItemScreen(InventoryEditor* this);
void InventoryEditor_UpdateInformationScreen(InventoryEditor* this);
void InventoryEditor_DrawRectangle(InventoryEditor* this, s32 leftX, s32 leftY, s32 rightX, s32 rightY,
Color_RGBA8 rgba);
void InventoryEditor_DrawMiscScreen(InventoryEditor* this);
void InventoryEditor_DrawEquipmentUpgrades(InventoryEditor* this, u16 i, s16 alpha);
void InventoryEditor_DrawInformationScreen(InventoryEditor* this);
void InventoryEditor_Init(InventoryEditor* this);
void InventoryEditor_Update(InventoryEditor* this);
void InventoryEditor_Draw(InventoryEditor* this);
bool InventoryEditor_Destroy(InventoryEditor* this);
void InventoryEditor_Main(InventoryEditor* this);
#define IS_IN_RANGE(val, min, max) ((val >= min) && (val <= max))
#define TIMER_DECR(val, target, changeBy) \
(((val - changeBy) < target) ? target : (val > target) ? (val - changeBy) : val)
#define TIMER_INCR(val, target, changeBy) \
(((val + changeBy) > target) ? target : (val < target) ? (val + changeBy) : val)
// General
#define INVEDITOR_PRINT_NEWLINE "\n "
#define INVEDITOR_ANIM_BASE_SPEED 16
#define INVEDITOR_BG_ANIM_SPEED INVEDITOR_ANIM_BASE_SPEED
#define INVEDITOR_BG_YPOS_TARGET 0
#define INVEDITOR_BG_YPOS 220
#define INVEDITOR_TITLE_TIMER 70 // frames
#define INVEDITOR_TITLE_ANIM_SPEED (INVEDITOR_ANIM_BASE_SPEED / 8)
#define INVEDITOR_TITLE_YPOS_TARGET 2
#define INVEDITOR_TITLE_YPOS 28
#define INVEDITOR_ALPHA_TRANS_SPEED (INVEDITOR_ANIM_BASE_SPEED * 2)
// Items
#define INVEDITOR_GET_BOTTLE_ITEM(invDebug) \
(IS_IN_RANGE((invDebug)->common.selectedSlot, SLOT_BOTTLE_1, SLOT_BOTTLE_4) \
? (invDebug)->itemDebug.bottleItems[(invDebug)->common.selectedSlot - SLOT_BOTTLE_1] \
: ITEM_NONE)
#define INVEDITOR_GET_CHILD_TRADE_ITEM(invDebug) \
(((invDebug)->common.selectedSlot == SLOT_TRADE_CHILD) ? (invDebug)->itemDebug.childTradeItem : ITEM_NONE)
#define INVEDITOR_GET_ADULT_TRADE_ITEM(invDebug) \
(((invDebug)->common.selectedSlot == SLOT_TRADE_ADULT) ? (invDebug)->itemDebug.adultTradeItem : ITEM_NONE)
#define INVEDITOR_GET_HOOKSHOT(invDebug) \
(((invDebug)->common.selectedSlot == SLOT_HOOKSHOT) ? (invDebug)->itemDebug.hookshotType : ITEM_NONE)
#define INVEDITOR_GET_OCARINA(invDebug) \
(((invDebug)->common.selectedSlot == SLOT_OCARINA) ? (invDebug)->itemDebug.ocarinaType : ITEM_NONE)
#define INVEDITOR_GET_VARIABLE_ITEM(invDebug) \
((INVEDITOR_GET_BOTTLE_ITEM(invDebug) != ITEM_NONE) ? INVEDITOR_GET_BOTTLE_ITEM(invDebug) \
: (INVEDITOR_GET_CHILD_TRADE_ITEM(invDebug) != ITEM_NONE) ? INVEDITOR_GET_CHILD_TRADE_ITEM(invDebug) \
: (INVEDITOR_GET_ADULT_TRADE_ITEM(invDebug) != ITEM_NONE) ? INVEDITOR_GET_ADULT_TRADE_ITEM(invDebug) \
: (INVEDITOR_GET_HOOKSHOT(invDebug) != ITEM_NONE) ? INVEDITOR_GET_HOOKSHOT(invDebug) \
: (INVEDITOR_GET_OCARINA(invDebug) != ITEM_NONE) ? INVEDITOR_GET_OCARINA(invDebug) \
: ITEM_NONE)
#define INVEDITOR_UPDATE_ITEM(invDbgCommon, min, max) \
{ \
if (IS_IN_RANGE(invDbgCommon.selectedItem, min, max)) { \
gSaveContext.save.info.inventory.items[invDbgCommon.selectedSlot] += invDbgCommon.changeBy; \
if (gSaveContext.save.info.inventory.items[invDbgCommon.selectedSlot] > max) { \
gSaveContext.save.info.inventory.items[invDbgCommon.selectedSlot] = min; \
} \
\
if (gSaveContext.save.info.inventory.items[invDbgCommon.selectedSlot] < min) { \
gSaveContext.save.info.inventory.items[invDbgCommon.selectedSlot] = max; \
} \
} \
}
// Equipment
#define INVEDITOR_IS_UPGRADE(invDbgCommon) \
(((invDbgCommon).selectedSlot == SLOT_UPG_QUIVER) || ((invDbgCommon).selectedSlot == SLOT_UPG_BOMB_BAG) || \
((invDbgCommon).selectedSlot == SLOT_UPG_STRENGTH) || ((invDbgCommon).selectedSlot == SLOT_UPG_SCALE))
// Misc
#define INVEDITOR_HUD_TOP_ANIM_SPEED INVEDITOR_ANIM_BASE_SPEED / 5
#define INVEDITOR_HUD_TOP_YPOS_TARGET 35
#define INVEDITOR_HUD_TOP_YPOS 0
#define INVEDITOR_HUD_BOTTOM_ANIM_SPEED INVEDITOR_ANIM_BASE_SPEED / 2
#define INVEDITOR_HUD_BOTTOM_YPOS_TARGET 100
#define INVEDITOR_HUD_BOTTOM_YPOS 0
#define INVEDITOR_HUD_BOTTOM_INVERT_SPEED INVEDITOR_ANIM_BASE_SPEED / 16
#define INVEDITOR_HUD_BOTTOM_INVERT_TARGET 16
#endif

View File

@@ -105,6 +105,11 @@ Gfx* Gfx_SetupDL_39(Gfx* gfx);
void Gfx_SetupDL_39Opa(struct GraphicsContext* gfxCtx);
void Gfx_SetupDL_39Overlay(struct GraphicsContext* gfxCtx);
void Gfx_SetupDL_39Ptr(Gfx** gfxP);
#if DEBUG_FEATURES
void Gfx_SetupDL_39Debug(struct GraphicsContext* gfxCtx);
#endif
void Gfx_SetupDL_40Opa(struct GraphicsContext* gfxCtx);
void Gfx_SetupDL_41Opa(struct GraphicsContext* gfxCtx);
void Gfx_SetupDL_47Xlu(struct GraphicsContext* gfxCtx);

View File

@@ -151,6 +151,25 @@ typedef enum InventorySlot {
/* 0xFF */ SLOT_NONE = 0xFF
} InventorySlot;
typedef enum EquipmentSlot {
/* 0x00 */ SLOT_UPG_QUIVER, // also bullet bag slot
/* 0x01 */ SLOT_SWORD_KOKIRI,
/* 0x02 */ SLOT_SWORD_MASTER,
/* 0x03 */ SLOT_SWORD_BIGGORON,
/* 0x04 */ SLOT_UPG_BOMB_BAG, // also deku stick capacity slot (inventory editor only)
/* 0x05 */ SLOT_SHIELD_DEKU,
/* 0x06 */ SLOT_SHIELD_HYLIAN,
/* 0x07 */ SLOT_SHIELD_MIRROR,
/* 0x08 */ SLOT_UPG_STRENGTH, // also deku nut capacity slot (inventory editor only)
/* 0x09 */ SLOT_TUNIC_KOKIRI,
/* 0x0A */ SLOT_TUNIC_GORON,
/* 0x0B */ SLOT_TUNIC_ZORA,
/* 0x0C */ SLOT_UPG_SCALE, // also wallet capacity slot (inventory editor only)
/* 0x0D */ SLOT_BOOTS_KOKIRI,
/* 0x0E */ SLOT_BOOTS_IRON,
/* 0x0F */ SLOT_BOOTS_HOVER
} EquipmentSlot;
typedef enum ItemID {
/* 0x00 */ ITEM_DEKU_STICK,
/* 0x01 */ ITEM_DEKU_NUT,

View File

@@ -93,7 +93,7 @@ typedef enum PauseDebugState {
#if IS_INV_EDITOR_ENABLED || IS_EVENT_EDITOR_ENABLED
#define IS_PAUSED(pauseCtx) \
(((pauseCtx)->state != PAUSE_STATE_OFF) || ((pauseCtx)->debugState != PAUSE_DEBUG_STATE_CLOSED))
(((pauseCtx)->state != PAUSE_STATE_OFF) || (IS_INV_EDITOR_ACTIVE && (pauseCtx)->debugState != PAUSE_DEBUG_STATE_CLOSED))
#else
#define IS_PAUSED(pauseCtx) \
((pauseCtx)->state != PAUSE_STATE_OFF)

View File

@@ -876,6 +876,7 @@ beginseg
#if ENABLE_PROFILER
include "$(BUILD_DIR)/src/debug/profiler.o"
#endif
include "$(BUILD_DIR)/src/debug/inventory_editor.o"
endseg
#endif

View File

@@ -13,6 +13,8 @@
#include "play_state.h"
#include "player.h"
#include "skin_matrix.h"
#include "gfx.h"
#include "debug.h"
#pragma increment_block_number "ntsc-1.0:136 ntsc-1.1:136 ntsc-1.2:136"

View File

@@ -9,6 +9,8 @@
#include "terminal.h"
#include "translation.h"
#include "play_state.h"
#include "gfx.h"
#include "debug.h"
void (*sKaleidoScopeUpdateFunc)(PlayState* play);
void (*sKaleidoScopeDrawFunc)(PlayState* play);

View File

@@ -8,6 +8,8 @@
#include "audio.h"
#include "play_state.h"
#include "save.h"
#include "gfx.h"
#include "debug.h"
/*
* The following three arrays are effectively unused.
@@ -81,8 +83,9 @@ void KaleidoSetup_Update(PlayState* play) {
if (IS_EVENT_EDITOR_ENABLED && BREG(0)) {
pauseCtx->debugState = PAUSE_DEBUG_STATE_FLAG_SET_OPEN;
}
} else if (CHECK_BTN_ALL(input->press.button, BTN_START)) {
} else if (CHECK_BTN_ALL(input->press.button, BTN_START) && !IS_INV_EDITOR_ACTIVE) {
// The start button was pressed, pause
// doesn't run if the inventory editor is active
gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode;
R_PAUSE_BUTTON_LEFT_X = -175;

View File

@@ -31,6 +31,7 @@
#include "play_state.h"
#include "player.h"
#include "save.h"
#include "debug.h"
#include "assets/objects/gameplay_keep/gameplay_keep.h"
#include "assets/objects/gameplay_field_keep/gameplay_field_keep.h"

View File

@@ -8,6 +8,7 @@
#include "play_state.h"
#include "player.h"
#include "save.h"
#include "debug.h"
#include "assets/textures/parameter_static/parameter_static.h"
@@ -328,6 +329,14 @@ void Health_DrawMeter(PlayState* play) {
u8* curBgImgLoaded = NULL;
s32 ddHeartCountMinusOne = gSaveContext.save.info.inventory.defenseHearts - 1;
u8 posY = 0;
#if IS_INV_EDITOR_ENABLED
if (IS_INV_EDITOR_ACTIVE) {
posY = gDebug.invDebug.miscDebug.hudTopPosY;
}
#endif
OPEN_DISPS(gfxCtx, "../z_lifemeter.c", 353);
if (!(gSaveContext.save.info.playerData.health % 0x10)) {
@@ -455,7 +464,7 @@ void Health_DrawMeter(PlayState* play) {
}
}
heartCenterY = 26.0f + offsetY;
heartCenterY = 26.0f + offsetY + posY;
heartCenterX = 30.0f + offsetX;
heartTexCoordPerPixel = 1.0f;
heartTexCoordPerPixel /= 0.68f;
@@ -489,7 +498,7 @@ void Health_DrawMeter(PlayState* play) {
f32 wideOffsetX = USE_WIDESCREEN ? (offsetX - (30.f * WIDE_GET_16_9)) : offsetX;
Matrix_SetTranslateScaleMtx2(
matrix, 1.0f - (0.32f * beatingHeartPulsingSize), 1.0f - (0.32f * beatingHeartPulsingSize),
1.0f - (0.32f * beatingHeartPulsingSize), -130.0f + wideOffsetX, 94.5f - offsetY, 0.0f);
1.0f - (0.32f * beatingHeartPulsingSize), -130.0f + wideOffsetX, 94.5f - offsetY - posY, 0.0f);
gSPMatrix(OVERLAY_DISP++, matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(OVERLAY_DISP++, beatingHeartVtx, 4, 0);
gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0);

View File

@@ -17,6 +17,7 @@
#include "play_state.h"
#include "player.h"
#include "save.h"
#include "debug.h"
#include "assets/objects/gameplay_keep/gameplay_keep.h"
#include "assets/textures/parameter_static/parameter_static.h"

View File

@@ -25,6 +25,7 @@
#include "play_state.h"
#include "player.h"
#include "save.h"
#include "debug.h"
#include "assets/textures/parameter_static/parameter_static.h"
#include "assets/textures/do_action_static/do_action_static.h"
@@ -2345,10 +2346,12 @@ void Inventory_DeleteItem(u16 item, u16 invSlot) {
PRINTF("\nItem_Register(%d)\n", invSlot, gSaveContext.save.info.inventory.items[invSlot]);
for (i = 1; i < 4; i++) {
if (gSaveContext.save.info.equips.buttonItems[i] == item) {
gSaveContext.save.info.equips.buttonItems[i] = ITEM_NONE;
gSaveContext.save.info.equips.cButtonSlots[i - 1] = SLOT_NONE;
if (!IS_INV_EDITOR_ACTIVE) {
for (i = 1; i < 4; i++) {
if (gSaveContext.save.info.equips.buttonItems[i] == item) {
gSaveContext.save.info.equips.buttonItems[i] = ITEM_NONE;
gSaveContext.save.info.equips.cButtonSlots[i - 1] = SLOT_NONE;
}
}
}
}
@@ -2996,20 +2999,31 @@ 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.magicLevel != 0
#if IS_INV_EDITOR_ENABLED
|| (gDebug.invDebug.miscDebug.showMiscScreen && gSaveContext.save.info.playerData.isMagicAcquired)
#endif
) {
// NOLINTBEGIN
if (gSaveContext.save.info.playerData.healthCapacity > 0xA0)
magicMeterY = R_MAGIC_METER_Y_LOWER; // two rows of hearts
else
magicMeterY = R_MAGIC_METER_Y_HIGHER; // one row of hearts
// NOLINTEND
// NOLINTEND
#if IS_INV_EDITOR_ENABLED
if (IS_INV_EDITOR_ACTIVE) {
magicMeterY += gDebug.invDebug.miscDebug.hudTopPosY;
}
#endif
Gfx_SetupDL_39Overlay(play->state.gfxCtx);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sMagicBorderR, sMagicBorderG, sMagicBorderB, interfaceCtx->magicAlpha);
gDPSetEnvColor(OVERLAY_DISP++, 100, 50, 50, 255);
// TODO: find something better
//! TODO: find something better
{
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gMagicMeterEndTex, 8, 16, WIDE_INCR(R_MAGIC_METER_X, -4),
magicMeterY, WIDE_INCR(8, -2), 16, 1 << 10, 1 << 10);
@@ -3041,7 +3055,7 @@ void Magic_DrawMeter(PlayState* play) {
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
// TODO: find something better
//! TODO: find something better
{
s16 posX = WIDE_MULT(WIDE_INCR(R_MAGIC_FILL_X, 1), WIDE_GET_RATIO);
s16 posRx =
@@ -3056,7 +3070,7 @@ void Magic_DrawMeter(PlayState* play) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, R_MAGIC_FILL_COLOR(0), R_MAGIC_FILL_COLOR(1), R_MAGIC_FILL_COLOR(2),
interfaceCtx->magicAlpha);
// TODO: find something better
//! TODO: find something better
{
s16 posX = WIDE_MULT(WIDE_INCR(R_MAGIC_FILL_X, 1), WIDE_GET_RATIO);
s16 posRx = WIDE_MULT(WIDE_INCR((R_MAGIC_FILL_X + gSaveContext.magicTarget), 1), WIDE_GET_RATIO);
@@ -3073,7 +3087,7 @@ void Magic_DrawMeter(PlayState* play) {
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
// TODO: find something better
//! TODO: find something better
{
s16 posX = WIDE_MULT(WIDE_INCR(R_MAGIC_FILL_X, 1), WIDE_GET_RATIO);
s16 posRx =
@@ -3208,7 +3222,7 @@ void Interface_DrawItemButtons(PlayState* play) {
(R_START_BTN_Y + 22) << 2, G_TX_RENDERTILE, 0, 0, (s32)(1.4277344 * (1 << 10)),
(s32)(1.4277344 * (1 << 10)));
#elif OOT_NTSC
// TODO: widescreen stuff for NTSC
//! TODO: widescreen stuff for NTSC
gSPTextureRectangle(OVERLAY_DISP++, 132 << 2, 17 << 2, (132 + 22) << 2, (17 + 22) << 2, G_TX_RENDERTILE, 0,
0, (s32)(1.4277344 * (1 << 10)), (s32)(1.4277344 * (1 << 10)));
#else
@@ -3539,8 +3553,67 @@ void func_8008A994(InterfaceContext* interfaceCtx) {
View_ApplyOrthoToOverlay(&interfaceCtx->view);
}
void Interface_DrawSmallKeyCounter(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
s16 svar3;
s16 smallKeyPosY = 0;
u16 mapIndex = gSaveContext.mapIndex;
#if IS_INV_EDITOR_ENABLED
if (IS_INV_EDITOR_ACTIVE) {
smallKeyPosY = gDebug.invDebug.miscDebug.hudBottomPosY;
if (smallKeyPosY > 0) {
smallKeyPosY -= gDebug.invDebug.miscDebug.invertVal;
}
if (gDebug.invDebug.miscDebug.showMiscScreen) {
mapIndex = gDebug.invDebug.miscDebug.mapIndex;
}
}
#endif
OPEN_DISPS(play->state.gfxCtx, __FILE__, __LINE__);
if (gSaveContext.save.info.inventory.dungeonKeys[mapIndex] >= 0) {
// Small Key Icon
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 230, 255, interfaceCtx->magicAlpha);
gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 20, 255);
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gSmallKeyCounterIconTex, 16, 16, WIDE_INCR(26, -7),
190 - smallKeyPosY, WIDE_INCR(16, -4), 16, 1 << 10, 1 << 10);
// Small Key Counter
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha);
gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0,
PRIMITIVE, 0);
interfaceCtx->counterDigits[2] = 0;
interfaceCtx->counterDigits[3] = gSaveContext.save.info.inventory.dungeonKeys[mapIndex];
while (interfaceCtx->counterDigits[3] >= 10) {
interfaceCtx->counterDigits[2]++;
interfaceCtx->counterDigits[3] -= 10;
}
svar3 = 42;
if (interfaceCtx->counterDigits[2] != 0) {
OVERLAY_DISP =
Gfx_TextureI8(OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * interfaceCtx->counterDigits[2])), 8, 16,
svar3, 190 - smallKeyPosY, 8, 16, 1 << 10, 1 << 10);
svar3 += 8;
}
OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * interfaceCtx->counterDigits[3])),
8, 16, svar3, 190 - smallKeyPosY, 8, 16, 1 << 10, 1 << 10);
}
CLOSE_DISPS(play->state.gfxCtx, __FILE__, __LINE__);
}
#if IS_INV_EDITOR_ENABLED || IS_EVENT_EDITOR_ENABLED
#define CAN_DRAW_INTERFACE (pauseCtx->debugState == PAUSE_DEBUG_STATE_CLOSED)
#define CAN_DRAW_INTERFACE (pauseCtx->debugState == PAUSE_DEBUG_STATE_CLOSED && !IS_INV_EDITOR_ACTIVE)
#else
#define CAN_DRAW_INTERFACE true
#endif
@@ -3576,6 +3649,16 @@ void Interface_Draw(PlayState* play) {
s16 svar5;
s16 timerId;
s16 rupeePosY = 0;
#if IS_INV_EDITOR_ENABLED
if (IS_INV_EDITOR_ACTIVE) {
rupeePosY = gDebug.invDebug.miscDebug.hudBottomPosY;
if (rupeePosY > 0) {
rupeePosY += gDebug.invDebug.miscDebug.invertVal;
}
}
#endif
OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 3405);
gSPSegment(OVERLAY_DISP++, 0x02, interfaceCtx->parameterSegment);
@@ -3583,7 +3666,7 @@ void Interface_Draw(PlayState* play) {
gSPSegment(OVERLAY_DISP++, 0x08, interfaceCtx->iconItemSegment);
gSPSegment(OVERLAY_DISP++, 0x0B, interfaceCtx->mapSegment);
if (CAN_DRAW_INTERFACE) {
if (CAN_DRAW_INTERFACE || IS_INV_EDITOR_ACTIVE) {
Interface_InitVertices(play);
func_8008A994(interfaceCtx);
Health_DrawMeter(play);
@@ -3605,63 +3688,32 @@ void Interface_Draw(PlayState* play) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 255, 100, interfaceCtx->magicAlpha);
}
gDPSetEnvColor(OVERLAY_DISP++, 0, 80, 0, 255);
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, WIDE_MULT(26, WIDE_GET_RATIO), 206,
16, 16, WIDE_INCR(1, (u16)(WIDE_GET_RATIO)) << 10, 1 << 10);
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, WIDE_MULT(26, WIDE_GET_RATIO),
206 - rupeePosY, 16, 16, WIDE_INCR(1, (u16)(WIDE_GET_RATIO)) << 10, 1 << 10);
switch (play->sceneId) {
case SCENE_FOREST_TEMPLE:
case SCENE_FIRE_TEMPLE:
case SCENE_WATER_TEMPLE:
case SCENE_SPIRIT_TEMPLE:
case SCENE_SHADOW_TEMPLE:
case SCENE_BOTTOM_OF_THE_WELL:
case SCENE_ICE_CAVERN:
case SCENE_GANONS_TOWER:
case SCENE_GERUDO_TRAINING_GROUND:
case SCENE_THIEVES_HIDEOUT:
case SCENE_INSIDE_GANONS_CASTLE:
case SCENE_GANONS_TOWER_COLLAPSE_INTERIOR:
case SCENE_INSIDE_GANONS_CASTLE_COLLAPSE:
case SCENE_TREASURE_BOX_SHOP:
if (gSaveContext.save.info.inventory.dungeonKeys[gSaveContext.mapIndex] >= 0) {
// Small Key Icon
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 230, 255, interfaceCtx->magicAlpha);
gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 20, 255);
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gSmallKeyCounterIconTex, 16, 16, WIDE_INCR(26, -7), 190,
WIDE_INCR(16, -4), 16, 1 << 10, 1 << 10);
// Small Key Counter
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha);
gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE,
TEXEL0, 0, PRIMITIVE, 0);
interfaceCtx->counterDigits[2] = 0;
interfaceCtx->counterDigits[3] =
gSaveContext.save.info.inventory.dungeonKeys[gSaveContext.mapIndex];
while (interfaceCtx->counterDigits[3] >= 10) {
interfaceCtx->counterDigits[2]++;
interfaceCtx->counterDigits[3] -= 10;
}
svar3 = 42;
if (interfaceCtx->counterDigits[2] != 0) {
OVERLAY_DISP = Gfx_TextureI8(
OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * interfaceCtx->counterDigits[2])), 8, 16,
svar3, 190, 8, 16, 1 << 10, 1 << 10);
svar3 += 8;
}
OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP,
((u8*)gCounterDigit0Tex + (8 * 16 * interfaceCtx->counterDigits[3])),
8, 16, svar3, 190, 8, 16, 1 << 10, 1 << 10);
}
break;
default:
break;
if (IS_INV_EDITOR_ACTIVE) {
Interface_DrawSmallKeyCounter(play);
} else {
switch (play->sceneId) {
case SCENE_FOREST_TEMPLE:
case SCENE_FIRE_TEMPLE:
case SCENE_WATER_TEMPLE:
case SCENE_SPIRIT_TEMPLE:
case SCENE_SHADOW_TEMPLE:
case SCENE_BOTTOM_OF_THE_WELL:
case SCENE_ICE_CAVERN:
case SCENE_GANONS_TOWER:
case SCENE_GERUDO_TRAINING_GROUND:
case SCENE_THIEVES_HIDEOUT:
case SCENE_INSIDE_GANONS_CASTLE:
case SCENE_GANONS_TOWER_COLLAPSE_INTERIOR:
case SCENE_INSIDE_GANONS_CASTLE_COLLAPSE:
case SCENE_TREASURE_BOX_SHOP:
Interface_DrawSmallKeyCounter(play);
break;
default:
break;
}
}
// Rupee Counter
@@ -3701,11 +3753,18 @@ void Interface_Draw(PlayState* play) {
for (svar1 = 0, svar3 = 42; svar1 < svar4; svar1++, svar2++, svar3 += 8) {
OVERLAY_DISP =
Gfx_TextureI8(OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * interfaceCtx->counterDigits[svar2])), 8,
16, svar3, 206, 8, 16, 1 << 10, 1 << 10);
16, svar3, 206 - rupeePosY, 8, 16, 1 << 10, 1 << 10);
}
Magic_DrawMeter(play);
Minimap_Draw(play); // TODO: fix the arrows
#if IS_INV_EDITOR_ENABLED
if (gDebug.invDebug.miscDebug.showMiscScreen && gDebug.invDebug.elementsAlpha == 0) {
return;
}
#endif
Minimap_Draw(play); //! TODO: fix the arrows
if ((R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_PROCESS) &&
(R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_READY)) {
@@ -4667,9 +4726,11 @@ void Interface_Update(PlayState* play) {
WREG(7) = interfaceCtx->unk_1F4;
// Update Magic
if (!IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) &&
(play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) &&
(play->transitionMode == TRANS_MODE_OFF) && ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) {
if ((!IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) &&
(play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) &&
(play->transitionMode == TRANS_MODE_OFF) &&
((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) ||
IS_INV_EDITOR_ACTIVE) {
if (gSaveContext.save.info.playerData.isMagicAcquired && (gSaveContext.save.info.playerData.magicLevel == 0)) {
gSaveContext.save.info.playerData.magicLevel = gSaveContext.save.info.playerData.isDoubleMagicAcquired + 1;

View File

@@ -335,6 +335,10 @@ void Play_Init(GameState* thisx) {
#if ENABLE_HACKER_DEBUG
gDebug.play = this;
gDebug.invDebug.state = INVEDITOR_STATE_OFF;
gDebug.invDebug.gfxCtx = this->state.gfxCtx;
gDebug.invDebug.pauseCtx = &this->pauseCtx;
gDebug.invDebug.elementsAlpha = 255;
#endif
if (gSaveContext.save.entranceIndex == ENTR_LOAD_OPENING) {

View File

@@ -1224,6 +1224,16 @@ void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx) {
CLOSE_DISPS(gfxCtx, "../z_rcp.c", 1811);
}
#if DEBUG_FEATURES
void Gfx_SetupDL_39Debug(GraphicsContext* gfxCtx) {
OPEN_DISPS(gfxCtx, __FILE__, __LINE__);
DEBUG_DISP = Gfx_SetupDL_39(DEBUG_DISP);
CLOSE_DISPS(gfxCtx, __FILE__, __LINE__);
}
#endif
void Gfx_SetupDL_39Ptr(Gfx** gfxP) {
Gfx* gfx = *gfxP;

View File

@@ -1,3 +1,4 @@
#include "gfx.h"
#include "debug.h"
#include "collision_check.h"
#include "play_state.h"

View File

@@ -1,8 +1,8 @@
#include "gfx.h"
#include "debug.h"
#include "fault.h"
#include "camera.h"
#include "play_state.h"
#include "gfx.h"
#include "sys_matrix.h"
#if ENABLE_HACKER_DEBUG

1180
src/debug/inventory_editor.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
#include "gfx.h"
#include "debug.h"
#include "controller.h"
#include "save.h"

Some files were not shown because too many files have changed in this diff Show More