Skip to content

Commit

Permalink
Implement an RTC, bump version to 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ry755 committed Sep 9, 2022
1 parent cea9b12 commit 9970a04
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
30 changes: 28 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
30 changes: 30 additions & 0 deletions src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -19,6 +20,8 @@ pub struct Bus {
pub mouse: Arc<Mutex<Mouse>>,

pub overlays: Arc<Mutex<Vec<Overlay>>>,

pub startup_time: i64,
}

impl Bus {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9970a04

Please sign in to comment.