Skip to content
Snippets Groups Projects
Verified Commit b45f4b9d authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: support for next_frame()

Allowing frame by frame "navigation".
parent 4cf7c444
No related branches found
No related tags found
1 merge request!36Support for Python
Pipeline #3598 passed
This commit is part of merge request !36. Comments created here will be created in the context of that merge request.
......@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
*
* Support for Python 3 API - [#36](https://gitlab.stage.hive.pt/joamag/boytacean/-/issues/36)
* `next_frame()` method for frame by frame navigation
### Changed
......
......@@ -3,5 +3,6 @@ import boytacean
gb = boytacean.GameBoy()
gb.load()
gb.load_rom("../../res/roms/demo/pocket.gb")
gb.clocks(10000000)
for _ in range(6000):
gb.next_frame()
gb.save_image("pocket.png")
......@@ -487,6 +487,18 @@ impl GameBoy {
cycles
}
pub fn next_frame(&mut self) -> u32 {
let mut cycles = 0u32;
let current_frame = self.ppu_frame();
loop {
cycles += self.clock() as u32;
if self.ppu_frame() != current_frame {
break;
}
}
cycles
}
pub fn key_press(&mut self, key: PadKey) {
self.pad().key_press(key);
}
......
......@@ -43,6 +43,10 @@ impl GameBoy {
self.system.clocks(count)
}
pub fn next_frame(&mut self) -> u32 {
self.system.next_frame()
}
pub fn frame_buffer(&mut self, py: Python) -> PyObject {
let pybytes = PyBytes::new(py, self.system.frame_buffer());
pybytes.into()
......
......@@ -23,6 +23,9 @@ class GameBoy:
def clocks(self, count: int) -> int:
return self._system.clocks(count)
def next_frame(self) -> int:
return self._system.next_frame()
def frame_buffer(self):
return self._system.frame_buffer()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment