chore: extract core emulator to own crate, add actions for testing
This commit is contained in:
parent
dff765a38c
commit
984ead01eb
31 changed files with 85 additions and 26 deletions
42
.github/workflows/action.yml
vendored
Normal file
42
.github/workflows/action.yml
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main_test:
|
||||||
|
name: Test changes to main
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install toolchain
|
||||||
|
run: curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain stable -y && echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Run cargo tests (meowgb-core)
|
||||||
|
run: cargo test -p meowgb-core
|
||||||
|
|
||||||
|
- name: Run test ROM (blargg cpu_instrs)
|
||||||
|
if: always()
|
||||||
|
run: cargo run --bin meowgb-tests --release -- test-roms/blargg/roms/cpu_instrs.gb test -m 100000000 -s meowgb-tests/expected_output/cpu_instrs.bin
|
||||||
|
|
||||||
|
- name: Run test ROM (blargg instr_timing)
|
||||||
|
if: always()
|
||||||
|
run: cargo run --bin meowgb-tests --release -- test-roms/blargg/roms/instr_timing.gb test -m 100000000 -s meowgb-tests/expected_output/instr_timing.bin
|
||||||
|
|
||||||
|
- name: Run test ROM (mealybug-tearoom-tests intr_1_2_timing)
|
||||||
|
if: always()
|
||||||
|
run: cargo run --bin meowgb-tests --release -- test-roms/mealybug-tearoom-tests/roms/intr_1_2_timing-GS.gb test -m 100000000 -s meowgb-tests/expected_output/intr_1_2_timing-GS.bin
|
||||||
|
|
||||||
|
- name: Run test ROM (mealybug-tearoom-tests intr_2_0_timing)
|
||||||
|
if: always()
|
||||||
|
run: cargo run --bin meowgb-tests --release -- test-roms/mealybug-tearoom-tests/roms/intr_2_0_timing.gb test -m 100000000 -s meowgb-tests/expected_output/intr_2_0_timing.bin
|
||||||
|
|
||||||
|
- name: Run test ROM (mealybug-tearoom-tests stat_lyc_onoff)
|
||||||
|
if: always()
|
||||||
|
run: cargo run --bin meowgb-tests --release -- test-roms/mealybug-tearoom-tests/roms/stat_lyc_onoff.gb test -m 100000000 -s meowgb-tests/expected_output/stat_lyc_onoff.bin
|
||||||
|
|
||||||
|
- name: Run test ROM (mealybug-tearoom-tests stat_irq_blocking)
|
||||||
|
if: always()
|
||||||
|
run: cargo run --bin meowgb-tests --release -- test-roms/mealybug-tearoom-tests/roms/stat_irq_blocking.gb test -m 100000000 -s meowgb-tests/expected_output/stat_irq_blocking.bin
|
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -1063,22 +1063,32 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||||
name = "meowgb"
|
name = "meowgb"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bmp",
|
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"config",
|
"config",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"log",
|
"log",
|
||||||
"meowgb-opcode",
|
"meowgb-core",
|
||||||
"paste",
|
|
||||||
"pixels",
|
"pixels",
|
||||||
"serde",
|
"serde",
|
||||||
"sha1",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"winit",
|
"winit",
|
||||||
"winit_input_helper",
|
"winit_input_helper",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "meowgb-core"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bmp",
|
||||||
|
"chrono",
|
||||||
|
"log",
|
||||||
|
"meowgb-opcode",
|
||||||
|
"paste",
|
||||||
|
"sha1",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "meowgb-opcode"
|
name = "meowgb-opcode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -1094,7 +1104,7 @@ name = "meowgb-tests"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"meowgb",
|
"meowgb-core",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["meowgb", "meowgb-opcode", "meowgb-tests"]
|
members = ["meowgb", "meowgb-core", "meowgb-opcode", "meowgb-tests"]
|
||||||
|
|
15
meowgb-core/Cargo.toml
Normal file
15
meowgb-core/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[package]
|
||||||
|
name = "meowgb-core"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
log = "0.4.14"
|
||||||
|
paste = "1.0.6"
|
||||||
|
meowgb-opcode = { path = "../meowgb-opcode" }
|
||||||
|
bmp = "0.5.0"
|
||||||
|
chrono = "0.4.19"
|
||||||
|
thiserror = "1.0.30"
|
||||||
|
sha1 = { version = "0.10.6", features = ["std"] }
|
|
@ -1,12 +1,8 @@
|
||||||
use std::io::Stdout;
|
|
||||||
|
|
||||||
pub mod gameboy;
|
pub mod gameboy;
|
||||||
#[allow(unused)]
|
|
||||||
mod settings;
|
|
||||||
|
|
||||||
pub fn setup_test_emulator<const ROM_LENGTH: usize>(
|
pub fn setup_test_emulator<const ROM_LENGTH: usize>(
|
||||||
test_opcodes: [u8; ROM_LENGTH],
|
test_opcodes: [u8; ROM_LENGTH],
|
||||||
) -> gameboy::Gameboy<Stdout> {
|
) -> gameboy::Gameboy<std::io::Stdout> {
|
||||||
let mut gameboy = gameboy::Gameboy::new(None, std::io::stdout());
|
let mut gameboy = gameboy::Gameboy::new(None, std::io::stdout());
|
||||||
|
|
||||||
let mut cartridge = gameboy::mapper::NoMBC { rom: [0u8; 0x8000], ram: None };
|
let mut cartridge = gameboy::mapper::NoMBC { rom: [0u8; 0x8000], ram: None };
|
|
@ -1,4 +1,4 @@
|
||||||
use meowgb::setup_test_emulator;
|
use meowgb_core::setup_test_emulator;
|
||||||
|
|
||||||
macro_rules! conditional_jump_relative_testgen {
|
macro_rules! conditional_jump_relative_testgen {
|
||||||
($flag:ident, $not_opcode:literal, $opcode:literal) => {
|
($flag:ident, $not_opcode:literal, $opcode:literal) => {
|
|
@ -1,4 +1,4 @@
|
||||||
use meowgb::setup_test_emulator;
|
use meowgb_core::setup_test_emulator;
|
||||||
|
|
||||||
macro_rules! ld_reg_imm_u16_testgen {
|
macro_rules! ld_reg_imm_u16_testgen {
|
||||||
($hireg:ident, $loreg:ident, $opcode:literal) => {
|
($hireg:ident, $loreg:ident, $opcode:literal) => {
|
|
@ -1,4 +1,4 @@
|
||||||
use meowgb::setup_test_emulator;
|
use meowgb_core::setup_test_emulator;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nop() {
|
fn test_nop() {
|
|
@ -7,5 +7,5 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.4.12", features = ["derive"] }
|
clap = { version = "4.4.12", features = ["derive"] }
|
||||||
meowgb = { path = "../meowgb" }
|
meowgb-core = { path = "../meowgb-core" }
|
||||||
thiserror = "1.0.56"
|
thiserror = "1.0.56"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{path::{PathBuf, Path}, sync::{RwLock, Arc}, time::{Duration, Instant}};
|
use std::{path::{PathBuf, Path}, sync::{RwLock, Arc}, time::{Duration, Instant}};
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use meowgb::gameboy::{Gameboy, serial::SerialWriter};
|
use meowgb_core::gameboy::{Gameboy, serial::SerialWriter};
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
/// DMG Emulator
|
/// DMG Emulator
|
||||||
|
|
|
@ -6,17 +6,14 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bmp = "0.5.0"
|
meowgb-core = { path = "../meowgb-core" }
|
||||||
chrono = "0.4.19"
|
|
||||||
clap = { version = "4.4.12", features = ["derive"] }
|
clap = { version = "4.4.12", features = ["derive"] }
|
||||||
config = "0.13.4"
|
config = "0.13.4"
|
||||||
meowgb-opcode = { path = "../meowgb-opcode" }
|
|
||||||
env_logger = "0.10.1"
|
env_logger = "0.10.1"
|
||||||
log = "0.4.14"
|
|
||||||
paste = "1.0.6"
|
|
||||||
pixels = "0.13.0"
|
pixels = "0.13.0"
|
||||||
serde = { version = "1.0.130", features = ["derive"] }
|
serde = { version = "1.0.130", features = ["derive"] }
|
||||||
sha1 = { version = "0.10.6", features = ["std"] }
|
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
winit = { version = "0.29.7", default-features = false, features = ["serde", "rwh_05"] }
|
winit = { version = "0.29.7", default-features = false, features = ["serde", "rwh_05"] }
|
||||||
winit_input_helper = "0.15.1"
|
winit_input_helper = "0.15.1"
|
||||||
|
chrono = "0.4.31"
|
||||||
|
log = "0.4.20"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
mod gameboy;
|
|
||||||
mod settings;
|
mod settings;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
|
@ -10,7 +9,7 @@ use std::{
|
||||||
|
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use gameboy::{Gameboy, bootrom::{BootromParseError, verify_parse_bootrom}};
|
use meowgb_core::gameboy::{Gameboy, bootrom::{BootromParseError, verify_parse_bootrom}};
|
||||||
use settings::DeemgeeConfig;
|
use settings::DeemgeeConfig;
|
||||||
use window::EmulatorWindowEvent;
|
use window::EmulatorWindowEvent;
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,8 @@ pub fn run_window(
|
||||||
let window_size = window.inner_size();
|
let window_size = window.inner_size();
|
||||||
let surface_texture = SurfaceTexture::new(window_size.width, window_size.height, &window);
|
let surface_texture = SurfaceTexture::new(window_size.width, window_size.height, &window);
|
||||||
Pixels::new(
|
Pixels::new(
|
||||||
crate::gameboy::ppu::FB_WIDTH,
|
meowgb_core::gameboy::ppu::FB_WIDTH,
|
||||||
crate::gameboy::ppu::FB_HEIGHT,
|
meowgb_core::gameboy::ppu::FB_HEIGHT,
|
||||||
surface_texture,
|
surface_texture,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Reference in a new issue