summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenny022p <info@henny022.de>2021-11-30 04:28:49 +0100
committerHenny022p <info@henny022.de>2021-11-30 04:28:49 +0100
commit029ce60b3dc3680c4c96fe1c101f0f72b0472d64 (patch)
tree3d99fa74004da4c5ce4977a23e8a8aa1edb27ef1
parentc498ec163e2b24200493437dd7eaf4f356b84f99 (diff)
removed some unnecessary vectors
-rw-r--r--tools/src/asset_processor/assets/animation.cpp21
-rw-r--r--tools/src/asset_processor/assets/exitlist.cpp36
-rw-r--r--tools/src/asset_processor/assets/frameobjlists.cpp30
-rw-r--r--tools/src/asset_processor/assets/spriteframe.cpp14
-rw-r--r--tools/src/asset_processor/main.cpp6
-rw-r--r--tools/src/asset_processor/reader.h6
6 files changed, 51 insertions, 62 deletions
diff --git a/tools/src/asset_processor/assets/animation.cpp b/tools/src/asset_processor/assets/animation.cpp
index 73923e3f..fb14fea4 100644
--- a/tools/src/asset_processor/assets/animation.cpp
+++ b/tools/src/asset_processor/assets/animation.cpp
@@ -5,31 +5,28 @@
void AnimationAsset::convertToHumanReadable(const std::vector<char>& baserom) {
Reader reader(baserom, start, size);
- std::vector<std::string> lines;
bool end_of_animation = false;
+ auto file = util::open_file(assetPath, "w");
while (!end_of_animation && reader.cursor + 3 < size) {
u8 frame_index = reader.read_u8();
u8 keyframe_duration = reader.read_u8();
u8 bitfield = reader.read_u8();
u8 bitfield2 = reader.read_u8();
end_of_animation = (bitfield2 & 0x80) != 0;
- lines.push_back(fmt::format("\tkeyframe frame_index={}", frame_index));
- lines.push_back(opt_param(", duration={}", 0, keyframe_duration));
- lines.push_back(opt_param(", bitfield={:#x}", 0, bitfield));
- lines.push_back(opt_param(", bitfield2={:#x}", 0, bitfield2));
- lines.emplace_back("\n");
+ auto line = fmt::format("\tkeyframe frame_index={}", frame_index);
+ line += opt_param(", duration={}", 0, keyframe_duration);
+ line += opt_param(", bitfield={:#x}", 0, bitfield);
+ line += opt_param(", bitfield2={:#x}", 0, bitfield2);
+ std::fputs(line.c_str(), file.get());
+ std::fputc('\n', file.get());
}
if (!end_of_animation) {
- lines.emplace_back("@ TODO why no terminator?\n");
+ std::fputs("@ TODO why no terminator?\n", file.get());
}
while (reader.cursor < size) {
u8 keyframe_count = reader.read_u8();
- lines.push_back(fmt::format("\t.byte {} @ keyframe count\n", keyframe_count));
- }
- auto file = util::open_file(assetPath, "w");
- for (const auto& line : lines) {
- std::fputs(line.c_str(), file.get());
+ fmt::print(file.get(), "\t.byte {} @ keyframe count\n", keyframe_count);
}
}
diff --git a/tools/src/asset_processor/assets/exitlist.cpp b/tools/src/asset_processor/assets/exitlist.cpp
index f73d4a0c..85051fd1 100644
--- a/tools/src/asset_processor/assets/exitlist.cpp
+++ b/tools/src/asset_processor/assets/exitlist.cpp
@@ -5,7 +5,7 @@
void ExitListAsset::convertToHumanReadable(const std::vector<char>& baserom) {
Reader reader(baserom, start, size);
- std::vector<std::string> lines;
+ auto file = util::open_file(assetPath, "w");
while (reader.cursor < size) {
u16 transition_type = reader.read_u16();
u16 x_pos = reader.read_u16();
@@ -21,27 +21,23 @@ void ExitListAsset::convertToHumanReadable(const std::vector<char>& baserom) {
u16 unknown_5 = reader.read_u16();
u16 padding_1 = reader.read_u16();
if (transition_type == 0xffff) {
- lines.emplace_back("\texit_list_end\n");
+ std::fputs("\texit_list_end\n", file.get());
break;
}
- lines.push_back(fmt::format("\texit transition={}", transition_type));
- lines.push_back(opt_param(", x={:#x}", 0, x_pos));
- lines.push_back(opt_param(", y={:#x}", 0, y_pos));
- lines.push_back(opt_param(", destX={:#x}", 0, dest_x));
- lines.push_back(opt_param(", destY={:#x}", 0, dest_y));
- lines.push_back(opt_param(", screenEdge={:#x}", 0, screen_edge));
- lines.push_back(opt_param(", destArea={:#x}", 0, dest_area));
- lines.push_back(opt_param(", destRoom={:#x}", 0, dest_room));
- lines.push_back(opt_param(", unknown={:#x}", 0, unknown_2));
- lines.push_back(opt_param(", unknown2={:#x}", 0, unknown_3));
- lines.push_back(opt_param(", unknown3={:#x}", 0, unknown_4));
- lines.push_back(opt_param(", unknown4={:#x}", 0, unknown_5));
- lines.push_back(opt_param(", padding={:#x}", 0, padding_1));
- lines.emplace_back("\n");
- }
-
- auto file = util::open_file(assetPath, "w");
- for (const auto& line : lines) {
+ auto line = fmt::format("\texit transition={}", transition_type);
+ line += opt_param(", x={:#x}", 0, x_pos);
+ line += opt_param(", y={:#x}", 0, y_pos);
+ line += opt_param(", destX={:#x}", 0, dest_x);
+ line += opt_param(", destY={:#x}", 0, dest_y);
+ line += opt_param(", screenEdge={:#x}", 0, screen_edge);
+ line += opt_param(", destArea={:#x}", 0, dest_area);
+ line += opt_param(", destRoom={:#x}", 0, dest_room);
+ line += opt_param(", unknown={:#x}", 0, unknown_2);
+ line += opt_param(", unknown2={:#x}", 0, unknown_3);
+ line += opt_param(", unknown3={:#x}", 0, unknown_4);
+ line += opt_param(", unknown4={:#x}", 0, unknown_5);
+ line += opt_param(", padding={:#x}", 0, padding_1);
std::fputs(line.c_str(), file.get());
+ std::fputc('\n', file.get());
}
} \ No newline at end of file
diff --git a/tools/src/asset_processor/assets/frameobjlists.cpp b/tools/src/asset_processor/assets/frameobjlists.cpp
index db1b80ca..d2ac6b22 100644
--- a/tools/src/asset_processor/assets/frameobjlists.cpp
+++ b/tools/src/asset_processor/assets/frameobjlists.cpp
@@ -10,8 +10,8 @@ void FrameObjListsAsset::convertToHumanReadable(const std::vector<char>& baserom
std::vector<u32> first_level;
std::vector<u32> second_level;
- std::vector<std::string> lines;
- lines.emplace_back("@ First level of offsets\n");
+ auto file = util::open_file(assetPath, "w");
+ std::fputs("@ First level of offsets\n", file.get());
while (reader.cursor < size) {
if (std::find(first_level.begin(), first_level.end(), reader.cursor) != first_level.end()) {
@@ -21,10 +21,10 @@ void FrameObjListsAsset::convertToHumanReadable(const std::vector<char>& baserom
u32 pointer = reader.read_u32();
first_level.push_back(pointer);
- lines.push_back(fmt::format("\t.4byte {:#x}\n", pointer));
+ fmt::print(file.get(), "\t.4byte {:#x}\n", pointer);
}
- lines.emplace_back("\n@ Second level of offsets\n");
+ std::fputs("\n@ Second level of offsets\n", file.get());
while (reader.cursor < size) {
if (std::find(second_level.begin(), second_level.end(), reader.cursor) != second_level.end()) {
@@ -33,7 +33,7 @@ void FrameObjListsAsset::convertToHumanReadable(const std::vector<char>& baserom
}
u32 pointer = reader.read_u32();
second_level.push_back(pointer);
- lines.push_back(fmt::format("\t.4byte {:#x}\n", pointer));
+ fmt::print(file.get(), "\t.4byte {:#x}\n", pointer);
}
u32 max_second_level = *std::max_element(second_level.begin(), second_level.end());
@@ -51,29 +51,25 @@ void FrameObjListsAsset::convertToHumanReadable(const std::vector<char>& baserom
}
}
int diff = next - reader.cursor;
- lines.push_back(fmt::format("@ Skipping {} bytes\n", diff));
+ fmt::print(file.get(), "@ Skipping {} bytes\n", diff);
for (int i = 0; i < diff; i++) {
u8 byte = reader.read_u8();
- lines.push_back(fmt::format("\t.byte {}\n", byte));
+ fmt::print(file.get(), "\t.byte {}\n", byte);
}
}
u8 num_objects = reader.read_u8();
- lines.push_back(fmt::format("\t.byte {} @ num_objs\n", num_objects));
+ fmt::print(file.get(), "\t.byte {} @ num_objs\n", num_objects);
for (int i = 0; i < num_objects; i++) {
s8 x_offset = reader.read_s8();
s8 y_offset = reader.read_s8();
u8 bitfield = reader.read_u8();
u16 bitfield2 = reader.read_u16();
- lines.push_back(fmt::format("\tobj x={}, y={}", x_offset, y_offset));
- lines.push_back(opt_param(", bitfield={:#x}", 0, bitfield));
- lines.push_back(opt_param(", bitfield2={:#x}", 0, bitfield2));
- lines.emplace_back("\n");
+ auto line = fmt::format("\tobj x={}, y={}", x_offset, y_offset);
+ line += opt_param(", bitfield={:#x}", 0, bitfield);
+ line += opt_param(", bitfield2={:#x}", 0, bitfield2);
+ std::fputs(line.c_str(), file.get());
+ std::fputc('\n', file.get());
}
}
-
- auto file = util::open_file(assetPath, "w");
- for (const auto& line : lines) {
- std::fputs(line.c_str(), file.get());
- }
} \ No newline at end of file
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<char>& baserom) {
Reader reader(baserom, start, size);
- std::vector<std::string> 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
diff --git a/tools/src/asset_processor/main.cpp b/tools/src/asset_processor/main.cpp
index c04ab3d1..1e6df2a0 100644
--- a/tools/src/asset_processor/main.cpp
+++ b/tools/src/asset_processor/main.cpp
@@ -189,7 +189,8 @@ int main(int argc, char** argv) {
case CONVERT: {
std::unique_ptr<BaseAsset> assetHandler = getAssetHandlerByType(path, asset, currentOffset);
if (!std::filesystem::exists(assetHandler->getBuildPath())) {
- std::cerr << "Error: Extracted binary file " << assetHandler->getBuildPath() << " does not exist. Run `make` first." << std::endl;
+ std::cerr << "Error: Extracted binary file " << assetHandler->getBuildPath()
+ << " does not exist. Run `make` first." << std::endl;
std::exit(1);
}
if (shouldConvertAsset(assetHandler)) {
@@ -203,7 +204,8 @@ int main(int argc, char** argv) {
case BUILD: {
std::unique_ptr<BaseAsset> assetHandler = getAssetHandlerByType(path, asset, currentOffset);
if (!std::filesystem::exists(assetHandler->getAssetPath())) {
- std::cerr << "Error: Extracted asset file " << assetHandler->getAssetPath() << " does not exist. Run `make extractassets` first." << std::endl;
+ std::cerr << "Error: Extracted asset file " << assetHandler->getAssetPath()
+ << " does not exist. Run `make extractassets` first." << std::endl;
std::exit(1);
}
if (shouldBuildAsset(assetHandler)) {
diff --git a/tools/src/asset_processor/reader.h b/tools/src/asset_processor/reader.h
index 021ea3c8..dc2159fc 100644
--- a/tools/src/asset_processor/reader.h
+++ b/tools/src/asset_processor/reader.h
@@ -6,7 +6,9 @@
class Reader {
public:
- Reader(const std::vector<char>& baserom, int start, int size_) : data(baserom.data() + start), size(size_) {
+ Reader(const std::vector<char>& baserom, int start, [[maybe_unused]]int size_)
+ : data(baserom.data() + start) //, size(size_)
+ {
}
[[nodiscard]] s8 read_s8() {
@@ -30,7 +32,7 @@ class Reader {
private:
const char* data;
- const int size;
+ // const int size;
};
#endif \ No newline at end of file