Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
chip-ahoyto
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
chip-ahoyto
Commits
1f3be783
Verified
Commit
1f3be783
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
fix: timer support
parent
73cb5974
No related branches found
No related tags found
No related merge requests found
Pipeline
#604
passed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/sdl/src/main.rs
+15
-2
15 additions, 2 deletions
examples/sdl/src/main.rs
src/chip8.rs
+0
-6
0 additions, 6 deletions
src/chip8.rs
src/chip8_neo.rs
+1
-1
1 addition, 1 deletion
src/chip8_neo.rs
with
16 additions
and
9 deletions
examples/sdl/src/main.rs
+
15
−
2
View file @
1f3be783
...
@@ -27,6 +27,7 @@ const COLORS: [[u8; 3]; 6] = [
...
@@ -27,6 +27,7 @@ const COLORS: [[u8; 3]; 6] = [
const
LOGIC_HZ
:
u32
=
480
;
const
LOGIC_HZ
:
u32
=
480
;
const
VISUAL_HZ
:
u32
=
60
;
const
VISUAL_HZ
:
u32
=
60
;
const
IDLE_HZ
:
u32
=
60
;
const
IDLE_HZ
:
u32
=
60
;
const
TIMER_HZ
:
u32
=
60
;
const
BEEP_DURATION
:
f32
=
0.1
;
const
BEEP_DURATION
:
f32
=
0.1
;
...
@@ -87,6 +88,7 @@ pub struct State {
...
@@ -87,6 +88,7 @@ pub struct State {
logic_frequency
:
u32
,
logic_frequency
:
u32
,
visual_frequency
:
u32
,
visual_frequency
:
u32
,
idle_frequency
:
u32
,
idle_frequency
:
u32
,
timer_frequency
:
u32
,
screen_scale
:
f32
,
screen_scale
:
f32
,
beep_duration
:
f32
,
beep_duration
:
f32
,
next_tick_time
:
u32
,
next_tick_time
:
u32
,
...
@@ -112,6 +114,7 @@ fn main() {
...
@@ -112,6 +114,7 @@ fn main() {
logic_frequency
:
LOGIC_HZ
,
logic_frequency
:
LOGIC_HZ
,
visual_frequency
:
VISUAL_HZ
,
visual_frequency
:
VISUAL_HZ
,
idle_frequency
:
IDLE_HZ
,
idle_frequency
:
IDLE_HZ
,
timer_frequency
:
TIMER_HZ
,
screen_scale
:
SCREEN_SCALE
,
screen_scale
:
SCREEN_SCALE
,
beep_duration
:
BEEP_DURATION
,
beep_duration
:
BEEP_DURATION
,
next_tick_time
:
0
,
next_tick_time
:
0
,
...
@@ -313,9 +316,19 @@ fn main() {
...
@@ -313,9 +316,19 @@ fn main() {
// to make sure that the proper number of updates are performed
// to make sure that the proper number of updates are performed
let
logic_visual_ratio
=
state
.logic_frequency
/
state
.visual_frequency
;
let
logic_visual_ratio
=
state
.logic_frequency
/
state
.visual_frequency
;
for
_
in
0
..
logic_visual_ratio
{
for
_
in
0
..
logic_visual_ratio
{
// runs the
ti
ck operation in the CHIP-8 system,
// runs the
clo
ck operation in the CHIP-8 system,
// effectively changing the logic state of the machine
// effectively changing the logic state of the machine
state
.system
.tick
();
state
.system
.clock
();
}
// calculates the ration between the timer and the visual frequency
// so that the proper timer updates are rune
let
timer_visual_ratio
=
state
.timer_frequency
/
state
.visual_frequency
;
for
_
in
0
..
timer_visual_ratio
{
// runs the clock for the timers (both sound and delay),
// after that tries to determine if a beep should be sounded
state
.system
.clock_dt
();
state
.system
.clock_st
();
beep
|
=
state
.system
.beep
();
beep
|
=
state
.system
.beep
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/chip8.rs
+
0
−
6
View file @
1f3be783
...
@@ -128,12 +128,6 @@ impl Chip8 {
...
@@ -128,12 +128,6 @@ impl Chip8 {
self
.ram
[
ROM_START
..
ROM_START
+
rom
.len
()]
.clone_from_slice
(
rom
);
self
.ram
[
ROM_START
..
ROM_START
+
rom
.len
()]
.clone_from_slice
(
rom
);
}
}
pub
fn
tick
(
&
mut
self
)
{
self
.clock
();
self
.clock_dt
();
self
.clock_st
();
}
pub
fn
clock
(
&
mut
self
)
{
pub
fn
clock
(
&
mut
self
)
{
let
opcode
=
self
.fetch_opcode
();
let
opcode
=
self
.fetch_opcode
();
self
.process_opcode
(
opcode
);
self
.process_opcode
(
opcode
);
...
...
This diff is collapsed.
Click to expand it.
src/chip8_neo.rs
+
1
−
1
View file @
1f3be783
...
@@ -5,7 +5,7 @@ pub const STACK_SIZE: usize = 16;
...
@@ -5,7 +5,7 @@ pub const STACK_SIZE: usize = 16;
pub
const
REGISTERS_SIZE
:
usize
=
16
;
pub
const
REGISTERS_SIZE
:
usize
=
16
;
/// The starting address for the ROM loading, should be
/// The starting address for the ROM loading, should be
/// the initial PC position.
/// the initial PC position
for execution
.
const
ROM_START
:
usize
=
0x200
;
const
ROM_START
:
usize
=
0x200
;
static
FONT_SET
:
[
u8
;
80
]
=
[
static
FONT_SET
:
[
u8
;
80
]
=
[
...
...
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