From 8c248ffb11fd54cc9d94859c28e16a4a80a4cb7d Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sun, 30 Jan 2022 02:39:16 -0400 Subject: [PATCH] chore: zero-initialize VRAM --- src/ppu.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ppu.zig b/src/ppu.zig index f480c87..53b02a5 100644 --- a/src/ppu.zig +++ b/src/ppu.zig @@ -117,8 +117,16 @@ const Vram = struct { alloc: Allocator, fn init(alloc: Allocator) !Self { + // In Modes 3 and 4, parts of the VRAM are copied to the + // frame buffer, therefore we want to zero-initialize Vram + // + // some programs like Armwrestler assume that VRAM is zeroed-out. + const black = std.mem.zeroes([0x18000]u8); + const buf = try alloc.alloc(u8, 0x18000); + std.mem.copy(u8, buf, &black); + return Self{ - .buf = try alloc.alloc(u8, 0x18000), + .buf = buf, .alloc = alloc, }; }