Skip to content

Commit

Permalink
Rename frame() to advance_frame()
Browse files Browse the repository at this point in the history
and slightly refactor its usage in the GUI
  • Loading branch information
diogotito committed Mar 25, 2024
1 parent d9f57c5 commit 3b67d3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions fpt-egui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl FPT {
if self.cycles_since_last_frame == self.gb.borrow().cycles_in_one_frame() {
let gb = self.gb.borrow();
frame = Some(*gb.get_frame()); // Copies the whole [u8; WIDTH * HEIGHT] into frame

self.gb_frame_count += 1;
self.cycles_since_last_frame = 0;
}
Expand All @@ -178,11 +177,9 @@ impl FPT {
self.gb_frame_count += 1;
self.cycles_since_last_frame = 0;
self.total_cycles += 70224;
self.gb.borrow_mut().frame();

let gb = self.gb.borrow();
let frame = gb.get_frame();

// Run for a whole frame and decode the resulting picture into our GUI's image
let mut gb = self.gb.borrow_mut();
let frame = gb.advance_frame();
for (i, &gb_pixel) in frame.iter().enumerate() {
self.image.pixels[i] = PALETTE[gb_pixel as usize];
}
Expand Down
2 changes: 1 addition & 1 deletion fpt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Gameboy {
cycles
}

pub fn frame(&mut self) -> &Frame {
pub fn advance_frame(&mut self) -> &Frame {
for _ in 0..DOTS_IN_ONE_FRAME {
// TODO: care for double speed mode (need to run two cpu t_cycles)
self.cpu.t_cycle();
Expand Down

0 comments on commit 3b67d3e

Please sign in to comment.