Merge pull request #2379 from AsparagusEduardo/RHH/pr/pretmerge_20221007

One for the go! (pret merge 2022/10/07)
This commit is contained in:
ghoulslash 2022-10-07 17:14:00 -04:00 committed by GitHub
commit 06bddbac23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 493 additions and 281 deletions

View File

@ -931,6 +931,10 @@
#define ITEMS_COUNT 758 #define ITEMS_COUNT 758
#define ITEM_FIELD_ARROW ITEMS_COUNT #define ITEM_FIELD_ARROW ITEMS_COUNT
// A special item id associated with "Cancel"/"Exit" etc. in a list of items or decorations
// Its icon is defined at ITEMS_COUNT as the "return to field" arrow
#define ITEM_LIST_END 0xFFFF
// Range of berries given out by various NPCS // Range of berries given out by various NPCS
#define FIRST_BERRY_MASTER_BERRY ITEM_POMEG_BERRY #define FIRST_BERRY_MASTER_BERRY ITEM_POMEG_BERRY
#define LAST_BERRY_MASTER_BERRY ITEM_NOMEL_BERRY #define LAST_BERRY_MASTER_BERRY ITEM_NOMEL_BERRY

View File

@ -67,6 +67,9 @@
#define DISPLAY_WIDTH 240 #define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 160 #define DISPLAY_HEIGHT 160
#define DISPLAY_TILE_WIDTH (DISPLAY_WIDTH / 8)
#define DISPLAY_TILE_HEIGHT (DISPLAY_HEIGHT / 8)
#define TILE_SIZE_4BPP 32 #define TILE_SIZE_4BPP 32
#define TILE_SIZE_8BPP 64 #define TILE_SIZE_8BPP 64

View File

@ -64,13 +64,11 @@ u16 CountTotalItemQuantityInBag(u16 itemId);
bool8 AddPyramidBagItem(u16 itemId, u16 count); bool8 AddPyramidBagItem(u16 itemId, u16 count);
bool8 RemovePyramidBagItem(u16 itemId, u16 count); bool8 RemovePyramidBagItem(u16 itemId, u16 count);
const u8 *ItemId_GetName(u16 itemId); const u8 *ItemId_GetName(u16 itemId);
u16 ItemId_GetId(u16 itemId);
u16 ItemId_GetPrice(u16 itemId); u16 ItemId_GetPrice(u16 itemId);
u8 ItemId_GetHoldEffect(u16 itemId); u8 ItemId_GetHoldEffect(u16 itemId);
u8 ItemId_GetHoldEffectParam(u16 itemId); u8 ItemId_GetHoldEffectParam(u16 itemId);
const u8 *ItemId_GetDescription(u16 itemId); const u8 *ItemId_GetDescription(u16 itemId);
u8 ItemId_GetImportance(u16 itemId); u8 ItemId_GetImportance(u16 itemId);
u8 ItemId_GetRegistrability(u16 itemId);
u8 ItemId_GetPocket(u16 itemId); u8 ItemId_GetPocket(u16 itemId);
u8 ItemId_GetType(u16 itemId); u8 ItemId_GetType(u16 itemId);
ItemUseFunc ItemId_GetFieldFunc(u16 itemId); ItemUseFunc ItemId_GetFieldFunc(u16 itemId);

View File

@ -3,47 +3,6 @@
extern EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3]; extern EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3];
enum
{
MART_TYPE_NORMAL, // normal mart
MART_TYPE_DECOR,
MART_TYPE_DECOR2,
};
// shop view window NPC info enum
enum
{
OBJ_EVENT_ID,
X_COORD,
Y_COORD,
ANIM_NUM,
LAYER_TYPE
};
struct MartInfo
{
/*0x0*/ void (*callback)(void);
/*0x4*/ const struct MenuAction *menuActions;
/*0x8*/ const u16 *itemList;
/*0xC*/ u16 itemCount;
/*0xE*/ u8 windowId;
/*0xF*/ u8 martType;
};
struct ShopData
{
/*0x0000*/ u16 tilemapBuffers[4][0x400];
/*0x2000*/ u32 totalCost;
/*0x2004*/ u16 itemsShowed;
/*0x2006*/ u16 selectedRow;
/*0x2008*/ u16 scrollOffset;
/*0x200A*/ u8 maxQuantity;
/*0x200B*/ u8 scrollIndicatorsTaskId;
/*0x200C*/ u8 iconSlot;
/*0x200D*/ u8 itemSpriteIds[2];
/*0x2010*/ s16 viewportObjects[OBJECT_EVENTS_COUNT][5];
};
void CreatePokemartMenu(const u16 *); void CreatePokemartMenu(const u16 *);
void CreateDecorationShop1Menu(const u16 *); void CreateDecorationShop1Menu(const u16 *);
void CreateDecorationShop2Menu(const u16 *); void CreateDecorationShop2Menu(const u16 *);

View File

@ -7856,8 +7856,8 @@ static void SpriteCB_TwinkleOnBattler(struct Sprite *sprite)
void AnimTask_PrimalReversion(u8 taskId) void AnimTask_PrimalReversion(u8 taskId)
{ {
if (ItemId_GetId(gBattleMons[gBattleAnimAttacker].item) == ITEM_RED_ORB) if (gBattleMons[gBattleAnimAttacker].item == ITEM_RED_ORB)
gBattleAnimArgs[0] = ItemId_GetId(gBattleMons[gBattleAnimAttacker].item); gBattleAnimArgs[0] = gBattleMons[gBattleAnimAttacker].item;
else else
gBattleAnimArgs[0] = 0; gBattleAnimArgs[0] = 0;
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);

View File

@ -325,10 +325,13 @@ static const struct SpriteTemplate sHealthbarSpriteTemplates[MAX_BATTLERS_COUNT]
} }
}; };
/* v-- Origin
[0 + ][1 ] 64x8
*/
static const struct Subsprite sHealthBar_Subsprites_Player[] = static const struct Subsprite sHealthBar_Subsprites_Player[] =
{ {
{ {
.x = DISPLAY_WIDTH, .x = -16,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -345,10 +348,14 @@ static const struct Subsprite sHealthBar_Subsprites_Player[] =
} }
}; };
/* v-- Origin
[] [0 + ][1 ] 8x8 + 64x8
2^ ^--- Note 8px space
*/
static const struct Subsprite sHealthBar_Subsprites_Opponent[] = static const struct Subsprite sHealthBar_Subsprites_Opponent[] =
{ {
{ {
.x = DISPLAY_WIDTH, .x = -16,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -364,7 +371,7 @@ static const struct Subsprite sHealthBar_Subsprites_Opponent[] =
.priority = 1 .priority = 1
}, },
{ {
.x = DISPLAY_WIDTH - 16, .x = -32,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(8x8), .shape = SPRITE_SHAPE(8x8),
.size = SPRITE_SIZE(8x8), .size = SPRITE_SIZE(8x8),
@ -378,11 +385,13 @@ static const struct SubspriteTable sHealthBar_SubspriteTables[] =
[B_SIDE_PLAYER] = {ARRAY_COUNT(sHealthBar_Subsprites_Player), sHealthBar_Subsprites_Player}, [B_SIDE_PLAYER] = {ARRAY_COUNT(sHealthBar_Subsprites_Player), sHealthBar_Subsprites_Player},
[B_SIDE_OPPONENT] = {ARRAY_COUNT(sHealthBar_Subsprites_Opponent), sHealthBar_Subsprites_Opponent} [B_SIDE_OPPONENT] = {ARRAY_COUNT(sHealthBar_Subsprites_Opponent), sHealthBar_Subsprites_Opponent}
}; };
/* v-- Origin
[0 ][1 ][2 ][3 ] 128x8
*/
static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] = static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
{ {
{ {
.x = 32 * 5, .x = 32 * -3,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -390,7 +399,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
.priority = 1 .priority = 1
}, },
{ {
.x = 32 * 6, .x = 32 * -2,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -398,7 +407,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
.priority = 1 .priority = 1
}, },
{ {
.x = 32 * 7, .x = 32 * -1,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -415,10 +424,14 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
} }
}; };
/* v-- Origin
[0 ][1 ][2 ][3 ][4 ][5 ] 192x8
^-- uses same tiles --^
*/
static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] = static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
{ {
{ {
.x = 32 * 5, .x = 32 * -3,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -426,7 +439,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
.priority = 1 .priority = 1
}, },
{ {
.x = 32 * 6, .x = 32 * -2,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),
@ -434,7 +447,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
.priority = 1 .priority = 1
}, },
{ {
.x = 32 * 7, .x = 32 * -1,
.y = 0, .y = 0,
.shape = SPRITE_SHAPE(32x8), .shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8), .size = SPRITE_SIZE(32x8),

View File

@ -645,7 +645,7 @@ static void BagCursorMoved(s32 itemIndex, bool8 onInit, struct ListMenu *list)
if (itemIndex != LIST_CANCEL) if (itemIndex != LIST_CANCEL)
ShowItemIcon(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gPyramidBagMenu->isAltIcon); ShowItemIcon(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gPyramidBagMenu->isAltIcon);
else else
ShowItemIcon(0xFFFF, gPyramidBagMenu->isAltIcon); // Show exit arrow if on Cancel ShowItemIcon(ITEM_LIST_END, gPyramidBagMenu->isAltIcon); // Show exit arrow if on Cancel
gPyramidBagMenu->isAltIcon ^= 1; gPyramidBagMenu->isAltIcon ^= 1;
PrintItemDescription(itemIndex); PrintItemDescription(itemIndex);
} }

View File

@ -1008,7 +1008,7 @@ static bool8 LoadBerryBlenderGfx(void)
static void DrawBlenderBg(void) static void DrawBlenderBg(void)
{ {
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
ShowBg(0); ShowBg(0);
ShowBg(1); ShowBg(1);
@ -1029,7 +1029,7 @@ static void InitBerryBlenderWindows(void)
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
FillWindowPixelBuffer(i, PIXEL_FILL(0)); FillWindowPixelBuffer(i, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
Menu_LoadStdPalAt(0xE0); Menu_LoadStdPalAt(0xE0);
} }
} }

View File

