Add basic terminal card

This commit is contained in:
pjht 2022-10-11 11:47:03 -05:00
parent 1f21cb4259
commit 7505d172f2
2 changed files with 41 additions and 0 deletions

View File

@ -8,6 +8,7 @@ mod m68k;
mod ram;
mod rom;
mod storage;
mod term;
use crate::{
backplane::Backplane,
m68k::{BusError, M68K},

40
src/term.rs Normal file
View File

@ -0,0 +1,40 @@
use std::fmt::Display;
use nullable_result::NullableResult;
use serde_yaml::Mapping;
use crate::{card::Card, m68k::BusError, register};
#[derive(Debug)]
pub struct Term;
impl Display for Term {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Terminal card")
}
}
impl Card for Term {
fn new(_data: &Mapping) -> Self
where
Self: Sized,
{
Self
}
fn read_byte_io(&mut self, address: u8) -> NullableResult<u8, BusError> {
match address {
0xFF => NullableResult::Ok(3),
_ => NullableResult::Null,
}
}
fn write_byte_io(&mut self, address: u8, data: u8) -> NullableResult<(), BusError> {
if address == 0 {
print!("{}", data as char);
}
NullableResult::Ok(())
}
}
register!(Term, "term");