fix: resolve out-of-bounds error with 8bpp tall / horizontal sprites
Boot ROM is now enabled by default as well
This commit is contained in:
parent
242bf08cf2
commit
ff6d2517be
|
@ -84,7 +84,7 @@ pub fn main() anyerror!void {
|
||||||
defer cpu.deinit();
|
defer cpu.deinit();
|
||||||
|
|
||||||
cpu.bus.attach(&cpu);
|
cpu.bus.attach(&cpu);
|
||||||
cpu.fastBoot();
|
// cpu.fastBoot();
|
||||||
|
|
||||||
// Initialize SDL Audio
|
// Initialize SDL Audio
|
||||||
const audio_dev = initAudio(&cpu.bus.apu);
|
const audio_dev = initAudio(&cpu.bus.apu);
|
||||||
|
|
11
src/ppu.zig
11
src/ppu.zig
|
@ -187,14 +187,11 @@ pub const Ppu = struct {
|
||||||
// When calcualting the inital address, the first entry is always 0x20 * tile_id, even if it is 8bpp
|
// When calcualting the inital address, the first entry is always 0x20 * tile_id, even if it is 8bpp
|
||||||
const tile_base = char_base + (0x20 * @as(u32, tile_id)) + (tile_row_offset * row) + if (is_8bpp) col else col / 2;
|
const tile_base = char_base + (0x20 * @as(u32, tile_id)) + (tile_row_offset * row) + if (is_8bpp) col else col / 2;
|
||||||
|
|
||||||
// TODO: Understand more
|
// TODO: Finish that 2D Sprites Test ROM
|
||||||
var tile_offset = (tile_x / 8) * tile_len;
|
const offset_base = (tile_x / 8) * tile_len;
|
||||||
if (self.dispcnt.obj_mapping.read()) {
|
const offset_offset = (tile_y / 8) * tile_len * if (self.dispcnt.obj_mapping.read()) sprite.width / 8 else if (is_8bpp) @as(u32, 0x10) else 0x20;
|
||||||
tile_offset += (tile_y / 8) * tile_len * (sprite.width / 8); // 1D Mapping
|
|
||||||
} else {
|
|
||||||
tile_offset += (tile_y / 8) * tile_len * 0x20; // 2D Mapping
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const tile_offset = offset_base + offset_offset;
|
||||||
const tile = self.vram.buf[tile_base + tile_offset];
|
const tile = self.vram.buf[tile_base + tile_offset];
|
||||||
|
|
||||||
const pal_id: u16 = if (!is_8bpp) blk: {
|
const pal_id: u16 = if (!is_8bpp) blk: {
|
||||||
|
|
Loading…
Reference in New Issue