command line option to connect serial to stdout
This commit is contained in:
parent
3df569a7a1
commit
ac3b197d6d
|
@ -51,8 +51,12 @@ struct Args {
|
|||
#[arg(short, long)]
|
||||
verbose: bool,
|
||||
|
||||
/// Show cycle count
|
||||
/// Connect the serial port output to stdout
|
||||
#[arg(short, long)]
|
||||
connect_serial: bool,
|
||||
|
||||
/// Show cycle count
|
||||
#[arg(long)]
|
||||
cycle_count: bool,
|
||||
|
||||
/// Show tile window
|
||||
|
@ -127,7 +131,7 @@ fn main() {
|
|||
window.topmost(true);
|
||||
|
||||
let mut cpu = Cpu::new(
|
||||
Memory::init(bootrom, rom),
|
||||
Memory::init(bootrom, rom, args.connect_serial),
|
||||
window,
|
||||
args.tile_window,
|
||||
bootrom_enabled,
|
||||
|
|
|
@ -29,7 +29,12 @@ pub struct Memory {
|
|||
}
|
||||
|
||||
impl Memory {
|
||||
pub fn init(bootrom: Option<Vec<u8>>, rom: Rom) -> Self {
|
||||
pub fn init(bootrom: Option<Vec<u8>>, rom: Rom, connect_serial: bool) -> Self {
|
||||
let serial = if connect_serial {
|
||||
Serial::default().connected()
|
||||
} else {
|
||||
Serial::default()
|
||||
};
|
||||
Self {
|
||||
bootrom,
|
||||
rom,
|
||||
|
@ -45,7 +50,7 @@ impl Memory {
|
|||
user_mode: false,
|
||||
joypad: Joypad::default(),
|
||||
apu: Apu::init_default(),
|
||||
serial: Serial::default(),
|
||||
serial,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ pub struct Serial {
|
|||
}
|
||||
|
||||
impl Serial {
|
||||
pub fn connected(mut self) -> Self {
|
||||
self.is_connected = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn tick(&mut self, steps: usize) -> bool {
|
||||
let mut will_interrupt = false;
|
||||
if !self.is_connected {
|
||||
|
|
Loading…
Reference in a new issue