From bc4a8577f3f139a8d0b420e2decbbb9701d25c4c Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 23 Nov 2021 05:40:41 +0100 Subject: moved asset_processor to new location --- tools/src/asset_processor/assets/spriteframe.cpp | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/src/asset_processor/assets/spriteframe.cpp (limited to 'tools/src/asset_processor/assets/spriteframe.cpp') diff --git a/tools/src/asset_processor/assets/spriteframe.cpp b/tools/src/asset_processor/assets/spriteframe.cpp new file mode 100644 index 00000000..6aea52cf --- /dev/null +++ b/tools/src/asset_processor/assets/spriteframe.cpp @@ -0,0 +1,25 @@ +#include "spriteframe.h" +#include "reader.h" +#include +#include + +void SpriteFrameAsset::convertToHumanReadable(const std::vector& baserom) { + Reader reader(baserom, this->start, this->size); + std::vector lines; + while (reader.cursor < this->size) { + u8 num_gfx_tiles = reader.read_u8(); + u8 unk = reader.read_u8(); + u16 first_gfx_tile_index = reader.read_u16(); + + lines.push_back(string_format("\tsprite_frame first_tile_index=0x%x", first_gfx_tile_index)); + lines.push_back(opt_param(", num_tiles=%d", 0, num_gfx_tiles)); + lines.push_back(opt_param(", unknown=0x%x", 0, unk)); + lines.push_back("\n"); + } + + std::ofstream out(this->assetPath); + for (const auto& line : lines) { + out << line; + } + out.close(); +} \ No newline at end of file -- cgit v1.2.3 From 794d5fc97cb01a70c8579dc08962b667edf5a29e Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 23 Nov 2021 20:22:22 +0100 Subject: cleaned asset_processor to build without warnings --- tools/src/asset_processor/assets/spriteframe.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tools/src/asset_processor/assets/spriteframe.cpp') diff --git a/tools/src/asset_processor/assets/spriteframe.cpp b/tools/src/asset_processor/assets/spriteframe.cpp index 6aea52cf..5c303e4b 100644 --- a/tools/src/asset_processor/assets/spriteframe.cpp +++ b/tools/src/asset_processor/assets/spriteframe.cpp @@ -2,22 +2,23 @@ #include "reader.h" #include #include +#include void SpriteFrameAsset::convertToHumanReadable(const std::vector& baserom) { - Reader reader(baserom, this->start, this->size); + Reader reader(baserom, start, size); std::vector lines; - while (reader.cursor < this->size) { + while (reader.cursor < size) { u8 num_gfx_tiles = reader.read_u8(); u8 unk = reader.read_u8(); u16 first_gfx_tile_index = reader.read_u16(); - lines.push_back(string_format("\tsprite_frame first_tile_index=0x%x", first_gfx_tile_index)); - lines.push_back(opt_param(", num_tiles=%d", 0, num_gfx_tiles)); - lines.push_back(opt_param(", unknown=0x%x", 0, unk)); - lines.push_back("\n"); + lines.push_back(fmt::format("\tsprite_frame first_tile_index={:#x}", first_gfx_tile_index)); + lines.push_back(opt_param(", num_tiles={}", 0, num_gfx_tiles)); + lines.push_back(opt_param(", unknown={:#x}", 0, unk)); + lines.emplace_back("\n"); } - std::ofstream out(this->assetPath); + std::ofstream out(assetPath); for (const auto& line : lines) { out << line; } -- cgit v1.2.3 From 25c9367d1730f1419abcbe6154d8391034f67d34 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Sat, 27 Nov 2021 08:32:17 +0100 Subject: replace fstream with fmt::print --- tools/src/asset_processor/assets/spriteframe.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tools/src/asset_processor/assets/spriteframe.cpp') diff --git a/tools/src/asset_processor/assets/spriteframe.cpp b/tools/src/asset_processor/assets/spriteframe.cpp index 5c303e4b..24e69a4a 100644 --- a/tools/src/asset_processor/assets/spriteframe.cpp +++ b/tools/src/asset_processor/assets/spriteframe.cpp @@ -1,8 +1,7 @@ #include "spriteframe.h" #include "reader.h" -#include -#include #include +#include void SpriteFrameAsset::convertToHumanReadable(const std::vector& baserom) { Reader reader(baserom, start, size); @@ -18,9 +17,8 @@ void SpriteFrameAsset::convertToHumanReadable(const std::vector& baserom) lines.emplace_back("\n"); } - std::ofstream out(assetPath); + auto file = util::open_file(assetPath, "w"); for (const auto& line : lines) { - out << line; + std::fputs(line.c_str(), file.get()); } - out.close(); } \ No newline at end of file -- cgit v1.2.3 From 029ce60b3dc3680c4c96fe1c101f0f72b0472d64 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 30 Nov 2021 04:28:49 +0100 Subject: removed some unnecessary vectors --- tools/src/asset_processor/assets/spriteframe.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tools/src/asset_processor/assets/spriteframe.cpp') diff --git a/tools/src/asset_processor/assets/spriteframe.cpp b/tools/src/asset_processor/assets/spriteframe.cpp index 24e69a4a..70a40f61 100644 --- a/tools/src/asset_processor/assets/spriteframe.cpp +++ b/tools/src/asset_processor/assets/spriteframe.cpp @@ -5,20 +5,16 @@ void SpriteFrameAsset::convertToHumanReadable(const std::vector& baserom) { Reader reader(baserom, start, size); - std::vector lines; + auto file = util::open_file(assetPath, "w"); while (reader.cursor < size) { u8 num_gfx_tiles = reader.read_u8(); u8 unk = reader.read_u8(); u16 first_gfx_tile_index = reader.read_u16(); - lines.push_back(fmt::format("\tsprite_frame first_tile_index={:#x}", first_gfx_tile_index)); - lines.push_back(opt_param(", num_tiles={}", 0, num_gfx_tiles)); - lines.push_back(opt_param(", unknown={:#x}", 0, unk)); - lines.emplace_back("\n"); - } - - auto file = util::open_file(assetPath, "w"); - for (const auto& line : lines) { + auto line = fmt::format("\tsprite_frame first_tile_index={:#x}", first_gfx_tile_index); + line += opt_param(", num_tiles={}", 0, num_gfx_tiles); + line += opt_param(", unknown={:#x}", 0, unk); std::fputs(line.c_str(), file.get()); + std::fputc('\n', file.get()); } } \ No newline at end of file -- cgit v1.2.3