@ -525,6 +525,9 @@ static const struct SpriteTemplate sSpriteTemplates_NextTurn[CONTESTANT_COUNT] =
} }
}; };
/* v-- Origin
[0 +][1 ] 64x8
*/
static const struct Subsprite sSubsprites_NextTurn[] = static const struct Subsprite sSubsprites_NextTurn[] =
{ {
{ {

View File

@ -1150,24 +1150,24 @@ static void TryCreateWirelessSprites(void)
static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId) static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{ {
u16 windowId; u16 windowId;
int origWidth; int tileWidth;
int strWidth; int strWidth;
u8 *spriteTilePtrs[4]; u8 *spriteTilePtrs[4];
u8 *dst; u8 *dst;
struct WindowTemplate windowTemplate; struct WindowTemplate windowTemplate;
memset(&windowTemplate, 0, sizeof(windowTemplate)); memset(&windowTemplate, 0, sizeof(windowTemplate));
windowTemplate.width = 30; windowTemplate.width = DISPLAY_TILE_WIDTH;
windowTemplate.height = 2; windowTemplate.height = 2;
windowId = AddWindow(&windowTemplate); windowId = AddWindow(&windowTemplate);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
origWidth = GetStringWidth(FONT_NORMAL, text, 0); strWidth = GetStringWidth(FONT_NORMAL, text, 0);
strWidth = (origWidth + 9) / 8; tileWidth = (strWidth + 9) / 8;
if (strWidth > 30) if (tileWidth > DISPLAY_TILE_WIDTH)
strWidth = 30; tileWidth = DISPLAY_TILE_WIDTH;
AddTextPrinterParameterized3(windowId, FONT_NORMAL, (strWidth * 8 - origWidth) / 2, 1, sContestLinkTextColors, TEXT_SKIP_DRAW, text); AddTextPrinterParameterized3(windowId, FONT_NORMAL, (tileWidth * 8 - strWidth) / 2, 1, sContestLinkTextColors, TEXT_SKIP_DRAW, text);
{ {
s32 i; s32 i;
struct Sprite *sprite; struct Sprite *sprite;
@ -1190,7 +1190,7 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
CpuCopy32(src + 128, dst + 0x200, 0x20); CpuCopy32(src + 128, dst + 0x200, 0x20);
CpuCopy32(src + 64, dst + 0x300, 0x20); CpuCopy32(src + 64, dst + 0x300, 0x20);
for (i = 0; i < strWidth; i++) for (i = 0; i < tileWidth; i++)
{ {
dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32]; dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
CpuCopy32(src + 192, dst, 0x20); CpuCopy32(src + 192, dst, 0x20);
@ -1208,7 +1208,7 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
} }
RemoveWindow(windowId); RemoveWindow(windowId);
return (DISPLAY_WIDTH - (strWidth + 2) * 8) / 2; return (DISPLAY_WIDTH - (tileWidth + 2) * 8) / 2;
} }
static void CreateResultsTextWindowSprites(void) static void CreateResultsTextWindowSprites(void)

View File

@ -184,7 +184,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 9, .tilemapTop = 9,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 12, .height = 12,
.paletteNum = 8, .paletteNum = 8,
.baseBlock = 1 .baseBlock = 1

View File

@ -10,7 +10,7 @@ static const u16 sFrontierExchangeCorner_Decor1[] =
DECOR_CYNDAQUIL_DOLL, DECOR_CYNDAQUIL_DOLL,
DECOR_CHIKORITA_DOLL, DECOR_CHIKORITA_DOLL,
DECOR_TOTODILE_DOLL, DECOR_TOTODILE_DOLL,
0xFFFF ITEM_LIST_END
}; };
static const u16 sFrontierExchangeCorner_Decor2[] = static const u16 sFrontierExchangeCorner_Decor2[] =
@ -20,7 +20,7 @@ static const u16 sFrontierExchangeCorner_Decor2[] =
DECOR_VENUSAUR_DOLL, DECOR_VENUSAUR_DOLL,
DECOR_CHARIZARD_DOLL, DECOR_CHARIZARD_DOLL,
DECOR_BLASTOISE_DOLL, DECOR_BLASTOISE_DOLL,
0xFFFF ITEM_LIST_END
}; };
static const u16 sFrontierExchangeCorner_Vitamins[] = static const u16 sFrontierExchangeCorner_Vitamins[] =
@ -31,7 +31,7 @@ static const u16 sFrontierExchangeCorner_Vitamins[] =
ITEM_ZINC, ITEM_ZINC,
ITEM_CARBOS, ITEM_CARBOS,
ITEM_HP_UP, ITEM_HP_UP,
0xFFFF ITEM_LIST_END
}; };
static const u16 sFrontierExchangeCorner_HoldItems[] = static const u16 sFrontierExchangeCorner_HoldItems[] =
@ -45,7 +45,7 @@ static const u16 sFrontierExchangeCorner_HoldItems[] =
ITEM_KINGS_ROCK, ITEM_KINGS_ROCK,
ITEM_FOCUS_BAND, ITEM_FOCUS_BAND,
ITEM_SCOPE_LENS, ITEM_SCOPE_LENS,
0xFFFF ITEM_LIST_END
}; };
static const u8 *const sFrontierExchangeCorner_Decor1Descriptions[] = static const u8 *const sFrontierExchangeCorner_Decor1Descriptions[] =

View File

@ -1,4 +1,4 @@
const u32 *const gItemIconTable[][2] = const u32 *const gItemIconTable[ITEMS_COUNT + 1][2] =
{ {
[ITEM_NONE] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark}, [ITEM_NONE] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
// Poké Balls // Poké Balls
@ -804,5 +804,5 @@ const u32 *const gItemIconTable[][2] =
[ITEM_RUBY] = {gItemIcon_Gem, gItemIconPalette_Ruby}, [ITEM_RUBY] = {gItemIcon_Gem, gItemIconPalette_Ruby},
[ITEM_SAPPHIRE] = {gItemIcon_Gem, gItemIconPalette_Sapphire}, [ITEM_SAPPHIRE] = {gItemIcon_Gem, gItemIconPalette_Sapphire},
// Return to field arrow // Return to field arrow
[ITEM_FIELD_ARROW] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow}, [ITEMS_COUNT] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow},
}; };

View File

@ -4675,7 +4675,7 @@ static void ShowNames(void)
ClearWindowTilemap(sGfx->windowIds[i]); ClearWindowTilemap(sGfx->windowIds[i]);
RemoveWindow(sGfx->windowIds[i]); RemoveWindow(sGfx->windowIds[i]);
} }
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_INTERFACE);
sGfx->finished = TRUE; sGfx->finished = TRUE;
} }
@ -4859,7 +4859,7 @@ static void ShowResults(void)
sGfx->state++; sGfx->state++;
} }
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 5, 30, 15); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 5, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT - 5);
RemoveWindow(sGfx->windowIds[1]); RemoveWindow(sGfx->windowIds[1]);
sGfx->windowIds[1] = AddWindow(&sWindowTemplate_Prize); sGfx->windowIds[1] = AddWindow(&sWindowTemplate_Prize);
ClearWindowTilemap(sGfx->windowIds[1]); ClearWindowTilemap(sGfx->windowIds[1]);
@ -4917,7 +4917,7 @@ static void ShowResults(void)
ClearWindowTilemap(sGfx->windowIds[1]); ClearWindowTilemap(sGfx->windowIds[1]);
RemoveWindow(sGfx->windowIds[0]); RemoveWindow(sGfx->windowIds[0]);
RemoveWindow(sGfx->windowIds[1]); RemoveWindow(sGfx->windowIds[1]);
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_INTERFACE);
sGfx->finished = TRUE; sGfx->finished = TRUE;
break; break;
@ -5012,7 +5012,7 @@ static void Msg_WantToPlayAgain(void)
ClearWindowTilemap(sGfx->windowIds[WIN_YES_NO]); ClearWindowTilemap(sGfx->windowIds[WIN_YES_NO]);
RemoveWindow(sGfx->windowIds[WIN_PLAY_AGAIN]); RemoveWindow(sGfx->windowIds[WIN_PLAY_AGAIN]);
RemoveWindow(sGfx->windowIds[WIN_YES_NO]); RemoveWindow(sGfx->windowIds[WIN_YES_NO]);
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_INTERFACE);
sGfx->finished = TRUE; sGfx->finished = TRUE;
break; break;
@ -5044,7 +5044,7 @@ static void Msg_SavingDontTurnOff(void)
sGfx->state++; sGfx->state++;
break; break;
default: default:
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_INTERFACE);
sGfx->finished = TRUE; sGfx->finished = TRUE;
break; break;
@ -5083,7 +5083,7 @@ static void EraseMessage(void)
{ {
ClearWindowTilemap(sGfx->windowIds[0]); ClearWindowTilemap(sGfx->windowIds[0]);
RemoveWindow(sGfx->windowIds[0]); RemoveWindow(sGfx->windowIds[0]);
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_INTERFACE);
sGfx->finished = TRUE; sGfx->finished = TRUE;
} }
@ -5121,7 +5121,7 @@ static void Msg_SomeoneDroppedOut(void)
sGfx->playAgainState = PLAY_AGAIN_DROPPED; sGfx->playAgainState = PLAY_AGAIN_DROPPED;
ClearWindowTilemap(sGfx->windowIds[0]); ClearWindowTilemap(sGfx->windowIds[0]);
RemoveWindow(sGfx->windowIds[0]); RemoveWindow(sGfx->windowIds[0]);
FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_INTERFACE);
sGfx->finished = TRUE; sGfx->finished = TRUE;
break; break;

View File

@ -405,6 +405,11 @@ static const struct SpriteFrameImage sPicTable_HofMonitorSmall[] =
{.data = sHofMonitorSmall_Gfx, .size = 0x200} // the macro breaks down here {.data = sHofMonitorSmall_Gfx, .size = 0x200} // the macro breaks down here
}; };
/*
[0_][] <-1 24x16
[2 ][] <-3
^-- Origin
*/
static const struct Subsprite sSubsprites_PokecenterMonitor[] = static const struct Subsprite sSubsprites_PokecenterMonitor[] =
{ {
{ {
@ -443,6 +448,11 @@ static const struct Subsprite sSubsprites_PokecenterMonitor[] =
static const struct SubspriteTable sSubspriteTable_PokecenterMonitor = subsprite_table(sSubsprites_PokecenterMonitor); static const struct SubspriteTable sSubspriteTable_PokecenterMonitor = subsprite_table(sSubsprites_PokecenterMonitor);
/*
[0_____][1_____] 24x16
[2 ][3 ]
^-- Origin
*/
static const struct Subsprite sSubsprites_HofMonitorBig[] = static const struct Subsprite sSubsprites_HofMonitorBig[] =
{ {
{ {

View File

@ -1136,7 +1136,7 @@ static void Task_OrbEffect(u8 taskId)
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 7)); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 7));
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ);
SetBgTilemapPalette(0, 0, 0, 0x1E, 0x14, 0xF); SetBgTilemapPalette(0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 0xF);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
SetOrbFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], tCenterX, tCenterY, 1); SetOrbFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], tCenterX, tCenterY, 1);
CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480); CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480);

View File

@ -2925,7 +2925,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
{ {
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1: case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1:
AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_Decor1Descriptions[selection], 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY); AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_Decor1Descriptions[selection], 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
if (sFrontierExchangeCorner_Decor1[selection] == 0xFFFF) if (sFrontierExchangeCorner_Decor1[selection] == ITEM_LIST_END)
{ {
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor1[selection]); ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor1[selection]);
} }
@ -2938,7 +2938,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
break; break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2: case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_Decor2Descriptions[selection], 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY); AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_Decor2Descriptions[selection], 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
if (sFrontierExchangeCorner_Decor2[selection] == 0xFFFF) if (sFrontierExchangeCorner_Decor2[selection] == ITEM_LIST_END)
{ {
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor2[selection]); ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor2[selection]);
} }

View File

@ -760,9 +760,9 @@ static bool32 InitFrontierPass(void)
case 7: case 7:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return FALSE; return FALSE;
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);
@ -1396,9 +1396,9 @@ static bool32 InitFrontierMap(void)
SetBgTilemapBuffer(0, sMapData->tilemapBuff0); SetBgTilemapBuffer(0, sMapData->tilemapBuff0);
SetBgTilemapBuffer(1, sMapData->tilemapBuff1); SetBgTilemapBuffer(1, sMapData->tilemapBuff1);
SetBgTilemapBuffer(2, sMapData->tilemapBuff2); SetBgTilemapBuffer(2, sMapData->tilemapBuff2);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);

View File

