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 "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) {
22 static MemoryEditor mem_edit;
23 static MemoryEditor comp_edit;
24 static bool show_compare_rom = false;
25 static Rom comparison_rom;
26 ImGui::Begin("Hex Editor", &show_memory_editor);
27 if (ImGui::Button("Compare Rom")) {
29 PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
30 show_compare_rom = true;
31 }
32
33 static uint64_t convert_address = 0;
34 gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
35 SameLine();
36 Text("%x", SnesToPc(convert_address));
37
38 // mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
39 BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
40 SETUP_COLUMN("Source")
41 SETUP_COLUMN("Dest")
42
44 Text("%s", rom()->filename().data());
45 mem_edit.DrawContents((void *)&(*rom()), rom()->size());
46
48 if (show_compare_rom) {
49 comp_edit.SetComparisonData((void *)&(*rom()));
50 ImGui::BeginGroup();
51 ImGui::BeginChild("Comparison ROM");
52 Text("%s", comparison_rom.filename().data());
53 comp_edit.DrawContents((void *)&(comparison_rom), comparison_rom.size());
54 ImGui::EndChild();
55 ImGui::EndGroup();
56 }
57 END_TABLE()
58
59 ImGui::End();
60 }
61
62 // Set the ROM pointer
63 void set_rom(Rom* rom) { rom_ = rom; }
64
65 // Get the ROM pointer
66 Rom* rom() const { return rom_; }
67
68 private:
70};
71
72} // namespace editor
73} // namespace yaze
74
75#endif // YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:58
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:231
auto filename() const
Definition rom.h:182
auto size() const
Definition rom.h:176
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:143
Main namespace for the application.
Definition controller.cc:18
uint32_t SnesToPc(uint32_t addr) noexcept
Definition snes.h:8
void Update(bool &show_memory_editor)