fix nonmatchings
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#ifdndef GUARD_SEA_COTTAGE_H
|
#ifndef GUARD_SEA_COTTAGE_SPECIAL_ANIM_H
|
||||||
#define GUARD_SEA_COTTAGE_H
|
#define GUARD_SEA_COTTAGE_SPECIAL_ANIM_H
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
@@ -9,4 +9,4 @@ bool8 sub_809C474(void);
|
|||||||
void sub_809C4A8(void);
|
void sub_809C4A8(void);
|
||||||
void sub_809C5FC(void);
|
void sub_809C5FC(void);
|
||||||
|
|
||||||
#endif // GUARD_SEA_COTTAGE_H
|
#endif // GUARD_SEA_COTTAGE_SPECIAL_ANIM_H
|
||||||
+20
-209
@@ -7,14 +7,9 @@
|
|||||||
#include "field_map_obj.h"
|
#include "field_map_obj.h"
|
||||||
#include "field_camera.h"
|
#include "field_camera.h"
|
||||||
|
|
||||||
#define t0 data[0]
|
|
||||||
#define tX data[4]
|
|
||||||
#define tY data[5]
|
|
||||||
#define tListTaskId data[7]
|
|
||||||
|
|
||||||
static EWRAM_DATA u8 gUnknown_2039984 = 0;
|
static EWRAM_DATA u8 gUnknown_2039984 = 0;
|
||||||
|
|
||||||
static void sub_809C1D8(u8 taskId, const u16* a1, u16 a2);
|
static void sub_809C1D8(u8 taskId, const s16 *a1, u16 a2);
|
||||||
static void sub_809C334(u8 taskId);
|
static void sub_809C334(u8 taskId);
|
||||||
static void sub_809C500(u8 taskId);
|
static void sub_809C500(u8 taskId);
|
||||||
static void sub_809C640(u8 taskId);
|
static void sub_809C640(u8 taskId);
|
||||||
@@ -28,17 +23,14 @@ static const u16 gUnknown_83DF0F2[] = {0x02e4, 0x0317, 0x0315};
|
|||||||
static const u16 gUnknown_83DF0F8[] = {0x02eb, 0x031e, 0x031c};
|
static const u16 gUnknown_83DF0F8[] = {0x02eb, 0x031e, 0x031c};
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
#ifdef NONMATCHING
|
static void sub_809C1D8(u8 taskId, const s16 *a1, u16 a2)
|
||||||
// Couldn't get the registers to match. Hard to know where to fix since I'm unsure what the variables are for.
|
|
||||||
static void sub_809C1D8(u8 taskId, const u16* a1, u16 a2)
|
|
||||||
{
|
{
|
||||||
s16 v1, v2, v3;
|
s16 r5, r3, r4;
|
||||||
s16 i, j;
|
s16 i, j;
|
||||||
const s16* v4;
|
|
||||||
|
|
||||||
v1 = gTasks[taskId].data[4] - 1;
|
r5 = gTasks[taskId].data[4] - 1;
|
||||||
v2 = gTasks[taskId].data[5] - 1;
|
r3 = gTasks[taskId].data[5] - 1;
|
||||||
v3 = gTasks[taskId].data[1];
|
r4 = gTasks[taskId].data[1];
|
||||||
|
|
||||||
if (gTasks[taskId].data[2] == 0)
|
if (gTasks[taskId].data[2] == 0)
|
||||||
{
|
{
|
||||||
@@ -46,13 +38,14 @@ static void sub_809C1D8(u8 taskId, const u16* a1, u16 a2)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
v4 = &a1[v3];
|
s32 id = MapGridGetMetatileIdAt(r5 + j, r3 + i);
|
||||||
if (MapGridGetMetatileIdAt(v1 + j, v2 + i) == v4[0])
|
|
||||||
|
if (a1[r4] == (s16)id)
|
||||||
{
|
{
|
||||||
if (v3 != 2)
|
if (r4 != 2)
|
||||||
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | v4[1]);
|
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[r4 + 1]);
|
||||||
else
|
else
|
||||||
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | v4[0]);
|
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,201 +56,19 @@ static void sub_809C1D8(u8 taskId, const u16* a1, u16 a2)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
if (a1[2 - v3] == MapGridGetMetatileIdAt(v1 + j, v2 + i))
|
s32 id = MapGridGetMetatileIdAt(r5 + j, r3 + i);
|
||||||
|
|
||||||
|
if (a1[2 - r4] == (s16)id)
|
||||||
{
|
{
|
||||||
if (v3 != 2)
|
if (r4 != 2)
|
||||||
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | a1[1 - v3]);
|
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[1 - r4]);
|
||||||
else
|
else
|
||||||
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | a1[2]);
|
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
NAKED
|
|
||||||
void sub_809C1D8(u8 taskId, const u16* a1, u16 a2)
|
|
||||||
{
|
|
||||||
asm_unified("\tpush {r4-r7,lr}\n"
|
|
||||||
"\tmov r7, r10\n"
|
|
||||||
"\tmov r6, r9\n"
|
|
||||||
"\tmov r5, r8\n"
|
|
||||||
"\tpush {r5-r7}\n"
|
|
||||||
"\tsub sp, 0x10\n"
|
|
||||||
"\tmov r9, r1\n"
|
|
||||||
"\tlsls r0, 24\n"
|
|
||||||
"\tlsrs r0, 24\n"
|
|
||||||
"\tlsls r2, 16\n"
|
|
||||||
"\tlsrs r2, 16\n"
|
|
||||||
"\tmov r10, r2\n"
|
|
||||||
"\tldr r2, _0809C26C @ =gTasks\n"
|
|
||||||
"\tlsls r1, r0, 2\n"
|
|
||||||
"\tadds r1, r0\n"
|
|
||||||
"\tlsls r1, 3\n"
|
|
||||||
"\tadds r1, r2\n"
|
|
||||||
"\tldrh r0, [r1, 0x10]\n"
|
|
||||||
"\tsubs r0, 0x1\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tlsrs r5, r0, 16\n"
|
|
||||||
"\tldrh r0, [r1, 0x12]\n"
|
|
||||||
"\tsubs r0, 0x1\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tlsrs r3, r0, 16\n"
|
|
||||||
"\tldrh r4, [r1, 0xA]\n"
|
|
||||||
"\tmovs r2, 0xC\n"
|
|
||||||
"\tldrsh r0, [r1, r2]\n"
|
|
||||||
"\tcmp r0, 0\n"
|
|
||||||
"\tbne _0809C29C\n"
|
|
||||||
"\tmovs r2, 0\n"
|
|
||||||
"\tlsls r5, 16\n"
|
|
||||||
"\tstr r5, [sp, 0xC]\n"
|
|
||||||
"\tlsls r0, r3, 16\n"
|
|
||||||
"\tlsls r1, r4, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tstr r0, [sp]\n"
|
|
||||||
"\tasrs r1, 16\n"
|
|
||||||
"\tstr r1, [sp, 0x4]\n"
|
|
||||||
"\tlsls r0, r1, 1\n"
|
|
||||||
"\tmov r1, r9\n"
|
|
||||||
"\tadds r7, r0, r1\n"
|
|
||||||
"_0809C22C:\n"
|
|
||||||
"\tmovs r4, 0\n"
|
|
||||||
"\tlsls r2, 16\n"
|
|
||||||
"\tmov r8, r2\n"
|
|
||||||
"\tasrs r0, r2, 16\n"
|
|
||||||
"\tldr r2, [sp]\n"
|
|
||||||
"\tadds r6, r2, r0\n"
|
|
||||||
"_0809C238:\n"
|
|
||||||
"\tldr r0, [sp, 0xC]\n"
|
|
||||||
"\tasrs r1, r0, 16\n"
|
|
||||||
"\tlsls r4, 16\n"
|
|
||||||
"\tasrs r0, r4, 16\n"
|
|
||||||
"\tadds r5, r1, r0\n"
|
|
||||||
"\tadds r0, r5, 0\n"
|
|
||||||
"\tadds r1, r6, 0\n"
|
|
||||||
"\tbl MapGridGetMetatileIdAt\n"
|
|
||||||
"\tmovs r2, 0\n"
|
|
||||||
"\tldrsh r1, [r7, r2]\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tcmp r1, r0\n"
|
|
||||||
"\tbne _0809C280\n"
|
|
||||||
"\tldr r0, [sp, 0x4]\n"
|
|
||||||
"\tcmp r0, 0x2\n"
|
|
||||||
"\tbeq _0809C270\n"
|
|
||||||
"\tldrh r0, [r7, 0x2]\n"
|
|
||||||
"\tmov r2, r10\n"
|
|
||||||
"\torrs r2, r0\n"
|
|
||||||
"\tadds r0, r5, 0\n"
|
|
||||||
"\tadds r1, r6, 0\n"
|
|
||||||
"\tbl MapGridSetMetatileIdAt\n"
|
|
||||||
"\tb _0809C280\n"
|
|
||||||
"\t.align 2, 0\n"
|
|
||||||
"_0809C26C: .4byte gTasks\n"
|
|
||||||
"_0809C270:\n"
|
|
||||||
"\tmov r1, r9\n"
|
|
||||||
"\tldrh r0, [r1]\n"
|
|
||||||
"\tmov r2, r10\n"
|
|
||||||
"\torrs r2, r0\n"
|
|
||||||
"\tadds r0, r5, 0\n"
|
|
||||||
"\tadds r1, r6, 0\n"
|
|
||||||
"\tbl MapGridSetMetatileIdAt\n"
|
|
||||||
"_0809C280:\n"
|
|
||||||
"\tmovs r2, 0x80\n"
|
|
||||||
"\tlsls r2, 9\n"
|
|
||||||
"\tadds r0, r4, r2\n"
|
|
||||||
"\tlsrs r4, r0, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tcmp r0, 0x2\n"
|
|
||||||
"\tble _0809C238\n"
|
|
||||||
"\tadds r0, r2, 0\n"
|
|
||||||
"\tadd r0, r8\n"
|
|
||||||
"\tlsrs r2, r0, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tcmp r0, 0x2\n"
|
|
||||||
"\tble _0809C22C\n"
|
|
||||||
"\tb _0809C324\n"
|
|
||||||
"_0809C29C:\n"
|
|
||||||
"\tmovs r2, 0\n"
|
|
||||||
"\tlsls r5, 16\n"
|
|
||||||
"\tstr r5, [sp, 0xC]\n"
|
|
||||||
"\tlsls r0, r3, 16\n"
|
|
||||||
"\tlsls r1, r4, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tstr r0, [sp, 0x8]\n"
|
|
||||||
"\tasrs r7, r1, 16\n"
|
|
||||||
"_0809C2AC:\n"
|
|
||||||
"\tmovs r4, 0\n"
|
|
||||||
"\tlsls r2, 16\n"
|
|
||||||
"\tmov r8, r2\n"
|
|
||||||
"\tasrs r0, r2, 16\n"
|
|
||||||
"\tldr r1, [sp, 0x8]\n"
|
|
||||||
"\tadds r6, r1, r0\n"
|
|
||||||
"_0809C2B8:\n"
|
|
||||||
"\tldr r2, [sp, 0xC]\n"
|
|
||||||
"\tasrs r1, r2, 16\n"
|
|
||||||
"\tlsls r4, 16\n"
|
|
||||||
"\tasrs r0, r4, 16\n"
|
|
||||||
"\tadds r5, r1, r0\n"
|
|
||||||
"\tadds r0, r5, 0\n"
|
|
||||||
"\tadds r1, r6, 0\n"
|
|
||||||
"\tbl MapGridGetMetatileIdAt\n"
|
|
||||||
"\tmovs r1, 0x2\n"
|
|
||||||
"\tsubs r1, r7\n"
|
|
||||||
"\tlsls r1, 1\n"
|
|
||||||
"\tadd r1, r9\n"
|
|
||||||
"\tmovs r2, 0\n"
|
|
||||||
"\tldrsh r1, [r1, r2]\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tcmp r1, r0\n"
|
|
||||||
"\tbne _0809C30A\n"
|
|
||||||
"\tcmp r7, 0x2\n"
|
|
||||||
"\tbeq _0809C2FA\n"
|
|
||||||
"\tmovs r0, 0x1\n"
|
|
||||||
"\tsubs r0, r7\n"
|
|
||||||
"\tlsls r0, 1\n"
|
|
||||||
"\tadd r0, r9\n"
|
|
||||||
"\tldrh r0, [r0]\n"
|
|
||||||
"\tmov r2, r10\n"
|
|
||||||
"\torrs r2, r0\n"
|
|
||||||
"\tadds r0, r5, 0\n"
|
|
||||||
"\tadds r1, r6, 0\n"
|
|
||||||
"\tbl MapGridSetMetatileIdAt\n"
|
|
||||||
"\tb _0809C30A\n"
|
|
||||||
"_0809C2FA:\n"
|
|
||||||
"\tmov r1, r9\n"
|
|
||||||
"\tldrh r0, [r1, 0x4]\n"
|
|
||||||
"\tmov r2, r10\n"
|
|
||||||
"\torrs r2, r0\n"
|
|
||||||
"\tadds r0, r5, 0\n"
|
|
||||||
"\tadds r1, r6, 0\n"
|
|
||||||
"\tbl MapGridSetMetatileIdAt\n"
|
|
||||||
"_0809C30A:\n"
|
|
||||||
"\tmovs r2, 0x80\n"
|
|
||||||
"\tlsls r2, 9\n"
|
|
||||||
"\tadds r0, r4, r2\n"
|
|
||||||
"\tlsrs r4, r0, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tcmp r0, 0x2\n"
|
|
||||||
"\tble _0809C2B8\n"
|
|
||||||
"\tadds r0, r2, 0\n"
|
|
||||||
"\tadd r0, r8\n"
|
|
||||||
"\tlsrs r2, r0, 16\n"
|
|
||||||
"\tasrs r0, 16\n"
|
|
||||||
"\tcmp r0, 0x2\n"
|
|
||||||
"\tble _0809C2AC\n"
|
|
||||||
"_0809C324:\n"
|
|
||||||
"\tadd sp, 0x10\n"
|
|
||||||
"\tpop {r3-r5}\n"
|
|
||||||
"\tmov r8, r3\n"
|
|
||||||
"\tmov r9, r4\n"
|
|
||||||
"\tmov r10, r5\n"
|
|
||||||
"\tpop {r4-r7}\n"
|
|
||||||
"\tpop {r0}\n"
|
|
||||||
"\tbx r0\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void sub_809C334(u8 taskId)
|
static void sub_809C334(u8 taskId)
|
||||||
{
|
{
|
||||||
@@ -308,8 +119,8 @@ static u8 sub_809C3FC(u16 a0)
|
|||||||
|
|
||||||
taskId = CreateTask(sub_809C334, 0);
|
taskId = CreateTask(sub_809C334, 0);
|
||||||
data = gTasks[taskId].data;
|
data = gTasks[taskId].data;
|
||||||
PlayerGetDestCoords(&tX, &tY);
|
PlayerGetDestCoords(&data[4], &data[5]);
|
||||||
t0 = 0;
|
data[0] = 0;
|
||||||
data[1] = 0;
|
data[1] = 0;
|
||||||
data[2] = a0;
|
data[2] = a0;
|
||||||
sub_809C334(taskId);
|
sub_809C334(taskId);
|
||||||
|
|||||||
+80
-200
@@ -87,13 +87,7 @@ struct MartHistory
|
|||||||
/*0x09*/ u8 unk9;
|
/*0x09*/ u8 unk9;
|
||||||
/*0x0A*/ u8 unkA;
|
/*0x0A*/ u8 unkA;
|
||||||
/*0x0B*/ u8 unkB;
|
/*0x0B*/ u8 unkB;
|
||||||
/*0x0C*/ u16 unkC;
|
}; /* size = 12 */
|
||||||
/*0x0E*/ u8 unkE[6];
|
|
||||||
/*0x14*/ u8 unk14;
|
|
||||||
/*0x15*/ u8 unk15;
|
|
||||||
/*0x16*/ u8 unk16;
|
|
||||||
/*0x17*/ u8 unk17;
|
|
||||||
}; /* size = 0x18 */
|
|
||||||
|
|
||||||
static EWRAM_DATA s16 sViewportMapObjects[MAP_OBJECTS_COUNT][4] = {0};
|
static EWRAM_DATA s16 sViewportMapObjects[MAP_OBJECTS_COUNT][4] = {0};
|
||||||
EWRAM_DATA struct ShopData gShopData = {0};
|
EWRAM_DATA struct ShopData gShopData = {0};
|
||||||
@@ -104,11 +98,11 @@ EWRAM_DATA u16 (*gShopTilemapBuffer3)[0x400] = {0};
|
|||||||
EWRAM_DATA u16 (*gShopTilemapBuffer4)[0x400] = {0};
|
EWRAM_DATA u16 (*gShopTilemapBuffer4)[0x400] = {0};
|
||||||
EWRAM_DATA struct ListMenuItem *sShopMenuListMenu = {0};
|
EWRAM_DATA struct ListMenuItem *sShopMenuListMenu = {0};
|
||||||
static EWRAM_DATA u8 (*sShopMenuItemStrings)[13] = {0};
|
static EWRAM_DATA u8 (*sShopMenuItemStrings)[13] = {0};
|
||||||
EWRAM_DATA struct MartHistory gShopMenuHistory = {0};
|
EWRAM_DATA struct MartHistory gShopMenuHistory[2] = {0};
|
||||||
|
|
||||||
//Function Declarations
|
//Function Declarations
|
||||||
static u8 CreateShopMenu(u8 a0);
|
static u8 CreateShopMenu(u8 a0);
|
||||||
static bool8 GetMartTypeFromItemList(bool32 a0);
|
static u8 GetMartTypeFromItemList(u32 a0);
|
||||||
static void SetShopItemsForSale(const u16 *items);
|
static void SetShopItemsForSale(const u16 *items);
|
||||||
static void SetShopMenuCallback(MainCallback callback);
|
static void SetShopMenuCallback(MainCallback callback);
|
||||||
static void Task_ShopMenu(u8 taskId);
|
static void Task_ShopMenu(u8 taskId);
|
||||||
@@ -230,7 +224,7 @@ static const struct BgTemplate sShopBuyMenuBgTemplates[4] =
|
|||||||
// Functions
|
// Functions
|
||||||
static u8 CreateShopMenu(u8 a0)
|
static u8 CreateShopMenu(u8 a0)
|
||||||
{
|
{
|
||||||
gShopData.martType = GetMartTypeFromItemList(a0) & 0xF;
|
gShopData.martType = GetMartTypeFromItemList(a0);
|
||||||
gShopData.selectedRow = 0;
|
gShopData.selectedRow = 0;
|
||||||
if (ContextNpcGetTextColor() == 0)
|
if (ContextNpcGetTextColor() == 0)
|
||||||
gShopData.unk16_4 = 4;
|
gShopData.unk16_4 = 4;
|
||||||
@@ -246,56 +240,35 @@ static u8 CreateShopMenu(u8 a0)
|
|||||||
return CreateTask(Task_ShopMenu, 8);
|
return CreateTask(Task_ShopMenu, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool8 GetMartTypeFromItemList(bool32 a0)
|
static u8 GetMartTypeFromItemList(u32 a0)
|
||||||
{
|
{
|
||||||
u16 i;
|
u16 i;
|
||||||
|
|
||||||
if (a0)
|
if (a0)
|
||||||
return (u8)a0;
|
return a0;
|
||||||
goto MAIN;
|
|
||||||
|
|
||||||
RETURN_1:
|
for (i = 0; i < gShopData.itemCount && gShopData.itemList[i] != 0; i++)
|
||||||
return 1;
|
|
||||||
|
|
||||||
MAIN:
|
|
||||||
i = 0;
|
|
||||||
if (i >= gShopData.itemCount)
|
|
||||||
goto RETURN_0;
|
|
||||||
else if (gShopData.itemList[0] == 0)
|
|
||||||
goto RETURN_0;
|
|
||||||
|
|
||||||
while (gShopData.itemList[i] != 0)
|
|
||||||
{
|
{
|
||||||
if (ItemId_GetPocket(gShopData.itemList[i]) == POCKET_TM_CASE)
|
if (ItemId_GetPocket(gShopData.itemList[i]) == POCKET_TM_CASE)
|
||||||
goto RETURN_1;
|
return 1;
|
||||||
++i;
|
|
||||||
if (i >= gShopData.itemCount)
|
|
||||||
goto RETURN_0;
|
|
||||||
else if (gShopData.itemList[i] == 0)
|
|
||||||
goto RETURN_0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_0:
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetShopItemsForSale(const u16 *items)
|
static void SetShopItemsForSale(const u16 *items)
|
||||||
{
|
{
|
||||||
struct ShopData *mart;
|
gShopData.itemList = items;
|
||||||
|
gShopData.itemCount = 0;
|
||||||
mart = &gShopData;
|
if (gShopData.itemList[0] == 0)
|
||||||
mart->itemList = items;
|
|
||||||
mart->itemCount = 0;
|
|
||||||
if (mart->itemList[0] == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do
|
while (gShopData.itemList[gShopData.itemCount])
|
||||||
{
|
{
|
||||||
++gShopData.itemCount;
|
++gShopData.itemCount;
|
||||||
} while (mart->itemList[gShopData.itemCount]);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetShopMenuCallback(MainCallback callback)
|
static void SetShopMenuCallback(void (*callback)(void))
|
||||||
{
|
{
|
||||||
gShopData.callback = callback;
|
gShopData.callback = callback;
|
||||||
}
|
}
|
||||||
@@ -416,7 +389,7 @@ static void CB2_InitBuyMenu(void)
|
|||||||
ResetTasks();
|
ResetTasks();
|
||||||
ClearScheduledBgCopiesToVram();
|
ClearScheduledBgCopiesToVram();
|
||||||
ResetItemMenuIconState();
|
ResetItemMenuIconState();
|
||||||
if ((!(InitShopData())) || (!(BuyMenuBuildListMenuTemplate())))
|
if (!(InitShopData()) || !(BuyMenuBuildListMenuTemplate()))
|
||||||
return;
|
return;
|
||||||
BuyMenuInitBgs();
|
BuyMenuInitBgs();
|
||||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
||||||
@@ -451,25 +424,37 @@ static bool8 InitShopData(void)
|
|||||||
{
|
{
|
||||||
gShopTilemapBuffer1 = Alloc(sizeof(*gShopTilemapBuffer1));
|
gShopTilemapBuffer1 = Alloc(sizeof(*gShopTilemapBuffer1));
|
||||||
if (gShopTilemapBuffer1 == NULL)
|
if (gShopTilemapBuffer1 == NULL)
|
||||||
goto CANCEL;
|
{
|
||||||
|
|
||||||
gShopTilemapBuffer2 = Alloc(sizeof(*gShopTilemapBuffer2));
|
|
||||||
if (gShopTilemapBuffer2 == NULL)
|
|
||||||
goto CANCEL;
|
|
||||||
|
|
||||||
gShopTilemapBuffer3 = Alloc(sizeof(*gShopTilemapBuffer3));
|
|
||||||
if (gShopTilemapBuffer3 == NULL)
|
|
||||||
goto CANCEL;
|
|
||||||
|
|
||||||
gShopTilemapBuffer4 = Alloc(sizeof(*gShopTilemapBuffer4));
|
|
||||||
if (gShopTilemapBuffer4 == NULL)
|
|
||||||
goto CANCEL;
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
CANCEL:
|
|
||||||
BuyMenuFreeMemory();
|
BuyMenuFreeMemory();
|
||||||
SetShopExitCallback();
|
SetShopExitCallback();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gShopTilemapBuffer2 = Alloc(sizeof(*gShopTilemapBuffer2));
|
||||||
|
if (gShopTilemapBuffer2 == NULL)
|
||||||
|
{
|
||||||
|
BuyMenuFreeMemory();
|
||||||
|
SetShopExitCallback();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gShopTilemapBuffer3 = Alloc(sizeof(*gShopTilemapBuffer3));
|
||||||
|
if (gShopTilemapBuffer3 == NULL)
|
||||||
|
{
|
||||||
|
BuyMenuFreeMemory();
|
||||||
|
SetShopExitCallback();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gShopTilemapBuffer4 = Alloc(sizeof(*gShopTilemapBuffer4));
|
||||||
|
if (gShopTilemapBuffer4 == NULL)
|
||||||
|
{
|
||||||
|
BuyMenuFreeMemory();
|
||||||
|
SetShopExitCallback();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BuyMenuInitBgs(void)
|
static void BuyMenuInitBgs(void)
|
||||||
@@ -540,35 +525,25 @@ static void BuyMenuDrawGraphics(void)
|
|||||||
ScheduleBgCopyTilemapToVram(3);
|
ScheduleBgCopyTilemapToVram(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool8 BuyMenuBuildListMenuTemplate(void)
|
bool8 BuyMenuBuildListMenuTemplate(void)
|
||||||
{
|
{
|
||||||
u16 i, v;
|
u16 i, v;
|
||||||
struct ListMenuItem **list = &sShopMenuListMenu;
|
|
||||||
struct ShopData *mart = &gShopData;
|
|
||||||
|
|
||||||
*list = Alloc((gShopData.itemCount + 1) * sizeof(*sShopMenuListMenu));
|
sShopMenuListMenu = Alloc((gShopData.itemCount + 1) * sizeof(*sShopMenuListMenu));
|
||||||
if (sShopMenuListMenu == NULL)
|
if (sShopMenuListMenu == NULL
|
||||||
goto FREE_MEMORY;
|
|| (sShopMenuItemStrings = Alloc((gShopData.itemCount + 1) * sizeof(*sShopMenuItemStrings))) == NULL)
|
||||||
|
|
||||||
sShopMenuItemStrings = Alloc((gShopData.itemCount + 1) * sizeof(*sShopMenuItemStrings));
|
|
||||||
if (sShopMenuItemStrings == NULL)
|
|
||||||
{
|
{
|
||||||
FREE_MEMORY:
|
|
||||||
BuyMenuFreeMemory();
|
BuyMenuFreeMemory();
|
||||||
SetShopExitCallback();
|
SetShopExitCallback();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (i >= mart->itemCount)
|
|
||||||
goto ADD_CANCEL;
|
|
||||||
|
|
||||||
for (i = 0; i < mart->itemCount; i++)
|
for (i = 0; i < gShopData.itemCount; i++)
|
||||||
{
|
{
|
||||||
PokeMartWriteNameAndIdAt(&sShopMenuListMenu[i], mart->itemList[i], sShopMenuItemStrings[i]);
|
PokeMartWriteNameAndIdAt(&sShopMenuListMenu[i], gShopData.itemList[i], sShopMenuItemStrings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ADD_CANCEL:
|
|
||||||
StringCopy(sShopMenuItemStrings[i], gFameCheckerText_Cancel);
|
StringCopy(sShopMenuItemStrings[i], gFameCheckerText_Cancel);
|
||||||
sShopMenuListMenu[i].label = sShopMenuItemStrings[i];
|
sShopMenuListMenu[i].label = sShopMenuItemStrings[i];
|
||||||
sShopMenuListMenu[i].index = -2;
|
sShopMenuListMenu[i].index = -2;
|
||||||
@@ -801,7 +776,7 @@ static void BuyMenuDrawMapBg(void)
|
|||||||
static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLayerType)
|
static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLayerType)
|
||||||
{
|
{
|
||||||
u16 offset1 = x * 2;
|
u16 offset1 = x * 2;
|
||||||
u16 offset2 = ((y << 0x16) + 0x400000) >> 0x10;
|
u16 offset2 = (y * 64) + 64;
|
||||||
|
|
||||||
switch (metatileLayerType)
|
switch (metatileLayerType)
|
||||||
{
|
{
|
||||||
@@ -1091,7 +1066,7 @@ static void Task_ExitBuyMenu(u8 taskId)
|
|||||||
|
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
DestroyListMenuTask(tListTaskId, 0, 0);
|
DestroyListMenuTask(tListTaskId, NULL, NULL);
|
||||||
BuyMenuFreeMemory();
|
BuyMenuFreeMemory();
|
||||||
SetMainCallback2(CB2_ReturnToField);
|
SetMainCallback2(CB2_ReturnToField);
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
@@ -1106,154 +1081,59 @@ static void nullsub_53(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NONMATCHING
|
|
||||||
// couldn't get registers to match. It should store an address into r4 (what tmp wants to be), and load/store from there, eg. ldrh r0, [r4,#4]. Which indicates an array inside the MartHistory struct, except data sizes are not consistent.
|
|
||||||
void RecordItemPurchase(u16 item, u16 quantity, u8 a2)
|
void RecordItemPurchase(u16 item, u16 quantity, u8 a2)
|
||||||
{
|
{
|
||||||
struct MartHistory *tmp;
|
struct MartHistory *history;
|
||||||
|
|
||||||
if (gShopMenuHistory.unkA == a2)
|
if (gShopMenuHistory[0].unkA == a2)
|
||||||
{
|
{
|
||||||
tmp = &gShopMenuHistory;
|
history = &gShopMenuHistory[0];
|
||||||
|
}
|
||||||
|
else if (gShopMenuHistory[1].unkA == a2)
|
||||||
|
{
|
||||||
|
history = &gShopMenuHistory[1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gShopMenuHistory.unk16 == a2)
|
if (gShopMenuHistory[0].unkA == 0)
|
||||||
{
|
history = &gShopMenuHistory[0];
|
||||||
tmp = &gShopMenuHistory + 12;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
history = &gShopMenuHistory[1];
|
||||||
tmp = &gShopMenuHistory + 12;
|
history->unkA = a2;
|
||||||
if (gShopMenuHistory.unkA == 0)
|
|
||||||
{
|
|
||||||
tmp = &gShopMenuHistory;
|
|
||||||
gShopMenuHistory.unkA = a2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp->unk4 != 0)
|
if (history->unk4 != 0)
|
||||||
{
|
{
|
||||||
gShopMenuHistory.unk9 = 1;
|
history->unk9 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gShopMenuHistory.unk4 = item;
|
history->unk4 = item;
|
||||||
if (gShopMenuHistory.unk6 <= 998)
|
if (history->unk6 < 999)
|
||||||
{
|
{
|
||||||
gShopMenuHistory.unk6 += item;
|
history->unk6 += quantity;
|
||||||
if (item > 999)
|
if (history->unk6 > 999)
|
||||||
gShopMenuHistory.unk6 = 999;
|
history->unk6 = 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gShopMenuHistory.unk0 < 999998)
|
if (history->unk0 < 999999)
|
||||||
{
|
{
|
||||||
gShopMenuHistory.unk0 += ((s16)itemid_get_market_price(item) >> (quantity-1))*quantity;
|
history->unk0 += (itemid_get_market_price(item) >> (a2 - 1)) * quantity;
|
||||||
if (gShopMenuHistory.unk0 > 999999)
|
if (history->unk0 > 999999)
|
||||||
gShopMenuHistory.unk0 = 999999;
|
history->unk0 = 999999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
NAKED
|
|
||||||
void RecordItemPurchase(u16 item, u16 quantity, u8 a2)
|
|
||||||
{
|
|
||||||
asm_unified("\tpush {r4-r6,lr}\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tlsrs r3, r0, 16\n"
|
|
||||||
"\tlsls r1, 16\n"
|
|
||||||
"\tlsrs r6, r1, 16\n"
|
|
||||||
"\tlsls r2, 24\n"
|
|
||||||
"\tlsrs r5, r2, 24\n"
|
|
||||||
"\tldr r1, _0809C0B8 @ =gShopMenuHistory\n"
|
|
||||||
"\tldrb r2, [r1, 0xA]\n"
|
|
||||||
"\tcmp r2, r5\n"
|
|
||||||
"\tbne _0809C0BC\n"
|
|
||||||
"\tadds r4, r1, 0\n"
|
|
||||||
"\tb _0809C0D4\n"
|
|
||||||
"\t.align 2, 0\n"
|
|
||||||
"_0809C0B8: .4byte gShopMenuHistory\n"
|
|
||||||
"_0809C0BC:\n"
|
|
||||||
"\tldrb r0, [r1, 0x16]\n"
|
|
||||||
"\tcmp r0, r5\n"
|
|
||||||
"\tbne _0809C0C8\n"
|
|
||||||
"\tadds r4, r1, 0\n"
|
|
||||||
"\tadds r4, 0xC\n"
|
|
||||||
"\tb _0809C0D4\n"
|
|
||||||
"_0809C0C8:\n"
|
|
||||||
"\tadds r4, r1, 0\n"
|
|
||||||
"\tadds r4, 0xC\n"
|
|
||||||
"\tcmp r2, 0\n"
|
|
||||||
"\tbne _0809C0D2\n"
|
|
||||||
"\tadds r4, r1, 0\n"
|
|
||||||
"_0809C0D2:\n"
|
|
||||||
"\tstrb r5, [r4, 0xA]\n"
|
|
||||||
"_0809C0D4:\n"
|
|
||||||
"\tldrh r0, [r4, 0x4]\n"
|
|
||||||
"\tcmp r0, 0\n"
|
|
||||||
"\tbeq _0809C0DE\n"
|
|
||||||
"\tmovs r0, 0x1\n"
|
|
||||||
"\tstrb r0, [r4, 0x9]\n"
|
|
||||||
"_0809C0DE:\n"
|
|
||||||
"\tstrh r3, [r4, 0x4]\n"
|
|
||||||
"\tldrh r1, [r4, 0x6]\n"
|
|
||||||
"\tldr r0, _0809C128 @ =0x000003e6\n"
|
|
||||||
"\tcmp r1, r0\n"
|
|
||||||
"\tbhi _0809C0F8\n"
|
|
||||||
"\tadds r0, r6, r1\n"
|
|
||||||
"\tstrh r0, [r4, 0x6]\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tlsrs r0, 16\n"
|
|
||||||
"\tldr r1, _0809C12C @ =0x000003e7\n"
|
|
||||||
"\tcmp r0, r1\n"
|
|
||||||
"\tbls _0809C0F8\n"
|
|
||||||
"\tstrh r1, [r4, 0x6]\n"
|
|
||||||
"_0809C0F8:\n"
|
|
||||||
"\tldr r1, [r4]\n"
|
|
||||||
"\tldr r0, _0809C130 @ =0x000f423e\n"
|
|
||||||
"\tcmp r1, r0\n"
|
|
||||||
"\tbhi _0809C120\n"
|
|
||||||
"\tadds r0, r3, 0\n"
|
|
||||||
"\tbl itemid_get_market_price\n"
|
|
||||||
"\tlsls r0, 16\n"
|
|
||||||
"\tlsrs r0, 16\n"
|
|
||||||
"\tsubs r1, r5, 0x1\n"
|
|
||||||
"\tasrs r0, r1\n"
|
|
||||||
"\tadds r1, r0, 0\n"
|
|
||||||
"\tmuls r1, r6\n"
|
|
||||||
"\tldr r0, [r4]\n"
|
|
||||||
"\tadds r0, r1\n"
|
|
||||||
"\tstr r0, [r4]\n"
|
|
||||||
"\tldr r1, _0809C134 @ =0x000f423f\n"
|
|
||||||
"\tcmp r0, r1\n"
|
|
||||||
"\tbls _0809C120\n"
|
|
||||||
"\tstr r1, [r4]\n"
|
|
||||||
"_0809C120:\n"
|
|
||||||
"\tpop {r4-r6}\n"
|
|
||||||
"\tpop {r0}\n"
|
|
||||||
"\tbx r0\n"
|
|
||||||
"\t.align 2, 0\n"
|
|
||||||
"_0809C128: .4byte 0x000003e6\n"
|
|
||||||
"_0809C12C: .4byte 0x000003e7\n"
|
|
||||||
"_0809C130: .4byte 0x000f423e\n"
|
|
||||||
"_0809C134: .4byte 0x000f423f\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void RecordQuestLogItemPurchase(void)
|
static void RecordQuestLogItemPurchase(void)
|
||||||
{
|
{
|
||||||
struct MartHistory *history = &gShopMenuHistory;
|
|
||||||
u16 v;
|
u16 v;
|
||||||
|
|
||||||
v = history->unkA;
|
v = gShopMenuHistory[0].unkA;
|
||||||
if (v != 0)
|
if (v != 0)
|
||||||
sub_8113550(v + 0x24, (const u16*)history);
|
sub_8113550(v + 0x24, (const u16 *)&gShopMenuHistory[0]);
|
||||||
|
|
||||||
v = history->unk16;
|
v = gShopMenuHistory[1].unkA;
|
||||||
if (v != 0)
|
if (v != 0)
|
||||||
{
|
sub_8113550(v + 0x24, (const u16 *)&gShopMenuHistory[1]);
|
||||||
v += 0x24;
|
|
||||||
sub_8113550(v, (const u16*)&history->unkC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatePokemartMenu(const u16 *itemsForSale)
|
void CreatePokemartMenu(const u16 *itemsForSale)
|
||||||
@@ -1262,9 +1142,9 @@ void CreatePokemartMenu(const u16 *itemsForSale)
|
|||||||
CreateShopMenu(MART_TYPE_REGULAR);
|
CreateShopMenu(MART_TYPE_REGULAR);
|
||||||
SetShopMenuCallback(EnableBothScriptContexts);
|
SetShopMenuCallback(EnableBothScriptContexts);
|
||||||
nullsub_53();
|
nullsub_53();
|
||||||
memset(&gShopMenuHistory, 0, sizeof(struct MartHistory));
|
memset(&gShopMenuHistory, 0, sizeof(gShopMenuHistory));
|
||||||
gShopMenuHistory.unk8 = gMapHeader.regionMapSectionId;
|
gShopMenuHistory[0].unk8 = gMapHeader.regionMapSectionId;
|
||||||
gShopMenuHistory.unk14 = gMapHeader.regionMapSectionId;
|
gShopMenuHistory[1].unk8 = gMapHeader.regionMapSectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateDecorationShop1Menu(const u16 *itemsForSale)
|
void CreateDecorationShop1Menu(const u16 *itemsForSale)
|
||||||
|
|||||||
Reference in New Issue
Block a user