From 1b17b1eb0c5502177c564217e3e55011c91c8e80 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:20 -0300 Subject: [PATCH] chore: use zig slices for fun --- src/ppu.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ppu.zig b/src/ppu.zig index e72c520..05d2518 100644 --- a/src/ppu.zig +++ b/src/ppu.zig @@ -73,9 +73,7 @@ pub const Ppu = struct { }, 0x3 => { const start = framebuf_pitch * @as(usize, scanline); - const end = start + framebuf_pitch; - - std.mem.copy(u8, self.framebuf[start..end], self.vram.buf[start..end]); + std.mem.copy(u8, self.framebuf[start..][0..framebuf_pitch], self.vram.buf[start..][0..framebuf_pitch]); }, 0x4 => { const select = self.dispcnt.frame_select.read(); @@ -90,8 +88,7 @@ pub const Ppu = struct { const id = byte * 2; const j = i * @sizeOf(u16); - self.framebuf[buf_start + j + 1] = self.palette.buf[id + 1]; - self.framebuf[buf_start + j] = self.palette.buf[id]; + std.mem.copy(u8, self.framebuf[(buf_start + j)..][0..2], self.palette.buf[id..][0..2]); } }, else => std.debug.panic("[PPU] TODO: Implement BG Mode {}", .{bg_mode}),