match 2 field functions

This commit is contained in:
DizzyEggg
2018-11-29 21:19:00 +01:00
parent a7a317f6cc
commit f87e68379c
2 changed files with 27 additions and 277 deletions
+15 -150
View File
@@ -1709,8 +1709,18 @@ const u8 *const gElevatorFloorsTable[] = {
gText_Rooftop
};
const u16 gUnknown_085B2BF4[] = { 0x0329, 0x032a, 0x032b, 0x0331, 0x0332, 0x0333, 0x0339, 0x033a, 0x033b };
const u16 gUnknown_085B2C06[] = { 0x0329, 0x032b, 0x032a, 0x0331, 0x0333, 0x0332, 0x0339, 0x033b, 0x033a };
const u16 gUnknown_085B2BF4[][3] =
{
{0x0329, 0x032a, 0x032b},
{0x0331, 0x0332, 0x0333},
{0x0339, 0x033a, 0x033b},
};
const u16 gUnknown_085B2C06[][3] =
{
{0x0329, 0x032b, 0x032a},
{0x0331, 0x0333, 0x0332},
{0x0339, 0x033b, 0x033a},
};
void SetDepartmentStoreFloorVar(void)
{
@@ -1866,9 +1876,6 @@ static void sub_8139C2C(u16 a1, u8 a2)
}
}
// Annoyingly close but compiler wants to add all the parts of the index into the arrays
// first and then shift by one, whereas we need each individual part to shift and then be added.
#ifdef NONMATCHING
static void sub_8139C80(u8 taskId)
{
u8 x, y;
@@ -1883,7 +1890,7 @@ static void sub_8139C80(u8 taskId)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y * 3 + data[0] % 3] | 0xC00);
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | 0xC00);
}
}
}
@@ -1893,7 +1900,7 @@ static void sub_8139C80(u8 taskId)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y * 3 + data[0] % 3] | 0xC00);
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | 0xC00);
}
}
}
@@ -1906,148 +1913,6 @@ static void sub_8139C80(u8 taskId)
}
data[1]++;
}
#else
NAKED
static void sub_8139C80(u8 taskId)
{
asm_unified("push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x4\n\
lsls r0, 24\n\
lsrs r0, 24\n\
str r0, [sp]\n\
lsls r0, 2\n\
ldr r1, [sp]\n\
adds r0, r1\n\
lsls r0, 3\n\
ldr r1, =gTasks + 0x8\n\
adds r6, r0, r1\n\
movs r2, 0x2\n\
ldrsh r0, [r6, r2]\n\
cmp r0, 0x6\n\
bne _08139D7C\n\
ldrh r0, [r6]\n\
adds r0, 0x1\n\
strh r0, [r6]\n\
movs r1, 0x4\n\
ldrsh r0, [r6, r1]\n\
cmp r0, 0\n\
bne _08139D10\n\
movs r1, 0\n\
ldr r2, =gUnknown_085B2BF4\n\
mov r10, r2\n\
_08139CBA:\n\
movs r5, 0\n\
adds r7, r1, 0x7\n\
lsls r0, r1, 1\n\
adds r2, r1, 0x1\n\
mov r8, r2\n\
adds r0, r1\n\
lsls r0, 1\n\
mov r9, r0\n\
_08139CCA:\n\
adds r4, r5, 0\n\
adds r4, 0x8\n\
movs r1, 0\n\
ldrsh r0, [r6, r1]\n\
movs r1, 0x3\n\
bl __modsi3\n\
lsls r0, 16\n\
asrs r0, 15\n\
add r0, r9\n\
add r0, r10\n\
ldrh r0, [r0]\n\
movs r1, 0xC0\n\
lsls r1, 4\n\
adds r2, r1, 0\n\
orrs r2, r0\n\
adds r0, r4, 0\n\
adds r1, r7, 0\n\
bl MapGridSetMetatileIdAt\n\
adds r0, r5, 0x1\n\
lsls r0, 24\n\
lsrs r5, r0, 24\n\
cmp r5, 0x2\n\
bls _08139CCA\n\
mov r2, r8\n\
lsls r0, r2, 24\n\
lsrs r1, r0, 24\n\
cmp r1, 0x2\n\
bls _08139CBA\n\
b _08139D62\n\
.pool\n\
_08139D10:\n\
movs r1, 0\n\
ldr r0, =gUnknown_085B2C06\n\
mov r10, r0\n\
_08139D16:\n\
movs r5, 0\n\
adds r7, r1, 0x7\n\
lsls r0, r1, 1\n\
adds r2, r1, 0x1\n\
mov r8, r2\n\
adds r0, r1\n\
lsls r0, 1\n\
mov r9, r0\n\
_08139D26:\n\
adds r4, r5, 0\n\
adds r4, 0x8\n\
movs r1, 0\n\
ldrsh r0, [r6, r1]\n\
movs r1, 0x3\n\
bl __modsi3\n\
lsls r0, 16\n\
asrs r0, 15\n\
add r0, r9\n\
add r0, r10\n\
ldrh r0, [r0]\n\
movs r1, 0xC0\n\
lsls r1, 4\n\
adds r2, r1, 0\n\
orrs r2, r0\n\
adds r0, r4, 0\n\
adds r1, r7, 0\n\
bl MapGridSetMetatileIdAt\n\
adds r0, r5, 0x1\n\
lsls r0, 24\n\
lsrs r5, r0, 24\n\
cmp r5, 0x2\n\
bls _08139D26\n\
mov r2, r8\n\
lsls r0, r2, 24\n\
lsrs r1, r0, 24\n\
cmp r1, 0x2\n\
bls _08139D16\n\
_08139D62:\n\
bl DrawWholeMapView\n\
movs r0, 0\n\
strh r0, [r6, 0x2]\n\
movs r0, 0\n\
ldrsh r1, [r6, r0]\n\
movs r2, 0x6\n\
ldrsh r0, [r6, r2]\n\
cmp r1, r0\n\
bne _08139D7C\n\
ldr r0, [sp]\n\
bl DestroyTask\n\
_08139D7C:\n\
ldrh r0, [r6, 0x2]\n\
adds r0, 0x1\n\
strh r0, [r6, 0x2]\n\
add sp, 0x4\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool");
}
#endif // NAKED
void sub_8139D98(void)
{
@@ -2069,7 +1934,7 @@ void sub_8139D98(void)
}
gSpecialVar_0x8006 = 0;
gSpecialVar_0x8007 = ivStorage[STAT_HP];
gSpecialVar_0x8007 = ivStorage[STAT_HP];
for (i = 1; i < NUM_STATS; i++)
{