Decompress map assets

This commit is contained in:
octorock 2022-12-06 17:00:46 +01:00
parent 03408debcd
commit 80b66166f5
11 changed files with 2849 additions and 2720 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -543,107 +543,107 @@ gAreaRoomMaps_CrenelMinishPaths:: @ 08103D24
.4byte gAreaRoomMap_CrenelMinishPaths_3
gAreaRoomMap_MinishHouseInteriors_0:: @ 08103D34
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_0_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_0_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_1:: @ 08103D58
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_1_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_1_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_2:: @ 08103D7C
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_2_1, 0x1D0, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_2_2, 0x1000, 1, 1
gAreaRoomMap_MinishHouseInteriors_3:: @ 08103DA0
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_3_1, 0xA0, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_3_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_4:: @ 08103DC4
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_4_1, 0xA0, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_4_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_5:: @ 08103DE8
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_5_1, 0xA0, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_5_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_6:: @ 08103E0C
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_6_1, 0xA0, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_6_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_8:: @ 08103E30
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_8_1, 0xE1, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_8_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_7:: @ 08103E54
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_7_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_7_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_9:: @ 08103E78
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_9_1, 0x159, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_9_2, 0x1000, 1, 1
gAreaRoomMap_MinishHouseInteriors_10:: @ 08103E9C
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_10_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_10_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_11:: @ 08103EC0
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_11_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_11_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_12:: @ 08103EE4
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_12_1, 0xDC, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_12_2, 0x1000, 1, 1
gAreaRoomMap_MinishHouseInteriors_13:: @ 08103F08
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_13_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_13_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_14:: @ 08103F2C
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_14_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_14_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_15:: @ 08103F50
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_15_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_15_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_16:: @ 08103F74
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_16_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_16_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_17:: @ 08103F98
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_17_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_17_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_18:: @ 08103FBC
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_18_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_18_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_19:: @ 08103FE0
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_19_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_19_2, 0x800, 1, 1
gAreaRoomMap_MinishHouseInteriors_20:: @ 08104004
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_MinishHouseInteriors_20_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_MinishHouseInteriors_20_2, 0x800, 1, 1
@ -690,47 +690,47 @@ gAreaRoomMaps_MinishHouseInteriors:: @ 08104028
.4byte gAreaRoomMap_MinishHouseInteriors_20
gAreaRoomMap_TownMinishHoles_0:: @ 081040C8
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_0_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_0_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_1:: @ 081040EC
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_1_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_1_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_2:: @ 08104110
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_2_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_2_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_3:: @ 08104134
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_3_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_3_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_4:: @ 08104158
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_4_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_4_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_5:: @ 0810417C
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_5_1, 0x96, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_5_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_6:: @ 081041A0
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_6_1, 0x24C, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_6_2, 0x2000, 1, 1
gAreaRoomMap_TownMinishHoles_7:: @ 081041C4
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_7_1, 0xE1, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_7_2, 0x800, 1, 1
gAreaRoomMap_TownMinishHoles_8:: @ 081041E8
map_bottom offset_gAreaRoomMap_TownMinishHoles_8_0, 0x2000, 1
map_bottom offset_gAreaRoomMap_None, 0x2000, 1
collision_bottom offset_gAreaRoomMap_TownMinishHoles_8_1, 0x190, 1
map_bottom_special offset_gAreaRoomMap_TownMinishHoles_8_2, 0x2000, 1, 1

View File

@ -15,20 +15,20 @@ gAreaTilesets_Unused:: @ 08100CF0
gAreaRoomMaps_Unused::
.4byte gAreaTileset_Unused_0
gTileset_MinishWoods_0:: @ 08100CF4
gAreaTileset_MinishWoods_0:: @ 08100CF4
tileset_tiles offset_gAreaTileset_LakeWoodsCave_0_0, 0x6000000, 0x4000, 1
tileset_tiles offset_gAreaTileset_LakeWoodsCave_0_1, 0x6004000, 0x4000, 1
tileset_tiles offset_gAreaTileset_LakeWoodsCave_0_2, 0x6008000, 0x4000, 1
tileset_palette_set 28, 1
gTileset_MinishWoods_1:: @ 08100D24
gAreaTileset_MinishWoods_1:: @ 08100D24
tileset_tiles offset_gAreaTileset_LakeWoodsCave_0_3, 0x6000000, 0x2000, 1
tileset_tiles offset_gAreaTileset_LakeWoodsCave_0_4, 0x6008000, 0x2000, 1
tileset_palette_set 21, 1
gAreaTilesets_MinishWoods:: @ 08100D48
.4byte gTileset_MinishWoods_0
.4byte gTileset_MinishWoods_1
.4byte gAreaTileset_MinishWoods_0
.4byte gAreaTileset_MinishWoods_1
gAreaTileset_LakeHylia_0:: @ 08100D50
tileset_tiles offset_gAreaTileset_HyliaDigCaves_0_0, 0x6000000, 0x4000, 1

View File

