From c18abe0b00a88b11d0d624aa2f496c447e3acfb5 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sat, 31 May 2025 01:43:49 +0200 Subject: [PATCH] replace LZ77UnCompWram -> DecompressDataWithHeaderWram --- include/menu.h | 1 - include/mystery_gift.h | 6 ++-- src/battle_gfx_sfx_util.c | 2 +- src/berry_crush.c | 2 +- src/bg.c | 3 +- src/dodrio_berry_picking.c | 11 ++++---- src/fieldmap.c | 2 +- src/intro.c | 6 ++-- src/menu.c | 38 ++++---------------------- src/mystery_gift_show_card.c | 22 +++++++-------- src/mystery_gift_show_news.c | 23 ++++++++-------- src/naming_screen.c | 3 +- src/pokemon_storage_system.c | 8 +++--- src/pokemon_summary_screen.c | 14 +++++----- src/region_map.c | 53 ++++++++++++++++++------------------ src/trainer_card.c | 25 +++++++++-------- src/window.c | 3 +- 17 files changed, 100 insertions(+), 122 deletions(-) diff --git a/include/menu.h b/include/menu.h index aee989513..3fc8f0ca4 100644 --- a/include/menu.h +++ b/include/menu.h @@ -105,7 +105,6 @@ void DisplayYesNoMenuDefaultYes(void); void InitStandardTextBoxWindows(void); void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); void InitTextBoxGfxAndPrinters(void); -void *DecompressAndCopyTileDataToVram2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); void LoadMessageBoxAndFrameGfx(u8 windowId, bool8 copyToVram); void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram); void ResetBgPositions(void); diff --git a/include/mystery_gift.h b/include/mystery_gift.h index c6f4210e2..bb53087af 100644 --- a/include/mystery_gift.h +++ b/include/mystery_gift.h @@ -43,9 +43,9 @@ struct WonderGraphics u8 bodyTextPal:4; u8 footerTextPal:4; u8 stampShadowPal:4; - const u8 * tiles; - const u8 * map; - const u16 * pal; + const u32 *tiles; + const u32 *map; + const u16 *pal; }; extern const u16 gCard1Pal[]; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 0e25e0593..8d0aca020 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -488,7 +488,7 @@ void DecompressGhostFrontPic(struct Pokemon *unused, u8 battlerId) u16 palOffset; u8 position = GetBattlerPosition(battlerId); - LZ77UnCompWram(gGhostFrontPic, gMonSpritesGfxPtr->spritesGfx[position]); + DecompressDataWithHeaderWram(gGhostFrontPic, gMonSpritesGfxPtr->spritesGfx[position]); palOffset = OBJ_PLTT_ID(battlerId); LoadPalette(gGhostPalette, palOffset, PLTT_SIZE_4BPP); LoadPalette(gGhostPalette, BG_PLTT_ID(8) + BG_PLTT_ID(battlerId), PLTT_SIZE_4BPP); diff --git a/src/berry_crush.c b/src/berry_crush.c index 24f4f7a7e..4b3e5e1aa 100644 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -3270,7 +3270,7 @@ static void CopyPlayerNameWindowGfxToBg(struct BerryCrushGame * game) u8 i = 0; u8 *crusherGfx; - LZ77UnCompWram(gBerryCrush_TextWindows_Tilemap, gDecompressionBuffer); + DecompressDataWithHeaderWram(gBerryCrush_TextWindows_Tilemap, gDecompressionBuffer); for (crusherGfx = gDecompressionBuffer; i < game->playerCount; ++i) { CopyToBgTilemapBufferRect( diff --git a/src/bg.c b/src/bg.c index db8d5e036..00034cb19 100644 --- a/src/bg.c +++ b/src/bg.c @@ -1,6 +1,7 @@ #include #include "global.h" #include "bg.h" +#include "decompress.h" #include "dma3.h" #include "gpu_regs.h" @@ -910,7 +911,7 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) } else { - LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 32))); + DecompressDataWithHeaderWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 32))); } } } diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 48b137e53..0cdea4d22 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -1,10 +1,9 @@ #include "global.h" - #include "bg.h" #include "gpu_regs.h" #include "malloc.h" #include "string_util.h" - +#include "decompress.h" #include "dodrio_berry_picking.h" #include "dynamic_placeholder_text_util.h" #include "event_data.h" @@ -3520,7 +3519,7 @@ static void LoadDodrioGfx(void) struct SpritePalette normal = {sDodrioNormal_Pal, PALTAG_DODRIO_NORMAL}; struct SpritePalette shiny = {sDodrioShiny_Pal, PALTAG_DODRIO_SHINY}; - LZ77UnCompWram(sDodrio_Gfx, ptr); + DecompressDataWithHeaderWram(sDodrio_Gfx, ptr); if (ptr) { struct SpriteSheet sheet = {ptr, 0x3000, GFXTAG_DODRIO}; @@ -3703,7 +3702,7 @@ static void CreateStatusBarSprites(void) void *ptr = AllocZeroed(0x180); struct SpritePalette pal = {sStatus_Pal, PALTAG_STATUS}; - LZ77UnCompWram(sStatus_Gfx, ptr); + DecompressDataWithHeaderWram(sStatus_Gfx, ptr); // This check should be one line up. if (ptr) { @@ -3844,7 +3843,7 @@ static void LoadBerryGfx(void) void *ptr = AllocZeroed(0x480); struct SpritePalette pal = {sBerries_Pal, PALTAG_BERRIES}; - LZ77UnCompWram(sBerries_Gfx, ptr); + DecompressDataWithHeaderWram(sBerries_Gfx, ptr); if (ptr) { struct SpriteSheet sheet = {ptr, 0x480, GFXTAG_BERRIES}; @@ -3986,7 +3985,7 @@ static void CreateCloudSprites(void) void *ptr = AllocZeroed(0x400); struct SpritePalette pal = {sCloud_Pal, PALTAG_CLOUD}; - LZ77UnCompWram(sCloud_Gfx, ptr); + DecompressDataWithHeaderWram(sCloud_Gfx, ptr); if (ptr) { struct SpriteSheet sheet = {ptr, 0x400, GFXTAG_CLOUD}; diff --git a/src/fieldmap.c b/src/fieldmap.c index 13d6d1b17..99bc0072f 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -827,7 +827,7 @@ static void CopyTilesetToVram(struct Tileset const *tileset, u16 numTiles, u16 o if (!tileset->isCompressed) LoadBgTiles(2, tileset->tiles, numTiles * 32, offset); else - DecompressAndCopyTileDataToVram2(2, tileset->tiles, numTiles * 32, offset, 0); + DecompressAndCopyTileDataToVram(2, tileset->tiles, numTiles * 32, offset, 0); } } diff --git a/src/intro.c b/src/intro.c index d3caa84f7..4871908d3 100644 --- a/src/intro.c +++ b/src/intro.c @@ -255,7 +255,7 @@ static const u16 sGameFreakBg_Pal[] = INCBIN_U16("graphics/intro/game_freak/bg static const u8 sGameFreakBg_Gfx[] = INCBIN_U8( "graphics/intro/game_freak/bg.4bpp.lz"); static const u8 sGameFreakBg_Map[] = INCBIN_U8( "graphics/intro/game_freak/bg.bin.lz"); static const u16 sGameFreakLogo_Pal[] = INCBIN_U16("graphics/intro/game_freak/logo.gbapal"); -static const u8 sGameFreakText_Gfx[] = INCBIN_U8( "graphics/intro/game_freak/game_freak.4bpp.lz"); +static const u32 sGameFreakText_Gfx[] = INCBIN_U32( "graphics/intro/game_freak/game_freak.4bpp.lz"); static const u32 sGameFreakLogo_Gfx[] = INCBIN_U32("graphics/intro/game_freak/logo.4bpp.lz"); static const u16 sStar_Pal[] = INCBIN_U16("graphics/intro/game_freak/star.gbapal"); static const u32 sStar_Gfx[] = INCBIN_U32("graphics/intro/game_freak/star.4bpp.lz"); @@ -1116,8 +1116,8 @@ static void IntroCB_Init(struct IntroSequenceData * this) { case 0: InitWindows(sWindowTemplates); - LZ77UnCompWram(sGameFreakText_Gfx, this->gameFreakTextGfx); - LZ77UnCompWram(sGameFreakLogo_Gfx, this->gameFreakLogoGfx); + DecompressDataWithHeaderWram(sGameFreakText_Gfx, this->gameFreakTextGfx); + DecompressDataWithHeaderWram(sGameFreakLogo_Gfx, this->gameFreakLogoGfx); FillBgTilemapBufferRect(BG_GF_TEXT_LOGO, 0x000, 0, 0, 32, 32, 17); FillWindowPixelBuffer(WIN_GF_TEXT_LOGO, PIXEL_FILL(0)); BlitBitmapToWindow(WIN_GF_TEXT_LOGO, this->gameFreakTextGfx, 0, 40, 144, 16); diff --git a/src/menu.c b/src/menu.c index 35f2550b4..f3f792c7b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,4 +1,5 @@ #include "global.h" +#include "decompress.h" #include "gflib.h" #include "field_specials.h" #include "field_weather.h" @@ -1062,25 +1063,6 @@ void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 of return NULL; } -void *DecompressAndCopyTileDataToVram2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) -{ - u32 sizeOut; - - if (sTempTileDataBufferCursor < NELEMS(sTempTileDataBuffers)) - { - void *ptr = malloc_and_decompress(src, &sizeOut); - if (sizeOut > size) - sizeOut = size; - if (ptr) - { - CopyDecompressedTileDataToVram(bgId, ptr, sizeOut, offset, mode); - sTempTileDataBuffers[sTempTileDataBufferCursor++] = ptr; - } - return ptr; - } - return NULL; -} - void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; @@ -1122,23 +1104,15 @@ static void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId) void *malloc_and_decompress(const void *src, u32 *size) { - u32 sizeLocal; // If size is passed as NULL, because we don't care about knowing the size void *ptr; + u32 localSize = GetDecompressedDataSize(src); - if (size == NULL) - size = &sizeLocal; + if (size != NULL) + *size = localSize; - u8 *sizeAsBytes = (u8 *)size; - u8 *srcAsBytes = (u8 *)src; - - sizeAsBytes[0] = srcAsBytes[1]; - sizeAsBytes[1] = srcAsBytes[2]; - sizeAsBytes[2] = srcAsBytes[3]; - sizeAsBytes[3] = 0; - - ptr = Alloc(*size); + ptr = Alloc(localSize); if (ptr) - LZ77UnCompWram(src, ptr); + DecompressDataWithHeaderWram(src, ptr); return ptr; } diff --git a/src/mystery_gift_show_card.c b/src/mystery_gift_show_card.c index b7e57191b..3b5d820a2 100644 --- a/src/mystery_gift_show_card.c +++ b/src/mystery_gift_show_card.c @@ -101,16 +101,16 @@ const u16 gCard4Pal[] = INCBIN_U16("graphics/wonder_card/bg4.gbapal"); const u16 gCard5Pal[] = INCBIN_U16("graphics/wonder_card/bg5.gbapal"); static const u16 sCard6Pal[] = INCBIN_U16("graphics/wonder_card/bg6.gbapal"); static const u16 sCard7Pal[] = INCBIN_U16("graphics/wonder_card/bg7.gbapal"); -static const u8 sCard0Gfx[] = INCBIN_U8("graphics/wonder_card/bg0.4bpp.lz"); -static const u8 sCard0Map[] = INCBIN_U8("graphics/wonder_card/bg0.bin.lz"); -static const u8 sCard1Gfx[] = INCBIN_U8("graphics/wonder_card/bg1.4bpp.lz"); -static const u8 sCard1Map[] = INCBIN_U8("graphics/wonder_card/bg1.bin.lz"); -static const u8 sCard2Gfx[] = INCBIN_U8("graphics/wonder_card/bg2.4bpp.lz"); -static const u8 sCard2Map[] = INCBIN_U8("graphics/wonder_card/bg2.bin.lz"); -static const u8 sCard6Gfx[] = INCBIN_U8("graphics/wonder_card/bg6.4bpp.lz"); -static const u8 sCard6Map[] = INCBIN_U8("graphics/wonder_card/bg6.bin.lz"); -static const u8 sCard7Gfx[] = INCBIN_U8("graphics/wonder_card/bg7.4bpp.lz"); -static const u8 sCard7Map[] = INCBIN_U8("graphics/wonder_card/bg7.bin.lz"); +static const u32 sCard0Gfx[] = INCBIN_U32("graphics/wonder_card/bg0.4bpp.lz"); +static const u32 sCard0Map[] = INCBIN_U32("graphics/wonder_card/bg0.bin.lz"); +static const u32 sCard1Gfx[] = INCBIN_U32("graphics/wonder_card/bg1.4bpp.lz"); +static const u32 sCard1Map[] = INCBIN_U32("graphics/wonder_card/bg1.bin.lz"); +static const u32 sCard2Gfx[] = INCBIN_U32("graphics/wonder_card/bg2.4bpp.lz"); +static const u32 sCard2Map[] = INCBIN_U32("graphics/wonder_card/bg2.bin.lz"); +static const u32 sCard6Gfx[] = INCBIN_U32("graphics/wonder_card/bg6.4bpp.lz"); +static const u32 sCard6Map[] = INCBIN_U32("graphics/wonder_card/bg6.bin.lz"); +static const u32 sCard7Gfx[] = INCBIN_U32("graphics/wonder_card/bg7.4bpp.lz"); +static const u32 sCard7Map[] = INCBIN_U32("graphics/wonder_card/bg7.bin.lz"); static const u16 sStampShadowPal0[] = INCBIN_U16("graphics/wonder_card/stamp_shadow_0.gbapal"); static const u16 sStampShadowPal1[] = INCBIN_U16("graphics/wonder_card/stamp_shadow_1.gbapal"); static const u16 sStampShadowPal2[] = INCBIN_U16("graphics/wonder_card/stamp_shadow_2.gbapal"); @@ -215,7 +215,7 @@ s32 WonderCard_Enter(void) return 0; gPaletteFade.bufferTransferDisabled = TRUE; LoadPalette(sWonderCardData->gfx->pal, BG_PLTT_ID(1), PLTT_SIZE_4BPP); - LZ77UnCompWram(sWonderCardData->gfx->map, sWonderCardData->bgTilemapBuffer); + DecompressDataWithHeaderWram(sWonderCardData->gfx->map, sWonderCardData->bgTilemapBuffer); CopyRectToBgTilemapBufferRect(2, sWonderCardData->bgTilemapBuffer, 0, 0, 30, 20, 0, 0, 30, 20, 1, 0x008, 0); CopyBgTilemapBufferToVram(2); break; diff --git a/src/mystery_gift_show_news.c b/src/mystery_gift_show_news.c index 47d1ab6b5..ac2a2fc10 100644 --- a/src/mystery_gift_show_news.c +++ b/src/mystery_gift_show_news.c @@ -1,4 +1,5 @@ #include "global.h" +#include "decompress.h" #include "gflib.h" #include "menu_indicators.h" #include "mystery_gift.h" @@ -84,16 +85,16 @@ static const struct ScrollArrowsTemplate sArrowsTemplate = { static const u16 sNews0Pal[] = INCBIN_U16("graphics/wonder_news/bg0.gbapal"); static const u16 sNews6Pal[] = INCBIN_U16("graphics/wonder_news/bg6.gbapal"); static const u16 sNews7Pal[] = INCBIN_U16("graphics/wonder_news/bg7.gbapal"); -static const u8 sNews0Gfx[] = INCBIN_U8("graphics/wonder_news/bg0.4bpp.lz"); -static const u8 sNews0Map[] = INCBIN_U8("graphics/wonder_news/bg0.bin.lz"); -static const u8 sNews1Gfx[] = INCBIN_U8("graphics/wonder_news/bg1.4bpp.lz"); -static const u8 sNews1Map[] = INCBIN_U8("graphics/wonder_news/bg1.bin.lz"); -static const u8 sNews2Gfx[] = INCBIN_U8("graphics/wonder_news/bg2.4bpp.lz"); -static const u8 sNews2Map[] = INCBIN_U8("graphics/wonder_news/bg2.bin.lz"); -static const u8 sNews6Gfx[] = INCBIN_U8("graphics/wonder_news/bg6.4bpp.lz"); -static const u8 sNews6Map[] = INCBIN_U8("graphics/wonder_news/bg6.bin.lz"); -static const u8 sNews7Gfx[] = INCBIN_U8("graphics/wonder_news/bg7.4bpp.lz"); -static const u8 sNews7Map[] = INCBIN_U8("graphics/wonder_news/bg7.bin.lz"); +static const u32 sNews0Gfx[] = INCBIN_U32("graphics/wonder_news/bg0.4bpp.lz"); +static const u32 sNews0Map[] = INCBIN_U32("graphics/wonder_news/bg0.bin.lz"); +static const u32 sNews1Gfx[] = INCBIN_U32("graphics/wonder_news/bg1.4bpp.lz"); +static const u32 sNews1Map[] = INCBIN_U32("graphics/wonder_news/bg1.bin.lz"); +static const u32 sNews2Gfx[] = INCBIN_U32("graphics/wonder_news/bg2.4bpp.lz"); +static const u32 sNews2Map[] = INCBIN_U32("graphics/wonder_news/bg2.bin.lz"); +static const u32 sNews6Gfx[] = INCBIN_U32("graphics/wonder_news/bg6.4bpp.lz"); +static const u32 sNews6Map[] = INCBIN_U32("graphics/wonder_news/bg6.bin.lz"); +static const u32 sNews7Gfx[] = INCBIN_U32("graphics/wonder_news/bg7.4bpp.lz"); +static const u32 sNews7Map[] = INCBIN_U32("graphics/wonder_news/bg7.bin.lz"); static const struct WonderGraphics sNewsGraphics[NUM_WONDER_BGS] = { {.titleTextPal = 1, .bodyTextPal = 0, .tiles = sNews0Gfx, .map = sNews0Map, .pal = sNews0Pal}, @@ -171,7 +172,7 @@ s32 WonderNews_Enter(void) return 0; gPaletteFade.bufferTransferDisabled = TRUE; LoadPalette(sWonderNewsData->gfx->pal, BG_PLTT_ID(1), PLTT_SIZE_4BPP); - LZ77UnCompWram(sWonderNewsData->gfx->map, sWonderNewsData->bgTilemapBuffer); + DecompressDataWithHeaderWram(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); CopyBgTilemapBufferToVram(1); diff --git a/src/naming_screen.c b/src/naming_screen.c index 95cf0cdf9..2dabaa5d0 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1,4 +1,5 @@ #include "global.h" +#include "decompress.h" #include "gflib.h" #include "data.h" #include "keyboard_text.h" @@ -1872,7 +1873,7 @@ static void SaveInputText(void) static void LoadGfx(void) { - LZ77UnCompWram(gNamingScreenMenu_Gfx, sNamingScreen->tileBuffer); + DecompressDataWithHeaderWram(gNamingScreenMenu_Gfx, sNamingScreen->tileBuffer); LoadBgTiles(1, sNamingScreen->tileBuffer, sizeof(sNamingScreen->tileBuffer), 0); LoadBgTiles(2, sNamingScreen->tileBuffer, sizeof(sNamingScreen->tileBuffer), 0); LoadBgTiles(3, sNamingScreen->tileBuffer, sizeof(sNamingScreen->tileBuffer), 0); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index e6888f383..9ffafe99c 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3554,7 +3554,7 @@ static void LoadPokeStorageMenuGfx(void) { InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); DecompressAndLoadBgGfxUsingHeap(1, gPokeStorageMenu_Gfx, 0, 0, 0); - LZ77UnCompWram(sMenu_Tilemap, gStorage->menuTilemapBuffer); + DecompressDataWithHeaderWram(sMenu_Tilemap, gStorage->menuTilemapBuffer); SetBgTilemapBuffer(1, gStorage->menuTilemapBuffer); ShowBg(1); ScheduleBgCopyTilemapToVram(1); @@ -3762,7 +3762,7 @@ static void UpdateWaveformAnimation(void) static void InitSupplementalTilemaps(void) { - LZ77UnCompWram(gPokeStoragePartyMenu_Tilemap, gStorage->partyMenuTilemapBuffer); + DecompressDataWithHeaderWram(gPokeStoragePartyMenu_Tilemap, gStorage->partyMenuTilemapBuffer); LoadPalette(gPokeStoragePartyMenu_Pal, BG_PLTT_ID(1), PLTT_SIZE_4BPP); TilemapUtil_SetTilemap(TILEMAP_PARTY_MENU, 1, gStorage->partyMenuTilemapBuffer, 12, 22); TilemapUtil_SetTilemap(TILEMAP_CLOSE_BUTTON, 1, sCloseBoxButton_Tilemap, 9, 4); @@ -5151,7 +5151,7 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction) wallpaperId = GetBoxWallpaper(gStorage->wallpaperLoadBoxId); wallpaper = &sWallpapers[wallpaperId]; - LZ77UnCompWram(wallpaper->tileMap, gStorage->wallpaperTilemap); + DecompressDataWithHeaderWram(wallpaper->tileMap, gStorage->wallpaperTilemap); DrawWallpaper(gStorage->wallpaperBgTilemapBuffer, gStorage->wallpaperTilemap, gStorage->wallpaperLoadDir, gStorage->wallpaperOffset); if (gStorage->wallpaperLoadDir != 0) @@ -8656,7 +8656,7 @@ static void LoadItemIconGfx(u8 id, const u32 *itemTiles, const u16 *itemPal) return; CpuFastFill(0, gStorage->itemIconBuffer, 0x200); - LZ77UnCompWram(itemTiles, gStorage->tileBuffer); + DecompressDataWithHeaderWram(itemTiles, gStorage->tileBuffer); for (i = 0; i < 3; i++) CpuFastCopy(gStorage->tileBuffer + (i * 0x60), gStorage->itemIconBuffer + (i * 0x80), 0x60); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 93d86dae0..a2e23dd4b 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -4627,8 +4627,8 @@ static void CreateMoveSelectionCursorObjs(u16 tileTag, u16 palTag) sMoveSelectionCursorObjs[2] = AllocZeroed(sizeof(struct MoveSelectionCursor)); sMoveSelectionCursorObjs[3] = AllocZeroed(sizeof(struct MoveSelectionCursor)); - LZ77UnCompWram(sMoveSelectionCursorTiles_Left, gfxBufferPtrs[0]); - LZ77UnCompWram(sMoveSelectionCursorTiles_Right, gfxBufferPtrs[1]); + DecompressDataWithHeaderWram(sMoveSelectionCursorTiles_Left, gfxBufferPtrs[0]); + DecompressDataWithHeaderWram(sMoveSelectionCursorTiles_Right, gfxBufferPtrs[1]); for (i = 0; i < 4; i++) { @@ -4740,7 +4740,7 @@ static void CreateMonStatusIconObj(u16 tileTag, u16 palTag) sStatusIcon = AllocZeroed(sizeof(struct MonStatusIconObj)); gfxBufferPtr = AllocZeroed(0x20 * 32); - LZ77UnCompWram(gSummaryScreen_StatusAilmentIcon_Gfx, gfxBufferPtr); + DecompressDataWithHeaderWram(gSummaryScreen_StatusAilmentIcon_Gfx, gfxBufferPtr); if (sStatusIcon != NULL) { @@ -4832,7 +4832,7 @@ static void CreateHpBarObjs(u16 tileTag, u16 palTag) sHpBarObjs = AllocZeroed(sizeof(struct HpBarObjs)); gfxBufferPtr = AllocZeroed(0x20 * 12); - LZ77UnCompWram(gSummaryScreen_HpBar_Gfx, gfxBufferPtr); + DecompressDataWithHeaderWram(gSummaryScreen_HpBar_Gfx, gfxBufferPtr); curHp = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_HP); maxHp = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_MAX_HP); @@ -4990,7 +4990,7 @@ static void CreateExpBarObjs(u16 tileTag, u16 palTag) sExpBarObjs = AllocZeroed(sizeof(struct ExpBarObjs)); gfxBufferPtr = AllocZeroed(0x20 * 12); - LZ77UnCompWram(gSummaryScreen_ExpBar_Gfx, gfxBufferPtr); + DecompressDataWithHeaderWram(gSummaryScreen_ExpBar_Gfx, gfxBufferPtr); if (gfxBufferPtr != NULL) { struct SpriteSheet sheet = { @@ -5122,7 +5122,7 @@ static void CreatePokerusIconObj(u16 tileTag, u16 palTag) sPokerusIconObj = AllocZeroed(sizeof(struct PokerusIconObj)); gfxBufferPtr = AllocZeroed(0x20 * 1); - LZ77UnCompWram(sPokerusIconObjTiles, gfxBufferPtr); + DecompressDataWithHeaderWram(sPokerusIconObjTiles, gfxBufferPtr); if (sPokerusIconObj != NULL) { @@ -5207,7 +5207,7 @@ static void CreateShinyStarObj(u16 tileTag, u16 palTag) sShinyStarObjData = AllocZeroed(sizeof(struct ShinyStarObjData)); gfxBufferPtr = AllocZeroed(0x20 * 2); - LZ77UnCompWram(sStarObjTiles, gfxBufferPtr); + DecompressDataWithHeaderWram(sStarObjTiles, gfxBufferPtr); if (sShinyStarObjData != NULL) { diff --git a/src/region_map.c b/src/region_map.c index 101e8cf31..29fa14a07 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1,4 +1,5 @@ #include "global.h" +#include "decompress.h" #include "gflib.h" #include "scanline_effect.h" #include "task.h" @@ -1130,19 +1131,19 @@ static bool8 LoadRegionMapGfx(void) return FALSE; break; case 5: - LZ77UnCompWram(sKanto_Tilemap, sRegionMap->layouts[REGIONMAP_KANTO]); + DecompressDataWithHeaderWram(sKanto_Tilemap, sRegionMap->layouts[REGIONMAP_KANTO]); break; case 6: - LZ77UnCompWram(sSevii123_Tilemap, sRegionMap->layouts[REGIONMAP_SEVII123]); + DecompressDataWithHeaderWram(sSevii123_Tilemap, sRegionMap->layouts[REGIONMAP_SEVII123]); break; case 7: - LZ77UnCompWram(sSevii45_Tilemap, sRegionMap->layouts[REGIONMAP_SEVII45]); + DecompressDataWithHeaderWram(sSevii45_Tilemap, sRegionMap->layouts[REGIONMAP_SEVII45]); break; case 8: - LZ77UnCompWram(sSevii67_Tilemap, sRegionMap->layouts[REGIONMAP_SEVII67]); + DecompressDataWithHeaderWram(sSevii67_Tilemap, sRegionMap->layouts[REGIONMAP_SEVII67]); break; default: - LZ77UnCompWram(sBackground_Tilemap, sRegionMap->layouts[REGIONMAP_COUNT]); + DecompressDataWithHeaderWram(sBackground_Tilemap, sRegionMap->layouts[REGIONMAP_COUNT]); return TRUE; } sRegionMap->loadGfxState++; @@ -1551,20 +1552,20 @@ static void InitSwitchMapMenu(u8 whichMap, u8 taskId, TaskFunc taskFunc) switch (sSwitchMapMenu->maxSelection) { case 1: - LZ77UnCompWram(sSwitchMap_KantoSevii123_Tilemap, sSwitchMapMenu->switchMapTilemap); + DecompressDataWithHeaderWram(sSwitchMap_KantoSevii123_Tilemap, sSwitchMapMenu->switchMapTilemap); sSwitchMapMenu->yOffset = 6; break; case 2: // never reached - LZ77UnCompWram(sSwitchMap_KantoSeviiAll2_Tilemap, sSwitchMapMenu->switchMapTilemap); + DecompressDataWithHeaderWram(sSwitchMap_KantoSeviiAll2_Tilemap, sSwitchMapMenu->switchMapTilemap); sSwitchMapMenu->yOffset = 4; break; case 3: default: sSwitchMapMenu->yOffset = 3; - LZ77UnCompWram(sSwitchMap_KantoSeviiAll_Tilemap, sSwitchMapMenu->switchMapTilemap); + DecompressDataWithHeaderWram(sSwitchMap_KantoSeviiAll_Tilemap, sSwitchMapMenu->switchMapTilemap); break; } - LZ77UnCompWram(sSwitchMapMenu_Gfx, sSwitchMapMenu->switchMapTiles); + DecompressDataWithHeaderWram(sSwitchMapMenu_Gfx, sSwitchMapMenu->switchMapTiles); sSwitchMapMenu->mainState = 0; sSwitchMapMenu->currentSelection = whichMap; sSwitchMapMenu->exitTask = taskFunc; @@ -1833,10 +1834,10 @@ static bool8 CreateSwitchMapCursor(void) switch (sSwitchMapMenu->cursorLoadState) { case 0: - LZ77UnCompWram(sSwitchMapCursorLeft_Gfx, sSwitchMapMenu->cursorSubsprite[0].tiles); + DecompressDataWithHeaderWram(sSwitchMapCursorLeft_Gfx, sSwitchMapMenu->cursorSubsprite[0].tiles); break; case 1: - LZ77UnCompWram(sSwitchMapCursorRight_Gfx, sSwitchMapMenu->cursorSubsprite[1].tiles); + DecompressDataWithHeaderWram(sSwitchMapCursorRight_Gfx, sSwitchMapMenu->cursorSubsprite[1].tiles); break; case 2: CreateSwitchMapCursorSubsprite(0, 2, 2); @@ -1949,10 +1950,10 @@ static bool8 LoadMapPreviewGfx(void) switch (sDungeonMapPreview->loadState) { case 0: - LZ77UnCompWram(sDungeonMapPreview->mapPreviewInfo->tilesptr, sDungeonMapPreview->tiles); + DecompressDataWithHeaderWram(sDungeonMapPreview->mapPreviewInfo->tilesptr, sDungeonMapPreview->tiles); break; case 1: - LZ77UnCompWram(sDungeonMapPreview->mapPreviewInfo->tilemapptr, sDungeonMapPreview->tilemap); + DecompressDataWithHeaderWram(sDungeonMapPreview->mapPreviewInfo->tilemapptr, sDungeonMapPreview->tilemap); break; case 2: LoadBgTiles(2, sDungeonMapPreview->tiles, sizeof(sDungeonMapPreview->tiles), 0); @@ -2240,34 +2241,34 @@ static bool8 LoadMapEdgeGfx(void) switch (sMapOpenCloseAnim->loadGfxState) { case 0: - LZ77UnCompWram(sMapEdge_TopLeft, sMapOpenCloseAnim->mapEdges[MAPEDGE_TOP_LEFT]->tiles); + DecompressDataWithHeaderWram(sMapEdge_TopLeft, sMapOpenCloseAnim->mapEdges[MAPEDGE_TOP_LEFT]->tiles); CreateMapEdgeSprite(MAPEDGE_TOP_LEFT, 4, 4); break; case 1: - LZ77UnCompWram(sMapEdge_MidLeft, sMapOpenCloseAnim->mapEdges[MAPEDGE_MID_LEFT]->tiles); + DecompressDataWithHeaderWram(sMapEdge_MidLeft, sMapOpenCloseAnim->mapEdges[MAPEDGE_MID_LEFT]->tiles); CreateMapEdgeSprite(MAPEDGE_MID_LEFT, 5, 5); break; case 2: - LZ77UnCompWram(sMapEdge_BottomLeft, sMapOpenCloseAnim->mapEdges[MAPEDGE_BOT_LEFT]->tiles); + DecompressDataWithHeaderWram(sMapEdge_BottomLeft, sMapOpenCloseAnim->mapEdges[MAPEDGE_BOT_LEFT]->tiles); CreateMapEdgeSprite(MAPEDGE_BOT_LEFT, 6, 6); break; case 3: - LZ77UnCompWram(sMapEdge_TopRight, sMapOpenCloseAnim->mapEdges[MAPEDGE_TOP_RIGHT]->tiles); + DecompressDataWithHeaderWram(sMapEdge_TopRight, sMapOpenCloseAnim->mapEdges[MAPEDGE_TOP_RIGHT]->tiles); CreateMapEdgeSprite(MAPEDGE_TOP_RIGHT, 7, 7); break; case 4: - LZ77UnCompWram(sMapEdge_MidRight, sMapOpenCloseAnim->mapEdges[MAPEDGE_MID_RIGHT]->tiles); + DecompressDataWithHeaderWram(sMapEdge_MidRight, sMapOpenCloseAnim->mapEdges[MAPEDGE_MID_RIGHT]->tiles); CreateMapEdgeSprite(MAPEDGE_MID_RIGHT, 8, 8); break; case 5: - LZ77UnCompWram(sMapEdge_BottomRight, sMapOpenCloseAnim->mapEdges[MAPEDGE_BOT_RIGHT]->tiles); + DecompressDataWithHeaderWram(sMapEdge_BottomRight, sMapOpenCloseAnim->mapEdges[MAPEDGE_BOT_RIGHT]->tiles); CreateMapEdgeSprite(MAPEDGE_BOT_RIGHT, 9, 9); break; case 6: - LZ77UnCompWram(sMapEdge_Gfx, sMapOpenCloseAnim->tiles); + DecompressDataWithHeaderWram(sMapEdge_Gfx, sMapOpenCloseAnim->tiles); break; case 7: - LZ77UnCompWram(sMapEdge_Tilemap, sMapOpenCloseAnim->tilemap); + DecompressDataWithHeaderWram(sMapEdge_Tilemap, sMapOpenCloseAnim->tilemap); break; case 8: LoadBgTiles(1, sMapOpenCloseAnim->tiles, BG_SCREEN_SIZE, 0); @@ -2675,7 +2676,7 @@ static void SpriteCB_MapCursor(struct Sprite *sprite) static void CreateMapCursor(u16 tileTag, u16 palTag) { sMapCursor = AllocZeroed(sizeof(struct MapCursor)); - LZ77UnCompWram(sMapCursor_Gfx, sMapCursor->tiles); + DecompressDataWithHeaderWram(sMapCursor_Gfx, sMapCursor->tiles); sMapCursor->tileTag = tileTag; sMapCursor->palTag = palTag; GetPlayerPositionOnRegionMap_HandleOverrides(); @@ -3358,9 +3359,9 @@ static void CreatePlayerIcon(u16 tileTag, u16 palTag) { sPlayerIcon = AllocZeroed(sizeof(struct PlayerIcon)); if (gSaveBlock2Ptr->playerGender == FEMALE) - LZ77UnCompWram(sPlayerIcon_Leaf, sPlayerIcon->tiles); + DecompressDataWithHeaderWram(sPlayerIcon_Leaf, sPlayerIcon->tiles); else - LZ77UnCompWram(sPlayerIcon_Red, sPlayerIcon->tiles); + DecompressDataWithHeaderWram(sPlayerIcon_Red, sPlayerIcon->tiles); sPlayerIcon->tileTag = tileTag; sPlayerIcon->palTag = palTag; sPlayerIcon->x = GetMapCursorX(); @@ -3431,8 +3432,8 @@ static void InitMapIcons(u8 whichMap, u8 taskId, TaskFunc taskFunc) sMapIcons = AllocZeroed(sizeof(struct MapIcons)); sMapIcons->exitTask = taskFunc; sMapIcons->region = whichMap; - LZ77UnCompWram(sDungeonIcon, sMapIcons->dungeonIconTiles); - LZ77UnCompWram(sFlyIcon, sMapIcons->flyIconTiles); + DecompressDataWithHeaderWram(sDungeonIcon, sMapIcons->dungeonIconTiles); + DecompressDataWithHeaderWram(sFlyIcon, sMapIcons->flyIconTiles); gTasks[taskId].func = LoadMapIcons; } diff --git a/src/trainer_card.c b/src/trainer_card.c index 13b0a735c..540272a00 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -1,4 +1,5 @@ #include "global.h" +#include "decompress.h" #include "gflib.h" #include "scanline_effect.h" #include "task.h" @@ -650,45 +651,45 @@ static bool8 LoadCardGfx(void) { case 0: if (sTrainerCardDataPtr->cardType == CARD_TYPE_RSE) - LZ77UnCompWram(sHoennTrainerCardBg_Tilemap, sTrainerCardDataPtr->bgTilemap); + DecompressDataWithHeaderWram(sHoennTrainerCardBg_Tilemap, sTrainerCardDataPtr->bgTilemap); else - LZ77UnCompWram(sKantoTrainerCardBg_Tilemap, sTrainerCardDataPtr->bgTilemap); + DecompressDataWithHeaderWram(sKantoTrainerCardBg_Tilemap, sTrainerCardDataPtr->bgTilemap); break; case 1: if (sTrainerCardDataPtr->cardType == CARD_TYPE_RSE) - LZ77UnCompWram(sHoennTrainerCardBack_Tilemap, sTrainerCardDataPtr->backTilemap); + DecompressDataWithHeaderWram(sHoennTrainerCardBack_Tilemap, sTrainerCardDataPtr->backTilemap); else - LZ77UnCompWram(sKantoTrainerCardBack_Tilemap, sTrainerCardDataPtr->backTilemap); + DecompressDataWithHeaderWram(sKantoTrainerCardBack_Tilemap, sTrainerCardDataPtr->backTilemap); break; case 2: if (!sTrainerCardDataPtr->isLink) { if (sTrainerCardDataPtr->cardType == CARD_TYPE_RSE) - LZ77UnCompWram(sHoennTrainerCardFront_Tilemap, sTrainerCardDataPtr->frontTilemap); + DecompressDataWithHeaderWram(sHoennTrainerCardFront_Tilemap, sTrainerCardDataPtr->frontTilemap); else - LZ77UnCompWram(sKantoTrainerCardFront_Tilemap, sTrainerCardDataPtr->frontTilemap); + DecompressDataWithHeaderWram(sKantoTrainerCardFront_Tilemap, sTrainerCardDataPtr->frontTilemap); } else { if (sTrainerCardDataPtr->cardType == CARD_TYPE_RSE) - LZ77UnCompWram(sHoennTrainerCardFrontLink_Tilemap, sTrainerCardDataPtr->frontTilemap); + DecompressDataWithHeaderWram(sHoennTrainerCardFrontLink_Tilemap, sTrainerCardDataPtr->frontTilemap); else - LZ77UnCompWram(sKantoTrainerCardFrontLink_Tilemap, sTrainerCardDataPtr->frontTilemap); + DecompressDataWithHeaderWram(sKantoTrainerCardFrontLink_Tilemap, sTrainerCardDataPtr->frontTilemap); } break; case 3: // ? Doesnt check for RSE, sHoennTrainerCardBadges_Gfx goes unused - LZ77UnCompWram(sKantoTrainerCardBadges_Gfx, sTrainerCardDataPtr->badgeTiles); + DecompressDataWithHeaderWram(sKantoTrainerCardBadges_Gfx, sTrainerCardDataPtr->badgeTiles); break; case 4: if (sTrainerCardDataPtr->cardType == CARD_TYPE_RSE) - LZ77UnCompWram(gHoennTrainerCard_Gfx, &sTrainerCardDataPtr->cardTiles); + DecompressDataWithHeaderWram(gHoennTrainerCard_Gfx, &sTrainerCardDataPtr->cardTiles); else - LZ77UnCompWram(gKantoTrainerCard_Gfx, &sTrainerCardDataPtr->cardTiles); + DecompressDataWithHeaderWram(gKantoTrainerCard_Gfx, &sTrainerCardDataPtr->cardTiles); break; case 5: if (sTrainerCardDataPtr->cardType == CARD_TYPE_FRLG) - LZ77UnCompWram(sTrainerCardStickers_Gfx, sTrainerCardDataPtr->stickerTiles); + DecompressDataWithHeaderWram(sTrainerCardStickers_Gfx, sTrainerCardDataPtr->stickerTiles); break; default: sTrainerCardDataPtr->gfxLoadState = 0; diff --git a/src/window.c b/src/window.c index ec998083a..65f24ce65 100644 --- a/src/window.c +++ b/src/window.c @@ -3,6 +3,7 @@ #include "malloc.h" #include "bg.h" #include "blit.h" +#include "decompress.h" // This global is set to 0 and never changed. COMMON_DATA u8 gTransparentTileNumber = 0; @@ -443,7 +444,7 @@ void CopyToWindowPixelBuffer(u32 windowId, const void *src, u16 size, u16 tileOf if (size != 0) CpuCopy16(src, gWindows[windowId].tileData + (32 * tileOffset), size); else - LZ77UnCompWram(src, gWindows[windowId].tileData + (32 * tileOffset)); + DecompressDataWithHeaderWram(src, gWindows[windowId].tileData + (32 * tileOffset)); } // Sets all pixels within the window to the fillValue color.