Merge branch 'master' into porymap-5

This commit is contained in:
GriffinR 2022-10-18 22:54:25 -04:00 committed by GitHub
commit 3e8baa5b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 771 additions and 530 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 B

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 200 B

View File

@ -78,6 +78,11 @@
#define BATTLE_TYPE_RECORDED_IS_MASTER (1 << 31)
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)
#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE)
#define BATTLE_TYPE_RECORDED_INVALID ((BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_FIRST_BATTLE \
| BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_ROAMER | BATTLE_TYPE_EREADER_TRAINER \
| BATTLE_TYPE_KYOGRE_GROUDON | BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI \
| BATTLE_TYPE_RECORDED | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_SECRET_BASE \
| BATTLE_TYPE_GROUDON | BATTLE_TYPE_KYOGRE | BATTLE_TYPE_RAYQUAZA))
// Battle Outcome defines
#define B_OUTCOME_WON 1

View File

@ -477,7 +477,10 @@
#define ITEM_OLD_SEA_MAP 376
#define ITEMS_COUNT 377
#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
#define FIRST_BERRY_MASTER_BERRY ITEM_POMEG_BERRY

View File

@ -19,6 +19,8 @@ enum {
PALTAG_WEATHER_2
};
#define NUM_WEATHER_COLOR_MAPS 19
struct Weather
{
union
@ -39,12 +41,12 @@ struct Weather
struct Sprite *sandstormSprites2[NUM_SWIRL_SANDSTORM_SPRITES];
} s2;
} sprites;
u8 gammaShifts[19][32];
u8 altGammaShifts[19][32];
s8 gammaIndex;
s8 gammaTargetIndex;
u8 gammaStepDelay;
u8 gammaStepFrameCounter;
u8 darkenedContrastColorMaps[NUM_WEATHER_COLOR_MAPS][32];
u8 contrastColorMaps[NUM_WEATHER_COLOR_MAPS][32];
s8 colorMapIndex;
s8 targetColorMapIndex;
u8 colorMapStepDelay;
u8 colorMapStepCounter;
u16 fadeDestColor;
u8 palProcessingState;
u8 fadeScreenCounter;
@ -59,7 +61,7 @@ struct Weather
u8 weatherGfxLoaded;
bool8 weatherChangeComplete;
u8 weatherPicSpritePalIndex;
u8 altGammaSpritePalIndex;
u8 contrastColorMapSpritePalIndex;
// Rain
u16 rainSpriteVisibleCounter;
u8 curRainSpriteIndex;
@ -146,12 +148,12 @@ void StartWeather(void);
void SetNextWeather(u8 weather);
void SetCurrentAndNextWeather(u8 weather);
void SetCurrentAndNextWeatherNoDelay(u8 weather);
void ApplyWeatherGammaShiftIfIdle(s8 gammaIndex);
void ApplyWeatherGammaShiftIfIdle_Gradual(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay);
void ApplyWeatherColorMapIfIdle(s8 colorMapIndex);
void ApplyWeatherColorMapIfIdle_Gradual(u8 colorMapIndex, u8 targetColorMapIndex, u8 colorMapStepDelay);
void FadeScreen(u8 mode, s8 delay);
bool8 IsWeatherNotFadingIn(void);
void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex);
void ApplyWeatherGammaShiftToPal(u8 paletteIndex);
void ApplyWeatherColorMapToPal(u8 paletteIndex);
void LoadCustomWeatherSpritePalette(const u16 *palette);
void ResetDroughtWeatherPaletteLoading(void);
bool8 LoadDroughtWeatherPalettes(void);

View File

@ -67,6 +67,9 @@
#define DISPLAY_WIDTH 240
#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_8BPP 64

View File

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

View File

@ -3,47 +3,6 @@
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 CreateDecorationShop1Menu(const u16 *);
void CreateDecorationShop2Menu(const u16 *);

View File

@ -318,10 +318,17 @@ static const struct SpriteTemplate sHealthbarSpriteTemplates[MAX_BATTLERS_COUNT]
}
};
/* v-- Origin
[0 + ][1 ]
[ ][ ]
[ ][ ]
[______________][______] 96x40
[2 ][3 ][4 ]
*/
static const struct Subsprite sUnused_Subsprites_0[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
@ -337,7 +344,7 @@ static const struct Subsprite sUnused_Subsprites_0[] =
.priority = 1
},
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 32,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -362,10 +369,11 @@ static const struct Subsprite sUnused_Subsprites_0[] =
}
};
// This subsprite table has the same layout as above, but offset by 64 base tiles.
static const struct Subsprite sUnused_Subsprites_2[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
@ -381,7 +389,7 @@ static const struct Subsprite sUnused_Subsprites_2[] =
.priority = 1
},
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 32,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -406,10 +414,16 @@ static const struct Subsprite sUnused_Subsprites_2[] =
}
};
/* v-- Origin
[0 + ][1 ]
[ ][ ]
[ ][ ]
[ ][ ] 96x32
*/
static const struct Subsprite sUnused_Subsprites_1[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
@ -426,10 +440,11 @@ static const struct Subsprite sUnused_Subsprites_1[] =
}
};
// Same as above
static const struct Subsprite sUnused_Subsprites_3[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
@ -446,10 +461,13 @@ static const struct Subsprite sUnused_Subsprites_3[] =
}
};
/* v-- Origin
[0 + ][1 ] 64x8
*/
static const struct Subsprite sHealthBar_Subsprites_Player[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -466,10 +484,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[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -485,7 +507,7 @@ static const struct Subsprite sHealthBar_Subsprites_Opponent[] =
.priority = 1
},
{
.x = DISPLAY_WIDTH - 16,
.x = -32,
.y = 0,
.shape = SPRITE_SHAPE(8x8),
.size = SPRITE_SIZE(8x8),
@ -507,11 +529,13 @@ static const struct SubspriteTable sHealthBar_SubspriteTables[] =
[B_SIDE_PLAYER] = {ARRAY_COUNT(sHealthBar_Subsprites_Player), sHealthBar_Subsprites_Player},
[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[] =
{
{
.x = 32 * 5,
.x = 32 * -3,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -519,7 +543,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
.priority = 1
},
{
.x = 32 * 6,
.x = 32 * -2,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -527,7 +551,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
.priority = 1
},
{
.x = 32 * 7,
.x = 32 * -1,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -544,10 +568,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[] =
{
{
.x = 32 * 5,
.x = 32 * -3,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -555,7 +583,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
.priority = 1
},
{
.x = 32 * 6,
.x = 32 * -2,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
@ -563,7 +591,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
.priority = 1
},
{
.x = 32 * 7,
.x = 32 * -1,
.y = 0,
.shape = SPRITE_SHAPE(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)
ShowItemIcon(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gPyramidBagMenu->isAltIcon);
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;
PrintItemDescription(itemIndex);
}

View File

@ -1008,7 +1008,7 @@ static bool8 LoadBerryBlenderGfx(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);
ShowBg(0);
ShowBg(1);
@ -1029,7 +1029,7 @@ static void InitBerryBlenderWindows(void)
for (i = 0; i < 5; i++)
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);
}
}

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[] =
{
{

View File

@ -1167,24 +1167,24 @@ static void TryCreateWirelessSprites(void)
static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{
u16 windowId;
int origWidth;
int tileWidth;
int strWidth;
u8 *spriteTilePtrs[4];
u8 *dst;
struct WindowTemplate windowTemplate;
memset(&windowTemplate, 0, sizeof(windowTemplate));
windowTemplate.width = 30;
windowTemplate.width = DISPLAY_TILE_WIDTH;
windowTemplate.height = 2;
windowId = AddWindow(&windowTemplate);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
origWidth = GetStringWidth(FONT_NORMAL, text, 0);
strWidth = (origWidth + 9) / 8;
if (strWidth > 30)
strWidth = 30;
strWidth = GetStringWidth(FONT_NORMAL, text, 0);
tileWidth = (strWidth + 9) / 8;
if (tileWidth > DISPLAY_TILE_WIDTH)
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;
struct Sprite *sprite;
@ -1207,7 +1207,7 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
CpuCopy32(src + 128, dst + 0x200, 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];
CpuCopy32(src + 192, dst, 0x20);
@ -1225,7 +1225,7 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
}
RemoveWindow(windowId);
return (DISPLAY_WIDTH - (strWidth + 2) * 8) / 2;
return (DISPLAY_WIDTH - (tileWidth + 2) * 8) / 2;
}
static void CreateResultsTextWindowSprites(void)

View File

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

View File

@ -10,7 +10,7 @@ static const u16 sFrontierExchangeCorner_Decor1[] =
DECOR_CYNDAQUIL_DOLL,
DECOR_CHIKORITA_DOLL,
DECOR_TOTODILE_DOLL,
0xFFFF
ITEM_LIST_END
};
static const u16 sFrontierExchangeCorner_Decor2[] =
@ -20,7 +20,7 @@ static const u16 sFrontierExchangeCorner_Decor2[] =
DECOR_VENUSAUR_DOLL,
DECOR_CHARIZARD_DOLL,
DECOR_BLASTOISE_DOLL,
0xFFFF
ITEM_LIST_END
};
static const u16 sFrontierExchangeCorner_Vitamins[] =
@ -31,7 +31,7 @@ static const u16 sFrontierExchangeCorner_Vitamins[] =
ITEM_ZINC,
ITEM_CARBOS,
ITEM_HP_UP,
0xFFFF
ITEM_LIST_END
};
static const u16 sFrontierExchangeCorner_HoldItems[] =
@ -45,7 +45,7 @@ static const u16 sFrontierExchangeCorner_HoldItems[] =
ITEM_KINGS_ROCK,
ITEM_FOCUS_BAND,
ITEM_SCOPE_LENS,
0xFFFF
ITEM_LIST_END
};
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},
// Pokeballs
@ -402,5 +402,5 @@ const u32 *const gItemIconTable[][2] =
[ITEM_MAGMA_EMBLEM] = {gItemIcon_MagmaEmblem, gItemIconPalette_MagmaEmblem},
[ITEM_OLD_SEA_MAP] = {gItemIcon_OldSeaMap, gItemIconPalette_OldSeaMap},
// Return to field arrow
[ITEM_FIELD_ARROW] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow},
[ITEMS_COUNT] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow},
};

