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