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
6#include "app/gui/input.h"
7#include "app/rom.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 void Update(bool &show_memory_editor) {
20 static MemoryEditor mem_edit;
21 static MemoryEditor comp_edit;
22 static bool show_compare_rom = false;
23 static Rom comparison_rom;
24 ImGui::Begin("Hex Editor", &show_memory_editor);
25 if (ImGui::Button("Compare Rom")) {
27 PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
28 show_compare_rom = true;
29 }
30
31 static uint64_t convert_address = 0;
32 gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
33 SameLine();
34 Text("%x", SnesToPc(convert_address));
35
36 // mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
37 BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
38 SETUP_COLUMN("Source")
39 SETUP_COLUMN("Dest")
40
42 Text("%s", rom()->filename().data());
43 mem_edit.DrawContents((void *)&(*rom()), rom()->size());
44
46 if (show_compare_rom) {
47 comp_edit.SetComparisonData((void *)&(*rom()));
48 ImGui::BeginGroup();
49 ImGui::BeginChild("Comparison ROM");
50 Text("%s", comparison_rom.filename().data());
51 comp_edit.DrawContents((void *)&(comparison_rom), comparison_rom.size());
52 ImGui::EndChild();
53 ImGui::EndGroup();
54 }
55 END_TABLE()
56
57 ImGui::End();
58 }
59};
60
61} // namespace editor
62} // namespace yaze
63
64#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:173
auto filename() const
Definition rom.h:171
auto size() const
Definition rom.h:163
auto rom()
Definition rom.h:383
SharedRom()=default
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
#define SETUP_COLUMN(l)
Definition macro.h:21
#define END_TABLE()
Definition macro.h:29
#define BEGIN_TABLE(l, n, f)
Definition macro.h:20
#define PRINT_IF_ERROR(expression)
Definition macro.h:36
#define NEXT_COLUMN()
Definition macro.h:27
Editors are the view controllers for the application.
bool InputHex(const char *label, uint64_t *data)
Definition input.cc:134
Main namespace for the application.
Definition controller.cc:18
uint32_t SnesToPc(uint32_t addr) noexcept
Definition rom.h:328
void Update(bool &show_memory_editor)