feat: add test harness, fix ppu windows, rename

This commit is contained in:
EliseZeroTwo 2024-01-02 11:47:06 -07:00
parent 85d61764e8
commit dff765a38c
Signed by: elise
GPG key ID: FA8F56FFFE6E8B3E
49 changed files with 629 additions and 286 deletions

492
Cargo.lock generated
View file

@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.7.6"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd"
dependencies = [
"getrandom",
"once_cell",
@ -29,14 +29,32 @@ dependencies = [
]
[[package]]
name = "aho-corasick"
version = "0.7.18"
name = "ahash"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]]
name = "aho-corasick"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "android-activity"
version = "0.5.1"
@ -64,6 +82,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
@ -123,9 +147,9 @@ dependencies = [
[[package]]
name = "arrayvec"
version = "0.7.2"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "ash"
@ -133,14 +157,14 @@ version = "0.37.3+1.3.251"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a"
dependencies = [
"libloading 0.7.2",
"libloading 0.7.4",
]
[[package]]
name = "async-trait"
version = "0.1.75"
version = "0.1.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98"
checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
@ -155,9 +179,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "autocfg"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
@ -182,9 +206,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "bit-set"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [
"bit-vec",
]
@ -252,9 +276,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.8.0"
version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c"
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
[[package]]
name = "bytemuck"
@ -264,9 +288,9 @@ checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
version = "1.4.3"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
@ -290,11 +314,12 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.72"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"jobserver",
"libc",
]
[[package]]
@ -317,15 +342,16 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
version = "0.4.19"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
dependencies = [
"libc",
"num-integer",
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"time",
"winapi",
"wasm-bindgen",
"windows-targets 0.48.5",
]
[[package]]
@ -459,13 +485,12 @@ dependencies = [
[[package]]
name = "core-graphics-types"
version = "0.1.1"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"foreign-types 0.3.2",
"libc",
]
@ -513,7 +538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8f0de2f5a8e7bd4a9eec0e3c781992a4ce1724f68aec7d7a3715344de8b39da"
dependencies = [
"bitflags 1.3.2",
"libloading 0.7.2",
"libloading 0.7.4",
"winapi",
]
@ -552,36 +577,6 @@ dependencies = [
"syn",
]
[[package]]
name = "deemgee"
version = "0.1.0"
dependencies = [
"bmp",
"chrono",
"clap",
"config",
"deemgee-opcode",
"env_logger",
"log",
"paste",
"pixels",
"serde",
"sha1",
"thiserror",
"winit",
"winit_input_helper",
]
[[package]]
name = "deemgee-opcode"
version = "0.1.0"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "digest"
version = "0.10.7"
@ -626,6 +621,12 @@ dependencies = [
"termcolor",
]
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.8"
@ -702,7 +703,7 @@ checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
dependencies = [
"cfg-if",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"wasi",
]
[[package]]
@ -725,9 +726,9 @@ dependencies = [
[[package]]
name = "gpu-alloc"
version = "0.5.2"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e64cbb8d36508d3e19da95e56e196a84f674fc190881f2cc010000798838aa6"
checksum = "22beaafc29b38204457ea030f6fb7a84c9e4dd1b86e311ba0542533453d87f62"
dependencies = [
"bitflags 1.3.2",
"gpu-alloc-types",
@ -757,31 +758,22 @@ dependencies = [
[[package]]
name = "gpu-descriptor"
version = "0.2.2"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a538f217be4d405ff4719a283ca68323cc2384003eca5baaa87501e821c81dda"
checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.4.1",
"gpu-descriptor-types",
"hashbrown 0.11.2",
"hashbrown 0.14.3",
]
[[package]]
name = "gpu-descriptor-types"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "363e3677e55ad168fef68cf9de3a4a310b53124c5e784c53a1d70e92d23f2126"
checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash",
"bitflags 2.4.1",
]
[[package]]
@ -790,7 +782,17 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash",
"ahash 0.7.7",
]
[[package]]
name = "hashbrown"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash 0.8.7",
"allocator-api2",
]
[[package]]
@ -802,7 +804,7 @@ dependencies = [
"bitflags 1.3.2",
"com-rs",
"libc",
"libloading 0.7.2",
"libloading 0.7.4",
"thiserror",
"widestring",
"winapi",
@ -832,6 +834,29 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "iana-time-zone"
version = "0.1.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "icrate"
version = "0.0.4"
@ -860,12 +885,13 @@ dependencies = [
]
[[package]]
name = "instant"
version = "0.1.12"
name = "indexmap"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
dependencies = [
"cfg-if",
"equivalent",
"hashbrown 0.14.3",
]
[[package]]
@ -881,9 +907,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "0.4.8"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "jni"
@ -943,7 +969,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3"
dependencies = [
"libc",
"libloading 0.7.2",
"libloading 0.7.4",
"pkg-config",
]
@ -961,9 +987,9 @@ checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]]
name = "libloading"
version = "0.7.2"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
@ -992,9 +1018,9 @@ dependencies = [
[[package]]
name = "linked-hash-map"
version = "0.5.4"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
@ -1004,21 +1030,19 @@ checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "lock_api"
version = "0.4.5"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.14"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "malloc_buf"
@ -1031,9 +1055,48 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.4.1"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "meowgb"
version = "0.1.0"
dependencies = [
"bmp",
"chrono",
"clap",
"config",
"env_logger",
"log",
"meowgb-opcode",
"paste",
"pixels",
"serde",
"sha1",
"thiserror",
"winit",
"winit_input_helper",
]
[[package]]
name = "meowgb-opcode"
version = "0.1.0"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "meowgb-tests"
version = "0.1.0"
dependencies = [
"clap",
"meowgb",
"thiserror",
]
[[package]]
name = "metal"
@ -1074,7 +1137,7 @@ dependencies = [
"bitflags 1.3.2",
"codespan-reporting",
"hexf-parse",
"indexmap",
"indexmap 1.9.3",
"log",
"num-traits",
"rustc-hash",
@ -1116,30 +1179,19 @@ dependencies = [
[[package]]
name = "nom"
version = "7.1.0"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
"version_check",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
@ -1242,34 +1294,32 @@ dependencies = [
[[package]]
name = "parking_lot"
version = "0.11.2"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.5"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall 0.2.10",
"redox_syscall 0.4.1",
"smallvec",
"winapi",
"windows-targets 0.48.5",
]
[[package]]
name = "paste"
version = "1.0.6"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "pathdiff"
@ -1344,9 +1394,9 @@ dependencies = [
[[package]]
name = "pkg-config"
version = "0.3.23"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1a3ea4f0dd7f1f3e512cf97bf100819aa547f36a6eccac8dbaae839eb92363e"
checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
[[package]]
name = "polling"
@ -1370,43 +1420,43 @@ checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
[[package]]
name = "proc-macro-crate"
version = "1.1.0"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83"
checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a"
dependencies = [
"thiserror",
"toml",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "proc-macro2"
version = "1.0.71"
version = "1.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"
dependencies = [
"unicode-ident",
]
[[package]]
name = "profiling"
version = "1.0.4"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9926767b8b8244d7b6b64546585121d193c3d0b4856ccd656b7bfa9deb91ab6a"
checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e"
[[package]]
name = "quote"
version = "1.0.33"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "range-alloc"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6"
checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab"
[[package]]
name = "raw-window-handle"
@ -1414,15 +1464,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
[[package]]
name = "redox_syscall"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_syscall"
version = "0.3.5"
@ -1443,9 +1484,21 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.4"
version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
@ -1454,9 +1507,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.25"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "renderdoc-sys"
@ -1512,9 +1565,9 @@ dependencies = [
[[package]]
name = "ryu"
version = "1.0.6"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "safe_arch"
@ -1536,24 +1589,24 @@ dependencies = [
[[package]]
name = "scopeguard"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
version = "1.0.193"
version = "1.0.194"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.193"
version = "1.0.194"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0"
dependencies = [
"proc-macro2",
"quote",
@ -1562,9 +1615,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.72"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527"
checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257"
dependencies = [
"itoa",
"ryu",
@ -1604,9 +1657,9 @@ dependencies = [
[[package]]
name = "slotmap"
version = "1.0.6"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a"
dependencies = [
"version_check",
]
@ -1650,9 +1703,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "2.0.43"
version = "2.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"
dependencies = [
"proc-macro2",
"quote",
@ -1661,27 +1714,27 @@ dependencies = [
[[package]]
name = "termcolor"
version = "1.1.2"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
dependencies = [
"winapi-util",
]
[[package]]
name = "thiserror"
version = "1.0.52"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.52"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",
@ -1689,23 +1742,29 @@ dependencies = [
]
[[package]]
name = "time"
version = "0.1.44"
name = "toml"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
"serde",
]
[[package]]
name = "toml"
version = "0.5.8"
name = "toml_datetime"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
[[package]]
name = "toml_edit"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
dependencies = [
"serde",
"indexmap 2.1.0",
"toml_datetime",
"winnow",
]
[[package]]
@ -1753,15 +1812,15 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
version = "0.1.9"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "unicode-xid"
@ -1783,21 +1842,14 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
version = "2.3.2"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@ -2024,9 +2076,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
@ -2046,6 +2098,15 @@ dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.0",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
@ -2246,9 +2307,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winit"
version = "0.29.7"
version = "0.29.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fd430cd4560ee9c48885a4ef473b609a56796e37b1e18222abee146143f7457"
checksum = "0dc1a7ae1076890701c7dd71ea35b2aebaf9aeb7b8868ac2d33b1c7e8ef93c00"
dependencies = [
"android-activity",
"atomic-waker",
@ -2290,6 +2351,15 @@ dependencies = [
"winit",
]
[[package]]
name = "winnow"
version = "0.5.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c"
dependencies = [
"memchr",
]
[[package]]
name = "xkbcommon-dl"
version = "0.4.1"
@ -2317,3 +2387,23 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]
[[package]]
name = "zerocopy"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View file

@ -1,3 +1,3 @@
[workspace]
resolver = "2"
members = ["deemgee", "deemgee-opcode"]
members = ["meowgb", "meowgb-opcode", "meowgb-tests"]

View file

@ -1,5 +1,5 @@
[package]
name = "deemgee-opcode"
name = "meowgb-opcode"
version = "0.1.0"
edition = "2021"

View file

@ -56,7 +56,7 @@ pub fn opcode(item: TokenStream) -> TokenStream {
let length = length.base10_parse::<u8>().expect("Failed to parse opcode length as u8");
let fn_sig = quote::quote! {
pub fn #name(state: &mut Gameboy) -> CycleResult
pub fn #name(state: &mut Gameboy<impl crate::gameboy::serial::SerialWriter>) -> CycleResult
};
let mut cycle = Vec::new();

11
meowgb-tests/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "meowgb-tests"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4.4.12", features = ["derive"] }
meowgb = { path = "../meowgb" }
thiserror = "1.0.56"

View file

@ -0,0 +1,5 @@
cpu_instrs
01:ok 02:ok 03:ok 04:ok 05:ok 06:ok 07:ok 08:ok 09:ok 10:ok 11:ok
Passed all tests

View file

@ -0,0 +1,4 @@
instr_timing
Passed

View file

@ -0,0 +1 @@
 "

View file

@ -0,0 +1 @@
 "

View file

@ -0,0 +1 @@
 "

View file

@ -0,0 +1,5 @@
mem_timing
01:ok 02:ok 03:ok
Passed all tests

View file

@ -0,0 +1 @@
 "

169
meowgb-tests/src/main.rs Normal file
View file

@ -0,0 +1,169 @@
use std::{path::{PathBuf, Path}, sync::{RwLock, Arc}, time::{Duration, Instant}};
use clap::{Parser, Subcommand};
use meowgb::gameboy::{Gameboy, serial::SerialWriter};
#[derive(Debug, Parser)]
/// DMG Emulator
pub struct CliArgs {
/// game path
pub rom: PathBuf,
#[clap(subcommand)]
pub operation: Operation
}
#[derive(Debug, Subcommand)]
pub enum Operation {
Test {
/// maximum M-cycles
#[clap(short='m', long)]
maximum_m_cycles: u64,
/// path to expected serial output
#[clap(short='s', long)]
expected_serial: PathBuf,
},
GenerateOutput {
/// M-cycles to run for
#[clap(short='m', long)]
m_cycles: u64,
/// path to expected serial output
#[clap(short='s', long)]
expected_serial: PathBuf,
}
}
#[derive(Debug, thiserror::Error)]
pub enum DmgTestError {
#[error("ROM not found")]
RomNotFound,
#[error("ROM reading error: {0}")]
RomRead(std::io::Error),
#[error("Missing serial output file")]
SerialOutputFileNotFound,
#[error("Error reading serial output file: {0}")]
SerialOutputFileRead(std::io::Error),
#[error("Error writing serial output file: {0}")]
SerialOutputFileWrite(std::io::Error),
#[error("Serial mismatch\nExpected: {0}\nFound: {1}")]
SerialDifferent(String, String),
}
#[derive(Debug, Clone)]
pub struct SyncWriter(pub Arc<RwLock<Vec<u8>>>);
impl SyncWriter {
pub fn new() -> Self {
Self(Arc::new(RwLock::new(Vec::new())))
}
pub fn compare(&self, expected: &[u8]) -> bool {
self.0.read().unwrap().as_slice() == expected
}
pub fn into_inner(self) -> Vec<u8> {
std::sync::Arc::into_inner(self.0).unwrap().into_inner().unwrap()
}
}
impl SerialWriter for SyncWriter {
fn write_byte(&mut self, byte: u8) {
self.0.write().unwrap().write_byte(byte);
}
}
fn generate_output(rom: &Path, m_cycles: u64, expected_serial: &Path) -> Result<Duration, DmgTestError> {
let rom = {
if !rom.is_file() {
return Err(DmgTestError::RomNotFound);
}
std::fs::read(rom).map_err(DmgTestError::RomRead)?
};
let sync_writer = SyncWriter::new();
let mut gameboy = Gameboy::new(None, sync_writer.clone());
gameboy.load_cartridge(rom);
let instant = std::time::Instant::now();
for _ in 0..m_cycles {
gameboy.tick_4();
}
drop(gameboy);
let serial_content = sync_writer.into_inner();
std::fs::write(expected_serial, &serial_content).map_err(DmgTestError::SerialOutputFileWrite)?;
Ok(instant.elapsed())
}
fn run_test(rom: &Path, maximum_m_cycles: u64, expected_serial: &Path) -> Result<(u64, Duration), DmgTestError> {
let rom = {
if !rom.is_file() {
return Err(DmgTestError::RomNotFound);
}
std::fs::read(rom).map_err(DmgTestError::RomRead)?
};
let expected_serial = {
if !expected_serial.is_file() {
return Err(DmgTestError::SerialOutputFileNotFound);
}
std::fs::read(expected_serial).map_err(DmgTestError::SerialOutputFileRead)?
};
let sync_writer = SyncWriter::new();
let mut gameboy = Gameboy::new(None, sync_writer.clone());
gameboy.load_cartridge(rom);
let instant = Instant::now();
let mut cycle_counter = 0;
while cycle_counter < maximum_m_cycles {
gameboy.tick_4();
cycle_counter += 1;
if sync_writer.compare(&expected_serial) {
return Ok((cycle_counter, instant.elapsed()));
}
}
drop(gameboy);
match sync_writer.compare(&expected_serial) {
true => Ok((cycle_counter, instant.elapsed())),
false => Err(DmgTestError::SerialDifferent(expected_serial.into_iter().map(char::from).collect(), sync_writer.into_inner().into_iter().map(char::from).collect())),
}
}
fn main() {
let args = CliArgs::parse();
match args.operation {
Operation::Test { maximum_m_cycles, expected_serial } => match run_test(args.rom.as_path(), maximum_m_cycles, expected_serial.as_path()) {
Ok((m_cycles, duration)) => {
println!("Success! Ran {} M-Cycles in {}ms", m_cycles, duration.as_millis());
},
Err(why) => {
eprintln!("{}", why);
std::process::exit(1);
}
},
Operation::GenerateOutput { m_cycles, expected_serial } => match generate_output(args.rom.as_path(), m_cycles, expected_serial.as_path()) {
Ok(duration) => {
println!("Successfully written serial output to {} in {} M-Cycles ({}ms), please verify it is correct", expected_serial.display(), m_cycles, duration.as_millis());
},
Err(why) => {
eprintln!("{}", why);
std::process::exit(1);
}
},
}
}

View file

@ -1,5 +1,5 @@
[package]
name = "deemgee"
name = "meowgb"
version = "0.1.0"
edition = "2021"
@ -10,7 +10,7 @@ bmp = "0.5.0"
chrono = "0.4.19"
clap = { version = "4.4.12", features = ["derive"] }
config = "0.13.4"
deemgee-opcode = { path = "../deemgee-opcode" }
meowgb-opcode = { path = "../meowgb-opcode" }
env_logger = "0.10.1"
log = "0.4.14"
paste = "1.0.6"

View file

@ -1,10 +1,11 @@
pub mod bootrom;
mod cpu;
mod interrupts;
mod joypad;
pub mod mapper;
mod memory;
pub mod ppu;
mod serial;
pub mod serial;
mod sound;
mod timer;
@ -18,7 +19,7 @@ use timer::Timer;
use self::{
cpu::Registers,
mapper::{mbc1::MBC1, NoMBC},
serial::Serial,
serial::{Serial, SerialWriter},
sound::Sound,
};
@ -109,7 +110,7 @@ fn test_ringbuffer() {
);
}
pub struct Gameboy {
pub struct Gameboy<S: SerialWriter> {
pub ppu: Ppu,
pub memory: Memory,
pub cartridge: Option<Box<dyn Mapper>>,
@ -117,7 +118,7 @@ pub struct Gameboy {
pub timer: Timer,
pub registers: Registers,
pub joypad: Joypad,
pub serial: Serial,
pub serial: Serial<S>,
pub dma: DmaState,
pub sound: Sound,
@ -137,15 +138,15 @@ pub struct Gameboy {
pub tick_count: u8,
}
impl Gameboy {
pub fn new(bootrom: Option<[u8; 0x100]>) -> Self {
impl<S: SerialWriter> Gameboy<S> {
pub fn new(bootrom: Option<[u8; 0x100]>, serial_writer: S) -> Self {
Self {
memory: Memory::new(bootrom),
cartridge: None,
interrupts: Interrupts::new(),
timer: Timer::new(),
joypad: Joypad::new(),
serial: Serial::new(),
serial: Serial::new(serial_writer),
dma: DmaState::new(),
ppu: Ppu::new(bootrom.is_some()),
registers: match bootrom.is_some() {
@ -342,7 +343,7 @@ impl Gameboy {
self.ppu.dump_bg_tiles();
}
"dumpfb" => {
println!("Written to: {}", self.ppu.dump_fb());
println!("Written to: {}", self.ppu.dump_fb_to_file());
}
"dumpoam" => {
for x in 0..self.ppu.oam.len() {

View file

@ -0,0 +1,48 @@
use std::{path::Path, io::Read};
use sha1::{Digest, Sha1};
#[derive(Debug, thiserror::Error)]
pub enum BootromParseError {
#[error("Bootrom file cannot be found")]
BootromNotFound,
#[error("IO error whilst reading bootrom: {0}")]
Io(#[from] std::io::Error),
#[error("Bootrom size is {0} bytes, expected 256 bytes")]
InvalidSize(u64),
#[error("Bootrom has an invalid SHA1 (expected \"4ed31ec6b0b175bb109c0eb5fd3d193da823339f\")")]
InvalidHash,
#[error("Failed to open bootrom file: {0}")]
FileOpen(std::io::Error),
#[error("Failed to read bootrom file: {0}")]
FileRead(std::io::Error),
}
pub fn verify_parse_bootrom(path: &Path) -> Result<[u8; 0x100], BootromParseError> {
if !path.is_file() {
return Err(BootromParseError::BootromNotFound);
}
let mut bootrom_slice = [0u8; 0x100];
let mut file = std::fs::File::open(path).map_err(BootromParseError::FileOpen)?;
let metadata = file.metadata()?;
if metadata.len() != 256 {
return Err(BootromParseError::InvalidSize(metadata.len()));
}
file.read_exact(&mut bootrom_slice).map_err(BootromParseError::FileRead)?;
let mut hash_ctx = Sha1::new();
hash_ctx.update(&bootrom_slice);
let digest = hash_ctx.finalize();
if digest.as_slice()
!= b"\x4e\xd3\x1e\xc6\xb0\xb1\x75\xbb\x10\x9c\x0e\xb5\xfd\x3d\x19\x3d\xa8\x23\x33\x9f"
{
return Err(BootromParseError::InvalidHash);
}
Ok(bootrom_slice)
}

View file

@ -4,7 +4,7 @@ mod load_store_move;
mod misc;
mod prefixed;
use super::Gameboy;
use super::{Gameboy, serial::SerialWriter};
macro_rules! define_register {
($lident:ident, $rident:ident) => {
@ -140,7 +140,7 @@ impl Registers {
}
}
pub fn tick_cpu(state: &mut Gameboy) {
pub fn tick_cpu(state: &mut Gameboy<impl SerialWriter>) {
state.registers.mem_op_happened = false;
if state.joypad.interrupt_triggered {

View file

@ -1,4 +1,4 @@
use deemgee_opcode::opcode;
use meowgb_opcode::opcode;
use super::CycleResult;
use crate::gameboy::Gameboy;

View file

@ -1,4 +1,4 @@
use deemgee_opcode::opcode;
use meowgb_opcode::opcode;
use super::CycleResult;
use crate::gameboy::Gameboy;

View file

@ -1,4 +1,4 @@
use deemgee_opcode::opcode;
use meowgb_opcode::opcode;
use crate::gameboy::{cpu::CycleResult, Gameboy};

View file

@ -1,4 +1,4 @@
use deemgee_opcode::opcode;
use meowgb_opcode::opcode;
use super::CycleResult;
use crate::gameboy::Gameboy;

View file

@ -1,9 +1,9 @@
use deemgee_opcode::opcode;
use meowgb_opcode::opcode;
use super::CycleResult;
use crate::gameboy::Gameboy;
use crate::gameboy::{Gameboy, serial::SerialWriter};
pub fn prefixed_handler(state: &mut Gameboy) -> CycleResult {
pub fn prefixed_handler(state: &mut Gameboy<impl SerialWriter>) -> CycleResult {
let opcode = match state.registers.current_prefixed_opcode {
Some(prefixed_opcode) => prefixed_opcode,
None => match state.registers.mem_read_hold.take() {

View file

@ -564,8 +564,8 @@ impl Ppu {
oam_entry.y.wrapping_sub(16).wrapping_add(sprite_height as u8);
if oam_entry.x > 0
&& self.ly.wrapping_add(self.scy) < real_oam_y
&& self.ly.wrapping_add(self.scy) >= oam_entry.y.wrapping_sub(16)
&& self.ly < real_oam_y
&& self.ly >= oam_entry.y.wrapping_sub(16)
&& self.sprite_count < 10
{
self.sprite_buffer[self.sprite_count] = Some(oam_entry);
@ -744,6 +744,8 @@ impl Ppu {
mut window_drawn,
draw_only_sprites,
) => {
// assert_eq!(scy, self.scy);
// assert_eq!(scx, self.scx);
let wx_match = (drawn_pixels as usize + 7) >= self.wx as usize;
let scrolled_y = self.ly.wrapping_add(scy) as usize;
let scrolled_x = drawn_pixels.wrapping_add(scx) as usize;
@ -762,13 +764,14 @@ impl Ppu {
if self.window_enabled() && wx_match && self.wy_match {
window_drawn = true;
let tilemap_idx =
drawn_pixels as usize / 8 + ((self.ly as usize / 8) * 32);
let window_x = (drawn_pixels as u8).wrapping_sub(self.wx.wrapping_sub(7)) as usize;
let window_y = self.ly.wrapping_sub(self.wy) as usize;
let tilemap_idx = window_x / 8 + ((window_y / 8) * 32);
let tilemap_value = self.read_window_tile_map()[tilemap_idx];
(bg_color_id, bg_color) = Self::parse_tile_color(
self.read_bg_win_tile(tilemap_value),
drawn_pixels as usize % 8,
self.ly as usize % 8,
window_x % 8,
window_y % 8,
&self.bgp,
);
}
@ -889,7 +892,7 @@ impl Ppu {
out
}
pub fn dump_fb(&self) -> String {
pub fn dump_fb_to_file(&self) -> String {
let mut image = bmp::Image::new(FB_WIDTH, FB_HEIGHT);
for y in 0..FB_HEIGHT {

View file

@ -1,15 +1,27 @@
use std::io::Write;
pub struct Serial {
pub trait SerialWriter {
fn write_byte(&mut self, byte: u8);
}
impl<T: Write> SerialWriter for T {
fn write_byte(&mut self, byte: u8) {
self.write_all(&[byte]).expect(format!("writing serial to {} failed", std::any::type_name::<T>()).as_str());
self.flush().expect(format!("flushing serial to {} failed", std::any::type_name::<T>()).as_str());
}
}
pub struct Serial<S: SerialWriter> {
pub sb: u8,
pub sc: u8,
internal_tick: u16,
writer: S,
}
impl Serial {
pub fn new() -> Serial {
Self { sb: 0, sc: 0, internal_tick: 0 }
impl<S: SerialWriter> Serial<S> {
pub fn new(writer: S) -> Serial<S> {
Self { sb: 0, sc: 0, internal_tick: 0, writer }
}
pub fn set_transfer_in_process(&mut self, value: bool) {
@ -36,8 +48,7 @@ impl Serial {
if self.internal_tick < 128 {
self.internal_tick += 1;
} else {
std::io::stdout().write_all(&[self.sb]).expect("writing stdout failed");
std::io::stdout().flush().expect("flushing stdout failed");
self.writer.write_byte(self.sb);
self.sb = 0;
self.set_transfer_in_process(false);
self.internal_tick = 0;

View file

@ -1,13 +1,13 @@
use std::io::Stdout;
pub mod gameboy;
#[allow(unused)]
mod settings;
#[allow(unused)]
mod window;
pub fn setup_test_emulator<const ROM_LENGTH: usize>(
test_opcodes: [u8; ROM_LENGTH],
) -> gameboy::Gameboy {
let mut gameboy = gameboy::Gameboy::new(None);
) -> gameboy::Gameboy<Stdout> {
let mut gameboy = gameboy::Gameboy::new(None, std::io::stdout());
let mut cartridge = gameboy::mapper::NoMBC { rom: [0u8; 0x8000], ram: None };

View file

@ -10,9 +10,8 @@ use std::{
use chrono::{Duration, Utc};
use clap::Parser;
use gameboy::Gameboy;
use gameboy::{Gameboy, bootrom::{BootromParseError, verify_parse_bootrom}};
use settings::DeemgeeConfig;
use sha1::{Digest, Sha1};
use window::EmulatorWindowEvent;
use crate::window::GameboyEvent;
@ -33,12 +32,8 @@ pub struct CliArgs {
#[derive(Debug, thiserror::Error)]
pub enum DmgError {
#[error("Bootrom Not Found")]
BootromNotFound,
#[error("Bootrom Incorrect Size (expected 256 bytes, found {0} bytes)")]
BootromInvalidSize(u64),
#[error("Bootrom SHA1 failed (expected 4ed31ec6b0b175bb109c0eb5fd3d193da823339f)")]
BootromInvalidHash,
#[error(transparent)]
Bootrom(BootromParseError),
#[error("Game Not Found")]
GameNotFound,
#[error("IO Error: {0}")]
@ -79,42 +74,12 @@ pub fn run_gameboy(
rx: Receiver<EmulatorWindowEvent>,
tx: Sender<GameboyEvent>,
) -> Result<(), DmgError> {
let mut bootrom = None;
if let Some(bootrom_path) = args.bootrom {
if !bootrom_path.is_file() {
return Err(DmgError::BootromNotFound);
}
let bootrom = match args.bootrom.as_deref() {
Some(path) => Some(verify_parse_bootrom(path).map_err(DmgError::Bootrom)?),
None => None,
};
let brom_md = std::fs::metadata(bootrom_path.as_path())?;
if brom_md.len() != 256 {
return Err(DmgError::BootromInvalidSize(brom_md.len()));
}
let mut bootrom_slice = [0u8; 0x100];
let bootrom_vec = std::fs::read(bootrom_path)?;
if bootrom_vec.len() != 256 {
return Err(DmgError::BootromInvalidSize(bootrom_vec.len() as u64));
}
let mut hash_ctx = Sha1::new();
hash_ctx.update(&bootrom_vec);
let digest = hash_ctx.finalize();
if digest.as_slice()
!= b"\x4e\xd3\x1e\xc6\xb0\xb1\x75\xbb\x10\x9c\x0e\xb5\xfd\x3d\x19\x3d\xa8\x23\x33\x9f"
{
return Err(DmgError::BootromInvalidHash);
}
bootrom_slice.copy_from_slice(&bootrom_vec);
bootrom = Some(bootrom_slice)
}
let mut gameboy = Gameboy::new(bootrom);
let mut gameboy = Gameboy::new(bootrom, std::io::stdout());
if args.debug {
gameboy.single_step = true;

View file

@ -1,4 +1,4 @@
use deemgee::setup_test_emulator;
use meowgb::setup_test_emulator;
macro_rules! conditional_jump_relative_testgen {
($flag:ident, $not_opcode:literal, $opcode:literal) => {

View file

@ -1,4 +1,4 @@
use deemgee::setup_test_emulator;
use meowgb::setup_test_emulator;
macro_rules! ld_reg_imm_u16_testgen {
($hireg:ident, $loreg:ident, $opcode:literal) => {

View file

@ -1,4 +1,4 @@
use deemgee::setup_test_emulator;
use meowgb::setup_test_emulator;
#[test]
fn test_nop() {

1
test-roms/blargg/LICENSE Normal file
View file

@ -0,0 +1 @@
All rights of these test ROMs belong to Blargg. They were never shipped with a license, and both of the offical websites for them are down now. If they do not want these ROMs being used here, please contact me and I will remove them.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Matt Currie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,5 @@
# Mealybug Tearoom Tests
These test ROMs were written by "mattcurrie", and are licensed by them under the MIT license, a copy of their license is in [LICENSE](./LICENSE).
The original source code can be found at [https://github.com/mattcurrie/mealybug-tearoom-tests](https://github.com/mattcurrie/mealybug-tearoom-tests).