From 910e4b856b5f9bdec6717b8f4a9bc311d9c4e619 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Wed, 1 Feb 2023 20:13:15 -0600 Subject: [PATCH] Added gfx crate --- .idea/vulcan-emu.iml | 1 + Cargo.lock | 10 ++++++++++ Cargo.toml | 3 ++- vemu/Cargo.toml | 1 + vemu/src/main.rs | 4 ++-- vgfx/Cargo.toml | 9 +++++++++ {vemu => vgfx}/src/display.rs | 2 +- {vemu => vgfx}/src/font.rom | Bin vgfx/src/lib.rs | 2 ++ 9 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 vgfx/Cargo.toml rename {vemu => vgfx}/src/display.rs (99%) rename {vemu => vgfx}/src/font.rom (100%) create mode 100644 vgfx/src/lib.rs diff --git a/.idea/vulcan-emu.iml b/.idea/vulcan-emu.iml index 071d209..9f53825 100644 --- a/.idea/vulcan-emu.iml +++ b/.idea/vulcan-emu.iml @@ -10,6 +10,7 @@ + diff --git a/Cargo.lock b/Cargo.lock index 8134031..a1ce4a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1463,6 +1463,7 @@ dependencies = [ "rand", "vasm_core", "vcore", + "vgfx", "winit", ] @@ -1472,6 +1473,13 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vgfx" +version = "0.1.0" +dependencies = [ + "vcore", +] + [[package]] name = "vlua" version = "0.1.0" @@ -1496,7 +1504,9 @@ dependencies = [ "serde-wasm-bindgen", "vasm_core", "vcore", + "vgfx", "wasm-bindgen", + "web-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 67b14a6..a1c6980 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,5 +7,6 @@ members = [ "vasm", "vtest", "vlua", - "vweb" + "vweb", + "vgfx" ] \ No newline at end of file diff --git a/vemu/Cargo.toml b/vemu/Cargo.toml index 18e7003..5a1779e 100644 --- a/vemu/Cargo.toml +++ b/vemu/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] vcore = { path = "../vcore" } +vgfx = { path = "../vgfx" } vasm_core = { path = "../vasm_core" } rand = "0.8.0" winit = "0.26.1" diff --git a/vemu/src/main.rs b/vemu/src/main.rs index 23ed9bd..de995f8 100644 --- a/vemu/src/main.rs +++ b/vemu/src/main.rs @@ -1,4 +1,3 @@ -mod display; mod keyboard; use winit::{ @@ -20,6 +19,7 @@ use vcore::memory::{Memory, PeekPoke}; use vcore::word::Word; use winit::event::{DeviceEvent, ElementState}; use winit::window::Window; +use vgfx::display; fn main() { let event_loop = EventLoop::new(); @@ -44,7 +44,7 @@ fn main() { let memory = Memory::from(rng); let mut cpu = CPU::new(memory); - display::reset(&mut cpu); + display::init_gfx(&mut cpu); let code = assemble_snippet(include_str!("typewriter.asm").lines().map(String::from)) .expect("Assemble error"); // let code = assemble_file("init.asm").expect("Assemble error"); diff --git a/vgfx/Cargo.toml b/vgfx/Cargo.toml new file mode 100644 index 0000000..133d24c --- /dev/null +++ b/vgfx/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "vgfx" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +vcore = { path = "../vcore" } diff --git a/vemu/src/display.rs b/vgfx/src/display.rs similarity index 99% rename from vemu/src/display.rs rename to vgfx/src/display.rs index 40a9153..52e342d 100644 --- a/vemu/src/display.rs +++ b/vgfx/src/display.rs @@ -74,7 +74,7 @@ pub fn draw(machine: &P, frame: &mut [u8]) { } } -pub fn reset(machine: &mut P) { +pub fn init_gfx(machine: &mut P) { init_display_registers(machine, 16.into()); init_font(machine); init_palette(machine); diff --git a/vemu/src/font.rom b/vgfx/src/font.rom similarity index 100% rename from vemu/src/font.rom rename to vgfx/src/font.rom diff --git a/vgfx/src/lib.rs b/vgfx/src/lib.rs new file mode 100644 index 0000000..96f6858 --- /dev/null +++ b/vgfx/src/lib.rs @@ -0,0 +1,2 @@ +pub mod display; +