@ -16,8 +16,21 @@ void GfxAsset::convertToHumanReadable(const std::vector<char>& baserom) {
std::filesystem::path toolsPath = "tools";
std::vector<std::string> cmd;
std::filesystem::path decompressedPath = path;
if (isCompressed()) {
// First decompress.
decompressedPath.replace_extension("");
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(path);
cmd.push_back(decompressedPath);
check_call(cmd);
cmd.clear();
}
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(path);
cmd.push_back(decompressedPath);
cmd.push_back(assetPath);
if (asset.contains("options")) {
for (const auto& it : asset["options"].items()) {
@ -31,8 +44,26 @@ void GfxAsset::convertToHumanReadable(const std::vector<char>& baserom) {
void GfxAsset::buildToBinary() {
std::filesystem::path toolsPath = "tools";
std::vector<std::string> cmd;
std::filesystem::path decompressedPath = path;
if (isCompressed()) {
decompressedPath.replace_extension("");
}
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(assetPath);
cmd.push_back(path);
cmd.push_back(decompressedPath);
check_call(cmd);
if (isCompressed()) {
// Compress.
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(decompressedPath);
cmd.push_back(path);
check_call(cmd);
}
}
bool GfxAsset::isCompressed() {
return path.extension() == ".lz";
}

View File

@ -8,4 +8,5 @@ class GfxAsset : public BaseAsset {
private:
virtual std::filesystem::path generateAssetPath();
bool isCompressed();
};

View File

@ -0,0 +1,44 @@
#include "map.h"
#include "util.h"
#include <nlohmann/json.hpp>
std::filesystem::path MapAsset::generateAssetPath() {
std::filesystem::path decompressedPath = path;
if (isCompressed()) {
if (decompressedPath.extension() == ".lz") {
decompressedPath.replace_extension("");
}
}
return decompressedPath;
}
void MapAsset::convertToHumanReadable(const std::vector<char>& baserom) {
(void)baserom;
if (isCompressed()) {
std::filesystem::path toolsPath = "tools";
std::vector<std::string> cmd;
// Decompress.
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(path);
cmd.push_back(assetPath);
check_call(cmd);
}
}
void MapAsset::buildToBinary() {
if (isCompressed()) {
std::filesystem::path toolsPath = "tools";
std::vector<std::string> cmd;
// Compress.
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(assetPath);
cmd.push_back(path);
check_call(cmd);
}
}
bool MapAsset::isCompressed() {
return path.extension() == ".lz";
}

17
tools/src/asset_processor/assets/map.h vendored Normal file
View File

@ -0,0 +1,17 @@
#ifndef MAP_H
#define MAP_H
#include "asset.h"
class MapAsset : public BaseAsset {
public:
using BaseAsset::BaseAsset;
virtual void convertToHumanReadable(const std::vector<char>& baserom);
virtual void buildToBinary();
private:
virtual std::filesystem::path generateAssetPath();
bool isCompressed();
};
#endif // MAP_H

View File

@ -15,8 +15,21 @@ void TilesetAsset::convertToHumanReadable(const std::vector<char>& baserom) {
std::filesystem::path toolsPath = "tools";
std::vector<std::string> cmd;
std::filesystem::path decompressedPath = path;
if (isCompressed()) {
// First decompress.
decompressedPath.replace_extension("");
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(path);
cmd.push_back(decompressedPath);
check_call(cmd);
cmd.clear();
}
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(path);
cmd.push_back(decompressedPath);
cmd.push_back(assetPath);
cmd.push_back("-mwidth");
cmd.push_back("32");
@ -26,8 +39,26 @@ void TilesetAsset::convertToHumanReadable(const std::vector<char>& baserom) {
void TilesetAsset::buildToBinary() {
std::filesystem::path toolsPath = "tools";
std::vector<std::string> cmd;
std::filesystem::path decompressedPath = path;
if (isCompressed()) {
decompressedPath.replace_extension("");
}
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(assetPath);
cmd.push_back(path);
cmd.push_back(decompressedPath);
check_call(cmd);
if (isCompressed()) {
// Compress.
cmd.push_back(toolsPath / "bin" / "gbagfx");
cmd.push_back(decompressedPath);
cmd.push_back(path);
check_call(cmd);
}
}
bool TilesetAsset::isCompressed() {
return path.extension() == ".lz";
}

View File

@ -8,4 +8,5 @@ class TilesetAsset : public BaseAsset {
private:
virtual std::filesystem::path generateAssetPath();
bool isCompressed();
};

View File

@ -3,6 +3,7 @@
#include "assets/animation.h"
#include "assets/frameobjlists.h"
#include "assets/gfx.h"
#include "assets/map.h"
#include "assets/midi.h"
#include "assets/palette.h"
#include "assets/spriteframe.h"
@ -281,7 +282,9 @@ std::unique_ptr<BaseAsset> getAssetHandlerByType(const std::filesystem::path& pa
} else if (type == "map_gfx" || type == "map_layer1" || type == "map_layer2" || type == "metatiles_tile_types1" ||
type == "metatiles_tile_types2" || type == "metatiles_tileset1" || type == "metatiles_tileset2" ||
type == "map_mapping1" || type == "map_mapping2" || type == "tileset_mapping3" ||
type == "map_collision" || type == "unknown") {
type == "map_collision") {
assetHandler = std::make_unique<MapAsset>(path, start, size, asset);
} else if (type == "unknown") {
// TODO implement conversions
assetHandler = std::make_unique<BaseAsset>(path, start, size, asset);
} else if (type.empty()) {