mirror of
https://github.com/kirjavascript/trueLMAO.git
synced 2024-06-02 03:27:21 -04:00
debug mod
This commit is contained in:
parent
965bdcf73c
commit
7d4fffd5a5
23
emu/src/debug.rs
Normal file
23
emu/src/debug.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use crate::Megadrive;
|
||||
|
||||
pub fn disasm_demo(emu: &Megadrive) -> Vec<(u32, String)> {
|
||||
use r68k_tools::PC;
|
||||
let mut buffer = Vec::new();
|
||||
let mut opcodes = Vec::new();
|
||||
// longest opcode is 16 bytes
|
||||
for i in 0..(16 * 10) {
|
||||
buffer.push(emu.core.mem.rom.read_byte(emu.core.pc + i));
|
||||
}
|
||||
let mvec = r68k_tools::memory::MemoryVec::new8(PC(0), buffer);
|
||||
let mut cursor = PC(0);
|
||||
for _ in 0..10 {
|
||||
let disasm = r68k_tools::disassembler::disassemble(cursor, &mvec);
|
||||
if let Ok((pc, opcode)) = disasm {
|
||||
opcodes.push((cursor.0 + emu.core.pc, opcode.to_string().to_lowercase()));
|
||||
cursor = pc;
|
||||
}
|
||||
}
|
||||
|
||||
opcodes
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
use r68k_emu::cpu::{STACK_POINTER_REG, ConfiguredCore};
|
||||
use r68k_emu::interrupts::AutoInterruptController;
|
||||
|
||||
pub mod debug;
|
||||
pub mod gfx;
|
||||
pub mod io;
|
||||
pub mod mem;
|
||||
|
@ -41,33 +42,6 @@ impl Megadrive {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn step_n(&mut self, amount: usize) {
|
||||
for _ in 0..amount {
|
||||
self.core.execute1();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn disasm(&self) -> Vec<(u32, String)> {
|
||||
use r68k_tools::PC;
|
||||
let mut buffer = Vec::new();
|
||||
let mut opcodes = Vec::new();
|
||||
// longest opcode is 16 bytes
|
||||
for i in 0..(16 * 10) {
|
||||
buffer.push(self.core.mem.rom.read_byte(self.core.pc + i));
|
||||
}
|
||||
let mvec = r68k_tools::memory::MemoryVec::new8(PC(0), buffer);
|
||||
let mut cursor = PC(0);
|
||||
for _ in 0..10 {
|
||||
let disasm = r68k_tools::disassembler::disassemble(cursor, &mvec);
|
||||
if let Ok((pc, opcode)) = disasm {
|
||||
opcodes.push((cursor.0 + self.core.pc, opcode.to_string().to_lowercase()));
|
||||
cursor = pc;
|
||||
}
|
||||
}
|
||||
|
||||
opcodes
|
||||
}
|
||||
|
||||
pub fn frame(&mut self, draw: bool) {
|
||||
/* cycle counts initially taken from drx/kiwi */
|
||||
// TODO: use a counter instead
|
||||
|
|
|
@ -159,7 +159,7 @@ impl eframe::App for App {
|
|||
ui.radio_value(&mut self.vsync, true, "vsync");
|
||||
ui.radio_value(&mut self.vsync, false, "not vsync");
|
||||
|
||||
self.test_vec.push_back(self.game_state.frames_to_render().min(4));
|
||||
self.test_vec.push_back(self.game_state.frames_to_render.min(4));
|
||||
|
||||
if self.test_vec.len() > 60 {
|
||||
self.test_vec.pop_front();
|
||||
|
@ -216,7 +216,7 @@ impl eframe::App for App {
|
|||
debug.push_str(&format!("\n"));
|
||||
debug.push_str(&format!("\n"));
|
||||
|
||||
for (pc, opcode) in self.emu.disasm() {
|
||||
for (pc, opcode) in emu::debug::disasm_demo(&self.emu) {
|
||||
debug.push_str(&format!("0x{:X}\t{}\n", pc, opcode));
|
||||
}
|
||||
ui.label(&debug);
|
||||
|
|
Loading…
Reference in a new issue