Skip to content

Commit 75be33b

Browse files
committed
bodyprog: fix Gfx_Inventory_2dBackgroundDraw
1 parent 10a7bfb commit 75be33b

File tree

1 file changed

+22
-44
lines changed

1 file changed

+22
-44
lines changed

src/bodyprog/items/item_screens_3.c

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,6 @@ void func_8004FB0C(void) // 0x8004FB0C
10701070
GsOUT_PACKET_P = (PACKET*)poly + sizeof(POLY_F4);
10711071
}
10721072

1073-
// TODO: RODATA migration.
1074-
//
1075-
// Function isn't fully matching.
1076-
// `new_var -= SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vx` is mismatched
1077-
// Scratch: https://decomp.me/scratch/pGIn2
1078-
#ifdef NON_MATCHING
10791073
/** Draws many 2D menu elements.
10801074
* The background behind the text in the upper
10811075
* and lower part of the inventory screen, the
@@ -1084,9 +1078,6 @@ void func_8004FB0C(void) // 0x8004FB0C
10841078
*/
10851079
void Gfx_Inventory_2dBackgroundDraw(s32* arg0) // 0x8004FBCC
10861080
{
1087-
s16 ot0_7;
1088-
s16 temp_a2_2;
1089-
s16 temp_t2_3;
10901081
s32 temp_t3;
10911082
s32 temp_v1;
10921083
s32 k;
@@ -1095,11 +1086,9 @@ void Gfx_Inventory_2dBackgroundDraw(s32* arg0) // 0x8004FBCC
10951086
s32 var_t5;
10961087
s32 var_t6;
10971088
s32 new_var;
1098-
s32 new_var3;
10991089
s32 spA0;
11001090
GsOT* ot0;
11011091
GsOT* ot1;
1102-
GsOT* new_var2;
11031092
POLY_G4* poly_g4;
11041093
POLY_FT4* poly_ft4;
11051094
LINE_G2* line_g2;
@@ -1332,32 +1321,25 @@ void Gfx_Inventory_2dBackgroundDraw(s32* arg0) // 0x8004FBCC
13321321
}
13331322

13341323
temp_t3 = (Math_Cos(g_Gfx_Inventory_SelectionBordersDraw << 7) * Math_Cos(g_Gfx_Inventory_SelectionBordersDraw << 7) * 0x10) >> 0x10;
1335-
new_var = SelectionOuline_InnerLine[*arg0].field_0.vx;
1336-
new_var -= SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vx;
1337-
temp_a2_2 = SelectionOuline_InnerLine[*arg0].field_0.vx + FP_FROM((new_var) * temp_t3, Q12_SHIFT);
13381324

1339-
D_800C3B68[0][0].vx = temp_a2_2;
1340-
1341-
temp_t2_3 = SelectionOuline_InnerLine[*arg0].field_0.vy +
1342-
FP_FROM((SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vy - SelectionOuline_InnerLine[*arg0].field_0.vy) * temp_t3, Q12_SHIFT);
1343-
1344-
D_800C3B68[0][1].vx = temp_a2_2;
1345-
D_800C3B68[0][0].vy = temp_t2_3;
1325+
D_800C3B68[0][0].vx = SelectionOuline_InnerLine[*arg0].field_0.vx +
1326+
FP_FROM((new_var = SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vx - SelectionOuline_InnerLine[*arg0].field_0.vx) * temp_t3, Q12_SHIFT);
13461327

1347-
temp_a2_2 = SelectionOuline_InnerLine[*arg0].field_0.vy + SelectionOuline_InnerLine[*arg0].field_4.vy +
1348-
FP_FROM(((SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vy + SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_4.vy) -
1349-
(SelectionOuline_InnerLine[*arg0].field_0.vy + SelectionOuline_InnerLine[*arg0].field_4.vy)) * temp_t3, Q12_SHIFT);
1350-
1351-
D_800C3B68[0][1].vy = temp_a2_2;
1352-
1353-
ot0_7 = SelectionOuline_InnerLine[*arg0].field_0.vx + SelectionOuline_InnerLine[*arg0].field_4.vx +
1354-
FP_FROM(((SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vx + SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_4.vx) -
1355-
(SelectionOuline_InnerLine[*arg0].field_0.vx + SelectionOuline_InnerLine[*arg0].field_4.vx)) * temp_t3, Q12_SHIFT);
1328+
D_800C3B68[0][0].vy = SelectionOuline_InnerLine[*arg0].field_0.vy +
1329+
FP_FROM((SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vy - SelectionOuline_InnerLine[*arg0].field_0.vy) * temp_t3, Q12_SHIFT);
1330+
1331+
D_800C3B68[0][1].vx = D_800C3B68[0][0].vx;
1332+
1333+
D_800C3B68[0][1].vy = SelectionOuline_InnerLine[*arg0].field_0.vy + SelectionOuline_InnerLine[*arg0].field_4.vy +
1334+
FP_FROM(((SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vy + SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_4.vy) -
1335+
(SelectionOuline_InnerLine[*arg0].field_0.vy + SelectionOuline_InnerLine[*arg0].field_4.vy)) * temp_t3, Q12_SHIFT);
13561336

