fix trait bounds + tile window
This commit is contained in:
parent
d001e0d0e2
commit
72723edaa3
|
@ -23,7 +23,11 @@ mod types;
|
|||
const TILE_WINDOW_WIDTH: usize = 16 * 8;
|
||||
const TILE_WINDOW_HEIGHT: usize = 24 * 8;
|
||||
|
||||
pub struct Gpu<ColourFormat: From<Colour>, R: Renderer<ColourFormat>> {
|
||||
pub struct Gpu<ColourFormat, R>
|
||||
where
|
||||
ColourFormat: From<Colour> + Clone,
|
||||
R: Renderer<ColourFormat>,
|
||||
{
|
||||
pub buffer: Vec<ColourFormat>,
|
||||
pub vram: Vram,
|
||||
pub oam: Oam,
|
||||
|
@ -48,7 +52,11 @@ pub struct Gpu<ColourFormat: From<Colour>, R: Renderer<ColourFormat>> {
|
|||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct GpuSaveState<ColourFormat: From<Colour>, R: Renderer<ColourFormat>> {
|
||||
pub struct GpuSaveState<ColourFormat, R>
|
||||
where
|
||||
ColourFormat: From<Colour> + Clone,
|
||||
R: Renderer<ColourFormat>,
|
||||
{
|
||||
buffer: Vec<ColourFormat>,
|
||||
vram: Vram,
|
||||
oam: Oam,
|
||||
|
|
|
@ -8,7 +8,11 @@ use super::{
|
|||
Colour, Gpu,
|
||||
};
|
||||
|
||||
impl<Format: From<Colour>, R: Renderer<Format>> Gpu<Format, R> {
|
||||
impl<ColourFormat, R> Gpu<ColourFormat, R>
|
||||
where
|
||||
ColourFormat: From<Colour> + Clone,
|
||||
R: Renderer<ColourFormat>,
|
||||
{
|
||||
pub fn update_lcdc(&mut self, data: u8) {
|
||||
self.lcdc.enable = get_bit(data, 7);
|
||||
self.lcdc.window_tilemap = if get_bit(data, 6) {
|
||||
|
|
|
@ -6,18 +6,23 @@ use crate::{
|
|||
|
||||
use super::{types::Vram, Colour};
|
||||
|
||||
pub(super) struct TileWindow<Format: From<Colour>, R: Renderer<Format>> {
|
||||
sprite_buffer: Vec<Format>,
|
||||
pub(super) struct TileWindow<ColourFormat, R>
|
||||
where
|
||||
ColourFormat: From<Colour> + Clone,
|
||||
R: Renderer<ColourFormat>,
|
||||
{
|
||||
sprite_buffer: Vec<ColourFormat>,
|
||||
sprite_renderer: R,
|
||||
}
|
||||
|
||||
impl<Format: From<Colour>, R: Renderer<Format>> TileWindow<Format, R> {
|
||||
impl<ColourFormat, R> TileWindow<ColourFormat, R>
|
||||
where
|
||||
ColourFormat: From<Colour> + Clone,
|
||||
R: Renderer<ColourFormat>,
|
||||
{
|
||||
pub(super) fn new(window: R) -> Self {
|
||||
let mut sprite_buffer = Vec::new();
|
||||
sprite_buffer.reserve_exact(TILE_WINDOW_WIDTH * TILE_WINDOW_HEIGHT);
|
||||
|
||||
Self {
|
||||
sprite_buffer,
|
||||
sprite_buffer: vec![Colour::Error.into(); TILE_WINDOW_WIDTH * TILE_WINDOW_HEIGHT],
|
||||
sprite_renderer: window,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue