diff --git a/src/app/core/common.h b/src/app/core/common.h index ee7e393e..e92f541b 100644 --- a/src/app/core/common.h +++ b/src/app/core/common.h @@ -42,6 +42,9 @@ class ExperimentFlags { // Flag to enable the saving of all palettes to the Rom. bool kSaveAllPalettes = false; + // Flag to enable the saving of gfx groups to the rom. + bool kSaveGfxGroups = false; + // Flag to enable the change queue, which could have any anonymous // save routine for the Rom. In practice, just the overworld tilemap // and tile32 save. diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 20ee33db..f3b5190e 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -400,8 +400,7 @@ void MasterEditor::DrawFileMenu() { Checkbox("Log Instructions to Debugger", &mutable_flags()->kLogInstructions); Checkbox("Save All Palettes", &mutable_flags()->kSaveAllPalettes); - Checkbox("Save With Change Queue", - &mutable_flags()->kSaveWithChangeQueue); + Checkbox("Save Gfx Groups", &mutable_flags()->kSaveGfxGroups); Checkbox("Use New ImGui Input", &mutable_flags()->kUseNewImGuiInput); ImGui::EndMenu(); } @@ -596,6 +595,7 @@ void MasterEditor::DrawHelpMenu() { ImGui::Text("Graphics"); ImGui::BulletText("View Decompressed Graphics Sheets"); + ImGui::BulletText("View/Update Graphics Groups"); ImGui::Text("Palettes"); ImGui::BulletText("View Palette Groups"); @@ -604,8 +604,6 @@ void MasterEditor::DrawHelpMenu() { ImGui::BulletText("All Listed Overworld Features"); ImGui::BulletText("Hex Editor Changes"); - - if (ImGui::Button("Close", gui::kDefaultModalSize)) { open_supported_features = false; ImGui::CloseCurrentPopup(); diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index 53908bff..fffde026 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -65,6 +65,7 @@ class MasterEditor : public SharedRom, void Shutdown() { overworld_editor_.Shutdown(); } auto emulator() -> emu::Emulator& { return emulator_; } + auto quit() { return quit_; } private: void DrawFileDialog(); @@ -81,6 +82,7 @@ class MasterEditor : public SharedRom, void LoadRom(); void SaveRom(); + bool quit_ = false; bool about_ = false; bool rom_info_ = false; bool backup_rom_ = false; diff --git a/src/app/rom.cc b/src/app/rom.cc index d27c1684..14706aeb 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -257,6 +257,10 @@ absl::Status Rom::SaveToFile(bool backup, bool save_new, std::string filename) { RETURN_IF_ERROR(SaveAllPalettes()); } + if (flags()->kSaveGfxGroups) { + SaveGroupsToRom(); + } + if (save_new) { // Create a file of the same name and append the date between the filename // and file extension @@ -335,6 +339,39 @@ absl::Status Rom::SaveAllPalettes() { return absl::OkStatus(); } +void Rom::SaveGroupsToRom() { + int gfxPointer = + (rom_data_[kGfxGroupsPointer + 1] << 8) + rom_data_[kGfxGroupsPointer]; + gfxPointer = core::SnesToPc(gfxPointer); + + for (int i = 0; i < 37; i++) { + for (int j = 0; j < 8; j++) { + rom_data_[gfxPointer + (i * 8) + j] = main_blockset_ids[i][j]; + } + } + + for (int i = 0; i < 82; i++) { + for (int j = 0; j < 4; j++) { + rom_data_[core::entrance_gfx_group + (i * 4) + j] = + room_blockset_ids[i][j]; + } + } + + for (int i = 0; i < 144; i++) { + for (int j = 0; j < 4; j++) { + rom_data_[version_constants().kSpriteBlocksetPointer + (i * 4) + j] = + spriteset_ids[i][j]; + } + } + + for (int i = 0; i < 72; i++) { + for (int j = 0; j < 4; j++) { + rom_data_[version_constants().kDungeonPalettesGroups + (i * 4) + j] = + paletteset_ids[i][j]; + } + } +} + std::shared_ptr SharedRom::shared_rom_ = nullptr; } // namespace app diff --git a/src/app/rom.h b/src/app/rom.h index f33e4b9a..a2f1e8b8 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -570,40 +570,7 @@ class Rom : public core::ExperimentFlags { } } - bool SaveGroupsToRom() { - int gfxPointer = - (rom_data_[kGfxGroupsPointer + 1] << 8) + rom_data_[kGfxGroupsPointer]; - gfxPointer = core::SnesToPc(gfxPointer); - - for (int i = 0; i < 37; i++) { - for (int j = 0; j < 8; j++) { - rom_data_[gfxPointer + (i * 8) + j] = main_blockset_ids[i][j]; - } - } - - for (int i = 0; i < 82; i++) { - for (int j = 0; j < 4; j++) { - rom_data_[core::entrance_gfx_group + (i * 4) + j] = - room_blockset_ids[i][j]; - } - } - - for (int i = 0; i < 144; i++) { - for (int j = 0; j < 4; j++) { - rom_data_[version_constants().kSpriteBlocksetPointer + (i * 4) + j] = - spriteset_ids[i][j]; - } - } - - for (int i = 0; i < 72; i++) { - for (int j = 0; j < 4; j++) { - rom_data_[version_constants().kDungeonPalettesGroups + (i * 4) + j] = - paletteset_ids[i][j]; - } - } - - return false; - } + void SaveGroupsToRom(); auto resource_label() { return &resource_label_manager_; }