housekeeping
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -295,14 +296,13 @@ Bytes CreateCompressionString(std::shared_ptr<CompressionPiece>& start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status ValidateCompressionResult(
|
absl::Status ValidateCompressionResult(
|
||||||
std::shared_ptr<CompressionPiece>& compressed_chain_start, int mode,
|
CompressionPiecePointer& compressed_chain_start, int mode, int start,
|
||||||
int start, int src_data_pos) {
|
int src_data_pos) {
|
||||||
if (compressed_chain_start->next != nullptr) {
|
if (compressed_chain_start->next != nullptr) {
|
||||||
ROM temp_rom;
|
ROM temp_rom;
|
||||||
RETURN_IF_ERROR(temp_rom.LoadFromBytes(
|
RETURN_IF_ERROR(temp_rom.LoadFromBytes(
|
||||||
CreateCompressionString(compressed_chain_start->next, mode)))
|
CreateCompressionString(compressed_chain_start->next, mode)))
|
||||||
ASSIGN_OR_RETURN(auto decomp_data,
|
ASSIGN_OR_RETURN(auto decomp_data, temp_rom.Decompress(0, temp_rom.size()))
|
||||||
temp_rom.Decompress(0, temp_rom.size()))
|
|
||||||
if (!std::equal(decomp_data.begin() + start, decomp_data.end(),
|
if (!std::equal(decomp_data.begin() + start, decomp_data.end(),
|
||||||
temp_rom.begin())) {
|
temp_rom.begin())) {
|
||||||
return absl::InternalError(absl::StrFormat(
|
return absl::InternalError(absl::StrFormat(
|
||||||
@@ -314,9 +314,8 @@ absl::Status ValidateCompressionResult(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Merge consecutive copy if possible
|
// Merge consecutive copy if possible
|
||||||
std::shared_ptr<CompressionPiece> MergeCopy(
|
CompressionPiecePointer MergeCopy(CompressionPiecePointer& start) {
|
||||||
std::shared_ptr<CompressionPiece>& start) {
|
CompressionPiecePointer piece = start;
|
||||||
std::shared_ptr<CompressionPiece> piece = start;
|
|
||||||
|
|
||||||
while (piece != nullptr) {
|
while (piece != nullptr) {
|
||||||
if (piece->command == kCommandDirectCopy && piece->next != nullptr &&
|
if (piece->command == kCommandDirectCopy && piece->next != nullptr &&
|
||||||
@@ -371,7 +370,7 @@ Bytes SnesTo8bppSheet(Bytes sheet, int bpp) {
|
|||||||
for (int i = 0; i < num_tiles; i++) { // for each tiles, 16 per line
|
for (int i = 0; i < num_tiles; i++) { // for each tiles, 16 per line
|
||||||
for (int y = 0; y < 8; y++) { // for each line
|
for (int y = 0; y < 8; y++) { // for each line
|
||||||
for (int x = 0; x < 8; x++) { //[0] + [1] + [16]
|
for (int x = 0; x < 8; x++) { //[0] + [1] + [16]
|
||||||
auto b1 = ((sheet[(y * 2) + (bpp * pos)] & (kGraphicsBitmap[x])));
|
auto b1 = (sheet[(y * 2) + (bpp * pos)] & (kGraphicsBitmap[x]));
|
||||||
auto b2 = (sheet[((y * 2) + (bpp * pos)) + 1] & (kGraphicsBitmap[x]));
|
auto b2 = (sheet[((y * 2) + (bpp * pos)) + 1] & (kGraphicsBitmap[x]));
|
||||||
auto b3 = (sheet[(16 + y) + (bpp * pos)] & (kGraphicsBitmap[x]));
|
auto b3 = (sheet[(16 + y) + (bpp * pos)] & (kGraphicsBitmap[x]));
|
||||||
unsigned char b = 0;
|
unsigned char b = 0;
|
||||||
@@ -384,7 +383,7 @@ Bytes SnesTo8bppSheet(Bytes sheet, int bpp) {
|
|||||||
if (b3 != 0 && bpp != 16) {
|
if (b3 != 0 && bpp != 16) {
|
||||||
b |= 4;
|
b |= 4;
|
||||||
}
|
}
|
||||||
sheet_buffer_out[x + (xx) + (y * 128) + (yy * 1024)] = b;
|
sheet_buffer_out[x + xx + (y * 128) + (yy * 1024)] = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ struct CompressionPiece {
|
|||||||
: command(cmd), length(len), argument_length(arg_len), argument(args) {}
|
: command(cmd), length(len), argument_length(arg_len), argument(args) {}
|
||||||
};
|
};
|
||||||
using CompressionPiece = struct CompressionPiece;
|
using CompressionPiece = struct CompressionPiece;
|
||||||
|
using CompressionPiecePointer = std::shared_ptr<CompressionPiece>;
|
||||||
|
|
||||||
class ROM {
|
class ROM {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
void Inventory::Create() {
|
void Inventory::Create() {
|
||||||
data_.reserve(256 * 256);
|
data_.reserve(256 * 256);
|
||||||
for (int i = 0; i < 256 * 256; i++) {
|
for (int i = 0; i < 256 * 256; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user