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
5f5ac9f3
Verified
Commit
5f5ac9f3
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: made constructor for state
parent
ce55d76c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/sdl/src/main.rs
+27
-23
27 additions, 23 deletions
examples/sdl/src/main.rs
with
27 additions
and
23 deletions
examples/sdl/src/main.rs
+
27
−
23
View file @
5f5ac9f3
...
...
@@ -116,6 +116,32 @@ pub struct State {
}
impl
State
{
pub
fn
new
(
system
:
Box
<
dyn
Chip8
>
)
->
State
{
State
{
system
:
system
,
logic_frequency
:
LOGIC_HZ
,
visual_frequency
:
VISUAL_HZ
,
idle_frequency
:
IDLE_HZ
,
timer_frequency
:
TIMER_HZ
,
screen_scale
:
SCREEN_SCALE
,
beep_duration
:
BEEP_DURATION
,
next_tick_time
:
0.0
,
next_tick_time_i
:
0
,
beep_ticks
:
0
,
frame_count
:
0
,
frame_start
:
0
,
fps
:
0
,
pixel_color
:
COLORS
[
0
],
background_color
:
BACKGROUNDS
[
0
],
diag_color
:
COLORS
[
1
],
pixel_color_index
:
0
,
title
:
String
::
from
(
TITLE_INITIAL
),
rom_name
:
String
::
from
(
"unloaded"
),
rom_loaded
:
false
,
diag
:
false
,
}
}
pub
fn
set_title
(
&
mut
self
,
title
:
&
String
)
{
self
.title
=
title
.to_string
();
}
...
...
@@ -140,29 +166,7 @@ fn main() {
// builds the CHIP-8 machine, this is the instance that
// is going to logically represent the CHIP-8
let
mut
state
=
State
{
system
:
system
,
logic_frequency
:
LOGIC_HZ
,
visual_frequency
:
VISUAL_HZ
,
idle_frequency
:
IDLE_HZ
,
timer_frequency
:
TIMER_HZ
,
screen_scale
:
SCREEN_SCALE
,
beep_duration
:
BEEP_DURATION
,
next_tick_time
:
0.0
,
next_tick_time_i
:
0
,
beep_ticks
:
0
,
frame_count
:
0
,
frame_start
:
0
,
fps
:
0
,
pixel_color
:
COLORS
[
0
],
background_color
:
BACKGROUNDS
[
0
],
diag_color
:
COLORS
[
1
],
pixel_color_index
:
0
,
title
:
String
::
from
(
TITLE_INITIAL
),
rom_name
:
String
::
from
(
"unloaded"
),
rom_loaded
:
false
,
diag
:
false
,
};
let
mut
state
=
State
::
new
(
system
);
// initializes the SDL sub-system
let
sdl
=
sdl2
::
init
()
.unwrap
();
...
...
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