View File

@ -268,7 +268,7 @@ bool8 LoadCompressedSpriteSheetUsingHeap(const struct CompressedSpriteSheet *src
struct SpriteSheet dest;
void *buffer;
buffer = AllocZeroed(*((u32 *)(&src->data[0])) >> 8);
buffer = AllocZeroed(src->data[0] >> 8);
LZ77UnCompWram(src->data, buffer);
dest.data = buffer;
@ -285,7 +285,7 @@ bool8 LoadCompressedSpritePaletteUsingHeap(const struct CompressedSpritePalette
struct SpritePalette dest;
void *buffer;
buffer = AllocZeroed(*((u32 *)(&src->data[0])) >> 8);
buffer = AllocZeroed(src->data[0] >> 8);
LZ77UnCompWram(src->data, buffer);
dest.data = buffer;
dest.tag = src->tag;

View File

@ -4675,7 +4675,7 @@ static void ShowNames(void)
ClearWindowTilemap(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);
sGfx->finished = TRUE;
}
@ -4859,7 +4859,7 @@ static void ShowResults(void)
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]);
sGfx->windowIds[1] = AddWindow(&sWindowTemplate_Prize);
ClearWindowTilemap(sGfx->windowIds[1]);
@ -4917,7 +4917,7 @@ static void ShowResults(void)
ClearWindowTilemap(sGfx->windowIds[1]);
RemoveWindow(sGfx->windowIds[0]);
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);
sGfx->finished = TRUE;
break;
@ -5012,7 +5012,7 @@ static void Msg_WantToPlayAgain(void)
ClearWindowTilemap(sGfx->windowIds[WIN_YES_NO]);
RemoveWindow(sGfx->windowIds[WIN_PLAY_AGAIN]);
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);
sGfx->finished = TRUE;
break;
@ -5044,7 +5044,7 @@ static void Msg_SavingDontTurnOff(void)
sGfx->state++;
break;
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);
sGfx->finished = TRUE;
break;
@ -5083,7 +5083,7 @@ static void EraseMessage(void)
{
ClearWindowTilemap(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);
sGfx->finished = TRUE;
}
@ -5121,7 +5121,7 @@ static void Msg_SomeoneDroppedOut(void)
sGfx->playAgainState = PLAY_AGAIN_DROPPED;
ClearWindowTilemap(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);
sGfx->finished = TRUE;
break;

View File

@ -36,7 +36,7 @@
#include "constants/trainer_hill.h"
static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0;
static EWRAM_DATA u16 sPreviousPlayerMetatileBehavior = 0;
static EWRAM_DATA u16 sPrevMetatileBehavior = 0;
u8 gSelectedObjectEvent;
@ -671,18 +671,18 @@ static bool8 CheckStandardWildEncounter(u16 metatileBehavior)
if (sWildEncounterImmunitySteps < 4)
{
sWildEncounterImmunitySteps++;
sPreviousPlayerMetatileBehavior = metatileBehavior;
sPrevMetatileBehavior = metatileBehavior;
return FALSE;
}
if (StandardWildEncounter(metatileBehavior, sPreviousPlayerMetatileBehavior) == TRUE)
if (StandardWildEncounter(metatileBehavior, sPrevMetatileBehavior) == TRUE)
{
sWildEncounterImmunitySteps = 0;
sPreviousPlayerMetatileBehavior = metatileBehavior;
sPrevMetatileBehavior = metatileBehavior;
return TRUE;
}
sPreviousPlayerMetatileBehavior = metatileBehavior;
sPrevMetatileBehavior = metatileBehavior;
return FALSE;
}

View File

@ -405,6 +405,11 @@ static const struct SpriteFrameImage sPicTable_HofMonitorSmall[] =
{.data = sHofMonitorSmall_Gfx, .size = 0x200} // the macro breaks down here
};
/*
[0_][] <-1 24x16
[2 ][] <-3
^-- Origin
*/
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);
/*
[0_____][1_____] 24x16
[2 ][3 ]
^-- Origin
*/
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_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);
SetBgTilemapPalette(0, 0, 0, 0x1E, 0x14, 0xF);
SetBgTilemapPalette(0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 0xF);
ScheduleBgCopyTilemapToVram(0);
SetOrbFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], tCenterX, tCenterY, 1);
CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480);

View File

@ -2919,7 +2919,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
{
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);
if (sFrontierExchangeCorner_Decor1[selection] == 0xFFFF)
if (sFrontierExchangeCorner_Decor1[selection] == ITEM_LIST_END)
{
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor1[selection]);
}
@ -2932,7 +2932,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
break;
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);
if (sFrontierExchangeCorner_Decor2[selection] == 0xFFFF)
if (sFrontierExchangeCorner_Decor2[selection] == ITEM_LIST_END)
{
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor2[selection]);
}

View File

