Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
b0c52823
Verified
Commit
b0c52823
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: new game boy API
parent
b2087d21
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/sdl/src/main.rs
+8
-1
8 additions, 1 deletion
examples/sdl/src/main.rs
src/cpu.rs
+4
-4
4 additions, 4 deletions
src/cpu.rs
src/gb.rs
+5
-1
5 additions, 1 deletion
src/gb.rs
src/ppu.rs
+2
-2
2 additions, 2 deletions
src/ppu.rs
with
19 additions
and
8 deletions
examples/sdl/src/main.rs
+
8
−
1
View file @
b0c52823
...
...
@@ -5,7 +5,14 @@ fn main() {
game_boy
.load_boot_default
();
for
i
in
0
..
37000
{
game_boy
.clock
();
// runs the CPU clock and determines the number of
// cycles that have advanced for that clock tick
let
cycles
=
game_boy
.clock
();
// calls the clock in the PPU to update its own
// execution lifecycle by one set of ticks
game_boy
.ppu_clock
(
cycles
);
if
game_boy
.cpu
()
.pc
()
>=
0x6032
{
println!
(
"{}"
,
i
);
break
;
...
...
This diff is collapsed.
Click to expand it.
src/cpu.rs
+
4
−
4
View file @
b0c52823
...
...
@@ -506,7 +506,7 @@ impl Cpu {
}
}
pub
fn
clock
(
&
mut
self
)
{
pub
fn
clock
(
&
mut
self
)
->
u8
{
let
pc
=
self
.pc
;
// fetches the current instruction and increments
...
...
@@ -535,9 +535,9 @@ impl Cpu {
instruction_fn
(
self
);
self
.ticks
=
self
.ticks
.wrapping_add
(
*
instruction_time
as
u32
);
//
calls the clock in the PPU to update its ow
n
//
execution lifecycle by one set of ticks
self
.ppu
()
.clock
(
*
instruction_time
);
//
returns the number of cycles that the operatio
n
//
that has been executed has taken
*
instruction_time
}
#[inline(always)]
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
5
−
1
View file @
b0c52823
...
...
@@ -12,10 +12,14 @@ impl GameBoy {
GameBoy
{
cpu
:
cpu
}
}
pub
fn
clock
(
&
mut
self
)
{
pub
fn
clock
(
&
mut
self
)
->
u8
{
self
.cpu
.clock
()
}
pub
fn
ppu_clock
(
&
mut
self
,
cycles
:
u8
)
{
self
.ppu
()
.clock
(
cycles
)
}
pub
fn
cpu
(
&
mut
self
)
->
&
mut
Cpu
{
&
mut
self
.cpu
}
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
2
−
2
View file @
b0c52823
...
...
@@ -88,8 +88,8 @@ impl Ppu {
}
}
pub
fn
clock
(
&
mut
self
,
tick
s
:
u8
)
{
self
.mode_clock
+=
tick
s
as
u16
;
pub
fn
clock
(
&
mut
self
,
cycle
s
:
u8
)
{
self
.mode_clock
+=
cycle
s
as
u16
;
match
self
.mode
{
PpuMode
::
OamRead
=>
{
if
self
.mode_clock
>=
204
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment