yaze 0.2.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
5#include "app/gui/input.h"
6#include "app/rom.h"
7#include "imgui/imgui.h"
8#include "imgui_memory_editor.h"
9#include "util/macro.h"
10
11namespace yaze {
12namespace editor {
13
14using ImGui::SameLine;
15using ImGui::Text;
16
18 explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
19
20 void Update(bool &show_memory_editor) {
21 static MemoryEditor mem_edit;
22 static MemoryEditor comp_edit;
23 static bool show_compare_rom = false;
24 static Rom comparison_rom;
25 ImGui::Begin("Hex Editor", &show_memory_editor);
26 if (ImGui::Button("Compare Rom")) {
28 PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
29 show_compare_rom = true;
30 }
31
32 static uint64_t convert_address = 0;
33 gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
34 SameLine();
35 Text("%x", SnesToPc(convert_address));
36
37 // mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
38 BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
39 SETUP_COLUMN("Source")
40 SETUP_COLUMN("Dest")
41
43 Text("%s", rom()->filename().data());
44 mem_edit.DrawContents((void *)&(*rom()), rom()->size());
45
47 if (show_compare_rom) {
48 comp_edit.SetComparisonData((void *)&(*rom()));
49 ImGui::BeginGroup();
50 ImGui::BeginChild("Comparison ROM");
51 Text("%s", comparison_rom.filename().data());
52 comp_edit.DrawContents((void *)&(comparison_rom), comparison_rom.size());
53 ImGui::EndChild();
54 ImGui::EndGroup();
55 }
56 END_TABLE()
57
58 ImGui::End();
59 }
60
61 // Set the ROM pointer
62 void set_rom(Rom* rom) { rom_ = rom; }
63
64 // Get the ROM pointer
65 Rom* rom() const { return rom_; }
66
67 private:
69};
70
71} // namespace editor
72} // namespace yaze
73
74#endif // YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:59
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:172
auto filename() const
Definition rom.h:169
auto size() const
Definition rom.h:162
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
#define SETUP_COLUMN(l)
Definition macro.h:10
#define END_TABLE()
Definition macro.h:18
#define BEGIN_TABLE(l, n, f)
Definition macro.h:9
#define PRINT_IF_ERROR(expression)
Definition macro.h:25
#define NEXT_COLUMN()
Definition macro.h:16
Editors are the view controllers for the application.
bool InputHex(const char *label, uint64_t *data)
Definition input.cc:142
Main namespace for the application.
Definition controller.cc:18
uint32_t SnesToPc(uint32_t addr) noexcept
Definition rom.h:329
void Update(bool &show_memory_editor)