1357-
D_800C3B68[0][2].vy = temp_a2_2;
1358-
D_800C3B68[0][3].vy = temp_t2_3;
1359-
D_800C3B68[0][2].vx = ot0_7;
1360-
D_800C3B68[0][3].vx = ot0_7;
1337+
D_800C3B68[0][2].vx = SelectionOuline_InnerLine[*arg0].field_0.vx + SelectionOuline_InnerLine[*arg0].field_4.vx +
1338+
FP_FROM(((SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_0.vx + SelectionOuline_InnerLine[g_Inventory_PrevSelectionId].field_4.vx) -
1339+
(SelectionOuline_InnerLine[*arg0].field_0.vx + SelectionOuline_InnerLine[*arg0].field_4.vx)) * temp_t3, Q12_SHIFT);
1340+
D_800C3B68[0][3].vx = D_800C3B68[0][2].vx;
1341+
D_800C3B68[0][2].vy = D_800C3B68[0][1].vy;
1342+
D_800C3B68[0][3].vy = D_800C3B68[0][0].vy;
13611343

13621344
if (*arg0 == 8 || g_GameWork.gameStateStep_598[1] == 0xF)
13631345
{
@@ -1469,8 +1451,11 @@ void Gfx_Inventory_2dBackgroundDraw(s32* arg0) // 0x8004FBCC
14691451

14701452
setRGB0(line_g2, 0x60 - (0x20 * j), 0x60 - (0x20 * j), 0xFF);
14711453
setRGB1(line_g2, 0x60 - (0x20 * j), 0x60 - (0x20 * j), 0xFF);
1454+
1455+
new_var = (u16)D_800C3B68[j][i].vx;
1456+
14721457
setXY2(line_g2,
1473-
D_800C3B68[j][i].vx, D_800C3B68[j][i].vy,
1458+
new_var, D_800C3B68[j][i].vy,
14741459
D_800C3B68[j][(i + 1) & 0x3].vx, D_800C3B68[j][(i + 1) & 0x3].vy);
14751460

14761461
addPrim(&ot0->org[7], line_g2);
@@ -1518,22 +1503,15 @@ void Gfx_Inventory_2dBackgroundDraw(s32* arg0) // 0x8004FBCC
15181503
{
15191504
setXY2(line_g2, SelectionOuline_ConerLines[*arg0].field_0.vx,
15201505
(i == 1) ? (SelectionOuline_ConerLines[*arg0].field_0.vy - 1) : SelectionOuline_ConerLines[*arg0].field_0.vy,
1521-
(i != 2) ? (SelectionOuline_ConerLines[*arg0].field_0.vx + (SelectionOuline_InnerLine[*arg0].field_0.vx >> 1)) : SelectionOuline_ConerLines[*arg0].field_0.vx,
1522-
(i == 2) ? (SelectionOuline_ConerLines[*arg0].field_0.vy + (SelectionOuline_InnerLine[*arg0].field_0.vy >> 1)) :
1506+
(i != 2) ? (SelectionOuline_ConerLines[*arg0].field_0.vx + (SelectionOuline_InnerLine[*arg0].field_4.vx >> 1)) : SelectionOuline_ConerLines[*arg0].field_0.vx,
1507+
(i == 2) ? (SelectionOuline_ConerLines[*arg0].field_0.vy + (SelectionOuline_InnerLine[*arg0].field_4.vy >> 1)) :
15231508
(i == 1) ? (SelectionOuline_ConerLines[*arg0].field_0.vy - 1) : SelectionOuline_ConerLines[*arg0].field_0.vy);
15241509
}
15251510

15261511
addPrim(&ot0->org[7], line_g2);
15271512
GsOUT_PACKET_P = (PACKET*)line_g2 + sizeof(LINE_G2);
15281513
}
15291514
}
1530-
#else
1531-
INCLUDE_RODATA("asm/bodyprog/nonmatchings/items/item_screens_3", D_80027E54);
1532-
1533-
INCLUDE_RODATA("asm/bodyprog/nonmatchings/items/item_screens_3", D_80027E9C);
1534-
1535-
INCLUDE_ASM("asm/bodyprog/nonmatchings/items/item_screens_3", Gfx_Inventory_2dBackgroundDraw); // 0x8004FBCC
1536-
#endif
15371515

15381516
static inline s16 GetUvOrRandom(void)
15391517
{

0 commit comments

Comments
 (0)