decomp functions in d5a50 and fix type for widthScale and heightScale (#357)

This commit is contained in:
Rainchus 2021-08-05 03:16:57 -05:00 committed by GitHub
parent f23045e775
commit 18f0888e91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 130 deletions

View File

@ -432,8 +432,8 @@ typedef struct HudElement {
/* 0x24 */ f32 unk_24;
/* 0x28 */ f32 unkImgScale[2];
/* 0x30 */ f32 uniformScale;
/* 0x34 */ f32 widthScaleF; /* X.10 fmt (divide by 1024.0 to get float) */
/* 0x38 */ f32 heightScaleF; /* X.10 fmt (divide by 1024.0 to get float) */
/* 0x34 */ s32 widthScale; /* X.10 fmt (divide by 1024.0 to get float) */
/* 0x38 */ s32 heightScale; /* X.10 fmt (divide by 1024.0 to get float) */
/* 0x3C */ s16 renderPosX;
/* 0x3E */ s16 renderPosY;
/* 0x40 */ u8 screenPosOffset[2];

View File

@ -1,5 +1,7 @@
#include "common.h"
void free_hud_element_transform(s32 arg0);
s32 D_8014EFC0[] = { 0x00000000, };
s32 D_8014EFC4[] = { 0x00011000, };
s32 D_8014EFC8[] = { 0x00000000, };
@ -68,13 +70,39 @@ void draw_hud_element_clipped(s32 arg0) {
draw_hud_element(arg0, 0);
}
INCLUDE_ASM(s32, "d5a50_len_5fd0", draw_hud_element_2);
void draw_hud_element_2(s32 arg0) {
draw_hud_element(arg0, 1);
}
void draw_icon_2(s32 iconID) {
draw_hud_element(iconID, 2);
}
INCLUDE_ASM(s32, "d5a50_len_5fd0", set_hud_element_script);
void set_hud_element_script(s32 arg0, s32 *arg1) {
HudElement* hudElement = gHudElementList[arg0 & ~0x800];
if (arg1 == NULL) {
arg1 = D_8014EFC8;
}
hudElement->updateTimer = 1;
hudElement->widthScale = 1024;
hudElement->heightScale = 1024;
hudElement->readPos = arg1;
hudElement->startReadPos = arg1;
hudElement->ptrPropertyList = arg1;
hudElement->screenPosOffset[0] = 0;
hudElement->screenPosOffset[1] = 0;
hudElement->worldPosOffset[0] = 0;
hudElement->worldPosOffset[1] = 0;
hudElement->flags &= ~4;
hudElement->uniformScale = 1.0f;
hudElement->flags &= ~0x930;
load_hud_element(hudElement, arg1);
while (hud_element_update(hudElement) != 0) {}
}
s32* get_hud_element_script(s32 arg0) {
return gHudElementList[arg0 & ~0x800]->startReadPos;
@ -122,7 +150,17 @@ INCLUDE_ASM(s32, "d5a50_len_5fd0", ALT_clear_hud_element_cache);
INCLUDE_ASM(void, "d5a50_len_5fd0", set_hud_element_scale, s32 index, f32 scale);
INCLUDE_ASM(s32, "d5a50_len_5fd0", set_hud_element_size);
void set_hud_element_size(s32 arg0, s8 arg1) {
HudElement* hudElement = gHudElementList[arg0 & ~0x800];
hudElement->widthScale = 0x400;
hudElement->heightScale = 0x400;
hudElement->tileSizePreset = arg1;
hudElement->drawSizePreset = arg1;
hudElement->uniformScale = 1.0f;
hudElement->flags &= ~0x100;
hudElement->flags &= ~0x810;
}
INCLUDE_ASM(s32, "d5a50_len_5fd0", func_80144E4C);
@ -158,7 +196,18 @@ INCLUDE_ASM(s32, "d5a50_len_5fd0", create_hud_element_transform_B);
INCLUDE_ASM(s32, "d5a50_len_5fd0", create_hud_element_transform_C);
INCLUDE_ASM(s32, "d5a50_len_5fd0", free_hud_element_transform);
void free_hud_element_transform(s32 arg0) {
HudElement* hudElement = gHudElementList[arg0 & ~0x800];
s32* hudTransform = hudElement->hudTransform;
if (!(hudElement->flags & 0x20000)) {
func_8013A854(*hudTransform);
}
heap_free(hudElement->hudTransform);
hudElement->hudTransform = NULL;
hudElement->flags &= ~0x40030000;
}
INCLUDE_ASM(s32, "d5a50_len_5fd0", set_hud_element_transform_pos);

View File

@ -1,11 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel draw_hud_element_2
/* DAEC4 801447C4 27BDFFE8 */ addiu $sp, $sp, -0x18
/* DAEC8 801447C8 AFBF0010 */ sw $ra, 0x10($sp)
/* DAECC 801447CC 0C0510A6 */ jal draw_hud_element
/* DAED0 801447D0 24050001 */ addiu $a1, $zero, 1
/* DAED4 801447D4 8FBF0010 */ lw $ra, 0x10($sp)
/* DAED8 801447D8 03E00008 */ jr $ra
/* DAEDC 801447DC 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,36 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel free_hud_element_transform
/* DB808 80145108 27BDFFE8 */ addiu $sp, $sp, -0x18
/* DB80C 8014510C 2402F7FF */ addiu $v0, $zero, -0x801
/* DB810 80145110 00822024 */ and $a0, $a0, $v0
/* DB814 80145114 3C028015 */ lui $v0, %hi(gHudElementList)
/* DB818 80145118 8C427960 */ lw $v0, %lo(gHudElementList)($v0)
/* DB81C 8014511C 00042080 */ sll $a0, $a0, 2
/* DB820 80145120 AFBF0014 */ sw $ra, 0x14($sp)
/* DB824 80145124 AFB00010 */ sw $s0, 0x10($sp)
/* DB828 80145128 00822021 */ addu $a0, $a0, $v0
/* DB82C 8014512C 8C900000 */ lw $s0, ($a0)
/* DB830 80145130 3C030002 */ lui $v1, 2
/* DB834 80145134 8E020000 */ lw $v0, ($s0)
/* DB838 80145138 8E04001C */ lw $a0, 0x1c($s0)
/* DB83C 8014513C 00431024 */ and $v0, $v0, $v1
/* DB840 80145140 14400004 */ bnez $v0, .L80145154
/* DB844 80145144 00000000 */ nop
/* DB848 80145148 0C04EA15 */ jal func_8013A854
/* DB84C 8014514C 8C840000 */ lw $a0, ($a0)
/* DB850 80145150 8E04001C */ lw $a0, 0x1c($s0)
.L80145154:
/* DB854 80145154 0C00AB4B */ jal heap_free
/* DB858 80145158 00000000 */ nop
/* DB85C 8014515C 3C03BFFC */ lui $v1, 0xbffc
/* DB860 80145160 8E020000 */ lw $v0, ($s0)
/* DB864 80145164 3463FFFF */ ori $v1, $v1, 0xffff
/* DB868 80145168 AE00001C */ sw $zero, 0x1c($s0)
/* DB86C 8014516C 00431024 */ and $v0, $v0, $v1
/* DB870 80145170 AE020000 */ sw $v0, ($s0)
/* DB874 80145174 8FBF0014 */ lw $ra, 0x14($sp)
/* DB878 80145178 8FB00010 */ lw $s0, 0x10($sp)
/* DB87C 8014517C 03E00008 */ jr $ra
/* DB880 80145180 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,51 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel set_hud_element_script
/* DAEFC 801447FC 27BDFFE8 */ addiu $sp, $sp, -0x18
/* DAF00 80144800 2402F7FF */ addiu $v0, $zero, -0x801
/* DAF04 80144804 00822024 */ and $a0, $a0, $v0
/* DAF08 80144808 3C028015 */ lui $v0, %hi(gHudElementList)
/* DAF0C 8014480C 8C427960 */ lw $v0, %lo(gHudElementList)($v0)
/* DAF10 80144810 00042080 */ sll $a0, $a0, 2
/* DAF14 80144814 AFBF0014 */ sw $ra, 0x14($sp)
/* DAF18 80144818 AFB00010 */ sw $s0, 0x10($sp)
/* DAF1C 8014481C 00822021 */ addu $a0, $a0, $v0
/* DAF20 80144820 8C900000 */ lw $s0, ($a0)
/* DAF24 80144824 14A00003 */ bnez $a1, .L80144834
/* DAF28 80144828 0200202D */ daddu $a0, $s0, $zero
/* DAF2C 8014482C 3C058015 */ lui $a1, %hi(D_8014EFC8)
/* DAF30 80144830 24A5EFC8 */ addiu $a1, $a1, %lo(D_8014EFC8)
.L80144834:
/* DAF34 80144834 24020001 */ addiu $v0, $zero, 1
/* DAF38 80144838 A2020047 */ sb $v0, 0x47($s0)
/* DAF3C 8014483C 24020400 */ addiu $v0, $zero, 0x400
/* DAF40 80144840 AE020034 */ sw $v0, 0x34($s0)
/* DAF44 80144844 AE020038 */ sw $v0, 0x38($s0)
/* DAF48 80144848 8E020000 */ lw $v0, ($s0)
/* DAF4C 8014484C 3C013F80 */ lui $at, 0x3f80
/* DAF50 80144850 44810000 */ mtc1 $at, $f0
/* DAF54 80144854 2403FFFB */ addiu $v1, $zero, -5
/* DAF58 80144858 AE050004 */ sw $a1, 4($s0)
/* DAF5C 8014485C AE050008 */ sw $a1, 8($s0)
/* DAF60 80144860 AE05000C */ sw $a1, 0xc($s0)
/* DAF64 80144864 A2000040 */ sb $zero, 0x40($s0)
/* DAF68 80144868 A2000041 */ sb $zero, 0x41($s0)
/* DAF6C 8014486C A2000042 */ sb $zero, 0x42($s0)
/* DAF70 80144870 A2000043 */ sb $zero, 0x43($s0)
/* DAF74 80144874 00431024 */ and $v0, $v0, $v1
/* DAF78 80144878 2403F6CF */ addiu $v1, $zero, -0x931
/* DAF7C 8014487C AE020000 */ sw $v0, ($s0)
/* DAF80 80144880 00431024 */ and $v0, $v0, $v1
/* DAF84 80144884 E6000030 */ swc1 $f0, 0x30($s0)
/* DAF88 80144888 0C04FCD4 */ jal load_hud_element
/* DAF8C 8014488C AE020000 */ sw $v0, ($s0)
.L80144890:
/* DAF90 80144890 0C0505C1 */ jal hud_element_update
/* DAF94 80144894 0200202D */ daddu $a0, $s0, $zero
/* DAF98 80144898 1440FFFD */ bnez $v0, .L80144890
/* DAF9C 8014489C 00000000 */ nop
/* DAFA0 801448A0 8FBF0014 */ lw $ra, 0x14($sp)
/* DAFA4 801448A4 8FB00010 */ lw $s0, 0x10($sp)
/* DAFA8 801448A8 03E00008 */ jr $ra
/* DAFAC 801448AC 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,26 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel set_hud_element_size
/* DB4F4 80144DF4 2402F7FF */ addiu $v0, $zero, -0x801
/* DB4F8 80144DF8 00822024 */ and $a0, $a0, $v0
/* DB4FC 80144DFC 00042080 */ sll $a0, $a0, 2
/* DB500 80144E00 3C028015 */ lui $v0, %hi(gHudElementList)
/* DB504 80144E04 8C427960 */ lw $v0, %lo(gHudElementList)($v0)
/* DB508 80144E08 3C013F80 */ lui $at, 0x3f80
/* DB50C 80144E0C 44810000 */ mtc1 $at, $f0
/* DB510 80144E10 00822021 */ addu $a0, $a0, $v0
/* DB514 80144E14 8C840000 */ lw $a0, ($a0)
/* DB518 80144E18 24020400 */ addiu $v0, $zero, 0x400
/* DB51C 80144E1C AC820034 */ sw $v0, 0x34($a0)
/* DB520 80144E20 AC820038 */ sw $v0, 0x38($a0)
/* DB524 80144E24 8C820000 */ lw $v0, ($a0)
/* DB528 80144E28 2403FEFF */ addiu $v1, $zero, -0x101
/* DB52C 80144E2C A0850046 */ sb $a1, 0x46($a0)
/* DB530 80144E30 A0850045 */ sb $a1, 0x45($a0)
/* DB534 80144E34 E4800030 */ swc1 $f0, 0x30($a0)
/* DB538 80144E38 00431024 */ and $v0, $v0, $v1
/* DB53C 80144E3C 2403F7EF */ addiu $v1, $zero, -0x811
/* DB540 80144E40 00431024 */ and $v0, $v0, $v1
/* DB544 80144E44 03E00008 */ jr $ra
/* DB548 80144E48 AC820000 */ sw $v0, ($a0)