Implement an RTC, bump version to 0.4.0
This commit is contained in:
parent
cea9b12661
commit
9970a04cc9
30
Cargo.lock
generated
30
Cargo.lock
generated
|
@ -349,6 +349,20 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6127248204b9aba09a362f6c930ef6a78f2c1b2215f8a7b398c06e1083f17af0"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"time 0.1.44",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.3.1"
|
||||
|
@ -852,9 +866,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fox32"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
"image",
|
||||
"log",
|
||||
"pixels",
|
||||
|
@ -2557,6 +2572,17 @@ dependencies = [
|
|||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.13"
|
||||
|
@ -2665,7 +2691,7 @@ dependencies = [
|
|||
"git2",
|
||||
"rustversion",
|
||||
"thiserror",
|
||||
"time",
|
||||
"time 0.3.13",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
[package]
|
||||
name = "fox32"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
authors = ["ry"]
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4"
|
||||
image = "0.24"
|
||||
log = "0.4"
|
||||
pixels = "0.9.0"
|
||||
|
|
30
src/bus.rs
30
src/bus.rs
|
@ -2,6 +2,7 @@
|
|||
|
||||
use crate::{Memory, AudioChannel, DiskController, Keyboard, Mouse, Overlay};
|
||||
|
||||
use chrono::prelude::*;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::io::{Write, stdout};
|
||||
|
||||
|
@ -19,6 +20,8 @@ pub struct Bus {
|
|||
pub mouse: Arc<Mutex<Mouse>>,
|
||||
|
||||
pub overlays: Arc<Mutex<Vec<Overlay>>>,
|
||||
|
||||
pub startup_time: i64,
|
||||
}
|
||||
|
||||
impl Bus {
|
||||
|
@ -109,6 +112,33 @@ impl Bus {
|
|||
_ => panic!("invalid audio channel"),
|
||||
}
|
||||
}
|
||||
0x80000700..=0x80000706 => { // RTC port
|
||||
let setting = (port & 0x000000FF) as u8;
|
||||
match setting {
|
||||
0 => { // year
|
||||
Local::now().year() as u32
|
||||
},
|
||||
1 => { // month
|
||||
Local::now().month()
|
||||
},
|
||||
2 => { // day
|
||||
Local::now().day()
|
||||
},
|
||||
3 => { // hour
|
||||
Local::now().hour()
|
||||
},
|
||||
4 => { // minute
|
||||
Local::now().minute()
|
||||
},
|
||||
5 => { // second
|
||||
Local::now().second()
|
||||
},
|
||||
6 => { // milliseconds elapsed since startup
|
||||
(Local::now().timestamp_millis() - self.startup_time) as u32
|
||||
},
|
||||
_ => panic!("invalid RTC port"),
|
||||
}
|
||||
}
|
||||
0x80001000..=0x80002003 => { // disk controller port
|
||||
let id = port as u8;
|
||||
let operation = (port & 0x0000F000) >> 8;
|
||||
|
|
|
@ -22,6 +22,7 @@ use std::process::exit;
|
|||
use std::env;
|
||||
use std::fs::{File, read};
|
||||
|
||||
use chrono::prelude::*;
|
||||
use image;
|
||||
use log::error;
|
||||
use pixels::{Pixels, SurfaceTexture};
|
||||
|
@ -97,6 +98,7 @@ fn main() {
|
|||
keyboard: keyboard.clone(),
|
||||
mouse: mouse.clone(),
|
||||
overlays: display.overlays.clone(),
|
||||
startup_time: Local::now().timestamp_millis(),
|
||||
};
|
||||
|
||||
if args.len() > 1 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user