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:
parent
b00fbfb38c
commit
3687161b98
|
@ -18,6 +18,7 @@ pub use bus::*;
|
||||||
|
|
||||||
pub use super::{AudioInterface, InputInterface, VideoInterface};
|
pub use super::{AudioInterface, InputInterface, VideoInterface};
|
||||||
|
|
||||||
|
#[cfg(rba_with_debugger)]
|
||||||
use crate::debugger;
|
use crate::debugger;
|
||||||
|
|
||||||
use zip;
|
use zip;
|
||||||
|
@ -26,6 +27,7 @@ use zip;
|
||||||
pub enum GBAError {
|
pub enum GBAError {
|
||||||
IO(::std::io::Error),
|
IO(::std::io::Error),
|
||||||
CpuError(arm7tdmi::CpuError),
|
CpuError(arm7tdmi::CpuError),
|
||||||
|
#[cfg(rba_with_debugger)]
|
||||||
DebuggerError(debugger::DebuggerError),
|
DebuggerError(debugger::DebuggerError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +45,7 @@ impl From<arm7tdmi::CpuError> for GBAError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(rba_with_debugger)]
|
||||||
impl From<debugger::DebuggerError> for GBAError {
|
impl From<debugger::DebuggerError> for GBAError {
|
||||||
fn from(err: debugger::DebuggerError) -> GBAError {
|
fn from(err: debugger::DebuggerError) -> GBAError {
|
||||||
GBAError::DebuggerError(err)
|
GBAError::DebuggerError(err)
|
||||||
|
|
|
@ -30,9 +30,11 @@ extern crate zip;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod util;
|
pub mod util;
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod debugger;
|
|
||||||
pub mod disass;
|
pub mod disass;
|
||||||
|
|
||||||
|
#[cfg(rba_with_debugger)]
|
||||||
|
pub mod debugger;
|
||||||
|
|
||||||
pub trait VideoInterface {
|
pub trait VideoInterface {
|
||||||
fn render(&mut self, buffer: &[u32]);
|
fn render(&mut self, buffer: &[u32]);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +56,7 @@ pub mod prelude {
|
||||||
pub use super::core::arm7tdmi;
|
pub use super::core::arm7tdmi;
|
||||||
pub use super::core::cartridge::Cartridge;
|
pub use super::core::cartridge::Cartridge;
|
||||||
pub use super::core::{GBAError, GBAResult, GameBoyAdvance};
|
pub use super::core::{GBAError, GBAResult, GameBoyAdvance};
|
||||||
|
#[cfg(rba_with_debugger)]
|
||||||
pub use super::debugger::Debugger;
|
pub use super::debugger::Debugger;
|
||||||
pub use super::util::read_bin_file;
|
pub use super::util::read_bin_file;
|
||||||
pub use super::{AudioInterface, InputInterface, VideoInterface};
|
pub use super::{AudioInterface, InputInterface, VideoInterface};
|
||||||
|
|
|
@ -31,6 +31,7 @@ fn main() {
|
||||||
let matches = clap::App::from_yaml(yaml).get_matches();
|
let matches = clap::App::from_yaml(yaml).get_matches();
|
||||||
|
|
||||||
let skip_bios = matches.occurrences_of("skip_bios") != 0;
|
let skip_bios = matches.occurrences_of("skip_bios") != 0;
|
||||||
|
|
||||||
let debug = matches.occurrences_of("debug") != 0;
|
let debug = matches.occurrences_of("debug") != 0;
|
||||||
|
|
||||||
let bios_path = Path::new(matches.value_of("bios").unwrap_or_default());
|
let bios_path = Path::new(matches.value_of("bios").unwrap_or_default());
|
||||||
|
@ -63,64 +64,84 @@ fn main() {
|
||||||
let mut event_pump = sdl_context.event_pump().unwrap();
|
let mut event_pump = sdl_context.event_pump().unwrap();
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
gba.cpu.set_verbose(true);
|
#[cfg(rba_with_debugger)]
|
||||||
let mut debugger = Debugger::new(gba);
|
{
|
||||||
println!("starting debugger...");
|
gba.cpu.set_verbose(true);
|
||||||
debugger.repl(matches.value_of("script_file")).unwrap();
|
let mut debugger = Debugger::new(gba);
|
||||||
println!("ending debugger...");
|
println!("starting debugger...");
|
||||||
} else {
|
debugger.repl(matches.value_of("script_file")).unwrap();
|
||||||
let frame_time = time::Duration::new(0, 1_000_000_000u32 / 60);
|
println!("ending debugger...");
|
||||||
loop {
|
return;
|
||||||
let start_time = time::Instant::now();
|
}
|
||||||
|
#[cfg(not(rba_with_debugger))]
|
||||||
|
{
|
||||||
|
panic!("Please compile me with cfg(rba_with_debugger)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for event in event_pump.poll_iter() {
|
let frame_time = time::Duration::new(0, 1_000_000_000u32 / 60);
|
||||||
match event {
|
loop {
|
||||||
Event::KeyDown {
|
let start_time = time::Instant::now();
|
||||||
keycode: Some(Keycode::Space),
|
|
||||||
..
|
for event in event_pump.poll_iter() {
|
||||||
} => {
|
match event {
|
||||||
frame_limiter = false;
|
Event::KeyDown {
|
||||||
}
|
keycode: Some(Keycode::Space),
|
||||||
Event::KeyUp {
|
..
|
||||||
keycode: Some(Keycode::Space),
|
} => {
|
||||||
..
|
frame_limiter = false;
|
||||||
} => {
|
|
||||||
frame_limiter = true;
|
|
||||||
}
|
|
||||||
Event::KeyDown {
|
|
||||||
keycode: Some(keycode),
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
input.borrow_mut().on_keyboard_key_down(keycode);
|
|
||||||
}
|
|
||||||
Event::KeyUp {
|
|
||||||
keycode: Some(keycode),
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
input.borrow_mut().on_keyboard_key_up(keycode);
|
|
||||||
}
|
|
||||||
Event::Quit { .. } => panic!("quit!"),
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
Event::KeyUp {
|
||||||
|
keycode: Some(Keycode::Space),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
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),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
input.borrow_mut().on_keyboard_key_down(keycode);
|
||||||
|
}
|
||||||
|
Event::KeyUp {
|
||||||
|
keycode: Some(keycode),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
input.borrow_mut().on_keyboard_key_up(keycode);
|
||||||
|
}
|
||||||
|
Event::Quit { .. } => panic!("quit!"),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gba.frame();
|
gba.frame();
|
||||||
|
|
||||||
if let Some(fps) = fps_counter.tick() {
|
if let Some(fps) = fps_counter.tick() {
|
||||||
let title = format!("{} ({} fps)", rom_name, fps);
|
let title = format!("{} ({} fps)", rom_name, fps);
|
||||||
video.borrow_mut().set_window_title(&title);
|
video.borrow_mut().set_window_title(&title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if frame_limiter {
|
if frame_limiter {
|
||||||
let time_passed = start_time.elapsed();
|
let time_passed = start_time.elapsed();
|
||||||
let delay = frame_time.checked_sub(time_passed);
|
let delay = frame_time.checked_sub(time_passed);
|
||||||
match delay {
|
match delay {
|
||||||
None => {}
|
None => {}
|
||||||
Some(delay) => {
|
Some(delay) => {
|
||||||
spin_sleep::sleep(delay);
|
spin_sleep::sleep(delay);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue