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 "app/gui/input.h"
6#include "app/rom.h"
7#include "app/snes.h"
8#include "imgui/imgui.h"
9#include "imgui_memory_editor.h"
10#include "util/macro.h"
11
12namespace yaze {
13namespace editor {
14
15using ImGui::SameLine;
16using ImGui::Text;
17
19 explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
20
21 void Update(bool &show_memory_editor) {
23 ImGui::Separator();
24 static MemoryEditor mem_edit;
25 static MemoryEditor comp_edit;
26 static bool show_compare_rom = false;
27 static Rom comparison_rom;
28 ImGui::Begin("Hex Editor", &show_memory_editor);
29 if (ImGui::Button("Compare Rom")) {
31 PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
32 show_compare_rom = true;
33 }
34
35 static uint64_t convert_address = 0;
36 gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
37 SameLine();
38 Text("%x", SnesToPc(convert_address));
39
40 // mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
41 BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
42 SETUP_COLUMN("Source")
43 SETUP_COLUMN("Dest")
44
46 Text("%s", rom()->filename().data());
47 mem_edit.DrawContents((void *)&(*rom()), rom()->size());
48
50 if (show_compare_rom) {
51 comp_edit.SetComparisonData((void *)&(*rom()));
52 ImGui::BeginGroup();
53 ImGui::BeginChild("Comparison ROM");
54 Text("%s", comparison_rom.filename().data());
55 comp_edit.DrawContents((void *)&(comparison_rom), comparison_rom.size());
56 ImGui::EndChild();
57 ImGui::EndGroup();
58 }
59 END_TABLE()
60
61 ImGui::End();
62 }
63
64 // Set the ROM pointer
65 void set_rom(Rom* rom) { rom_ = rom; }
66
67 // Get the ROM pointer
68 Rom* rom() const { return rom_; }
69
70 private:
71 void DrawToolbar();
73 void DrawSearchPopup();
74 void DrawBookmarksPopup();
75
77
78 // Toolbar state
79 char jump_address_[16] = "0x000000";
80 char search_pattern_[256] = "";
81 uint32_t current_address_ = 0;
82
83 struct Bookmark {
84 uint32_t address;
85 std::string name;
86 std::string description;
87 };
88 std::vector<Bookmark> bookmarks_;
89};
90
91} // namespace editor
92} // namespace yaze
93
94#endif // YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:289
auto filename() const
Definition rom.h:208
auto size() const
Definition rom.h:202
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.
uint32_t SnesToPc(uint32_t addr) noexcept
Definition snes.h:8
void Update(bool &show_memory_editor)