diff --git a/Cargo.lock b/Cargo.lock index 726452f..7000ca4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1119,7 +1119,7 @@ dependencies = [ [[package]] name = "gb-emu" -version = "0.3.2" +version = "0.3.3" dependencies = [ "clap", "cpal", @@ -1136,7 +1136,7 @@ dependencies = [ [[package]] name = "gb-emu-lib" -version = "0.3.2" +version = "0.3.3" dependencies = [ "async-ringbuf", "bytemuck", @@ -2965,7 +2965,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vst" -version = "0.3.2" +version = "0.3.3" dependencies = [ "async-ringbuf", "baseview", diff --git a/gb-emu/Cargo.toml b/gb-emu/Cargo.toml index a067414..4328272 100644 --- a/gb-emu/Cargo.toml +++ b/gb-emu/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gb-emu" -version = "0.3.2" +version = "0.3.3" edition = "2021" [features] diff --git a/gb-vst/Cargo.toml b/gb-vst/Cargo.toml index 150771f..b25ddd3 100644 --- a/gb-vst/Cargo.toml +++ b/gb-vst/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vst" -version = "0.3.2" +version = "0.3.3" edition = "2021" [lib] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index aba1e95..84d49d1 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gb-emu-lib" -version = "0.3.2" +version = "0.3.3" edition = "2021" [features] diff --git a/lib/src/constants.rs b/lib/src/constants.rs index c7d16e5..708dcd6 100644 --- a/lib/src/constants.rs +++ b/lib/src/constants.rs @@ -1,2 +1,21 @@ +use crate::connect::Colour; + // Hz pub const CLOCK_SPEED: usize = 4194304; + +pub(crate) const ERROR_COLOUR: Colour = Colour(0xFF, 0x00, 0x00); + +pub(crate) mod dmg_colours { + use crate::connect::Colour; + // validation b&w (dmg-acid2 etc.) + // pub(crate) const ZERO: Colour = Colour(0xFF, 0xFF, 0xFF); + // pub(crate) const ONE: Colour = Colour(0xAA, 0xAA, 0xAA); + // pub(crate) const TWO: Colour = Colour(0x55, 0x55, 0x55); + // pub(crate) const THREE: Colour = Colour(0x00, 0x00, 0x00); + + // from https://www.designpieces.com/palette/game-boy-original-color-palette-hex-and-rgb/ + pub(crate) const ZERO: Colour = Colour(0x9B, 0xBC, 0x0F); + pub(crate) const ONE: Colour = Colour(0x8B, 0xAC, 0x0F); + pub(crate) const TWO: Colour = Colour(0x30, 0x62, 0x30); + pub(crate) const THREE: Colour = Colour(0x0F, 0x38, 0x0F); +} diff --git a/lib/src/processor/memory/mmio/gpu/types.rs b/lib/src/processor/memory/mmio/gpu/types.rs index e7e3eb6..d7027e4 100644 --- a/lib/src/processor/memory/mmio/gpu/types.rs +++ b/lib/src/processor/memory/mmio/gpu/types.rs @@ -2,6 +2,7 @@ use bytemuck::from_bytes; use serde::{Deserialize, Serialize}; use crate::{ + constants::{dmg_colours, ERROR_COLOUR}, processor::memory::addresses::{OamAddress, VramAddress}, util::{as_signed, get_bit, SaturatingCast}, }; @@ -100,7 +101,7 @@ pub enum ColourInner { Error = 255, } -pub struct Colour(u8, u8, u8); +pub struct Colour(pub u8, pub u8, pub u8); impl From for u32 { fn from(value: Colour) -> Self { @@ -145,24 +146,24 @@ impl ColourInner { ) -> Colour { if let Some((cgb_palette, pallete_num)) = cgb_data { if *self == ColourInner::Error { - return Colour(0xFF, 0, 0); + return ERROR_COLOUR; } let offset: usize = (pallete_num as usize * 2 * 4) + (*self as usize * 2); rgb_from_bytes(*from_bytes(&cgb_palette.data[offset..=offset + 1])) } else { match self { - ColourInner::Zero => Colour(0xFF, 0xFF, 0xFF), - ColourInner::One => Colour(0xAA, 0xAA, 0xAA), - ColourInner::Two => Colour(0x55, 0x55, 0x55), - ColourInner::Three => Colour(0x00, 0x00, 0x00), + ColourInner::Zero => dmg_colours::ZERO, + ColourInner::One => dmg_colours::ONE, + ColourInner::Two => dmg_colours::TWO, + ColourInner::Three => dmg_colours::THREE, ColourInner::Error => { if cfg!(debug_assertions) { - Colour(0xFF, 0x00, 0x00) + ERROR_COLOUR } else if is_cgb_mode { rgb_from_bytes(0xFFFF) } else { - Colour(0xFF, 0xFF, 0xFF) + dmg_colours::ZERO } } }