@ -21,9 +21,9 @@
enum
{
GAMMA_NONE,
GAMMA_NORMAL,
GAMMA_ALT,
COLOR_MAP_NONE,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_CONTRAST,
};
struct RGBColor
@ -33,11 +33,6 @@ struct RGBColor
u16 b:5;
};
struct WeatherPaletteData
{
u16 gammaShiftColors[8][0x1000]; // 0x1000 is the number of bytes that make up all palettes.
};
struct WeatherCallbacks
{
void (*initVars)(void);
@ -48,11 +43,11 @@ struct WeatherCallbacks
// This file's functions.
static bool8 LightenSpritePaletteInFog(u8);
static void BuildGammaShiftTables(void);
static void UpdateWeatherGammaShift(void);
static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex);
static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor);
static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 blendColor);
static void BuildColorMaps(void);
static void UpdateWeatherColorMap(void);
static void ApplyColorMap(u8 startPalIndex, u8 numPalettes, s8 colorMapIndex);
static void ApplyColorMapWithBlend(u8 startPalIndex, u8 numPalettes, s8 colorMapIndex, u8 blendCoeff, u16 blendColor);
static void ApplyDroughtColorMapWithBlend(s8 colorMapIndex, u8 blendCoeff, u16 blendColor);
static void ApplyFogBlend(u8 blendCoeff, u16 blendColor);
static bool8 FadeInScreen_RainShowShade(void);
static bool8 FadeInScreen_Drought(void);
@ -66,9 +61,9 @@ static void None_Main(void);
static u8 None_Finish(void);
EWRAM_DATA struct Weather gWeather = {0};
EWRAM_DATA static u8 sFieldEffectPaletteGammaTypes[32] = {0};
EWRAM_DATA static u8 sFieldEffectPaletteColorMapTypes[32] = {0};
static const u8 *sPaletteGammaTypes;
static const u8 *sPaletteColorMapTypes;
// The drought weather effect uses a precalculated color lookup table. Presumably this
// is because the underlying color shift calculation is slow.
@ -108,50 +103,50 @@ static const struct WeatherCallbacks sWeatherFuncs[] =
void (*const gWeatherPalStateFuncs[])(void) =
{
[WEATHER_PAL_STATE_CHANGING_WEATHER] = UpdateWeatherGammaShift,
[WEATHER_PAL_STATE_CHANGING_WEATHER] = UpdateWeatherColorMap,
[WEATHER_PAL_STATE_SCREEN_FADING_IN] = FadeInScreenWithWeather,
[WEATHER_PAL_STATE_SCREEN_FADING_OUT] = DoNothing,
[WEATHER_PAL_STATE_IDLE] = DoNothing,
};
// This table specifies which of the gamma shift tables should be
// This table specifies which of the color maps should be
// applied to each of the background and sprite palettes.
static const u8 sBasePaletteGammaTypes[32] =
static const u8 sBasePaletteColorMapTypes[32] =
{
// background palettes
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NONE,
GAMMA_NONE,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_NONE,
COLOR_MAP_NONE,
// sprite palettes
GAMMA_ALT,
GAMMA_NORMAL,
GAMMA_ALT,
GAMMA_ALT,
GAMMA_ALT,
GAMMA_ALT,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_ALT,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
GAMMA_NORMAL,
COLOR_MAP_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_CONTRAST,
COLOR_MAP_CONTRAST,
COLOR_MAP_CONTRAST,
COLOR_MAP_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
COLOR_MAP_DARK_CONTRAST,
};
const u16 gFogPalette[] = INCBIN_U16("graphics/weather/fog.gbapal");
@ -160,10 +155,10 @@ void StartWeather(void)
{
if (!FuncIsActiveTask(Task_WeatherMain))
{
u8 index = AllocSpritePalette(TAG_WEATHER_START);
u8 index = AllocSpritePalette(PALTAG_WEATHER);
CpuCopy32(gFogPalette, &gPlttBufferUnfaded[0x100 + index * 16], 32);
BuildGammaShiftTables();
gWeatherPtr->altGammaSpritePalIndex = index;
BuildColorMaps();
gWeatherPtr->contrastColorMapSpritePalIndex = index;
gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(PALTAG_WEATHER_2);
gWeatherPtr->rainSpriteCount = 0;
gWeatherPtr->curRainSpriteIndex = 0;
@ -238,7 +233,7 @@ static void Task_WeatherMain(u8 taskId)
{
// Finished cleaning up previous weather. Now transition to next weather.
sWeatherFuncs[gWeatherPtr->nextWeather].initVars();
gWeatherPtr->gammaStepFrameCounter = 0;
gWeatherPtr->colorMapStepCounter = 0;
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER;
gWeatherPtr->currWeather = gWeatherPtr->nextWeather;
gWeatherPtr->weatherChangeComplete = TRUE;
@ -254,8 +249,8 @@ static void Task_WeatherMain(u8 taskId)
static void None_Init(void)
{
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 0;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 0;
}
static void None_Main(void)
@ -267,70 +262,82 @@ static u8 None_Finish(void)
return 0;
}
// Builds two tables that contain gamma shifts for palette colors.
// Builds two tables that contain color maps, used for directly transforming
// palette colors in weather effects. The colors maps are a spectrum of
// brightness + contrast mappings. By transitioning between the maps, weather
// effects like lightning are created.
// It's unclear why the two tables aren't declared as const arrays, since
// this function always builds the same two tables.
static void BuildGammaShiftTables(void)
static void BuildColorMaps(void)
{
u16 v0;
u8 (*gammaTable)[32];
u16 v2;
u16 v4;
u16 v5;
u16 gammaIndex;
u16 v9;
u32 v10;
u16 v11;
s16 dunno;
u16 i;
u8 (*colorMaps)[32];
u16 colorVal;
u16 curBrightness;
u16 brightnessDelta;
u16 colorMapIndex;
u16 baseBrightness;
u32 remainingBrightness;
s16 diff;
sPaletteGammaTypes = sBasePaletteGammaTypes;
for (v0 = 0; v0 <= 1; v0++)
sPaletteColorMapTypes = sBasePaletteColorMapTypes;
for (i = 0; i < 2; i++)
{
if (v0 == 0)
gammaTable = gWeatherPtr->gammaShifts;
if (i == 0)
colorMaps = gWeatherPtr->darkenedContrastColorMaps;
else
gammaTable = gWeatherPtr->altGammaShifts;
colorMaps = gWeatherPtr->contrastColorMaps;
for (v2 = 0; v2 < 32; v2++)
for (colorVal = 0; colorVal < 32; colorVal++)
{
v4 = v2 << 8;
if (v0 == 0)
v5 = (v2 << 8) / 16;
curBrightness = colorVal << 8;
if (i == 0)
brightnessDelta = (colorVal << 8) / 16;
else
v5 = 0;
for (gammaIndex = 0; gammaIndex <= 2; gammaIndex++)
brightnessDelta = 0;
// First three color mappings are simple brightness modifiers which are
// progressively darker, according to brightnessDelta.
for (colorMapIndex = 0; colorMapIndex < 3; colorMapIndex++)
{
v4 = (v4 - v5);
gammaTable[gammaIndex][v2] = v4 >> 8;
curBrightness -= brightnessDelta;
colorMaps[colorMapIndex][colorVal] = curBrightness >> 8;
}
v9 = v4;
v10 = 0x1f00 - v4;
if ((0x1f00 - v4) < 0)
baseBrightness = curBrightness;
remainingBrightness = 0x1f00 - curBrightness;
if ((0x1f00 - curBrightness) < 0)
remainingBrightness += 0xf;
brightnessDelta = remainingBrightness / (NUM_WEATHER_COLOR_MAPS - 3);
if (colorVal < 12)
{
v10 += 0xf;
}
v11 = v10 >> 4;
if (v2 < 12)
{
for (; gammaIndex < 19; gammaIndex++)
// For shadows (color values < 12), the remaining color mappings are
// brightness modifiers, which are increased at a significantly lower rate
// than the midtones and highlights (color values >= 12). This creates a
// high contrast effect, used in the thunderstorm weather.
for (; colorMapIndex < NUM_WEATHER_COLOR_MAPS; colorMapIndex++)
{
v4 += v11;
dunno = v4 - v9;
if (dunno > 0)
v4 -= (dunno + ((u16)dunno >> 15)) >> 1;
gammaTable[gammaIndex][v2] = v4 >> 8;
if (gammaTable[gammaIndex][v2] > 0x1f)
gammaTable[gammaIndex][v2] = 0x1f;
curBrightness += brightnessDelta;
diff = curBrightness - baseBrightness;
if (diff > 0)
curBrightness -= diff / 2;
colorMaps[colorMapIndex][colorVal] = curBrightness >> 8;
if (colorMaps[colorMapIndex][colorVal] > 31)
colorMaps[colorMapIndex][colorVal] = 31;
}
}
else
{
for (; gammaIndex < 19; gammaIndex++)
// For midtones and highlights (color values >= 12), the remaining
// color mappings are simple brightness modifiers which are
// progressively brighter, hitting exactly 31 at the last mapping.
for (; colorMapIndex < NUM_WEATHER_COLOR_MAPS; colorMapIndex++)
{
v4 += v11;
gammaTable[gammaIndex][v2] = v4 >> 8;
if (gammaTable[gammaIndex][v2] > 0x1f)
gammaTable[gammaIndex][v2] = 0x1f;
curBrightness += brightnessDelta;
colorMaps[colorMapIndex][colorVal] = curBrightness >> 8;
if (colorMaps[colorMapIndex][colorVal] > 31)
colorMaps[colorMapIndex][colorVal] = 31;
}
}
}
@ -338,26 +345,26 @@ static void BuildGammaShiftTables(void)
}
// When the weather is changing, it gradually updates the palettes
// towards the desired gamma shift.
static void UpdateWeatherGammaShift(void)
// towards the desired color map.
static void UpdateWeatherColorMap(void)
{
if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_OUT)
{
if (gWeatherPtr->gammaIndex == gWeatherPtr->gammaTargetIndex)
if (gWeatherPtr->colorMapIndex == gWeatherPtr->targetColorMapIndex)
{
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
else
{
if (++gWeatherPtr->gammaStepFrameCounter >= gWeatherPtr->gammaStepDelay)
if (++gWeatherPtr->colorMapStepCounter >= gWeatherPtr->colorMapStepDelay)
{
gWeatherPtr->gammaStepFrameCounter = 0;
if (gWeatherPtr->gammaIndex < gWeatherPtr->gammaTargetIndex)
gWeatherPtr->gammaIndex++;
gWeatherPtr->colorMapStepCounter = 0;
if (gWeatherPtr->colorMapIndex < gWeatherPtr->targetColorMapIndex)
gWeatherPtr->colorMapIndex++;
else
gWeatherPtr->gammaIndex--;
gWeatherPtr->colorMapIndex--;
ApplyGammaShift(0, 32, gWeatherPtr->gammaIndex);
ApplyColorMap(0, 32, gWeatherPtr->colorMapIndex);
}
}
}
@ -377,21 +384,21 @@ static void FadeInScreenWithWeather(void)
case WEATHER_SHADE:
if (FadeInScreen_RainShowShade() == FALSE)
{
gWeatherPtr->gammaIndex = 3;
gWeatherPtr->colorMapIndex = 3;
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
break;
case WEATHER_DROUGHT:
if (FadeInScreen_Drought() == FALSE)
{
gWeatherPtr->gammaIndex = -6;
gWeatherPtr->colorMapIndex = -6;
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
break;
case WEATHER_FOG_HORIZONTAL:
if (FadeInScreen_FogHorizontal() == FALSE)
{
gWeatherPtr->gammaIndex = 0;
gWeatherPtr->colorMapIndex = 0;
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
break;
@ -402,7 +409,7 @@ static void FadeInScreenWithWeather(void)
default:
if (!gPaletteFade.active)
{
gWeatherPtr->gammaIndex = gWeatherPtr->gammaTargetIndex;
gWeatherPtr->colorMapIndex = gWeatherPtr->targetColorMapIndex;
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
break;
@ -416,12 +423,12 @@ static bool8 FadeInScreen_RainShowShade(void)
if (++gWeatherPtr->fadeScreenCounter >= 16)
{
ApplyGammaShift(0, 32, 3);
ApplyColorMap(0, 32, 3);
gWeatherPtr->fadeScreenCounter = 16;
return FALSE;
}
ApplyGammaShiftWithBlend(0, 32, 3, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor);
ApplyColorMapWithBlend(0, 32, 3, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor);
return TRUE;
}
@ -432,12 +439,12 @@ static bool8 FadeInScreen_Drought(void)
if (++gWeatherPtr->fadeScreenCounter >= 16)
{
ApplyGammaShift(0, 32, -6);
ApplyColorMap(0, 32, -6);
gWeatherPtr->fadeScreenCounter = 16;
return FALSE;
}
ApplyDroughtGammaShiftWithBlend(-6, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor);
ApplyDroughtColorMapWithBlend(-6, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor);
return TRUE;
}
@ -454,24 +461,24 @@ static bool8 FadeInScreen_FogHorizontal(void)
static void DoNothing(void)
{ }
static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
static void ApplyColorMap(u8 startPalIndex, u8 numPalettes, s8 colorMapIndex)
{
u16 curPalIndex;
u16 palOffset;
u8 *gammaTable;
u8 *colorMap;
u16 i;
if (gammaIndex > 0)
if (colorMapIndex > 0)
{
gammaIndex--;
colorMapIndex--;
palOffset = startPalIndex * 16;
numPalettes += startPalIndex;
curPalIndex = startPalIndex;
// Loop through the speficied palette range and apply necessary gamma shifts to the colors.
// Loop through the specified palette range and apply necessary color maps.
while (curPalIndex < numPalettes)
{
if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE)
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_NONE)
{
// No palette change.
CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16));
@ -481,18 +488,18 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
{
u8 r, g, b;
if (sPaletteGammaTypes[curPalIndex] == GAMMA_ALT || curPalIndex - 16 == gWeatherPtr->altGammaSpritePalIndex)
gammaTable = gWeatherPtr->altGammaShifts[gammaIndex];
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_CONTRAST || curPalIndex - 16 == gWeatherPtr->contrastColorMapSpritePalIndex)
colorMap = gWeatherPtr->contrastColorMaps[colorMapIndex];
else
gammaTable = gWeatherPtr->gammaShifts[gammaIndex];
colorMap = gWeatherPtr->darkenedContrastColorMaps[colorMapIndex];
for (i = 0; i < 16; i++)
{
// Apply gamma shift to the original color.
// Apply color map to the original color.
struct RGBColor baseColor = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset];
r = gammaTable[baseColor.r];
g = gammaTable[baseColor.g];
b = gammaTable[baseColor.b];
r = colorMap[baseColor.r];
g = colorMap[baseColor.g];
b = colorMap[baseColor.b];
gPlttBufferFaded[palOffset++] = RGB2(r, g, b);
}
}
@ -500,17 +507,17 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
curPalIndex++;
}
}
else if (gammaIndex < 0)
else if (colorMapIndex < 0)
{
// A negative gammIndex value means that the blending will come from the special Drought weather's palette tables.
gammaIndex = -gammaIndex - 1;
colorMapIndex = -colorMapIndex - 1;
palOffset = startPalIndex * 16;
numPalettes += startPalIndex;
curPalIndex = startPalIndex;
while (curPalIndex < numPalettes)
{
if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE)
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_NONE)
{
// No palette change.
CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16));
@ -520,7 +527,7 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
{
for (i = 0; i < 16; i++)
{
gPlttBufferFaded[palOffset] = sDroughtWeatherColors[gammaIndex][DROUGHT_COLOR_INDEX(gPlttBufferUnfaded[palOffset])];
gPlttBufferFaded[palOffset] = sDroughtWeatherColors[colorMapIndex][DROUGHT_COLOR_INDEX(gPlttBufferUnfaded[palOffset])];
palOffset++;
}
}
@ -535,7 +542,7 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex)
}
}
static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor)
static void ApplyColorMapWithBlend(u8 startPalIndex, u8 numPalettes, s8 colorMapIndex, u8 blendCoeff, u16 blendColor)
{
u16 palOffset;
u16 curPalIndex;
@ -547,34 +554,34 @@ static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaI
palOffset = startPalIndex * 16;
numPalettes += startPalIndex;
gammaIndex--;
colorMapIndex--;
curPalIndex = startPalIndex;
while (curPalIndex < numPalettes)
{
if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE)
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_NONE)
{
// No gamma shift. Simply blend the colors.
// No color map. Simply blend the colors.
BlendPalette(palOffset, 16, blendCoeff, blendColor);
palOffset += 16;
}
else
{
u8 *gammaTable;
u8 *colorMap;
if (sPaletteGammaTypes[curPalIndex] == GAMMA_NORMAL)
gammaTable = gWeatherPtr->gammaShifts[gammaIndex];
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_DARK_CONTRAST)
colorMap = gWeatherPtr->darkenedContrastColorMaps[colorMapIndex];
else
gammaTable = gWeatherPtr->altGammaShifts[gammaIndex];
colorMap = gWeatherPtr->contrastColorMaps[colorMapIndex];
for (i = 0; i < 16; i++)
{
struct RGBColor baseColor = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset];
u8 r = gammaTable[baseColor.r];
u8 g = gammaTable[baseColor.g];
u8 b = gammaTable[baseColor.b];
u8 r = colorMap[baseColor.r];
u8 g = colorMap[baseColor.g];
u8 b = colorMap[baseColor.b];
// Apply gamma shift and target blend color to the original color.
// Apply color map and target blend color to the original color.
r += ((rBlend - r) * blendCoeff) >> 4;
g += ((gBlend - g) * blendCoeff) >> 4;
b += ((bBlend - b) * blendCoeff) >> 4;
@ -586,7 +593,7 @@ static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaI
}
}
static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 blendColor)
static void ApplyDroughtColorMapWithBlend(s8 colorMapIndex, u8 blendCoeff, u16 blendColor)
{
struct RGBColor color;
u8 rBlend;
@ -596,7 +603,7 @@ static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 bl
u16 palOffset;
u16 i;
gammaIndex = -gammaIndex - 1;
colorMapIndex = -colorMapIndex - 1;
color = *(struct RGBColor *)&blendColor;
rBlend = color.r;
gBlend = color.g;
@ -604,9 +611,9 @@ static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 bl
palOffset = 0;
for (curPalIndex = 0; curPalIndex < 32; curPalIndex++)
{
if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE)
if (sPaletteColorMapTypes[curPalIndex] == COLOR_MAP_NONE)
{
// No gamma shift. Simply blend the colors.
// No color map. Simply blend the colors.
BlendPalette(palOffset, 16, blendCoeff, blendColor);
palOffset += 16;
}
@ -626,7 +633,7 @@ static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 bl
b1 = color1.b;
offset = ((b1 & 0x1E) << 7) | ((g1 & 0x1E) << 3) | ((r1 & 0x1E) >> 1);
color2 = *(struct RGBColor *)&sDroughtWeatherColors[gammaIndex][offset];
color2 = *(struct RGBColor *)&sDroughtWeatherColors[colorMapIndex][offset];
r2 = color2.r;
g2 = color2.g;
b2 = color2.b;
@ -710,25 +717,25 @@ static bool8 LightenSpritePaletteInFog(u8 paletteIndex)
return FALSE;
}
void ApplyWeatherGammaShiftIfIdle(s8 gammaIndex)
void ApplyWeatherColorMapIfIdle(s8 colorMapIndex)
{
if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE)
{
ApplyGammaShift(0, 32, gammaIndex);
gWeatherPtr->gammaIndex = gammaIndex;
ApplyColorMap(0, 32, colorMapIndex);
gWeatherPtr->colorMapIndex = colorMapIndex;
}
}
void ApplyWeatherGammaShiftIfIdle_Gradual(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay)
void ApplyWeatherColorMapIfIdle_Gradual(u8 colorMapIndex, u8 targetColorMapIndex, u8 colorMapStepDelay)
{
if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE)
{
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER;
gWeatherPtr->gammaIndex = gammaIndex;
gWeatherPtr->gammaTargetIndex = gammaTargetIndex;
gWeatherPtr->gammaStepFrameCounter = 0;
gWeatherPtr->gammaStepDelay = gammaStepDelay;
ApplyWeatherGammaShiftIfIdle(gammaIndex);
gWeatherPtr->colorMapIndex = colorMapIndex;
gWeatherPtr->targetColorMapIndex = targetColorMapIndex;
gWeatherPtr->colorMapStepCounter = 0;
gWeatherPtr->colorMapStepDelay = colorMapStepDelay;
ApplyWeatherColorMapIfIdle(colorMapIndex);
}
}
@ -832,7 +839,7 @@ void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex)
default:
if (gWeatherPtr->currWeather != WEATHER_FOG_HORIZONTAL)
{
ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex);
ApplyColorMap(paletteIndex, 1, gWeatherPtr->colorMapIndex);
}
else
{
@ -843,9 +850,9 @@ void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex)
}
}
void ApplyWeatherGammaShiftToPal(u8 paletteIndex)
void ApplyWeatherColorMapToPal(u8 paletteIndex)
{
ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex);
ApplyColorMap(paletteIndex, 1, gWeatherPtr->colorMapIndex);
}
// Unused
@ -886,9 +893,9 @@ bool8 LoadDroughtWeatherPalettes(void)
return FALSE;
}
static void SetDroughtGamma(s8 gammaIndex)
static void SetDroughtColorMap(s8 colorMapIndex)
{
ApplyWeatherGammaShiftIfIdle(-gammaIndex - 1);
ApplyWeatherColorMapIfIdle(-colorMapIndex - 1);
}
void DroughtStateInit(void)
@ -907,7 +914,7 @@ void DroughtStateRun(void)
if (++gWeatherPtr->droughtTimer > 5)
{
gWeatherPtr->droughtTimer = 0;
SetDroughtGamma(gWeatherPtr->droughtBrightnessStage++);
SetDroughtColorMap(gWeatherPtr->droughtBrightnessStage++);
if (gWeatherPtr->droughtBrightnessStage > 5)
{
gWeatherPtr->droughtLastBrightnessStage = gWeatherPtr->droughtBrightnessStage;
@ -920,14 +927,14 @@ void DroughtStateRun(void)
gWeatherPtr->droughtTimer = (gWeatherPtr->droughtTimer + 3) & 0x7F;
gWeatherPtr->droughtBrightnessStage = ((gSineTable[gWeatherPtr->droughtTimer] - 1) >> 6) + 2;
if (gWeatherPtr->droughtBrightnessStage != gWeatherPtr->droughtLastBrightnessStage)
SetDroughtGamma(gWeatherPtr->droughtBrightnessStage);
SetDroughtColorMap(gWeatherPtr->droughtBrightnessStage);
gWeatherPtr->droughtLastBrightnessStage = gWeatherPtr->droughtBrightnessStage;
break;
case 2:
if (++gWeatherPtr->droughtTimer > 5)
{
gWeatherPtr->droughtTimer = 0;
SetDroughtGamma(--gWeatherPtr->droughtBrightnessStage);
SetDroughtColorMap(--gWeatherPtr->droughtBrightnessStage);
if (gWeatherPtr->droughtBrightnessStage == 3)
gWeatherPtr->droughtState = 0;
}
@ -1093,12 +1100,12 @@ void SetWeatherPalStateIdle(void)
void PreservePaletteInWeather(u8 preservedPalIndex)
{
CpuCopy16(sBasePaletteGammaTypes, sFieldEffectPaletteGammaTypes, 32);
sFieldEffectPaletteGammaTypes[preservedPalIndex] = GAMMA_NONE;
sPaletteGammaTypes = sFieldEffectPaletteGammaTypes;
CpuCopy16(sBasePaletteColorMapTypes, sFieldEffectPaletteColorMapTypes, 32);
sFieldEffectPaletteColorMapTypes[preservedPalIndex] = COLOR_MAP_NONE;
sPaletteColorMapTypes = sFieldEffectPaletteColorMapTypes;
}
void ResetPreservedPalettesInWeather(void)
{
sPaletteGammaTypes = sBasePaletteGammaTypes;
sPaletteColorMapTypes = sBasePaletteColorMapTypes;
}

View File

@ -94,8 +94,8 @@ static const struct SpriteTemplate sCloudSpriteTemplate =
void Clouds_InitVars(void)
{
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->initStep = 0;
if (gWeatherPtr->cloudSpritesCreated == FALSE)
@ -152,8 +152,8 @@ bool8 Clouds_Finish(void)
void Sunny_InitVars(void)
{
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 20;
}
void Sunny_InitAll(void)
@ -235,8 +235,8 @@ void Drought_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 0;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 0;
}
void Drought_InitAll(void)
@ -476,8 +476,8 @@ void Rain_InitVars(void)
gWeatherPtr->rainSpriteVisibleDelay = 8;
gWeatherPtr->isDownpour = FALSE;
gWeatherPtr->targetRainSpriteCount = 10;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 3;
gWeatherPtr->colorMapStepDelay = 20;
SetRainStrengthFromSoundEffect(SE_RAIN);
}
@ -768,8 +768,8 @@ void Snow_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 3;
gWeatherPtr->colorMapStepDelay = 20;
gWeatherPtr->targetSnowflakeSpriteCount = 16;
gWeatherPtr->snowflakeVisibleCounter = 0;
}
@ -1042,8 +1042,8 @@ void Thunderstorm_InitVars(void)
gWeatherPtr->rainSpriteVisibleDelay = 4;
gWeatherPtr->isDownpour = FALSE;
gWeatherPtr->targetRainSpriteCount = 16;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 3;
gWeatherPtr->colorMapStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment
gWeatherPtr->thunderTriggered = FALSE;
SetRainStrengthFromSoundEffect(SE_THUNDERSTORM);
@ -1071,8 +1071,8 @@ void Downpour_InitVars(void)
gWeatherPtr->rainSpriteVisibleDelay = 4;
gWeatherPtr->isDownpour = TRUE;
gWeatherPtr->targetRainSpriteCount = 24;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 3;
gWeatherPtr->colorMapStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment
SetRainStrengthFromSoundEffect(SE_DOWNPOUR);
}
@ -1128,7 +1128,7 @@ void Thunderstorm_Main(void)
gWeatherPtr->initStep++;
// fall through
case TSTORM_STATE_TRY_THUNDER_SHORT:
ApplyWeatherGammaShiftIfIdle(19);
ApplyWeatherColorMapIfIdle(19);
if (!gWeatherPtr->thunderSkipShort && gWeatherPtr->thunderShortRetries == 1)
SetThunderCounter(20); // Do short thunder
@ -1138,7 +1138,7 @@ void Thunderstorm_Main(void)
case TSTORM_STATE_TRY_NEW_THUNDER:
if (--gWeatherPtr->thunderDelay == 0)
{
ApplyWeatherGammaShiftIfIdle(3);
ApplyWeatherColorMapIfIdle(3);
gWeatherPtr->thunderAllowEnd = TRUE;
if (--gWeatherPtr->thunderShortRetries != 0)
{
@ -1171,7 +1171,7 @@ void Thunderstorm_Main(void)
{
// Do long thunder
SetThunderCounter(100);
ApplyWeatherGammaShiftIfIdle(19);
ApplyWeatherColorMapIfIdle(19);
gWeatherPtr->thunderDelay = (Random() & 0xF) + 30;
gWeatherPtr->initStep++;
}
@ -1179,7 +1179,7 @@ void Thunderstorm_Main(void)
case TSTORM_STATE_FADE_THUNDER_LONG:
if (--gWeatherPtr->thunderDelay == 0)
{
ApplyWeatherGammaShiftIfIdle_Gradual(19, 3, 5);
ApplyWeatherColorMapIfIdle_Gradual(19, 3, 5);
gWeatherPtr->initStep++;
}
break;
@ -1361,8 +1361,8 @@ void FogHorizontal_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 20;
if (gWeatherPtr->fogHSpritesCreated == 0)
{
gWeatherPtr->fogHScrollCounter = 0;
@ -1516,8 +1516,8 @@ void Ash_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 20;
gWeatherPtr->ashUnused = 20; // Never read
if (!gWeatherPtr->ashSpritesCreated)
{
@ -1726,8 +1726,8 @@ void FogDiagonal_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = 0;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 20;
gWeatherPtr->fogHScrollCounter = 0;
gWeatherPtr->fogHScrollOffset = 1;
if (!gWeatherPtr->fogDSpritesCreated)
@ -1940,8 +1940,8 @@ void Sandstorm_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = 0;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 0;
gWeatherPtr->colorMapStepDelay = 20;
if (!gWeatherPtr->sandstormSpritesCreated)
{
gWeatherPtr->sandstormXOffset = gWeatherPtr->sandstormYOffset = 0;
@ -2237,8 +2237,8 @@ static void UpdateSandstormSwirlSprite(struct Sprite *sprite)
void Shade_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->targetColorMapIndex = 3;
gWeatherPtr->colorMapStepDelay = 20;
}
void Shade_InitAll(void)

View File

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

View File

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

View File

@ -880,6 +880,7 @@ const u8 *ItemId_GetName(u16 itemId)
return gItems[SanitizeItemId(itemId)].name;
}
// Unused
u16 ItemId_GetId(u16 itemId)
{
return gItems[SanitizeItemId(itemId)].itemId;
@ -910,7 +911,7 @@ u8 ItemId_GetImportance(u16 itemId)
return gItems[SanitizeItemId(itemId)].importance;
}
// unused
// Unused
u8 ItemId_GetRegistrability(u16 itemId)
{
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)
{
if (itemId == 0xFFFF)
itemId = ITEM_FIELD_ARROW;
if (itemId == ITEM_LIST_END)
itemId = ITEMS_COUNT; // Use last icon, the "return to field" arrow
else if (itemId >= ITEMS_COUNT)
itemId = 0;

View File

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

View File

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

View File

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

View File

@ -1121,7 +1121,7 @@ static void Task_DisplayMainMenuInvalidActionError(u8 taskId)
switch (gTasks[taskId].tCurrItem)
{
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)
{
case 0:

View File

@ -90,7 +90,7 @@ void CB2_InitMysteryEventMenu(void)
for (i = 0; i < 2; i++)
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);
Menu_LoadStdPalAt(0xE0);
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,
.tilemapLeft = 0,
.tilemapTop = 0,
.width = 30,
.width = DISPLAY_TILE_WIDTH,
.height = 2,
.paletteNum = 12,
.baseBlock = 0x0013
@ -118,7 +118,7 @@ static const struct WindowTemplate sMainWindows[] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 15,
.width = 30,
.width = DISPLAY_TILE_WIDTH,
.height = 5,
.paletteNum = 13,
.baseBlock = 0x004f
@ -640,8 +640,8 @@ static u32 MysteryGift_HandleThreeOptionMenu(u8 * unused0, u16 * unused1, u8 whi
width++;
windowTemplate.width = width;
if (width < 30)
windowTemplate.tilemapLeft = (30 - width) / 2;
if (width < DISPLAY_TILE_WIDTH)
windowTemplate.tilemapLeft = (DISPLAY_TILE_WIDTH - width) / 2;
else
windowTemplate.tilemapLeft = 0;

View File

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

View File

@ -267,7 +267,7 @@ static const struct WindowTemplate sWindowTemplates[WIN_COUNT + 1] =
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 0,
.width = 30,
.width = DISPLAY_TILE_WIDTH,
.height = 2,
.paletteNum = 11,
.baseBlock = 0x074
@ -2179,6 +2179,12 @@ static const struct OamData sOam_32x16 =
.paletteNum = 0,
};
/*
[0_____][] <-1 40x32
[2_____][] <-3
[4___+_][] <-5/Origin
[6 ][] <-7
*/
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[] =
{
{
@ -2267,6 +2277,11 @@ static const struct Subsprite sSubsprites_PageSwapText[] =
}
};
/*
[0_____][] <-1 40x24
[2_____][] <-3
[4___+_][] <-5/Origin
*/
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[] =
{
{

View File

@ -812,8 +812,8 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum)
CopySecondaryTilesetToVramUsingHeap(gMapHeader.mapLayout);
LoadSecondaryTilesetPalette(gMapHeader.mapLayout);
for (paletteIndex = 6; paletteIndex < 13; paletteIndex++)
ApplyWeatherGammaShiftToPal(paletteIndex);
for (paletteIndex = NUM_PALS_IN_PRIMARY; paletteIndex < NUM_PALS_TOTAL; paletteIndex++)
ApplyWeatherColorMapToPal(paletteIndex);
InitSecondaryTilesetAnimation();
UpdateLocationHistoryForRoamer();

View File

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

View File

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

View File

@ -550,8 +550,7 @@ struct PokemonStorageSystemData
u16 *displayMonTilePtr;
struct Sprite *displayMonSprite;
u16 displayMonPalBuffer[0x40];
u8 tileBuffer[0x800];
u8 unusedBuffer[0x1800]; // Unused
u8 tileBuffer[MON_PIC_SIZE * 4]; // 4x the size of a 'Mon sprite to account for Castform
u8 itemIconBuffer[0x800];
u8 wallpaperBgTilemapBuffer[0x1000];
u8 displayMenuTilemapBuffer[0x800];

View File

@ -21,11 +21,6 @@
#include "constants/rgb.h"
#define BATTLER_RECORD_SIZE 664
#define ILLEGAL_BATTLE_TYPES ((BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_FIRST_BATTLE \
| BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_ROAMER | BATTLE_TYPE_EREADER_TRAINER \
| BATTLE_TYPE_KYOGRE_GROUDON | BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI \
| BATTLE_TYPE_RECORDED | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_SECRET_BASE \
| BATTLE_TYPE_GROUDON | BATTLE_TYPE_KYOGRE | BATTLE_TYPE_RAYQUAZA))
struct PlayerInfo
{
@ -301,7 +296,7 @@ static bool32 IsRecordedBattleSaveValid(struct RecordedBattleSave *save)
{
if (save->battleFlags == 0)
return FALSE;
if (save->battleFlags & ILLEGAL_BATTLE_TYPES)
if (save->battleFlags & BATTLE_TYPE_RECORDED_INVALID)
return FALSE;
if (CalcByteArraySum((void *)(save), sizeof(*save) - 4) != save->checksum)
return FALSE;

278
src/shop.c Executable file → Normal file
View File

@ -42,10 +42,72 @@
#define TAG_SCROLL_ARROW 2100
#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 ShopData *sShopData = 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;
EWRAM_DATA struct ItemSlot gMartPurchaseHistory[SMARTSHOPPER_NUM_ITEMS] = {0};
@ -114,7 +176,7 @@ static const struct MenuAction sShopMenuActions_BuyQuit[] =
static const struct WindowTemplate sShopMenuWindowTemplates[] =
{
{
[WIN_BUY_SELL_QUIT] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 1,
@ -123,7 +185,8 @@ static const struct WindowTemplate sShopMenuWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x0008,
},
{
// Separate shop menu window for decorations, which can't be sold
[WIN_BUY_QUIT] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 1,
@ -141,7 +204,7 @@ static const struct ListMenuTemplate sShopBuyMenuListTemplate =
.itemPrintFunc = BuyMenuPrintPriceInList,
.totalItems = 0,
.maxShowed = 0,
.windowId = 1,
.windowId = WIN_ITEM_LIST,
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -198,7 +261,7 @@ static const struct BgTemplate sShopBuyMenuBgTemplates[] =
static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
{
{
[WIN_MONEY] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -207,7 +270,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x001E,
},
{
[WIN_ITEM_LIST] = {
.bg = 0,
.tilemapLeft = 14,
.tilemapTop = 2,
@ -216,7 +279,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x0032,
},
{
[WIN_ITEM_DESCRIPTION] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 13,
@ -225,7 +288,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x0122,
},
{
[WIN_QUANTITY_IN_BAG] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 11,
@ -234,7 +297,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x0176,
},
{
[WIN_QUANTITY_PRICE] = {
.bg = 0,
.tilemapLeft = 18,
.tilemapTop = 11,
@ -243,7 +306,7 @@ static const struct WindowTemplate sShopBuyMenuWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x018E,
},
{
[WIN_MESSAGE] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
@ -268,9 +331,9 @@ static const struct WindowTemplate sShopBuyMenuYesNoWindowTemplates =
static const u8 sShopBuyMenuTextColors[][3] =
{
{1, 2, 3},
{0, 2, 3},
{0, 3, 2}
[COLORID_NORMAL] = {1, 2, 3},
[COLORID_ITEM_LIST] = {0, 2, 3},
[COLORID_GRAY_CURSOR] = {0, 3, 2},
};
static u8 CreateShopMenu(u8 martType)
@ -282,8 +345,7 @@ static u8 CreateShopMenu(u8 martType)
if (martType == MART_TYPE_NORMAL)
{
struct WindowTemplate winTemplate;
winTemplate = sShopMenuWindowTemplates[0];
struct WindowTemplate winTemplate = sShopMenuWindowTemplates[WIN_BUY_SELL_QUIT];
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit));
sMartInfo.windowId = AddWindow(&winTemplate);
sMartInfo.menuActions = sShopMenuActions_BuySellQuit;
@ -291,8 +353,7 @@ static u8 CreateShopMenu(u8 martType)
}
else
{
struct WindowTemplate winTemplate;
winTemplate = sShopMenuWindowTemplates[1];
struct WindowTemplate winTemplate = sShopMenuWindowTemplates[WIN_BUY_QUIT];
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit));
sMartInfo.windowId = AddWindow(&winTemplate);
sMartInfo.menuActions = sShopMenuActions_BuyQuit;
@ -320,6 +381,7 @@ static void SetShopItemsForSale(const u16 *items)
sMartInfo.itemList = items;
sMartInfo.itemCount = 0;
// Read items until ITEM_NONE / DECOR_NONE is reached
while (sMartInfo.itemList[i])
{
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)
{
s16 *data = gTasks[taskId].data;
data[8] = (u32)CB2_InitBuyMenu >> 16;
data[9] = (u32)CB2_InitBuyMenu;
tCallbackHi = (u32)CB2_InitBuyMenu >> 16;
tCallbackLo = (u32)CB2_InitBuyMenu;
gTasks[taskId].func = Task_GoToBuyOrSellMenu;
FadeScreen(FADE_TO_BLACK, 0);
}
@ -356,8 +424,8 @@ static void Task_HandleShopMenuBuy(u8 taskId)
static void Task_HandleShopMenuSell(u8 taskId)
{
s16 *data = gTasks[taskId].data;
data[8] = (u32)CB2_GoToSellMenu >> 16;
data[9] = (u32)CB2_GoToSellMenu;
tCallbackHi = (u32)CB2_GoToSellMenu >> 16;
tCallbackLo = (u32)CB2_GoToSellMenu;
gTasks[taskId].func = Task_GoToBuyOrSellMenu;
FadeScreen(FADE_TO_BLACK, 0);
}
@ -386,7 +454,7 @@ static void Task_GoToBuyOrSellMenu(u8 taskId)
if (!gPaletteFade.active)
{
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();
}
#define tItemCount data[1]
#define tItemId data[5]
#define tListTaskId data[7]
static void CB2_InitBuyMenu(void)
{
u8 taskId;
@ -472,8 +536,8 @@ static void CB2_InitBuyMenu(void)
BuyMenuAddScrollIndicatorArrows();
taskId = CreateTask(Task_BuyMenu, 8);
gTasks[taskId].tListTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
BlendPalettes(PALETTES_ALL, 0x10, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK);
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
SetVBlankCallback(VBlankCB_BuyMenu);
SetMainCallback2(CB2_BuyMenu);
break;
@ -504,8 +568,8 @@ static void BuyMenuBuildListMenuTemplate(void)
gMultiuseListMenuTemplate = sShopBuyMenuListTemplate;
gMultiuseListMenuTemplate.items = sListMenuItems;
gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1;
if (gMultiuseListMenuTemplate.totalItems > 8)
gMultiuseListMenuTemplate.maxShowed = 8;
if (gMultiuseListMenuTemplate.totalItems > MAX_ITEMS_SHOWN)
gMultiuseListMenuTemplate.maxShowed = MAX_ITEMS_SHOWN;
else
gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems;
@ -532,7 +596,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
if (item != LIST_CANCEL)
BuyMenuAddItemIcon(item, sShopData->iconSlot);
else
BuyMenuAddItemIcon(-1, sShopData->iconSlot);
BuyMenuAddItemIcon(ITEM_LIST_END, sShopData->iconSlot);
BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1);
sShopData->iconSlot ^= 1;
@ -548,8 +612,8 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
description = gText_QuitShopping;
}
FillWindowPixelBuffer(2, PIXEL_FILL(0));
BuyMenuPrint(2, description, 3, 1, 0, 0);
FillWindowPixelBuffer(WIN_ITEM_DESCRIPTION, PIXEL_FILL(0));
BuyMenuPrint(WIN_ITEM_DESCRIPTION, description, 3, 1, 0, COLORID_NORMAL);
}
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);
x = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 0x78);
AddTextPrinterParameterized4(windowId, FONT_NARROW, x, y, 0, 0, sShopBuyMenuTextColors[1], TEXT_SKIP_DRAW, gStringVar4);
x = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 120);
AddTextPrinterParameterized4(windowId, FONT_NARROW, x, y, 0, 0, sShopBuyMenuTextColors[COLORID_ITEM_LIST], TEXT_SKIP_DRAW, gStringVar4);
}
}
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(
SCROLL_ARROW_UP,
172,
12,
148,
sMartInfo.itemCount - 7,
sMartInfo.itemCount - (MAX_ITEMS_SHOWN - 1),
TAG_SCROLL_ARROW,
TAG_SCROLL_ARROW,
&sShopData->scrollOffset);
@ -609,7 +673,7 @@ static void BuyMenuRemoveScrollIndicatorArrows(void)
static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet)
{
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)
@ -619,7 +683,7 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
if (*spriteIdPtr != SPRITE_NONE)
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);
if (spriteId != MAX_SPRITES)
@ -683,11 +747,11 @@ static void BuyMenuInitWindows(void)
{
InitWindows(sShopBuyMenuWindowTemplates);
DeactivateAllTextPrinters();
LoadUserWindowBorderGfx(0, 1, 0xD0);
LoadMessageBoxGfx(0, 0xA, 0xE0);
PutWindowTilemap(0);
PutWindowTilemap(1);
PutWindowTilemap(2);
LoadUserWindowBorderGfx(WIN_MONEY, 1, 0xD0);
LoadMessageBoxGfx(WIN_MONEY, 0xA, 0xE0);
PutWindowTilemap(WIN_MONEY);
PutWindowTilemap(WIN_ITEM_LIST);
PutWindowTilemap(WIN_ITEM_DESCRIPTION);
}
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)
{
DisplayMessageAndContinueTask(taskId, 5, 10, 14, FONT_NORMAL, GetPlayerTextSpeedDelay(), text, callback);
DisplayMessageAndContinueTask(taskId, WIN_MESSAGE, 10, 14, FONT_NORMAL, GetPlayerTextSpeedDelay(), text, callback);
ScheduleBgCopyTilemapToVram(0);
}
@ -706,7 +770,7 @@ static void BuyMenuDrawGraphics(void)
BuyMenuDrawMapGraphics();
BuyMenuCopyMenuBgToBg1TilemapBuffer();
AddMoneyLabelObject(19, 11);
PrintMoneyAmountInMoneyBoxWithBorder(0, 1, 13, GetMoney(&gSaveBlock1Ptr->money));
PrintMoneyAmountInMoneyBoxWithBorder(WIN_MONEY, 1, 13, GetMoney(&gSaveBlock1Ptr->money));
ScheduleBgCopyTilemapToVram(0);
ScheduleBgCopyTilemapToVram(1);
ScheduleBgCopyTilemapToVram(2);
@ -722,10 +786,8 @@ static void BuyMenuDrawMapGraphics(void)
static void BuyMenuDrawMapBg(void)
{
s16 i;
s16 j;
s16 x;
s16 y;
s16 i, j;
s16 x, y;
const struct MapLayout *mapLayout;
u16 metatile;
u8 metatileLayerType;
@ -790,11 +852,13 @@ static void BuyMenuCollectObjectEventData(void)
s16 facingY;
u8 y;
u8 x;
u8 r8 = 0;
u8 numObjects = 0;
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
for (y = 0; y < OBJECT_EVENTS_COUNT; y++)
sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
for (y = 0; y < 5; y++)
{
for (x = 0; x < 7; x++)
@ -803,28 +867,28 @@ static void BuyMenuCollectObjectEventData(void)
if (objEventId != OBJECT_EVENTS_COUNT)
{
sShopData->viewportObjects[r8][OBJ_EVENT_ID] = objEventId;
sShopData->viewportObjects[r8][X_COORD] = x;
sShopData->viewportObjects[r8][Y_COORD] = y;
sShopData->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
sShopData->viewportObjects[numObjects][OBJ_EVENT_ID] = objEventId;
sShopData->viewportObjects[numObjects][X_COORD] = x;
sShopData->viewportObjects[numObjects][Y_COORD] = y;
sShopData->viewportObjects[numObjects][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
switch (gObjectEvents[objEventId].facingDirection)
{
case DIR_SOUTH:
sShopData->viewportObjects[r8][ANIM_NUM] = 0;
break;
case DIR_NORTH:
sShopData->viewportObjects[r8][ANIM_NUM] = 1;
break;
case DIR_WEST:
sShopData->viewportObjects[r8][ANIM_NUM] = 2;
break;
case DIR_EAST:
default:
sShopData->viewportObjects[r8][ANIM_NUM] = 3;
break;
case DIR_SOUTH:
sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_SOUTH;
break;
case DIR_NORTH:
sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_NORTH;
break;
case DIR_WEST:
sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_WEST;
break;
case DIR_EAST:
default:
sShopData->viewportObjects[numObjects][ANIM_NUM] = ANIM_STD_FACE_EAST;
break;
}
r8++;
numObjects++;
}
}
}
@ -863,13 +927,9 @@ static void BuyMenuDrawObjectEvents(void)
static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object)
{
if (!BuyMenuCheckForOverlapWithMenuBg(object[X_COORD], object[Y_COORD] + 2) && object[LAYER_TYPE] != METATILE_LAYER_TYPE_COVERED)
{
return TRUE;
}
else
{
return FALSE;
}
}
static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
@ -881,9 +941,7 @@ static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
for (i = 0; i < 1024; i++)
{
if (src[i] != 0)
{
dest[i] = src[i] + 0xC3E3;
}
}
}
@ -897,9 +955,7 @@ static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y)
metatile[offset2 + offset1 + 32] == 0 &&
metatile[offset2 + offset1 + 1] == 0 &&
metatile[offset2 + offset1 + 33] == 0)
{
return TRUE;
}
return FALSE;
}
@ -924,18 +980,14 @@ static void Task_BuyMenu(u8 taskId)
default:
PlaySE(SE_SELECT);
tItemId = itemId;
ClearWindowTilemap(2);
ClearWindowTilemap(WIN_ITEM_DESCRIPTION);
BuyMenuRemoveScrollIndicatorArrows();
BuyMenuPrintCursor(tListTaskId, 2);
BuyMenuPrintCursor(tListTaskId, COLORID_GRAY_CURSOR);
if (sMartInfo.martType == MART_TYPE_NORMAL)
{
sShopData->totalCost = (ItemId_GetPrice(itemId) >> IsPokeNewsActive(POKENEWS_SLATEPORT));
}
else
{
sShopData->totalCost = gDecorations[itemId].price;
}
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost))
{
@ -981,25 +1033,21 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
u16 quantityInBag = CountTotalItemQuantityInBag(tItemId);
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);
StringExpandPlaceholders(gStringVar4, gText_InBagVar1);
BuyMenuPrint(3, gStringVar4, 0, 1, 0, 0);
BuyMenuPrint(WIN_QUANTITY_IN_BAG, gStringVar4, 0, 1, 0, COLORID_NORMAL);
tItemCount = 1;
DrawStdFrameWithCustomTileAndPalette(4, FALSE, 1, 13);
DrawStdFrameWithCustomTileAndPalette(WIN_QUANTITY_PRICE, FALSE, 1, 13);
BuyMenuPrintItemQuantityAndPrice(taskId);
ScheduleBgCopyTilemapToVram(0);
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost;
if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
{
sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY;
}
else
{
sShopData->maxQuantity = maxQuantity;
}
gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput;
}
@ -1018,11 +1066,11 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(4, FALSE);
ClearStdWindowAndFrameToTransparent(3, FALSE);
ClearWindowTilemap(4);
ClearWindowTilemap(3);
PutWindowTilemap(1);
ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_PRICE, FALSE);
ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_IN_BAG, FALSE);
ClearWindowTilemap(WIN_QUANTITY_PRICE);
ClearWindowTilemap(WIN_QUANTITY_IN_BAG);
PutWindowTilemap(WIN_ITEM_LIST);
CopyItemName(tItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
@ -1031,10 +1079,10 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(4, FALSE);
ClearStdWindowAndFrameToTransparent(3, FALSE);
ClearWindowTilemap(4);
ClearWindowTilemap(3);
ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_PRICE, FALSE);
ClearStdWindowAndFrameToTransparent(WIN_QUANTITY_IN_BAG, FALSE);
ClearWindowTilemap(WIN_QUANTITY_PRICE);
ClearWindowTilemap(WIN_QUANTITY_IN_BAG);
BuyMenuReturnToItemList(taskId);
}
}
@ -1049,7 +1097,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
{
s16 *data = gTasks[taskId].data;
PutWindowTilemap(1);
PutWindowTilemap(WIN_ITEM_LIST);
if (sMartInfo.martType == MART_TYPE_NORMAL)
{
@ -1084,16 +1132,12 @@ static void BuyMenuSubtractMoney(u8 taskId)
IncrementGameStat(GAME_STAT_SHOPPED);
RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost);
PlaySE(SE_SHOP);
PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0);
PrintMoneyAmountInMoneyBox(WIN_MONEY, GetMoney(&gSaveBlock1Ptr->money), 0);
if (sMartInfo.martType == MART_TYPE_NORMAL)
{
gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase;
}
else
{
gTasks[taskId].func = Task_ReturnToItemListAfterDecorationPurchase;
}
}
static void Task_ReturnToItemListAfterItemPurchase(u8 taskId)
@ -1103,14 +1147,12 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId)
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
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);
}
else
{
BuyMenuReturnToItemList(taskId);
}
}
}
@ -1127,10 +1169,10 @@ static void BuyMenuReturnToItemList(u8 taskId)
{
s16 *data = gTasks[taskId].data;
ClearDialogWindowAndFrameToTransparent(5, FALSE);
BuyMenuPrintCursor(tListTaskId, 1);
PutWindowTilemap(1);
PutWindowTilemap(2);
ClearDialogWindowAndFrameToTransparent(WIN_MESSAGE, FALSE);
BuyMenuPrintCursor(tListTaskId, COLORID_ITEM_LIST);
PutWindowTilemap(WIN_ITEM_LIST);
PutWindowTilemap(WIN_ITEM_DESCRIPTION);
ScheduleBgCopyTilemapToVram(0);
BuyMenuAddScrollIndicatorArrows();
gTasks[taskId].func = Task_BuyMenu;
@ -1140,11 +1182,11 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
{
s16 *data = gTasks[taskId].data;
FillWindowPixelBuffer(4, PIXEL_FILL(1));
PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW);
FillWindowPixelBuffer(WIN_QUANTITY_PRICE, PIXEL_FILL(1));
PrintMoneyAmount(WIN_QUANTITY_PRICE, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
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)
@ -1200,6 +1242,8 @@ static void RecordItemPurchase(u8 taskId)
#undef tItemCount
#undef tItemId
#undef tListTaskId
#undef tCallbackHi
#undef tCallbackLo
void CreatePokemartMenu(const u16 *itemsForSale)
{

View File

@ -6433,6 +6433,20 @@ static const struct SpriteTemplate sSpriteTemplate_PikaPowerBolt =
.callback = SpriteCB_PikaPowerBolt
};
/*
[0 ][1 ]
[ ][ ]
[ ][ ]
[ ][ ]
[ ][ ]
[______________][______________] 128x128
[ ]+ <- Origin ]
[ ][ ]
[ ][ ]
[ ][ ]
[ ][ ]
[2 ][3 ]
*/
static const struct Subsprite sSubsprites_ReelBackground[] =
{
{
@ -6474,6 +6488,11 @@ static const struct SubspriteTable sSubspriteTable_ReelBackground[] =
ARRAY_COUNT(sSubsprites_ReelBackground), sSubsprites_ReelBackground
};
/* v-- Origin on 3
[0_____][1_____]
[2_____][3_____] 64x24
[4 ][5 ]
*/
static const struct Subsprite sSubsprites_ReelTimeMachineAntennae[] =
{
{
@ -6531,6 +6550,13 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeMachineAntennae[] =
ARRAY_COUNT(sSubsprites_ReelTimeMachineAntennae), sSubsprites_ReelTimeMachineAntennae
};
/*
[0 ]
[ ]
[ + Origin]
[______________] 64x40
[1 ][2 ]
*/
static const struct Subsprite sSubsprites_ReelTimeMachine[] =
{
{
@ -6564,6 +6590,14 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeMachine[] =
ARRAY_COUNT(sSubsprites_ReelTimeMachine), sSubsprites_ReelTimeMachine
};
/*
[0 ]
[ ]
[ + Origin]
[______________] 64x48
[1 ][2 ]
[3 ][4 ]
*/
static const struct Subsprite sSubsprites_BrokenReelTimeMachine[] =
{
{
@ -6613,6 +6647,10 @@ static const struct SubspriteTable sSubspriteTable_BrokenReelTimeMachine[] =
ARRAY_COUNT(sSubsprites_BrokenReelTimeMachine), sSubsprites_BrokenReelTimeMachine
};
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
static const struct Subsprite sSubsprites_ReelTimeShadow[] =
{
{
@ -6654,6 +6692,11 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeShadow[] =
ARRAY_COUNT(sSubsprites_ReelTimeShadow), sSubsprites_ReelTimeShadow
};
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
static const struct Subsprite sSubsprites_ReelTimeNumberGap[] =
{
{
@ -6687,6 +6730,14 @@ static const struct SubspriteTable sSubspriteTable_ReelTimeNumberGap[] =
ARRAY_COUNT(sSubsprites_ReelTimeNumberGap), sSubsprites_ReelTimeNumberGap
};
/*
[0 ]
[ ]
[ + Origin]
[______________] 64x48
[1 ][2 ]
[3 ][4 ]
*/
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
};
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
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
};
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
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
};
/* v-- Origin on 3
[0_____][1_____]
[2 ][3 ] 64x16
*/
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
};
/* v-- Origin on 3
[0_____][1_____]
[2_____][3_____]
[4 ][5 ] 64x24
*/
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
};
/*
[0_____][1_]
[2_____][3_]
[4_____][5_]
[6_____][7+] <-- Origin
[8_____][9_]
[10____][11]
*/
static const struct Subsprite sSubsprites_DigitalDisplay_Pokeball[] =
{
{
@ -6962,7 +7038,7 @@ static const struct Subsprite sSubsprites_DigitalDisplay_Pokeball[] =
},
{
.x = 8,
-24,
.y = -24,
.shape = SPRITE_SHAPE(16x8),
.size = SPRITE_SIZE(16x8),
.tileOffset = 4,
@ -7055,6 +7131,11 @@ static const struct SubspriteTable sSubspriteTable_DigitalDisplay_Pokeball[] =
ARRAY_COUNT(sSubsprites_DigitalDisplay_Pokeball), sSubsprites_DigitalDisplay_Pokeball
};
/*
[0 ] 32x24
[ + ] <- Origin
[1 ][2 ]
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[]<-0 16x16
[]<-1 <- Origin
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[]<-0 16x16
[]<-1 <- Origin
*/
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
};
/*
[0 ] 16x16
[1+] <- Origin
*/
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
};
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
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
};
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
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
};
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
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
};
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
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
};
/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
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
};
/*
[0_][] <-1
[2_][] <-3
[4_][] <-5
^-- Origin on 3
*/
static const struct Subsprite sSubsprites_DigitalDisplay_RegG[] =
{
{

View File

@ -1264,7 +1264,7 @@ static void Task_SaveAfterLinkBattle(u8 taskId)
}
else
{
gSoftResetDisabled = 1;
gSoftResetDisabled = TRUE;
*state = 1;
}
break;
@ -1278,7 +1278,7 @@ static void Task_SaveAfterLinkBattle(u8 taskId)
{
ClearContinueGameWarpStatus2();
*state = 3;
gSoftResetDisabled = 0;
gSoftResetDisabled = FALSE;
}
break;
case 3:

View File

@ -351,7 +351,7 @@ static void InitTradeMenu(void)
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(2, 1, 0xE0);
LoadMonIconPalettes();
@ -2064,13 +2064,13 @@ static void RedrawTradeMenuParty(u8 whichParty)
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);
}
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);
}

