New sprite compressor (#5627)

Co-authored-by: Hedara <hedara90@gmail.com>
Co-authored-by: DizzyEggg
Co-authored-by: Raymond Dodge <git@rayrobdod.name>
This commit is contained in:
hedara90 2025-05-30 23:10:54 +02:00 committed by GitHub
parent d25f637b4e
commit 6e64f6f5ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
139 changed files with 11017 additions and 360 deletions

5
.gitignore vendored
View File

@ -13,6 +13,9 @@
*.8bpp
*.gbapal
*.lz
*.smol
*.fastSmol
*.smolTM
*.rl
*.latfont
*.hwjpnfont
@ -41,6 +44,8 @@ prefabs.json
/pokeemerald-*.png
src/data/map_group_count.h
tools/trainerproc/trainerproc
tools/compresSmol/compresSmol
tools/compresSmol/compresSmolTilemap
*.Identifier
*.smol
*.fastSmol

View File

@ -151,6 +151,8 @@ endif
AUTO_GEN_TARGETS :=
include make_tools.mk
# Tool executables
SMOLTM := $(TOOLS_DIR)/compresSmol/compresSmolTilemap$(EXE)
SMOL := $(TOOLS_DIR)/compresSmol/compresSmol$(EXE)
GFX := $(TOOLS_DIR)/gbagfx/gbagfx$(EXE)
AIF := $(TOOLS_DIR)/aif2pcm/aif2pcm$(EXE)
MID := $(TOOLS_DIR)/mid2agb/mid2agb$(EXE)
@ -317,7 +319,7 @@ clean-assets:
rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc
rm -f $(DATA_ASM_SUBDIR)/maps/connections.inc $(DATA_ASM_SUBDIR)/maps/events.inc $(DATA_ASM_SUBDIR)/maps/groups.inc $(DATA_ASM_SUBDIR)/maps/headers.inc $(DATA_SRC_SUBDIR)/map_group_count.h
find sound -iname '*.bin' -exec rm {} +
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.smol' -o -iname '*.fastSmol' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
find $(DATA_ASM_SUBDIR)/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} +
tidy: tidymodern tidycheck tidydebug
@ -351,13 +353,16 @@ generated: $(AUTO_GEN_TARGETS)
%.pal: ;
%.aif: ;
%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.gbapal: %.png ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@
%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.gbapal: %.png ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
%.smolTM: % ; $(SMOLTM) $< $@
%.fastSmol: % ; $(SMOL) -w $< $@ false false false
%.smol: % ; $(SMOL) -w $< $@
%.rl: % ; $(GFX) $< $@
clean-generated:
@rm -f $(AUTO_GEN_TARGETS)

View File

@ -1139,6 +1139,9 @@
#undef B_FLAG_INVERSE_BATTLE
#define B_FLAG_INVERSE_BATTLE TESTING_FLAG_INVERSE_BATTLE
// Compression DebugPrintf switch
#define T_COMPRESSION_SHOULD_PRINT FALSE
// Move animation testing
#define T_SHOULD_RUN_MOVE_ANIM FALSE // If TRUE, enables the move animation tests, these are very computationally heavy and takes a long time to run.

View File

@ -5,9 +5,68 @@
#define MAX_DECOMPRESSION_BUFFER_SIZE 0x4000
void LZDecompressWram(const u32 *src, void *dest);
void LZDecompressVram(const u32 *src, void *dest);
#define TANS_TABLE_SIZE 64
#define PACKED_FREQ_MASK 0x3F
#define PARTIAL_FREQ_MASK 0xC0000000
#define FIRST_LO_MASK 0x7f
#define CONTINUE_BIT 0x80
#define SMOL_IMAGE_SIZE_MULTIPLIER 4
struct LZ77Header {
u32 lz77IdBits:5;
u32 padding:3;
u32 size:24;
};
struct SmolHeader {
u32 mode:4;
u32 imageSize:14;
u32 symSize:14;
u32 initialState:6;
u32 bitstreamSize:13;
u32 loSize:13;
};
struct SpriteSheetHeader {
u32 mode:4;
u32 numComponents:12;
u32 framesPerComponent:16;
};
struct SmolTilemapHeader {
u32 mode:4;
u32 tilemapSize:14;
u32 symSize:14;
u32 tileNumberSize;
};
union CompressionHeader {
struct LZ77Header lz77;
struct SmolHeader smol;
struct SmolTilemapHeader smolTilemap;
};
enum CompressionMode {
MODE_LZ77 = 0,
BASE_ONLY = 1,
ENCODE_SYMS = 2,
ENCODE_DELTA_SYMS = 3,
ENCODE_LO = 4,
ENCODE_BOTH = 5,
ENCODE_BOTH_DELTA_SYMS = 6,
IS_FRAME_CONTAINER = 7,
IS_TILEMAP = 8,
};
void DecompressDataWithHeaderVram(const u32 *src, void *dest);
void DecompressDataWithHeaderWram(const u32 *src, void *dest);
// Lucky's fast lz decompression function
void FastLZ77UnCompWram(const u32 *src, void *dest);
// Default Decompression functions are below here
u32 IsLZ77Data(const void *ptr, u32 minSize, u32 maxSize);
u32 LoadCompressedSpriteSheet(const struct CompressedSpriteSheet *src);

View File

@ -0,0 +1,15 @@
#ifndef GUARD_DECOMPRESS_ERROR_HANDLER_H
#define GUARD_DECOMPRESS_ERROR_HANDLER_H
#include "gba/types.h"
enum CompressionError {
NO_COMPRESSION_ERROR,
HEADER_ERROR,
};
void DoDecompressionError(void);
void DecompressionError_CB2(void);
void DecompressionError(const u32 *src, enum CompressionError error);
#endif // GUARD_DECOMPRESS_ERROR_HANDLER_H

View File

@ -5,7 +5,7 @@ MAKEFLAGS += --no-print-directory
# Inclusive list. If you don't want a tool to be built, don't add it here.
TOOLS_DIR := tools
TOOL_NAMES := aif2pcm bin2c gbafix gbagfx jsonproc mapjson mid2agb preproc ramscrgen rsfont scaninc trainerproc
TOOL_NAMES := aif2pcm bin2c gbafix gbagfx jsonproc mapjson mid2agb preproc ramscrgen rsfont scaninc trainerproc compresSmol
CHECK_TOOL_NAMES = patchelf mgba-rom-test-hydra
TOOLDIRS := $(TOOL_NAMES:%=$(TOOLS_DIR)/%)

View File

@ -0,0 +1,67 @@
import glob
import re
import os
from pathlib import Path
if not os.path.exists("Makefile"):
print("Please run this script from your root folder.")
quit()
primaryTileset_pattern = re.compile(r"(.*\"data/tilesets/primary/.+\.4bpp\.)lz(\".*)")
secondaryTileset_pattern = re.compile(r"(.*\"data/tilesets/secondary/.+\.4bpp\.)lz(\".*)")
tilemap_pattern = re.compile(r"(.*\"graphics/.+\.bin\.)lz(\".*)")
lzuncomp_pattern = re.compile(r"(.*)\bLZ77UnComp([WV])ram\b(\(.*)")
lzdecomp_pattern = re.compile(r"(.*)\bLZDecompress([WV])ram\b(\(.*)")
def handle_file(fileInput):
fileTest = Path(fileInput)
if not fileTest.is_file():
return False
allLines = list()
with open(fileInput, 'r', encoding='UTF-8') as file:
has_decompress_h = False
needs_decompress_h = False
while line:=file.readline():
if line.strip() == "#include \"decompress.h\"":
has_decompress_h = True
elif match := secondaryTileset_pattern.match(line):
line = match.group(1) + "fastSmol" + match.group(2) + "\n"
elif match := primaryTileset_pattern.match(line):
line = match.group(1) + "smol" + match.group(2) + "\n"
elif match := tilemap_pattern.match(line):
line = match.group(1) + "smolTM" + match.group(2) + "\n"
elif ".4bpp.lz" in line:
line = line.replace(".4bpp.lz", ".4bpp.smol")
elif ".8bpp.lz" in line:
line = line.replace(".8bpp.lz", ".8bpp.smol")
elif match := lzuncomp_pattern.match(line):
if allLines[-1].strip() != "case MODE_LZ77:": # do not modify DecompressDataWithHeader itself
line = match.group(1) + "DecompressDataWithHeader" + match.group(2) + "ram" + match.group(3) + "\n"
needs_decompress_h = True
elif match := lzdecomp_pattern.match(line):
line = match.group(1) + "DecompressDataWithHeader" + match.group(2) + "ram" + match.group(3) + "\n"
needs_decompress_h = True
else:
pass
allLines.append(line)
if needs_decompress_h and not has_decompress_h:
# attempt to place the new header in alphabetical order
i = 0
while not allLines[i].startswith("#include \"") or allLines[i] == "#include \"global.h\"\n":
i += 1
while allLines[i].startswith("#include \"") and allLines[i] < "#include \"decompress.h\"\n":
i += 1
allLines.insert(i, "#include \"decompress.h\"\n")
with open(fileInput, 'w', encoding='UTF-8') as file:
for line in allLines:
file.write(line)
return True
for path in glob.glob("src/**/*.c", recursive=True):
handle_file(path)
for path in glob.glob("src/**/*.h", recursive=True):
handle_file(path)

View File

@ -1571,17 +1571,17 @@ void LoadMoveBg(u16 bgId)
void *decompressionBuffer = Alloc(0x800);
const u32 *tilemap = gBattleAnimBackgroundTable[bgId].tilemap;
LZDecompressWram(tilemap, decompressionBuffer);
DecompressDataWithHeaderWram(tilemap, decompressionBuffer);
RelocateBattleBgPal(GetBattleBgPaletteNum(), decompressionBuffer, 0x100, FALSE);
DmaCopy32(3, decompressionBuffer, (void *)BG_SCREEN_ADDR(26), 0x800);
LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)BG_SCREEN_ADDR(4));
DecompressDataWithHeaderVram(gBattleAnimBackgroundTable[bgId].image, (void *)BG_SCREEN_ADDR(4));
LoadPalette(gBattleAnimBackgroundTable[bgId].palette, BG_PLTT_ID(GetBattleBgPaletteNum()), PLTT_SIZE_4BPP);
Free(decompressionBuffer);
}
else
{
LZDecompressVram(gBattleAnimBackgroundTable[bgId].tilemap, (void *)BG_SCREEN_ADDR(26));
LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)BG_CHAR_ADDR(2));
DecompressDataWithHeaderVram(gBattleAnimBackgroundTable[bgId].tilemap, (void *)BG_SCREEN_ADDR(26));
DecompressDataWithHeaderVram(gBattleAnimBackgroundTable[bgId].image, (void *)BG_CHAR_ADDR(2));
LoadPalette(gBattleAnimBackgroundTable[bgId].palette, BG_PLTT_ID(2), PLTT_SIZE_4BPP);
}
}

View File

@ -916,7 +916,7 @@ void ClearBattleAnimBg(u32 bgId)
void AnimLoadCompressedBgGfx(u32 bgId, const u32 *src, u32 tilesOffset)
{
CpuFill32(0, gBattleAnimBgTileBuffer, 0x2000);
LZDecompressWram(src, gBattleAnimBgTileBuffer);
DecompressDataWithHeaderWram(src, gBattleAnimBgTileBuffer);
LoadBgTiles(bgId, gBattleAnimBgTileBuffer, 0x2000, tilesOffset);
}

View File

