From ac6c2afd109845d76c511379350167d0874224d0 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Wed, 8 Feb 2023 21:06:26 +1100 Subject: [PATCH] initial state --- Cargo.lock | 54 ++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 ++- src/main.rs | 4 ++++ src/processor/mod.rs | 3 +-- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d933544..fe70440 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,9 +224,21 @@ version = "0.1.0" dependencies = [ "clap", "minifb", + "rand", "spin_sleep", ] +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "heck" version = "0.4.0" @@ -437,6 +449,12 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -479,6 +497,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "raw-window-handle" version = "0.3.4" @@ -664,6 +712,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.84" diff --git a/Cargo.toml b/Cargo.toml index 4e93886..040ae81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,5 @@ edition = "2021" [dependencies] clap = {version = "4.1.1", features = ["derive"]} spin_sleep = "1.1.1" -minifb = "0.23" \ No newline at end of file +minifb = "0.23" +rand = "0.8.5" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 229d9a5..465abac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,6 +67,7 @@ struct Args { } fn cpu_ram_init(cpu: &mut CPU) { + cpu.memory.set(0xFF04, 0xAD); cpu.memory.set(0xFF10, 0x80); cpu.memory.set(0xFF11, 0xBF); cpu.memory.set(0xFF12, 0xF3); @@ -86,6 +87,9 @@ fn cpu_ram_init(cpu: &mut CPU) { cpu.memory.set(0xFF47, 0xFC); cpu.memory.set(0xFF48, 0xFF); cpu.memory.set(0xFF49, 0xFF); + for i in 0xC000..0xE000 { + cpu.memory.set(i, if rand::random() { 0xFF } else { 0x00 }); + } } static mut PAUSE_ENABLED: bool = false; diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 81b1c13..6bacded 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -200,8 +200,7 @@ impl Default for Registers { fn default() -> Self { // default post-bootrom values Self { - af: 0x00B0, - // af: 0x01B0, + af: 0x01B0, bc: 0x0013, de: 0x00D8, hl: 0x014D,