@ -3322,24 +3322,29 @@ static u8 CreateGameFreakLogoSprites(s16 x, s16 y, s16 unused)
#undef sLetterX #undef sLetterX
#undef COLOR_CHANGES #undef COLOR_CHANGES
#define sScale data[1]
#define sRot data[2]
#define sPos data[3]
#define sTimer data[7]
static void SpriteCB_FlygonSilhouette(struct Sprite *sprite) static void SpriteCB_FlygonSilhouette(struct Sprite *sprite)
{ {
sprite->data[7]++; sprite->sTimer++;
if (sprite->sState != 0) if (sprite->sState != 0)
{ {
s16 sin1; s16 sin;
s16 sin2; s16 cos;
s16 a, b, c, d; s16 a, b, c, d;
// Determines rotation of the sprite
sin1 = gSineTable[(u8)sprite->data[2]]; sin = gSineTable[(u8)sprite->sRot];
sin2 = gSineTable[(u8)(sprite->data[2] + 64)]; cos = gSineTable[(u8)(sprite->sRot + 64)];
// Converts rotation and scale into the OAM matrix
d = Q_8_8_TO_INT(sin2 * sprite->data[1]); d = Q_8_8_TO_INT( cos * sprite->sScale);
c = Q_8_8_TO_INT(-sin1 * sprite->data[1]); c = Q_8_8_TO_INT(-sin * sprite->sScale);
b = Q_8_8_TO_INT(sin1 * sprite->data[1]); b = Q_8_8_TO_INT( sin * sprite->sScale);
a = Q_8_8_TO_INT(sin2 * sprite->data[1]); a = Q_8_8_TO_INT( cos * sprite->sScale);
SetOamMatrix(1, a, b, c, d); SetOamMatrix(1, a, b, c, d);
} }
@ -3353,36 +3358,41 @@ static void SpriteCB_FlygonSilhouette(struct Sprite *sprite)
CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_DOUBLE); CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_DOUBLE);
sprite->invisible = FALSE; sprite->invisible = FALSE;
sprite->sState = 1; sprite->sState = 1;
sprite->data[1] = 0x80; sprite->sScale = 128;
sprite->data[2] = 0; sprite->sRot = 0;
sprite->data[3] = 0; sprite->sPos = 0;
break; break;
case 1: case 1:
sprite->x2 = -Sin((u8)sprite->data[3], 140); sprite->x2 = -Sin((u8)sprite->sPos, 140);
sprite->y2 = -Sin((u8)sprite->data[3], 120); sprite->y2 = -Sin((u8)sprite->sPos, 120);
sprite->data[1] += 7; sprite->sScale += 7;
sprite->data[3] += 3; sprite->sPos += 3;
if (sprite->x + sprite->x2 <= -16) if (sprite->x + sprite->x2 <= -16)
{ {
sprite->oam.priority = 3; sprite->oam.priority = 3;
sprite->sState++; sprite->sState++;
sprite->x = 20; sprite->x = 20;
sprite->y = 40; sprite->y = 40;
sprite->data[1] = 0x200; sprite->sScale = 512;
sprite->data[2] = 0; sprite->sRot = 0;
sprite->data[3] = 0x10; sprite->sPos = 16;
} }
break; break;
case 2: case 2:
sprite->x2 = Sin((u8)sprite->data[3], 34); sprite->x2 = Sin((u8)sprite->sPos, 34);
sprite->y2 = -Cos((u8)sprite->data[3], 60); sprite->y2 = -Cos((u8)sprite->sPos, 60);
sprite->data[1] += 2; sprite->sScale += 2;
if (sprite->data[7] % 5 == 0) if (sprite->sTimer % 5 == 0)
sprite->data[3]++; sprite->sPos++;
break; break;
} }
} }
#undef sScale
#undef sRot
#undef sPos
#undef sTimer
static void SpriteCB_RayquazaOrb(struct Sprite *sprite) static void SpriteCB_RayquazaOrb(struct Sprite *sprite)
{ {
u16 foo; u16 foo;

View File

@ -880,6 +880,7 @@ const u8 *ItemId_GetName(u16 itemId)
return gItems[SanitizeItemId(itemId)].name; return gItems[SanitizeItemId(itemId)].name;
} }
// Unused
u16 ItemId_GetId(u16 itemId) u16 ItemId_GetId(u16 itemId)
{ {
return gItems[SanitizeItemId(itemId)].itemId; return gItems[SanitizeItemId(itemId)].itemId;
@ -910,7 +911,7 @@ u8 ItemId_GetImportance(u16 itemId)
return gItems[SanitizeItemId(itemId)].importance; return gItems[SanitizeItemId(itemId)].importance;
} }
// unused // Unused
u8 ItemId_GetRegistrability(u16 itemId) u8 ItemId_GetRegistrability(u16 itemId)
{ {
return gItems[SanitizeItemId(itemId)].registrability; return gItems[SanitizeItemId(itemId)].registrability;

View File

@ -159,8 +159,8 @@ u8 AddCustomItemIconSprite(const struct SpriteTemplate *customSpriteTemplate, u1
const void *GetItemIconPicOrPalette(u16 itemId, u8 which) const void *GetItemIconPicOrPalette(u16 itemId, u8 which)
{ {
if (itemId == 0xFFFF) if (itemId == ITEM_LIST_END)
itemId = ITEM_FIELD_ARROW; itemId = ITEMS_COUNT; // Use last icon, the "return to field" arrow
else if (itemId >= ITEMS_COUNT) else if (itemId >= ITEMS_COUNT)
itemId = 0; itemId = 0;

View File

@ -937,7 +937,7 @@ static void BagMenu_MoveCursorCallback(s32 itemIndex, bool8 onInit, struct ListM
if (itemIndex != LIST_CANCEL) if (itemIndex != LIST_CANCEL)
AddBagItemIconSprite(BagGetItemIdByPocketPosition(gBagPosition.pocket + 1, itemIndex), gBagMenu->itemIconSlot); AddBagItemIconSprite(BagGetItemIdByPocketPosition(gBagPosition.pocket + 1, itemIndex), gBagMenu->itemIconSlot);
else else
AddBagItemIconSprite(-1, gBagMenu->itemIconSlot); AddBagItemIconSprite(ITEM_LIST_END, gBagMenu->itemIconSlot);
gBagMenu->itemIconSlot ^= 1; gBagMenu->itemIconSlot ^= 1;
if (!gBagMenu->inhibitItemDescriptionPrint) if (!gBagMenu->inhibitItemDescriptionPrint)
PrintItemDescription(itemIndex); PrintItemDescription(itemIndex);

View File

@ -198,7 +198,7 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 0, .tilemapTop = 0,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 5, .height = 5,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x002 .baseBlock = 0x002
@ -206,7 +206,7 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 6, .tilemapTop = 6,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 7, .height = 7,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x098 .baseBlock = 0x098
@ -214,7 +214,7 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 13, .tilemapTop = 13,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 7, .height = 7,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x16A .baseBlock = 0x16A

View File

@ -556,8 +556,8 @@ static bool8 MailReadBuildGraphics(void)
} }
break; break;
case 10: case 10:
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 1, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 1, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyToBgTilemapBuffer(1, sMailGraphics[sMailRead->mailType].tileMap, 0, 0); CopyToBgTilemapBuffer(1, sMailGraphics[sMailRead->mailType].tileMap, 0, 0);
break; break;
case 11: case 11:

View File

@ -1121,7 +1121,7 @@ static void Task_DisplayMainMenuInvalidActionError(u8 taskId)
switch (gTasks[taskId].tCurrItem) switch (gTasks[taskId].tCurrItem)
{ {
case 0: case 0:
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
switch (gTasks[taskId].tMenuType) switch (gTasks[taskId].tMenuType)
{ {
case 0: case 0:

View File

@ -90,7 +90,7 @@ void CB2_InitMysteryEventMenu(void)
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
FillWindowPixelBuffer(i, PIXEL_FILL(0)); FillWindowPixelBuffer(i, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
LoadUserWindowBorderGfx(0, 1u, 0xD0u); LoadUserWindowBorderGfx(0, 1u, 0xD0u);
Menu_LoadStdPalAt(0xE0); Menu_LoadStdPalAt(0xE0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON);

View File

@ -102,7 +102,7 @@ static const struct WindowTemplate sMainWindows[] = {
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 0, .tilemapTop = 0,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 2, .height = 2,
.paletteNum = 12, .paletteNum = 12,
.baseBlock = 0x0013 .baseBlock = 0x0013
@ -118,7 +118,7 @@ static const struct WindowTemplate sMainWindows[] = {
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 15, .tilemapTop = 15,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 5, .height = 5,
.paletteNum = 13, .paletteNum = 13,
.baseBlock = 0x004f .baseBlock = 0x004f
@ -640,8 +640,8 @@ static u32 MysteryGift_HandleThreeOptionMenu(u8 *unused0, u16 * unused1, u8 whic
width++; width++;
windowTemplate.width = width; windowTemplate.width = width;
if (width < 30) if (width < DISPLAY_TILE_WIDTH)
windowTemplate.tilemapLeft = (30 - width) / 2; windowTemplate.tilemapLeft = (DISPLAY_TILE_WIDTH - width) / 2;
else else
windowTemplate.tilemapLeft = 0; windowTemplate.tilemapLeft = 0;

View File

@ -226,9 +226,9 @@ s32 WonderCard_Enter(void)
return 0; return 0;
break; break;
case 2: case 2:
FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);
@ -244,7 +244,7 @@ s32 WonderCard_Enter(void)
gPaletteFade.bufferTransferDisabled = TRUE; gPaletteFade.bufferTransferDisabled = TRUE;
LoadPalette(sWonderCardData->gfx->pal, 0x10, 0x20); LoadPalette(sWonderCardData->gfx->pal, 0x10, 0x20);
LZ77UnCompWram(sWonderCardData->gfx->map, sWonderCardData->bgTilemapBuffer); LZ77UnCompWram(sWonderCardData->gfx->map, sWonderCardData->bgTilemapBuffer);
CopyRectToBgTilemapBufferRect(2, sWonderCardData->bgTilemapBuffer, 0, 0, 30, 20, 0, 0, 30, 20, 1, 0x008, 0); CopyRectToBgTilemapBufferRect(2, sWonderCardData->bgTilemapBuffer, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 1, 0x008, 0);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);
break; break;
case 4: case 4:
@ -291,9 +291,9 @@ s32 WonderCard_Exit(bool32 useCancel)
return 0; return 0;
break; break;
case 2: case 2:
FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);
@ -595,7 +595,7 @@ static const struct WindowTemplate sNews_WindowTemplates[] = {
.tilemapLeft = 1, .tilemapLeft = 1,
.tilemapTop = 3, .tilemapTop = 3,
.width = 28, .width = 28,
.height = 20, .height = DISPLAY_TILE_HEIGHT,
.paletteNum = 2, .paletteNum = 2,
.baseBlock = 0x07C .baseBlock = 0x07C
} }
@ -688,10 +688,10 @@ s32 WonderNews_Enter(void)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
break; break;
case 2: case 2:
FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(3, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(3, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);
@ -707,8 +707,8 @@ s32 WonderNews_Enter(void)
gPaletteFade.bufferTransferDisabled = TRUE; gPaletteFade.bufferTransferDisabled = TRUE;
LoadPalette(sWonderNewsData->gfx->pal, 0x10, 0x20); LoadPalette(sWonderNewsData->gfx->pal, 0x10, 0x20);
LZ77UnCompWram(sWonderNewsData->gfx->map, sWonderNewsData->bgTilemapBuffer); LZ77UnCompWram(sWonderNewsData->gfx->map, sWonderNewsData->bgTilemapBuffer);
CopyRectToBgTilemapBufferRect(1, sWonderNewsData->bgTilemapBuffer, 0, 0, 30, 3, 0, 0, 30, 3, 1, 8, 0); CopyRectToBgTilemapBufferRect(1, sWonderNewsData->bgTilemapBuffer, 0, 0, DISPLAY_TILE_WIDTH, 3, 0, 0, DISPLAY_TILE_WIDTH, 3, 1, 8, 0);
CopyRectToBgTilemapBufferRect(3, sWonderNewsData->bgTilemapBuffer, 0, 3, 30, 23, 0, 3, 30, 23, 1, 8, 0); CopyRectToBgTilemapBufferRect(3, sWonderNewsData->bgTilemapBuffer, 0, 3, DISPLAY_TILE_WIDTH, 3 + DISPLAY_TILE_HEIGHT, 0, 3, DISPLAY_TILE_WIDTH, 3 + DISPLAY_TILE_HEIGHT, 1, 8, 0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(3); CopyBgTilemapBufferToVram(3);
break; break;
@ -760,10 +760,10 @@ s32 WonderNews_Exit(bool32 useCancel)
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
break; break;
case 2: case 2:
FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, 30, 24); FillBgTilemapBufferRect_Palette0(2, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT + 4);
FillBgTilemapBufferRect_Palette0(3, 0x000, 0, 0, 30, 24); FillBgTilemapBufferRect_Palette0(3, 0x000, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT + 4);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);

View File

@ -267,7 +267,7 @@ static const struct WindowTemplate sWindowTemplates[WIN_COUNT + 1] =
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 0, .tilemapTop = 0,
.width = 30, .width = DISPLAY_TILE_WIDTH,
.height = 2, .height = 2,
.paletteNum = 11, .paletteNum = 11,
.baseBlock = 0x074 .baseBlock = 0x074
@ -2179,6 +2179,12 @@ static const struct OamData sOam_32x16 =
.paletteNum = 0, .paletteNum = 0,
}; };
/*
[0_____][] <-1 40x32
[2_____][] <-3
[4___+_][] <-5/Origin
[6 ][] <-7
*/
static const struct Subsprite sSubsprites_PageSwapFrame[] = static const struct Subsprite sSubsprites_PageSwapFrame[] =
{ {
{ {
@ -2247,6 +2253,10 @@ static const struct Subsprite sSubsprites_PageSwapFrame[] =
} }
}; };
/*
[0_][] <-1 24x8
^-- Origin
*/
static const struct Subsprite sSubsprites_PageSwapText[] = static const struct Subsprite sSubsprites_PageSwapText[] =
{ {
{ {
@ -2267,6 +2277,11 @@ static const struct Subsprite sSubsprites_PageSwapText[] =
} }
}; };
/*
[0_____][] <-1 40x24
[2_____][] <-3
[4___+_][] <-5/Origin
*/
static const struct Subsprite sSubsprites_Button[] = static const struct Subsprite sSubsprites_Button[] =
{ {
{ {
@ -2319,6 +2334,11 @@ static const struct Subsprite sSubsprites_Button[] =
} }
}; };
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
static const struct Subsprite sSubsprites_PCIcon[] = static const struct Subsprite sSubsprites_PCIcon[] =
{ {
{ {

View File

@ -2857,7 +2857,7 @@ static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newW
{ {
if (x + width < 0) if (x + width < 0)
return FALSE; return FALSE;
if (x > 31) if (x >= 32)
return FALSE; return FALSE;
if (x < 0) if (x < 0)
@ -2870,7 +2870,7 @@ static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newW
{ {
*leftMove = 0; *leftMove = 0;
*newX = x; *newX = x;
if (x + width > 31) if (x + width >= 32)
*newWidth = 32 - x; *newWidth = 32 - x;
else else
*newWidth = width; *newWidth = width;

View File

@ -1015,7 +1015,7 @@ static void ItemStorage_MoveCursor(s32 id, bool8 onInit, struct ListMenu *list)
if (id != LIST_CANCEL) if (id != LIST_CANCEL)
ItemStorage_DrawItemIcon(gSaveBlock1Ptr->pcItems[id].itemId); ItemStorage_DrawItemIcon(gSaveBlock1Ptr->pcItems[id].itemId);
else else
ItemStorage_DrawItemIcon(MSG_GO_BACK_TO_PREV); ItemStorage_DrawItemIcon(ITEM_LIST_END);
ItemStorage_PrintDescription(id); ItemStorage_PrintDescription(id);
} }
} }

View File

@ -42,10 +42,72 @@
#define TAG_SCROLL_ARROW 2100 #define TAG_SCROLL_ARROW 2100
#define TAG_ITEM_ICON_BASE 2110 #define TAG_ITEM_ICON_BASE 2110
#define MAX_ITEMS_SHOWN 8
enum {
WIN_BUY_SELL_QUIT,
WIN_BUY_QUIT,
};
enum {
WIN_MONEY,
WIN_ITEM_LIST,
WIN_ITEM_DESCRIPTION,
WIN_QUANTITY_IN_BAG,
WIN_QUANTITY_PRICE,
WIN_MESSAGE,
};
enum {
COLORID_NORMAL, // Item descriptions, quantity in bag, and quantity/price
COLORID_ITEM_LIST, // The text in the item list, and the cursor normally
COLORID_GRAY_CURSOR, // When the cursor has selected an item to purchase
};
enum {
MART_TYPE_NORMAL,
MART_TYPE_DECOR,
MART_TYPE_DECOR2,
};
// shop view window NPC info enum
enum
{
OBJ_EVENT_ID,
X_COORD,
Y_COORD,
ANIM_NUM,
LAYER_TYPE
};
struct MartInfo
{
void (*callback)(void);
const struct MenuAction *menuActions;
const u16 *itemList;
u16 itemCount;
u8 windowId;
u8 martType;
};
struct ShopData
{
u16 tilemapBuffers[4][0x400];
u32 totalCost;
u16 itemsShowed;
u16 selectedRow;
u16 scrollOffset;
u8 maxQuantity;
u8 scrollIndicatorsTaskId;
u8 iconSlot;
u8 itemSpriteIds[2];
s16 viewportObjects[OBJECT_EVENTS_COUNT][5];
};
static EWRAM_DATA struct MartInfo sMartInfo = {0}; static EWRAM_DATA struct MartInfo sMartInfo = {0};
static EWRAM_DATA struct ShopData *sShopData = NULL; static EWRAM_DATA struct ShopData *sShopData = NULL;
static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL; static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL;
static EWRAM_DATA u8 (*sItemNames)[16] = {0}; static EWRAM_DATA u8 (*sItemNames)[ITEM_NAME_LENGTH + 2] = {0};
static EWRAM_DATA u8 sPurchaseHistoryId = 0; static EWRAM_DATA u8 sPurchaseHistoryId = 0;
EWRAM_DATA struct ItemSlot gMartPurchaseHistory[SMARTSHOPPER_NUM_ITEMS] = {0}; EWRAM_DATA struct ItemSlot gMartPurchaseHistory[SMARTSHOPPER_NUM_ITEMS] = {0};
@ -114,7 +176,7 @@ static const struct MenuAction sShopMenuActions_BuyQuit[] =
static const struct WindowTemplate sShopMenuWindowTemplates[] = static const struct WindowTemplate sShopMenuWindowTemplates[] =
{ {
{ [WIN_BUY_SELL_QUIT] = {
.bg = 0, .bg = 0,
.tilemapLeft = 2, .tilemapLeft = 2,
.tilemapTop = 1, .tilemapTop = 1,
@ -123,7 +185,8 @@ static const struct WindowTemplate sShopMenuWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x0008, .baseBlock = 0x0008,
}, },
{ // Separate shop menu window for decorations, which can't be sold
[WIN_BUY_QUIT] = {
.bg = 0, .bg = 0,
.tilemapLeft = 2, .tilemapLeft = 2,
.tilemapTop = 1, .tilemapTop = 1,
@ -141,7 +204,7 @@ static const struct ListMenuTemplate sShopBuyMenuListTemplate =
.itemPrintFunc = BuyMenuPrintPriceInList, .itemPrintFunc = BuyMenuPrintPriceInList,
.totalItems = 0, .totalItems = 0,
.maxShowed = 0, .maxShowed = 0,
.windowId = 1, .windowId = WIN_ITEM_LIST,
.header_X = 0, .header_X = 0,
.item_X = 8, .item_X = 8,
.cursor_X = 0, .cursor_X = 0,
@ -198,7 +261,7 @@ static const struct BgTemplate sShopBuyMenuBgTemplates[] =
static const struct WindowTemplate sShopBuyMenuWindowTemplates[] = static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
{ {
{ [WIN_MONEY] = {
.bg = 0, .bg = 0,
.tilemapLeft = 1, .tilemapLeft = 1,
.tilemapTop = 1, .tilemapTop = 1,
@ -207,7 +270,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x001E, .baseBlock = 0x001E,
}, },
{ [WIN_ITEM_LIST] = {
.bg = 0, .bg = 0,
.tilemapLeft = 14, .tilemapLeft = 14,
.tilemapTop = 2, .tilemapTop = 2,
@ -216,7 +279,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x0032, .baseBlock = 0x0032,
}, },
{ [WIN_ITEM_DESCRIPTION] = {
.bg = 0, .bg = 0,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 13, .tilemapTop = 13,
@ -225,7 +288,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x0122, .baseBlock = 0x0122,
}, },
{ [WIN_QUANTITY_IN_BAG] = {
.bg = 0, .bg = 0,
.tilemapLeft = 1, .tilemapLeft = 1,
.tilemapTop = 11, .tilemapTop = 11,
@ -234,7 +297,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x0176, .baseBlock = 0x0176,
}, },
{ [WIN_QUANTITY_PRICE] = {
.bg = 0, .bg = 0,
.tilemapLeft = 18, .tilemapLeft = 18,
.tilemapTop = 11, .tilemapTop = 11,
@ -243,7 +306,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x018E, .baseBlock = 0x018E,
}, },
{ [WIN_MESSAGE] = {
.bg = 0, .bg = 0,
.tilemapLeft = 2, .tilemapLeft = 2,
.tilemapTop = 15, .tilemapTop = 15,
@ -268,9 +331,9 @@ static const struct WindowTemplate sShopBuyMenuYesNoWindowTemplates =
static const u8 sShopBuyMenuTextColors[][3] = static const u8 sShopBuyMenuTextColors[][3] =
{ {
{1, 2, 3}, [COLORID_NORMAL] = {1, 2, 3},
{0, 2, 3}, [COLORID_ITEM_LIST] = {0, 2, 3},
{0, 3, 2} [COLORID_GRAY_CURSOR] = {0, 3, 2},
}; };
static u8 CreateShopMenu(u8 martType) static u8 CreateShopMenu(u8 martType)
@ -282,8 +345,7 @@ static u8 CreateShopMenu(u8 martType)
if (martType == MART_TYPE_NORMAL) if (martType == MART_TYPE_NORMAL)
{ {
struct WindowTemplate winTemplate; struct WindowTemplate winTemplate = sShopMenuWindowTemplates[WIN_BUY_SELL_QUIT];
winTemplate = sShopMenuWindowTemplates[0];
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit)); winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit));
sMartInfo.windowId = AddWindow(&winTemplate); sMartInfo.windowId = AddWindow(&winTemplate);
sMartInfo.menuActions = sShopMenuActions_BuySellQuit; sMartInfo.menuActions = sShopMenuActions_BuySellQuit;
@ -291,8 +353,7 @@ static u8 CreateShopMenu(u8 martType)
} }
else else
{ {
struct WindowTemplate winTemplate; struct WindowTemplate winTemplate = sShopMenuWindowTemplates[WIN_BUY_QUIT];
winTemplate = sShopMenuWindowTemplates[1];
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit)); winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit));
sMartInfo.windowId = AddWindow(&winTemplate); sMartInfo.windowId = AddWindow(&winTemplate);
sMartInfo.menuActions = sShopMenuActions_BuyQuit; sMartInfo.menuActions = sShopMenuActions_BuyQuit;
@ -320,6 +381,7 @@ static void SetShopItemsForSale(const u16 *items)
sMartInfo.itemList = items; sMartInfo.itemList = items;
sMartInfo.itemCount = 0; sMartInfo.itemCount = 0;
// Read items until ITEM_NONE / DECOR_NONE is reached
while (sMartInfo.itemList[i]) while (sMartInfo.itemList[i])
{ {
sMartInfo.itemCount++; sMartInfo.itemCount++;
@ -344,11 +406,17 @@ static void Task_ShopMenu(u8 taskId)
} }
} }
#define tItemCount data[1]
#define tItemId data[5]
#define tListTaskId data[7]
#define tCallbackHi data[8]
#define tCallbackLo data[9]
static void Task_HandleShopMenuBuy(u8 taskId) static void Task_HandleShopMenuBuy(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
data[8] = (u32)CB2_InitBuyMenu >> 16; tCallbackHi = (u32)CB2_InitBuyMenu >> 16;
data[9] = (u32)CB2_InitBuyMenu; tCallbackLo = (u32)CB2_InitBuyMenu;
gTasks[taskId].func = Task_GoToBuyOrSellMenu; gTasks[taskId].func = Task_GoToBuyOrSellMenu;
FadeScreen(FADE_TO_BLACK, 0); FadeScreen(FADE_TO_BLACK, 0);
} }
@ -356,8 +424,8 @@ static void Task_HandleShopMenuBuy(u8 taskId)
static void Task_HandleShopMenuSell(u8 taskId) static void Task_HandleShopMenuSell(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
data[8] = (u32)CB2_GoToSellMenu >> 16; tCallbackHi = (u32)CB2_GoToSellMenu >> 16;
data[9] = (u32)CB2_GoToSellMenu; tCallbackLo = (u32)CB2_GoToSellMenu;
gTasks[taskId].func = Task_GoToBuyOrSellMenu; gTasks[taskId].func = Task_GoToBuyOrSellMenu;
FadeScreen(FADE_TO_BLACK, 0); FadeScreen(FADE_TO_BLACK, 0);
} }
@ -386,7 +454,7 @@ static void Task_GoToBuyOrSellMenu(u8 taskId)
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
DestroyTask(taskId); DestroyTask(taskId);
SetMainCallback2((void *)((u16)data[8] << 16 | (u16)data[9])); SetMainCallback2((void *)((u16)tCallbackHi << 16 | (u16)tCallbackLo));
} }
} }
@ -429,10 +497,6 @@ static void VBlankCB_BuyMenu(void)
TransferPlttBuffer(); TransferPlttBuffer();
} }
#define tItemCount data[1]
#define tItemId data[5]
#define tListTaskId data[7]
static void CB2_InitBuyMenu(void) static void CB2_InitBuyMenu(void)
{ {
u8 taskId; u8 taskId;
@ -472,8 +536,8 @@ static void CB2_InitBuyMenu(void)
BuyMenuAddScrollIndicatorArrows(); BuyMenuAddScrollIndicatorArrows();
taskId = CreateTask(Task_BuyMenu, 8); taskId = CreateTask(Task_BuyMenu, 8);
gTasks[taskId].tListTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); gTasks[taskId].tListTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
BlendPalettes(PALETTES_ALL, 0x10, RGB_BLACK); BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
SetVBlankCallback(VBlankCB_BuyMenu); SetVBlankCallback(VBlankCB_BuyMenu);
SetMainCallback2(CB2_BuyMenu); SetMainCallback2(CB2_BuyMenu);
break; break;
@ -504,8 +568,8 @@ static void BuyMenuBuildListMenuTemplate(void)
gMultiuseListMenuTemplate = sShopBuyMenuListTemplate; gMultiuseListMenuTemplate = sShopBuyMenuListTemplate;
gMultiuseListMenuTemplate.items = sListMenuItems; gMultiuseListMenuTemplate.items = sListMenuItems;
gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1; gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1;
if (gMultiuseListMenuTemplate.totalItems > 8) if (gMultiuseListMenuTemplate.totalItems > MAX_ITEMS_SHOWN)
gMultiuseListMenuTemplate.maxShowed = 8; gMultiuseListMenuTemplate.maxShowed = MAX_ITEMS_SHOWN;
else else
gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems; gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems;
@ -532,7 +596,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
if (item != LIST_CANCEL) if (item != LIST_CANCEL)
BuyMenuAddItemIcon(item, sShopData->iconSlot); BuyMenuAddItemIcon(item, sShopData->iconSlot);
else else
BuyMenuAddItemIcon(-1, sShopData->iconSlot); BuyMenuAddItemIcon(ITEM_LIST_END, sShopData->iconSlot);
BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1); BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1);
sShopData->iconSlot ^= 1; sShopData->iconSlot ^= 1;
@ -548,8 +612,8 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
description = gText_QuitShopping; description = gText_QuitShopping;
} }
FillWindowPixelBuffer(2, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_ITEM_DESCRIPTION, PIXEL_FILL(0));
BuyMenuPrint(2, description, 3, 1, 0, 0); BuyMenuPrint(WIN_ITEM_DESCRIPTION, description, 3, 1, 0, COLORID_NORMAL);
} }
static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y) static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y)
@ -576,21 +640,21 @@ static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y)
} }
StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1); StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1);
x = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 0x78); x = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 120);
AddTextPrinterParameterized4(windowId, FONT_NARROW, x, y, 0, 0, sShopBuyMenuTextColors[1], TEXT_SKIP_DRAW, gStringVar4); AddTextPrinterParameterized4(windowId, FONT_NARROW, x, y, 0, 0, sShopBuyMenuTextColors[COLORID_ITEM_LIST], TEXT_SKIP_DRAW, gStringVar4);
} }
} }
static void BuyMenuAddScrollIndicatorArrows(void) static void BuyMenuAddScrollIndicatorArrows(void)
{ {
if (sShopData->scrollIndicatorsTaskId == TASK_NONE && sMartInfo.itemCount + 1 > 8) if (sShopData->scrollIndicatorsTaskId == TASK_NONE && sMartInfo.itemCount + 1 > MAX_ITEMS_SHOWN)
{ {
sShopData->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized( sShopData->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
SCROLL_ARROW_UP, SCROLL_ARROW_UP,
172, 172,
12, 12,
148, 148,
sMartInfo.itemCount - 7, sMartInfo.itemCount - (MAX_ITEMS_SHOWN - 1),
TAG_SCROLL_ARROW, TAG_SCROLL_ARROW,
TAG_SCROLL_ARROW, TAG_SCROLL_ARROW,
&sShopData->scrollOffset); &sShopData->scrollOffset);
@ -609,7 +673,7 @@ static void BuyMenuRemoveScrollIndicatorArrows(void)
static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet) static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet)
{ {
u8 y = ListMenuGetYCoordForPrintingArrowCursor(scrollIndicatorsTaskId); u8 y = ListMenuGetYCoordForPrintingArrowCursor(scrollIndicatorsTaskId);
BuyMenuPrint(1, gText_SelectorArrow2, 0, y, 0, colorSet); BuyMenuPrint(WIN_ITEM_LIST, gText_SelectorArrow2, 0, y, 0, colorSet);
} }
static void BuyMenuAddItemIcon(u16 item, u8 iconSlot) static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
@ -619,7 +683,7 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
if (*spriteIdPtr != SPRITE_NONE) if (*spriteIdPtr != SPRITE_NONE)
return; return;
if (sMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF) if (sMartInfo.martType == MART_TYPE_NORMAL || item == ITEM_LIST_END)
{ {
spriteId = AddItemIconSprite(iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE, item); spriteId = AddItemIconSprite(iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE, item);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
@ -683,11 +747,11 @@ static void BuyMenuInitWindows(void)
{ {
InitWindows(sShopBuyMenuWindowTemplates); InitWindows(sShopBuyMenuWindowTemplates);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
LoadUserWindowBorderGfx(0, 1, 0xD0); LoadUserWindowBorderGfx(WIN_MONEY, 1, 0xD0);
LoadMessageBoxGfx(0, 0xA, 0xE0); LoadMessageBoxGfx(WIN_MONEY, 0xA, 0xE0);
PutWindowTilemap(0); PutWindowTilemap(WIN_MONEY);
PutWindowTilemap(1); PutWindowTilemap(WIN_ITEM_LIST);
PutWindowTilemap(2); PutWindowTilemap(WIN_ITEM_DESCRIPTION);
} }
static void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 colorSet) static void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 colorSet)
@ -697,7 +761,7 @@ static void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 c
static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback) static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback)
{ {
DisplayMessageAndContinueTask(taskId, 5, 10, 14, FONT_NORMAL, GetPlayerTextSpeedDelay(), text, callback); DisplayMessageAndContinueTask(taskId, WIN_MESSAGE, 10, 14, FONT_NORMAL, GetPlayerTextSpeedDelay(), text, callback);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
} }
@ -706,7 +770,7 @@ static void BuyMenuDrawGraphics(void)
BuyMenuDrawMapGraphics(); BuyMenuDrawMapGraphics();
BuyMenuCopyMenuBgToBg1TilemapBuffer(); BuyMenuCopyMenuBgToBg1TilemapBuffer();
AddMoneyLabelObject(19, 11); AddMoneyLabelObject(19, 11);
PrintMoneyAmountInMoneyBoxWithBorder(0, 1, 13, GetMoney(&gSaveBlock1Ptr->money)); PrintMoneyAmountInMoneyBoxWithBorder(WIN_MONEY, 1, 13, GetMoney(&gSaveBlock1Ptr->money));
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
ScheduleBgCopyTilemapToVram(1); ScheduleBgCopyTilemapToVram(1);
ScheduleBgCopyTilemapToVram(2); ScheduleBgCopyTilemapToVram(2);
@ -722,10 +786,8 @@ static void BuyMenuDrawMapGraphics(void)
static void BuyMenuDrawMapBg(void) static void BuyMenuDrawMapBg(void)
{ {
s16 i; s16 i, j;
s16 j; s16 x, y;
s16 x;
s16 y;
const struct MapLayout *mapLayout; const struct MapLayout *mapLayout;
u16 metatile; u16 metatile;
u8 metatileLayerType; u8 metatileLayerType;
@ -746,13 +808,9 @@ static void BuyMenuDrawMapBg(void)
metatileLayerType = METATILE_LAYER_TYPE_COVERED; metatileLayerType = METATILE_LAYER_TYPE_COVERED;
if (metatile < NUM_METATILES_IN_PRIMARY) if (metatile < NUM_METATILES_IN_PRIMARY)
{
BuyMenuDrawMapMetatile(i, j, (u16 *)mapLayout->primaryTileset->metatiles + metatile * 8, metatileLayerType); BuyMenuDrawMapMetatile(i, j, (u16 *)mapLayout->primaryTileset->metatiles + metatile * 8, metatileLayerType);
}
else else
{
BuyMenuDrawMapMetatile(i, j, (u16 *)mapLayout->secondaryTileset->metatiles + ((metatile - NUM_METATILES_IN_PRIMARY) * 8), metatileLayerType); BuyMenuDrawMapMetatile(i, j, (u16 *)mapLayout->secondaryTileset->metatiles + ((metatile - NUM_METATILES_IN_PRIMARY) * 8), metatileLayerType);
}
} }
} }
} }
@ -794,11 +852,13 @@ static void BuyMenuCollectObjectEventData(void)
s16 facingY; s16 facingY;
u8 y; u8 y;
u8 x; u8 x;
u8 r8 = 0; u8 numObjects = 0;
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
for (y = 0; y < OBJECT_EVENTS_COUNT; y++) for (y = 0; y < OBJECT_EVENTS_COUNT; y++)
sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT; sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
for (y = 0; y < 5; y++) for (y = 0; y < 5; y++)
{ {
for (x = 0; x < 7; x++) for (x = 0; x < 7; x++)
@ -807,28 +867,28 @@ static void BuyMenuCollectObjectEventData(void)
if (objEventId != OBJECT_EVENTS_COUNT) if (objEventId != OBJECT_EVENTS_COUNT)
{ {
sShopData->viewportObjects[r8][OBJ_EVENT_ID] = objEventId; sShopData->viewportObjects[numObjects][OBJ_EVENT_ID] = objEventId;
sShopData->viewportObjects[r8][X_COORD] = x; sShopData->viewportObjects[numObjects][X_COORD] = x;
sShopData->viewportObjects[r8][Y_COORD] = y; sShopData->viewportObjects[numObjects][Y_COORD] = y;
sShopData->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y); sShopData->viewportObjects[numObjects][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
switch (gObjectEvents[objEventId].facingDirection) switch (gObjectEvents[objEventId].facingDirection)
{ {
case DIR_SOUTH: case DIR_SOUTH:
sShopData->viewportObjects[r8][ANIM_NUM] = 0; sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_SOUTH;
break; break;
case DIR_NORTH: case DIR_NORTH:
sShopData->viewportObjects[r8][ANIM_NUM] = 1; sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_NORTH;
break; break;
case DIR_WEST: case DIR_WEST:
sShopData->viewportObjects[r8][ANIM_NUM] = 2; sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_WEST;
break; break;
case DIR_EAST: case DIR_EAST:
default: default:
sShopData->viewportObjects[r8][ANIM_NUM] = 3; sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_EAST;
break; break;
} }
r8++; numObjects++;
} }
} }
} }
@ -867,13 +927,9 @@ static void BuyMenuDrawObjectEvents(void)
static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object) static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object)
{ {
if (!BuyMenuCheckForOverlapWithMenuBg(object[X_COORD], object[Y_COORD] + 2) && object[LAYER_TYPE] != METATILE_LAYER_TYPE_COVERED) if (!BuyMenuCheckForOverlapWithMenuBg(object[X_COORD], object[Y_COORD] + 2) && object[LAYER_TYPE] != METATILE_LAYER_TYPE_COVERED)
{
return TRUE; return TRUE;
}
else else
{
return FALSE; return FALSE;
}
} }
static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void) static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
@ -885,9 +941,7 @@ static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
{ {
if (src[i] != 0) if (src[i] != 0)
{
dest[i] = src[i] + 0xC3E3; dest[i] = src[i] + 0xC3E3;
}
} }
} }
@ -901,9 +955,7 @@ static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y)
metatile[offset2 + offset1 + 32] == 0 && metatile[offset2 + offset1 + 32] == 0 &&
metatile[offset2 + offset1 + 1] == 0 && metatile[offset2 + offset1 + 1] == 0 &&
metatile[offset2 + offset1 + 33] == 0) metatile[offset2 + offset1 + 33] == 0)
{
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
@ -928,18 +980,14 @@ static void Task_BuyMenu(u8 taskId)
default: default:
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
tItemId = itemId; tItemId = itemId;
ClearWindowTilemap(2); ClearWindowTilemap(WIN_ITEM_DESCRIPTION);
BuyMenuRemoveScrollIndicatorArrows(); BuyMenuRemoveScrollIndicatorArrows();
BuyMenuPrintCursor(tListTaskId, 2); BuyMenuPrintCursor(tListTaskId, COLORID_GRAY_CURSOR);
if (sMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{
sShopData->totalCost = (ItemId_GetPrice(itemId) >> IsPokeNewsActive(POKENEWS_SLATEPORT)); sShopData->totalCost = (ItemId_GetPrice(itemId) >> IsPokeNewsActive(POKENEWS_SLATEPORT));
}
else else
{
sShopData->totalCost = gDecorations[itemId].price; sShopData->totalCost = gDecorations[itemId].price;
}
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost)) if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost))
{ {
@ -985,25 +1033,21 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
u16 quantityInBag = CountTotalItemQuantityInBag(tItemId); u16 quantityInBag = CountTotalItemQuantityInBag(tItemId);
u16 maxQuantity; u16 maxQuantity;
DrawStdFrameWithCustomTileAndPalette(3, FALSE, 1, 13); DrawStdFrameWithCustomTileAndPalette(WIN_QUANTITY_IN_BAG, FALSE, 1, 13);
ConvertIntToDecimalStringN(gStringVar1, quantityInBag, STR_CONV_MODE_RIGHT_ALIGN, MAX_ITEM_DIGITS + 1); ConvertIntToDecimalStringN(gStringVar1, quantityInBag, STR_CONV_MODE_RIGHT_ALIGN, MAX_ITEM_DIGITS + 1);
StringExpandPlaceholders(gStringVar4, gText_InBagVar1); StringExpandPlaceholders(gStringVar4, gText_InBagVar1);
BuyMenuPrint(3, gStringVar4, 0, 1, 0, 0); BuyMenuPrint(WIN_QUANTITY_IN_BAG, gStringVar4, 0, 1, 0, COLORID_NORMAL);
tItemCount = 1; tItemCount = 1;
DrawStdFrameWithCustomTileAndPalette(4, FALSE, 1, 13); DrawStdFrameWithCustomTileAndPalette(WIN_QUANTITY_PRICE, FALSE, 1, 13);
BuyMenuPrintItemQuantityAndPrice(taskId); BuyMenuPrintItemQuantityAndPrice(taskId);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost; maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost;
if (maxQuantity > MAX_BAG_ITEM_CAPACITY) if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
{
sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY; sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY;
}
else else
{
sShopData->maxQuantity = maxQuantity; sShopData->maxQuantity = maxQuantity;
}
gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput; gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput;
} }
@ -1022,11 +1066,11 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
if (JOY_NEW(A_BUTTON)) if (JOY_NEW(A_BUTTON))
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(4, FALSE); ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_PRICE, FALSE);
ClearStdWindowAndFrameToTransparent(3, FALSE); ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_IN_BAG, FALSE);
ClearWindowTilemap(4); ClearWindowTilemap(WIN_QUANTITY_PRICE);
ClearWindowTilemap(3); ClearWindowTilemap(WIN_QUANTITY_IN_BAG);
PutWindowTilemap(1); PutWindowTilemap(WIN_ITEM_LIST);
CopyItemName(tItemId, gStringVar1); CopyItemName(tItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS); ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
@ -1035,10 +1079,10 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
else if (JOY_NEW(B_BUTTON)) else if (JOY_NEW(B_BUTTON))
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(4, FALSE); ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_PRICE, FALSE);
ClearStdWindowAndFrameToTransparent(3, FALSE); ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_IN_BAG, FALSE);
ClearWindowTilemap(4); ClearWindowTilemap(WIN_QUANTITY_PRICE);
ClearWindowTilemap(3); ClearWindowTilemap(WIN_QUANTITY_IN_BAG);
BuyMenuReturnToItemList(taskId); BuyMenuReturnToItemList(taskId);
} }
} }
@ -1053,7 +1097,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
PutWindowTilemap(1); PutWindowTilemap(WIN_ITEM_LIST);
if (sMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{ {
@ -1088,16 +1132,12 @@ static void BuyMenuSubtractMoney(u8 taskId)
IncrementGameStat(GAME_STAT_SHOPPED); IncrementGameStat(GAME_STAT_SHOPPED);
RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost); RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost);
PlaySE(SE_SHOP); PlaySE(SE_SHOP);
PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0); PrintMoneyAmountInMoneyBox(WIN_MONEY, GetMoney(&gSaveBlock1Ptr->money), 0);
if (sMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{
gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase; gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase;
}
else else
{
gTasks[taskId].func = Task_ReturnToItemListAfterDecorationPurchase; gTasks[taskId].func = Task_ReturnToItemListAfterDecorationPurchase;
}
} }
static void Task_ReturnToItemListAfterItemPurchase(u8 taskId) static void Task_ReturnToItemListAfterItemPurchase(u8 taskId)
@ -1107,14 +1147,12 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId)
if (JOY_NEW(A_BUTTON | B_BUTTON)) if (JOY_NEW(A_BUTTON | B_BUTTON))
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
if (tItemId == ITEM_POKE_BALL && tItemCount > 9 && AddBagItem(ITEM_PREMIER_BALL, 1) == TRUE)
{ // Purchasing 10+ Poke Balls gets the player a Premier Ball
if (tItemId == ITEM_POKE_BALL && tItemCount >= 10 && AddBagItem(ITEM_PREMIER_BALL, 1) == TRUE)
BuyMenuDisplayMessage(taskId, gText_ThrowInPremierBall, BuyMenuReturnToItemList); BuyMenuDisplayMessage(taskId, gText_ThrowInPremierBall, BuyMenuReturnToItemList);
}
else else
{
BuyMenuReturnToItemList(taskId); BuyMenuReturnToItemList(taskId);
}
} }
} }
@ -1131,10 +1169,10 @@ static void BuyMenuReturnToItemList(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
ClearDialogWindowAndFrameToTransparent(5, FALSE); ClearDialogWindowAndFrameToTransparent(WIN_MESSAGE, FALSE);
BuyMenuPrintCursor(tListTaskId, 1); BuyMenuPrintCursor(tListTaskId, COLORID_ITEM_LIST);
PutWindowTilemap(1); PutWindowTilemap(WIN_ITEM_LIST);
PutWindowTilemap(2); PutWindowTilemap(WIN_ITEM_DESCRIPTION);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
BuyMenuAddScrollIndicatorArrows(); BuyMenuAddScrollIndicatorArrows();
gTasks[taskId].func = Task_BuyMenu; gTasks[taskId].func = Task_BuyMenu;
@ -1144,11 +1182,11 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
FillWindowPixelBuffer(4, PIXEL_FILL(1)); FillWindowPixelBuffer(WIN_QUANTITY_PRICE, PIXEL_FILL(1));
PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW); PrintMoneyAmount(WIN_QUANTITY_PRICE, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS); ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1); StringExpandPlaceholders(gStringVar4, gText_xVar1);
BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0); BuyMenuPrint(WIN_QUANTITY_PRICE, gStringVar4, 0, 1, 0, COLORID_NORMAL);
} }
static void ExitBuyMenu(u8 taskId) static void ExitBuyMenu(u8 taskId)
@ -1204,6 +1242,8 @@ static void RecordItemPurchase(u8 taskId)
#undef tItemCount #undef tItemCount
#undef tItemId #undef tItemId
#undef tListTaskId #undef tListTaskId
#undef tCallbackHi
#undef tCallbackLo
void CreatePokemartMenu(const u16 *itemsForSale) void CreatePokemartMenu(const u16 *itemsForSale)
{ {

View File

@ -6433,6 +6433,20 @@ static const struct SpriteTemplate sSpriteTemplate_PikaPowerBolt =
.callback = SpriteCB_PikaPowerBolt .callback = SpriteCB_PikaPowerBolt
}; };
/*
[0 ][1 ]
[ ][ ]
[ ][ ]
[ ][ ]
[ ][ ]
[______________][______________] 128x128
[ ]+ <- Origin ]
[ ][ ]
[ ][ ]
[ ][ ]
[ ][ ]
[2 ][3 ]
*/
static const struct Subsprite sSubsprites_ReelBackground[] = static const struct Subsprite sSubsprites_ReelBackground[] =
{ {
{ {
@ -6474,6 +6488,11 @@ static const struct SubspriteTable sSubspriteTable_ReelBackground[] =
ARRAY_COUNT(sSubsprites_ReelBackground), sSubsprites_ReelBackground ARRAY_COUNT(sSubsprites_ReelBackground), sSubsprites_ReelBackground
}; };
/* v-- Origin on 3
[0_____][1_____]
[2_____][3_____] 64x24
[4 ][5 ]
*/
static const struct Subsprite sSubsprites_ReelTimeMachineAntennae[] = static const struct Subsprite sSubsprites_ReelTimeMachineAntennae[] =
{ {
{ {
@ -6531,6 +6550,13 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeMachineAntennae[] =
ARRAY_COUNT(sSubsprites_ReelTimeMachineAntennae), sSubsprites_ReelTimeMachineAntennae ARRAY_COUNT(sSubsprites_ReelTimeMachineAntennae), sSubsprites_ReelTimeMachineAntennae
}; };
/*
[0 ]
[ ]
[ + Origin]
[______________] 64x40
[1 ][2 ]
*/
static const struct Subsprite sSubsprites_ReelTimeMachine[] = static const struct Subsprite sSubsprites_ReelTimeMachine[] =
{ {
{ {
@ -6564,6 +6590,14 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeMachine[] =
ARRAY_COUNT(sSubsprites_ReelTimeMachine), sSubsprites_ReelTimeMachine ARRAY_COUNT(sSubsprites_ReelTimeMachine), sSubsprites_ReelTimeMachine
}; };
/*
[0 ]
[ ]
[ + Origin]
[______________] 64x48
[1 ][2 ]
[3 ][4 ]
*/
static const struct Subsprite sSubsprites_BrokenReelTimeMachine[] = static const struct Subsprite sSubsprites_BrokenReelTimeMachine[] =
{ {
{ {
@ -6613,6 +6647,10 @@ static const struct SubspriteTable sSubspriteTable_BrokenReelTimeMachine[] =
ARRAY_COUNT(sSubsprites_BrokenReelTimeMachine), sSubsprites_BrokenReelTimeMachine ARRAY_COUNT(sSubsprites_BrokenReelTimeMachine), sSubsprites_BrokenReelTimeMachine
}; };
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
static const struct Subsprite sSubsprites_ReelTimeShadow[] = static const struct Subsprite sSubsprites_ReelTimeShadow[] =
{ {
{ {
@ -6654,6 +6692,11 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeShadow[] =
ARRAY_COUNT(sSubsprites_ReelTimeShadow), sSubsprites_ReelTimeShadow ARRAY_COUNT(sSubsprites_ReelTimeShadow), sSubsprites_ReelTimeShadow
}; };
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
static const struct Subsprite sSubsprites_ReelTimeNumberGap[] = static const struct Subsprite sSubsprites_ReelTimeNumberGap[] =
{ {
{ {
@ -6687,6 +6730,14 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeNumberGap[] =
ARRAY_COUNT(sSubsprites_ReelTimeNumberGap), sSubsprites_ReelTimeNumberGap ARRAY_COUNT(sSubsprites_ReelTimeNumberGap), sSubsprites_ReelTimeNumberGap
}; };
/*
[0 ]
[ ]
[ + Origin]
[______________] 64x48
[1 ][2 ]
[3 ][4 ]
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Reel[] = static const struct Subsprite sSubsprites_DigitalDisplay_Reel[] =
{ {
{ {
@ -6736,6 +6787,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Reel[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Reel), sSubsprites_DigitalDisplay_Reel ARRAY_COUNT(sSubsprites_DigitalDisplay_Reel), sSubsprites_DigitalDisplay_Reel
}; };
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Time[] = static const struct Subsprite sSubsprites_DigitalDisplay_Time[] =
{ {
{ {
@ -6777,6 +6832,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Time[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Time), sSubsprites_DigitalDisplay_Time ARRAY_COUNT(sSubsprites_DigitalDisplay_Time), sSubsprites_DigitalDisplay_Time
}; };
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Insert[] = static const struct Subsprite sSubsprites_DigitalDisplay_Insert[] =
{ {
{ {
@ -6818,6 +6877,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Insert[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Insert), sSubsprites_DigitalDisplay_Insert ARRAY_COUNT(sSubsprites_DigitalDisplay_Insert), sSubsprites_DigitalDisplay_Insert
}; };
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Unused1[] = static const struct Subsprite sSubsprites_DigitalDisplay_Unused1[] =
{ {
{ {
@ -6859,6 +6922,11 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Unused1[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused1), sSubsprites_DigitalDisplay_Unused1 ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused1), sSubsprites_DigitalDisplay_Unused1
}; };
/* v-- Origin on 3
[0_____][1_____]
[2_____][3_____]
[4 ][5 ] 64x24
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Win[] = static const struct Subsprite sSubsprites_DigitalDisplay_Win[] =
{ {
{ {
@ -6950,6 +7018,14 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Unused2[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused2), sSubsprites_DigitalDisplay_Unused2 ARRAY_COUNT(sSubsprites_DigitalDisplay_Unused2), sSubsprites_DigitalDisplay_Unused2
}; };
/*
[0_____][1_]
[2_____][3_]
[4_____][5_]
[6_____][7+] <-- Origin
[8_____][9_]
[10____][11]
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Pokeball[] = static const struct Subsprite sSubsprites_DigitalDisplay_Pokeball[] =
{ {
{ {
@ -6962,7 +7038,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Pokeball[] =
}, },
{ {
.x = 8, .x = 8,
-24, .y = -24,
.shape = SPRITE_SHAPE(16x8), .shape = SPRITE_SHAPE(16x8),
.size = SPRITE_SIZE(16x8), .size = SPRITE_SIZE(16x8),
.tileOffset = 4, .tileOffset = 4,
@ -7055,6 +7131,11 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Pokeball[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Pokeball), sSubsprites_DigitalDisplay_Pokeball ARRAY_COUNT(sSubsprites_DigitalDisplay_Pokeball), sSubsprites_DigitalDisplay_Pokeball
}; };
/*
[0 ] 32x24
[ + ] <- Origin
[1 ][2 ]
*/
static const struct Subsprite sSubsprites_DigitalDisplay_DPad[] = static const struct Subsprite sSubsprites_DigitalDisplay_DPad[] =
{ {
{ {
@ -7088,6 +7169,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_DPad[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_DPad), sSubsprites_DigitalDisplay_DPad ARRAY_COUNT(sSubsprites_DigitalDisplay_DPad), sSubsprites_DigitalDisplay_DPad
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_StopS[] = static const struct Subsprite sSubsprites_DigitalDisplay_StopS[] =
{ {
{ {
@ -7113,6 +7198,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopS[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_StopS), sSubsprites_DigitalDisplay_StopS ARRAY_COUNT(sSubsprites_DigitalDisplay_StopS), sSubsprites_DigitalDisplay_StopS
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_StopT[] = static const struct Subsprite sSubsprites_DigitalDisplay_StopT[] =
{ {
{ {
@ -7138,6 +7227,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopT[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_StopT), sSubsprites_DigitalDisplay_StopT ARRAY_COUNT(sSubsprites_DigitalDisplay_StopT), sSubsprites_DigitalDisplay_StopT
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_StopO[] = static const struct Subsprite sSubsprites_DigitalDisplay_StopO[] =
{ {
{ {
@ -7163,6 +7256,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopO[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_StopO), sSubsprites_DigitalDisplay_StopO ARRAY_COUNT(sSubsprites_DigitalDisplay_StopO), sSubsprites_DigitalDisplay_StopO
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_StopP[] = static const struct Subsprite sSubsprites_DigitalDisplay_StopP[] =
{ {
{ {
@ -7188,6 +7285,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_StopP[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_StopP), sSubsprites_DigitalDisplay_StopP ARRAY_COUNT(sSubsprites_DigitalDisplay_StopP), sSubsprites_DigitalDisplay_StopP
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BonusB[] = static const struct Subsprite sSubsprites_DigitalDisplay_BonusB[] =
{ {
{ {
@ -7213,6 +7314,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusB[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusB), sSubsprites_DigitalDisplay_BonusB ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusB), sSubsprites_DigitalDisplay_BonusB
}; };
/*
[]<-0 16x16
[]<-1 <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BonusO[] = static const struct Subsprite sSubsprites_DigitalDisplay_BonusO[] =
{ {
{ {
@ -7238,6 +7343,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusO[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusO), sSubsprites_DigitalDisplay_BonusO ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusO), sSubsprites_DigitalDisplay_BonusO
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BonusN[] = static const struct Subsprite sSubsprites_DigitalDisplay_BonusN[] =
{ {
{ {
@ -7263,6 +7372,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusN[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusN), sSubsprites_DigitalDisplay_BonusN ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusN), sSubsprites_DigitalDisplay_BonusN
}; };
/*
[]<-0 16x16
[]<-1 <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BonusU[] = static const struct Subsprite sSubsprites_DigitalDisplay_BonusU[] =
{ {
{ {
@ -7288,6 +7401,10 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusU[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusU), sSubsprites_DigitalDisplay_BonusU ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusU), sSubsprites_DigitalDisplay_BonusU
}; };
/*
[0 ] 16x16
[1+] <- Origin
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BonusS[] = static const struct Subsprite sSubsprites_DigitalDisplay_BonusS[] =
{ {
{ {
@ -7313,6 +7430,12 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BonusS[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusS), sSubsprites_DigitalDisplay_BonusS ARRAY_COUNT(sSubsprites_DigitalDisplay_BonusS), sSubsprites_DigitalDisplay_BonusS
}; };
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BigB[] = static const struct Subsprite sSubsprites_DigitalDisplay_BigB[] =
{ {
{ {
@ -7370,6 +7493,11 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BigB[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BigB), sSubsprites_DigitalDisplay_BigB ARRAY_COUNT(sSubsprites_DigitalDisplay_BigB), sSubsprites_DigitalDisplay_BigB
}; };
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BigI[] = static const struct Subsprite sSubsprites_DigitalDisplay_BigI[] =
{ {
{ {
@ -7403,6 +7531,12 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BigI[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BigI), sSubsprites_DigitalDisplay_BigI ARRAY_COUNT(sSubsprites_DigitalDisplay_BigI), sSubsprites_DigitalDisplay_BigI
}; };
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
static const struct Subsprite sSubsprites_DigitalDisplay_BigG[] = static const struct Subsprite sSubsprites_DigitalDisplay_BigG[] =
{ {
{ {
@ -7460,6 +7594,12 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_BigG[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_BigG), sSubsprites_DigitalDisplay_BigG ARRAY_COUNT(sSubsprites_DigitalDisplay_BigG), sSubsprites_DigitalDisplay_BigG
}; };
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
static const struct Subsprite sSubsprites_DigitalDisplay_RegR[] = static const struct Subsprite sSubsprites_DigitalDisplay_RegR[] =
{ {
{ {
@ -7517,6 +7657,11 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_RegR[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_RegR), sSubsprites_DigitalDisplay_RegR ARRAY_COUNT(sSubsprites_DigitalDisplay_RegR), sSubsprites_DigitalDisplay_RegR
}; };
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
static const struct Subsprite sSubsprites_DigitalDisplay_RegE[] = static const struct Subsprite sSubsprites_DigitalDisplay_RegE[] =
{ {
{ {
@ -7550,6 +7695,12 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_RegE[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_RegE), sSubsprites_DigitalDisplay_RegE ARRAY_COUNT(sSubsprites_DigitalDisplay_RegE), sSubsprites_DigitalDisplay_RegE
}; };
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
static const struct Subsprite sSubsprites_DigitalDisplay_RegG[] = static const struct Subsprite sSubsprites_DigitalDisplay_RegG[] =
{ {
{ {

View File

@ -351,7 +351,7 @@ static void InitTradeMenu(void)
FillWindowPixelBuffer(i, PIXEL_FILL(0)); FillWindowPixelBuffer(i, PIXEL_FILL(0));
} }
FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 15); FillBgTilemapBufferRect(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 15);
LoadUserWindowBorderGfx_(0, 20, 0xC0); LoadUserWindowBorderGfx_(0, 20, 0xC0);
LoadUserWindowBorderGfx(2, 1, 0xE0); LoadUserWindowBorderGfx(2, 1, 0xE0);
LoadMonIconPalettes(); LoadMonIconPalettes();
@ -2064,13 +2064,13 @@ static void RedrawTradeMenuParty(u8 whichParty)
static void Task_DrawSelectionSummary(u8 taskId) static void Task_DrawSelectionSummary(u8 taskId)
{ {
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
} }
static void Task_DrawSelectionTrade(u8 taskId) static void Task_DrawSelectionTrade(u8 taskId)
{ {
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
} }

View File

@ -3680,8 +3680,8 @@ static s32 ListMenuHandler_AllItemsAvailable(u8 *state, u8 *windowId, u8 *listMe
if (winTemplateCopy.width > maxWidth) if (winTemplateCopy.width > maxWidth)
winTemplateCopy.width = maxWidth; winTemplateCopy.width = maxWidth;
if (winTemplateCopy.tilemapLeft + winTemplateCopy.width > 29) if (winTemplateCopy.tilemapLeft + winTemplateCopy.width >= DISPLAY_TILE_WIDTH)
winTemplateCopy.tilemapLeft = max(29 - winTemplateCopy.width, 0); winTemplateCopy.tilemapLeft = max(DISPLAY_TILE_WIDTH - 1 - winTemplateCopy.width, 0);
*windowId = AddWindow(&winTemplateCopy); *windowId = AddWindow(&winTemplateCopy);
DrawStdWindowFrame(*windowId, FALSE); DrawStdWindowFrame(*windowId, FALSE);

View File

@ -129,7 +129,7 @@ void CB2_UnionRoomBattle(void)
ClearWindowTilemap(0); ClearWindowTilemap(0);
FillWindowPixelBuffer(0, PIXEL_FILL(0)); FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(0, PIXEL_FILL(1)); FillWindowPixelBuffer(0, PIXEL_FILL(1));
FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 0xF); FillBgTilemapBufferRect(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 0xF);
LoadUserWindowBorderGfx(0, 1, 0xD0); LoadUserWindowBorderGfx(0, 1, 0xD0);
LoadUserWindowBorderGfx_(0, 1, 0xD0); LoadUserWindowBorderGfx_(0, 1, 0xD0);
Menu_LoadStdPal(); Menu_LoadStdPal();