@ -754,8 +754,8 @@ void DrawMainBattleBackground(void)
{
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_RECORDED_LINK))
{
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Frontier, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
}
else if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY)
@ -763,23 +763,23 @@ void DrawMainBattleBackground(void)
switch (GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL))
{
case SPECIES_GROUDON:
LZDecompressVram(gBattleEnvironmentTiles_Cave, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Cave, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Cave, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Cave, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Groudon, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case SPECIES_KYOGRE:
LZDecompressVram(gBattleEnvironmentTiles_Water, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Water, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Water, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Water, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Kyogre, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case SPECIES_RAYQUAZA:
LZDecompressVram(gBattleEnvironmentTiles_Rayquaza, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Rayquaza, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Rayquaza, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Rayquaza, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Rayquaza, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
default:
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].tileset, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].tilemap, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].tileset, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].tilemap, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(sBattleEnvironmentTable[gBattleEnvironment].palette, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
}
@ -791,15 +791,15 @@ void DrawMainBattleBackground(void)
u32 trainerClass = GetTrainerClassFromId(TRAINER_BATTLE_PARAM.opponentA);
if (trainerClass == TRAINER_CLASS_LEADER)
{
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_BuildingLeader, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
return;
}
else if (trainerClass == TRAINER_CLASS_CHAMPION)
{
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumWallace, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
return;
}
@ -809,48 +809,48 @@ void DrawMainBattleBackground(void)
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].tileset, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].tilemap, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].tileset, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].tilemap, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(sBattleEnvironmentTable[gBattleEnvironment].palette, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_BuildingGym, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumMagma, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumAqua, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumSidney, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumPhoebe, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumGlacia, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumDrake, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Frontier, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
}
@ -859,7 +859,7 @@ void DrawMainBattleBackground(void)
void LoadBattleTextboxAndBackground(void)
{
LZDecompressVram(gBattleTextboxTiles, (void *)(BG_CHAR_ADDR(0)));
DecompressDataWithHeaderVram(gBattleTextboxTiles, (void *)(BG_CHAR_ADDR(0)));
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
LoadPalette(gBattleTextboxPalette, BG_PLTT_ID(0), 2 * PLTT_SIZE_4BPP);
@ -1129,8 +1129,8 @@ void DrawBattleEntryBackground(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
LZDecompressVram(gBattleVSFrame_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gVsLettersGfx, (void *)OBJ_VRAM0);
DecompressDataWithHeaderVram(gBattleVSFrame_Gfx, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gVsLettersGfx, (void *)OBJ_VRAM0);
LoadPalette(gBattleVSFrame_Pal, BG_PLTT_ID(6), PLTT_SIZE_4BPP);
SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
@ -1148,8 +1148,8 @@ void DrawBattleEntryBackground(void)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId > TRAINER_PARTNER(PARTNER_NONE))
{
LZDecompressVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
}
else
{
@ -1168,20 +1168,20 @@ void DrawBattleEntryBackground(void)
switch (GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL))
{
case SPECIES_GROUDON:
LZDecompressVram(gBattleEnvironmentAnimTiles_Cave, (void*)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Cave, (void*)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Cave, (void*)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Cave, (void*)(BG_SCREEN_ADDR(28)));
break;
case SPECIES_KYOGRE:
LZDecompressVram(gBattleEnvironmentAnimTiles_Underwater, (void*)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Underwater, (void*)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Underwater, (void*)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Underwater, (void*)(BG_SCREEN_ADDR(28)));
break;
case SPECIES_RAYQUAZA:
LZDecompressVram(gBattleEnvironmentAnimTiles_Rayquaza, (void*)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Rayquaza, (void*)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Rayquaza, (void*)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Rayquaza, (void*)(BG_SCREEN_ADDR(28)));
break;
default:
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].entryTileset, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].entryTilemap, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].entryTileset, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].entryTilemap, (void *)(BG_SCREEN_ADDR(28)));
break;
}
}
@ -1192,27 +1192,27 @@ void DrawBattleEntryBackground(void)
u32 trainerClass = GetTrainerClassFromId(TRAINER_BATTLE_PARAM.opponentA);
if (trainerClass == TRAINER_CLASS_LEADER)
{
LZDecompressVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
return;
}
else if (trainerClass == TRAINER_CLASS_CHAMPION)
{
LZDecompressVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
return;
}
}
if (GetCurrentMapBattleScene() == MAP_BATTLE_SCENE_NORMAL)
{
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].entryTileset, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].entryTilemap, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].entryTileset, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].entryTilemap, (void *)(BG_SCREEN_ADDR(28)));
}
else
{
LZDecompressVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTiles_Building, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gBattleEnvironmentAnimTilemap_Building, (void *)(BG_SCREEN_ADDR(28)));
}
}
}
@ -1224,7 +1224,7 @@ bool8 LoadChosenBattleElement(u8 caseId)
switch (caseId)
{
case 0:
LZDecompressVram(gBattleTextboxTiles, (void *)(BG_CHAR_ADDR(0)));
DecompressDataWithHeaderVram(gBattleTextboxTiles, (void *)(BG_CHAR_ADDR(0)));
break;
case 1:
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
@ -1236,17 +1236,17 @@ bool8 LoadChosenBattleElement(u8 caseId)
case 3:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER))
{
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
}
else if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY)
{
switch (GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL))
{
case SPECIES_GROUDON:
LZDecompressVram(gBattleEnvironmentTiles_Cave, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Cave, (void*)(BG_CHAR_ADDR(2)));
break;
case SPECIES_KYOGRE:
LZDecompressVram(gBattleEnvironmentTilemap_Water, (void*)(BG_SCREEN_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Water, (void*)(BG_SCREEN_ADDR(2)));
break;
}
}
@ -1257,12 +1257,12 @@ bool8 LoadChosenBattleElement(u8 caseId)
u32 trainerClass = GetTrainerClassFromId(TRAINER_BATTLE_PARAM.opponentA);
if (trainerClass == TRAINER_CLASS_LEADER)
{
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
break;
}
else if (trainerClass == TRAINER_CLASS_CHAMPION)
{
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
}
}
@ -1271,31 +1271,31 @@ bool8 LoadChosenBattleElement(u8 caseId)
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].tileset, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].tileset, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void *)(BG_CHAR_ADDR(2)));
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void *)(BG_CHAR_ADDR(2)));
break;
}
}
@ -1303,14 +1303,14 @@ bool8 LoadChosenBattleElement(u8 caseId)
case 4:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER))
{
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
}
else if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY)
{
if (GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL) == SPECIES_GROUDON)
LZDecompressVram(gBattleEnvironmentTilemap_Cave, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Cave, (void*)(BG_SCREEN_ADDR(26)));
else
LZDecompressVram(gBattleEnvironmentTilemap_Water, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Water, (void *)(BG_SCREEN_ADDR(26)));
}
else
{
@ -1319,12 +1319,12 @@ bool8 LoadChosenBattleElement(u8 caseId)
u32 trainerClass = GetTrainerClassFromId(TRAINER_BATTLE_PARAM.opponentA);
if (trainerClass == TRAINER_CLASS_LEADER)
{
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
break;
}
else if (trainerClass == TRAINER_CLASS_CHAMPION)
{
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
}
}
@ -1333,31 +1333,31 @@ bool8 LoadChosenBattleElement(u8 caseId)
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(sBattleEnvironmentTable[gBattleEnvironment].tilemap, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[gBattleEnvironment].tilemap, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void *)(BG_SCREEN_ADDR(26)));
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void *)(BG_SCREEN_ADDR(26)));
break;
}
}

View File

@ -5260,7 +5260,7 @@ static void Task_ShowTourneyTree(u8 taskId)
break;
case 2:
sTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE);
LZDecompressWram(gDomeTourneyTree_Tilemap, sTilemapBuffer);
DecompressDataWithHeaderWram(gDomeTourneyTree_Tilemap, sTilemapBuffer);
SetBgTilemapBuffer(1, sTilemapBuffer);
CopyBgTilemapBufferToVram(1);
DecompressAndLoadBgGfxUsingHeap(1, gDomeTourneyTree_Gfx, 0x2000, 0, 0);

View File

@ -811,7 +811,7 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
void LoadBattleBarGfx(u8 unused)
{
LZDecompressWram(gBattleInterfaceGfx_BattleBar, gMonSpritesGfxPtr->barFontGfx);
DecompressDataWithHeaderWram(gBattleInterfaceGfx_BattleBar, gMonSpritesGfxPtr->barFontGfx);
}
bool8 BattleInitAllSprites(u8 *state1, u8 *battler)
@ -1026,11 +1026,11 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battler, bool8 loadMonSprite)
position = GetBattlerPosition(battler);
if (IsContest())
LZDecompressVram(gBattleAnimSpriteGfx_SubstituteBack, gMonSpritesGfxPtr->spritesGfx[position]);
DecompressDataWithHeaderVram(gBattleAnimSpriteGfx_SubstituteBack, gMonSpritesGfxPtr->spritesGfx[position]);
else if (!IsOnPlayerSide(battler))
LZDecompressVram(gBattleAnimSpriteGfx_Substitute, gMonSpritesGfxPtr->spritesGfx[position]);
DecompressDataWithHeaderVram(gBattleAnimSpriteGfx_Substitute, gMonSpritesGfxPtr->spritesGfx[position]);
else
LZDecompressVram(gBattleAnimSpriteGfx_SubstituteBack, gMonSpritesGfxPtr->spritesGfx[position]);
DecompressDataWithHeaderVram(gBattleAnimSpriteGfx_SubstituteBack, gMonSpritesGfxPtr->spritesGfx[position]);
for (i = 1; i < 4; i++)
{

View File

@ -573,7 +573,7 @@ static bool8 LoadPyramidBagGfx(void)
case 1:
if (FreeTempTileDataBuffersIfPossible() != TRUE)
{
LZDecompressWram(gBattlePyramidBagTilemap, gPyramidBagMenu->tilemapBuffer);
DecompressDataWithHeaderWram(gBattlePyramidBagTilemap, gPyramidBagMenu->tilemapBuffer);
gPyramidBagMenu->state++;
}
break;

View File

@ -1385,7 +1385,7 @@ static bool8 Aqua_Init(struct Task *task)
InitPatternWeaveTransition(task);
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, BG_SCREEN_SIZE);
LZ77UnCompVram(sTeamAqua_Tileset, tileset);
DecompressDataWithHeaderVram(sTeamAqua_Tileset, tileset);
LoadPalette(sEvilTeam_Palette, BG_PLTT_ID(15), sizeof(sEvilTeam_Palette));
task->tState++;
@ -1400,7 +1400,7 @@ static bool8 Magma_Init(struct Task *task)
InitPatternWeaveTransition(task);
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, BG_SCREEN_SIZE);
LZ77UnCompVram(sTeamMagma_Tileset, tileset);
DecompressDataWithHeaderVram(sTeamMagma_Tileset, tileset);
LoadPalette(sEvilTeam_Palette, BG_PLTT_ID(15), sizeof(sEvilTeam_Palette));
task->tState++;
@ -1460,7 +1460,7 @@ static bool8 Aqua_SetGfx(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sTeamAqua_Tilemap, tilemap);
DecompressDataWithHeaderVram(sTeamAqua_Tilemap, tilemap);
SetSinWave((s16*)gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT);
task->tState++;
@ -1472,7 +1472,7 @@ static bool8 Magma_SetGfx(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sTeamMagma_Tilemap, tilemap);
DecompressDataWithHeaderVram(sTeamMagma_Tilemap, tilemap);
SetSinWave((s16*)gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT);
task->tState++;
@ -1526,8 +1526,8 @@ static bool8 Kyogre_Init(struct Task *task)
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, BG_SCREEN_SIZE);
LZ77UnCompVram(sKyogre_Tileset, tileset);
LZ77UnCompVram(sKyogre_Tilemap, tilemap);
DecompressDataWithHeaderVram(sKyogre_Tileset, tileset);
DecompressDataWithHeaderVram(sKyogre_Tilemap, tilemap);
task->tState++;
return FALSE;
@ -3418,8 +3418,8 @@ static bool8 Groudon_Init(struct Task *task)
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, BG_SCREEN_SIZE);
LZ77UnCompVram(sGroudon_Tileset, tileset);
LZ77UnCompVram(sGroudon_Tilemap, tilemap);
DecompressDataWithHeaderVram(sGroudon_Tileset, tileset);
DecompressDataWithHeaderVram(sGroudon_Tilemap, tilemap);
task->tState++;
task->tTimer = 0;
@ -4304,7 +4304,7 @@ static bool8 FrontierLogoWiggle_Init(struct Task *task)
InitPatternWeaveTransition(task);
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, BG_SCREEN_SIZE);
LZ77UnCompVram(sFrontierLogo_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierLogo_Tileset, tileset);
LoadPalette(sFrontierLogo_Palette, BG_PLTT_ID(15), sizeof(sFrontierLogo_Palette));
task->tState++;
@ -4316,7 +4316,7 @@ static bool8 FrontierLogoWiggle_SetGfx(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap);
DecompressDataWithHeaderVram(sFrontierLogo_Tilemap, tilemap);
SetSinWave((s16*)gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT);
task->tState++;
@ -4366,7 +4366,7 @@ static bool8 FrontierLogoWave_Init(struct Task *task)
REG_BLDALPHA = sTransitionData->BLDALPHA;
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, BG_SCREEN_SIZE);
LZ77UnCompVram(sFrontierLogo_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierLogo_Tileset, tileset);
LoadPalette(sFrontierLogo_Palette, BG_PLTT_ID(15), sizeof(sFrontierLogo_Palette));
sTransitionData->cameraY = 0;
UpdateShadowColor(RGB_GRAY);
@ -4380,7 +4380,7 @@ static bool8 FrontierLogoWave_SetGfx(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap);
DecompressDataWithHeaderVram(sFrontierLogo_Tilemap, tilemap);
task->tState++;
return TRUE;
@ -4512,7 +4512,7 @@ static bool8 FrontierSquares_Init(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierSquares_FilledBg_Tileset, tileset);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
FillBgTilemapBufferRect(0, 1, 0, 0, MARGIN_SIZE, 32, 15);
@ -4570,13 +4570,13 @@ static bool8 FrontierSquares_Shrink(struct Task *task)
break;
case 1:
BlendPalettes(PALETTES_ALL & ~(1 << 15), 16, RGB_BLACK);
LZ77UnCompVram(sFrontierSquares_EmptyBg_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierSquares_EmptyBg_Tileset, tileset);
break;
case 2:
LZ77UnCompVram(sFrontierSquares_Shrink1_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierSquares_Shrink1_Tileset, tileset);
break;
case 3:
LZ77UnCompVram(sFrontierSquares_Shrink2_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierSquares_Shrink2_Tileset, tileset);
break;
default:
FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32);
@ -4607,7 +4607,7 @@ static bool8 FrontierSquaresSpiral_Init(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierSquares_FilledBg_Tileset, tileset);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
FillBgTilemapBufferRect(0, 1, 0, 0, MARGIN_SIZE, 32, 15);
@ -4725,7 +4725,7 @@ static bool8 FrontierSquaresScroll_Init(struct Task *task)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset);
DecompressDataWithHeaderVram(sFrontierSquares_FilledBg_Tileset, tileset);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
CopyBgTilemapBufferToVram(0);
LoadPalette(sFrontierSquares_Palette, BG_PLTT_ID(15), sizeof(sFrontierSquares_Palette));

