-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bc/trace' into as/apple-iie
- Loading branch information
Showing
12 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::trace::{CpuTrace, TraceHandler}; | ||
use std::{fs::File, io::Write}; | ||
|
||
pub struct FileTraceHandler { | ||
file: File, | ||
} | ||
|
||
impl FileTraceHandler { | ||
pub fn new(filename: String) -> Self { | ||
Self { | ||
file: File::create(filename).expect("Invalid filename"), | ||
} | ||
} | ||
} | ||
|
||
impl TraceHandler for FileTraceHandler { | ||
fn handle(&mut self, trace: &CpuTrace) { | ||
self | ||
.file | ||
.write_all(format!("{:04X}: {:02X}\n", trace.address, trace.opcode).as_bytes()) | ||
.unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#[cfg(not(target_arch = "wasm32"))] | ||
pub mod file; | ||
|
||
/// Trace information provided after each instruction by the CPU. | ||
pub struct CpuTrace { | ||
pub address: u16, | ||
pub opcode: u8, | ||
} | ||
|
||
/// An item which can handle a CPU trace (e.g. logging to a file) | ||
pub trait TraceHandler { | ||
/// Handle a trace event. | ||
fn handle(&mut self, trace: &CpuTrace); | ||
} |