yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
memory_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
2#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
3
4#include "util/file_util.h"
5#include "absl/container/flat_hash_map.h"
6#include "app/editor/editor.h"
8#include "app/rom.h"
9#include "app/snes.h"
10#include "imgui/imgui.h"
11#include "imgui_memory_editor.h"
12#include "util/macro.h"
13
14namespace yaze {
15namespace editor {
16
17using ImGui::SameLine;
18using ImGui::Text;
19
21 explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
22
23 void Update(bool &show_memory_editor) {
25 ImGui::Separator();
26 static MemoryEditor mem_edit;
27 static MemoryEditor comp_edit;
28 static bool show_compare_rom = false;
29 static Rom comparison_rom;
30 ImGui::Begin("Hex Editor", &show_memory_editor);
31 if (ImGui::Button("Compare Rom")) {
33 PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
34 show_compare_rom = true;
35 }
36
37 static uint64_t convert_address = 0;
38 gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
39 SameLine();
40 Text("%x", SnesToPc(convert_address));
41
42 // mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
43 BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
44 SETUP_COLUMN("Source")
45 SETUP_COLUMN("Dest")
46
48 Text("%s", rom()->filename().data());
49 mem_edit.DrawContents((void *)&(*rom()), rom()->size());
50
52 if (show_compare_rom) {
53 comp_edit.SetComparisonData((void *)&(*rom()));
54 ImGui::BeginGroup();
55 ImGui::BeginChild("Comparison ROM");
56 Text("%s", comparison_rom.filename().data());
57 comp_edit.DrawContents((void *)&(comparison_rom), comparison_rom.size());
58 ImGui::EndChild();
59 ImGui::EndGroup();
60 }
61 END_TABLE()
62
63 ImGui::End();
64 }
65
66 // Set the ROM pointer
67 void set_rom(Rom* rom) { rom_ = rom; }
68
69 // Get the ROM pointer
70 Rom* rom() const { return rom_; }
71
72 private:
73 void DrawToolbar();
75 void DrawSearchPopup();
76 void DrawBookmarksPopup();
77
79
80 // Toolbar state
81 char jump_address_[16] = "0x000000";
82 char search_pattern_[256] = "";
83 uint32_t current_address_ = 0;
84
85 struct Bookmark {
86 uint32_t address;
87 std::string name;
88 std::string description;
89 };
90 std::vector<Bookmark> bookmarks_;
91};
92
93} // namespace editor
94} // namespace yaze
95
96#endif // YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:74
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:292
auto filename() const
Definition rom.h:211
auto size() const
Definition rom.h:205
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
#define SETUP_COLUMN(l)
Definition macro.h:12
#define END_TABLE()
Definition macro.h:20
#define BEGIN_TABLE(l, n, f)
Definition macro.h:11
#define PRINT_IF_ERROR(expression)
Definition macro.h:27
#define NEXT_COLUMN()
Definition macro.h:18
bool InputHex(const char *label, uint64_t *data)
Definition input.cc:156
Main namespace for the application.
Definition controller.cc:20
uint32_t SnesToPc(uint32_t addr) noexcept
Definition snes.h:8
void Update(bool &show_memory_editor)