View File

@ -221,8 +221,8 @@ static void LoadLogoGfx(void)
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(sLogoCenter_Gfx, tileset);
LZ77UnCompVram(sLogoCenter_Tilemap, tilemap);
DecompressDataWithHeaderVram(sLogoCenter_Gfx, tileset);
DecompressDataWithHeaderVram(sLogoCenter_Tilemap, tilemap);
LoadPalette(sLogo_Pal, BG_PLTT_ID(15), sizeof(sLogo_Pal));
LoadCompressedSpriteSheet(&sSpriteSheet_LogoCircles);
LoadSpritePalette(&sSpritePalette_LogoCircles);

View File

@ -940,7 +940,7 @@ static bool8 LoadBerryBlenderGfx(void)
{
case 0:
sBerryBlender->tilesBuffer = AllocZeroed(GetDecompressedDataSize(gBerryBlenderCenter_Gfx) + 100);
LZDecompressWram(gBerryBlenderCenter_Gfx, sBerryBlender->tilesBuffer);
DecompressDataWithHeaderWram(gBerryBlenderCenter_Gfx, sBerryBlender->tilesBuffer);
sBerryBlender->loadGfxState++;
break;
case 1:
@ -954,7 +954,7 @@ static bool8 LoadBerryBlenderGfx(void)
sBerryBlender->loadGfxState++;
break;
case 3:
LZDecompressWram(gBerryBlenderOuter_Gfx, sBerryBlender->tilesBuffer);
DecompressDataWithHeaderWram(gBerryBlenderOuter_Gfx, sBerryBlender->tilesBuffer);
sBerryBlender->loadGfxState++;
break;
case 4:
@ -962,7 +962,7 @@ static bool8 LoadBerryBlenderGfx(void)
sBerryBlender->loadGfxState++;
break;
case 5:
LZDecompressWram(gBerryBlenderOuter_Tilemap, sBerryBlender->tilesBuffer);
DecompressDataWithHeaderWram(gBerryBlenderOuter_Tilemap, sBerryBlender->tilesBuffer);
sBerryBlender->loadGfxState++;
break;
case 6:

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "graphics.h"
#include "decompress.h"
// Duplicate of sBerryFixGraphics in berry_fix_program.c
static const struct {
@ -41,8 +42,8 @@ static void UNUSED LoadBerryFixGraphics(u32 idx)
REG_BG0HOFS = 0;
REG_BG0VOFS = 0;
REG_BLDCNT = 0;
LZ77UnCompVram(sBerryFixGraphics[idx].gfx, (void *)BG_CHAR_ADDR(0));
LZ77UnCompVram(sBerryFixGraphics[idx].tilemap, (void *)BG_SCREEN_ADDR(31));
DecompressDataWithHeaderVram(sBerryFixGraphics[idx].gfx, (void *)BG_CHAR_ADDR(0));
DecompressDataWithHeaderVram(sBerryFixGraphics[idx].tilemap, (void *)BG_SCREEN_ADDR(31));
CpuCopy16(sBerryFixGraphics[idx].pltt, (void *)BG_PLTT, BG_PLTT_SIZE);
REG_BG0CNT = BGCNT_SCREENBASE(31);
REG_DISPCNT = DISPCNT_BG0_ON;

View File

@ -12,6 +12,7 @@
#include "text.h"
#include "menu.h"
#include "m4a.h"
#include "decompress.h"
#include "constants/rgb.h"
enum {
@ -366,8 +367,8 @@ static void BerryFix_SetScene(int scene)
break;
}
CopyBgTilemapBufferToVram(0);
LZ77UnCompVram(sBerryFixGraphics[scene].gfx, (void *)BG_CHAR_ADDR(1));
LZ77UnCompVram(sBerryFixGraphics[scene].tilemap, (void *)BG_SCREEN_ADDR(31));
DecompressDataWithHeaderVram(sBerryFixGraphics[scene].gfx, (void *)BG_CHAR_ADDR(1));
DecompressDataWithHeaderVram(sBerryFixGraphics[scene].tilemap, (void *)BG_SCREEN_ADDR(31));
// These palettes range in size from 32-48 colors, so the below is interpreting whatever
// follows the palette (by default, the corresponding tiles) as the remaining 80-96.
CpuCopy32(sBerryFixGraphics[scene].palette, (void *)BG_PLTT, PLTT_SIZEOF(128));

View File

@ -335,12 +335,12 @@ static bool8 LoadBerryTagGfx(void)
case 1:
if (FreeTempTileDataBuffersIfPossible() != TRUE)
{
LZDecompressWram(gBerryTag_Gfx, sBerryTag->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gBerryTag_Gfx, sBerryTag->tilemapBuffers[0]);
sBerryTag->gfxState++;
}
break;
case 2:
LZDecompressWram(gBerryTag_Tilemap, sBerryTag->tilemapBuffers[2]);
DecompressDataWithHeaderWram(gBerryTag_Tilemap, sBerryTag->tilemapBuffers[2]);
sBerryTag->gfxState++;
break;
case 3:

View File

@ -5,6 +5,7 @@
#include "gpu_regs.h"
#include "malloc.h"
#include "menu.h"
#include "decompress.h"
#define DISPCNT_ALL_BG_AND_MODE_BITS (DISPCNT_BG_ALL_ON | 0x7)
@ -874,7 +875,7 @@ void CopyToBgTilemapBuffer(u32 bg, const void *src, u32 mode, u32 destOffset)
if (mode != 0)
CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
else
LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
DecompressDataWithHeaderWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
}
}

View File

@ -1133,8 +1133,8 @@ void LoadContestBgAfterMoveAnim(void)
{
s32 i;
LZDecompressVram(gContestInterfaceGfx, (void *)VRAM);
LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)));
DecompressDataWithHeaderVram(gContestInterfaceGfx, (void *)VRAM);
DecompressDataWithHeaderVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)));
CopyToBgTilemapBuffer(3, gContestAudienceTilemap, 0, 0);
CopyBgTilemapBufferToVram(3);
LoadPalette(gContestInterfaceAudiencePalette, BG_PLTT_OFFSET, BG_PLTT_SIZE);
@ -1414,10 +1414,10 @@ static bool8 SetupContestGraphics(u8 *stateVar)
RequestDma3Fill(0, (void *)VRAM + 0x10000, 0x8000, 1);
break;
case 1:
LZDecompressVram(gContestInterfaceGfx, (void *)VRAM);
DecompressDataWithHeaderVram(gContestInterfaceGfx, (void *)VRAM);
break;
case 2:
LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)));
DecompressDataWithHeaderVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)));
DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnzippedContestAudience_Gfx, 0x2000, 0x1000);
break;
case 3:

View File

