Merge branch 'master' of https://github.com/pret/pokeemerald into constants-num-frames

This commit is contained in:
GriffinR
2023-02-01 15:59:02 -05:00
890 changed files with 40310 additions and 37715 deletions

View File

@@ -256,7 +256,7 @@ enum {
// The maximum number of Pokémon icons that can appear on-screen.
// By default the limit is 40 (though in practice only 37 can be).
#define MAX_MON_ICONS (IN_BOX_COUNT + PARTY_SIZE + 1 >= 40 ? IN_BOX_COUNT + PARTY_SIZE + 1 : 40)
#define MAX_MON_ICONS max(IN_BOX_COUNT + PARTY_SIZE + 1, 40)
// The maximum number of item icons that can appear on-screen while
// moving held items. 1 in the cursor, and 2 more while switching
@@ -945,26 +945,26 @@ static const union AffineAnimCmd *const sAffineAnims_ChooseBoxMenu[] =
static const u8 sChooseBoxMenu_TextColors[] = {TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5};
static const u8 sText_OutOf30[] = _("/30");
static const u16 sChooseBoxMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/box_selection_popup.gbapal");
static const u8 sChooseBoxMenuCenter_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp");
static const u8 sChooseBoxMenuSides_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp");
static const u32 sScrollingBg_Gfx[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz");
static const u32 sScrollingBg_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz");
static const u16 sDisplayMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/display_menu.gbapal"); // Unused
static const u32 sDisplayMenu_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/display_menu.bin.lz");
static const u16 sPkmnData_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/pkmn_data.bin");
static const u16 sChooseBoxMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/box_selection_popup.gbapal");
static const u8 sChooseBoxMenuCenter_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp");
static const u8 sChooseBoxMenuSides_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp");
static const u32 sScrollingBg_Gfx[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz");
static const u32 sScrollingBg_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz");
static const u16 sDisplayMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/display_menu.gbapal"); // Unused
static const u32 sDisplayMenu_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/display_menu.bin.lz");
static const u16 sPkmnData_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/pkmn_data.bin");
// sInterface_Pal - parts of the display frame, "PkmnData"'s normal color, Close Box
static const u16 sInterface_Pal[] = INCBIN_U16("graphics/pokemon_storage/interface.gbapal");
static const u16 sPkmnDataGray_Pal[] = INCBIN_U16("graphics/pokemon_storage/pkmn_data_gray.gbapal");
static const u16 sBg_Pal[] = INCBIN_U16("graphics/pokemon_storage/bg.gbapal");
static const u16 sBgMoveItems_Pal[] = INCBIN_U16("graphics/pokemon_storage/bg_move_items.gbapal");
static const u16 sCloseBoxButton_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/close_box_button.bin");
static const u16 sPartySlotFilled_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/party_slot_filled.bin");
static const u16 sPartySlotEmpty_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/party_slot_empty.bin");
static const u16 sWaveform_Pal[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal");
static const u32 sWaveform_Gfx[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp");
static const u16 sUnused_Pal[] = INCBIN_U16("graphics/pokemon_storage/unused.gbapal");
static const u16 sTextWindows_Pal[] = INCBIN_U16("graphics/pokemon_storage/text_windows.gbapal");
static const u16 sInterface_Pal[] = INCBIN_U16("graphics/pokemon_storage/interface.gbapal");
static const u16 sPkmnDataGray_Pal[] = INCBIN_U16("graphics/pokemon_storage/pkmn_data_gray.gbapal");
static const u16 sScrollingBg_Pal[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.gbapal");
static const u16 sScrollingBgMoveItems_Pal[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg_move_items.gbapal");
static const u16 sCloseBoxButton_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/close_box_button.bin");
static const u16 sPartySlotFilled_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/party_slot_filled.bin");
static const u16 sPartySlotEmpty_Tilemap[] = INCBIN_U16("graphics/pokemon_storage/party_slot_empty.bin");
static const u16 sWaveform_Pal[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal");
static const u32 sWaveform_Gfx[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp");
static const u16 sUnused_Pal[] = INCBIN_U16("graphics/pokemon_storage/unused.gbapal");
static const u16 sTextWindows_Pal[] = INCBIN_U16("graphics/pokemon_storage/text_windows.gbapal");
static const struct WindowTemplate sWindowTemplates[] =
{
@@ -1240,7 +1240,7 @@ static const union AffineAnimCmd *const sAffineAnims_ReleaseMon[] =
static const u16 sUnusedColor = RGB(26, 29, 8);
static const struct SpriteSheet sSpriteSheet_Arrow = {sArrow_Gfx, 0x80, GFXTAG_ARROW};
static const struct SpriteSheet sSpriteSheet_Arrow = {sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW};
static const struct OamData sOamData_BoxTitle =
{
@@ -1763,6 +1763,8 @@ void ResetPokemonStorageSystem(void)
static void LoadChooseBoxMenuGfx(struct ChooseBoxMenu *menu, u16 tileTag, u16 palTag, u8 subpriority, bool32 loadPal)
{
// Because loadPal is always false, the below palette is never used.
// The Choose Box menu instead uses the palette indicated by palTag, which is always PALTAG_MISC_1 (sHandCursor_Pal)
struct SpritePalette palette =
{
sChooseBoxMenu_Pal, palTag
@@ -2127,7 +2129,7 @@ static void Task_InitPokeStorage(u8 taskId)
PutWindowTilemap(WIN_DISPLAY_INFO);
ClearWindowTilemap(WIN_MESSAGE);
CpuFill32(0, (void *)VRAM, 0x200);
LoadUserWindowBorderGfx(WIN_MESSAGE, 0xB, 0xE0);
LoadUserWindowBorderGfx(WIN_MESSAGE, 0xB, BG_PLTT_ID(14));
break;
case 3:
ResetAllBgCoords();
@@ -3848,13 +3850,13 @@ static void LoadWaveformSpritePalette(void)
static void InitPalettesAndSprites(void)
{
LoadPalette(sInterface_Pal, 0, sizeof(sInterface_Pal));
LoadPalette(sPkmnDataGray_Pal, 0x20, sizeof(sPkmnDataGray_Pal));
LoadPalette(sTextWindows_Pal, 0xF0, sizeof(sTextWindows_Pal));
LoadPalette(sInterface_Pal, BG_PLTT_ID(0), sizeof(sInterface_Pal));
LoadPalette(sPkmnDataGray_Pal, BG_PLTT_ID(2), sizeof(sPkmnDataGray_Pal));
LoadPalette(sTextWindows_Pal, BG_PLTT_ID(15), sizeof(sTextWindows_Pal));
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
LoadPalette(sBg_Pal, 0x30, sizeof(sBg_Pal));
LoadPalette(sScrollingBg_Pal, BG_PLTT_ID(3), sizeof(sScrollingBg_Pal));
else
LoadPalette(sBgMoveItems_Pal, 0x30, sizeof(sBgMoveItems_Pal));
LoadPalette(sScrollingBgMoveItems_Pal, BG_PLTT_ID(3), sizeof(sScrollingBgMoveItems_Pal));
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(30));
CreateDisplayMonSprite();
@@ -3957,7 +3959,7 @@ static void CreateDisplayMonSprite(void)
break;
sStorage->displayMonSprite = &gSprites[spriteId];
sStorage->displayMonPalOffset = palSlot * 16 + 0x100;
sStorage->displayMonPalOffset = OBJ_PLTT_ID(palSlot);
sStorage->displayMonTilePtr = (void *) OBJ_VRAM0 + tileStart * TILE_SIZE_4BPP;
} while (0);
@@ -3978,7 +3980,7 @@ static void LoadDisplayMonGfx(u16 species, u32 pid)
LoadSpecialPokePic(&gMonFrontPicTable[species], sStorage->tileBuffer, species, pid, TRUE);
LZ77UnCompWram(sStorage->displayMonPalette, sStorage->displayMonPalBuffer);
CpuCopy32(sStorage->tileBuffer, sStorage->displayMonTilePtr, MON_PIC_SIZE);
LoadPalette(sStorage->displayMonPalBuffer, sStorage->displayMonPalOffset, 0x20);
LoadPalette(sStorage->displayMonPalBuffer, sStorage->displayMonPalOffset, PLTT_SIZE_4BPP);
sStorage->displayMonSprite->invisible = FALSE;
}
else
@@ -4044,7 +4046,7 @@ static void UpdateWaveformAnimation(void)
static void InitSupplementalTilemaps(void)
{
LZ77UnCompWram(gStorageSystemPartyMenu_Tilemap, sStorage->partyMenuTilemapBuffer);
LoadPalette(gStorageSystemPartyMenu_Pal, 0x10, 0x20);
LoadPalette(gStorageSystemPartyMenu_Pal, BG_PLTT_ID(1), PLTT_SIZE_4BPP);
TilemapUtil_SetMap(TILEMAPID_PARTY_MENU, 1, sStorage->partyMenuTilemapBuffer, 12, 22);
TilemapUtil_SetMap(TILEMAPID_CLOSE_BUTTON, 1, sCloseBoxButton_Tilemap, 9, 4);
TilemapUtil_SetPos(TILEMAPID_PARTY_MENU, 10, 0);
@@ -4266,7 +4268,7 @@ static void UpdateBoxToSendMons(void)
static void InitPokeStorageBg0(void)
{
SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29));
LoadUserWindowBorderGfx(WIN_MESSAGE, 2, 208);
LoadUserWindowBorderGfx(WIN_MESSAGE, 2, BG_PLTT_ID(13));
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 20, 17);
CopyBgTilemapBufferToVram(0);
}
@@ -5379,9 +5381,9 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction)
DrawWallpaper(sStorage->wallpaperTilemap, sStorage->wallpaperLoadDir, sStorage->wallpaperOffset);
if (sStorage->wallpaperLoadDir != 0)
LoadPalette(wallpaper->palettes, (sStorage->wallpaperOffset * 32) + 0x40, 0x40);
LoadPalette(wallpaper->palettes, BG_PLTT_ID(4) + BG_PLTT_ID(sStorage->wallpaperOffset * 2), 2 * PLTT_SIZE_4BPP);
else
CpuCopy16(wallpaper->palettes, &gPlttBufferUnfaded[(sStorage->wallpaperOffset * 32) + 0x40], 0x40);
CpuCopy16(wallpaper->palettes, &gPlttBufferUnfaded[BG_PLTT_ID(4) + BG_PLTT_ID(sStorage->wallpaperOffset * 2)], 2 * PLTT_SIZE_4BPP);
sStorage->wallpaperTiles = malloc_and_decompress(wallpaper->tiles, &tilesSize);
LoadBgTiles(2, sStorage->wallpaperTiles, tilesSize, sStorage->wallpaperOffset << 8);
@@ -5397,9 +5399,9 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction)
CpuCopy16(GetWaldaWallpaperColorsPtr(), &sStorage->wallpaperTilemap[17], 4);
if (sStorage->wallpaperLoadDir != 0)
LoadPalette(sStorage->wallpaperTilemap, (sStorage->wallpaperOffset * 32) + 0x40, 0x40);
LoadPalette(sStorage->wallpaperTilemap, BG_PLTT_ID(4) + BG_PLTT_ID(sStorage->wallpaperOffset * 2), 2 * PLTT_SIZE_4BPP);
else
CpuCopy16(sStorage->wallpaperTilemap, &gPlttBufferUnfaded[(sStorage->wallpaperOffset * 32) + 0x40], 0x40);
CpuCopy16(sStorage->wallpaperTilemap, &gPlttBufferUnfaded[BG_PLTT_ID(4) + BG_PLTT_ID(sStorage->wallpaperOffset * 2)], 2 * PLTT_SIZE_4BPP);
sStorage->wallpaperTiles = malloc_and_decompress(wallpaper->tiles, &tilesSize);
iconGfx = malloc_and_decompress(sWaldaWallpaperIcons[GetWaldaWallpaperIconId()], &iconSize);
@@ -5436,7 +5438,7 @@ static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset)
else
x -= 4;
FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11);
FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 17);
}
static void TrimOldWallpaper(void *tilemap)
@@ -5487,7 +5489,7 @@ static void InitBoxTitle(u8 boxId)
sStorage->wallpaperPalBits = 0x3f0;
tagIndex = IndexOfSpritePaletteTag(PALTAG_BOX_TITLE);
sStorage->boxTitlePalOffset = 0x10e + 16 * tagIndex;
sStorage->boxTitlePalOffset = OBJ_PLTT_ID(tagIndex) + 14;
sStorage->wallpaperPalBits |= 0x10000 << tagIndex;
// The below seems intended to have separately tracked
@@ -5495,7 +5497,7 @@ static void InitBoxTitle(u8 boxId)
// share a palette tag, all colors (and fields in some cases)
// this is redundant along with the use of boxTitleAltPalOffset
tagIndex = IndexOfSpritePaletteTag(PALTAG_BOX_TITLE);
sStorage->boxTitleAltPalOffset = 0x10e + 16 * tagIndex;
sStorage->boxTitleAltPalOffset = OBJ_PLTT_ID(tagIndex) + 14;
sStorage->wallpaperPalBits |= 0x10000 << tagIndex;
StringCopyPadded(sStorage->boxTitleText, GetBoxNamePtr(boxId), 0, BOX_NAME_LENGTH);
@@ -8163,7 +8165,7 @@ static bool8 MultiMove_Start(void)
{
case 0:
HideBg(0);
TryLoadAllMonIconPalettesAtOffset(0x80);
TryLoadAllMonIconPalettesAtOffset(BG_PLTT_ID(8));
sMultiMove->state++;
break;
case 1:
@@ -8212,7 +8214,7 @@ static bool8 MultiMove_Cancel(void)
if (!IsDma3ManagerBusyWithBgCopy())
{
SetCursorPriorityTo1();
LoadPalette(GetTextWindowPalette(3), 0xD0, 0x20);
LoadPalette(GetTextWindowPalette(3), BG_PLTT_ID(13), PLTT_SIZE_4BPP);
ShowBg(0);
return FALSE;
}
@@ -8318,7 +8320,7 @@ static bool8 MultiMove_PlaceMons(void)
case 3:
if (!IsDma3ManagerBusyWithBgCopy())
{
LoadPalette(GetTextWindowPalette(3), 0xD0, 0x20);
LoadPalette(GetTextWindowPalette(3), BG_PLTT_ID(13), PLTT_SIZE_4BPP);
SetCursorPriorityTo1();
ShowBg(0);
return FALSE;
@@ -8825,12 +8827,12 @@ static void TakeItemFromMon(u8 cursorArea, u8 cursorPos)
if (cursorArea == CURSOR_AREA_IN_BOX)
{
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId);
SetBoxMonIconObjMode(cursorPos, 1);
SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
}
else
{
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId);
SetPartyMonIconObjMode(cursorPos, 1);
SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
}
sStorage->movingItemId = sStorage->displayMonItemId;
@@ -8891,12 +8893,12 @@ static void GiveItemToMon(u8 cursorArea, u8 cursorPos)
if (cursorArea == CURSOR_AREA_IN_BOX)
{
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId);
SetBoxMonIconObjMode(cursorPos, 0);
SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL);
}
else
{
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId);
SetPartyMonIconObjMode(cursorPos, 0);
SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL);
}
}
@@ -8915,12 +8917,12 @@ static void MoveItemFromMonToBag(u8 cursorArea, u8 cursorPos)
if (cursorArea == CURSOR_AREA_IN_BOX)
{
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId);
SetBoxMonIconObjMode(cursorPos, 1);
SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
}
else
{
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId);
SetPartyMonIconObjMode(cursorPos, 1);
SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
}
}
@@ -9102,7 +9104,7 @@ static void LoadItemIconGfx(u8 id, const u32 *itemTiles, const u32 *itemPal)
CpuFastCopy(sStorage->itemIconBuffer, sStorage->itemIcons[id].tiles, 0x200);
LZ77UnCompWram(itemPal, sStorage->itemIconBuffer);
LoadPalette(sStorage->itemIconBuffer, sStorage->itemIcons[id].palIndex, 0x20);
LoadPalette(sStorage->itemIconBuffer, sStorage->itemIcons[id].palIndex, PLTT_SIZE_4BPP);
}
static void SetItemIconAffineAnim(u8 id, u8 animNum)
@@ -9235,7 +9237,7 @@ static bool8 UpdateItemInfoWindowSlideOut(void)
if (pos >= 0)
DrawItemInfoWindow(pos);
FillBgTilemapBufferRect(0, 0, pos + 1, 12, 1, 9, 0x11);
FillBgTilemapBufferRect(0, 0, pos + 1, 12, 1, 9, 17);
ScheduleBgCopyTilemapToVram(0);
return TRUE;
}
@@ -9244,12 +9246,12 @@ static void DrawItemInfoWindow(u32 x)
{
if (x != 0)
{
FillBgTilemapBufferRect(0, 0x13A, 0, 0xC, x, 1, 0xFu);
FillBgTilemapBufferRect(0, 0x93A, 0, 0x14, x, 1, 0xFu);
FillBgTilemapBufferRect(0, 0x13A, 0, 0xC, x, 1, 15);
FillBgTilemapBufferRect(0, 0x93A, 0, 0x14, x, 1, 15);
}
FillBgTilemapBufferRect(0, 0x13B, x, 0xD, 1, 7, 0xFu);
FillBgTilemapBufferRect(0, 0x13C, x, 0xC, 1, 1, 0xFu);
FillBgTilemapBufferRect(0, 0x13D, x, 0x14, 1, 1, 0xFu);
FillBgTilemapBufferRect(0, 0x13B, x, 0xD, 1, 7, 15);
FillBgTilemapBufferRect(0, 0x13C, x, 0xC, 1, 1, 15);
FillBgTilemapBufferRect(0, 0x13D, x, 0x14, 1, 1, 15);
ScheduleBgCopyTilemapToVram(0);
}