big cleanup, replace Bytes alias with std::vector<uint8_t> to reduce ambiguity
This commit is contained in:
@@ -121,7 +121,6 @@
|
||||
using ushort = unsigned short;
|
||||
using uint = unsigned int;
|
||||
using uchar = unsigned char;
|
||||
using Bytes = std::vector<uint8_t>;
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -69,7 +69,7 @@ class Renderer : public ExperimentFlags {
|
||||
}
|
||||
|
||||
absl::Status CreateAndRenderBitmap(int width, int height, int depth,
|
||||
const Bytes& data, gfx::Bitmap& bitmap,
|
||||
const std::vector<uint8_t>& data, gfx::Bitmap& bitmap,
|
||||
gfx::SnesPalette& palette) {
|
||||
bitmap.Create(width, height, depth, data);
|
||||
RETURN_IF_ERROR(bitmap.ApplyPalette(palette));
|
||||
|
||||
@@ -60,7 +60,7 @@ class GfxGroupEditor : public SharedRom {
|
||||
gfx::PaletteGroup palette_group_;
|
||||
gfx::Bitmap* tile16_blockset_bmp_;
|
||||
|
||||
std::vector<Bytes> tile16_individual_data_;
|
||||
std::vector<std::vector<uint8_t>> tile16_individual_data_;
|
||||
std::vector<gfx::Bitmap> tile16_individual_;
|
||||
|
||||
gui::BitmapViewer gfx_group_viewer_;
|
||||
|
||||
@@ -712,7 +712,7 @@ absl::Status GraphicsEditor::DrawClipboardImport() {
|
||||
if (Button("Paste From Clipboard")) {
|
||||
const char* text = ImGui::GetClipboardText();
|
||||
if (text) {
|
||||
const auto clipboard_data = Bytes(text, text + strlen(text));
|
||||
const auto clipboard_data = std::vector<uint8_t>(text, text + strlen(text));
|
||||
ImGui::MemFree((void*)text);
|
||||
status_ = temp_rom_.LoadFromBytes(clipboard_data);
|
||||
is_open_ = true;
|
||||
|
||||
@@ -166,8 +166,8 @@ class GraphicsEditor : public SharedRom, public Editor {
|
||||
MemoryEditor cgx_memory_editor_;
|
||||
MemoryEditor col_memory_editor_;
|
||||
PaletteEditor palette_editor_;
|
||||
Bytes import_data_;
|
||||
Bytes graphics_buffer_;
|
||||
std::vector<uint8_t> import_data_;
|
||||
std::vector<uint8_t> graphics_buffer_;
|
||||
std::vector<uint8_t> decoded_cgx_;
|
||||
std::vector<uint8_t> cgx_data_;
|
||||
std::vector<uint8_t> extra_cgx_data_;
|
||||
|
||||
@@ -85,7 +85,7 @@ class ScreenEditor : public SharedRom, public Editor {
|
||||
bool copy_button_pressed = false;
|
||||
bool paste_button_pressed = false;
|
||||
|
||||
Bytes all_gfx_;
|
||||
std::vector<uint8_t> all_gfx_;
|
||||
zelda3::screen::Inventory inventory_;
|
||||
gfx::SnesPalette palette_;
|
||||
gui::Canvas screen_canvas_;
|
||||
|
||||
@@ -91,7 +91,7 @@ class Tile16Editor : public context::GfxContext, public SharedRom {
|
||||
gui::Canvas transfer_canvas_;
|
||||
gfx::Bitmap transfer_blockset_bmp_;
|
||||
|
||||
std::vector<Bytes> tile16_individual_data_;
|
||||
std::vector<std::vector<uint8_t>> tile16_individual_data_;
|
||||
std::vector<gfx::Bitmap> tile16_individual_;
|
||||
|
||||
std::vector<gfx::Bitmap> current_gfx_individual_;
|
||||
|
||||
@@ -706,30 +706,6 @@ std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) {
|
||||
return message;
|
||||
}
|
||||
|
||||
// push_backs a command to the text field when the push_back command button is
|
||||
// pressed or the command is double clicked in the list.
|
||||
void MessageEditor::InsertCommandButton_Click_1() {
|
||||
// InsertSelectedText(
|
||||
// TextCommands[TextCommandList.SelectedIndex].GetParameterizedToken(
|
||||
// (uint8_t)ParamsBox.HexValue));
|
||||
}
|
||||
|
||||
// push_backs a special character to the text field when the push_back command
|
||||
// button is pressed or the character is double clicked in the list.
|
||||
void MessageEditor::InsertSpecialButton_Click() {
|
||||
// InsertSelectedText(
|
||||
// SpecialChars[SpecialsList.SelectedIndex].GetParameterizedToken());
|
||||
}
|
||||
|
||||
void MessageEditor::InsertSelectedText(std::string str) {
|
||||
int textboxPos = message_text_box_.selection_start;
|
||||
from_form = true;
|
||||
// message_text_box_.Text = message_text_box_.Text.Insert(textboxPos, str);
|
||||
from_form = false;
|
||||
message_text_box_.selection_start = textboxPos + str.size();
|
||||
message_text_box_.Focus();
|
||||
}
|
||||
|
||||
void MessageEditor::Delete() {
|
||||
// Determine if any text is selected in the TextBox control.
|
||||
if (message_text_box_.selection_length == 0) {
|
||||
|
||||
@@ -109,10 +109,6 @@ class MessageEditor : public Editor, public SharedRom {
|
||||
void DrawMessagePreview();
|
||||
std::string DisplayTextOverflowError(int pos, bool bank);
|
||||
|
||||
void InsertCommandButton_Click_1();
|
||||
void InsertSpecialButton_Click();
|
||||
void InsertSelectedText(std::string str);
|
||||
|
||||
private:
|
||||
bool skip_next = false;
|
||||
bool from_form = false;
|
||||
@@ -133,8 +129,8 @@ class MessageEditor : public Editor, public SharedRom {
|
||||
|
||||
MessageData current_message_;
|
||||
|
||||
Bytes font_gfx16_data_;
|
||||
Bytes current_font_gfx16_data_;
|
||||
std::vector<uint8_t> font_gfx16_data_;
|
||||
std::vector<uint8_t> current_font_gfx16_data_;
|
||||
|
||||
gfx::Bitmap font_gfx_bitmap_;
|
||||
gfx::Bitmap current_font_gfx16_bitmap_;
|
||||
|
||||
@@ -132,7 +132,7 @@ absl::Status OverworldEditor::DrawToolset() {
|
||||
static bool show_gfx_group = false;
|
||||
static bool show_properties = false;
|
||||
|
||||
if (BeginTable("OWToolset", 23, kToolsetTableFlags, ImVec2(0, 0))) {
|
||||
if (BeginTable("OWToolset", 22, kToolsetTableFlags, ImVec2(0, 0))) {
|
||||
for (const auto &name : kToolsetColumnNames)
|
||||
ImGui::TableSetupColumn(name.data());
|
||||
|
||||
@@ -243,19 +243,12 @@ absl::Status OverworldEditor::DrawToolset() {
|
||||
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
|
||||
TableNextColumn(); // Experimental
|
||||
Checkbox("Experimental", &show_experimental);
|
||||
|
||||
TableNextColumn();
|
||||
Checkbox("Properties", &show_properties);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
if (show_experimental) {
|
||||
RETURN_IF_ERROR(DrawExperimentalModal())
|
||||
}
|
||||
|
||||
if (show_tile16_editor_) {
|
||||
// Create a table in ImGui for the Tile16 Editor
|
||||
ImGui::Begin("Tile16 Editor", &show_tile16_editor_,
|
||||
@@ -428,7 +421,7 @@ void OverworldEditor::DrawOverworldEdits() {
|
||||
}
|
||||
|
||||
void OverworldEditor::RenderUpdatedMapBitmap(const ImVec2 &click_position,
|
||||
const Bytes &tile_data) {
|
||||
const std::vector<uint8_t> &tile_data) {
|
||||
// Calculate the tile position relative to the current active map
|
||||
constexpr int tile_size = 16; // Tile size is 16x16 pixels
|
||||
|
||||
@@ -987,8 +980,6 @@ void OverworldEditor::DrawOverworldSprites() {
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
absl::Status OverworldEditor::LoadGraphics() {
|
||||
// Load the Link to the Past overworld.
|
||||
RETURN_IF_ERROR(overworld_.Load(*rom()))
|
||||
@@ -1011,7 +1002,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
// Loop through the tiles and copy their pixel data into separate vectors
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
// Create a new vector for the pixel data of the current tile
|
||||
Bytes tile_data(16 * 16, 0x00); // More efficient initialization
|
||||
std::vector<uint8_t> tile_data(16 * 16, 0x00); // More efficient initialization
|
||||
|
||||
// Copy the pixel data for the current tile into the vector
|
||||
for (int ty = 0; ty < 16; ty++) {
|
||||
@@ -1127,55 +1118,6 @@ void OverworldEditor::DrawOverworldProperties() {
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::DrawExperimentalModal() {
|
||||
ImGui::Begin("Experimental", &show_experimental);
|
||||
|
||||
DrawDebugWindow();
|
||||
|
||||
gui::TextWithSeparators("PROTOTYPE OVERWORLD TILEMAP LOADER");
|
||||
Text("Please provide two files:");
|
||||
Text("One based on MAPn.DAT, which represents the overworld tilemap");
|
||||
Text("One based on MAPDATn.DAT, which is the tile32 configurations.");
|
||||
Text("Currently, loading CGX for this component is NOT supported. ");
|
||||
Text("Please load a US ROM of LTTP (JP ROM support coming soon).");
|
||||
Text(
|
||||
"Once you've loaded the files, you can click the button below to load "
|
||||
"the tilemap into the editor");
|
||||
|
||||
ImGui::InputText("##TilemapFile", &ow_tilemap_filename_);
|
||||
SameLine();
|
||||
gui::FileDialogPipeline(
|
||||
"ImportTilemapsKey", ".DAT,.dat\0", "Tilemap Hex File", [this]() {
|
||||
ow_tilemap_filename_ = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
});
|
||||
|
||||
ImGui::InputText("##Tile32ConfigurationFile",
|
||||
&tile32_configuration_filename_);
|
||||
SameLine();
|
||||
gui::FileDialogPipeline("ImportTile32Key", ".DAT,.dat\0", "Tile32 Hex File",
|
||||
[this]() {
|
||||
tile32_configuration_filename_ =
|
||||
ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
});
|
||||
|
||||
if (Button("Load Prototype Overworld with ROM graphics")) {
|
||||
RETURN_IF_ERROR(LoadGraphics())
|
||||
all_gfx_loaded_ = true;
|
||||
}
|
||||
|
||||
gui::TextWithSeparators("Configuration");
|
||||
|
||||
gui::InputHexShort("Tilemap File Offset (High)", &tilemap_file_offset_high_);
|
||||
gui::InputHexShort("Tilemap File Offset (Low)", &tilemap_file_offset_low_);
|
||||
|
||||
gui::InputHexShort("LW Maps to Load", &light_maps_to_load_);
|
||||
gui::InputHexShort("DW Maps to Load", &dark_maps_to_load_);
|
||||
gui::InputHexShort("SP Maps to Load", &sp_maps_to_load_);
|
||||
|
||||
ImGui::End();
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::UpdateUsageStats() {
|
||||
if (BeginTable("UsageStatsTable", 3, kOWEditFlags, ImVec2(0, 0))) {
|
||||
TableSetupColumn("Entrances");
|
||||
@@ -1226,16 +1168,6 @@ absl::Status OverworldEditor::UpdateUsageStats() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void OverworldEditor::CalculateUsageStats() {
|
||||
absl::flat_hash_map<uint16_t, int> entrance_usage;
|
||||
for (auto each_entrance : overworld_.entrances()) {
|
||||
if (each_entrance.map_id_ < 0x40 + (current_world_ * 0x40) &&
|
||||
each_entrance.map_id_ >= (current_world_ * 0x40)) {
|
||||
entrance_usage[each_entrance.entrance_id_]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawUsageGrid() {
|
||||
// Create a grid of 8x8 squares
|
||||
int totalSquares = 128;
|
||||
@@ -1284,37 +1216,6 @@ void OverworldEditor::DrawUsageGrid() {
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::LoadAnimatedMaps() {
|
||||
int world_index = 0;
|
||||
static std::vector<bool> animated_built(0x40, false);
|
||||
if (!animated_built[world_index]) {
|
||||
animated_maps_[world_index] = maps_bmp_[world_index];
|
||||
auto &map = *overworld_.mutable_overworld_map(world_index);
|
||||
map.DrawAnimatedTiles();
|
||||
RETURN_IF_ERROR(map.BuildTileset());
|
||||
RETURN_IF_ERROR(map.BuildTiles16Gfx(overworld_.tiles16().size()));
|
||||
zelda3::OWBlockset blockset;
|
||||
if (current_world_ == 0) {
|
||||
blockset = overworld_.map_tiles().light_world;
|
||||
} else if (current_world_ == 1) {
|
||||
blockset = overworld_.map_tiles().dark_world;
|
||||
} else {
|
||||
blockset = overworld_.map_tiles().special_world;
|
||||
}
|
||||
RETURN_IF_ERROR(map.BuildBitmap(blockset));
|
||||
|
||||
RETURN_IF_ERROR(Renderer::GetInstance().CreateAndRenderBitmap(
|
||||
kOverworldMapSize, kOverworldMapSize, 0x200, map.bitmap_data(),
|
||||
animated_maps_[world_index], *map.mutable_current_palette()));
|
||||
|
||||
animated_built[world_index] = true;
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OverworldEditor::DrawDebugWindow() {
|
||||
Text("Current Map: %d", current_map_);
|
||||
Text("Current Tile16: %d", current_tile16_);
|
||||
|
||||
@@ -37,11 +37,11 @@ static constexpr uint kTile8DisplayHeight = 64;
|
||||
static constexpr float kInputFieldSize = 30.f;
|
||||
|
||||
static constexpr absl::string_view kToolsetColumnNames[] = {
|
||||
"#undoTool", "#redoTool", "#separator2", "#zoomOutTool",
|
||||
"#zoomInTool", "#separator", "#drawTool", "#history",
|
||||
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
||||
"#transportTool", "#musicTool", "#separator3", "#tilemapTool",
|
||||
"propertiesTool"};
|
||||
"#undoTool", "#redoTool", "#separator2", "#zoomOutTool",
|
||||
"#zoomInTool", "#separator", "#drawTool", "#history",
|
||||
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
||||
"#transportTool", "#musicTool", "#separator3", "#tilemapTool",
|
||||
"propertiesTool", "#separator4", "#experimentalTool"};
|
||||
|
||||
constexpr ImGuiTableFlags kOWMapFlags =
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable;
|
||||
@@ -156,7 +156,7 @@ class OverworldEditor : public Editor,
|
||||
void DrawOverworldMaps();
|
||||
void DrawOverworldEdits();
|
||||
void RenderUpdatedMapBitmap(const ImVec2& click_position,
|
||||
const Bytes& tile_data);
|
||||
const std::vector<uint8_t>& tile_data);
|
||||
void CheckForOverworldEdits();
|
||||
void CheckForSelectRectangle();
|
||||
absl::Status CheckForCurrentMap();
|
||||
@@ -176,13 +176,9 @@ class OverworldEditor : public Editor,
|
||||
|
||||
void DrawOverworldProperties();
|
||||
|
||||
absl::Status DrawExperimentalModal();
|
||||
|
||||
absl::Status UpdateUsageStats();
|
||||
void DrawUsageGrid();
|
||||
void CalculateUsageStats();
|
||||
|
||||
absl::Status LoadAnimatedMaps();
|
||||
void DrawDebugWindow();
|
||||
|
||||
auto gfx_group_editor() const { return gfx_group_editor_; }
|
||||
@@ -204,12 +200,14 @@ class OverworldEditor : public Editor,
|
||||
int current_world_ = 0;
|
||||
int current_map_ = 0;
|
||||
int current_parent_ = 0;
|
||||
int current_entrance_id_ = 0;
|
||||
int current_exit_id_ = 0;
|
||||
int current_item_id_ = 0;
|
||||
int current_sprite_id_ = 0;
|
||||
int game_state_ = 1;
|
||||
int current_tile16_ = 0;
|
||||
int selected_tile_ = 0;
|
||||
|
||||
int current_blockset_ = 0;
|
||||
|
||||
int selected_entrance_ = 0;
|
||||
int selected_usage_map_ = 0xFFFF;
|
||||
|
||||
@@ -220,12 +218,6 @@ class OverworldEditor : public Editor,
|
||||
char message_id_[5] = "";
|
||||
char staticgfx[16];
|
||||
|
||||
uint32_t tilemap_file_offset_high_ = 0;
|
||||
uint32_t tilemap_file_offset_low_ = 0;
|
||||
uint32_t light_maps_to_load_ = 0x51;
|
||||
uint32_t dark_maps_to_load_ = 0x2A;
|
||||
uint32_t sp_maps_to_load_ = 0x07;
|
||||
|
||||
bool opt_enable_grid = true;
|
||||
bool all_gfx_loaded_ = false;
|
||||
bool map_blockset_loaded_ = false;
|
||||
@@ -236,29 +228,20 @@ class OverworldEditor : public Editor,
|
||||
bool show_gfx_group_editor_ = false;
|
||||
bool overworld_canvas_fullscreen_ = false;
|
||||
bool middle_mouse_dragging_ = false;
|
||||
|
||||
bool is_dragging_entity_ = false;
|
||||
|
||||
zelda3::OverworldEntity* dragged_entity_;
|
||||
zelda3::OverworldEntity* current_entity_;
|
||||
|
||||
int current_entrance_id_ = 0;
|
||||
zelda3::overworld::OverworldEntrance current_entrance_;
|
||||
int current_exit_id_ = 0;
|
||||
zelda3::overworld::OverworldExit current_exit_;
|
||||
int current_item_id_ = 0;
|
||||
zelda3::overworld::OverworldItem current_item_;
|
||||
int current_sprite_id_ = 0;
|
||||
zelda3::Sprite current_sprite_;
|
||||
|
||||
bool show_experimental = false;
|
||||
std::string ow_tilemap_filename_ = "";
|
||||
std::string tile32_configuration_filename_ = "";
|
||||
|
||||
Bytes selected_tile_data_;
|
||||
std::vector<Bytes> tile16_individual_data_;
|
||||
std::vector<uint8_t> selected_tile_data_;
|
||||
std::vector<std::vector<uint8_t>> tile16_individual_data_;
|
||||
std::vector<gfx::Bitmap> tile16_individual_;
|
||||
|
||||
std::vector<Bytes> tile8_individual_data_;
|
||||
std::vector<std::vector<uint8_t>> tile8_individual_data_;
|
||||
std::vector<gfx::Bitmap> tile8_individual_;
|
||||
|
||||
Tile16Editor tile16_editor_;
|
||||
@@ -287,7 +270,6 @@ class OverworldEditor : public Editor,
|
||||
gfx::BitmapTable maps_bmp_;
|
||||
gfx::BitmapTable current_graphics_set_;
|
||||
gfx::BitmapTable sprite_previews_;
|
||||
gfx::BitmapTable animated_maps_;
|
||||
|
||||
zelda3::OWBlockset refresh_blockset_;
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ absl::Status OverworldEditor::RefreshTile16Blockset() {
|
||||
std::launch::async,
|
||||
[&](int index) {
|
||||
// Create a new vector for the pixel data of the current tile
|
||||
Bytes tile_data(16 * 16, 0x00); // More efficient initialization
|
||||
std::vector<uint8_t> tile_data(16 * 16, 0x00); // More efficient initialization
|
||||
|
||||
// Copy the pixel data for the current tile into the vector
|
||||
for (int ty = 0; ty < 16; ty++) {
|
||||
|
||||
@@ -101,7 +101,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
Rom rom_;
|
||||
emu::SNES snes_;
|
||||
Bytes rom_data_;
|
||||
std::vector<uint8_t> rom_data_;
|
||||
|
||||
bool running = true;
|
||||
bool loaded = false;
|
||||
|
||||
@@ -226,15 +226,15 @@ void Bitmap::SaveSurfaceToFile(std::string_view filename) {
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(int width, int height, int depth, int data_size) {
|
||||
Create(width, height, depth, Bytes(data_size, 0));
|
||||
Create(width, height, depth, std::vector<uint8_t>(data_size, 0));
|
||||
}
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, const Bytes &data) {
|
||||
void Bitmap::Create(int width, int height, int depth, const std::vector<uint8_t> &data) {
|
||||
Create(width, height, depth, kIndexed, data);
|
||||
}
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, int format,
|
||||
const Bytes &data) {
|
||||
const std::vector<uint8_t> &data) {
|
||||
if (data.empty()) {
|
||||
SDL_Log("Bitmap data is empty\n");
|
||||
active_ = false;
|
||||
|
||||
@@ -72,11 +72,11 @@ class Bitmap {
|
||||
Bitmap() = default;
|
||||
|
||||
Bitmap(int width, int height, int depth, int data_size);
|
||||
Bitmap(int width, int height, int depth, const Bytes &data)
|
||||
Bitmap(int width, int height, int depth, const std::vector<uint8_t> &data)
|
||||
: width_(width), height_(height), depth_(depth), data_(data) {
|
||||
Create(width, height, depth, data);
|
||||
}
|
||||
Bitmap(int width, int height, int depth, const Bytes &data,
|
||||
Bitmap(int width, int height, int depth, const std::vector<uint8_t> &data,
|
||||
const SnesPalette &palette)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
@@ -98,8 +98,8 @@ class Bitmap {
|
||||
/**
|
||||
* @brief Creates a bitmap object with the provided graphical data.
|
||||
*/
|
||||
void Create(int width, int height, int depth, const Bytes &data);
|
||||
void Create(int width, int height, int depth, int format, const Bytes &data);
|
||||
void Create(int width, int height, int depth, const std::vector<uint8_t> &data);
|
||||
void Create(int width, int height, int depth, int format, const std::vector<uint8_t> &data);
|
||||
|
||||
void Reformat(int format);
|
||||
|
||||
@@ -192,7 +192,7 @@ class Bitmap {
|
||||
auto modified() const { return modified_; }
|
||||
auto is_active() const { return active_; }
|
||||
void set_active(bool active) { active_ = active; }
|
||||
void set_data(const Bytes &data) { data_ = data; }
|
||||
void set_data(const std::vector<uint8_t> &data) { data_ = data; }
|
||||
void set_modified(bool modified) { modified_ = modified; }
|
||||
|
||||
private:
|
||||
@@ -207,7 +207,7 @@ class Bitmap {
|
||||
void *texture_pixels = nullptr;
|
||||
|
||||
uint8_t *pixel_data_ = nullptr;
|
||||
Bytes data_;
|
||||
std::vector<uint8_t> data_;
|
||||
|
||||
std::vector<uint8_t> png_data_;
|
||||
|
||||
|
||||
@@ -413,10 +413,11 @@ absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
||||
return new_piece;
|
||||
}
|
||||
|
||||
Bytes CreateCompressionString(CompressionPiecePointer& start, int mode) {
|
||||
std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start,
|
||||
int mode) {
|
||||
uint pos = 0;
|
||||
auto piece = start;
|
||||
Bytes output;
|
||||
std::vector<uint8_t> output;
|
||||
|
||||
while (piece != nullptr) {
|
||||
if (piece->length <= kMaxLengthNormalHeader) { // Normal header
|
||||
@@ -515,12 +516,13 @@ CompressionPiecePointer MergeCopy(CompressionPiecePointer& start) {
|
||||
return start;
|
||||
}
|
||||
|
||||
// TODO TEST compressed data border for each cmd
|
||||
absl::StatusOr<Bytes> CompressV2(const uchar* data, const int start,
|
||||
const int length, int mode, bool check) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
||||
const int start,
|
||||
const int length, int mode,
|
||||
bool check) {
|
||||
// Surely there's no need to compress zero...
|
||||
if (length == 0) {
|
||||
return Bytes();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
// Worst case should be a copy of the string with extended header
|
||||
@@ -868,18 +870,20 @@ uint8_t* Uncompress(uint8_t const* src, int* const size,
|
||||
return b2;
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressGraphics(const uchar* data, const int pos,
|
||||
const int length) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uchar* data,
|
||||
const int pos,
|
||||
const int length) {
|
||||
return CompressV2(data, pos, length, kNintendoMode2);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressOverworld(const uchar* data, const int pos,
|
||||
const int length) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uchar* data,
|
||||
const int pos,
|
||||
const int length) {
|
||||
return CompressV2(data, pos, length, kNintendoMode1);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressOverworld(const std::vector<uint8_t> data,
|
||||
const int pos, const int length) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(
|
||||
const std::vector<uint8_t> data, const int pos, const int length) {
|
||||
return CompressV3(data, pos, length, kNintendoMode1);
|
||||
}
|
||||
|
||||
@@ -1304,11 +1308,11 @@ void FinalizeCompression(CompressionContext& context) {
|
||||
<< context.compressed_data.size());
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> CompressV3(const std::vector<uint8_t>& data,
|
||||
const int start, const int length, int mode,
|
||||
bool check) {
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV3(
|
||||
const std::vector<uint8_t>& data, const int start, const int length,
|
||||
int mode, bool check) {
|
||||
if (length == 0) {
|
||||
return Bytes();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
CompressionContext context(data, start, length, mode);
|
||||
@@ -1332,7 +1336,8 @@ absl::StatusOr<Bytes> CompressV3(const std::vector<uint8_t>& data,
|
||||
}
|
||||
|
||||
FinalizeCompression(context);
|
||||
return Bytes(context.compressed_data.begin(), context.compressed_data.end());
|
||||
return std::vector<uint8_t>(context.compressed_data.begin(),
|
||||
context.compressed_data.end());
|
||||
}
|
||||
|
||||
// Decompression
|
||||
@@ -1354,8 +1359,8 @@ std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void memfill(const uchar* data, Bytes& buffer, int buffer_pos, int offset,
|
||||
int length) {
|
||||
void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
||||
int offset, int length) {
|
||||
auto a = data[offset];
|
||||
auto b = data[offset + 1];
|
||||
for (int i = 0; i < length; i = i + 2) {
|
||||
@@ -1364,13 +1369,13 @@ void memfill(const uchar* data, Bytes& buffer, int buffer_pos, int offset,
|
||||
}
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressV2(const uchar* data, int offset, int size,
|
||||
int mode) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
||||
int size, int mode) {
|
||||
if (size == 0) {
|
||||
return Bytes();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
Bytes buffer(size, 0);
|
||||
std::vector<uint8_t> buffer(size, 0);
|
||||
uint length = 0;
|
||||
uint buffer_pos = 0;
|
||||
uchar command = 0;
|
||||
@@ -1451,17 +1456,18 @@ absl::StatusOr<Bytes> DecompressV2(const uchar* data, int offset, int size,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressGraphics(const uchar* data, int pos, int size) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uchar* data,
|
||||
int pos, int size) {
|
||||
return DecompressV2(data, pos, size, kNintendoMode2);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const uchar* data, int pos,
|
||||
int size) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uchar* data,
|
||||
int pos, int size) {
|
||||
return DecompressV2(data, pos, size, kNintendoMode1);
|
||||
}
|
||||
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const std::vector<uint8_t> data,
|
||||
int pos, int size) {
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(
|
||||
const std::vector<uint8_t> data, int pos, int size) {
|
||||
return DecompressV2(data.data(), pos, size, kNintendoMode1);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,21 +142,21 @@ void CompressionCommandAlternativeV2(const uchar* data,
|
||||
* @brief Compresses a buffer of data using the LC_LZ2 algorithm.
|
||||
* \deprecated Use Compress and Uncompress instead.
|
||||
*/
|
||||
absl::StatusOr<Bytes> CompressV2(const uchar* data, const int start,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data, const int start,
|
||||
const int length, int mode = 1,
|
||||
bool check = false);
|
||||
|
||||
absl::StatusOr<Bytes> CompressGraphics(const uchar* data, const int pos,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uchar* data, const int pos,
|
||||
const int length);
|
||||
absl::StatusOr<Bytes> CompressOverworld(const uchar* data, const int pos,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uchar* data, const int pos,
|
||||
const int length);
|
||||
absl::StatusOr<Bytes> CompressOverworld(const std::vector<uint8_t> data,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const std::vector<uint8_t> data,
|
||||
const int pos, const int length);
|
||||
|
||||
absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
||||
CompressionPiecePointer& piece, int mode);
|
||||
|
||||
Bytes CreateCompressionString(CompressionPiecePointer& start, int mode);
|
||||
std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start, int mode);
|
||||
|
||||
absl::Status ValidateCompressionResult(CompressionPiecePointer& chain_head,
|
||||
int mode, int start, int src_data_pos);
|
||||
@@ -213,7 +213,7 @@ void FinalizeCompression(CompressionContext& context);
|
||||
* @brief Compresses a buffer of data using the LC_LZ2 algorithm.
|
||||
* \deprecated Use Compress and Uncompress instead.
|
||||
*/
|
||||
absl::StatusOr<Bytes> CompressV3(const std::vector<uint8_t>& data,
|
||||
absl::StatusOr<std::vector<uint8_t>> CompressV3(const std::vector<uint8_t>& data,
|
||||
const int start, const int length,
|
||||
int mode = 1, bool check = false);
|
||||
|
||||
@@ -229,18 +229,18 @@ uint8_t* Uncompress(uint8_t const* src, int* const size,
|
||||
std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
||||
int comp_accumulator);
|
||||
std::string SetBuffer(const uchar* data, int src_pos, int comp_accumulator);
|
||||
void memfill(const uchar* data, Bytes& buffer, int buffer_pos, int offset,
|
||||
void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos, int offset,
|
||||
int length);
|
||||
|
||||
/**
|
||||
* @brief Decompresses a buffer of data using the LC_LZ2 algorithm.
|
||||
* \deprecated Use Compress and Uncompress instead.
|
||||
*/
|
||||
absl::StatusOr<Bytes> DecompressV2(const uchar* data, int offset,
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
||||
int size = 0x800, int mode = 1);
|
||||
absl::StatusOr<Bytes> DecompressGraphics(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<Bytes> DecompressOverworld(const std::vector<uint8_t> data,
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uchar* data, int pos, int size);
|
||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const std::vector<uint8_t> data,
|
||||
int pos, int size);
|
||||
|
||||
} // namespace lc_lz2
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace scad_format {
|
||||
void FindMetastamp() {
|
||||
int matching_position = -1;
|
||||
bool matched = false;
|
||||
Bytes cgx_rom;
|
||||
Bytes raw_data_;
|
||||
std::vector<uint8_t> cgx_rom;
|
||||
std::vector<uint8_t> raw_data_;
|
||||
for (int i = 0;
|
||||
i < cgx_rom.size() - sizeof(kMatchedBytes) - kOffsetFromMatchedBytesEnd;
|
||||
i++) {
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace gfx {
|
||||
* @brief Internal functions for loading palettes by group.
|
||||
*/
|
||||
namespace palette_group_internal {
|
||||
absl::Status LoadOverworldMainPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadOverworldMainPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -37,7 +37,7 @@ absl::Status LoadOverworldMainPalettes(const Bytes& rom_data,
|
||||
}
|
||||
|
||||
absl::Status LoadOverworldAuxiliaryPalettes(
|
||||
const Bytes& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
const std::vector<uint8_t>& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
palette_groups.overworld_aux.AddPalette(
|
||||
@@ -48,7 +48,7 @@ absl::Status LoadOverworldAuxiliaryPalettes(
|
||||
}
|
||||
|
||||
absl::Status LoadOverworldAnimatedPalettes(
|
||||
const Bytes& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
const std::vector<uint8_t>& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 14; i++) {
|
||||
palette_groups.overworld_animated.AddPalette(gfx::ReadPaletteFromRom(
|
||||
@@ -57,7 +57,7 @@ absl::Status LoadOverworldAnimatedPalettes(
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadHUDPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadHUDPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@@ -67,7 +67,7 @@ absl::Status LoadHUDPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadGlobalSpritePalettes(const Bytes& rom_data,
|
||||
absl::Status LoadGlobalSpritePalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
palette_groups.global_sprites.AddPalette(
|
||||
@@ -77,7 +77,7 @@ absl::Status LoadGlobalSpritePalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadArmorPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadArmorPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -87,7 +87,7 @@ absl::Status LoadArmorPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSwordPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadSwordPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -97,7 +97,7 @@ absl::Status LoadSwordPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadShieldPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadShieldPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -107,7 +107,7 @@ absl::Status LoadShieldPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSpriteAux1Palettes(const Bytes& rom_data,
|
||||
absl::Status LoadSpriteAux1Palettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 12; i++) {
|
||||
@@ -117,7 +117,7 @@ absl::Status LoadSpriteAux1Palettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSpriteAux2Palettes(const Bytes& rom_data,
|
||||
absl::Status LoadSpriteAux2Palettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 11; i++) {
|
||||
@@ -127,7 +127,7 @@ absl::Status LoadSpriteAux2Palettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadSpriteAux3Palettes(const Bytes& rom_data,
|
||||
absl::Status LoadSpriteAux3Palettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 24; i++) {
|
||||
@@ -137,7 +137,7 @@ absl::Status LoadSpriteAux3Palettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadDungeonMainPalettes(const Bytes& rom_data,
|
||||
absl::Status LoadDungeonMainPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
@@ -147,7 +147,7 @@ absl::Status LoadDungeonMainPalettes(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status LoadGrassColors(const Bytes& rom_data,
|
||||
absl::Status LoadGrassColors(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
palette_groups.grass.AddColor(
|
||||
gfx::ReadColorFromRom(kHardcodedGrassLW, rom_data.data()));
|
||||
@@ -158,7 +158,7 @@ absl::Status LoadGrassColors(const Bytes& rom_data,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Load3DObjectPalettes(const Bytes& rom_data,
|
||||
absl::Status Load3DObjectPalettes(const std::vector<uint8_t>& rom_data,
|
||||
gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
palette_groups.object_3d.AddPalette(
|
||||
@@ -169,7 +169,7 @@ absl::Status Load3DObjectPalettes(const Bytes& rom_data,
|
||||
}
|
||||
|
||||
absl::Status LoadOverworldMiniMapPalettes(
|
||||
const Bytes& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
const std::vector<uint8_t>& rom_data, gfx::PaletteGroupMap& palette_groups) {
|
||||
auto data = rom_data.data();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
palette_groups.overworld_mini_map.AddPalette(gfx::ReadPaletteFromRom(
|
||||
@@ -327,7 +327,7 @@ absl::StatusOr<PaletteGroup> CreatePaletteGroupFromLargePalette(
|
||||
using namespace palette_group_internal;
|
||||
|
||||
// TODO: Refactor LoadAllPalettes to use group names, move to zelda3 namespace
|
||||
absl::Status LoadAllPalettes(const Bytes& rom_data, PaletteGroupMap& groups) {
|
||||
absl::Status LoadAllPalettes(const std::vector<uint8_t>& rom_data, PaletteGroupMap& groups) {
|
||||
RETURN_IF_ERROR(LoadOverworldMainPalettes(rom_data, groups))
|
||||
RETURN_IF_ERROR(LoadOverworldAuxiliaryPalettes(rom_data, groups))
|
||||
RETURN_IF_ERROR(LoadOverworldAnimatedPalettes(rom_data, groups))
|
||||
|
||||
@@ -352,7 +352,7 @@ absl::StatusOr<PaletteGroup> CreatePaletteGroupFromLargePalette(
|
||||
* groups.
|
||||
*
|
||||
*/
|
||||
absl::Status LoadAllPalettes(const Bytes& rom_data, PaletteGroupMap& groups);
|
||||
absl::Status LoadAllPalettes(const std::vector<uint8_t>& rom_data, PaletteGroupMap& groups);
|
||||
|
||||
/**
|
||||
* @brief Represents a set of palettes used in a SNES graphics system.
|
||||
|
||||
@@ -22,7 +22,7 @@ constexpr ushort TileVFlipBit = 0x8000;
|
||||
// Bits used for tile name
|
||||
constexpr ushort TileNameMask = 0x03FF;
|
||||
|
||||
tile8 UnpackBppTile(const Bytes& data, const uint32_t offset,
|
||||
tile8 UnpackBppTile(const std::vector<uint8_t>& data, const uint32_t offset,
|
||||
const uint32_t bpp) {
|
||||
tile8 tile;
|
||||
assert(bpp >= 1 && bpp <= 8);
|
||||
@@ -79,7 +79,7 @@ tile8 UnpackBppTile(const Bytes& data, const uint32_t offset,
|
||||
return tile;
|
||||
}
|
||||
|
||||
Bytes PackBppTile(const tile8& tile, const uint32_t bpp) {
|
||||
std::vector<uint8_t> PackBppTile(const tile8& tile, const uint32_t bpp) {
|
||||
// Allocate memory for output data
|
||||
std::vector<uint8_t> output(bpp * 8, 0); // initialized with 0
|
||||
unsigned maxcolor = 2 << bpp;
|
||||
@@ -148,7 +148,7 @@ std::vector<uint8_t> Convert4bppTo3bpp(const std::vector<uint8_t>& tiles) {
|
||||
return ConvertBpp(tiles, 4, 3);
|
||||
}
|
||||
|
||||
Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp) {
|
||||
std::vector<uint8_t> SnesTo8bppSheet(const std::vector<uint8_t>& sheet, int bpp) {
|
||||
int xx = 0; // positions where we are at on the sheet
|
||||
int yy = 0;
|
||||
int pos = 0;
|
||||
@@ -167,7 +167,7 @@ Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp) {
|
||||
} else if (bpp == 8) {
|
||||
bpp = 64;
|
||||
}
|
||||
Bytes sheet_buffer_out(buffer_size);
|
||||
std::vector<uint8_t> sheet_buffer_out(buffer_size);
|
||||
|
||||
for (int i = 0; i < num_tiles; i++) { // for each tiles, 16 per line
|
||||
for (int y = 0; y < 8; y++) { // for each line
|
||||
@@ -200,7 +200,7 @@ Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp) {
|
||||
return sheet_buffer_out;
|
||||
}
|
||||
|
||||
Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp) {
|
||||
std::vector<uint8_t> Bpp8SnesToIndexed(std::vector<uint8_t> data, uint64_t bpp) {
|
||||
// 3BPP
|
||||
// [r0,bp1],[r0,bp2],[r1,bp1],[r1,bp2],[r2,bp1],[r2,bp2],[r3,bp1],[r3,bp2]
|
||||
// [r4,bp1],[r4,bp2],[r5,bp1],[r5,bp2],[r6,bp1],[r6,bp2],[r7,bp1],[r7,bp2]
|
||||
@@ -212,7 +212,7 @@ Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp) {
|
||||
// [r4,bp7],[r4,bp8],[r5,bp7],[r5,bp8],[r6,bp7],[r6,bp8],[r7,bp7],[r7,bp8]
|
||||
|
||||
// 16 tiles = 1024 bytes
|
||||
auto buffer = Bytes(data.size());
|
||||
auto buffer = std::vector<uint8_t>(data.size());
|
||||
std::vector<std::vector<uint8_t>> bitmap_data;
|
||||
bitmap_data.resize(0x80);
|
||||
for (auto& each : bitmap_data) {
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace gfx {
|
||||
constexpr uint8_t kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10,
|
||||
0x08, 0x04, 0x02, 0x01};
|
||||
|
||||
Bytes SnesTo8bppSheet(const Bytes& sheet, int bpp);
|
||||
Bytes Bpp8SnesToIndexed(Bytes data, uint64_t bpp = 0);
|
||||
std::vector<uint8_t> SnesTo8bppSheet(const std::vector<uint8_t>& sheet, int bpp);
|
||||
std::vector<uint8_t> Bpp8SnesToIndexed(std::vector<uint8_t> data, uint64_t bpp = 0);
|
||||
|
||||
struct tile8 {
|
||||
uint32_t id;
|
||||
@@ -24,10 +24,10 @@ struct tile8 {
|
||||
};
|
||||
using tile8 = struct tile8;
|
||||
|
||||
tile8 UnpackBppTile(const Bytes& data, const uint32_t offset,
|
||||
tile8 UnpackBppTile(const std::vector<uint8_t>& data, const uint32_t offset,
|
||||
const uint32_t bpp);
|
||||
|
||||
Bytes PackBppTile(const tile8& tile, const uint32_t bpp);
|
||||
std::vector<uint8_t> PackBppTile(const tile8& tile, const uint32_t bpp);
|
||||
|
||||
std::vector<uint8_t> ConvertBpp(const std::vector<uint8_t>& tiles,
|
||||
uint32_t from_bpp, uint32_t to_bpp);
|
||||
|
||||
@@ -42,8 +42,8 @@ int GetGraphicsAddress(const uchar* data, uint8_t addr, uint32_t ptr1,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
absl::StatusOr<Bytes> Rom::Load2BppGraphics() {
|
||||
Bytes sheet;
|
||||
absl::StatusOr<std::vector<uint8_t>> Rom::Load2BppGraphics() {
|
||||
std::vector<uint8_t> sheet;
|
||||
const uint8_t sheets[] = {113, 114, 218, 219, 220, 221};
|
||||
|
||||
for (const auto& sheet_id : sheets) {
|
||||
@@ -81,7 +81,7 @@ absl::Status Rom::LoadLinkGraphics() {
|
||||
}
|
||||
|
||||
absl::Status Rom::LoadAllGraphicsData() {
|
||||
Bytes sheet;
|
||||
std::vector<uint8_t> sheet;
|
||||
bool bpp3 = false;
|
||||
|
||||
for (int i = 0; i < kNumGfxSheets; i++) {
|
||||
@@ -237,7 +237,7 @@ absl::Status Rom::LoadZelda3() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Rom::LoadFromBytes(const Bytes& data) {
|
||||
absl::Status Rom::LoadFromBytes(const std::vector<uint8_t>& data) {
|
||||
if (data.empty()) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Could not load ROM: parameter `data` is empty.");
|
||||
|
||||
@@ -142,7 +142,7 @@ class Rom : public core::ExperimentFlags {
|
||||
* appending the converted sheet data to a byte vector.
|
||||
*
|
||||
*/
|
||||
absl::StatusOr<Bytes> Load2BppGraphics();
|
||||
absl::StatusOr<std::vector<uint8_t>> Load2BppGraphics();
|
||||
|
||||
/**
|
||||
* @brief Loads the players 4bpp graphics sheet from Rom data.
|
||||
@@ -178,7 +178,7 @@ class Rom : public core::ExperimentFlags {
|
||||
*/
|
||||
absl::Status LoadFromFile(const std::string& filename, bool z3_load = true);
|
||||
absl::Status LoadFromPointer(uchar* data, size_t length, bool z3_load = true);
|
||||
absl::Status LoadFromBytes(const Bytes& data);
|
||||
absl::Status LoadFromBytes(const std::vector<uint8_t>& data);
|
||||
|
||||
/**
|
||||
* @brief Saves the Rom data to a file
|
||||
@@ -431,7 +431,7 @@ class Rom : public core::ExperimentFlags {
|
||||
}
|
||||
|
||||
// Full graphical data for the game
|
||||
Bytes graphics_buffer() const { return graphics_buffer_; }
|
||||
std::vector<uint8_t> graphics_buffer() const { return graphics_buffer_; }
|
||||
|
||||
auto link_graphics() { return link_graphics_; }
|
||||
auto mutable_link_graphics() { return &link_graphics_; }
|
||||
@@ -538,10 +538,10 @@ class Rom : public core::ExperimentFlags {
|
||||
std::string filename_ = "";
|
||||
|
||||
// Full contiguous rom space
|
||||
Bytes rom_data_;
|
||||
std::vector<uint8_t> rom_data_;
|
||||
|
||||
// Full contiguous graphics space
|
||||
Bytes graphics_buffer_;
|
||||
std::vector<uint8_t> graphics_buffer_;
|
||||
|
||||
// All graphics sheets in the game
|
||||
std::array<gfx::Bitmap, kNumGfxSheets> graphics_sheets_;
|
||||
|
||||
@@ -223,7 +223,7 @@ void Overworld::AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
||||
world[position_x2][position_y2] = tiles32_unique_[tpos].tile3_;
|
||||
}
|
||||
|
||||
void Overworld::OrganizeMapTiles(Bytes &bytes, Bytes &bytes2, int i, int sx,
|
||||
void Overworld::OrganizeMapTiles(std::vector<uint8_t> &bytes, std::vector<uint8_t> &bytes2, int i, int sx,
|
||||
int sy, int &ttpos) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
|
||||
@@ -588,7 +588,7 @@ class Overworld : public SharedRom, public core::ExperimentFlags {
|
||||
void AssembleMap16Tiles();
|
||||
void AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
||||
OWBlockset &world);
|
||||
void OrganizeMapTiles(Bytes &bytes, Bytes &bytes2, int i, int sx, int sy,
|
||||
void OrganizeMapTiles(std::vector<uint8_t> &bytes, std::vector<uint8_t> &bytes2, int i, int sx, int sy,
|
||||
int &ttpos);
|
||||
absl::Status DecompressAllMapTiles();
|
||||
|
||||
|
||||
@@ -525,7 +525,7 @@ absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
||||
|
||||
namespace {
|
||||
|
||||
void CopyTile8bpp16(int x, int y, int tile, Bytes& bitmap, Bytes& blockset) {
|
||||
void CopyTile8bpp16(int x, int y, int tile, std::vector<uint8_t>& bitmap, std::vector<uint8_t>& blockset) {
|
||||
int src_pos =
|
||||
((tile - ((tile / 0x08) * 0x08)) * 0x10) + ((tile / 0x08) * 2048);
|
||||
int dest_pos = (x + (y * 0x200));
|
||||
|
||||
@@ -139,10 +139,10 @@ class OverworldMap : public editor::context::GfxContext {
|
||||
uchar static_graphics_[16];
|
||||
|
||||
Rom rom_;
|
||||
Bytes all_gfx_;
|
||||
Bytes current_blockset_;
|
||||
Bytes current_gfx_;
|
||||
Bytes bitmap_data_;
|
||||
std::vector<uint8_t> all_gfx_;
|
||||
std::vector<uint8_t> current_blockset_;
|
||||
std::vector<uint8_t> current_gfx_;
|
||||
std::vector<uint8_t> bitmap_data_;
|
||||
OWMapTiles map_tiles_;
|
||||
|
||||
gfx::SnesPalette current_palette_;
|
||||
|
||||
@@ -76,7 +76,7 @@ absl::Status Inventory::BuildTileset() {
|
||||
tilesheets_.reserve(6 * 0x2000);
|
||||
for (int i = 0; i < 6 * 0x2000; i++) tilesheets_.push_back(0xFF);
|
||||
ASSIGN_OR_RETURN(tilesheets_, rom()->Load2BppGraphics())
|
||||
Bytes test;
|
||||
std::vector<uint8_t> test;
|
||||
for (int i = 0; i < 0x4000; i++) {
|
||||
test_.push_back(tilesheets_[i]);
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ class Inventory : public SharedRom {
|
||||
private:
|
||||
absl::Status BuildTileset();
|
||||
|
||||
Bytes data_;
|
||||
std::vector<uint8_t> data_;
|
||||
gfx::Bitmap bitmap_;
|
||||
|
||||
Bytes tilesheets_;
|
||||
Bytes test_;
|
||||
std::vector<uint8_t> tilesheets_;
|
||||
std::vector<uint8_t> test_;
|
||||
gfx::Bitmap tilesheets_bmp_;
|
||||
gfx::SnesPalette palette_;
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace zelda3 {
|
||||
namespace screen {
|
||||
|
||||
void TitleScreen::Create() {
|
||||
tiles8Bitmap.Create(128, 512, 8, Bytes(0, 0x20000));
|
||||
tilesBG1Bitmap.Create(256, 256, 8, Bytes(0, 0x80000));
|
||||
tilesBG2Bitmap.Create(256, 256, 8, Bytes(0, 0x80000));
|
||||
oamBGBitmap.Create(256, 256, 8, Bytes(0, 0x80000));
|
||||
tiles8Bitmap.Create(128, 512, 8, std::vector<uint8_t>(0, 0x20000));
|
||||
tilesBG1Bitmap.Create(256, 256, 8, std::vector<uint8_t>(0, 0x80000));
|
||||
tilesBG2Bitmap.Create(256, 256, 8, std::vector<uint8_t>(0, 0x80000));
|
||||
oamBGBitmap.Create(256, 256, 8, std::vector<uint8_t>(0, 0x80000));
|
||||
BuildTileset();
|
||||
LoadTitleScreen();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
void Sprite::InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x,
|
||||
void Sprite::InitSprite(const std::vector<uint8_t>& src, uchar mapid, uchar id, uchar x,
|
||||
uchar y, int map_x, int map_y) {
|
||||
current_gfx_ = src;
|
||||
overworld_ = true;
|
||||
@@ -27,7 +27,7 @@ void Sprite::InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x,
|
||||
}
|
||||
}
|
||||
|
||||
Sprite::Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
Sprite::Sprite(std::vector<uint8_t> src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
int map_y)
|
||||
: current_gfx_(src),
|
||||
map_id_(static_cast<int>(mapid)),
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace zelda3 {
|
||||
class Sprite : public OverworldEntity {
|
||||
public:
|
||||
Sprite() = default;
|
||||
Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
Sprite(std::vector<uint8_t> src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
int map_y);
|
||||
void InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x, uchar y,
|
||||
void InitSprite(const std::vector<uint8_t>& src, uchar mapid, uchar id, uchar x, uchar y,
|
||||
int map_x, int map_y);
|
||||
void updateBBox();
|
||||
|
||||
@@ -64,7 +64,7 @@ class Sprite : public OverworldEntity {
|
||||
auto set_deleted(bool deleted) { deleted_ = deleted; }
|
||||
|
||||
private:
|
||||
Bytes current_gfx_;
|
||||
std::vector<uint8_t> current_gfx_;
|
||||
bool overworld_;
|
||||
|
||||
uchar map_id_;
|
||||
@@ -81,7 +81,7 @@ class Sprite : public OverworldEntity {
|
||||
|
||||
int map_x_;
|
||||
int map_y_;
|
||||
Bytes preview_gfx_;
|
||||
std::vector<uint8_t> preview_gfx_;
|
||||
uchar lowerX_;
|
||||
uchar lowerY_;
|
||||
uchar higherX_;
|
||||
|
||||
Reference in New Issue
Block a user