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