From 8c08555003d63af057cc7fb000085464958029b6 Mon Sep 17 00:00:00 2001 From: Trevor Merritt Date: Mon, 7 Jul 2025 16:28:13 -0400 Subject: [PATCH] writes bins better now --- Cargo.lock | 1028 +++++++++++++++++++++- beneater/src/bin/beneater.rs | 39 +- beneater/src/bin/make_rom.rs | 44 +- beneater/src/bin/urn.rs | 12 +- beneater/src/lib.rs | 1 - beneater/src/parts/backplane.rs | 9 +- beneater/src/parts/ben_eater_pc.rs | 2 +- beneater/src/parts/cpu_display.rs | 4 +- cli/src/bin/rom_only.rs | 18 + cli/src/bin/ticker.rs | 2 +- core/src/computers/beneater/beneater.rs | 5 - core/src/computers/rom_only/backplane.rs | 8 +- core/src/constants/constants_system.rs | 4 - core/src/constants/constants_via6522.rs | 20 + core/src/constants/mod.rs | 1 + core/src/instruction_table.rs | 4 +- core/src/mos6502cpu/cpu.rs | 36 +- core/src/periph/at28c256/mod.rs | 10 +- core/src/periph/at28c256/new.rs | 10 + core/src/periph/at28c256/program.rs | 10 + core/src/periph/at28c256/tick.rs | 6 +- core/src/periph/hm62256/tick.rs | 2 + core/src/periph/mod.rs | 1 + core/src/periph/mos6522/mod.rs | 2 + core/src/periph/mos6522/mos6522.rs | 165 ++++ core/src/periph/mos6522/registers.rs | 12 + macroquad/Cargo.toml | 3 +- macroquad/src/bin/rom_only.rs | 31 - resources/beneater/asm/nop_1.asm | 0 29 files changed, 1381 insertions(+), 108 deletions(-) create mode 100644 cli/src/bin/rom_only.rs create mode 100644 core/src/constants/constants_via6522.rs create mode 100644 core/src/periph/at28c256/new.rs create mode 100644 core/src/periph/at28c256/program.rs create mode 100644 core/src/periph/mos6522/mod.rs create mode 100644 core/src/periph/mos6522/mos6522.rs create mode 100644 core/src/periph/mos6522/registers.rs create mode 100644 resources/beneater/asm/nop_1.asm diff --git a/Cargo.lock b/Cargo.lock index 80588a8..aee33ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,40 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ab_glyph" +version = "0.2.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0f4f6fbdc5ee39f2ede9f5f3ec79477271a6d6a2baff22310d51736bda6cea" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169" + [[package]] name = "adler2" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -73,6 +101,24 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "audir-sles" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea47348666a8edb7ad80cbee3940eb2bccf70df0e6ce09009abe1a836cb779f5" + +[[package]] +name = "audrey" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58b92a84e89497e3cd25d3672cd5d1c288abaac02c18ff21283f17d118b889b8" +dependencies = [ + "dasp_frame", + "dasp_sample", + "hound", + "lewton", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -99,11 +145,40 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2", +] + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + [[package]] name = "bytemuck" version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "byteorder" @@ -111,6 +186,41 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "calloop" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" +dependencies = [ + "bitflags 2.9.1", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" +dependencies = [ + "calloop", + "rustix 0.38.44", + "wayland-backend", + "wayland-client", +] + +[[package]] +name = "cc" +version = "1.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" +dependencies = [ + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.1" @@ -168,6 +278,15 @@ dependencies = [ "trevors_utilities", ] +[[package]] +name = "clipboard-win" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" +dependencies = [ + "error-code", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -180,6 +299,29 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "copypasta" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e6811e17f81fe246ef2bc553f76b6ee6ab41a694845df1d37e52a92b7bbd38a" +dependencies = [ + "clipboard-win", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "smithay-clipboard", + "x11-clipboard", +] + [[package]] name = "core" version = "0.1.0" @@ -197,6 +339,107 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + +[[package]] +name = "dasp_frame" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a3937f5fe2135702897535c8d4a5553f8b116f76c1529088797f2eee7c5cd6" +dependencies = [ + "dasp_sample", +] + +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "ecolor" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc4feb366740ded31a004a0e4452fbf84e80ef432ecf8314c485210229672fd1" +dependencies = [ + "bytemuck", + "emath", +] + +[[package]] +name = "egui" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd34cec49ab55d85ebf70139cb1ccd29c977ef6b6ba4fe85489d6877ee9ef3" +dependencies = [ + "ahash", + "bitflags 2.9.1", + "emath", + "epaint", + "nohash-hasher", + "profiling", +] + +[[package]] +name = "egui-macroquad" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243771baa600997c1c4eaeaf6641dacfc88948b67be57af7ab974bea4b2bd6b1" +dependencies = [ + "egui", + "egui-miniquad", + "macroquad 0.4.14", +] + +[[package]] +name = "egui-miniquad" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96b90650f8c5324bfaa9f54d75dae25428f2e0b380f89f3a09601da4e57bc3f" +dependencies = [ + "bytemuck", + "copypasta", + "egui", + "getrandom 0.2.16", + "miniquad", + "quad-rand", + "quad-url", +] + +[[package]] +name = "emath" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e4cadcff7a5353ba72b7fea76bf2122b5ebdbc68e8155aa56dfdea90083fe1b" +dependencies = [ + "bytemuck", +] + [[package]] name = "env_logger" version = "0.10.2" @@ -210,6 +453,29 @@ dependencies = [ "termcolor", ] +[[package]] +name = "epaint" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fcc0f5a7c613afd2dee5e4b30c3e6acafb8ad6f0edb06068811f708a67c562" +dependencies = [ + "ab_glyph", + "ahash", + "bytemuck", + "ecolor", + "emath", + "epaint_default_fonts", + "nohash-hasher", + "parking_lot", + "profiling", +] + +[[package]] +name = "epaint_default_fonts" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7e7a64c02cf7a5b51e745a9e45f60660a286f151c238b9d397b3e923f5082f" + [[package]] name = "equivalent" version = "1.0.2" @@ -226,6 +492,12 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "error-code" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" + [[package]] name = "fastrand" version = "2.3.0" @@ -264,7 +536,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e57e16b3fe8ff4364c0661fdaac543fb38b29ea9bc9c2f45612d90adf931d2b" dependencies = [ "hashbrown", - "ttf-parser", + "ttf-parser 0.21.1", +] + +[[package]] +name = "gethostname" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818" +dependencies = [ + "libc", + "windows-targets 0.48.5", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", ] [[package]] @@ -276,7 +569,7 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "wasi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -308,6 +601,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" +[[package]] +name = "hound" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" + [[package]] name = "humantime" version = "2.2.0" @@ -344,18 +643,65 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lewton" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d542c1a317036c45c2aa1cf10cc9d403ca91eb2d333ef1a4917e5cb10628bd0" +dependencies = [ + "byteorder", + "ogg", + "smallvec 0.6.14", +] + [[package]] name = "libc" version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +[[package]] +name = "libloading" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +dependencies = [ + "cfg-if", + "windows-targets 0.53.2", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "linux-raw-sys" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.27" @@ -367,6 +713,7 @@ name = "macroquad" version = "0.1.0" dependencies = [ "core", + "egui-macroquad", "macroquad 0.4.14", ] @@ -382,6 +729,7 @@ dependencies = [ "macroquad_macro", "miniquad", "quad-rand", + "quad-snd", ] [[package]] @@ -399,12 +747,27 @@ dependencies = [ "libc", ] +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "memchr" version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +[[package]] +name = "memmap2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +dependencies = [ + "libc", +] + [[package]] name = "miniquad" version = "0.4.8" @@ -433,6 +796,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "num-traits" version = "0.2.19" @@ -451,6 +820,114 @@ dependencies = [ "malloc_buf", ] +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.9.1", + "block2", + "libc", + "objc2", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.9.1", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.9.1", + "block2", + "libc", + "objc2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.9.1", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.9.1", + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "ogg" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e571c3517af9e1729d4c63571a27edd660ade0667973bfc74a67c660c2b651" +dependencies = [ + "byteorder", +] + [[package]] name = "once_cell" version = "1.21.3" @@ -463,6 +940,50 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +[[package]] +name = "owned_ttf_parser" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4" +dependencies = [ + "ttf-parser 0.25.1", +] + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec 1.15.1", + "windows-targets 0.52.6", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + [[package]] name = "png" version = "0.17.16" @@ -476,6 +997,21 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "polling" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b53a684391ad002dd6a596ceb6c74fd004fdce75f4be2e3f615068abbea5fd50" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.0.7", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -504,12 +1040,59 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" + +[[package]] +name = "quad-alsa-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66c2f04a6946293477973d85adc251d502da51c57b08cd9c997f0cfd8dcd4b5" +dependencies = [ + "libc", +] + [[package]] name = "quad-rand" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a651516ddc9168ebd67b24afd085a718be02f8858fe406591b013d101ce2f40" +[[package]] +name = "quad-snd" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cba0c4943fc67147fbe9d1eb731fb9e678bfc9d926507eebbbfe0103e154e5b0" +dependencies = [ + "audir-sles", + "audrey", + "libc", + "quad-alsa-sys", + "winapi", +] + +[[package]] +name = "quad-url" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1843b2c8bd2cf5c43fa99dc53bc9f977bd032d386c54491ceeee2499c2d5020f" +dependencies = [ + "sapp-jsutils", + "webbrowser", +] + +[[package]] +name = "quick-xml" +version = "0.37.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.40" @@ -551,7 +1134,16 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom", + "getrandom 0.3.3", +] + +[[package]] +name = "redox_syscall" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" +dependencies = [ + "bitflags 2.9.1", ] [[package]] @@ -583,6 +1175,19 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.9.1", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + [[package]] name = "rustix" version = "1.0.7" @@ -592,16 +1197,97 @@ dependencies = [ "bitflags 2.9.1", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] +[[package]] +name = "sapp-jsutils" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6673c9c245fda02a1e826e199133d1c3d1b8e4a392c9dfe55e4f90a2489b149" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simd-adler32" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smithay-client-toolkit" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" +dependencies = [ + "bitflags 2.9.1", + "calloop", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 0.38.44", + "thiserror", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-clipboard" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc8216eec463674a0e90f29e0ae41a4db573ec5b56b1c6c1c71615d249b6d846" +dependencies = [ + "libc", + "smithay-client-toolkit", + "wayland-backend", +] + [[package]] name = "strsim" version = "0.11.1" @@ -626,9 +1312,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", - "getrandom", + "getrandom 0.3.3", "once_cell", - "rustix", + "rustix 1.0.7", "windows-sys 0.59.0", ] @@ -641,6 +1327,42 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" + [[package]] name = "trevors_utilities" version = "0.1.0-20250606" @@ -657,6 +1379,12 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8" +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + [[package]] name = "unicode-ident" version = "1.0.18" @@ -669,6 +1397,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "wasi" version = "0.14.2+wasi-0.2.4" @@ -678,6 +1418,186 @@ dependencies = [ "wit-bindgen-rt", ] +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wayland-backend" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe770181423e5fc79d3e2a7f4410b7799d5aab1de4372853de3c6aa13ca24121" +dependencies = [ + "cc", + "downcast-rs", + "rustix 0.38.44", + "scoped-tls", + "smallvec 1.15.1", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978fa7c67b0847dbd6a9f350ca2569174974cd4082737054dbb7fbb79d7d9a61" +dependencies = [ + "bitflags 2.9.1", + "rustix 0.38.44", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.9.1", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65317158dec28d00416cb16705934070aef4f8393353d41126c54264ae0f182" +dependencies = [ + "rustix 0.38.44", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779075454e1e9a521794fed15886323ea0feda3f8b0fc1390f5398141310422a" +dependencies = [ + "bitflags 2.9.1", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cb6cdc73399c0e06504c437fe3cf886f25568dd5454473d565085b36d6a8bbf" +dependencies = [ + "bitflags 2.9.1", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a" +dependencies = [ + "web-sys", + "widestring", + "winapi", +] + +[[package]] +name = "widestring" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" + [[package]] name = "winapi" version = "0.3.9" @@ -727,6 +1647,21 @@ dependencies = [ "windows-targets 0.53.2", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -759,6 +1694,12 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -771,6 +1712,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -783,6 +1730,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -807,6 +1760,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -819,6 +1778,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -831,6 +1796,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -843,6 +1814,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -864,6 +1841,45 @@ dependencies = [ "bitflags 2.9.1", ] +[[package]] +name = "x11-clipboard" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662d74b3d77e396b8e5beb00b9cad6a9eccf40b2ef68cc858784b14c41d535a3" +dependencies = [ + "libc", + "x11rb", +] + +[[package]] +name = "x11rb" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12" +dependencies = [ + "gethostname", + "rustix 0.38.44", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" + +[[package]] +name = "xcursor" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + [[package]] name = "zerocopy" version = "0.8.26" diff --git a/beneater/src/bin/beneater.rs b/beneater/src/bin/beneater.rs index 3e44973..1597b7b 100644 --- a/beneater/src/bin/beneater.rs +++ b/beneater/src/bin/beneater.rs @@ -4,14 +4,39 @@ use beneater::parts::ben_eater_pc::BenEaterPC; use beneater::parts::cpu_display::CpuDisplay; use macroquad::prelude::*; use macroquad::telemetry::frame; +use core::mos6502cpu::cpu::Mos6502Cpu; +use core::periph::at28c256::At28C256; +use core::periph::hm62256::Hm62256; +use core::constants::constants_system::*; + +/// BenEater computer represents the 'Ben Eater' 6502 breadboard computer. +/// This was built along watching the video series where Ben builds a +/// 6502 on a breadboard and explains each step. +/// +pub struct BenEater { + cpu: Mos6502Cpu, + ram: At28C256, + rom: Hm62256 +} + +impl BenEater { + pub fn new(rom: &[u8; SIZE_32KB]) -> BenEater { + + } +} + + #[macroquad::main("Ben Eaters PC")] async fn main() { println!("Taxation is Theft"); - let mut backplane = Backplane::new(); - backplane.load_rom("resources/beneater/roms/ror.bin"); + let rom_to_run = fs::read("resources/beneater/roms/ror.bin"); + let mut pc = BenEater::new(&rom_to_run); - let mut dm = DisplayMatrix::new(200.0, 50.0); + let mut backplane = Backplane::new(); + // backplane.load_rom("resources/beneater/roms/ror.bin"); + + // let mut dm = DisplayMatrix::new(200.0, 50.0); // dm.push_letter('T'); let mut frame_number: u32 = 0x00; @@ -20,18 +45,18 @@ async fn main() { clear_background(BLUE); draw_text("Ben Eater", 20.0, 20.0, 30.0, BLACK); - dm.render(20.0, 40.0); + // dm.render(20.0, 40.0); // CpuDisplay::render(&computer.cpu, 20.0, 120.0); frame_number += 1; if frame_number.is_multiple_of(60) { - dm.push_letter('X'); - computer.tick_system(); + // dm.push_letter('X'); + // computer.tick_system(); } if frame_number.is_multiple_of(60 * 6) { - dm.clear_display() + // dm.clear_display() } next_frame().await diff --git a/beneater/src/bin/make_rom.rs b/beneater/src/bin/make_rom.rs index ba71992..3125846 100644 --- a/beneater/src/bin/make_rom.rs +++ b/beneater/src/bin/make_rom.rs @@ -1,16 +1,46 @@ +#![feature(slice_as_array)] + use core::constants::constants_system::SIZE_32KB; +use core::constants::constants_isa_op::*; use std::fs; +use std::path::Path; + +fn le_swap(to_swap: &[u8; SIZE_32KB]) -> [u8; 32768] { + + let mut work: [u8; SIZE_32KB] = [0x00; SIZE_32KB]; + + for i in (0..SIZE_32KB).step_by(2) { + work[i] = to_swap[i+1]; + work[i + 1] = to_swap[i]; + } + work +} fn main() { // make the rom data in memory. - // Fill with 0x6a -> ROR, A - let vec = vec![0x6a; SIZE_32KB]; - let slice: Box<[u8]> = vec.into_boxed_slice(); - let mut array: Box<[u8; SIZE_32KB]> = slice.try_into().expect("Unable to make rom in ram"); + // Fill with 0xea -> NOP + let mut vec: [u8; SIZE_32KB] = [ISA_OP_NOP; SIZE_32KB]; - array[0] = 0xa9; // LDA #$ab - array[1] = 0xab; // 1010 1011 + vec[0] = ISA_OP_LDA_I; // LDA #$ab + vec[1] = 0b1010_1011; // 1010 1011 + vec[2] = 0x02; // -- + vec[3] = 0x03; // -- + + vec[0x4000] = ISA_OP_LDA_I; + vec[0x4001] = 0b0101_0100; + vec[0x4002] = ISA_OP_JMP_ABS; + vec[0x4003] = 0x00; + vec[0x4004] = 0x40; + vec[0x4005] = ISA_OP_NOP; + + vec[0x7ffc] = 0x12; // Reset Vector + vec[0x7ffd] = 0x34; + vec[0x7ffe] = 0x43; // Interrupt Vector + vec[0x7fff] = 0x21; + + + vec = le_swap(&vec); // write the rom to disk - fs::write("outputfile.bin", array.as_slice()); + fs::write("outputfile.bin", &vec[..]).expect("TODO: panic message"); } diff --git a/beneater/src/bin/urn.rs b/beneater/src/bin/urn.rs index d0793dc..fd8acfb 100644 --- a/beneater/src/bin/urn.rs +++ b/beneater/src/bin/urn.rs @@ -8,7 +8,7 @@ fn main() { let mut backplane = Backplane::new(); - backplane.load_rom(); + //backplane.load_rom(); println!("Backplane is live."); let mut new_program = [0x00u8; SIZE_32KB]; @@ -21,9 +21,9 @@ fn main() { ); // println!("{:?}", new_program); - backplane.rom.program(&new_program); - backplane.cpu.pc = 0x6000; - backplane.memory[0x6000] = ISA_OP_LDA_I; - backplane.memory[0x6001] = 0xab; - backplane.tick(); + // backplane.rom.program(&new_program); + // backplane.cpu.pc = 0x6000; + // backplane.memory[0x6000] = ISA_OP_LDA_I; + // backplane.memory[0x6001] = 0xab; + // backplane.tick(); } diff --git a/beneater/src/lib.rs b/beneater/src/lib.rs index 9255f26..1dcc635 100644 --- a/beneater/src/lib.rs +++ b/beneater/src/lib.rs @@ -1,3 +1,2 @@ pub mod parts; pub mod backplane; -mod backplane; diff --git a/beneater/src/parts/backplane.rs b/beneater/src/parts/backplane.rs index 1111e09..71e3654 100644 --- a/beneater/src/parts/backplane.rs +++ b/beneater/src/parts/backplane.rs @@ -1,9 +1,10 @@ use crate::parts::mos6522_peripheral::Mos6522Peripheral; use crate::parts::via6522::VIA6522; use core::constants::constants_system::*; -use core::mos6502cpu::Mos6502Cpu; +use core::mos6502cpu::cpu::Mos6502Cpu; use core::periph::at28c256::At28C256; use core::periph::rom_chip::RomChip; +use core::constants::constants_via6522::*; /// Backplane /// @@ -60,7 +61,7 @@ impl Backplane { // if we are reading if rw { - println!("CPU HAS SET READ FLAG FOR ADDRESS {address:04x} with data 0x{data:02x}"); + println!("CPU HAS SET READ FLAG FOR ADDRESS {:04x} with data 0x{:02x}", self.address_bus, self.data_bus); match self.address_bus { 0x0000..=0x3fff => { // read from ram @@ -75,13 +76,13 @@ impl Backplane { } } } else { - println!("CPU HAS SET WRITE FLAG FOR ADDRESS 0x{address:04x} with data 0x{data:02x}"); + println!("CPU HAS SET WRITE FLAG FOR ADDRESS 0x{:04x} with data 0x{:02x}", self.address_bus, self.data_bus); match self.address_bus { 0x6000..=0x600f => { self.via.write((self.address_bus - 0x6000) as u8, self.data_bus); }, 0x0000..=0x3fff => { - self.memory[self.address_bus] = self.data_bus; + self.memory[self.address_bus as usize] = self.data_bus; } _ => { println!("ATTEMPT TO WRITE OUTSIDE OF MEMORY"); diff --git a/beneater/src/parts/ben_eater_pc.rs b/beneater/src/parts/ben_eater_pc.rs index b92dc72..6c8c51d 100644 --- a/beneater/src/parts/ben_eater_pc.rs +++ b/beneater/src/parts/ben_eater_pc.rs @@ -1,6 +1,6 @@ use crate::parts::clock::Clock; use core::constants::constants_system::*; -use core::mos6502cpu::Mos6502Cpu; +use core::mos6502cpu::cpu::Mos6502Cpu; use std::fs; use std::fs::File; use std::io::{BufReader, Read}; diff --git a/beneater/src/parts/cpu_display.rs b/beneater/src/parts/cpu_display.rs index 0e249b8..9c2e5a7 100644 --- a/beneater/src/parts/cpu_display.rs +++ b/beneater/src/parts/cpu_display.rs @@ -1,4 +1,4 @@ -use core::mos6502cpu::Mos6502Cpu; +use core::mos6502cpu::cpu::Mos6502Cpu; use macroquad::color::{BLACK, Color}; use macroquad::prelude::*; use macroquad::text::draw_text; @@ -7,7 +7,7 @@ pub struct CpuDisplay {} impl CpuDisplay { pub fn render(cpu: &Mos6502Cpu, x_offset: f32, y_offset: f32) { // get the data to display... - let (pc, a, x, y, address_bus, data_bus, microsteps_remaining) = cpu.dump_data(); + let (pc, a, x, y, address_bus, data_bus, microsteps_remaining, reset_vector, interrupt_vector) = cpu.dump_data(); // ...build the interface Self::draw_square(x_offset, y_offset, x_offset + 300.0, y_offset + 85.0, BLACK); diff --git a/cli/src/bin/rom_only.rs b/cli/src/bin/rom_only.rs new file mode 100644 index 0000000..ae54068 --- /dev/null +++ b/cli/src/bin/rom_only.rs @@ -0,0 +1,18 @@ +use clap::Parser; +use core::computers::rom_only::backplane::Backplane; + +#[derive(Parser)] +struct CliOptions { + offset: u16, + bytes: u16, + filename: String +} + +fn main() { + println!("Taxation is theft"); + + let opts = CliOptions::parse(); + + let mut rom_only = Backplane::new(); + rom_only.tick() +} \ No newline at end of file diff --git a/cli/src/bin/ticker.rs b/cli/src/bin/ticker.rs index 7a326f0..160d067 100644 --- a/cli/src/bin/ticker.rs +++ b/cli/src/bin/ticker.rs @@ -1,4 +1,4 @@ -use core::mos6502cpu::Mos6502Cpu; +use core::mos6502cpu::cpu::Mos6502Cpu; fn main() { let x = Mos6502Cpu::default(); diff --git a/core/src/computers/beneater/beneater.rs b/core/src/computers/beneater/beneater.rs index cc4ea5b..e69de29 100644 --- a/core/src/computers/beneater/beneater.rs +++ b/core/src/computers/beneater/beneater.rs @@ -1,5 +0,0 @@ -/// BenEater computer represents the 'Ben Eater' 6502 breadboard computer. -/// This was built along watching the video series where Ben builds a -/// 6502 on a breadboard and explains each step. -/// -pub struct BenEater {} diff --git a/core/src/computers/rom_only/backplane.rs b/core/src/computers/rom_only/backplane.rs index 6a47006..d01b7c0 100644 --- a/core/src/computers/rom_only/backplane.rs +++ b/core/src/computers/rom_only/backplane.rs @@ -3,7 +3,9 @@ use crate::periph::hm62256::Hm62256; use crate::periph::rom_chip::RomChip; pub struct Backplane { - rom: Hm62256 + rom: Hm62256, + data_bus: u8, + address_bus: u16 } impl Backplane { @@ -13,7 +15,9 @@ impl Backplane { pub fn program(rom: &[u8; SIZE_32KB]) -> Backplane { Backplane { - rom: *Hm62256::program(rom) + rom: *Hm62256::program(rom), + address_bus: 0x0000, + data_bus: 0x00 } } diff --git a/core/src/constants/constants_system.rs b/core/src/constants/constants_system.rs index 62c24f8..6f01bc3 100644 --- a/core/src/constants/constants_system.rs +++ b/core/src/constants/constants_system.rs @@ -5,7 +5,3 @@ pub const SIZE_64KB: usize = SIZE_1KB * 64; pub const OFFSET_RESET_VECTOR: u16 = 0xfffc; pub const OFFSET_INT_VECTOR: u16 = 0xfffe; -pub const VIA6522_ORB: u8 = 0; -pub const VIA6522_ORA: u8 = 1; -pub const VIA6522_DDRB: u8 = 2; -pub const VIA6522_DDRA: u8 = 3; diff --git a/core/src/constants/constants_via6522.rs b/core/src/constants/constants_via6522.rs new file mode 100644 index 0000000..1286151 --- /dev/null +++ b/core/src/constants/constants_via6522.rs @@ -0,0 +1,20 @@ +pub const VIA6522_ORB: u8 = 0b0000; +pub const VIA6522_ORA: u8 = 0b0001; +pub const VIA6522_DDRB: u8 = 0b0010; +pub const VIA6522_DDRA: u8 = 0b0011; + +/// Timer 1 Write Latch +pub const VIA6522_T1WL: u8 = 0b0100; +/// Timer 1 Read Counter High +pub const VIA6522_T1CL: u8 = 0b0101; +pub const VIA6522_T1CH: u8 = 0b0110; +pub const VIA6522_T1LL: u8 = 0b0111; +pub const VIA6522_T1LH: u8 = 0b1000; +pub const VIA6522_T2LL: u8 = 0b1001; +pub const VIA6522_T2CH: u8 = 0b1010; +pub const VIA6522_SR: u8 = 0b1011; +pub const VIA6522_ACR: u8 = 0b1100; +pub const VIA6522_PCR: u8 = 0b1101; +pub const VIA6522_IFR: u8 = 0b1110; +pub const VIA6522_IER: u8 = 0b1111; + diff --git a/core/src/constants/mod.rs b/core/src/constants/mod.rs index 9443730..9fffc48 100644 --- a/core/src/constants/mod.rs +++ b/core/src/constants/mod.rs @@ -1,3 +1,4 @@ pub mod constants_isa_op; pub mod constants_isa_stub; pub mod constants_system; +pub mod constants_via6522; diff --git a/core/src/instruction_table.rs b/core/src/instruction_table.rs index bf57a2f..1b10b18 100644 --- a/core/src/instruction_table.rs +++ b/core/src/instruction_table.rs @@ -31,11 +31,11 @@ use crate::op_info::OpInfo; use crate::operation::Operation; use crate::operation::Operation::*; -pub fn INSTRUCTION_CYCLES(instruction: u8) -> u8 { +pub fn instruction_cycles(instruction: u8) -> u8 { INSTRUCTION_TABLE[instruction as usize].unwrap().cycles } -pub fn INSTRUCTION_LENGTH(instruction: u8) -> u8 { +pub fn instruction_length(instruction: u8) -> u8 { INSTRUCTION_TABLE[instruction as usize].unwrap().length } diff --git a/core/src/mos6502cpu/cpu.rs b/core/src/mos6502cpu/cpu.rs index 4e67390..5a40ad3 100644 --- a/core/src/mos6502cpu/cpu.rs +++ b/core/src/mos6502cpu/cpu.rs @@ -483,7 +483,7 @@ impl Mos6502Cpu { mod test { use super::*; use crate::constants::constants_isa_op::*; - use crate::instruction_table::{INSTRUCTION_CYCLES, INSTRUCTION_TABLE}; + use crate::instruction_table::{instruction_cycles, INSTRUCTION_TABLE}; #[test] fn clc() { @@ -496,7 +496,7 @@ mod test { cpu.pc = 0x6000; // Tick the CPU through the instruction - for _ in 0..INSTRUCTION_CYCLES(ISA_OP_CLC) { + for _ in 0..instruction_cycles(ISA_OP_CLC) { cpu.tick(); } @@ -510,7 +510,7 @@ mod test { cpu.memory[0x6000] = ISA_OP_CLD; cpu.pc = 0x6000; - for _ in 0..INSTRUCTION_CYCLES(ISA_OP_CLD) { + for _ in 0..instruction_cycles(ISA_OP_CLD) { cpu.tick(); } @@ -524,7 +524,7 @@ mod test { cpu.memory[0x6000] = ISA_OP_CLI; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_CLI) { + for _ in 0..=instruction_cycles(ISA_OP_CLI) { cpu.tick(); } @@ -538,7 +538,7 @@ mod test { cpu.memory[0x6000] = ISA_OP_CLV; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_CLV) { + for _ in 0..=instruction_cycles(ISA_OP_CLV) { cpu.tick(); } @@ -552,7 +552,7 @@ mod test { cpu.memory[0x6001] = 0xab; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_I) { + for _ in 0..=instruction_cycles(ISA_OP_LDA_I) { cpu.tick(); } @@ -568,7 +568,7 @@ mod test { cpu.memory[0x00ac] = 0xbe; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ZX) { + for _ in 0..=instruction_cycles(ISA_OP_LDA_ZX) { cpu.tick(); } @@ -589,7 +589,7 @@ mod test { cpu.memory[0x00ab] = 0xbe; cpu.pc = 0x6000; - for _ in 0..INSTRUCTION_CYCLES(ISA_OP_LDA_Z) { + for _ in 0..instruction_cycles(ISA_OP_LDA_Z) { cpu.tick(); } @@ -605,7 +605,7 @@ mod test { cpu.memory[0x0eef] = 0xab; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ABS) { + for _ in 0..=instruction_cycles(ISA_OP_LDA_ABS) { cpu.tick(); } @@ -622,7 +622,7 @@ mod test { cpu.memory[0x0ef0] = 0xab; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ABSX) { + for _ in 0..=instruction_cycles(ISA_OP_LDA_ABSX) { cpu.tick(); } @@ -639,7 +639,7 @@ mod test { cpu.memory[0x0ef0] = 0xab; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ABSY) { + for _ in 0..=instruction_cycles(ISA_OP_LDA_ABSY) { cpu.tick(); } @@ -654,11 +654,11 @@ mod test { cpu.memory[0x6001] = ISA_OP_INX; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_DEX) { + for _ in 0..=instruction_cycles(ISA_OP_DEX) { cpu.tick(); } assert_eq!(0xaa, cpu.x); - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_INX) { + for _ in 0..=instruction_cycles(ISA_OP_INX) { cpu.tick(); } assert_eq!(0xab, cpu.x); @@ -672,11 +672,11 @@ mod test { cpu.memory[0x6001] = ISA_OP_INY; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_DEY) { + for _ in 0..=instruction_cycles(ISA_OP_DEY) { cpu.tick(); } assert_eq!(0xaa, cpu.peek_y()); - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_INY) { + for _ in 0..=instruction_cycles(ISA_OP_INY) { cpu.tick(); } assert_eq!(0xab, cpu.peek_y()); @@ -690,11 +690,11 @@ mod test { cpu.memory[0x6001] = ISA_OP_ROR_A; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_ROL_A) { + for _ in 0..=instruction_cycles(ISA_OP_ROL_A) { cpu.tick(); } assert_eq!(cpu.peek_a(), 0b0101_0101); - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_ROR_A) { + for _ in 0..=instruction_cycles(ISA_OP_ROR_A) { cpu.tick(); } assert_eq!(cpu.peek_a(), 0b1010_1010); @@ -708,7 +708,7 @@ mod test { cpu.memory[0x6001] = 0xab; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_ROL_ZP) { + for _ in 0..=instruction_cycles(ISA_OP_ROL_ZP) { cpu.tick(); } diff --git a/core/src/periph/at28c256/mod.rs b/core/src/periph/at28c256/mod.rs index 521318c..bf6267d 100644 --- a/core/src/periph/at28c256/mod.rs +++ b/core/src/periph/at28c256/mod.rs @@ -1,6 +1,8 @@ pub mod default; pub mod rom_chip; pub mod tick; +mod new; +mod program; use crate::constants::constants_system::SIZE_32KB; use crate::periph::rom_chip::RomChip; @@ -16,14 +18,6 @@ pub struct At28C256 { data: Box<[u8; SIZE_32KB]>, } -impl At28C256 { - pub fn program(&mut self, new_program: &[u8; SIZE_32KB]) { - // panic!("FAIL. Cant program the chip."); - // println!("PROGRAMMING {:?}", new_program); - self.data = Box::new(*new_program); - } -} - #[cfg(test)] mod test { use super::*; diff --git a/core/src/periph/at28c256/new.rs b/core/src/periph/at28c256/new.rs new file mode 100644 index 0000000..4d6c6fb --- /dev/null +++ b/core/src/periph/at28c256/new.rs @@ -0,0 +1,10 @@ +use crate::constants::constants_system::SIZE_32KB; +use crate::periph::at28c256::At28C256; + +impl At28C256 { + pub fn new(data: &[u8; SIZE_32KB]) -> Self { + At28C256 { + data: (*data).into() + } + } +} diff --git a/core/src/periph/at28c256/program.rs b/core/src/periph/at28c256/program.rs new file mode 100644 index 0000000..690a544 --- /dev/null +++ b/core/src/periph/at28c256/program.rs @@ -0,0 +1,10 @@ +use crate::constants::constants_system::SIZE_32KB; +use crate::periph::at28c256::At28C256; + +impl At28C256 { + pub fn program(&mut self, new_program: &[u8; SIZE_32KB]) { + // panic!("FAIL. Cant program the chip."); + // println!("PROGRAMMING {:?}", new_program); + self.data = Box::new(*new_program); + } +} diff --git a/core/src/periph/at28c256/tick.rs b/core/src/periph/at28c256/tick.rs index 96ff064..150ed16 100644 --- a/core/src/periph/at28c256/tick.rs +++ b/core/src/periph/at28c256/tick.rs @@ -3,8 +3,10 @@ use crate::periph::hm62256::Hm62256; impl At28C256 { fn tick(&mut self, address_bus: u16, data_bus: u8, read_mode: bool) -> (u16, u8) { - if !read_mode { - // has to be read mode. its a rom. + if read_mode { + panic!("UNABLE TO WRITE TO ROM"); + } else { + // has to be read mode. its a rom. return (address_bus, data_bus) } (address_bus, self.data[address_bus as usize]) diff --git a/core/src/periph/hm62256/tick.rs b/core/src/periph/hm62256/tick.rs index b66af83..bfcd38d 100644 --- a/core/src/periph/hm62256/tick.rs +++ b/core/src/periph/hm62256/tick.rs @@ -25,7 +25,9 @@ mod test { fn write_to_memory_read_back_works_at_0() { let mut ram = Hm62256::default(); + // load the data to ram ram.tick(0x0000, 0xab, false); + // read the data back let (_, new_data) = ram.tick(0x0000, 0x00, true); assert_eq!(new_data, 0xab); diff --git a/core/src/periph/mod.rs b/core/src/periph/mod.rs index 0f30a79..6761bad 100644 --- a/core/src/periph/mod.rs +++ b/core/src/periph/mod.rs @@ -3,3 +3,4 @@ pub mod rom_chip; pub mod at28c256; pub mod hm62256; pub mod ram_chip; +pub mod mos6522; diff --git a/core/src/periph/mos6522/mod.rs b/core/src/periph/mos6522/mod.rs new file mode 100644 index 0000000..b576f29 --- /dev/null +++ b/core/src/periph/mos6522/mod.rs @@ -0,0 +1,2 @@ +pub mod mos6522; +mod registers; \ No newline at end of file diff --git a/core/src/periph/mos6522/mos6522.rs b/core/src/periph/mos6522/mos6522.rs new file mode 100644 index 0000000..b201231 --- /dev/null +++ b/core/src/periph/mos6522/mos6522.rs @@ -0,0 +1,165 @@ +use std::time::Instant; +use log::debug; +use crate::constants::constants_via6522::*; + +#[derive(Default)] +pub struct Mos6522 { + /// data direction + dda: u8, + ddb: u8, + + /// bottom 4 address bits + rs0: u8, + rs1: u8, + rs2: u8, + rs3: u8, + + /// external data bus + data_bus: u8, + + cs1: bool, + cs2: bool, + rw: bool, + + /// reset circuit - true when reset inited + reset: bool, + + /// IRQ - true when interrupt waiting + irq: bool, + + ira: u8, + ora: u8, + porta: u8, + irb: u8, + orb: u8, + portb: u8, + + ca1: bool, + ca2: bool, + cb1: bool, + cb2: bool, +} + +impl Mos6522 { + pub fn new() -> Self { + Mos6522::default() + } + + /// tick + /// + /// data_bus -> 8 bits from the data bus + /// control -> 4 bits to identify which register to control + pub fn tick(&mut self, data_bus: u8, control: u8, rw: bool) -> (u8) { + println!("Mos6522 Tick Start -> 0x{data_bus:02x} / 0x{control:02x} / {rw}"); + if rw { + // RW true = CPU is writing + self.data_bus = data_bus; + match control { + VIA6522_DDRA => { + debug!("Setting DDA to 0x{data_bus:02x}"); + // setting the Data Direction for Port A + self.dda = data_bus; + }, + VIA6522_DDRB => { + debug!("Setting DDB to 0x{data_bus:02x}"); + // setting the data direction for port b + self.ddb = data_bus; + }, + VIA6522_ORB => { + // writing data to ORB + let masked_data = data_bus & self.ddb; + debug!("Setting ORB to 0x{data_bus:02x} / masked at 0x{masked_data:02x}"); + self.portb = masked_data; + }, + VIA6522_ORA => { + // writing data to ORA + let masked_data = data_bus & self.dda; + debug!("Setting ORA to 0x{data_bus:02x} / masked at 0x{masked_data:02x}"); + self.porta = masked_data; + }, + _ => {} + } + } else { + // RW false = CPU is reading + self.data_bus = match control { + VIA6522_DDRA => { + self.dda + } + VIA6522_DDRB => { + self.ddb + } + VIA6522_ORA => { + self.porta & self.dda + } + VIA6522_ORB => { + self.portb & self.ddb + } + _ => { + debug!("VIA got request for b{:08b} / 0x{:02x}", control, control); + // do nothing. bad address for VIA + self.data_bus + } + } + } + + (self.data_bus) + } + + pub fn start_clocks(&mut self) { + loop { + let cycle_start = Instant::now(); + // let duration = cycle_start.duration_since(self.clock); + // set the time to the new time. + // self.clock = cycle_start; + } + } +} + + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn smoke() { assert!(true); } + + #[test] + fn registers() { + let mut x = Mos6522::new(); + x.tick(0b0000_0000, VIA6522_DDRA, true); + assert_eq!(x.dda, 0b0000_0000); + x.tick(0b1111_1111, VIA6522_DDRA, true); + assert_eq!(x.dda, 0b1111_1111); + + x.tick(0b0000_0000, VIA6522_DDRB, true); + assert_eq!(x.ddb, 0b0000_0000); + x.tick(0b1111_1111, VIA6522_DDRB, true); + assert_eq!(x.ddb, 0b1111_1111); + + x.tick(0b0000_0000, VIA6522_ORA, true); + assert_eq!(x.porta, 0b0000_0000); + x.tick(0b1111_1111, VIA6522_ORA, true); + assert_eq!(x.porta, 0b1111_1111); + + x.tick(0b0000_0000, VIA6522_ORB, true); + assert_eq!(x.portb, 0b0000_0000); + x.tick(0b1111_1111, VIA6522_ORB, true); + assert_eq!(x.portb, 0b1111_1111); + } + + #[test] + fn partial_output_porta() { + let mut x = Mos6522::new(); + x.tick(0b1010_1010, VIA6522_DDRA, true); + x.tick(0b1111_1111, VIA6522_ORA, true); + assert_eq!(x.porta, 0b1010_1010); + } + + #[test] + fn partial_output_portb() { + let mut x = Mos6522::new(); + x.tick(0b0101_0101, VIA6522_DDRB, true); + x.tick(0b1111_1111, VIA6522_ORB, true); + assert_eq!(x.portb, 0b0101_0101); + } +} diff --git a/core/src/periph/mos6522/registers.rs b/core/src/periph/mos6522/registers.rs new file mode 100644 index 0000000..1b1c423 --- /dev/null +++ b/core/src/periph/mos6522/registers.rs @@ -0,0 +1,12 @@ +pub enum Via6522Registers { + ORA, + ORB, + DDRA, + DDRB, + T1WL, + T1CL, + T1CH, + T1LL, + T2LL, + T2CH, +} \ No newline at end of file diff --git a/macroquad/Cargo.toml b/macroquad/Cargo.toml index 399f198..be4b601 100644 --- a/macroquad/Cargo.toml +++ b/macroquad/Cargo.toml @@ -5,4 +5,5 @@ edition = "2024" [dependencies] macroquad.workspace = true -core = { path = "../core" } \ No newline at end of file +core = { path = "../core" } +egui-macroquad = "0.17" diff --git a/macroquad/src/bin/rom_only.rs b/macroquad/src/bin/rom_only.rs index 6d6ae69..e69de29 100644 --- a/macroquad/src/bin/rom_only.rs +++ b/macroquad/src/bin/rom_only.rs @@ -1,31 +0,0 @@ -use macroquad::prelude::*; -use core::computers::rom_only::backplane::Backplane; -pub struct UiState { - display_offset: u16, - current_offset: u16 -} - -#[macroquad::main("Rom_Only")] -async fn main() { - - let mut backplane = Backplane::new(); - let mut state = UiState { display_offset: 0x00, current_offset: 0x00 }; - - loop { - clear_background(BLUE); - - draw_text("ROM ONLY", 20.0, 20.0, 30.0, DARKGRAY); - - backplane.tick(); - - draw_text( - format!("Display Offset: 0x{:04x}", state.display_offset).as_str(), 20.0, 60.0, 30.0, DARKGRAY - ); - - draw_text( - format!("Current Offset: 0x{:04x}", state.current_offset).as_str(), 20.0, 100.0, 30.0, DARKGRAY - ); - - next_frame().await - } -} diff --git a/resources/beneater/asm/nop_1.asm b/resources/beneater/asm/nop_1.asm new file mode 100644 index 0000000..e69de29