mirror of https://github.com/zeldaret/tmc.git
Patch 1 (#692)
* True Match sub_080A5F48 matched sub_080A5F48 using typecast on Div. * True Match DrawChargeBar Matched DrawChargeBar using typecast on Div * Update ui.c changed gUnk_0200AF00 to gHUD. this change is not yet in the repo, which the nonmatch website uses * Update ui.c changes to how my code looks * Update ui.c ; * Update pauseMenu.c * Update ui.c * Update ui.c whitespace... * Update pauseMenu.c fighting with the lint system * Update ui.c that should be the right format now
This commit is contained in:
parent
d8a9e54fa9
commit
1a3f9e05d3
|
@ -1232,15 +1232,26 @@ bool32 sub_080A5F24(void) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A5F48(Item item, u32 param_2) {
|
typedef union {
|
||||||
extern u32 gSprite_082E68F4[];
|
struct {
|
||||||
u32 ammoCount;
|
s32 v1;
|
||||||
u32 tensDigit;
|
s32 v2;
|
||||||
u8* puVar2;
|
} values;
|
||||||
u32 temp1;
|
u64 raw;
|
||||||
|
} DoubleReturnValue;
|
||||||
|
|
||||||
|
void sub_080A5F48(Item item, u32 offset) {
|
||||||
|
// this funcitons signature allows the div function to return a u64 (2x 32 bit registers)
|
||||||
|
// with the result in one register and the remainder in the other
|
||||||
|
typedef u64 DivRem(u32, u32);
|
||||||
|
|
||||||
|
s32 ammoCount;
|
||||||
|
s32 onesDigit;
|
||||||
|
s32 tensDigit;
|
||||||
|
void* dest;
|
||||||
u16* temp2;
|
u16* temp2;
|
||||||
u32 temp3;
|
u32 index;
|
||||||
register u32 rem asm("r1");
|
DoubleReturnValue ret;
|
||||||
|
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case ITEM_BOTTLE1:
|
case ITEM_BOTTLE1:
|
||||||
|
@ -1248,17 +1259,14 @@ void sub_080A5F48(Item item, u32 param_2) {
|
||||||
case ITEM_BOTTLE3:
|
case ITEM_BOTTLE3:
|
||||||
case ITEM_BOTTLE4:
|
case ITEM_BOTTLE4:
|
||||||
item = gSave.stats.bottles[item - ITEM_BOTTLE1];
|
item = gSave.stats.bottles[item - ITEM_BOTTLE1];
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
temp1 = param_2 * 0x20 + 0x6010000;
|
dest = OBJ_VRAM0 + (offset * 0x20);
|
||||||
temp3 = gSpriteAnimations_322[item]->index;
|
index = gSpriteAnimations_322[item]->index;
|
||||||
temp2 = &gMoreSpritePtrs[1][temp3 * 2];
|
temp2 = &gMoreSpritePtrs[1][index * 2];
|
||||||
DmaCopy32(3, &gMoreSpritePtrs[2][temp2[1] * 0x10], temp1, 0x40 * 4);
|
DmaCopy32(3, &gMoreSpritePtrs[2][temp2[1] * 0x10], dest, 0x40 * 4);
|
||||||
ammoCount = -1;
|
|
||||||
|
|
||||||
|
ammoCount = -1;
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -1270,15 +1278,18 @@ void sub_080A5F48(Item item, u32 param_2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 < (int)ammoCount) {
|
if (ammoCount < 0)
|
||||||
tensDigit = Div(ammoCount, 10);
|
return;
|
||||||
item = rem;
|
|
||||||
if ((int)tensDigit >= 10) {
|
ret.raw = ((DivRem*)Div)(ammoCount, 10); // by casting to DivRem, we can recover the remainder from the Div call
|
||||||
tensDigit = 9;
|
onesDigit = ret.values.v2;
|
||||||
}
|
tensDigit = ret.values.v1;
|
||||||
DmaCopy32(3, gUnk_085C4620 + tensDigit * 0x8, temp1, 0x8 * 4);
|
|
||||||
DmaCopy32(3, gUnk_085C4620 + (item + 10) * 0x8, temp1 + 0x20, 0x8 * 4);
|
if (tensDigit >= 10)
|
||||||
}
|
tensDigit = 9;
|
||||||
|
|
||||||
|
DmaCopy32(3, gUnk_085C4620 + tensDigit * 0x8, dest, 0x8 * 4);
|
||||||
|
DmaCopy32(3, gUnk_085C4620 + (onesDigit + 10) * 0x8, dest + 0x20, 0x8 * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PauseMenu_Screen_7(void) {
|
void PauseMenu_Screen_7(void) {
|
||||||
|
|
81
src/ui.c
81
src/ui.c
|
@ -440,43 +440,52 @@ void EraseChargeBar(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
u32 values[2];
|
||||||
|
u64 raw;
|
||||||
|
} returnValues;
|
||||||
|
|
||||||
|
typedef u64 DivRem(u32, u32);
|
||||||
|
|
||||||
void DrawChargeBar(void) {
|
void DrawChargeBar(void) {
|
||||||
bool32 tmp1;
|
bool32 tmp1;
|
||||||
u16* ptr1;
|
u16* BufferPos;
|
||||||
u32 tmp2;
|
returnValues ret;
|
||||||
u32 tmp3;
|
// these names are almost certainly inaccurate
|
||||||
register u32 rem asm("r1");
|
u32 chargeTime;
|
||||||
u32 tmp5;
|
u32 chargeState;
|
||||||
|
u32 chargeFrame;
|
||||||
|
|
||||||
tmp1 = FALSE;
|
tmp1 = FALSE;
|
||||||
if ((gHUD.hideFlags & HUD_HIDE_CHARGE_BAR) == 0) {
|
if (!(gHUD.hideFlags & HUD_HIDE_CHARGE_BAR))
|
||||||
tmp1 = gPlayerState.chargeState.action != 0;
|
tmp1 = gPlayerState.chargeState.action != 0;
|
||||||
|
if (!tmp1) {
|
||||||
|
EraseChargeBar();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (gHUD.maxHealth > 10 * 4)
|
||||||
|
BufferPos = &gBG0Buffer[0x60];
|
||||||
|
else
|
||||||
|
BufferPos = &gBG0Buffer[0x40];
|
||||||
|
|
||||||
if (!tmp1)
|
chargeTime = Div(gPlayerState.chargeState.chargeTimer + 19, 20);
|
||||||
return EraseChargeBar();
|
if (chargeTime > 40)
|
||||||
|
chargeTime = 40;
|
||||||
|
|
||||||
if (gHUD.maxHealth > 10 * 4) {
|
if (gHUD.unk_6 == 0 || gHUD.unk_7 != chargeTime) {
|
||||||
ptr1 = &gBG0Buffer[0x60];
|
|
||||||
} else {
|
|
||||||
ptr1 = &gBG0Buffer[0x40];
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp2 = Div(gPlayerState.chargeState.chargeTimer + 19, 20);
|
|
||||||
if (tmp2 > 40) {
|
|
||||||
tmp2 = 40;
|
|
||||||
}
|
|
||||||
if (gHUD.unk_6 == 0 || gHUD.unk_7 != tmp2) {
|
|
||||||
gHUD.unk_6 = 1;
|
gHUD.unk_6 = 1;
|
||||||
gHUD.unk_7 = tmp2;
|
gHUD.unk_7 = chargeTime;
|
||||||
tmp3 = Div(tmp2, 4);
|
|
||||||
tmp5 = rem;
|
// this calls Div and returns the result in ret.values[0] and the remainder in ret.values[1]
|
||||||
ptr1[0] = 0xf016;
|
ret.raw = ((DivRem*)&Div)(chargeTime, 4);
|
||||||
ptr1[11] = 0xf416;
|
chargeState = ret.values[0];
|
||||||
DmaSet(3, gUnk_080C8F54 + (10 - tmp3), ptr1 + 1, 0x8000000a);
|
chargeFrame = ret.values[1];
|
||||||
if (tmp5 != 0) {
|
|
||||||
ptr1[tmp3 + 1] = ((tmp5 + 0x17U) & 0x3ff) | 0xf000;
|
BufferPos[0] = 0xf016;
|
||||||
}
|
BufferPos[11] = 0xf416;
|
||||||
|
DmaSet(3, &gUnk_080C8F54[10 - chargeState], BufferPos + 1, 0x8000000a);
|
||||||
|
if (chargeFrame != 0)
|
||||||
|
BufferPos[chargeState + 1] = ((chargeFrame + 0x17U) & 0x3ff) | 0xf000;
|
||||||
gScreen.bg0.updated = 1;
|
gScreen.bg0.updated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,18 +493,20 @@ void DrawChargeBar(void) {
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
gHUD.unk_9 += (gPlayerState.chargeState.action == 4) ? 2 : 1;
|
gHUD.unk_9 += (gPlayerState.chargeState.action == 4) ? 2 : 1;
|
||||||
tmp3 = gHUD.unk_9 >> 4 & 3;
|
chargeState = gHUD.unk_9 >> 4 & 3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tmp3 = 0;
|
chargeState = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp3 != gHUD.unk_8) {
|
if (chargeState == gHUD.unk_8)
|
||||||
gHUD.unk_8 = tmp3;
|
return;
|
||||||
ptr1 = (u16*)0x600c2c0;
|
|
||||||
DmaSet(3, gUnk_080C8F7C[tmp3], ptr1, 0x84000030);
|
gHUD.unk_8 = chargeState;
|
||||||
}
|
|
||||||
|
BufferPos = (u16*)(VRAM + 0xc2c0);
|
||||||
|
DmaSet(3, gUnk_080C8F7C[chargeState], BufferPos, 0x84000030);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawKeys(void) {
|
void DrawKeys(void) {
|
||||||
|
|
Loading…
Reference in New Issue