chore: properly deallocate OAM buffer

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-03-22 11:41:17 -03:00
parent 5dd69500ca
commit da4bb17782
1 changed files with 5 additions and 0 deletions

View File

@ -71,6 +71,7 @@ pub const Ppu = struct {
self.alloc.free(self.framebuf); self.alloc.free(self.framebuf);
self.vram.deinit(); self.vram.deinit();
self.palette.deinit(); self.palette.deinit();
self.oam.deinit();
} }
pub fn setBgOffsets(self: *Self, comptime n: u3, word: u32) void { pub fn setBgOffsets(self: *Self, comptime n: u3, word: u32) void {
@ -517,6 +518,10 @@ const Oam = struct {
}; };
} }
fn deinit(self: Self) void {
self.alloc.free(self.buf);
}
pub fn get32(self: *const Self, idx: usize) u32 { pub fn get32(self: *const Self, idx: usize) u32 {
return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx])); return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx]));
} }