colour update
This commit is contained in:
parent
335187732a
commit
c63cff149d
6 changed files with 34 additions and 14 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gb-emu"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "vst"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gb-emu-lib"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<Colour> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue