// Renders sprites to the framebuffer using the oam table.
Renders sprites to the framebuffer using the oam table.
Renders sprites to the framebuffer using the oam table .
fn render_sprites(&self, pixels: &mut PixelData) {
        // TODO
        // Need to emulate scanline, and priority rendering
        for sprite_attributes in self.oam.chunks_exact(4) {
            if sprite_attributes.iter().all(|x| *x == 0) {
                continue;
            }
            if let [y, x, pattern, flags] = sprite_attributes {
                let flags = SpriteAttribute::from(flags);
                let idx = *pattern as usize * 16;
                let palette = if flags.obj0 {
                    self.obj0pal
                } else {
                    self.obj1pal
                };
                let tile = Tile::sprite_construct(palette, &self.vram[Tile::range(idx)]);
                let screen_x = (*x).wrapping_sub(8);
                let screen_y = (*y).wrapping_sub(16);
                self.blit_to_screen(pixels, screen_x as usize, screen_y as usize, tile);
            }
        }
    }
fn render_sprites ( & self , pixels : & mut PixelData ) { // TODO // Need to emulate scanline, and priority rendering for sprite_attributes in self . oam . chunks_exact ( 4 ) { if sprite_attributes . iter ( ) . all ( | x | * x == 0 ) { continue ; } if let [ y , x , pattern , flags ] = sprite_attributes { let flags = SpriteAttribute :: from ( flags ) ; let idx = * pattern as usize * 16 ; let palette = if flags . obj0 { self . obj0pal } else { self . obj1pal } ; let tile = Tile :: sprite_construct ( palette , & self . vram [ Tile :: range ( idx ) ] ) ; let screen_x = ( * x ) . wrapping_sub ( 8 ) ; let screen_y = ( * y ) . wrapping_sub ( 16 ) ; self . blit_to_screen ( pixels , screen_x as usize , screen_y as usize , tile ) ; } } }
Renders sprites to the framebuffer using the oam table.
Renders sprites to the framebuffer using the oam table .
&self
pixels
&mut PixelData