yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
oracle_ram_panel.cc
Go to the documentation of this file.
2
5#include "imgui/imgui.h"
6
7namespace yaze {
8namespace editor {
9
10namespace {
11// Poll interval in seconds (30Hz)
12constexpr double kRefreshInterval = 1.0 / 30.0;
13}
14
18
19std::string OracleRamPanel::GetIcon() const {
20 return ICON_MD_MEMORY;
21}
22
26
28 // Key state variables
29 variables_ = {
30 {0x7E0010, "MODE", "Main game mode", 1},
31 {0x7E0011, "SUBMODE", "Sub-mode of current mode", 1},
32 {0x7E001B, "INDOORS", "Indoors/Outdoors flag", 1},
33 {0x7E00A0, "ROOM", "Current Underworld room ID", 2},
34 {0x7E008A, "OWSCR", "Current Overworld screen ID", 1},
35 {0x7E002F, "DIR", "Link facing direction", 1},
36 {0x7E005D, "LINKDO", "Link state machine ID", 1},
37 {0x7E031F, "IFRAMES", "Link invincibility timer", 1},
38
39 // Custom OoS Variables
40 {0x7E0739, "GoldstarOrHookshot", "0=Hookshot, 1=Goldstar", 1},
41 {0x7E0746, "DBG_REINIT_FLAGS", "Debug reinit trigger", 1},
42
43 // SRAM Progression (Shadowed in WRAM or read via Mesen)
44 {0x7EF3D6, "OOSPROG", "Major quest milestones", 1},
45 {0x7EF39C, "JournalState", "Current journal progression", 1},
46 {0x7EF410, "Dreams", "Bitfield for Courage/Power/Wisdom", 1},
47 };
48}
49
52 if (!client || !client->IsConnected()) return;
53
54 // Ideally we'd use a BATCH read, but for now we'll do individual reads
55 // or a large block if they are contiguous.
56 // For simplicity in the prototype, we just loop.
57 for (auto& var : variables_) {
58 auto result = client->ReadBlock(var.address, var.size);
59 if (result.ok()) {
60 const auto& data = *result;
61 if (data.size() < var.size) {
62 continue;
63 }
64 if (var.size == 1) {
65 var.last_value = data[0];
66 } else {
67 var.last_value = data[0] | (data[1] << 8);
68 }
69 }
70 }
71}
72
73void OracleRamPanel::Draw(bool* p_open) {
74 // Check refresh timer
75 double current_time = ImGui::GetTime();
76 if (auto_refresh_ && (current_time - last_refresh_time_ >= kRefreshInterval)) {
78 last_refresh_time_ = current_time;
79 }
80
81 // Toolbar
82 if (ImGui::Button(auto_refresh_ ? ICON_MD_PAUSE : ICON_MD_PLAY_ARROW)) {
84 }
85 ImGui::SameLine();
86 if (ImGui::Button(ICON_MD_REFRESH)) {
88 }
89 ImGui::SameLine();
90 ImGui::TextDisabled("Refreshed: %.1fs ago", current_time - last_refresh_time_);
91
92 ImGui::Separator();
93
95}
96
98 static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
99 ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable |
100 ImGuiTableFlags_Hideable;
101
102 if (ImGui::BeginTable("OracleRamVariables", 4, flags)) {
103 ImGui::TableSetupColumn("Address", ImGuiTableColumnFlags_WidthFixed, 80.0f);
104 ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_WidthFixed, 120.0f);
105 ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed, 60.0f);
106 ImGui::TableSetupColumn("Description", ImGuiTableColumnFlags_WidthStretch);
107 ImGui::TableHeadersRow();
108
109 for (const auto& var : variables_) {
110 ImGui::TableNextRow();
111
112 // Address
113 ImGui::TableSetColumnIndex(0);
114 ImGui::Text("$%06X", var.address);
115
116 // Label
117 ImGui::TableSetColumnIndex(1);
118 ImGui::Text("%s", var.label.c_str());
119
120 // Value
121 ImGui::TableSetColumnIndex(2);
122 if (var.size == 1) {
123 ImGui::Text("$%02X", var.last_value);
124 } else {
125 ImGui::Text("$%04X", var.last_value);
126 }
127
128 // Description
129 ImGui::TableSetColumnIndex(3);
130 ImGui::TextDisabled("%s", var.description.c_str());
131 }
132 ImGui::EndTable();
133 }
134}
135
136} // namespace editor
137} // namespace yaze
void Draw(bool *p_open) override
Draw the panel content.
std::vector< RamVariable > variables_
void OnOpen() override
Called when panel becomes visible.
std::string GetIcon() const override
Material Design icon for this panel.
static std::shared_ptr< MesenSocketClient > GetOrCreate()
#define ICON_MD_PAUSE
Definition icons.h:1389
#define ICON_MD_MEMORY
Definition icons.h:1195
#define ICON_MD_PLAY_ARROW
Definition icons.h:1479
#define ICON_MD_REFRESH
Definition icons.h:1572