@ -363,7 +363,7 @@ static void VBlankCB_ContestPainting(void)
static void InitContestMonPixels(u16 species, bool8 backPic)
{
const void *pal = GetMonSpritePalFromSpeciesAndPersonality(species, gContestPaintingWinner->isShiny, gContestPaintingWinner->personality);
LZDecompressVram(pal, gContestPaintingMonPalette);
DecompressDataWithHeaderVram(pal, gContestPaintingMonPalette);
if (!backPic)
{
HandleLoadSpecialPokePic(TRUE,

View File

@ -452,7 +452,7 @@ static void LoadContestResultsBgGfx(void)
s8 numStars, round2Points;
u16 tile1, tile2;
LZDecompressVram(gContestResults_Gfx, (void *)BG_CHAR_ADDR(0));
DecompressDataWithHeaderVram(gContestResults_Gfx, (void *)BG_CHAR_ADDR(0));
CopyToBgTilemapBuffer(3, gContestResults_Bg_Tilemap, 0, 0);
CopyToBgTilemapBuffer(2, gContestResults_Interface_Tilemap, 0, 0);
CopyToBgTilemapBuffer(0, gContestResults_WinnerBanner_Tilemap, 0, 0);

View File

@ -538,8 +538,8 @@ static void Task_LoadShowMons(u8 taskId)
ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
LZ77UnCompVram(gBirchBagGrass_Gfx, (void *)VRAM);
LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(7)));
DecompressDataWithHeaderVram(gBirchBagGrass_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(7)));
LoadPalette(gBirchBagGrass_Pal + 1, BG_PLTT_ID(0) + 1, PLTT_SIZEOF(2 * 16 - 1));
for (i = 0; i < MON_PIC_SIZE; i++)
@ -1282,7 +1282,7 @@ static void LoadTheEndScreen(u16 tileOffsetLoad, u16 tileOffsetWrite, u16 palOff
u16 baseTile;
u16 i;
LZ77UnCompVram(sCreditsCopyrightEnd_Gfx, (void *)(VRAM + tileOffsetLoad));
DecompressDataWithHeaderVram(sCreditsCopyrightEnd_Gfx, (void *)(VRAM + tileOffsetLoad));
LoadPalette(gIntroCopyright_Pal, palOffset, sizeof(gIntroCopyright_Pal));
baseTile = (palOffset / 16) << 12;

File diff suppressed because it is too large Load Diff

131
src/decompress_asm.s Normal file
View File

@ -0,0 +1,131 @@
.syntax unified
.arm
.section .iwram.code
.align 2
.global FastUnsafeCopy32
.type FastUnsafeCopy32, %function
@ Word aligned, 32-byte copy
@ This function WILL overwrite your buffer, so make sure it is at least 32 bytes larger than the desired size.
FastUnsafeCopy32:
push {r4-r10}
.Lloop_32:
ldmia r1!, {r3-r10}
stmia r0!, {r3-r10}
subs r2, r2, #32
bgt .Lloop_32
pop {r4-r10}
bx lr
@ Credit to: luckytyphlosion as it's his implementation
.section .text @Copied to stack on run-time
.align 2
.global LZ77UnCompWRAMOptimized
.type LZ77UnCompWRAMOptimized, %function
LZ77UnCompWRAMOptimized: @ 0x000010FC
push {r4, r5, r6, lr}
// read in data header in r5
// Data header (32bit)
// Bit 0-3 Reserved
// Bit 4-7 Compressed type (must be 1 for LZ77)
// Bit 8-31 Size of decompressed data
ldr r5, [r0], #4
// store decompressed size in r2
lsr r2, r5, #8
// main loop
cmp r2, #0
ble LZ77_Done
LZ77_MainLoop:
// read in Flag Byte
// Flag data (8bit)
// Bit 0-7 Type Flags for next 8 Blocks, MSB first
ldrb lr, [r0], #1
// shift to the highest byte
lsl lr, lr, #24
// 8 blocks so set counter (r4) to 8
mov r4, #8
b LZ77_EightBlockLoop
LZ77_HandleCompressedData:
// reading in block type 1 Part 1 into r5
// Block Type 1 Part 1 - Compressed - Copy N+3 Bytes from Dest-Disp-1 to Dest
// Bit 0-3 Disp MSBs
// Bit 4-7 Number of bytes to copy (minus 3)
// byte copy range: [3, 18]
ldrb r5, [r0], #1
// 18 -> 0
// 17 -> 1
// 16 -> 2
// ...
// 3 -> 15
// formula: do 18 - x
// want to calculate r3 = 18 - (3 + (numBytesToCopy))
// r3 = 18 - 3 - (numBytesToCopy)
// r3 = 15 - numBytesToCopy
// but then also need to do r2 = r2 - (3 + (numBytesToCopy))
// r2 = r2 - 3 - numBytesToCopy
// r2 = r2 - 18 + 18 - 3 - numBytesToCopy
// r2 = r2 - 18 + 15 - numBytesToCopy
mov r6, #3
// r3 = 3 + (numBytesToCopy)
add r3, r6, r5, asr #4
// get displacement high bits
and r5, r5, #0xf
// Now reading Block Type 1 Part 2 into r6
// Block type 1 Part 2
// Bit 0-7 Disp LSBs
ldrb r6, [r0], #1
// combine low and high bits into r6
orr r6, r6, r5, lsl #8
// +1 because of reasons
add r6, r6, #1
// subtract how many bytes are going to be copied from the size
subs r2, r2, r3
// do duff's device
// https://en.wikipedia.org/wiki/Duff%27s_device
// calculate pc offset
rsb r3, r3, #18
// jump
add pc, pc, r3, lsl #3
nop
.rept 18
ldrb r5, [r1, -r6]
strb r5, [r1], #1
.endr
// cpsr flags still preserved from earlier
// check if no more bytes have to be copied
ble LZ77_Done
// check if end of the block
subs r4, r4, #1
ble LZ77_MainLoop
LZ77_EightBlockLoop:
// check if compressed data (bit set)
lsls lr, lr, #1
bcs LZ77_HandleCompressedData
// uncompressed data can only be 1 byte long
// copy one byte of uncompressed data
ldrb r6, [r0], #1
strb r6, [r1], #1
subs r2, r2, #1
ble LZ77_Done
LZ77_EightBlockLoop_HandleLoop:
// check if we're done with the 8 blocks
subs r4, r4, #1
bgt LZ77_EightBlockLoop // go back to main loop if so
// no need to check if r2 is 0 since already checked elsewhere
b LZ77_MainLoop
LZ77_Done:
pop {r4, r5, r6, lr}
bx lr
.global LZ77UnCompWRAMOptimized_end
LZ77UnCompWRAMOptimized_end:

View File

@ -0,0 +1,197 @@
#include "decompress_error_handler.h"
#include "global.h"
#include "data.h"
#include "menu.h"
#include "menu_helpers.h"
#include "malloc.h"
#include "palette.h"
#include "graphics.h"
#include "gpu_regs.h"
#include "bg.h"
#include "main.h"
#include "text_window.h"
#include "string_util.h"
#include "constants/rgb.h"
static EWRAM_DATA u32 sErrorAddress;
static EWRAM_DATA enum CompressionError sCompressionError;
static const struct BgTemplate sBgTemplates[3] =
{
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0,
},
{
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 14,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0,
},
{
.bg = 3,
.charBaseIndex = 0,
.mapBaseIndex = 15,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0,
},
};
static void DecompressErrorScreenTextPrint(const u8 *text, u8 x, u8 y)
{
u8 color[3];
color[0] = TEXT_COLOR_TRANSPARENT;
color[1] = TEXT_DYNAMIC_COLOR_6;
color[2] = TEXT_COLOR_LIGHT_GRAY;
AddTextPrinterParameterized4(0, FONT_NORMAL, x * 8, y * 8 + 1, 0, 0, color, 0, text);
}
static void GetHexStringFromU32(u8 *str, u32 value)
{
str[0] = CHAR_0;
str[1] = CHAR_x;
str[10] = EOS;
for (u32 i = 0; i < 8; i++)
{
u8 currChar = 0;
switch ((value >> (4*i)) & 0xF)
{
case 0:
currChar = CHAR_0;
break;
case 1:
currChar = CHAR_1;
break;
case 2:
currChar = CHAR_2;
break;
case 3:
currChar = CHAR_3;
break;
case 4:
currChar = CHAR_4;
break;
case 5:
currChar = CHAR_5;
break;
case 6:
currChar = CHAR_6;
break;
case 7:
currChar = CHAR_7;
break;
case 8:
currChar = CHAR_8;
break;
case 9:
currChar = CHAR_9;
break;
case 10:
currChar = CHAR_A;
break;
case 11:
currChar = CHAR_B;
break;
case 12:
currChar = CHAR_C;
break;
case 13:
currChar = CHAR_D;
break;
case 14:
currChar = CHAR_E;
break;
case 15:
currChar = CHAR_F;
break;
}
u32 pos = 9 - i;
str[pos] = currChar;
}
}
void DecompressionError_CB2(void)
{
static const struct WindowTemplate textWin[] =
{
{
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 2,
.width = 24,
.height = 16,
.paletteNum = 15,
.baseBlock = 1,
}
};
if (sErrorAddress == 0)
return;
ResetVramOamAndBgCntRegs();
ResetAllBgsCoordinates();
FreeAllWindowBuffers();
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214);
DeactivateAllTextPrinters();
ResetTasks();
ResetPaletteFade();
LoadPalette(gTextWindowFrame1_Pal, 0xE0, 0x20);
LoadPalette(gStandardMenuPalette, 0xF0, 0x20);
InitWindows(textWin);
DrawStdFrameWithCustomTileAndPalette(0, TRUE, 0x214, 0xE);
static const u8 romCheckFailMessage[] =_(
"{COLOR RED}ERROR! {COLOR DARK_GRAY}Decompression Failed!\n"
"\n"
"Address:\n"
"Error:\n");
DecompressErrorScreenTextPrint(romCheckFailMessage, 1, 0);
u8 addressStr[11];
u8 errorStr[11];
GetHexStringFromU32(addressStr, sErrorAddress);
GetHexStringFromU32(errorStr, sCompressionError);
DecompressErrorScreenTextPrint(addressStr, 7, 4);
DecompressErrorScreenTextPrint(errorStr, 7, 6);
TransferPlttBuffer();
*(u16*)PLTT = RGB(17, 18, 31);
ShowBg(0);
sErrorAddress = 0;
// This loop is apparently needed to prevent the game from doing
// stupid stuff with data it couldn't decompress
while(TRUE)
sCompressionError++;
}
void DecompressionError(const u32 *src, enum CompressionError error)
{
sErrorAddress = (u32)src;
sCompressionError = error;
SetMainCallback2(DecompressionError_CB2);
DecompressionError_CB2();
}
void DoDecompressionError(void)
{
DecompressionError((u32 *)0x12345678, HEADER_ERROR);
}

View File

@ -2080,7 +2080,7 @@ static u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8
if (!AllocItemIconTemporaryBuffers())
return MAX_SPRITES;
LZDecompressWram(GetDecorationIconPic(decor), gItemIconDecompressionBuffer);
DecompressDataWithHeaderWram(GetDecorationIconPic(decor), gItemIconDecompressionBuffer);
CopyItemIconPicTo4x4Buffer(gItemIconDecompressionBuffer, gItemIcon4x4Buffer);
sheet.data = gItemIcon4x4Buffer;
sheet.size = 0x200;

View File

@ -1656,7 +1656,7 @@ static bool8 DexNav_LoadGraphics(void)
case 1:
if (FreeTempTileDataBuffersIfPossible() != TRUE)
{
LZDecompressWram(sDexNavGuiTilemap, sBg1TilemapBuffer);
DecompressDataWithHeaderWram(sDexNavGuiTilemap, sBg1TilemapBuffer);
sDexNavUiDataPtr->state++;
}
break;

View File

@ -80,7 +80,7 @@ void CB2_ShowDiploma(void)
DecompressAndCopyTileDataToVram(1, &sDiplomaTiles, 0, 0, 0);
while (FreeTempTileDataBuffersIfPossible())
;
LZDecompressWram(sDiplomaTilemap, sDiplomaTilemapPtr);
DecompressDataWithHeaderWram(sDiplomaTilemap, sDiplomaTilemapPtr);
CopyBgTilemapBufferToVram(1);
DisplayDiplomaText();
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "malloc.h"
#include "bg.h"
#include "decompress.h"
#include "dodrio_berry_picking.h"
#include "dynamic_placeholder_text_util.h"
#include "event_data.h"
@ -3830,7 +3831,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};
@ -4013,7 +4014,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)
{
@ -4155,7 +4156,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};
@ -4303,7 +4304,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};

View File

@ -308,10 +308,10 @@ static void ExpansionIntro_InitBgs(void)
static void ExpansionIntro_LoadGraphics(void)
{
LZ77UnCompVram(sBgTiles_PoweredBy, (void*) BG_CHAR_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG3].charBaseIndex));
LZ77UnCompVram(sBgMap_PoweredBy, (u16*) BG_SCREEN_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG3].mapBaseIndex));
LZ77UnCompVram(sBgTiles_RhhCredits, (void*) BG_CHAR_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG2].charBaseIndex));
LZ77UnCompVram(sBgMap_RhhCredits, (u16*) BG_SCREEN_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG2].mapBaseIndex));
DecompressDataWithHeaderVram(sBgTiles_PoweredBy, (void*) BG_CHAR_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG3].charBaseIndex));
DecompressDataWithHeaderVram(sBgMap_PoweredBy, (u16*) BG_SCREEN_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG3].mapBaseIndex));
DecompressDataWithHeaderVram(sBgTiles_RhhCredits, (void*) BG_CHAR_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG2].charBaseIndex));
DecompressDataWithHeaderVram(sBgMap_RhhCredits, (u16*) BG_SCREEN_ADDR(sBgTemplates_RhhCopyrightScreen[EXPANSION_INTRO_BG2].mapBaseIndex));
LoadPalette(sBgPal_Credits, 0x00, 0x60);
LoadCompressedSpriteSheet(&sSpriteSheet_DizzyEgg);

View File

