extract graphics data

This commit is contained in:
Evan
2019-11-26 11:47:12 -07:00
parent c73f061cc6
commit d1142b4290
10 changed files with 143 additions and 101 deletions
+8 -8
View File
@@ -14008,17 +14008,17 @@ gBerryPouchSpritePalette:: @ 8E85C1C
gBerryPouchBg1Tilemap:: @ 8E85C44 gBerryPouchBg1Tilemap:: @ 8E85C44
.incbin "graphics/berry_pouch/unk_8E85C44.bin.lz" .incbin "graphics/berry_pouch/unk_8E85C44.bin.lz"
gUnknown_8E85DC8:: @ 8E85DC8 gBuyMenuFrame_Gfx:: @ 8E85DC8
.incbin "baserom.gba", 0xE85DC8, 0x134 .incbin "graphics/shop_menu/shop_menu.4bpp.lz"
gUnknown_8E85EFC:: @ 8E85EFC gBuyMenuFrame_Tilemap:: @ 8E85EFC
.incbin "baserom.gba", 0xE85EFC, 0x13C .incbin "graphics/shop_menu/shop_tilemap.bin"
gUnknown_8E86038:: @ 8E86038 gBuyMenuFrame_TmHmTilemap:: @ 8E86038
.incbin "baserom.gba", 0xE86038, 0x138 .incbin "graphics/shop_menu/shop_tmHmTilemap.bin"
gUnknown_8E86170:: @ 8E86170 gBuyMenuFrame_Pal:: @ 8E86170
.incbin "baserom.gba", 0xE86170, 0x38 .incbin "graphics/shop_menu/shop_menu.gbapal.lz"
gUnknown_8E861A8:: @ 8E861A8 gUnknown_8E861A8:: @ 8E861A8
.incbin "baserom.gba", 0xE861A8, 0x98 .incbin "baserom.gba", 0xE861A8, 0x98
+35
View File
@@ -0,0 +1,35 @@
JASC-PAL
0100
32
238 230 172
222 156 106
255 189 131
255 222 164
255 255 213
238 230 172
106 106 106
189 213 213
238 255 255
222 246 255
255 255 255
164 222 255
16 172 222
0 82 115
0 115 139
0 123 197
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
189 213 213
238 255 255
222 246 255
255 255 255
164 222 255
24 82 180
0 90 131
24 82 180
24 82 180
Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.
Binary file not shown.
+6
View File
@@ -4239,4 +4239,10 @@ extern const u16 gUnknown_8E97DDC[];
extern const u32 gUnknown_8E97DFC[]; extern const u32 gUnknown_8E97DFC[];
extern const u32 gUnknown_8E97EC4[]; extern const u32 gUnknown_8E97EC4[];
// shop menu
extern const u32 gBuyMenuFrame_Gfx[];
extern const u32 gBuyMenuFrame_Tilemap[];
extern const u32 gBuyMenuFrame_TmHmTilemap[];
extern const u32 gBuyMenuFrame_Pal[];
#endif //GUARD_GRAPHICS_H #endif //GUARD_GRAPHICS_H
-1
View File
@@ -3,7 +3,6 @@
#include "global.h" #include "global.h"
void sub_809C1D8(u8 taskId, const u16* a1, u16 a2);
void sub_809C448(u8 a0); void sub_809C448(u8 a0);
void sub_809C460(void); void sub_809C460(void);
bool8 sub_809C474(void); bool8 sub_809C474(void);
-2
View File
@@ -9,8 +9,6 @@
#define INDEX_CANCEL -2 #define INDEX_CANCEL -2
#define NUM_CHARS_PRICE 4
extern EWRAM_DATA struct ItemSlot gUnknown_02039F80[3]; extern EWRAM_DATA struct ItemSlot gUnknown_02039F80[3];
void CreatePokemartMenu(const u16 *itemsForSale); void CreatePokemartMenu(const u16 *itemsForSale);
+50 -36
View File
@@ -7,21 +7,18 @@
#include "field_map_obj.h" #include "field_map_obj.h"
#include "field_camera.h" #include "field_camera.h"
// Defines
#define t0 data[0] #define t0 data[0]
#define tX data[4] #define tX data[4]
#define tY data[5]
#define tListTaskId data[7] #define tListTaskId data[7]
// RAM
EWRAM_DATA u8 gUnknown_2039984 = 0; EWRAM_DATA u8 gUnknown_2039984 = 0;
static void sub_809C1D8(u8 taskId, const u16* a1, u16 a2);
// Function Declarations
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);
// Data Definitions
static const u16 gUnknown_83DF0D4[] = {0x0308, 0x030a, 0x02d0}; static const u16 gUnknown_83DF0D4[] = {0x0308, 0x030a, 0x02d0};
static const u16 gUnknown_83DF0DA[] = {0x0309, 0x030b, 0x02d1}; static const u16 gUnknown_83DF0DA[] = {0x0309, 0x030b, 0x02d1};
static const u16 gUnknown_83DF0E0[] = {0x0310, 0x0312, 0x02d8}; static const u16 gUnknown_83DF0E0[] = {0x0310, 0x0312, 0x02d8};
@@ -30,34 +27,52 @@ static const u16 gUnknown_83DF0EC[] = {0x02e3, 0x0316, 0x0314};
static const u16 gUnknown_83DF0F2[] = {0x02e4, 0x0317, 0x0315}; 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 #ifdef NONMATCHING
void sub_809C1D8(u8 taskId, const u16* 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 v1, v2, v3;
s16 i, j; s16 i, j;
const s16* v4;
v1 = gTasks[taskId].data[5] - 1;
v2 = gTasks[taskId].data[6] - 1; v1 = gTasks[taskId].data[4] - 1;
v3 = gTasks[taskId].data[2]; v2 = gTasks[taskId].data[5] - 1;
v3 = gTasks[taskId].data[1];
if (gTasks[taskId].data[3] == 0)
{ if (gTasks[taskId].data[2] == 0)
for (i = 0; i < 3; i++) {
{ for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++) {
{ for (j = 0; j < 3; j++)
MapGridGetMetatileIdAt(v1 + j, v2 + i); {
if () v4 = &a1[v3];
{ if (MapGridGetMetatileIdAt(v1 + j, v2 + i) == v4[0])
{
} if (v3 != 2)
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | v4[1]);
MapGridSetMetatileIdAt else
} MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | v4[0]);
} }
} }
}
}
else
{
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
if (a1[2 - v3] == MapGridGetMetatileIdAt(v1 + j, v2 + i))
{
if (v3 != 2)
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | a1[1 - v3]);
else
MapGridSetMetatileIdAt(v1 + j, v2 + i, a2 | a1[2]);
}
}
}
}
} }
#else #else
NAKED NAKED
@@ -275,9 +290,9 @@ static void sub_809C334(u8 taskId)
default: default:
break; break;
} }
data[0] = (data[0] + 1) & 7; data[0] = (data[0] + 1) & 7;
v1 = data[0] & 7; v1 = data[0] & 7;
//ldrh r5, [r4] instead mov r5, r0 somehow
if (v1 == 0) if (v1 == 0)
{ {
DrawWholeMapView(); DrawWholeMapView();
@@ -293,7 +308,7 @@ 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, &data[5]); PlayerGetDestCoords(&tX, &tY);
t0 = 0; t0 = 0;
data[1] = 0; data[1] = 0;
data[2] = a0; data[2] = a0;
@@ -335,10 +350,8 @@ void sub_809C4A8(void)
s16 *data; s16 *data;
taskId = CreateTask(sub_809C500, 0); taskId = CreateTask(sub_809C500, 0);
gTasks[taskId].data[0] = 0; gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0; gTasks[taskId].data[1] = 0;
data = gTasks[taskId].data; data = gTasks[taskId].data;
PlayerGetDestCoords(&data[2], &data[3]); PlayerGetDestCoords(&data[2], &data[3]);
if (gSpecialVar_0x8004 == 0) if (gSpecialVar_0x8004 == 0)
@@ -376,9 +389,8 @@ static void sub_809C500(u8 taskId)
data[0]++; data[0]++;
if (data[0] != 0x10) if (data[0] != 0x10)
return; return;
data[0] = 0;
data[0] == 0; data[0] = 0;
data[1]++; data[1]++;
if (data[1] != 0xD) if (data[1] != 0xD)
return; return;
@@ -399,7 +411,6 @@ void sub_809C5FC(void)
taskId = CreateTask(sub_809C640, 0); taskId = CreateTask(sub_809C640, 0);
gTasks[taskId].data[0] = 0; gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0; gTasks[taskId].data[1] = 0;
data = gTasks[taskId].data; data = gTasks[taskId].data;
PlayerGetDestCoords(&data[2], &data[3]); PlayerGetDestCoords(&data[2], &data[3]);
gTasks[taskId].data[2] += 4; gTasks[taskId].data[2] += 4;
@@ -423,6 +434,7 @@ static void sub_809C640(u8 taskId)
DestroyTask(taskId); DestroyTask(taskId);
return; return;
} }
data[2]--; data[2]--;
} }
MapGridSetMetatileIdAt(data[2], data[3], 0xEB9); MapGridSetMetatileIdAt(data[2], data[3], 0xEB9);
@@ -430,6 +442,7 @@ static void sub_809C640(u8 taskId)
CurrentMapDrawMetatileAt(data[2], data[3]); CurrentMapDrawMetatileAt(data[2], data[3]);
CurrentMapDrawMetatileAt(data[2], data[3] + 1); CurrentMapDrawMetatileAt(data[2], data[3] + 1);
} }
data[0]++; data[0]++;
if (data[0] == 4) if (data[0] == 4)
{ {
@@ -437,3 +450,4 @@ static void sub_809C640(u8 taskId)
data[1]++; data[1]++;
} }
} }
+44 -54
View File
@@ -2,6 +2,8 @@
#include "shop.h" #include "shop.h"
#include "menu.h" #include "menu.h"
#include "data.h" #include "data.h"
#include "graphics.h"
#include "strings.h"
#include "list_menu.h" #include "list_menu.h"
#include "new_menu_helpers.h" #include "new_menu_helpers.h"
#include "party_menu.h" #include "party_menu.h"
@@ -15,7 +17,6 @@
#include "item_menu.h" #include "item_menu.h"
#include "main.h" #include "main.h"
#include "sound.h" #include "sound.h"
#include "strings.h"
#include "string_util.h" #include "string_util.h"
#include "overworld.h" #include "overworld.h"
#include "window.h" #include "window.h"
@@ -38,9 +39,7 @@
#include "constants/items.h" #include "constants/items.h"
#include "constants/game_stat.h" #include "constants/game_stat.h"
#define t0 data[0]
#define tItemCount data[1] #define tItemCount data[1]
#define tX data[4]
#define tItemId data[5] #define tItemId data[5]
#define tListTaskId data[7] #define tListTaskId data[7]
@@ -96,7 +95,6 @@ struct MartHistory
/*0x17*/ u8 unk17; /*0x17*/ u8 unk17;
}; /* size = 0x18 */ }; /* size = 0x18 */
EWRAM_DATA s16 sViewportMapObjects[MAP_OBJECTS_COUNT][4] = {0}; EWRAM_DATA s16 sViewportMapObjects[MAP_OBJECTS_COUNT][4] = {0};
EWRAM_DATA struct ShopData gShopData = {0}; EWRAM_DATA struct ShopData gShopData = {0};
EWRAM_DATA u8 sShopMenuWindowId = 0; EWRAM_DATA u8 sShopMenuWindowId = 0;
@@ -165,39 +163,23 @@ static void nullsub_52(u8 taskId);
static void nullsub_53(void); static void nullsub_53(void);
static void RecordQuestLogItemPurchase(void); static void RecordQuestLogItemPurchase(void);
// external defines
extern u8 MapGridGetMetatileLayerTypeAt(s16 x, s16 y); extern u8 MapGridGetMetatileLayerTypeAt(s16 x, s16 y);
extern u16 BagGetQuantityByItemId(u16 item); extern u16 BagGetQuantityByItemId(u16 item);
//Data Definitions static const struct MenuAction sShopMenuActions_BuySellQuit[] =
/*
extern const struct MenuAction gUnknown_83DF09C[];
extern const struct YesNoFuncTable gUnknown_83DF0B4[];
extern const struct WindowTemplate gUnknown_83DF0BC[];
extern const struct BgTemplate gUnknown_83DF0C4[];
*/
//graphics
extern const u32 gUnknown_8E85DC8[]; //gBuyMenuFrame_Gfx[];
extern const u32 gUnknown_8E85EFC[]; //gBuyMenuFrame_Tilemap
extern const u32 gUnknown_8E86038[]; //gBuyMenuFrame_TmHmTilemap
extern const u32 gUnknown_8E86170[]; //gBuyMenuFrame_Pal
static const struct MenuAction gUnknown_83DF09C[] = // sShopMenuActions_BuySellQuit
{ {
{gText_ShopBuy, {.void_u8 = Task_HandleShopMenuBuy}}, {gText_ShopBuy, {.void_u8 = Task_HandleShopMenuBuy}},
{gText_ShopSell, {.void_u8 = Task_HandleShopMenuSell}}, {gText_ShopSell, {.void_u8 = Task_HandleShopMenuSell}},
{gText_ShopQuit, {.void_u8 = Task_HandleShopMenuQuit}} {gText_ShopQuit, {.void_u8 = Task_HandleShopMenuQuit}}
}; };
static const struct YesNoFuncTable gUnknown_83DF0B4[] = //sShopMenuActions_BuyQuit static const struct YesNoFuncTable sShopMenuActions_BuyQuit[] =
{ {
BuyMenuTryMakePurchase, //Task_HandleShopMenuBuy, BuyMenuTryMakePurchase,
BuyMenuReturnToItemList //Task_HandleShopMenuQuit BuyMenuReturnToItemList
}; };
static const struct WindowTemplate gUnknown_83DF0BC[] = //sShopMenuWindowTemplates static const struct WindowTemplate sShopMenuWindowTemplates[] =
{ {
{ {
.bg = 0, .bg = 0,
@@ -210,7 +192,7 @@ static const struct WindowTemplate gUnknown_83DF0BC[] = //sShopMenuWindowTem
} }
}; };
static const struct BgTemplate gUnknown_83DF0C4[4] = //sShopBuyMenuBgTemplates static const struct BgTemplate sShopBuyMenuBgTemplates[4] =
{ {
{ {
.bg = 0, .bg = 0,
@@ -250,7 +232,6 @@ static const struct BgTemplate gUnknown_83DF0C4[4] = //sShopBuyMenuBgTemplat
} }
}; };
// Functions // Functions
static u8 CreateShopMenu(u8 a0) static u8 CreateShopMenu(u8 a0)
{ {
@@ -261,9 +242,9 @@ static u8 CreateShopMenu(u8 a0)
else else
gShopData.unk16_4 = 5; gShopData.unk16_4 = 5;
sShopMenuWindowId = AddWindow(gUnknown_83DF0BC); //sShopMenuWindowTemplates sShopMenuWindowId = AddWindow(sShopMenuWindowTemplates);
SetStdWindowBorderStyle(sShopMenuWindowId, 0); SetStdWindowBorderStyle(sShopMenuWindowId, 0);
PrintTextArray(sShopMenuWindowId, 2, GetMenuCursorDimensionByFont(2, 0), 2, 16, 3, gUnknown_83DF09C); PrintTextArray(sShopMenuWindowId, 2, GetMenuCursorDimensionByFont(2, 0), 2, 16, 3, sShopMenuActions_BuySellQuit);
Menu_InitCursor(sShopMenuWindowId, 2, 0, 2, 16, 3, 0); Menu_InitCursor(sShopMenuWindowId, 2, 0, 2, 16, 3, 0);
PutWindowTilemap(sShopMenuWindowId); PutWindowTilemap(sShopMenuWindowId);
CopyWindowToVram(sShopMenuWindowId, 1); CopyWindowToVram(sShopMenuWindowId, 1);
@@ -272,10 +253,12 @@ static u8 CreateShopMenu(u8 a0)
static u8 GetMartTypeFromItemList(u32 a0) static u8 GetMartTypeFromItemList(u32 a0)
{ {
u16 retVal, i; u16 i;
if (a0) if (a0)
return (u8)a0; return (u8)a0;
goto MAIN; goto MAIN;
RETURN_1: RETURN_1:
return 1; return 1;
@@ -296,6 +279,7 @@ static u8 GetMartTypeFromItemList(u32 a0)
else if (gShopData.itemList[i] == 0) else if (gShopData.itemList[i] == 0)
goto RETURN_0; goto RETURN_0;
} }
RETURN_0: RETURN_0:
return 0; return 0;
} }
@@ -333,7 +317,7 @@ static void Task_ShopMenu(u8 taskId)
Task_HandleShopMenuQuit(taskId); Task_HandleShopMenuQuit(taskId);
break; break;
default: default:
gUnknown_83DF09C[Menu_GetCursorPos()].func.void_u8(taskId); sShopMenuActions_BuySellQuit[Menu_GetCursorPos()].func.void_u8(taskId);
break; break;
} }
} }
@@ -377,6 +361,7 @@ static void Task_GoToBuyOrSellMenu(u8 taskId)
{ {
if (gPaletteFade.active) if (gPaletteFade.active)
return; return;
SetMainCallback2((void *)GetWordTaskArg(taskId, 0xE)); SetMainCallback2((void *)GetWordTaskArg(taskId, 0xE));
FreeAllWindowBuffers(); FreeAllWindowBuffers();
DestroyTask(taskId); DestroyTask(taskId);
@@ -392,6 +377,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
{ {
if (field_weather_is_fade_finished() != TRUE) if (field_weather_is_fade_finished() != TRUE)
return; return;
DisplayItemMessageOnField(taskId, GetMartUnk16_4(), gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu); DisplayItemMessageOnField(taskId, GetMartUnk16_4(), gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu);
} }
@@ -420,6 +406,7 @@ static void VBlankCB_BuyMenu(void)
static void CB2_InitBuyMenu(void) static void CB2_InitBuyMenu(void)
{ {
u8 taskId; u8 taskId;
switch (gMain.state) switch (gMain.state)
{ {
case 0: case 0:
@@ -469,12 +456,15 @@ static bool8 InitShopData(void)
gShopTilemapBuffer1 = Alloc(sizeof(*gShopTilemapBuffer1)); gShopTilemapBuffer1 = Alloc(sizeof(*gShopTilemapBuffer1));
if (gShopTilemapBuffer1 == 0) if (gShopTilemapBuffer1 == 0)
goto CANCEL; goto CANCEL;
gShopTilemapBuffer2 = Alloc(sizeof(*gShopTilemapBuffer2)); gShopTilemapBuffer2 = Alloc(sizeof(*gShopTilemapBuffer2));
if (gShopTilemapBuffer2 == 0) if (gShopTilemapBuffer2 == 0)
goto CANCEL; goto CANCEL;
gShopTilemapBuffer3 = Alloc(sizeof(*gShopTilemapBuffer3)); gShopTilemapBuffer3 = Alloc(sizeof(*gShopTilemapBuffer3));
if (gShopTilemapBuffer3 == 0) if (gShopTilemapBuffer3 == 0)
goto CANCEL; goto CANCEL;
gShopTilemapBuffer4 = Alloc(sizeof(*gShopTilemapBuffer4)); gShopTilemapBuffer4 = Alloc(sizeof(*gShopTilemapBuffer4));
if (gShopTilemapBuffer4 == 0) if (gShopTilemapBuffer4 == 0)
goto CANCEL; goto CANCEL;
@@ -489,7 +479,7 @@ static bool8 InitShopData(void)
static void BuyMenuInitBgs(void) static void BuyMenuInitBgs(void)
{ {
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_83DF0C4, NELEMS(gUnknown_83DF0C4)); InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, NELEMS(sShopBuyMenuBgTemplates));
SetBgTilemapBuffer(1, gShopTilemapBuffer2); SetBgTilemapBuffer(1, gShopTilemapBuffer2);
SetBgTilemapBuffer(2, gShopTilemapBuffer4); SetBgTilemapBuffer(2, gShopTilemapBuffer4);
SetBgTilemapBuffer(3, gShopTilemapBuffer3); SetBgTilemapBuffer(3, gShopTilemapBuffer3);
@@ -512,13 +502,15 @@ static void BuyMenuInitBgs(void)
static void BuyMenuDecompressBgGraphics(void) static void BuyMenuDecompressBgGraphics(void)
{ {
void* pal; void* pal;
DecompressAndCopyTileDataToVram(1, gUnknown_8E85DC8, 0x480, 0x3DC, 0);
DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x480, 0x3DC, 0);
if ((gShopData.martType) != MART_TYPE_TMHM) if ((gShopData.martType) != MART_TYPE_TMHM)
LZDecompressWram(gUnknown_8E85EFC, gShopTilemapBuffer1); //gBuyMenuFrame_Tilemap LZDecompressWram(gBuyMenuFrame_Tilemap, gShopTilemapBuffer1);
else else
LZDecompressWram(gUnknown_8E86038, gShopTilemapBuffer1); //gBuyMenuFrame_TmHmTilemap LZDecompressWram(gBuyMenuFrame_TmHmTilemap, gShopTilemapBuffer1);
pal = Alloc(0x40); pal = Alloc(0x40);
LZDecompressWram(gUnknown_8E86170, pal); LZDecompressWram(gBuyMenuFrame_Pal, pal);
LoadPalette(pal, 0xB0, 0x20); LoadPalette(pal, 0xB0, 0x20);
LoadPalette(pal + 0x20, 0x60, 0x20); LoadPalette(pal + 0x20, 0x60, 0x20);
Free(pal); Free(pal);
@@ -527,14 +519,17 @@ static void BuyMenuDecompressBgGraphics(void)
static void sub_809B10C(bool32 a0) static void sub_809B10C(bool32 a0)
{ {
u8 v; u8 v;
if (a0 == FALSE) if (a0 == FALSE)
v = 0xB; v = 0xB;
else else
v = 6; v = 6;
if ((gShopData.martType) != MART_TYPE_TMHM) if ((gShopData.martType) != MART_TYPE_TMHM)
SetBgRectPal(1, 0, 0xE, 0x1E, 6, v); SetBgRectPal(1, 0, 0xE, 0x1E, 6, v);
else else
SetBgRectPal(1, 0, 0xC, 0x1E, 8, v); SetBgRectPal(1, 0, 0xC, 0x1E, 8, v);
ScheduleBgCopyTilemapToVram(1); ScheduleBgCopyTilemapToVram(1);
} }
@@ -551,10 +546,10 @@ static void BuyMenuDrawGraphics(void)
static bool8 BuyMenuBuildListMenuTemplate(void) static bool8 BuyMenuBuildListMenuTemplate(void)
{ {
u16 i; u16 i, v;
u16 v;
struct ListMenuItem **list = &sShopMenuListMenu; struct ListMenuItem **list = &sShopMenuListMenu;
struct ShopData *mart = &gShopData; struct ShopData *mart = &gShopData;
*list = Alloc((gShopData.itemCount + 1) * sizeof(*sShopMenuListMenu)); *list = Alloc((gShopData.itemCount + 1) * sizeof(*sShopMenuListMenu));
if (sShopMenuListMenu == 0) if (sShopMenuListMenu == 0)
goto FREE_MEMORY; goto FREE_MEMORY;
@@ -574,7 +569,7 @@ static bool8 BuyMenuBuildListMenuTemplate(void)
for (i = 0; i < mart->itemCount; i++) for (i = 0; i < mart->itemCount; i++)
{ {
PokeMartWriteNameAndIdAt(&sShopMenuListMenu[i], mart->itemList[i], sShopMenuItemStrings[i]); //PokeMartWriteNameAndIdAt(u16 a0, u16 a1, u8* a2) PokeMartWriteNameAndIdAt(&sShopMenuListMenu[i], mart->itemList[i], sShopMenuItemStrings[i]);
} }
ADD_CANCEL: ADD_CANCEL:
@@ -640,6 +635,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
CreateItemMenuIcon(item, gShopData.itemSlot); CreateItemMenuIcon(item, gShopData.itemSlot);
else else
CreateItemMenuIcon(ITEM_N_A, gShopData.itemSlot); CreateItemMenuIcon(ITEM_N_A, gShopData.itemSlot);
gShopData.itemSlot ^= 1; gShopData.itemSlot ^= 1;
BuyMenuPrint(5, 2, description, 0, 3, 2, 1, 0, 0); BuyMenuPrint(5, 2, description, 0, 3, 2, 1, 0, 0);
} }
@@ -652,6 +648,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
} }
#ifdef NONMATCHING #ifdef NONMATCHING
// As simple as this seems, I could not get the while loop to use the correct registers. It should pad the front of gStringVar4 with 0 based on the length of gStringVar1.
static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
{ {
u32 len, x; u32 len, x;
@@ -857,10 +854,7 @@ static void sub_809B764(void)
static void BuyMenuDrawMapBg(void) static void BuyMenuDrawMapBg(void)
{ {
s16 i; s16 i, j, x, y;
s16 j;
s16 x;
s16 y;
const struct MapData *mapData; const struct MapData *mapData;
u16 metatile; u16 metatile;
u8 metatileLayerType; u8 metatileLayerType;
@@ -913,7 +907,6 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye
static void BuyMenuDrawMapMetatileLayer(u16 *dest, s16 offset1, s16 offset2, const u16 *src) static void BuyMenuDrawMapMetatileLayer(u16 *dest, s16 offset1, s16 offset2, const u16 *src)
{ {
// This function draws a whole 2x2 metatile.
dest[offset1 + offset2] = src[0]; // top left dest[offset1 + offset2] = src[0]; // top left
dest[offset1 + offset2 + 1] = src[1]; // top right dest[offset1 + offset2 + 1] = src[1]; // top right
dest[offset1 + offset2 + 32] = src[2]; // bottom left dest[offset1 + offset2 + 32] = src[2]; // bottom left
@@ -922,12 +915,9 @@ static void BuyMenuDrawMapMetatileLayer(u16 *dest, s16 offset1, s16 offset2, con
static void BuyMenuCollectEventObjectData(void) static void BuyMenuCollectEventObjectData(void)
{ {
s16 facingX; s16 facingX, facingY;
s16 facingY; u8 x, y, z;
u8 y;
u8 x;
u8 num = 0; u8 num = 0;
u8 z;
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
z = PlayerGetZCoord(); z = PlayerGetZCoord();
@@ -970,8 +960,7 @@ static void BuyMenuCollectEventObjectData(void)
static void BuyMenuDrawEventObjects(void) static void BuyMenuDrawEventObjects(void)
{ {
u8 i; u8 i, spriteId;
u8 spriteId;
const struct MapObjectGraphicsInfo *graphicsInfo; const struct MapObjectGraphicsInfo *graphicsInfo;
for (i = 0; i < MAP_OBJECTS_COUNT; i++) for (i = 0; i < MAP_OBJECTS_COUNT; i++)
@@ -993,7 +982,6 @@ static void BuyMenuDrawEventObjects(void)
static void BuyMenuCopyTilemapData(void) static void BuyMenuCopyTilemapData(void)
{ {
s16 i; s16 i;
u16 *dst = *gShopTilemapBuffer2; u16 *dst = *gShopTilemapBuffer2;
u16 *src = *gShopTilemapBuffer1; u16 *src = *gShopTilemapBuffer1;
@@ -1049,6 +1037,7 @@ static void Task_BuyMenu(u8 taskId)
CopyItemName(itemId, gStringVar1); CopyItemName(itemId, gStringVar1);
BuyMenuDisplayMessage(taskId, gText_Var1CertainlyHowMany, Task_BuyHowManyDialogueInit); BuyMenuDisplayMessage(taskId, gText_Var1CertainlyHowMany, Task_BuyHowManyDialogueInit);
} }
break;
} }
} }
} }
@@ -1056,7 +1045,6 @@ static void Task_BuyMenu(u8 taskId)
static void Task_BuyHowManyDialogueInit(u8 taskId) static void Task_BuyHowManyDialogueInit(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
u16 quantityInBag = BagGetQuantityByItemId(tItemId); u16 quantityInBag = BagGetQuantityByItemId(tItemId);
u16 maxQuantity; u16 maxQuantity;
@@ -1120,7 +1108,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
static void CreateBuyMenuConfirmPurchaseWindow(u8 taskId) static void CreateBuyMenuConfirmPurchaseWindow(u8 taskId)
{ {
BuyMenuConfirmPurchase(taskId, gUnknown_83DF0B4); BuyMenuConfirmPurchase(taskId, sShopMenuActions_BuyQuit);
} }
static void BuyMenuTryMakePurchase(u8 taskId) static void BuyMenuTryMakePurchase(u8 taskId)
@@ -1204,6 +1192,7 @@ static void nullsub_53(void)
} }
#ifdef NONMATCHING #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 *tmp;
@@ -1343,6 +1332,7 @@ static void RecordQuestLogItemPurchase(void)
v = history->unkA; v = history->unkA;
if (v != 0) if (v != 0)
sub_8113550(v + 0x24, (const u16*)history); sub_8113550(v + 0x24, (const u16*)history);
v = history->unk16; v = history->unk16;
if (v != 0) if (v != 0)
{ {