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