Add LC_LZ2 Compression library

Refactor ROM class
Editor housekeeping
This commit is contained in:
scawful
2023-07-21 03:44:44 -04:00
parent df8443152b
commit 82dd9dde1b
15 changed files with 646 additions and 504 deletions

View File

@@ -20,8 +20,8 @@ namespace editor {
absl::Status GraphicsEditor::Update() {
BEGIN_TABLE("#gfxEditTable", 2, gfx_edit_flags)
SETUP_COLUMN("Bin Importer")
SETUP_COLUMN("Graphics Manager")
SETUP_COLUMN("Memory Editor")
TABLE_HEADERS()
NEXT_COLUMN()
@@ -33,6 +33,7 @@ absl::Status GraphicsEditor::Update() {
RETURN_IF_ERROR(DrawClipboardImport())
END_TAB_ITEM()
END_TAB_BAR()
ImGui::Separator();
ImGui::Text("Graphics");
ImGui::Separator();
RETURN_IF_ERROR(DrawDecompressedData())
@@ -47,7 +48,6 @@ absl::Status GraphicsEditor::Update() {
absl::Status GraphicsEditor::DrawFileImport() {
static int size = 0;
ImGui::SetNextItemWidth(350.f);
ImGui::InputText("File", file_path_, sizeof(file_path_));
ImGui::SameLine();
// Open the file dialog when the user clicks the "Browse" button
@@ -98,6 +98,8 @@ absl::Status GraphicsEditor::DrawFileImport() {
absl::Status GraphicsEditor::DrawClipboardImport() {
static Bytes clipboard_data;
ImGui::Button("Paste");
if (!is_open_) {
clipboard_data.resize(0x1000);
for (int i = 0; i < 0x1000; i++) clipboard_data.push_back(0x00);
@@ -112,13 +114,14 @@ absl::Status GraphicsEditor::DrawMemoryEditor() {
std::string title = "Memory Editor";
if (is_open_) {
static MemoryEditor mem_edit;
mem_edit.DrawWindow(title.data(), (void *)&temp_rom_, temp_rom_.size());
// mem_edit.DrawWindow(title.data(), (void *)&temp_rom_, temp_rom_.size());
mem_edit.DrawContents(temp_rom_.data(), temp_rom_.size());
}
return absl::OkStatus();
}
absl::Status GraphicsEditor::DrawDecompressedData() {
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)2);
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)2);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
import_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
@@ -152,6 +155,24 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
return absl::OkStatus();
}
absl::Status GraphicsEditor::DecompressSuperDonkey() {
for (const auto& offset : kSuperDonkeyTiles) {
int offset_value =
std::stoi(offset, nullptr, 16); // convert hex string to int
ASSIGN_OR_RETURN(auto decompressed_data,
temp_rom_.Decompress(offset_value, 0x1000))
}
for (const auto& offset : kSuperDonkeySprites) {
int offset_value =
std::stoi(offset, nullptr, 16); // convert hex string to int
ASSIGN_OR_RETURN(auto decompressed_data,
temp_rom_.Decompress(offset_value, 0x1000))
}
return absl::OkStatus();
}
} // namespace editor
} // namespace app
} // namespace yaze

View File

@@ -52,13 +52,15 @@ class GraphicsEditor {
absl::Status DrawDecompressedData();
absl::Status DecompressImportData(int size);
absl::Status DecompressSuperDonkey();
int current_offset_ = 0;
int current_size_ = 0;
int current_palette_ = 0;
bool gfx_loaded_ = false;
bool is_open_ = false;
bool super_donkey_ = false;
char file_path_[256];
ROM rom_;
@@ -71,9 +73,10 @@ class GraphicsEditor {
gfx::BitmapTable graphics_bin_;
PaletteEditor palette_editor_;
gfx::SNESPalette palette_;
MemoryEditor memory_editor_;
gfx::SNESPalette palette_;
ImGuiTableFlags gfx_edit_flags = ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable |
ImGuiTableFlags_SizingStretchSame;

View File

@@ -141,7 +141,7 @@ void MasterEditor::DrawInfoPopup() {
if (rom_info_) ImGui::OpenPopup("ROM Information");
if (ImGui::BeginPopupModal("ROM Information", nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("Title: %s", rom_.GetTitle());
ImGui::Text("Title: %s", rom_.title());
ImGui::Text("ROM Size: %ld", rom_.size());
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
@@ -335,6 +335,7 @@ void MasterEditor::DrawMusicEditor() {
void MasterEditor::DrawSpriteEditor() {
TAB_ITEM("Sprites")
status_ = sprite_editor_.Update();
END_TAB_ITEM()
}

View File

@@ -16,6 +16,7 @@
#include "app/editor/overworld_editor.h"
#include "app/editor/palette_editor.h"
#include "app/editor/screen_editor.h"
#include "app/editor/sprite_editor.h"
#include "app/gfx/snes_palette.h"
#include "app/gfx/snes_tile.h"
#include "app/gui/canvas.h"
@@ -57,17 +58,20 @@ class MasterEditor {
bool backup_rom_ = true;
bool show_status_ = false;
std::shared_ptr<SDL_Renderer> sdl_renderer_;
absl::Status status_;
absl::Status prev_status_;
std::shared_ptr<SDL_Renderer> sdl_renderer_;
std::shared_ptr<core::Editor> current_editor_;
AssemblyEditor assembly_editor_;
DungeonEditor dungeon_editor_;
GraphicsEditor graphics_editor_;
MusicEditor music_editor_;
OverworldEditor overworld_editor_;
PaletteEditor palette_editor_;
ScreenEditor screen_editor_;
MusicEditor music_editor_;
SpriteEditor sprite_editor_;
ROM rom_;
};

View File

@@ -140,14 +140,6 @@ void ScreenEditor::DrawMosaicEditor() {
gui::InputHex("Routine Location", &overworldCustomMosaicASM);
if (ImGui::Button("Generate Mosaic Assembly")) {
auto mosaic =
rom_.PatchOverworldMosaic(mosaic_tiles_, overworldCustomMosaicASM);
if (!mosaic.ok()) {
std::cout << mosaic;
}
}
END_TAB_ITEM()
}

View File

@@ -0,0 +1,11 @@
#include "sprite_editor.h"
namespace yaze {
namespace app {
namespace editor {
absl::Status SpriteEditor::Update() { return absl::OkStatus(); }
} // namespace editor
} // namespace app
} // namespace yaze

View File

@@ -0,0 +1,17 @@
#ifndef YAZE_APP_EDITOR_SPRITE_EDITOR_H
#define YAZE_APP_EDITOR_SPRITE_EDITOR_H
#include "absl/status/status.h"
namespace yaze {
namespace app {
namespace editor {
class SpriteEditor {
public:
absl::Status Update();
};
} // namespace editor
} // namespace app
} // namespace yaze
#endif // YAZE_APP_EDITOR_SPRITE_EDITOR_H