View File

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

View File

@ -129,7 +129,7 @@ void CB2_UnionRoomBattle(void)
ClearWindowTilemap(0);
FillWindowPixelBuffer(0, PIXEL_FILL(0));
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);
Menu_LoadStdPal();

View File

@ -481,7 +481,7 @@ static bool8 DoMassOutbreakEncounterTest(void)
return FALSE;
}
static bool8 DoWildEncounterRateDiceRoll(u16 encounterRate)
static bool8 EncounterOddsCheck(u16 encounterRate)
{
if (Random() % MAX_ENCOUNTER_RATE < encounterRate)
return TRUE;
@ -489,7 +489,8 @@ static bool8 DoWildEncounterRateDiceRoll(u16 encounterRate)
return FALSE;
}
static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
// Returns true if it will try to create a wild encounter.
static bool8 WildEncounterCheck(u32 encounterRate, bool8 ignoreAbility)
{
encounterRate *= 16;
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
@ -515,10 +516,12 @@ static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
}
if (encounterRate > MAX_ENCOUNTER_RATE)
encounterRate = MAX_ENCOUNTER_RATE;
return DoWildEncounterRateDiceRoll(encounterRate);
return EncounterOddsCheck(encounterRate);
}
static bool8 DoGlobalWildEncounterDiceRoll(void)
// When you first step on a different type of metatile, there's a 40% chance it
// skips the wild encounter check entirely.
static bool8 AllowWildCheckOnNewMetatile(void)
{
if (Random() % 100 >= 60)
return FALSE;
@ -537,7 +540,7 @@ static bool8 AreLegendariesInSootopolisPreventingEncounters(void)
return FlagGet(FLAG_LEGENDARIES_IN_SOOTOPOLIS);
}
bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavior)
bool8 StandardWildEncounter(u16 curMetatileBehavior, u16 prevMetatileBehavior)
{
u16 headerId;
struct Roamer *roamer;
@ -551,9 +554,9 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PIKE_ROOM_WILD_MONS)
{
headerId = GetBattlePikeWildMonHeaderId();
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
if (prevMetatileBehavior != curMetatileBehavior && !AllowWildCheckOnNewMetatile())
return FALSE;
else if (DoWildEncounterRateTest(gBattlePikeWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
else if (WildEncounterCheck(gBattlePikeWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
return FALSE;
else if (TryGenerateWildMon(gBattlePikeWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE)
return FALSE;
@ -566,9 +569,9 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_FLOOR)
{
headerId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
if (prevMetatileBehavior != curMetatileBehavior && !AllowWildCheckOnNewMetatile())
return FALSE;
else if (DoWildEncounterRateTest(gBattlePyramidWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
else if (WildEncounterCheck(gBattlePyramidWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
return FALSE;
else if (TryGenerateWildMon(gBattlePyramidWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE)
return FALSE;
@ -580,13 +583,13 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
}
else
{
if (MetatileBehavior_IsLandWildEncounter(currMetaTileBehavior) == TRUE)
if (MetatileBehavior_IsLandWildEncounter(curMetatileBehavior) == TRUE)
{
if (gWildMonHeaders[headerId].landMonsInfo == NULL)
return FALSE;
else if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
else if (prevMetatileBehavior != curMetatileBehavior && !AllowWildCheckOnNewMetatile())
return FALSE;
else if (DoWildEncounterRateTest(gWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
else if (WildEncounterCheck(gWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
return FALSE;
if (TryStartRoamerEncounter() == TRUE)
@ -616,16 +619,16 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
return FALSE;
}
}
else if (MetatileBehavior_IsWaterWildEncounter(currMetaTileBehavior) == TRUE
|| (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING) && MetatileBehavior_IsBridgeOverWater(currMetaTileBehavior) == TRUE))
else if (MetatileBehavior_IsWaterWildEncounter(curMetatileBehavior) == TRUE
|| (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING) && MetatileBehavior_IsBridgeOverWater(curMetatileBehavior) == TRUE))
{
if (AreLegendariesInSootopolisPreventingEncounters() == TRUE)
return FALSE;
else if (gWildMonHeaders[headerId].waterMonsInfo == NULL)
return FALSE;
else if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
else if (prevMetatileBehavior != curMetatileBehavior && !AllowWildCheckOnNewMetatile())
return FALSE;
else if (DoWildEncounterRateTest(gWildMonHeaders[headerId].waterMonsInfo->encounterRate, FALSE) != TRUE)
else if (WildEncounterCheck(gWildMonHeaders[headerId].waterMonsInfo->encounterRate, FALSE) != TRUE)
return FALSE;
if (TryStartRoamerEncounter() == TRUE)
@ -665,7 +668,7 @@ void RockSmashWildEncounter(void)
{
gSpecialVar_Result = FALSE;
}
else if (DoWildEncounterRateTest(wildPokemonInfo->encounterRate, TRUE) == TRUE
else if (WildEncounterCheck(wildPokemonInfo->encounterRate, TRUE) == TRUE
&& TryGenerateWildMon(wildPokemonInfo, WILD_AREA_ROCKS, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
{
BattleSetup_StartWildBattle();