diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e7c88d..77bc34f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,40 +22,51 @@ jobs: env: RUST_BACKTRACE: 1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Rustup run: | rustup toolchain install nightly -c rustfmt rustup override set nightly + - name: Rust toolchain info run: | rustc -Vv cargo -V rustup -V + - name: Rustfmt run: cargo fmt --all -- --check if: runner.os == 'Linux' + - name: Cache CARGO_HOME - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" + - name: Cache cargo build - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: target key: ${{ runner.os }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} + - run: cargo check - - run: sudo apt-get install --no-install-recommends libsdl2-dev + - name: insall sdl for linux + run: sudo apt-get install --no-install-recommends libsdl2-dev if: runner.os == 'Linux' - - run: | + + - name: install sdl for windows + shell: bash + if: runner.os == 'Windows' + run: | mkdir sdl-vendor cd sdl-vendor curl -O https://www.libsdl.org/release/SDL2-devel-2.0.14-VC.zip @@ -64,12 +75,12 @@ jobs: cp SDL2-2.0.*/lib/x64/*.lib '/c/Libs' echo LIB="C:\Libs" >> $GITHUB_ENV cp SDL2-2.0.*/lib/x64/*.dll .. - shell: bash - if: runner.os == 'Windows' - - run: | + + - name: install sdl for mac + if: runner.os == 'macOS' + run: | brew install sdl2 echo LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" >> $GITHUB_ENV - if: runner.os == 'macOS' - run: cargo check --all - run: cargo build diff --git a/Cargo.lock b/Cargo.lock index 4685df0..2978da8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,10 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cfg-if" @@ -35,20 +37,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.86" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "nanorand" -version = "0.5.2" -source = "git+https://github.com/aspenluxxxy/nanorand-rs?branch=master#12c4a9f003bbaf19dd43ee2f3133051a075e5824" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" [[package]] name = "sdl2" -version = "0.34.3" +version = "0.34.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcbb85f4211627a7291c83434d6bbfa723e28dcaa53c7606087e3c61929e4b9c" +checksum = "deecbc3fa9460acff5a1e563e05cb5f31bba0aa0c214bb49a43db8159176d54b" dependencies = [ "bitflags", "lazy_static", @@ -58,9 +61,9 @@ dependencies = [ [[package]] name = "sdl2-sys" -version = "0.34.3" +version = "0.34.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d81feded049b9c14eceb4a4f6d596a98cebbd59abdba949c5552a015466d33" +checksum = "41a29aa21f175b5a41a6e26da572d5e5d1ee5660d35f9f9d0913e8a802098f74" dependencies = [ "cfg-if", "libc", diff --git a/Cargo.toml b/Cargo.toml index d7519b6..dcfb8d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,13 +2,13 @@ name = "chip8emu" version = "0.1.0" authors = ["Lzu Tao <taolzu@gmail.com>"] -edition = "2018" +edition = "2021" description = "A simple Chip-8 interpreter" # More configurations at <https://doc.rust-lang.org/cargo/reference/manifest.html>. [lib] -crate-type = ["dylib"] +# crate-type = ["dylib"] [profile.dev] debug = 1 @@ -26,8 +26,8 @@ amiga = [] members = ["interpreter"] [dependencies.nanorand] -version = "0.5.2" +version = "0.7" default-features = false features = ["wyrand"] -git = "https://github.com/aspenluxxxy/nanorand-rs" -branch = "master" +# git = "https://github.com/aspenluxxxy/nanorand-rs" +# branch = "master" diff --git a/interpreter/Cargo.toml b/interpreter/Cargo.toml index db87f20..eb03cef 100644 --- a/interpreter/Cargo.toml +++ b/interpreter/Cargo.toml @@ -2,7 +2,7 @@ name = "interpreter" version = "0.1.0" authors = ["Lzu Tao <taolzu@gmail.com>"] -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/cpu.rs b/src/cpu.rs index 12d3e9e..a59b86c 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -1,6 +1,6 @@ use std::mem::size_of; -use nanorand::{WyRand, RNG}; +use nanorand::{Rng, WyRand}; use super::display::{Display, DISPLAY_SIZE}; use super::keypad::{KeyCode, KeyState}; @@ -208,12 +208,11 @@ impl Cpu { /* The I Register for graphics */ LoadI { addr } => self.memory.i.store(addr), - AddIVx { x } => { - let f = self.memory.i.add_assign(self.v[x]); - if cfg!(feature = "amiga") { + AddIVx { x: _x } => { + #[cfg(feature = "amiga")] + { + let f = self.memory.i.add_assign(self.v[x]); self.v.set_vf(u8::from(f)); - } else { - drop(f); } } LoadBcd { x } => self.memory.store_bcd(self.v[x]), diff --git a/src/memory.rs b/src/memory.rs index 1cd6764..1093098 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -115,6 +115,7 @@ impl ProgramCounter { impl I { #[must_use] + #[cfg(feature = "amiga")] pub fn add_assign(&mut self, value: u8) -> bool { self.0 += u16::from(value); if cfg!(feature = "amiga") {