Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
2c2c committed Jul 17, 2024
1 parent fff9fc4 commit 7998626
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ EpicLog*
notes*
Blarg*
games

DUMP*
emutrace*
3 changes: 2 additions & 1 deletion src/cpu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,7 @@ pub const CPU = struct {
return false;
}
pub fn step(self: *CPU) u64 {
log.debug("step: {}\n", .{self.pc});
self.pending_t_cycles = 0;
var frame_cycles: u64 = 0;
var current_cycles = self.clock.t_cycles;
Expand All @@ -2030,7 +2031,6 @@ pub const CPU = struct {
self.pending_t_cycles = 0;
current_cycles = self.clock.t_cycles;

// gameboy_doctor_print(self);
beeg_print(self);
if (self.halt_state == HaltState.SwitchedOn or self.halt_state == HaltState.Enabled) {
self.halt_state = HaltState.Enabled;
Expand Down Expand Up @@ -2688,6 +2688,7 @@ fn beeg_print(self: *CPU) void {
// return;
// }
log.debug("A: {X:0>2} F: {X:0>2} B: {X:0>2} C: {X:0>2} D: {X:0>2} E: {X:0>2} H: {X:0>2} L: {X:0>2} SP: {X:0>4} PC: 00:{X:0>4} ({X:0>2} {X:0>2} {X:0>2} {X:0>2})\n", .{
// std.debug.print("A: {X:0>2} F: {X:0>2} B: {X:0>2} C: {X:0>2} D: {X:0>2} E: {X:0>2} H: {X:0>2} L: {X:0>2} SP: {X:0>4} PC: 00:{X:0>4} ({X:0>2} {X:0>2} {X:0>2} {X:0>2})\n", .{
self.registers.A,
@as(u8, @bitCast(self.registers.F)),
self.registers.B,
Expand Down
5 changes: 1 addition & 4 deletions src/gameboy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ pub const Gameboy = struct {

pub fn frame(self: *Gameboy) void {
const cycles_per_frame = CPU_SPEED_HZ / 60;
// const hz_60_nanos: u64 = std.time.ns_per_s / 60;
// _ = hz_60_nanos; // autofix
// var timer = try std.time.Timer.start();
// _ = timer; // autofix
var frame_cycles: u64 = 0;
// std.debug.print("joyp state: 0b{b:0>8}\n", .{@as(u8, @bitCast(self.bus.joypad.joyp))});

Expand All @@ -99,6 +95,7 @@ pub const Gameboy = struct {

// std.debug.print("gb.timer {} gb.bus.timer {}\n", .{ self.timer.tac, self.memory_bus.timer.tac });
self.memory_bus.update_if_flags(interrupt_flags);
std.time.sleep(500);
}

// need to track unspent cycles in CPU
Expand Down
14 changes: 7 additions & 7 deletions src/gpu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ pub const GPU = struct {
self.stat.ppu_mode = 0b00;
self.render_scanline();

// log.debug("scx {} scy {} ly {} wx {} wy {}\n", .{
// self.background_viewport.scx,
// self.background_viewport.scy,
// self.ly,
// self.window_position.wx,
// self.window_position.wy,
// });
log.debug("scx {} scy {} ly {} wx {} wy {}\n", .{
self.background_viewport.scx,
self.background_viewport.scy,
self.ly,
self.window_position.wx,
self.window_position.wy,
});

// log.debug("BGP 0b{b:0>8} OBP0 0b{b:0>8} OBP1 0b{b:0>8}\n", .{
// @as(u8, @bitCast(self.bgp)),
Expand Down
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub const std_options: std.Options = .{
.log_level = std.log.Level.info,
.log_scope_levels = &[_]std.log.ScopeLevel{
.{ .scope = .gb, .level = .info },
.{ .scope = .cpu, .level = .info },
.{ .scope = .gpu, .level = .debug },
.{ .scope = .cpu, .level = .debug },
.{ .scope = .gpu, .level = .info },
.{ .scope = .mbc, .level = .info },
.{ .scope = .timer, .level = .info },
.{ .scope = .joy, .level = .info },
Expand Down

0 comments on commit 7998626

Please sign in to comment.