diff --git a/src/app/gfx/compression.cc b/src/app/gfx/compression.cc index dfe09557..f15286d5 100644 --- a/src/app/gfx/compression.cc +++ b/src/app/gfx/compression.cc @@ -178,9 +178,6 @@ void CompressionCommandAlternative(const uchar* rom_data, comp_accumulator = 0; } -// ============================================================================ -// Compression V2 - void CheckByteRepeatV2(const uchar* data, uint& src_pos, const uint last_pos, CompressionCommand& cmd) { uint i = 0; @@ -379,15 +376,17 @@ absl::StatusOr SplitCompressionPiece( new_piece->argument[0] = (char)(piece->argument[0] + kMaxLengthCompression); break; - case kCommandDirectCopy: + case kCommandDirectCopy: { + std::string empty; piece->argument_length = kMaxLengthCompression; new_piece = std::make_shared( - piece->command, length_left, nullptr, length_left); + piece->command, length_left, empty, length_left); // MEMCPY for (int i = 0; i < length_left; ++i) { new_piece->argument[i] = piece->argument[i + kMaxLengthCompression]; } break; + } case kCommandRepeatingBytes: { piece->argument_length = kMaxLengthCompression; uint offset = piece->argument[0] + (piece->argument[1] << 8); @@ -525,7 +524,9 @@ absl::StatusOr> CompressV2(const uchar* data, } // Worst case should be a copy of the string with extended header - auto compressed_chain = std::make_shared(1, 1, "aaa", 2); + std::string worst_case = "aaa"; + auto compressed_chain = + std::make_shared(1, 1, worst_case, 2); auto compressed_chain_start = compressed_chain; CompressionCommand current_cmd = {/*argument*/ {{}}, @@ -1208,15 +1209,17 @@ absl::StatusOr SplitCompressionPieceV3( piece.argument_length); new_piece.argument[0] = (char)(piece.argument[0] + kMaxLengthCompression); break; - case kCommandDirectCopy: + case kCommandDirectCopy: { piece.argument_length = kMaxLengthCompression; - new_piece = - CompressionPiece(piece.command, length_left, nullptr, length_left); + std::string empty_string = ""; + new_piece = CompressionPiece(piece.command, length_left, empty_string, + length_left); // MEMCPY for (int i = 0; i < length_left; ++i) { new_piece.argument[i] = piece.argument[i + kMaxLengthCompression]; } break; + } case kCommandRepeatingBytes: { piece.argument_length = kMaxLengthCompression; uint offset = piece.argument[0] + (piece.argument[1] << 8); @@ -1339,8 +1342,6 @@ absl::StatusOr> CompressV3( context.compressed_data.end()); } -// Decompression - std::string SetBuffer(const uchar* data, int src_pos, int comp_accumulator) { std::string buffer; for (int i = 0; i < comp_accumulator; ++i) { @@ -1472,5 +1473,4 @@ absl::StatusOr> DecompressOverworld( } // namespace lc_lz2 } // namespace gfx - -} // namespace yaze \ No newline at end of file +} // namespace yaze diff --git a/src/app/gfx/compression.h b/src/app/gfx/compression.h index ec5b2f5e..6ce99c81 100644 --- a/src/app/gfx/compression.h +++ b/src/app/gfx/compression.h @@ -74,7 +74,7 @@ struct CompressionPiece { std::string argument; std::shared_ptr next = nullptr; CompressionPiece() = default; - CompressionPiece(int cmd, int len, std::string args, int arg_len) + CompressionPiece(int cmd, int len, std::string& args, int arg_len) : command(cmd), length(len), argument_length(arg_len), argument(args) {} }; using CompressionPiece = struct CompressionPiece;