Skip to content

Commit

Permalink
chore: adds clocks_cycles() to py interface
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jul 15, 2024
1 parent 8f93571 commit 499049f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ impl GameBoy {
self.system.clocks(count)
}

pub fn clocks_cycles(&mut self, limit: usize) -> u64 {
self.system.clocks_cycles(limit)
}

pub fn next_frame(&mut self) -> u32 {
self.system.next_frame()
}
Expand Down Expand Up @@ -162,6 +166,10 @@ impl GameBoy {
self.system.clock_freq_s()
}

pub fn boot_rom_s(&self) -> String {
self.system.boot_rom_s()
}

pub fn timer_div(&self) -> u8 {
self.system.timer_i().div()
}
Expand Down
2 changes: 2 additions & 0 deletions src/python/boytacean/boytacean.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class GameBoy:
def clock_many(self, count: int) -> int: ...
def clock_step(self, addr: int) -> int: ...
def clocks(self, count: int) -> int: ...
def clocks_cycles(self, limit: int) -> int: ...
def next_frame(self) -> int: ...
def step_to(self, addr: int) -> int: ...
def key_press(self, key: int): ...
Expand All @@ -45,6 +46,7 @@ class GameBoy:
def rom_title(self) -> str: ...
def version(self) -> str: ...
def clock_freq_s(self) -> str: ...
def boot_rom_s(self) -> str: ...
def timer_div(self) -> int: ...
def set_timer_div(self, value: int): ...
def save_state(self) -> bytes: ...
Expand Down
16 changes: 12 additions & 4 deletions src/python/boytacean/gb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ def _repr_markdown_(self) -> str:
# Boytacean
This is a [Game Boy](https://en.wikipedia.org/wiki/Game_Boy) emulator built using the [Rust Programming Language](https://www.rust-lang.org) and is running inside this browser with the help of [WebAssembly](https://webassembly.org).
| Field | Value |
| ------- | ------------------- |
| Version | {self.version} |
| Clock | {self.clock_freq_s} |
| Field | Value |
| ---------- | ------------------- |
| Version | {self.version} |
| Boot ROM | {self.boot_rom_s} |
| Clock | {self.clock_freq_s} |
"""

def boot(self):
Expand Down Expand Up @@ -111,6 +112,9 @@ def clock_step(self, addr: int) -> int:
def clocks(self, count: int) -> int:
return self._system.clocks(count)

def clocks_cycles(self, limit: int) -> int:
return self._system.clocks_cycles(limit)

def next_frame(self) -> int:
cycles = self._system.next_frame()
self._frame_index += 1
Expand Down Expand Up @@ -226,6 +230,10 @@ def version(self) -> str:
def clock_freq_s(self) -> str:
return self._system.clock_freq_s()

@property
def boot_rom_s(self) -> str:
return self._system.boot_rom_s()

@property
def timer_div(self) -> int:
return self._system.timer_div()
Expand Down

0 comments on commit 499049f

Please sign in to comment.