Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

plug debug windows in

Layleaaaab8888ee4
diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs
index 47fc82b..e5ed426 100644
--- a/crates/debugger/src/debugger.rs
+++ b/crates/debugger/src/debugger.rs
@@ -2,8 +2,9 @@
pub enum EmulatorState {
Running,
Paused,
- StepOne,
+ Step,
RunUntilVsync,
+ RunUntilAddress(u32),
}
pub struct DebuggerUi {
@@ -11,6 +12,9 @@ pub struct DebuggerUi {
pub show_cpu: bool,
pub show_gx_state: bool,
pub show_mmio: bool,
+ pub show_exi: bool,
+ pub show_irqs: bool,
+ pub show_controls: bool,
pub memory_base: u32,
pub memory_addr_input: String,
}
@@ -20,8 +24,11 @@ impl Default for DebuggerUi {
DebuggerUi {
emulator_state: EmulatorState::Paused,
show_cpu: true,
+ show_controls: true,
show_gx_state: false,
show_mmio: false,
+ show_exi: false,
+ show_irqs: false,
memory_base: 0x8000_0000,
memory_addr_input: "80000000".to_string(),
}
diff --git a/crates/debugger/src/render.rs b/crates/debugger/src/render.rs
index 472ca51..7480c01 100644
--- a/crates/debugger/src/render.rs
+++ b/crates/debugger/src/render.rs
@@ -176,7 +176,7 @@ impl RenderState {
pub fn render(&mut self, emulator: &mut Gekko, debugger_ui: &mut DebuggerUi, window: &Window) {
match debugger_ui.emulator_state {
EmulatorState::Running => emulator.run_until_vsync(),
- EmulatorState::StepOne => {
+ EmulatorState::Step => {
emulator.step();
debugger_ui.emulator_state = EmulatorState::Paused;
}
@@ -184,6 +184,12 @@ impl RenderState {
emulator.run_until_vsync();
debugger_ui.emulator_state = EmulatorState::Paused;
}
+ EmulatorState::RunUntilAddress(addr) => {
+ while emulator.cpu.pc != addr {
+ emulator.step();
+ }
+ debugger_ui.emulator_state = EmulatorState::Paused;
+ }
EmulatorState::Paused => {}
}
@@ -239,7 +245,7 @@ impl RenderState {
.add_enabled(is_paused, egui::Button::new(format!("{} Step", icons::ICON_SKIP_NEXT)))
.clicked()
{
- debugger_ui.emulator_state = EmulatorState::StepOne;
+ debugger_ui.emulator_state = EmulatorState::Step;
ui.close();
}
if ui
@@ -255,6 +261,9 @@ impl RenderState {
ui.checkbox(&mut debugger_ui.show_cpu, "CPU");
ui.checkbox(&mut debugger_ui.show_gx_state, "GX");
ui.checkbox(&mut debugger_ui.show_mmio, "MMIO");
+ ui.checkbox(&mut debugger_ui.show_exi, "EXI");
+ ui.checkbox(&mut debugger_ui.show_irqs, "IRQ");
+ ui.checkbox(&mut debugger_ui.show_controls, "Controls");
});
});
});
@@ -262,6 +271,9 @@ impl RenderState {
if debugger_ui.show_cpu {
windows::cpu::show_cpu(&ctx, &mut debugger_ui.show_cpu, cpu, mmio);
}
+ if debugger_ui.show_controls {
+ windows::controls::show_controls(&ctx, &mut debugger_ui.show_controls, &mut debugger_ui.emulator_state);
+ }
if debugger_ui.show_gx_state {
windows::gx::show_gx(&ctx, &mut debugger_ui.show_gx_state, gx, mmio);
}
@@ -274,6 +286,12 @@ impl RenderState {
mmio,
);
}
+ if debugger_ui.show_exi {
+ windows::exi::show_exi(&ctx, &mut debugger_ui.show_exi, &emulator.exi);
+ }
+ if debugger_ui.show_irqs {
+ windows::irq::show_irq(&ctx, &mut debugger_ui.show_irqs, &emulator.cpu, &emulator.pi);
+ }
});
self.egui_winit
diff --git a/crates/debugger/src/windows.rs b/crates/debugger/src/windows.rs
index 9a05805..c5b36c1 100644
--- a/crates/debugger/src/windows.rs
+++ b/crates/debugger/src/windows.rs
@@ -1,3 +1,6 @@
pub mod cpu;
pub mod gx;
pub mod mmio;
+pub mod controls;
+pub mod exi;
+pub mod irq;
\ No newline at end of file
diff --git a/crates/debugger/src/windows/controls.rs b/crates/debugger/src/windows/controls.rs
index 0bb1c0b..5aaef65 100644
--- a/crates/debugger/src/windows/controls.rs
+++ b/crates/debugger/src/windows/controls.rs
@@ -3,7 +3,7 @@ use egui_material_icons::icons;
use crate::debugger::EmulatorState;
-pub fn show_controls(ctx: &Context, open: &mut bool, state: &mut EmulatorState, run_until_addr_input: &mut String) {
+pub fn show_controls(ctx: &Context, open: &mut bool, state: &mut EmulatorState) {
egui::Window::new("Controls")
.open(open)
.resizable(false)
@@ -56,9 +56,10 @@ pub fn show_controls(ctx: &Context, open: &mut bool, state: &mut EmulatorState,
ui.separator();
ui.horizontal(|ui| {
+ let mut run_until_addr_input = "";
let resp = ui.add_enabled(
is_paused,
- egui::TextEdit::singleline(run_until_addr_input)
+ egui::TextEdit::singleline(&mut run_until_addr_input)
.hint_text("address")
.desired_width(80.0)
.font(egui::TextStyle::Monospace),