mirror of
https://github.com/zeldaret/tmc
synced 2026-06-14 22:29:16 -04:00
Decompile some UI
This commit is contained in:
+9
-8
@@ -6,9 +6,9 @@
|
||||
|
||||
extern u32 gFrameObjLists[];
|
||||
|
||||
extern void ram_sub_080B23F0(void);
|
||||
extern void ram_sub_080B2828(OAMCommand*, void*);
|
||||
extern void ram_sub_080B280C(OAMCommand*, u32, u32);
|
||||
extern void ram_DrawEntities(void);
|
||||
extern void ram_sub_080ADA04(OAMCommand*, void*);
|
||||
extern void ram_DrawDirect(OAMCommand*, u32, u32);
|
||||
|
||||
// regalloc
|
||||
NONMATCH("asm/non_matching/vram/sub_080AD8F0.inc", void* sub_080AD8F0(u32 sprite, u32 frame)) {
|
||||
@@ -59,16 +59,17 @@ void DrawEntities(void) {
|
||||
gOAMControls._4 = gRoomControls.aff_x + gRoomControls.scroll_x;
|
||||
gOAMControls._6 = gRoomControls.aff_y + gRoomControls.scroll_y;
|
||||
gOAMControls.field_0x1++;
|
||||
fn = &ram_sub_080B23F0;
|
||||
fn = &ram_DrawEntities;
|
||||
fn();
|
||||
}
|
||||
|
||||
// TODO second parameter is a frame obj entry from gFrameObjLists
|
||||
void sub_080ADA04(OAMCommand* cmd, void* dst) {
|
||||
void (*fn)(OAMCommand*, void*) = ram_sub_080B2828;
|
||||
void (*fn)(OAMCommand*, void*) = ram_sub_080ADA04;
|
||||
fn(cmd, dst);
|
||||
}
|
||||
|
||||
void DrawDirect(u32 a1, u32 a2) {
|
||||
void (*fn)(OAMCommand*, u32, u32) = ram_sub_080B280C;
|
||||
fn(&gOamCmd, a1, a2);
|
||||
void DrawDirect(u32 spriteIndex, u32 frameIndex) {
|
||||
void (*fn)(OAMCommand*, u32, u32) = ram_DrawDirect;
|
||||
fn(&gOamCmd, spriteIndex, frameIndex);
|
||||
}
|
||||
|
||||
+6
-6
@@ -185,8 +185,8 @@ void FileSelectTask(void) {
|
||||
gMapDataBottomSpecial.isTransitioning = FALSE;
|
||||
UpdateEntities();
|
||||
sub_0805066C();
|
||||
sub_0801C1D4();
|
||||
DrawOAMCmd();
|
||||
UpdateUIElements();
|
||||
DrawUIElements();
|
||||
DrawEntities();
|
||||
CopyOAM();
|
||||
if (gMapDataBottomSpecial.unk3 != gSaveHeader->language) {
|
||||
@@ -346,13 +346,13 @@ void sub_08050790(void) {
|
||||
}
|
||||
|
||||
static void HideButtonR(void) {
|
||||
gUnk_0200AF00.rButtonX = 0x140;
|
||||
gUnk_0200AF00.rButtonY = 0x24;
|
||||
gUnk_0200AF00.buttonX[2] = 0x140;
|
||||
gUnk_0200AF00.buttonY[2] = 0x24;
|
||||
}
|
||||
|
||||
static void ShowButtonR(void) {
|
||||
gUnk_0200AF00.rButtonX = 0xD0;
|
||||
gUnk_0200AF00.rButtonY = 0x24;
|
||||
gUnk_0200AF00.buttonX[2] = 0xD0;
|
||||
gUnk_0200AF00.buttonY[2] = 0x24;
|
||||
}
|
||||
|
||||
static void HandleFileSelect(void) {
|
||||
|
||||
+10
-10
@@ -113,7 +113,7 @@ extern void UpdateScroll(void);
|
||||
extern void UpdateBgAnim(void);
|
||||
extern void CleanUpGFXSlots(void);
|
||||
extern void sub_080ADE24(void);
|
||||
extern void InitUI(u32);
|
||||
extern void InitUI(bool32);
|
||||
extern void sub_0801AE44(u32);
|
||||
extern void GenerateAreaHint(void);
|
||||
extern void ForceSetPlayerState(u32);
|
||||
@@ -350,7 +350,7 @@ static void GameMain_InitRoom(void) {
|
||||
gRoomTransition.field_0x4[1] = 0;
|
||||
MessageInitialize();
|
||||
InitRoom();
|
||||
InitUI(0);
|
||||
InitUI(FALSE);
|
||||
InitializeEntities();
|
||||
#ifndef EU
|
||||
sub_0801855C();
|
||||
@@ -366,7 +366,7 @@ static void GameMain_ChangeRoom(void) {
|
||||
DrawUI();
|
||||
UpdateManagers();
|
||||
FlushSprites();
|
||||
DrawOAMCmd();
|
||||
DrawUIElements();
|
||||
UpdateCarriedObject();
|
||||
DrawEntities();
|
||||
CopyOAM();
|
||||
@@ -443,7 +443,7 @@ static void GameMain_Update(void) {
|
||||
sub_08052C3C();
|
||||
DrawUI();
|
||||
UpdateManagers();
|
||||
DrawOAMCmd();
|
||||
DrawUIElements();
|
||||
UpdateCarriedObject();
|
||||
DrawEntities();
|
||||
CheckRoomExit();
|
||||
@@ -476,7 +476,7 @@ static void GameMain_BarrelUpdate(void) {
|
||||
DrawUI();
|
||||
UpdateManagers();
|
||||
FlushSprites();
|
||||
DrawOAMCmd();
|
||||
DrawUIElements();
|
||||
UpdateCarriedObject();
|
||||
DrawEntities();
|
||||
CheckRoomExit();
|
||||
@@ -488,7 +488,7 @@ static void GameMain_BarrelUpdate(void) {
|
||||
|
||||
static void GameMain_ChangeArea(void) {
|
||||
FlushSprites();
|
||||
DrawOAMCmd();
|
||||
DrawUIElements();
|
||||
DrawEntities();
|
||||
gMain.pad = 1;
|
||||
CopyOAM();
|
||||
@@ -1151,7 +1151,7 @@ void RestoreGameTask(u32 a1) {
|
||||
CleanUpGFXSlots();
|
||||
#endif
|
||||
sub_080ADE24();
|
||||
InitUI(1);
|
||||
InitUI(TRUE);
|
||||
sub_0801AE44(a1);
|
||||
MemCopy(gUnk_02024090, gPaletteBuffer, 1024);
|
||||
gUsedPalettes = 0xffffffff;
|
||||
@@ -1302,7 +1302,7 @@ bool32 CanDispEzloMessage(void) {
|
||||
s32 tmp = PL_STATE_WALK;
|
||||
|
||||
if (!(gInput.heldKeys & SELECT_BUTTON) || gPlayerState.controlMode != CONTROL_ENABLED || gUnk_02034490.unk0 ||
|
||||
gUnk_0200AF00.filler0[1])
|
||||
gUnk_0200AF00.unk_1)
|
||||
return 0;
|
||||
|
||||
if ((gPlayerState.flags & (PL_NO_CAP | 0x110)) || (gPlayerState.framestate_last > tmp) || gPlayerState.item ||
|
||||
@@ -2291,8 +2291,8 @@ void ForceEquipItem(u32 itemID, u32 itemSlot) {
|
||||
}
|
||||
gSave.stats.itemButtons[itemSlot] = itemID;
|
||||
gSave.stats.itemButtons[otherItemIndex] = otherItem;
|
||||
gUnk_0200AF00.filler0[0x13] = 0x7f;
|
||||
gUnk_0200AF00.filler0[0x14] = 0x7f;
|
||||
gUnk_0200AF00.unk_13 = 0x7f;
|
||||
gUnk_0200AF00.unk_14 = 0x7f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -227,9 +227,9 @@ void PlayerUpdate(Entity* this) {
|
||||
void HandlePlayerLife(Entity* this) {
|
||||
u32 temp;
|
||||
|
||||
gUnk_0200AF00.filler25[10] = 0;
|
||||
gUnk_0200AF00.filler25[8] = 0;
|
||||
gUnk_0200AF00.filler25[9] = 0;
|
||||
gUnk_0200AF00.unk_2f = 0;
|
||||
gUnk_0200AF00.unk_2d = 0;
|
||||
gUnk_0200AF00.unk_2e = 0;
|
||||
|
||||
if ((gPlayerEntity.bitfield & 0x80) && (gPlayerEntity.iframes > 0))
|
||||
SoundReq(SFX_86);
|
||||
@@ -257,7 +257,7 @@ void HandlePlayerLife(Entity* this) {
|
||||
return;
|
||||
|
||||
#ifdef EU
|
||||
if ((gUnk_0200AF00.filler0[1] == 0) && gRoomTransition.frameCount % 90 == 0) {
|
||||
if ((gUnk_0200AF00.unk_1 == 0) && gRoomTransition.frameCount % 90 == 0) {
|
||||
temp = gSave.stats.maxHealth / 4;
|
||||
if (temp > 24)
|
||||
temp = 24;
|
||||
@@ -278,7 +278,7 @@ void HandlePlayerLife(Entity* this) {
|
||||
|
||||
if (gSave.stats.health <= temp) {
|
||||
gRoomVars.unk2 = 1;
|
||||
if ((gUnk_0200AF00.filler0[1] == 0) && gRoomTransition.frameCount % 90 == 0) {
|
||||
if ((gUnk_0200AF00.unk_1 == 0) && gRoomTransition.frameCount % 90 == 0) {
|
||||
EnqueueSFX(SFX_LOW_HEALTH);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ void sub_080171F0(void) {
|
||||
sub_080028E0(&gPlayerEntity);
|
||||
|
||||
if (gPlayerState.flags & PL_CLONING)
|
||||
gUnk_0200AF00.filler25[10] = 1;
|
||||
gUnk_0200AF00.unk_2f = 1;
|
||||
|
||||
sub_08078180();
|
||||
gPlayerState.field_0x7 &= ~0x80;
|
||||
|
||||
@@ -84,8 +84,8 @@ void Subtask_FigurineMenu(void) {
|
||||
figurineMenu1_Types[gMenu.menuType]();
|
||||
}
|
||||
UpdateEntities();
|
||||
sub_0801C1D4();
|
||||
DrawOAMCmd();
|
||||
UpdateUIElements();
|
||||
DrawUIElements();
|
||||
DrawEntities();
|
||||
FigurineMenu_080A4978();
|
||||
CopyOAM();
|
||||
@@ -598,7 +598,7 @@ void sub_080A4DB8(u32 param_1) {
|
||||
MemClear(&gBG0Buffer, 0x800);
|
||||
MemClear(&gBG1Buffer, 0x800);
|
||||
MemClear(&gBG2Buffer, 0x800);
|
||||
MemClear(gUnk_0200AF00.filler25 + 0xf, 0x300);
|
||||
MemClear(gUnk_0200AF00.elements, sizeof(gUnk_0200AF00.elements));
|
||||
MemClear(&gFigurineMenu, sizeof(gFigurineMenu));
|
||||
gFigurineMenu.unk2e = 0xffff;
|
||||
gMenu.field_0x3 = gUnk_02034490.unk2[param_1];
|
||||
|
||||
@@ -85,8 +85,8 @@ void Subtask_KinstoneMenu(void) {
|
||||
kinstoneMenuTypes[gMenu.menuType]();
|
||||
sub_080A3B74();
|
||||
KinstoneMenu_080A4054();
|
||||
sub_0801C1D4();
|
||||
DrawOAMCmd();
|
||||
UpdateUIElements();
|
||||
DrawUIElements();
|
||||
UpdateEntities();
|
||||
DrawEntities();
|
||||
CopyOAM();
|
||||
|
||||
@@ -38,8 +38,8 @@ void Subtask_PauseMenu(void) {
|
||||
FlushSprites();
|
||||
pauseMenu_Variants[gUnk_02034490.unk11]();
|
||||
sub_080A5128();
|
||||
sub_0801C1D4();
|
||||
DrawOAMCmd();
|
||||
UpdateUIElements();
|
||||
DrawUIElements();
|
||||
if (gUnk_02034490.unk11 != 4) {
|
||||
gUnk_08128A38[gUnk_02034490.unk1].func();
|
||||
}
|
||||
|
||||
@@ -172,9 +172,9 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
|
||||
this->unk_70 = ((super->x.HALF.HI + (s8)gUnk_08123184[tmp]) & -0x10) | 8;
|
||||
this->unk_72 = ((super->y.HALF.HI + (s8)gUnk_08123184[(tmp) + 1]) & -0x10) | 8;
|
||||
if (sub_080B1AB4(this->unk_70, this->unk_72, super->collisionLayer) == 0x19) {
|
||||
gUnk_0200AF00.filler25[10] = 3;
|
||||
gUnk_0200AF00.unk_2f = 3;
|
||||
} else {
|
||||
gUnk_0200AF00.filler25[10] = 0;
|
||||
gUnk_0200AF00.unk_2f = 0;
|
||||
}
|
||||
PositionRelative(&gPlayerEntity, super, 0, 0x10000);
|
||||
if (sub_080B1AA8(super) == 0x19) {
|
||||
@@ -184,7 +184,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
|
||||
if ((gPlayerState.field_0x92 & 0xc0) == 0) {
|
||||
return;
|
||||
}
|
||||
if (gUnk_0200AF00.filler25[10] != 3) {
|
||||
if (gUnk_0200AF00.unk_2f != 3) {
|
||||
return;
|
||||
}
|
||||
gPlayerState.heldObject = 0;
|
||||
|
||||
@@ -85,7 +85,7 @@ void ItemForSale_Init(ItemForSaleEntity* this) {
|
||||
void ItemForSale_Action1(ItemForSaleEntity* this) {
|
||||
if (super->subAction != 0) {
|
||||
super->action = 2;
|
||||
gUnk_0200AF00.filler25[10] = 2;
|
||||
gUnk_0200AF00.unk_2f = 2;
|
||||
} else {
|
||||
if (super->type == 0x36) {
|
||||
if (super->interactType != 0) {
|
||||
@@ -102,7 +102,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
|
||||
ResetPlayer();
|
||||
gPlayerState.heldObject = 4;
|
||||
gNewPlayerEntity.unk_74 = super;
|
||||
gUnk_0200AF00.filler25[10] = 2;
|
||||
gUnk_0200AF00.unk_2f = 2;
|
||||
MessageClose();
|
||||
}
|
||||
}
|
||||
@@ -112,14 +112,14 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
|
||||
void ItemForSale_Action2(ItemForSaleEntity* this) {
|
||||
void* ptr;
|
||||
|
||||
gUnk_0200AF00.filler25[10] = 2;
|
||||
gUnk_0200AF00.unk_2f = 2;
|
||||
super->spriteSettings.draw = gPlayerEntity.spriteSettings.draw;
|
||||
if ((gPlayerState.heldObject == 0) || (super != gNewPlayerEntity.unk_74)) {
|
||||
sub_080819B4(this);
|
||||
} else {
|
||||
ptr = sub_080784E4();
|
||||
if (((*(int*)(ptr + 8) == 0) ||
|
||||
((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.filler25[10] = 7, (gPlayerState.field_0x92 & 0x88) == 0)))) &&
|
||||
((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.unk_2f = 7, (gPlayerState.field_0x92 & 0x88) == 0)))) &&
|
||||
((gPlayerState.field_0x92 & 0x98) != 0)) {
|
||||
sub_080819B4(this);
|
||||
}
|
||||
@@ -141,8 +141,8 @@ void sub_080819B4(ItemForSaleEntity* this) {
|
||||
gNewPlayerEntity.unk_74 = 0;
|
||||
ptr = &gUnk_0200AF00;
|
||||
gRoomVars.shopItemType = 0;
|
||||
ptr->filler25[7] = 0;
|
||||
ptr->filler25[10] = 0;
|
||||
ptr->unk_2c = 0;
|
||||
ptr->unk_2f = 0;
|
||||
gRoomVars.shopItemType2 = 0;
|
||||
super->x.HALF.HI = this->unk_80 + gRoomControls.origin_x;
|
||||
super->y.HALF.HI = this->unk_82 + gRoomControls.origin_y;
|
||||
|
||||
+2
-2
@@ -1862,7 +1862,7 @@ static void PlayerPull(Entity* this) {
|
||||
|
||||
gPlayerState.framestate = PL_STATE_PULL;
|
||||
sPlayerPullStates[this->subAction](this);
|
||||
gUnk_0200AF00.filler25[9] = 8;
|
||||
gUnk_0200AF00.unk_2e = 8;
|
||||
}
|
||||
|
||||
static void sub_08072214(Entity* this) {
|
||||
@@ -2802,7 +2802,7 @@ void sub_08073584(Entity* this) {
|
||||
return;
|
||||
}
|
||||
|
||||
gUnk_0200AF00.filler25[10] = 1;
|
||||
gUnk_0200AF00.unk_2f = 1;
|
||||
if (sub_0807A2F8(0)) {
|
||||
this->subAction++;
|
||||
this->direction = 4 * (this->animationState & 6);
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ NONMATCH("asm/non_matching/playerUtils/sub_080777A0.inc", bool32 sub_080777A0(vo
|
||||
RequestPriorityDuration(&gPlayerEntity, 0xb4);
|
||||
return TRUE;
|
||||
}
|
||||
} else if ((((gUnk_0200AF00.filler25[7] == 0xc) && (gPlayerState.field_0x1c == 0)) &&
|
||||
} else if ((((gUnk_0200AF00.unk_2c == 0xc) && (gPlayerState.field_0x1c == 0)) &&
|
||||
(gPlayerState.floor_type != 0x11)) &&
|
||||
((((gPlayerState.field_0x90 & 0xf00) != 0 &&
|
||||
((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) &&
|
||||
|
||||
+2
-2
@@ -448,13 +448,13 @@ void sub_0807DF28(void) {
|
||||
}
|
||||
|
||||
void sub_0807DF38(void) {
|
||||
gUnk_0200AF00.filler0[1] = 0xff;
|
||||
gUnk_0200AF00.unk_1 = 0xff;
|
||||
gUnk_02034490.unk0 = 0xff;
|
||||
}
|
||||
|
||||
void sub_0807DF50(void) {
|
||||
gUnk_02034490.unk0 = 0;
|
||||
gUnk_0200AF00.filler0[1] = 0;
|
||||
gUnk_0200AF00.unk_1 = 0;
|
||||
RecoverUI(0);
|
||||
ResetPlayerAnimationAndAction();
|
||||
sub_08079184();
|
||||
|
||||
+1
-1
@@ -401,7 +401,7 @@ void sub_080A74F4(void) {
|
||||
UpdateEntities();
|
||||
UpdateManagers();
|
||||
DrawUI();
|
||||
DrawOAMCmd();
|
||||
DrawUIElements();
|
||||
UpdateCarriedObject();
|
||||
DrawEntities();
|
||||
CopyOAM();
|
||||
|
||||
@@ -1,77 +1,475 @@
|
||||
#include "global.h"
|
||||
#include "sound.h"
|
||||
#include "message.h"
|
||||
|
||||
typedef struct {
|
||||
s8 unk0;
|
||||
u8 unk1;
|
||||
u8 unk2;
|
||||
u8 unk3;
|
||||
u8 unk4;
|
||||
u8 unk5;
|
||||
u8 unk6;
|
||||
u8 unk7;
|
||||
u8 unk8;
|
||||
u8 unk9;
|
||||
u8 unkA;
|
||||
u8 unkB;
|
||||
u16 unkC;
|
||||
u16 unkE;
|
||||
u16 unk10;
|
||||
u8 unk12;
|
||||
u8 unk13;
|
||||
} Element;
|
||||
#include "functions.h"
|
||||
#include "screen.h"
|
||||
#include "common.h"
|
||||
#include "save.h"
|
||||
#include "player.h"
|
||||
#include "area.h"
|
||||
#include "game.h"
|
||||
|
||||
extern void sub_0805ECEC(u32, u32, u32, u32);
|
||||
extern void sub_0801CAD0(Element*);
|
||||
extern bool32 ItemIsBottle(u32);
|
||||
|
||||
extern void (*const gUnk_080C904C[])(Element*);
|
||||
typedef struct {
|
||||
u16 unk_0;
|
||||
u16 unk_2;
|
||||
u16 unk_4;
|
||||
u16 unk_6;
|
||||
u16 unk_8;
|
||||
} substruct_160;
|
||||
|
||||
typedef struct {
|
||||
substruct_160 unk_0;
|
||||
u8 unk_9[54];
|
||||
substruct_160 unk_40;
|
||||
} struct_02035160;
|
||||
extern struct_02035160 gUnk_02035160;
|
||||
|
||||
typedef struct {
|
||||
u32 unk_0;
|
||||
u32 unk_4;
|
||||
u32 unk_8;
|
||||
u32 unk_c;
|
||||
u32 unk_10;
|
||||
u32 unk_14;
|
||||
u8 unk_18[40];
|
||||
} struct_02034CF0;
|
||||
|
||||
extern struct_02034CF0 gUnk_02034CF0[];
|
||||
|
||||
typedef struct {
|
||||
struct_02034CF0 unk_0;
|
||||
struct_02034CF0 unk_40;
|
||||
} struct_02034D30;
|
||||
|
||||
extern struct_02034D30 gUnk_02034D30;
|
||||
|
||||
typedef struct {
|
||||
u16 unk_0;
|
||||
u16 unk_2;
|
||||
u16 unk_4;
|
||||
u16 unk_6;
|
||||
u8 pad[56];
|
||||
} substruct_0E2;
|
||||
|
||||
typedef struct {
|
||||
substruct_0E2 unk_0[2];
|
||||
} struct_020350E2;
|
||||
|
||||
extern struct_020350E2 gUnk_020350E2;
|
||||
|
||||
typedef struct {
|
||||
u16 unk_0; // -> gOamCmd._4
|
||||
u16 unk_2; // -> gOamCmd._6
|
||||
u16 unk_4; // -> element->unk_1a
|
||||
u16 spriteIndex;
|
||||
void (*updateFunction)(UIElement*);
|
||||
u8 buttonElementId;
|
||||
u8 unk_d;
|
||||
u8 unk_e;
|
||||
u8 unk_f;
|
||||
} UIElementDefinition;
|
||||
|
||||
extern UIElementDefinition gUIElementDefinitions[];
|
||||
extern void (*const ButtonUIElement_Actions[])(UIElement*);
|
||||
extern const u8 gUnk_080C9044[];
|
||||
extern void (*const EzloNagUIElement_Actions[])(UIElement*);
|
||||
extern u16 gUnk_080C9058[];
|
||||
extern Frame gUnk_080C9094[];
|
||||
|
||||
void EzloNag(Element* arg0) {
|
||||
gUnk_080C904C[arg0->unk4](arg0);
|
||||
void sub_0801C2F0(u32, u32);
|
||||
void DrawHearts(void);
|
||||
void DrawChargeBar(void);
|
||||
void DrawRupees(void);
|
||||
void DrawKeys(void);
|
||||
void CreateUIElement(u32, u32);
|
||||
void sub_0801C5E0(u32, u32, u32, u32);
|
||||
void sub_0801CAFC(UIElement*, u32);
|
||||
void sub_0801CB20(UIElement*, UIElementDefinition*);
|
||||
UIElement* FindUIElement(u32);
|
||||
void sub_0801CAD0(UIElement*);
|
||||
void sub_0801CAB8(UIElement*, Frame*);
|
||||
|
||||
void UpdateUIElements(void) {
|
||||
u32 index;
|
||||
UIElement* element;
|
||||
const UIElementDefinition* definition;
|
||||
for (index = 0; index < MAX_UI_ELEMENTS; index++) {
|
||||
element = &gUnk_0200AF00.elements[index];
|
||||
if (element->used != 0) {
|
||||
definition = &gUIElementDefinitions[element->type];
|
||||
definition->updateFunction(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern u32 gUnk_080C9094;
|
||||
extern void sub_0801CAB8(Element*, u32*);
|
||||
void DrawUIElements(void) {
|
||||
u32 index;
|
||||
UIElement* element;
|
||||
UIElementDefinition* definition;
|
||||
index = 0;
|
||||
for (index = 0; index < MAX_UI_ELEMENTS; index++) {
|
||||
element = &gUnk_0200AF00.elements[index];
|
||||
if (element->used == 1 && element->unk_0_1 == 1) {
|
||||
gOamCmd.x = element->x;
|
||||
gOamCmd.y = element->y;
|
||||
definition = &gUIElementDefinitions[element->type];
|
||||
gOamCmd._4 = definition->unk_0;
|
||||
gOamCmd._6 = definition->unk_2;
|
||||
gOamCmd._8 = element->unk_18 << 0xc | element->unk_1a;
|
||||
DrawDirect(definition->spriteIndex, element->frameIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NONMATCH("asm/non_matching/sub_0801CED8.inc", void sub_0801CED8(Element* arg0)) {
|
||||
if (gUnk_0200AF00.ezloNagFuncIndex == 1) {
|
||||
gUnk_0200AF00.ezloNagFuncIndex = 2;
|
||||
arg0->unkC = 0x10;
|
||||
arg0->unkE = 0x90;
|
||||
arg0->unk6 = 0;
|
||||
arg0->unk1 = 7;
|
||||
arg0->unk4 = 1;
|
||||
arg0->unk0 |= 2;
|
||||
sub_0801CAB8(arg0, &gUnk_080C9094);
|
||||
NONMATCH("asm/non_matching/ui/sub_0801C25C.inc", void sub_0801C25C(void)) {
|
||||
u32 uVar1;
|
||||
s32 index;
|
||||
u8 tmp;
|
||||
UIElement* element;
|
||||
|
||||
for (index = 0; index < MAX_UI_ELEMENTS; index++) {
|
||||
element = &gUnk_0200AF00.elements[index];
|
||||
if (((element->used) == 1) && ((element->unk_0_1) == 1)) {
|
||||
// TODO wrong bitfield access here
|
||||
if (element->unk_0_2 == 1) {
|
||||
element->unk_0_2 = 2;
|
||||
DmaSet(3, element->firstTile, element->unk_1a * 0x20 + 0x6010000, element->numTiles << 3 | 0x84000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gUnk_0200AF00.unk_13 < 0) {
|
||||
tmp = gUnk_0200AF00.unk_13 & 0x7f;
|
||||
gUnk_0200AF00.unk_13 = tmp;
|
||||
sub_0801C2F0(0x11a, tmp);
|
||||
}
|
||||
if (gUnk_0200AF00.unk_14 < 0) {
|
||||
tmp = gUnk_0200AF00.unk_14 & 0x7f;
|
||||
gUnk_0200AF00.unk_14 = tmp;
|
||||
sub_0801C2F0(0x126, tmp);
|
||||
}
|
||||
}
|
||||
END_NONMATCH
|
||||
|
||||
void sub_0801CF18(Element* arg0) {
|
||||
u32 temp;
|
||||
ASM_FUNC("asm/non_matching/ui/sub_0801C2F0.inc", void sub_0801C2F0(u32 a, u32 b))
|
||||
|
||||
temp = gUnk_080C9058[arg0->unk6++];
|
||||
sub_0805ECEC(0, temp, temp, 0);
|
||||
if (temp == 0) {
|
||||
arg0->unk4 = 2;
|
||||
arg0->unk1 = 8;
|
||||
void DrawUI(void) {
|
||||
gUnk_0200AF00.unk_0 &= ~gUnk_0200AF00.unk_1;
|
||||
DrawHearts();
|
||||
DrawChargeBar();
|
||||
DrawRupees();
|
||||
DrawKeys();
|
||||
gUnk_0200AF00.unk_0 = 0;
|
||||
UpdateUIElements();
|
||||
}
|
||||
|
||||
void InitUI(bool32 keepHealthAndRupees) {
|
||||
u32 health;
|
||||
u32 rupees;
|
||||
|
||||
if (!keepHealthAndRupees) {
|
||||
health = gSave.stats.health >> 1;
|
||||
rupees = gSave.stats.rupees;
|
||||
} else {
|
||||
health = gUnk_0200AF00.health;
|
||||
rupees = gUnk_0200AF00.rupees;
|
||||
}
|
||||
MemClear(&gUnk_0200AF00, sizeof(struct_0200AF00));
|
||||
gUnk_0200AF00.health = health;
|
||||
gUnk_0200AF00.rupees = rupees;
|
||||
gUnk_0200AF00.maxHealth = gSave.stats.maxHealth >> 1;
|
||||
LoadPaletteGroup(0xc);
|
||||
LoadGfxGroup(0x10);
|
||||
MemClear(&gBG0Buffer, 0x800);
|
||||
gScreen.bg0.tilemap = &gBG0Buffer;
|
||||
gScreen.bg0.control = 0x1f0c;
|
||||
gScreen.lcd.displayControl |= 0x100;
|
||||
gOAMControls.unk[0].unk7 = 1;
|
||||
gOAMControls.unk[0].unk6 = 1;
|
||||
gOAMControls.unk[1].unk6 = 1;
|
||||
gUnk_0200AF00.unk_13 = 0x7f;
|
||||
gUnk_0200AF00.unk_14 = 0x7f;
|
||||
gUnk_0200AF00.unk_8 = 0x7f;
|
||||
DrawHearts();
|
||||
DrawRupees();
|
||||
DrawChargeBar();
|
||||
DrawKeys();
|
||||
gUnk_0200AF00.buttonX[0] = 0xd0;
|
||||
gUnk_0200AF00.buttonX[1] = 0xb8;
|
||||
gUnk_0200AF00.buttonX[2] = 0xd8;
|
||||
gUnk_0200AF00.buttonY[0] = 0x1c;
|
||||
gUnk_0200AF00.buttonY[1] = 0x1c;
|
||||
gUnk_0200AF00.buttonY[2] = 0xe;
|
||||
// TODO why is this array cleared again? Is it filled by the function calls in the mean time?
|
||||
MemClear(gUnk_0200AF00.elements, sizeof(gUnk_0200AF00.elements));
|
||||
CreateUIElement(UI_ELEMENT_TEXT_R, 9);
|
||||
CreateUIElement(UI_ELEMENT_ITEM_A, 0);
|
||||
CreateUIElement(UI_ELEMENT_ITEM_B, 0);
|
||||
CreateUIElement(UI_ELEMENT_BUTTON_R, 0);
|
||||
CreateUIElement(UI_ELEMENT_BUTTON_B, 0);
|
||||
CreateUIElement(UI_ELEMENT_BUTTON_A, 0);
|
||||
CreateUIElement(UI_ELEMENT_EZLONAGSTART, 0);
|
||||
CreateUIElement(UI_ELEMENT_HEART, 0);
|
||||
}
|
||||
|
||||
void RefreshUI(void) {
|
||||
gScreen.bg0.updated = 1;
|
||||
}
|
||||
|
||||
void RecoverUI(u32 bottomPt, u32 topPt) {
|
||||
gUnk_0200AF00.unk_2 = 0;
|
||||
gUnk_0200AF00.unk_10 = 0;
|
||||
gUnk_0200AF00.unk_a = 0;
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/DrawRupees.inc", void DrawRupees(void))
|
||||
|
||||
// Draw icon with text for rupees or keys
|
||||
ASM_FUNC("asm/non_matching/ui/sub_0801C5E0.inc",
|
||||
void sub_0801C5E0(u32 iconVramIndex, u32 count, bool32 isTextYellow, u32 d))
|
||||
|
||||
void sub_0801C66C(void) {
|
||||
struct_02034CF0* ptr;
|
||||
s32 index;
|
||||
|
||||
if (gUnk_0200AF00.unk_2 != 0) {
|
||||
gUnk_0200AF00.unk_2 = 0;
|
||||
if (gUnk_0200AF00.maxHealth > 0x28) {
|
||||
index = 2;
|
||||
} else {
|
||||
index = 1;
|
||||
}
|
||||
ptr = gUnk_02034CF0;
|
||||
do {
|
||||
ptr->unk_0 = 0;
|
||||
ptr->unk_4 = 0;
|
||||
ptr->unk_8 = 0;
|
||||
ptr->unk_c = 0;
|
||||
ptr->unk_10 = 0;
|
||||
ptr->unk_14 = 0;
|
||||
ptr++;
|
||||
index--;
|
||||
} while (index > 0);
|
||||
gScreen.bg0.updated = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/DrawHearts.inc", void DrawHearts())
|
||||
|
||||
void sub_0801C824(void) {
|
||||
struct_02034CF0* ptr;
|
||||
|
||||
if (gUnk_0200AF00.unk_6 != 0) {
|
||||
gUnk_0200AF00.unk_6 = 0;
|
||||
if (gUnk_0200AF00.maxHealth > 4 * 10) {
|
||||
ptr = &gUnk_02034D30.unk_40; // Show second row of hearts
|
||||
} else {
|
||||
ptr = &gUnk_02034D30.unk_0;
|
||||
}
|
||||
ptr->unk_0 = 0;
|
||||
ptr->unk_4 = 0;
|
||||
ptr->unk_8 = 0;
|
||||
ptr->unk_c = 0;
|
||||
ptr->unk_10 = 0;
|
||||
ptr->unk_14 = 0;
|
||||
gScreen.bg0.updated = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/DrawChargeBar.inc", void DrawChargeBar())
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/DrawKeys.inc", void DrawKeys(void))
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/CreateUIElement.inc", void CreateUIElement(u32 type, u32 type2))
|
||||
|
||||
void sub_0801CAB8(UIElement* element, Frame* frame) {
|
||||
element->framePtr = frame;
|
||||
element->duration = frame->duration;
|
||||
element->spriteSettings = frame->spriteSettings.raw;
|
||||
element->frameSettings = frame->frameSettings.raw;
|
||||
sub_0801CAFC(element, frame->index);
|
||||
}
|
||||
|
||||
void sub_0801CAD0(UIElement* element) {
|
||||
if (--element->duration == 0) {
|
||||
Frame* frame = element->framePtr;
|
||||
if ((s8)frame->frameSettings.raw < 0) {
|
||||
frame -= frame[1].index;
|
||||
}
|
||||
sub_0801CAB8(element, frame + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0801CAFC(UIElement* element, u32 frameIndex) {
|
||||
UIElementDefinition* definition = &gUIElementDefinitions[element->type];
|
||||
if (frameIndex != element->frameIndex) {
|
||||
element->frameIndex = frameIndex;
|
||||
sub_0801CB20(element, definition);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0801CB20(UIElement* element, UIElementDefinition* definition) {
|
||||
if (definition->unk_e == 0) {
|
||||
SpritePtr* ptr = &gSpritePtrs[definition->spriteIndex];
|
||||
SpriteFrame* frame = &ptr->frames[element->frameIndex];
|
||||
u32* firstTile = (u32*)(ptr->ptr + frame->firstTileIndex * 0x20);
|
||||
u8 numTiles = frame->numTiles;
|
||||
if (numTiles == 0) {
|
||||
element->unk_0_2 = 0;
|
||||
} else {
|
||||
if ((element->numTiles != numTiles) || (element->firstTile != firstTile)) {
|
||||
element->firstTile = firstTile;
|
||||
element->unk_0_2 = 1;
|
||||
}
|
||||
}
|
||||
element->numTiles = numTiles;
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonUIElement(UIElement* element) {
|
||||
ButtonUIElement_Actions[element->action](element);
|
||||
}
|
||||
|
||||
void ButtonUIElement_Action0(UIElement* element) {
|
||||
element->x = gUnk_0200AF00.buttonX[element->type];
|
||||
element->y = gUnk_0200AF00.buttonY[element->type] - 0x20;
|
||||
element->action = 1;
|
||||
element->unk_0_1 = 1;
|
||||
sub_0801CAFC(element, element->type);
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/ButtonUIElement_Action1.inc", void ButtonUIElement_Action1())
|
||||
|
||||
u32 sub_0801CC80(UIElement* element) {
|
||||
u8 type = element->type;
|
||||
u32 buttonId = (type ^ 3) != 0;
|
||||
u32 itemId = gSave.stats.itemButtons[buttonId];
|
||||
if (ItemIsBottle(itemId)) {
|
||||
itemId = gSave.saved_status.field_0x24[itemId - 6];
|
||||
}
|
||||
return itemId;
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/ui/ItemUIElement.inc", void ItemUIElement())
|
||||
|
||||
NONMATCH("asm/non_matching/ui/TextUIElement.inc", void TextUIElement(UIElement* element)) {
|
||||
UIElement* buttonUIElement;
|
||||
u32 tmp;
|
||||
extern struct_0200AF00* ptr;
|
||||
u32 tmp1;
|
||||
UIElement* ptr2;
|
||||
|
||||
if (element->type2 == 9) {
|
||||
if (gUnk_0200AF00.unk_2f == 0) {
|
||||
switch (gArea.field_0x18) {
|
||||
case 2:
|
||||
tmp1 = 0xb;
|
||||
break;
|
||||
case 3:
|
||||
tmp1 = 0xa;
|
||||
break;
|
||||
default:
|
||||
tmp1 = gUnk_0200AF00.unk_2c;
|
||||
break;
|
||||
}
|
||||
gUnk_0200AF00.unk_32 = tmp1;
|
||||
}
|
||||
}
|
||||
tmp = gUnk_0200AF00.unk_30[element->buttonElementId];
|
||||
element->unk_0_1 = 0;
|
||||
if (tmp != 0) {
|
||||
sub_0801CAFC(element, tmp + gUnk_080C9044[((SaveHeader*)0x2000000)->language]);
|
||||
buttonUIElement = FindUIElement(element->buttonElementId);
|
||||
if (buttonUIElement != NULL) {
|
||||
element->x = buttonUIElement->x;
|
||||
element->y = buttonUIElement->y;
|
||||
element->unk_0_1 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
END_NONMATCH
|
||||
|
||||
UIElement* FindUIElement(u32 type) {
|
||||
UIElement* element;
|
||||
u32 index;
|
||||
for (index = 0; index < MAX_UI_ELEMENTS; index++) {
|
||||
element = &gUnk_0200AF00.elements[index];
|
||||
if (element->used != 0 && type == element->type) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void HeartUIElement(UIElement* element) {
|
||||
s32 tmp;
|
||||
u32 x;
|
||||
u16 y;
|
||||
u32 health;
|
||||
u32 frameIndex;
|
||||
element->unk_0_1 = 0;
|
||||
if (((gUnk_0200AF00.unk_1 & 0x10) == 0) && ((gMessage.doTextBox & 0x7f) == 0)) {
|
||||
health = gUnk_0200AF00.health;
|
||||
if (health != 0) {
|
||||
element->unk_0_1 = 1;
|
||||
// Calculate the position for this heart.
|
||||
tmp = ((health + 3) >> 2) * 8;
|
||||
x = tmp + 3;
|
||||
y = 0xc;
|
||||
if (health > 0x28) {
|
||||
y = 0x14;
|
||||
x = tmp - 0x4d;
|
||||
}
|
||||
element->x = x;
|
||||
element->y = y;
|
||||
if ((health & 3) == 0) {
|
||||
frameIndex = 4; // Full heart
|
||||
} else {
|
||||
frameIndex = health & 3; // Quarters
|
||||
}
|
||||
sub_0801CAFC(element, frameIndex + 0x71);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EzloNagUIElement(UIElement* element) {
|
||||
EzloNagUIElement_Actions[element->action](element);
|
||||
}
|
||||
|
||||
void EzloNagUIElement_Action0(UIElement* element) {
|
||||
if (gUnk_0200AF00.ezloNagFuncIndex == 1) {
|
||||
gUnk_0200AF00.ezloNagFuncIndex = 2;
|
||||
element->x = 0x10;
|
||||
element->y = 0x90;
|
||||
element->unk_6 = 0;
|
||||
element->type = UI_ELEMENT_EZLONAGSTART;
|
||||
element->action = 1;
|
||||
element->unk_0_1 = 1;
|
||||
sub_0801CAB8(element, gUnk_080C9094);
|
||||
}
|
||||
}
|
||||
|
||||
void EzloNagUIElement_Action1(UIElement* element) {
|
||||
u32 tmp = gUnk_080C9058[element->unk_6++];
|
||||
sub_0805ECEC(0, tmp, tmp, 0);
|
||||
if (tmp == 0) {
|
||||
element->action = 2;
|
||||
element->type = UI_ELEMENT_EZLONAGACTIVE;
|
||||
gUnk_0200AF00.ezloNagFuncIndex = 3;
|
||||
SoundReq(SFX_EZLO_UI);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0801CF60(Element* arg0) {
|
||||
|
||||
if ((gUnk_0200AF00.ezloNagFuncIndex >= 5) || (gMessage.doTextBox & 0x7f)) {
|
||||
arg0->unk4 = 0;
|
||||
arg0->unk0 &= -3;
|
||||
void EzloNagUIElement_Action2(UIElement* element) {
|
||||
if (gUnk_0200AF00.ezloNagFuncIndex >= 5 || (gMessage.doTextBox & 0x7f)) {
|
||||
element->action = 0;
|
||||
element->unk_0_1 = 0;
|
||||
return;
|
||||
}
|
||||
sub_0801CAD0(arg0);
|
||||
if (arg0->unk13 == 1) {
|
||||
sub_0801CAD0(element);
|
||||
if (element->frameSettings == 1) {
|
||||
gUnk_0200AF00.ezloNagFuncIndex = 4;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user