Compare commits
No commits in common. "6a6dccf4d82f25cb43bbffe11a1f96a0fa37507b" and "19359f7ee417051a747aa75e8693660c51fa2746" have entirely different histories.
6a6dccf4d8
...
19359f7ee4
|
@ -16,7 +16,6 @@ const gba_height = @import("ppu.zig").height;
|
||||||
const buf_pitch = @import("ppu.zig").buf_pitch;
|
const buf_pitch = @import("ppu.zig").buf_pitch;
|
||||||
|
|
||||||
pub const enable_logging: bool = false;
|
pub const enable_logging: bool = false;
|
||||||
const is_binary: bool = false;
|
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
// Allocator for Emulator + CLI
|
// Allocator for Emulator + CLI
|
||||||
|
@ -49,6 +48,7 @@ pub fn main() anyerror!void {
|
||||||
cpu.fastBoot();
|
cpu.fastBoot();
|
||||||
|
|
||||||
if (enable_logging) {
|
if (enable_logging) {
|
||||||
|
const is_binary: bool = true;
|
||||||
const file_name = if (is_binary) "zba.bin" else "zba.log";
|
const file_name = if (is_binary) "zba.bin" else "zba.log";
|
||||||
|
|
||||||
const file = try std.fs.cwd().createFile(file_name, .{ .read = true });
|
const file = try std.fs.cwd().createFile(file_name, .{ .read = true });
|
||||||
|
|
|
@ -36,26 +36,26 @@ pub const Scheduler = struct {
|
||||||
std.debug.panic("[Scheduler] Somehow, a u64 overflowed", .{});
|
std.debug.panic("[Scheduler] Somehow, a u64 overflowed", .{});
|
||||||
},
|
},
|
||||||
.HBlank => {
|
.HBlank => {
|
||||||
// The End of a Hblank (During Draw or Vblank)
|
// The End of a Hblank
|
||||||
const old_scanline = bus.io.vcount.scanline.read();
|
const scanline = bus.io.vcount.scanline.read();
|
||||||
const scanline = (old_scanline + 1) % 228;
|
const new_scanline = scanline + 1;
|
||||||
|
|
||||||
bus.io.vcount.scanline.write(scanline);
|
// TODO: Should this be done @ end of Draw instead of end of Hblank?
|
||||||
bus.io.dispstat.hblank.unset();
|
bus.ppu.drawScanline(&bus.io);
|
||||||
|
|
||||||
if (scanline < 160) {
|
bus.io.vcount.scanline.write(new_scanline);
|
||||||
|
|
||||||
|
if (new_scanline < 160) {
|
||||||
// Transitioning to another Draw
|
// Transitioning to another Draw
|
||||||
self.push(.Draw, self.tick + (240 * 4));
|
self.push(.Draw, self.tick + (240 * 4));
|
||||||
} else {
|
} else {
|
||||||
// Transitioning to a Vblank
|
// Transitioning to a Vblank
|
||||||
if (scanline < 227) bus.io.dispstat.vblank.set() else bus.io.dispstat.vblank.unset();
|
bus.io.dispstat.vblank.set();
|
||||||
|
self.push(.VBlank, self.tick + (308 * 4));
|
||||||
self.push(.VBlank, self.tick + (240 * 4));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.Draw => {
|
.Draw => {
|
||||||
// The end of a Draw
|
// The end of a Draw
|
||||||
bus.ppu.drawScanline(&bus.io);
|
|
||||||
|
|
||||||
// Transitioning to a Hblank
|
// Transitioning to a Hblank
|
||||||
bus.io.dispstat.hblank.set();
|
bus.io.dispstat.hblank.set();
|
||||||
|
@ -63,7 +63,23 @@ pub const Scheduler = struct {
|
||||||
},
|
},
|
||||||
.VBlank => {
|
.VBlank => {
|
||||||
// The end of a Vblank
|
// The end of a Vblank
|
||||||
self.push(.HBlank, self.tick + (68 * 4));
|
|
||||||
|
const scanline = bus.io.vcount.scanline.read();
|
||||||
|
const new_scanline = scanline + 1;
|
||||||
|
bus.io.vcount.scanline.write(new_scanline);
|
||||||
|
|
||||||
|
if (new_scanline == 227) bus.io.dispstat.vblank.unset();
|
||||||
|
|
||||||
|
if (new_scanline < 228) {
|
||||||
|
// Transition to another Vblank
|
||||||
|
self.push(.VBlank, self.tick + (308 * 4));
|
||||||
|
} else {
|
||||||
|
// Transition to another Draw
|
||||||
|
bus.io.vcount.scanline.write(0); // Reset Scanline
|
||||||
|
|
||||||
|
// DISPSTAT was disabled on scanline 227
|
||||||
|
self.push(.Draw, self.tick + (240 * 4));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue