Make the debugger into an optional build option.

This module is written purely and always breaks when changes are being
made into the 'core' module, so as long as I don't use it, I don't feel
like maintaining it.


Former-commit-id: f5b18ba54a27d22e8a195dd0912ec9c8f29fa830
This commit is contained in:
Michel Heily 2019-12-29 23:37:23 +02:00
parent b00fbfb38c
commit 3687161b98
3 changed files with 80 additions and 53 deletions

View file

@ -18,6 +18,7 @@ pub use bus::*;
pub use super::{AudioInterface, InputInterface, VideoInterface};
#[cfg(rba_with_debugger)]
use crate::debugger;
use zip;
@ -26,6 +27,7 @@ use zip;
pub enum GBAError {
IO(::std::io::Error),
CpuError(arm7tdmi::CpuError),
#[cfg(rba_with_debugger)]
DebuggerError(debugger::DebuggerError),
}
@ -43,6 +45,7 @@ impl From<arm7tdmi::CpuError> for GBAError {
}
}
#[cfg(rba_with_debugger)]
impl From<debugger::DebuggerError> for GBAError {
fn from(err: debugger::DebuggerError) -> GBAError {
GBAError::DebuggerError(err)

View file

@ -30,9 +30,11 @@ extern crate zip;
#[macro_use]
pub mod util;
pub mod core;
pub mod debugger;
pub mod disass;
#[cfg(rba_with_debugger)]
pub mod debugger;
pub trait VideoInterface {
fn render(&mut self, buffer: &[u32]);
}
@ -54,6 +56,7 @@ pub mod prelude {
pub use super::core::arm7tdmi;
pub use super::core::cartridge::Cartridge;
pub use super::core::{GBAError, GBAResult, GameBoyAdvance};
#[cfg(rba_with_debugger)]
pub use super::debugger::Debugger;
pub use super::util::read_bin_file;
pub use super::{AudioInterface, InputInterface, VideoInterface};

View file

@ -31,6 +31,7 @@ fn main() {
let matches = clap::App::from_yaml(yaml).get_matches();
let skip_bios = matches.occurrences_of("skip_bios") != 0;
let debug = matches.occurrences_of("debug") != 0;
let bios_path = Path::new(matches.value_of("bios").unwrap_or_default());
@ -63,12 +64,21 @@ fn main() {
let mut event_pump = sdl_context.event_pump().unwrap();
if debug {
#[cfg(rba_with_debugger)]
{
gba.cpu.set_verbose(true);
let mut debugger = Debugger::new(gba);
println!("starting debugger...");
debugger.repl(matches.value_of("script_file")).unwrap();
println!("ending debugger...");
} else {
return;
}
#[cfg(not(rba_with_debugger))]
{
panic!("Please compile me with cfg(rba_with_debugger)");
}
}
let frame_time = time::Duration::new(0, 1_000_000_000u32 / 60);
loop {
let start_time = time::Instant::now();
@ -87,6 +97,18 @@ fn main() {
} => {
frame_limiter = true;
}
#[cfg(rba_with_debugger)]
Event::KeyUp {
keycode: Some(Keycode::F1),
..
} => {
let mut debugger = Debugger::new(gba);
println!("starting debugger...");
debugger.repl(matches.value_of("script_file")).unwrap();
gba = debugger.gba;
println!("ending debugger...");
break;
}
Event::KeyDown {
keycode: Some(keycode),
..
@ -123,4 +145,3 @@ fn main() {
}
}
}
}