@ -930,7 +930,7 @@ u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buf
static void UNUSED LoadTrainerGfx_TrainerCard(u8 gender, u16 palOffset, u8 *dest)
{
LZDecompressVram(gTrainerSprites[gender].frontPic.data, dest);
DecompressDataWithHeaderVram(gTrainerSprites[gender].frontPic.data, dest);
LoadPalette(gTrainerSprites[gender].palette.data, palOffset, PLTT_SIZE_4BPP);
}

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "braille_puzzles.h"
#include "decompress.h"
#include "event_data.h"
#include "event_scripts.h"
#include "field_effect.h"
@ -216,8 +217,8 @@ static void Task_ExitCaveTransition1(u8 taskId)
static void Task_ExitCaveTransition2(u8 taskId)
{
SetGpuReg(REG_OFFSET_DISPCNT, 0);
LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
DecompressDataWithHeaderVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
DecompressDataWithHeaderVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
LoadPalette(sCaveTransitionPalette_White, BG_PLTT_ID(14), PLTT_SIZE_4BPP);
LoadPalette(&sCaveTransitionPalette_Enter[8], BG_PLTT_ID(14), PLTT_SIZEOF(8));
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0
@ -301,8 +302,8 @@ static void Task_EnterCaveTransition1(u8 taskId)
static void Task_EnterCaveTransition2(u8 taskId)
{
SetGpuReg(REG_OFFSET_DISPCNT, 0);
LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
DecompressDataWithHeaderVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
DecompressDataWithHeaderVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);

View File

@ -1059,8 +1059,8 @@ static void MainCB2_EndIntro(void)
static void LoadCopyrightGraphics(u16 tilesetAddress, u16 tilemapAddress, u16 paletteOffset)
{
LZ77UnCompVram(gIntroCopyright_Gfx, (void *)(VRAM + tilesetAddress));
LZ77UnCompVram(gIntroCopyright_Tilemap, (void *)(VRAM + tilemapAddress));
DecompressDataWithHeaderVram(gIntroCopyright_Gfx, (void *)(VRAM + tilesetAddress));
DecompressDataWithHeaderVram(gIntroCopyright_Tilemap, (void *)(VRAM + tilemapAddress));
LoadPalette(gIntroCopyright_Pal, paletteOffset, PLTT_SIZE_4BPP);
}
@ -1184,14 +1184,14 @@ void Task_Scene1_Load(u8 taskId)
SetGpuReg(REG_OFFSET_BG2VOFS, 80);
SetGpuReg(REG_OFFSET_BG1VOFS, 24);
SetGpuReg(REG_OFFSET_BG0VOFS, 40);
LZ77UnCompVram(sIntro1Bg_Gfx, (void *)VRAM);
LZ77UnCompVram(sIntro1Bg0_Tilemap, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(sIntro1Bg_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(sIntro1Bg0_Tilemap, (void *)(BG_CHAR_ADDR(2)));
DmaClear16(3, BG_SCREEN_ADDR(17), BG_SCREEN_SIZE);
LZ77UnCompVram(sIntro1Bg1_Tilemap, (void *)(BG_SCREEN_ADDR(18)));
DecompressDataWithHeaderVram(sIntro1Bg1_Tilemap, (void *)(BG_SCREEN_ADDR(18)));
DmaClear16(3, BG_SCREEN_ADDR(19), BG_SCREEN_SIZE);
LZ77UnCompVram(sIntro1Bg2_Tilemap, (void *)(BG_SCREEN_ADDR(20)));
DecompressDataWithHeaderVram(sIntro1Bg2_Tilemap, (void *)(BG_SCREEN_ADDR(20)));
DmaClear16(3, BG_SCREEN_ADDR(21), BG_SCREEN_SIZE);
LZ77UnCompVram(sIntro1Bg3_Tilemap, (void *)(BG_SCREEN_ADDR(22)));
DecompressDataWithHeaderVram(sIntro1Bg3_Tilemap, (void *)(BG_SCREEN_ADDR(22)));
DmaClear16(3, BG_SCREEN_ADDR(23), BG_SCREEN_SIZE);
LoadPalette(sIntro1Bg_Pal, BG_PLTT_ID(0), sizeof(sIntro1Bg_Pal));
SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(22) | BGCNT_16COLOR | BGCNT_TXT256x512);
@ -1730,8 +1730,8 @@ static void SpriteCB_Manectric(struct Sprite *sprite)
static void Task_Scene3_Load(u8 taskId)
{
IntroResetGpuRegs();
LZ77UnCompVram(sIntroPokeball_Gfx, (void *)VRAM);
LZ77UnCompVram(sIntroPokeball_Tilemap, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(sIntroPokeball_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(sIntroPokeball_Tilemap, (void *)(BG_CHAR_ADDR(1)));
LoadPalette(sIntroPokeball_Pal, BG_PLTT_ID(0), sizeof(sIntroPokeball_Pal));
gTasks[taskId].tAlpha = 0;
gTasks[taskId].tZoomDiv = 0;
@ -1785,10 +1785,10 @@ static void Task_Scene3_LoadGroudon(u8 taskId)
ResetSpriteData();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
LZDecompressVram(gIntroGroudon_Gfx, (void *)VRAM);
LZDecompressVram(gIntroGroudon_Tilemap, (void *)(BG_CHAR_ADDR(3)));
LZDecompressVram(gIntroLegendBg_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gIntroGroudonBg_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gIntroGroudon_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gIntroGroudon_Tilemap, (void *)(BG_CHAR_ADDR(3)));
DecompressDataWithHeaderVram(gIntroLegendBg_Gfx, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gIntroGroudonBg_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]);
LoadSpritePalette(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]);
CpuCopy16(gIntro3Bg_Pal, gPlttBufferUnfaded, sizeof(gIntro3Bg_Pal));
@ -2060,9 +2060,9 @@ static void SpriteCB_GroudonRocks(struct Sprite *sprite)
static void Task_Scene3_LoadKyogre(u8 taskId)
{
ResetSpriteData();
LZDecompressVram(gIntroKyogre_Gfx, (void *)VRAM);
LZDecompressVram(gIntroKyogre_Tilemap, (void *)(BG_CHAR_ADDR(3)));
LZDecompressVram(gIntroKyogreBg_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gIntroKyogre_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gIntroKyogre_Tilemap, (void *)(BG_CHAR_ADDR(3)));
DecompressDataWithHeaderVram(gIntroKyogreBg_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
LoadCompressedSpriteSheet(sSpriteSheet_Bubbles);
LoadSpritePalette(sSpritePalette_Bubbles);
BeginNormalPaletteFade(PALETTES_ALL & ~1, 0, 16, 0, RGB_WHITEALPHA);
@ -2368,16 +2368,16 @@ static void Task_Scene3_LoadClouds1(u8 taskId)
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
LZDecompressVram(gIntroClouds_Gfx, (void *)VRAM);
LZDecompressVram(gIntroClouds_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gIntroCloudsSun_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gIntroClouds_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gIntroClouds_Gfx, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gIntroCloudsSun_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
gTasks[taskId].func = Task_Scene3_LoadClouds2;
}
static void Task_Scene3_LoadClouds2(u8 taskId)
{
LZDecompressVram(gIntroCloudsLeft_Tilemap, (void *)(BG_CHAR_ADDR(3)));
LZDecompressVram(gIntroCloudsRight_Tilemap, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gIntroCloudsLeft_Tilemap, (void *)(BG_CHAR_ADDR(3)));
DecompressDataWithHeaderVram(gIntroCloudsRight_Tilemap, (void *)(BG_SCREEN_ADDR(26)));
gTasks[taskId].func = Task_Scene3_InitClouds;
}
@ -2435,10 +2435,10 @@ static void Task_Scene3_Clouds(u8 taskId)
static void Task_Scene3_LoadLightning(u8 taskId)
{
LZDecompressVram(gIntroRayquaza_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
LZDecompressVram(gIntroRayquazaClouds_Tilemap, (void *)(BG_CHAR_ADDR(3)));
LZDecompressVram(gIntroRayquaza_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZDecompressVram(gIntroRayquazaClouds_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gIntroRayquaza_Tilemap, (void *)(BG_SCREEN_ADDR(28)));
DecompressDataWithHeaderVram(gIntroRayquazaClouds_Tilemap, (void *)(BG_CHAR_ADDR(3)));
DecompressDataWithHeaderVram(gIntroRayquaza_Gfx, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(gIntroRayquazaClouds_Gfx, (void *)VRAM);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0
| DISPCNT_OBJ_1D_MAP
| DISPCNT_BG0_ON

View File

@ -728,8 +728,8 @@ static void Task_BicycleBgAnimation(u8);
void LoadIntroPart2Graphics(u8 scenery)
{
LZ77UnCompVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZ77UnCompVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15)));
DecompressDataWithHeaderVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15)));
LoadPalette(&sGrass_Pal, BG_PLTT_ID(15), sizeof(sGrass_Pal));
switch (scenery)
{
@ -737,16 +737,16 @@ void LoadIntroPart2Graphics(u8 scenery)
default:
// Never reached, only called with an argument of 1
// Clouds are never used in this part of the intro
LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM));
LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(sCloudsBg_Gfx, (void *)(VRAM));
DecompressDataWithHeaderVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&sCloudsBg_Pal, BG_PLTT_ID(0), sizeof(sCloudsBg_Pal));
LoadCompressedSpriteSheet(sSpriteSheet_Clouds);
LoadPalette(&sClouds_Pal, OBJ_PLTT_ID(0), sizeof(sClouds_Pal));
CreateCloudSprites();
break;
case 1:
LZ77UnCompVram(sTrees_Gfx, (void *)(VRAM));
LZ77UnCompVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(sTrees_Gfx, (void *)(VRAM));
DecompressDataWithHeaderVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&sTrees_Pal, BG_PLTT_ID(0), sizeof(sTrees_Pal));
LoadCompressedSpriteSheet(sSpriteSheet_TreesSmall);
LoadPalette(&sTreesSmall_Pal, OBJ_PLTT_ID(0), sizeof(sTreesSmall_Pal));
@ -837,36 +837,36 @@ void SetIntroPart2BgCnt(u8 scenery)
void LoadCreditsSceneGraphics(u8 scene)
{
LZ77UnCompVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1)));
LZ77UnCompVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15)));
DecompressDataWithHeaderVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1)));
DecompressDataWithHeaderVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15)));
switch (scene)
{
case SCENE_OCEAN_MORNING:
default:
LoadPalette(&sGrass_Pal, BG_PLTT_ID(15), sizeof(sGrass_Pal));
LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM));
LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(sCloudsBg_Gfx, (void *)(VRAM));
DecompressDataWithHeaderVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&sCloudsBg_Pal, BG_PLTT_ID(0), sizeof(sCloudsBg_Pal));
LoadCompressedSpriteSheet(sSpriteSheet_Clouds);
LZ77UnCompVram(sClouds_Gfx, (void *)(OBJ_VRAM0));
DecompressDataWithHeaderVram(sClouds_Gfx, (void *)(OBJ_VRAM0));
LoadPalette(&sClouds_Pal, OBJ_PLTT_ID(0), sizeof(sClouds_Pal));
CreateCloudSprites();
break;
case SCENE_OCEAN_SUNSET:
LoadPalette(&sGrassSunset_Pal, BG_PLTT_ID(15), sizeof(sGrassSunset_Pal));
LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM));
LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(sCloudsBg_Gfx, (void *)(VRAM));
DecompressDataWithHeaderVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&sCloudsBgSunset_Pal, BG_PLTT_ID(0), sizeof(sCloudsBgSunset_Pal));
LoadCompressedSpriteSheet(sSpriteSheet_Clouds);
LZ77UnCompVram(sClouds_Gfx, (void *)(OBJ_VRAM0));
DecompressDataWithHeaderVram(sClouds_Gfx, (void *)(OBJ_VRAM0));
LoadPalette(&sCloudsSunset_Pal, OBJ_PLTT_ID(0), sizeof(sCloudsSunset_Pal));
CreateCloudSprites();
break;
case SCENE_FOREST_RIVAL_ARRIVE:
case SCENE_FOREST_CATCH_RIVAL:
LoadPalette(&sGrassSunset_Pal, BG_PLTT_ID(15), sizeof(sGrassSunset_Pal));
LZ77UnCompVram(sTrees_Gfx, (void *)(VRAM));
LZ77UnCompVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(sTrees_Gfx, (void *)(VRAM));
DecompressDataWithHeaderVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&sTreesSunset_Pal, BG_PLTT_ID(0), sizeof(sTreesSunset_Pal));
LoadCompressedSpriteSheet(sSpriteSheet_TreesSmall);
LoadPalette(&sTreesSunset_Pal, OBJ_PLTT_ID(0), sizeof(sTreesSunset_Pal));
@ -874,8 +874,8 @@ void LoadCreditsSceneGraphics(u8 scene)
break;
case SCENE_CITY_NIGHT:
LoadPalette(&sGrassNight_Pal, BG_PLTT_ID(15), sizeof(sGrassNight_Pal));
LZ77UnCompVram(sHouses_Gfx, (void *)(VRAM));
LZ77UnCompVram(sHouses_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(sHouses_Gfx, (void *)(VRAM));
DecompressDataWithHeaderVram(sHouses_Tilemap, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&sHouses_Pal, BG_PLTT_ID(0), sizeof(sHouses_Pal));
LoadCompressedSpriteSheet(sSpriteSheet_HouseSilhouette);
LoadPalette(&sHouseSilhouette_Pal, OBJ_PLTT_ID(0), sizeof(sHouseSilhouette_Pal));

View File

@ -99,7 +99,7 @@ u8 AddItemIconSprite(u16 tilesTag, u16 paletteTag, u16 itemId)
struct SpritePalette spritePalette;
struct SpriteTemplate *spriteTemplate;
LZDecompressWram(GetItemIconPic(itemId), gItemIconDecompressionBuffer);
DecompressDataWithHeaderWram(GetItemIconPic(itemId), gItemIconDecompressionBuffer);
CopyItemIconPicTo4x4Buffer(gItemIconDecompressionBuffer, gItemIcon4x4Buffer);
spriteSheet.data = gItemIcon4x4Buffer;
spriteSheet.size = 0x200;
@ -136,7 +136,7 @@ u8 AddCustomItemIconSprite(const struct SpriteTemplate *customSpriteTemplate, u1
struct SpritePalette spritePalette;
struct SpriteTemplate *spriteTemplate;
LZDecompressWram(GetItemIconPic(itemId), gItemIconDecompressionBuffer);
DecompressDataWithHeaderWram(GetItemIconPic(itemId), gItemIconDecompressionBuffer);
CopyItemIconPicTo4x4Buffer(gItemIconDecompressionBuffer, gItemIcon4x4Buffer);
spriteSheet.data = gItemIcon4x4Buffer;
spriteSheet.size = 0x200;

View File

@ -827,7 +827,7 @@ static bool8 LoadBagMenu_Graphics(void)
case 1:
if (FreeTempTileDataBuffersIfPossible() != TRUE)
{
LZDecompressWram(gBagScreen_GfxTileMap, gBagMenu->tilemapBuffer);
DecompressDataWithHeaderWram(gBagScreen_GfxTileMap, gBagMenu->tilemapBuffer);
gBagMenu->graphicsLoadState++;
}
break;

View File

@ -1295,8 +1295,8 @@ static void Task_NewGameBirchSpeech_Init(u8 taskId)
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
LZ77UnCompVram(sBirchSpeechShadowGfx, (void *)VRAM);
LZ77UnCompVram(sBirchSpeechBgMap, (void *)(BG_SCREEN_ADDR(7)));
DecompressDataWithHeaderVram(sBirchSpeechShadowGfx, (void *)VRAM);
DecompressDataWithHeaderVram(sBirchSpeechBgMap, (void *)(BG_SCREEN_ADDR(7)));
LoadPalette(sBirchSpeechBgPals, BG_PLTT_ID(0), 2 * PLTT_SIZE_4BPP);
LoadPalette(&sBirchSpeechBgGradientPal[8], BG_PLTT_ID(0) + 1, PLTT_SIZEOF(8));
ScanlineEffect_Stop();
@ -1830,8 +1830,8 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void)
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
ResetPaletteFade();
LZ77UnCompVram(sBirchSpeechShadowGfx, (u8 *)VRAM);
LZ77UnCompVram(sBirchSpeechBgMap, (u8 *)(BG_SCREEN_ADDR(7)));
DecompressDataWithHeaderVram(sBirchSpeechShadowGfx, (u8 *)VRAM);
DecompressDataWithHeaderVram(sBirchSpeechBgMap, (u8 *)(BG_SCREEN_ADDR(7)));
LoadPalette(sBirchSpeechBgPals, BG_PLTT_ID(0), 2 * PLTT_SIZE_4BPP);
LoadPalette(&sBirchSpeechBgGradientPal[1], BG_PLTT_ID(0) + 1, PLTT_SIZEOF(8));
ResetTasks();

View File

@ -2,6 +2,7 @@
#include "malloc.h"
#include "bg.h"
#include "blit.h"
#include "decompress.h"
#include "dma3.h"
#include "event_data.h"
#include "field_weather.h"
@ -1943,23 +1944,15 @@ void task_free_buf_after_copying_tile_data_to_vram(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;
}

View File

@ -243,7 +243,7 @@ s32 WonderCard_Enter(void)
LoadPalette(GetTextWindowPalette(1), BG_PLTT_ID(2), PLTT_SIZE_4BPP);
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, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT, 1, 0x008, 0);
CopyBgTilemapBufferToVram(2);
break;
@ -706,7 +706,7 @@ s32 WonderNews_Enter(void)
LoadPalette(GetTextWindowPalette(1), BG_PLTT_ID(2), PLTT_SIZE_4BPP);
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, 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);

