cgb colour palettes work
This commit is contained in:
parent
5039b19222
commit
63818494b7
|
@ -456,11 +456,15 @@ where
|
|||
let lsb = get_bit(lsbs, x_addr);
|
||||
let msb = get_bit(msbs, x_addr);
|
||||
// maybe have to change this for cgb mode
|
||||
let (colour, is_zero) = match object.flags.dmg_palette {
|
||||
ObjPalette::Zero => self.obj_palette_0,
|
||||
ObjPalette::One => self.obj_palette_1,
|
||||
}
|
||||
.map_bits(lsb, msb);
|
||||
let (colour, is_zero) = if self.is_cgb_mode() {
|
||||
(ColourInner::from_bits(lsb, msb), !lsb && !msb)
|
||||
} else {
|
||||
match object.flags.dmg_palette {
|
||||
ObjPalette::Zero => self.obj_palette_0,
|
||||
ObjPalette::One => self.obj_palette_1,
|
||||
}
|
||||
.map_bits(lsb, msb)
|
||||
};
|
||||
if is_zero {
|
||||
continue;
|
||||
}
|
||||
|
@ -548,7 +552,11 @@ where
|
|||
};
|
||||
let lsb = get_bit(lsbs, 7 - tile_px_x);
|
||||
let msb = get_bit(msbs, 7 - tile_px_x);
|
||||
let (colour, is_zero) = self.bg_palette.map_bits(lsb, msb);
|
||||
let (colour, is_zero) = if self.is_cgb_mode() {
|
||||
(ColourInner::from_bits(lsb, msb), !lsb && !msb)
|
||||
} else {
|
||||
self.bg_palette.map_bits(lsb, msb)
|
||||
};
|
||||
self.is_bg_zero[x] = is_zero;
|
||||
|
||||
let cgb_data = self
|
||||
|
|
|
@ -103,10 +103,13 @@ where
|
|||
let real_px_x = (tile_x as usize * 8) + px_x as usize;
|
||||
let lsb = get_bit(lsbs, 7 - px_x);
|
||||
let msb = get_bit(msbs, 7 - px_x);
|
||||
let colour = palette.map_bits(lsb, msb);
|
||||
let colour = if is_cgb_mode {
|
||||
ColourInner::from_bits(lsb, msb)
|
||||
} else {
|
||||
palette.map_bits(lsb, msb).0
|
||||
};
|
||||
|
||||
self.sprite_buffer[real_px_x + (real_px_y * TILE_WINDOW_WIDTH)] = colour
|
||||
.0
|
||||
.rgb_bytes(cgb_data.map(|v| (v, attributes.palette)))
|
||||
.into();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue