yaze 0.2.0
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 "absl/status/status.h"
7#include "app/core/project.h"
20#include "app/emu/emulator.h"
22#include "app/gfx/snes_tile.h"
23#include "app/gui/canvas.h"
24#include "app/gui/icons.h"
25#include "app/gui/input.h"
26#include "app/gui/style.h"
27#include "app/rom.h"
28#include "imgui/imgui.h"
29#include "imgui/misc/cpp/imgui_stdlib.h"
30#include "imgui_memory_editor.h"
31
32namespace yaze {
33namespace app {
34namespace editor {
35
36using ImGui::SameLine;
37using ImGui::Text;
38
40 void Update(bool &show_memory_editor) {
41 static MemoryEditor mem_edit;
42 static MemoryEditor comp_edit;
43 static bool show_compare_rom = false;
44 static Rom comparison_rom;
45 ImGui::Begin("Hex Editor", &show_memory_editor);
46 if (ImGui::Button("Compare Rom")) {
48 PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
49 show_compare_rom = true;
50 }
51
52 static uint64_t convert_address = 0;
53 gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
54 SameLine();
55 Text("%x", core::SnesToPc(convert_address));
56
57 // mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
58 BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
59 SETUP_COLUMN("Source")
60 SETUP_COLUMN("Dest")
61
63 Text("%s", rom()->filename().data());
64 mem_edit.DrawContents((void *)&(*rom()), rom()->size());
65
67 if (show_compare_rom) {
68 comp_edit.SetComparisonData((void *)&(*rom()));
69 ImGui::BeginGroup();
70 ImGui::BeginChild("Comparison ROM");
71 Text("%s", comparison_rom.filename().data());
72 comp_edit.DrawContents((void *)&(comparison_rom), comparison_rom.size());
73 ImGui::EndChild();
74 ImGui::EndGroup();
75 }
76 END_TABLE()
77
78 ImGui::End();
79 }
80};
81
82} // namespace editor
83} // namespace app
84} // namespace yaze
85
86#endif // YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:145
auto filename() const
Definition rom.h:473
auto size() const
Definition rom.h:467
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:142
A class to hold a shared pointer to a Rom object.
Definition rom.h:585
static std::string ShowOpenFileDialog()
#define SETUP_COLUMN(l)
Definition constants.h:28
#define END_TABLE()
Definition constants.h:36
#define BEGIN_TABLE(l, n, f)
Definition constants.h:27
#define PRINT_IF_ERROR(expression)
Definition constants.h:43
#define NEXT_COLUMN()
Definition constants.h:34
uint32_t SnesToPc(uint32_t addr) noexcept
Definition common.h:223
bool InputHex(const char *label, uint64_t *data)
Definition input.cc:143
Definition common.cc:21
void Update(bool &show_memory_editor)