View File

@ -27,6 +27,7 @@
#include "overworld.h"
#include "walda_phrase.h"
#include "main.h"
#include "decompress.h"
#include "constants/event_objects.h"
#include "constants/rgb.h"
@ -1886,7 +1887,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);

View File

@ -904,7 +904,7 @@ static bool8 AllocPartyMenuBgGfx(void)
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
{
LZDecompressWram(gPartyMenuBg_Tilemap, sPartyBgTilemapBuffer);
DecompressDataWithHeaderWram(gPartyMenuBg_Tilemap, sPartyBgTilemapBuffer);
sPartyMenuInternal->data[0]++;
}
break;

View File

@ -1567,7 +1567,7 @@ void LoadBallGfx(u8 ballId)
case BALL_REPEAT:
case BALL_SAFARI:
var = GetSpriteTileStartByTag(gBallSpriteSheets[ballId].tag);
LZDecompressVram(gOpenPokeballGfx, (void *)(OBJ_VRAM0 + 0x100 + var * 32));
DecompressDataWithHeaderVram(gOpenPokeballGfx, (void *)(OBJ_VRAM0 + 0x100 + var * 32));
break;
}
}

View File

@ -653,7 +653,7 @@ static bool8 LoadPokeblockMenuGfx(void)
case 1:
if (FreeTempTileDataBuffersIfPossible() != TRUE)
{
LZDecompressWram(gMenuPokeblock_Tilemap, sPokeblockMenu->tilemap);
DecompressDataWithHeaderWram(gMenuPokeblock_Tilemap, sPokeblockMenu->tilemap);
sPokeblockMenu->gfxState++;
}
break;

View File

@ -697,7 +697,7 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon)
case 7:
if (FreeTempTileDataBuffersIfPossible() != TRUE)
{
LZDecompressWram(gPokeblockFeedBg_Tilemap, sPokeblockFeed->tilemapBuffer);
DecompressDataWithHeaderWram(gPokeblockFeedBg_Tilemap, sPokeblockFeed->tilemapBuffer);
sPokeblockFeed->loadGfxState++;
}
break;

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "bg.h"
#include "decompress.h"
#include "event_data.h"
#include "gpu_regs.h"
#include "graphics.h"
@ -1000,7 +1001,7 @@ static void LoadAreaUnknownGraphics(void)
.size = sizeof(sPokedexAreaScreen->areaUnknownGraphicsBuffer),
.tag = TAG_AREA_UNKNOWN,
};
LZ77UnCompWram(gPokedexAreaScreenAreaUnknown_Gfx, sPokedexAreaScreen->areaUnknownGraphicsBuffer);
DecompressDataWithHeaderWram(gPokedexAreaScreenAreaUnknown_Gfx, sPokedexAreaScreen->areaUnknownGraphicsBuffer);
LoadSpriteSheet(&spriteSheet);
LoadSpritePalette(&sAreaUnknownSpritePalette);
}

View File

@ -927,73 +927,73 @@ static void LoadBattleBg(u8 battleBgType, u8 battleEnvironment)
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(sBattleEnvironmentTable[battleEnvironment].tileset, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(sBattleEnvironmentTable[battleEnvironment].tilemap, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[battleEnvironment].tileset, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(sBattleEnvironmentTable[battleEnvironment].tilemap, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(sBattleEnvironmentTable[battleEnvironment].palette, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_BuildingGym, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumMagma, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumAqua, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumSidney, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumPhoebe, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumGlacia, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumDrake, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Frontier, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_LEADER:
LZDecompressVram(gBattleEnvironmentTiles_Building, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Building, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Building, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Building, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_BuildingLeader, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_WALLACE:
LZDecompressVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Stadium, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Stadium, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_StadiumWallace, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GROUDON:
LZDecompressVram(gBattleEnvironmentTiles_Cave, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Cave, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Cave, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Cave, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Groudon, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_KYOGRE:
LZDecompressVram(gBattleEnvironmentTiles_Water, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Water, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Water, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Water, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Kyogre, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_RAYQUAZA:
LZDecompressVram(gBattleEnvironmentTiles_Rayquaza, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleEnvironmentTilemap_Rayquaza, (void*)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(gBattleEnvironmentTiles_Rayquaza, (void*)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(gBattleEnvironmentTilemap_Rayquaza, (void*)(BG_SCREEN_ADDR(26)));
LoadPalette(gBattleEnvironmentPalette_Rayquaza, 0x20, 0x60);
break;
}

View File

@ -3809,7 +3809,7 @@ static void SetScrollingBackground(void)
{
SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(31));
DecompressAndLoadBgGfxUsingHeap(3, sScrollingBg_Gfx, 0, 0, 0);
LZ77UnCompVram(sScrollingBg_Tilemap, (void *)BG_SCREEN_ADDR(31));
DecompressDataWithHeaderVram(sScrollingBg_Tilemap, (void *)BG_SCREEN_ADDR(31));
}
static void ScrollBackground(void)
@ -3822,7 +3822,7 @@ static void LoadPokeStorageMenuGfx(void)
{
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
DecompressAndLoadBgGfxUsingHeap(1, gStorageSystemMenu_Gfx, 0, 0, 0);
LZ77UnCompWram(sDisplayMenu_Tilemap, sStorage->displayMenuTilemapBuffer);
DecompressDataWithHeaderWram(sDisplayMenu_Tilemap, sStorage->displayMenuTilemapBuffer);
SetBgTilemapBuffer(1, sStorage->displayMenuTilemapBuffer);
ShowBg(1);
ScheduleBgCopyTilemapToVram(1);
@ -4040,7 +4040,7 @@ static void UpdateWaveformAnimation(void)
static void InitSupplementalTilemaps(void)
{
LZ77UnCompWram(gStorageSystemPartyMenu_Tilemap, sStorage->partyMenuTilemapBuffer);
DecompressDataWithHeaderWram(gStorageSystemPartyMenu_Tilemap, sStorage->partyMenuTilemapBuffer);
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);
@ -5387,7 +5387,7 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction)
if (wallpaperId != WALLPAPER_FRIENDS)
{
wallpaper = &sWallpapers[wallpaperId];
LZ77UnCompWram(wallpaper->tilemap, sStorage->wallpaperTilemap);
DecompressDataWithHeaderWram(wallpaper->tilemap, sStorage->wallpaperTilemap);
DrawWallpaper(sStorage->wallpaperTilemap, sStorage->wallpaperLoadDir, sStorage->wallpaperOffset);
if (sStorage->wallpaperLoadDir != 0)
@ -5401,7 +5401,7 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction)
else
{
wallpaper = &sWaldaWallpapers[GetWaldaWallpaperPatternId()];
LZ77UnCompWram(wallpaper->tilemap, sStorage->wallpaperTilemap);
DecompressDataWithHeaderWram(wallpaper->tilemap, sStorage->wallpaperTilemap);
DrawWallpaper(sStorage->wallpaperTilemap, sStorage->wallpaperLoadDir, sStorage->wallpaperOffset);
CpuCopy16(wallpaper->palettes, sStorage->wallpaperTilemap, 0x40);
@ -9180,7 +9180,7 @@ static void LoadItemIconGfx(u8 id, const u32 *itemTiles, const u16 *itemPal)
return;
CpuFastFill(0, sStorage->itemIconBuffer, 0x200);
LZ77UnCompWram(itemTiles, sStorage->tileBuffer);
DecompressDataWithHeaderWram(itemTiles, sStorage->tileBuffer);
for (i = 0; i < 3; i++)
CpuFastCopy(&sStorage->tileBuffer[i * 0x60], &sStorage->itemIconBuffer[i * 0x80], 0x60);

View File

@ -1418,24 +1418,24 @@ static bool8 DecompressGraphics(void)
case 1:
if (FreeTempTileDataBuffersIfPossible() != 1)
{
LZDecompressWram(gSummaryPage_Info_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0]);
DecompressDataWithHeaderWram(gSummaryPage_Info_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0]);
sMonSummaryScreen->switchCounter++;
}
break;
case 2:
LZDecompressWram(gSummaryPage_InfoEgg_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][1]);
DecompressDataWithHeaderWram(gSummaryPage_InfoEgg_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][1]);
sMonSummaryScreen->switchCounter++;
break;
case 3:
LZDecompressWram(gSummaryPage_Skills_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_SKILLS][1]);
DecompressDataWithHeaderWram(gSummaryPage_Skills_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_SKILLS][1]);
sMonSummaryScreen->switchCounter++;
break;
case 4:
LZDecompressWram(gSummaryPage_BattleMoves_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][1]);
DecompressDataWithHeaderWram(gSummaryPage_BattleMoves_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][1]);
sMonSummaryScreen->switchCounter++;
break;
case 5:
LZDecompressWram(gSummaryPage_ContestMoves_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_CONTEST_MOVES][1]);
DecompressDataWithHeaderWram(gSummaryPage_ContestMoves_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_CONTEST_MOVES][1]);
sMonSummaryScreen->switchCounter++;
break;
case 6:

View File

@ -222,7 +222,7 @@ static u32 LoopedTask_OpenConditionGraphMenu(s32 state)
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
LZ77UnCompVram(gPokenavCondition_Tilemap, menu->tilemapBuffers[0]);
DecompressDataWithHeaderVram(gPokenavCondition_Tilemap, menu->tilemapBuffers[0]);
SetBgTilemapBuffer(3, menu->tilemapBuffers[0]);
if (IsConditionMenuSearchMode() == TRUE)
CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4);
@ -236,7 +236,7 @@ static u32 LoopedTask_OpenConditionGraphMenu(s32 state)
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
LZ77UnCompVram(sConditionGraphData_Tilemap, menu->tilemapBuffers[2]);
DecompressDataWithHeaderVram(sConditionGraphData_Tilemap, menu->tilemapBuffers[2]);
SetBgTilemapBuffer(2, menu->tilemapBuffers[2]);
CopyBgTilemapBufferToVram(2);
CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, BG_PLTT_ID(3), PLTT_SIZE_4BPP);

View File

@ -685,7 +685,7 @@ static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
tag = sMenuLeftHeaderSpriteSheets[menuGfxId].tag;
size = GetDecompressedDataSize(sMenuLeftHeaderSpriteSheets[menuGfxId].data);
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], OBJ_PLTT_ID(IndexOfSpritePaletteTag(1)), PLTT_SIZE_4BPP);
LZDecompressWram(sMenuLeftHeaderSpriteSheets[menuGfxId].data, menu->leftHeaderMenuBuffer);
DecompressDataWithHeaderWram(sMenuLeftHeaderSpriteSheets[menuGfxId].data, menu->leftHeaderMenuBuffer);
RequestDma3Copy(menu->leftHeaderMenuBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1);
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sMenuLeftHeaderSpriteSheets[menuGfxId].size;
@ -707,7 +707,7 @@ static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId)
tag = sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].tag;
size = GetDecompressedDataSize(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data);
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], OBJ_PLTT_ID(IndexOfSpritePaletteTag(2)), PLTT_SIZE_4BPP);
LZDecompressWram(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data, menu->leftHeaderSubMenuBuffer);
DecompressDataWithHeaderWram(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data, menu->leftHeaderSubMenuBuffer);
RequestDma3Copy(menu->leftHeaderSubMenuBuffer, (void *)OBJ_VRAM0 + 0x800 + (GetSpriteTileStartByTag(2) * 32), size, 1);
}

