aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock63
-rw-r--r--Cargo.toml3
-rw-r--r--src/lib.rs4
-rw-r--r--src/main.rs45
4 files changed, 112 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..58db0ae
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,63 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "chip8"
+version = "0.1.0"
+dependencies = [
+ "sdl2",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.139"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
+
+[[package]]
+name = "sdl2"
+version = "0.35.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a"
+dependencies = [
+ "bitflags",
+ "lazy_static",
+ "libc",
+ "sdl2-sys",
+]
+
+[[package]]
+name = "sdl2-sys"
+version = "0.35.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "version-compare",
+]
+
+[[package]]
+name = "version-compare"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
diff --git a/Cargo.toml b/Cargo.toml
index e13653c..d4be877 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,8 +1,9 @@
[package]
-name = "chip-8"
+name = "chip8"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+sdl2 = "0.35.2"
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..577bab9
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,4 @@
+pub struct Chip8 {
+ mem : [u32],
+
+}
diff --git a/src/main.rs b/src/main.rs
index e7a11a9..531a4ce 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,44 @@
-fn main() {
- println!("Hello, world!");
+extern crate sdl2;
+
+use sdl2::pixels::Color;
+use sdl2::event::Event;
+use sdl2::keyboard::Keycode;
+use std::time::Duration;
+
+static WIDTH : u32 = 32;
+static HEIGHT : u32 = 64;
+static SCALE : u32 = 10;
+
+
+pub fn main() {
+ let sdl_context = sdl2::init().unwrap();
+ let video_subsystem = sdl_context.video().unwrap();
+
+ let window = video_subsystem.window("CHIP-8", WIDTH * SCALE, HEIGHT * SCALE)
+ .position_centered()
+ .build()
+ .unwrap();
+
+ let mut canvas = window.into_canvas().build().unwrap();
+
+ canvas.set_draw_color(Color::RGB(255, 255, 255));
+ canvas.clear();
+ canvas.present();
+ let mut event_pump = sdl_context.event_pump().unwrap();
+ 'running: loop {
+ for event in event_pump.poll_iter() {
+ match event {
+ Event::Quit {..} |
+ Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
+ break 'running
+ },
+ _ => {}
+ }
+ }
+ // The rest of the game loop goes here...
+
+ canvas.clear();
+ canvas.present();
+ std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
+ }
}