diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..9334e895 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,44 @@ +[workspace] + +resolver = "2" + +# unfortunately we can't include 'agb' or anything which compiles to non-native code +# in the workspace here, and they need to be tracked separately. +members = [ + # "agb" + "agb-debug", + "agb-fixnum", + "agb-gbafix", + "agb-hashmap", + "agb-image-converter", + "agb-macros", + "agb-sound-converter", + + "tracker/agb-midi", + "tracker/agb-midi-core", + "tracker/agb-tracker-interop", + # "tracker/agb-tracker", + "tracker/agb-xm", + "tracker/agb-xm-core", + + "tools", + + "emulator/mgba", + "emulator/mgba-sys", + "emulator/test-runner", +] + +exclude = [ + "agb", + + "tracker/agb-tracker", + + "examples/amplitude", + "examples/combo", + "examples/hyperspace-roll", + "examples/the-dungeon-puzzlers-lament", + "examples/the-hat-chooses-the-wizard", + "examples/the-purple-night", + + "book/games/pong", +] diff --git a/emulator/Cargo.toml b/emulator/Cargo.toml deleted file mode 100644 index ac17e7bb..00000000 --- a/emulator/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[workspace] -members = [ - "mgba", - "mgba-sys", - "test-runner" -] \ No newline at end of file diff --git a/emulator/mgba/src/log.rs b/emulator/mgba/src/log.rs index 663a2421..6e7b32f7 100644 --- a/emulator/mgba/src/log.rs +++ b/emulator/mgba/src/log.rs @@ -15,7 +15,6 @@ pub enum LogLevel { Unknown, } - #[derive(Debug, Error)] #[error("A log level of {provided_log_level} does not match any known log level")] pub struct LogLevelIsNotValid { @@ -34,9 +33,11 @@ impl TryFrom for LogLevel { mgba_sys::mLogLevel_mLOG_DEBUG => LogLevel::Debug, mgba_sys::mLogLevel_mLOG_STUB => LogLevel::Stub, mgba_sys::mLogLevel_mLOG_GAME_ERROR => LogLevel::GameError, - _ => return Err(LogLevelIsNotValid { - provided_log_level: value - }) + _ => { + return Err(LogLevelIsNotValid { + provided_log_level: value, + }) + } }) } } @@ -95,7 +96,11 @@ extern "C" fn log_string_wrapper( unsafe { CStr::from_ptr(category_c_name).to_str() }.unwrap_or(UNKNOWN) }; - logger(category_name, LogLevel::try_from(level).unwrap_or(LogLevel::Unknown), s); + logger( + category_name, + LogLevel::try_from(level).unwrap_or(LogLevel::Unknown), + s, + ); } } } diff --git a/emulator/mgba/src/vfile.rs b/emulator/mgba/src/vfile.rs index 97092b3f..0a36b87a 100644 --- a/emulator/mgba/src/vfile.rs +++ b/emulator/mgba/src/vfile.rs @@ -113,14 +113,14 @@ impl VFileAlloc { } pub(crate) fn into_mgba(self) -> *mut mgba_sys::VFile { - let f = Box::into_raw(self.0) as *mut VFileInner; + let f = Box::into_raw(self.0); f.cast() } } mod vfile_extern { - use std::io::SeekFrom; use super::VFileExtensions; + use std::io::SeekFrom; /// Safety: Must be part of a VFileInner pub unsafe fn create_vfile() -> mgba_sys::VFile { diff --git a/emulator/test-runner/src/image_compare.rs b/emulator/test-runner/src/image_compare.rs index 413d2e00..13a0b027 100644 --- a/emulator/test-runner/src/image_compare.rs +++ b/emulator/test-runner/src/image_compare.rs @@ -1,20 +1,15 @@ use std::path::Path; -use image::{io::Reader, DynamicImage}; +use image::io::Reader; pub struct ComparisonResult { matches: bool, - image: DynamicImage, } impl ComparisonResult { pub fn success(&self) -> bool { self.matches } - - pub fn image(&self) -> &DynamicImage { - &self.image - } } const WIDTH: usize = 240; @@ -36,10 +31,7 @@ pub fn compare_image( let (exp_dim_x, exp_dim_y) = expected_buffer.dimensions(); if exp_dim_x != WIDTH as u32 || exp_dim_y != HEIGHT as u32 { - return Ok(ComparisonResult { - matches: false, - image: expected, - }); + return Ok(ComparisonResult { matches: false }); } for y in 0..HEIGHT { @@ -49,16 +41,10 @@ pub fn compare_image( let image_pixel = convert_rgba_to_nearest_gba_colour(image_pixel.0); if image_pixel[0..3] != video_pixel.to_le_bytes()[0..3] { - return Ok(ComparisonResult { - matches: false, - image: expected, - }); + return Ok(ComparisonResult { matches: false }); } } } - Ok(ComparisonResult { - matches: true, - image: expected, - }) + Ok(ComparisonResult { matches: true }) } diff --git a/justfile b/justfile index f04558b5..848cf761 100644 --- a/justfile +++ b/justfile @@ -11,21 +11,15 @@ build-release: just _build-release tracker/agb-tracker clippy: just _all-crates _clippy - just _clippy tools test: just _test-debug agb just _test-multiboot - just _test-debug agb-fixnum - just _test-debug agb-hashmap just _test-debug tracker/agb-tracker just _test-debug-arm agb - just _test-debug tools - just _test-debug emulator test-release: just _test-release agb - just _test-release agb-fixnum just _test-release tracker/agb-tracker just _test-release-arm agb @@ -35,8 +29,7 @@ doctest-agb: check-docs: (cd agb && cargo doc --target=thumbv4t-none-eabi --no-deps) (cd tracker/agb-tracker && cargo doc --target=thumbv4t-none-eabi --no-deps) - just _build_docs agb-fixnum - just _build_docs agb-hashmap + cargo doc --no-deps _build_docs crate: (cd "{{crate}}" && cargo doc --no-deps) @@ -46,10 +39,9 @@ clean: fmt: just _all-crates _fmt - just _fmt tools + fmt-check: just _all-crates _fmt-check - just _fmt-check tools run-example example: just _build-example "{{example}}" @@ -148,7 +140,7 @@ debug *args: (cd agb-debug && cargo build --release && cd "{{invocation_directory()}}" && "$CARGO_TARGET_DIR/release/agb-debug" {{args}}) _all-crates target: - for CARGO_PROJECT_FILE in agb-*/Cargo.toml agb/Cargo.toml tracker/agb-*/Cargo.toml; do \ + for CARGO_PROJECT_FILE in agb/Cargo.toml tracker/agb-tracker/Cargo.toml ./Cargo.toml; do \ PROJECT_DIR=$(dirname "$CARGO_PROJECT_FILE"); \ just "{{target}}" "$PROJECT_DIR" || exit $?; \ done