View File

@ -657,7 +657,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState)
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
if (taskState < NUM_CITY_MAPS)
{
LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]);
DecompressDataWithHeaderWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]);
return LT_INC_AND_CONTINUE;
}

View File

@ -1599,9 +1599,9 @@ static void LoadDuoFightSceneGfx(void)
DecompressAndCopyTileDataToVram(0, gRaySceneDuoFight_Clouds_Gfx, 0, 0, 0);
while (FreeTempTileDataBuffersIfPossible())
;
LZDecompressWram(gRaySceneDuoFight_Clouds2_Tilemap, sRayScene->tilemapBuffers[0]);
LZDecompressWram(gRaySceneDuoFight_Clouds1_Tilemap, sRayScene->tilemapBuffers[1]);
LZDecompressWram(gRaySceneDuoFight_Clouds3_Tilemap, sRayScene->tilemapBuffers[2]);
DecompressDataWithHeaderWram(gRaySceneDuoFight_Clouds2_Tilemap, sRayScene->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gRaySceneDuoFight_Clouds1_Tilemap, sRayScene->tilemapBuffers[1]);
DecompressDataWithHeaderWram(gRaySceneDuoFight_Clouds3_Tilemap, sRayScene->tilemapBuffers[2]);
LoadPalette(gRaySceneDuoFight_Clouds_Pal, BG_PLTT_ID(0), 2 * PLTT_SIZE_4BPP);
LoadCompressedSpriteSheet(&sSpriteSheet_DuoFight_Groudon);
LoadCompressedSpriteSheet(&sSpriteSheet_DuoFight_GroudonShoulder);
@ -2039,9 +2039,9 @@ static void LoadTakesFlightSceneGfx(void)
DecompressAndCopyTileDataToVram(2, gRaySceneTakesFlight_Rayquaza_Gfx, 0, 0, 0);
while (FreeTempTileDataBuffersIfPossible())
;
LZDecompressWram(gRaySceneDuoFight_Clouds2_Tilemap, sRayScene->tilemapBuffers[0]);
LZDecompressWram(gRaySceneTakesFlight_Bg_Tilemap, sRayScene->tilemapBuffers[1]);
LZDecompressWram(gRaySceneTakesFlight_Rayquaza_Tilemap, sRayScene->tilemapBuffers[2]);
DecompressDataWithHeaderWram(gRaySceneDuoFight_Clouds2_Tilemap, sRayScene->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gRaySceneTakesFlight_Bg_Tilemap, sRayScene->tilemapBuffers[1]);
DecompressDataWithHeaderWram(gRaySceneTakesFlight_Rayquaza_Tilemap, sRayScene->tilemapBuffers[2]);
LoadPalette(gRaySceneTakesFlight_Rayquaza_Pal, BG_PLTT_ID(0), 2 * PLTT_SIZE_4BPP);
LoadCompressedSpriteSheet(&sSpriteSheet_TakesFlight_Smoke);
LoadSpritePalette(&sSpritePal_TakesFlight_Smoke);
@ -2242,8 +2242,8 @@ static void LoadDescendsSceneGfx(void)
DecompressAndCopyTileDataToVram(1, gRaySceneDescends_Bg_Gfx, 0, 0, 0);
while (FreeTempTileDataBuffersIfPossible())
;
LZDecompressWram(gRaySceneDescends_Light_Tilemap, sRayScene->tilemapBuffers[0]);
LZDecompressWram(gRaySceneDescends_Bg_Tilemap, sRayScene->tilemapBuffers[3]);
DecompressDataWithHeaderWram(gRaySceneDescends_Light_Tilemap, sRayScene->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gRaySceneDescends_Bg_Tilemap, sRayScene->tilemapBuffers[3]);
CpuFastFill16(0, sRayScene->tilemapBuffers[2], BG_SCREEN_SIZE);
CpuFastCopy(sRayScene->tilemapBuffers[3], sRayScene->tilemapBuffers[1], BG_SCREEN_SIZE);
CpuFastFill16(0, &sRayScene->tilemapBuffers[1][0x100], 0x340);
@ -2493,10 +2493,10 @@ static void LoadChargesSceneGfx(void)
DecompressAndCopyTileDataToVram(3, gRaySceneCharges_Bg_Gfx, 0, 0, 0);
while (FreeTempTileDataBuffersIfPossible())
;
LZDecompressWram(gRaySceneCharges_Orbs_Tilemap, sRayScene->tilemapBuffers[0]);
LZDecompressWram(gRaySceneCharges_Rayquaza_Tilemap, sRayScene->tilemapBuffers[1]);
LZDecompressWram(gRaySceneCharges_Streaks_Tilemap, sRayScene->tilemapBuffers[2]);
LZDecompressWram(gRaySceneCharges_Bg_Tilemap, sRayScene->tilemapBuffers[3]);
DecompressDataWithHeaderWram(gRaySceneCharges_Orbs_Tilemap, sRayScene->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gRaySceneCharges_Rayquaza_Tilemap, sRayScene->tilemapBuffers[1]);
DecompressDataWithHeaderWram(gRaySceneCharges_Streaks_Tilemap, sRayScene->tilemapBuffers[2]);
DecompressDataWithHeaderWram(gRaySceneCharges_Bg_Tilemap, sRayScene->tilemapBuffers[3]);
LoadPalette(gRaySceneCharges_Bg_Pal, BG_PLTT_ID(0), 4 * PLTT_SIZE_4BPP);
}
@ -2678,9 +2678,9 @@ static void LoadChasesAwaySceneGfx(void)
DecompressAndCopyTileDataToVram(0, gRaySceneChasesAway_Light_Gfx, 0, 0, 0);
while (FreeTempTileDataBuffersIfPossible())
;
LZDecompressWram(gRaySceneChasesAway_Bg_Tilemap, sRayScene->tilemapBuffers[1]);
LZDecompressWram(gRaySceneChasesAway_Light_Tilemap, sRayScene->tilemapBuffers[0]);
LZDecompressWram(gRaySceneChasesAway_Ring_Tilemap, sRayScene->tilemapBuffers[2]);
DecompressDataWithHeaderWram(gRaySceneChasesAway_Bg_Tilemap, sRayScene->tilemapBuffers[1]);
DecompressDataWithHeaderWram(gRaySceneChasesAway_Light_Tilemap, sRayScene->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gRaySceneChasesAway_Ring_Tilemap, sRayScene->tilemapBuffers[2]);
LoadPalette(gRaySceneChasesAway_Bg_Pal, BG_PLTT_ID(0), 3 * PLTT_SIZE_4BPP);
LoadCompressedSpriteSheet(&sSpriteSheet_ChasesAway_Groudon);
LoadCompressedSpriteSheet(&sSpriteSheet_ChasesAway_GroudonTail);

View File

@ -20,6 +20,7 @@
#include "field_specials.h"
#include "fldeff.h"
#include "region_map.h"
#include "decompress.h"
#include "constants/region_map_sections.h"
#include "heal_location.h"
#include "constants/field_specials.h"
@ -549,7 +550,7 @@ bool8 LoadRegionMapGfx(void)
if (sRegionMap->bgManaged)
DecompressAndCopyTileDataToVram(sRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0);
else
LZ77UnCompVram(sRegionMapBg_GfxLZ, (u16 *)BG_CHAR_ADDR(2));
DecompressDataWithHeaderVram(sRegionMapBg_GfxLZ, (u16 *)BG_CHAR_ADDR(2));
break;
case 1:
if (sRegionMap->bgManaged)
@ -559,7 +560,7 @@ bool8 LoadRegionMapGfx(void)
}
else
{
LZ77UnCompVram(sRegionMapBg_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28));
DecompressDataWithHeaderVram(sRegionMapBg_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28));
}
break;
case 2:
@ -567,10 +568,10 @@ bool8 LoadRegionMapGfx(void)
LoadPalette(sRegionMapBg_Pal, BG_PLTT_ID(7), 3 * PLTT_SIZE_4BPP);
break;
case 3:
LZ77UnCompWram(sRegionMapCursorSmallGfxLZ, sRegionMap->cursorSmallImage);
DecompressDataWithHeaderWram(sRegionMapCursorSmallGfxLZ, sRegionMap->cursorSmallImage);
break;
case 4:
LZ77UnCompWram(sRegionMapCursorLargeGfxLZ, sRegionMap->cursorLargeImage);
DecompressDataWithHeaderWram(sRegionMapCursorLargeGfxLZ, sRegionMap->cursorLargeImage);
break;
case 5:
InitMapBasedOnPlayerLocation();
@ -1707,11 +1708,11 @@ void CB2_OpenFlyMap(void)
gMain.state++;
break;
case 5:
LZ77UnCompVram(sRegionMapFrameGfxLZ, (u16 *)BG_CHAR_ADDR(3));
DecompressDataWithHeaderVram(sRegionMapFrameGfxLZ, (u16 *)BG_CHAR_ADDR(3));
gMain.state++;
break;
case 6:
LZ77UnCompVram(sRegionMapFrameTilemapLZ, (u16 *)BG_SCREEN_ADDR(30));
DecompressDataWithHeaderVram(sRegionMapFrameTilemapLZ, (u16 *)BG_SCREEN_ADDR(30));
gMain.state++;
break;
case 7:
@ -1830,7 +1831,7 @@ static void LoadFlyDestIcons(void)
{
struct SpriteSheet sheet;
LZ77UnCompWram(sFlyTargetIcons_Gfx, sFlyMap->tileBuffer);
DecompressDataWithHeaderWram(sFlyTargetIcons_Gfx, sFlyMap->tileBuffer);
sheet.data = sFlyMap->tileBuffer;
sheet.size = sizeof(sFlyMap->tileBuffer);
sheet.tag = TAG_FLY_ICON;

View File

@ -3833,9 +3833,7 @@ static void SpriteCB_GridSquare(struct Sprite *sprite)
static void CreateWheelCenterSprite(void)
{
u8 spriteId;
LoadCompressedSpriteSheet(&sSpriteSheet_WheelCenter);
// This sprite id isn't saved because it doesn't need to be referenced again
// but by virtue of creation order it's SPR_WHEEL_CENTER
spriteId = CreateSprite(&sSpriteTemplate_WheelCenter, 116, 80, 81);

View File

@ -205,10 +205,10 @@ static void CB2_SaveFailedScreen(void)
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
LZ77UnCompVram(gBirchBagGrass_Gfx, (void *)VRAM);
LZ77UnCompVram(gBirchBagTilemap, (void *)(BG_SCREEN_ADDR(14)));
LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(15)));
LZ77UnCompVram(sSaveFailedClockGfx, (void *)(OBJ_VRAM0 + 0x20));
DecompressDataWithHeaderVram(gBirchBagGrass_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gBirchBagTilemap, (void *)(BG_SCREEN_ADDR(14)));
DecompressDataWithHeaderVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(15)));
DecompressDataWithHeaderVram(sSaveFailedClockGfx, (void *)(OBJ_VRAM0 + 0x20));
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
SetBgTilemapBuffer(0, sSaveFailedBuffers->tilemapBuffer);

View File

@ -745,7 +745,7 @@ static void BuyMenuInitBgs(void)
static void BuyMenuDecompressBgGraphics(void)
{
DecompressAndCopyTileDataToVram(1, gShopMenu_Gfx, 0x3A0, 0x3E3, 0);
LZDecompressWram(gShopMenu_Tilemap, sShopData->tilemapBuffers[0]);
DecompressDataWithHeaderWram(gShopMenu_Tilemap, sShopData->tilemapBuffers[0]);
LoadPalette(gShopMenu_Pal, BG_PLTT_ID(12), PLTT_SIZE_4BPP);
}

View File

@ -5015,9 +5015,9 @@ static void LoadSlotMachineGfx(void)
LoadReelBackground();
sDigitalDisplayGfxPtr = Alloc(0x3200);
LZDecompressWram(gSlotMachineDigitalDisplay_Gfx, sDigitalDisplayGfxPtr);
DecompressDataWithHeaderWram(gSlotMachineDigitalDisplay_Gfx, sDigitalDisplayGfxPtr);
sReelTimeGfxPtr = Alloc(0x3600);
LZDecompressWram(sReelTimeGfx, sReelTimeGfxPtr);
DecompressDataWithHeaderWram(sReelTimeGfx, sReelTimeGfxPtr);
sSlotMachineSpritesheetsPtr = AllocZeroed(sizeof(struct SpriteSheet) * ARRAY_COUNT(sSlotMachineSpriteSheets));
for (i = 0; i < ARRAY_COUNT(sSlotMachineSpriteSheets); i++)
{
@ -5055,7 +5055,7 @@ static void LoadReelBackground(void)
static void LoadMenuGfx(void)
{
sMenuGfx = Alloc(0x2200);
LZDecompressWram(gSlotMachineMenu_Gfx, sMenuGfx);
DecompressDataWithHeaderWram(gSlotMachineMenu_Gfx, sMenuGfx);
LoadBgTiles(2, sMenuGfx, 0x2200, 0);
LoadPalette(gSlotMachineMenu_Pal, BG_PLTT_ID(0), 5 * PLTT_SIZE_4BPP);
LoadPalette(sUnkPalette, BG_PLTT_ID(13), PLTT_SIZE_4BPP);

View File

@ -878,8 +878,11 @@ void BeginAnim(struct Sprite *sprite)
if (sprite->usingSheet)
{
// Inject OW decompression here
if (OW_GFX_COMPRESS && sprite->sheetSpan)
{
imageValue = (imageValue + 1) << sprite->sheetSpan;
}
sprite->oam.tileNum = sprite->sheetTileStart + imageValue;
}
else
@ -937,7 +940,10 @@ void AnimCmd_frame(struct Sprite *sprite)
if (sprite->usingSheet)
{
if (OW_GFX_COMPRESS && sprite->sheetSpan)
{
// Inject OW frame switcher here
imageValue = (imageValue + 1) << sprite->sheetSpan;
}
sprite->oam.tileNum = sprite->sheetTileStart + imageValue;
}
else

View File

@ -397,9 +397,9 @@ void CB2_ChooseStarter(void)
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
LZ77UnCompVram(gBirchBagGrass_Gfx, (void *)VRAM);
LZ77UnCompVram(gBirchBagTilemap, (void *)(BG_SCREEN_ADDR(6)));
LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(7)));
DecompressDataWithHeaderVram(gBirchBagGrass_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gBirchBagTilemap, (void *)(BG_SCREEN_ADDR(6)));
DecompressDataWithHeaderVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(7)));
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));

View File

@ -596,15 +596,15 @@ void CB2_InitTitleScreen(void)
break;
case 1:
// bg2
LZ77UnCompVram(gTitleScreenPokemonLogoGfx, (void *)(BG_CHAR_ADDR(0)));
LZ77UnCompVram(gTitleScreenPokemonLogoTilemap, (void *)(BG_SCREEN_ADDR(9)));
DecompressDataWithHeaderVram(gTitleScreenPokemonLogoGfx, (void *)(BG_CHAR_ADDR(0)));
DecompressDataWithHeaderVram(gTitleScreenPokemonLogoTilemap, (void *)(BG_SCREEN_ADDR(9)));
LoadPalette(gTitleScreenBgPalettes, BG_PLTT_ID(0), 15 * PLTT_SIZE_4BPP);
// bg3
LZ77UnCompVram(sTitleScreenRayquazaGfx, (void *)(BG_CHAR_ADDR(2)));
LZ77UnCompVram(sTitleScreenRayquazaTilemap, (void *)(BG_SCREEN_ADDR(26)));
DecompressDataWithHeaderVram(sTitleScreenRayquazaGfx, (void *)(BG_CHAR_ADDR(2)));
DecompressDataWithHeaderVram(sTitleScreenRayquazaTilemap, (void *)(BG_SCREEN_ADDR(26)));
// bg1
LZ77UnCompVram(sTitleScreenCloudsGfx, (void *)(BG_CHAR_ADDR(3)));
LZ77UnCompVram(gTitleScreenCloudsTilemap, (void *)(BG_SCREEN_ADDR(27)));
DecompressDataWithHeaderVram(sTitleScreenCloudsGfx, (void *)(BG_CHAR_ADDR(3)));
DecompressDataWithHeaderVram(gTitleScreenCloudsTilemap, (void *)(BG_SCREEN_ADDR(27)));
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();

View File

@ -3189,7 +3189,7 @@ static void SetTradeSequenceBgGpuRegs(u8 state)
DISPCNT_OBJ_1D_MAP |
DISPCNT_BG1_ON |
DISPCNT_OBJ_ON);
LZ77UnCompVram(sWirelessCloseup_Map, (void *) BG_SCREEN_ADDR(5));
DecompressDataWithHeaderVram(sWirelessCloseup_Map, (void *) BG_SCREEN_ADDR(5));
BlendPalettes(0x8, 16, RGB_BLACK);
}
else
@ -3204,8 +3204,8 @@ static void SetTradeSequenceBgGpuRegs(u8 state)
break;
case 3:
LoadPalette(sWirelessSignalNone_Pal, BG_PLTT_ID(3), PLTT_SIZE_4BPP);
LZ77UnCompVram(sWirelessSignal_Gfx, (void *) BG_CHAR_ADDR(1));
LZ77UnCompVram(sWirelessSignal_Tilemap, (void *) BG_SCREEN_ADDR(18));
DecompressDataWithHeaderVram(sWirelessSignal_Gfx, (void *) BG_CHAR_ADDR(1));
DecompressDataWithHeaderVram(sWirelessSignal_Tilemap, (void *) BG_SCREEN_ADDR(18));
sTradeAnim->bg2vofs = 80;
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |

View File

@ -26,6 +26,7 @@
#include "pokemon_icon.h"
#include "trainer_pokemon_sprites.h"
#include "contest_util.h"
#include "decompress.h"
#include "constants/songs.h"
#include "constants/game_stat.h"
#include "constants/battle_frontier.h"
@ -535,47 +536,47 @@ static bool8 LoadCardGfx(void)
{
case 0:
if (sData->cardType != CARD_TYPE_FRLG)
LZ77UnCompWram(gHoennTrainerCardBg_Tilemap, sData->bgTilemap);
DecompressDataWithHeaderWram(gHoennTrainerCardBg_Tilemap, sData->bgTilemap);
else
LZ77UnCompWram(gKantoTrainerCardBg_Tilemap, sData->bgTilemap);
DecompressDataWithHeaderWram(gKantoTrainerCardBg_Tilemap, sData->bgTilemap);
break;
case 1:
if (sData->cardType != CARD_TYPE_FRLG)
LZ77UnCompWram(gHoennTrainerCardBack_Tilemap, sData->backTilemap);
DecompressDataWithHeaderWram(gHoennTrainerCardBack_Tilemap, sData->backTilemap);
else
LZ77UnCompWram(gKantoTrainerCardBack_Tilemap, sData->backTilemap);
DecompressDataWithHeaderWram(gKantoTrainerCardBack_Tilemap, sData->backTilemap);
break;
case 2:
if (!sData->isLink)
{
if (sData->cardType != CARD_TYPE_FRLG)
LZ77UnCompWram(gHoennTrainerCardFront_Tilemap, sData->frontTilemap);
DecompressDataWithHeaderWram(gHoennTrainerCardFront_Tilemap, sData->frontTilemap);
else
LZ77UnCompWram(gKantoTrainerCardFront_Tilemap, sData->frontTilemap);
DecompressDataWithHeaderWram(gKantoTrainerCardFront_Tilemap, sData->frontTilemap);
}
else
{
if (sData->cardType != CARD_TYPE_FRLG)
LZ77UnCompWram(gHoennTrainerCardFrontLink_Tilemap, sData->frontTilemap);
DecompressDataWithHeaderWram(gHoennTrainerCardFrontLink_Tilemap, sData->frontTilemap);
else
LZ77UnCompWram(gKantoTrainerCardFrontLink_Tilemap, sData->frontTilemap);
DecompressDataWithHeaderWram(gKantoTrainerCardFrontLink_Tilemap, sData->frontTilemap);
}
break;
case 3:
if (sData->cardType != CARD_TYPE_FRLG)
LZ77UnCompWram(sHoennTrainerCardBadges_Gfx, sData->badgeTiles);
DecompressDataWithHeaderWram(sHoennTrainerCardBadges_Gfx, sData->badgeTiles);
else
LZ77UnCompWram(sKantoTrainerCardBadges_Gfx, sData->badgeTiles);
DecompressDataWithHeaderWram(sKantoTrainerCardBadges_Gfx, sData->badgeTiles);
break;
case 4:
if (sData->cardType != CARD_TYPE_FRLG)
LZ77UnCompWram(gHoennTrainerCard_Gfx, sData->cardTiles);
DecompressDataWithHeaderWram(gHoennTrainerCard_Gfx, sData->cardTiles);
else
LZ77UnCompWram(gKantoTrainerCard_Gfx, sData->cardTiles);
DecompressDataWithHeaderWram(gKantoTrainerCard_Gfx, sData->cardTiles);
break;
case 5:
if (sData->cardType == CARD_TYPE_FRLG)
LZ77UnCompWram(sTrainerCardStickers_Gfx, sData->stickerTiles);
DecompressDataWithHeaderWram(sTrainerCardStickers_Gfx, sData->stickerTiles);
break;
default:
sData->gfxLoadState = 0;

View File

@ -1334,7 +1334,7 @@ static bool8 LoadUsePokeblockMenuGfx(void)
sMonFrame_TilemapPtr = Alloc(1280);
break;
case 2:
LZ77UnCompVram(sMonFrame_Tilemap, sMonFrame_TilemapPtr);
DecompressDataWithHeaderVram(sMonFrame_Tilemap, sMonFrame_TilemapPtr);
break;
case 3:
LoadBgTiles(3, sMonFrame_Gfx, 224, 0);
@ -1347,10 +1347,10 @@ static bool8 LoadUsePokeblockMenuGfx(void)
sMenu->curMonXOffset = -80;
break;
case 6:
LZ77UnCompVram(gUsePokeblockGraph_Gfx, sGraph_Gfx);
DecompressDataWithHeaderVram(gUsePokeblockGraph_Gfx, sGraph_Gfx);
break;
case 7:
LZ77UnCompVram(gUsePokeblockGraph_Tilemap, sGraph_Tilemap);
DecompressDataWithHeaderVram(gUsePokeblockGraph_Tilemap, sGraph_Tilemap);
LoadPalette(gUsePokeblockGraph_Pal, BG_PLTT_ID(2), PLTT_SIZE_4BPP);
break;
case 8:
@ -1362,7 +1362,7 @@ static bool8 LoadUsePokeblockMenuGfx(void)
CopyBgTilemapBufferToVram(1);
break;
case 10:
LZ77UnCompVram(sGraphData_Tilemap, sMenu->tilemapBuffer);
DecompressDataWithHeaderVram(sGraphData_Tilemap, sMenu->tilemapBuffer);
break;
case 11:
LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0);

View File

@ -644,7 +644,7 @@ static void LoadWallClockGraphics(void)
DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
DmaClear32(3, (void *)OAM, OAM_SIZE);
DmaClear16(3, (void *)PLTT, PLTT_SIZE);
LZ77UnCompVram(gWallClock_Gfx, (void *)VRAM);
DecompressDataWithHeaderVram(gWallClock_Gfx, (void *)VRAM);
if (gSpecialVar_0x8004 == MALE)
LoadPalette(gWallClockMale_Pal, BG_PLTT_ID(0), PLTT_SIZE_4BPP);
@ -689,7 +689,7 @@ void CB2_StartWallClock(void)
u8 spriteId;
LoadWallClockGraphics();
LZ77UnCompVram(gWallClockStart_Tilemap, (u16 *)BG_SCREEN_ADDR(7));
DecompressDataWithHeaderVram(gWallClockStart_Tilemap, (u16 *)BG_SCREEN_ADDR(7));
taskId = CreateTask(Task_SetClock_WaitFadeIn, 0);
gTasks[taskId].tHours = 10;
@ -733,7 +733,7 @@ void CB2_ViewWallClock(void)
u8 angle2;
LoadWallClockGraphics();
LZ77UnCompVram(gWallClockView_Tilemap, (u16 *)BG_SCREEN_ADDR(7));
DecompressDataWithHeaderVram(gWallClockView_Tilemap, (u16 *)BG_SCREEN_ADDR(7));
taskId = CreateTask(Task_ViewClock_WaitFadeIn, 0);
InitClockWithRtc(taskId);

View File

@ -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;
@ -457,7 +458,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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
test/compression/ledian.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

6337
test/compression/smol.c Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Some files were not shown because too many files have changed in this diff Show More