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
5a08ab2d
Verified
Commit
5a08ab2d
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: support for unlimited mode
parent
12c18063
No related branches found
No related tags found
No related merge requests found
Pipeline
#2768
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontends/sdl/src/main.rs
+32
-11
32 additions, 11 deletions
frontends/sdl/src/main.rs
with
32 additions
and
11 deletions
frontends/sdl/src/main.rs
+
32
−
11
View file @
5a08ab2d
...
...
@@ -54,13 +54,15 @@ impl Default for Benchmark {
}
pub
struct
EmulatorOptions
{
auto_mode
:
bool
,
auto_mode
:
Option
<
bool
>
,
unlimited
:
Option
<
bool
>
,
features
:
Option
<
Vec
<&
'static
str
>>
,
}
pub
struct
Emulator
{
system
:
GameBoy
,
auto_mode
:
bool
,
unlimited
:
bool
,
sdl
:
Option
<
SdlSystem
>
,
audio
:
Option
<
Audio
>
,
title
:
&
'static
str
,
...
...
@@ -78,7 +80,8 @@ impl Emulator {
pub
fn
new
(
system
:
GameBoy
,
options
:
EmulatorOptions
)
->
Self
{
Self
{
system
,
auto_mode
:
options
.auto_mode
,
auto_mode
:
options
.auto_mode
.unwrap_or
(
true
),
unlimited
:
options
.unlimited
.unwrap_or
(
false
),
sdl
:
None
,
audio
:
None
,
title
:
TITLE
,
...
...
@@ -250,6 +253,10 @@ impl Emulator {
self
.palette_index
=
(
self
.palette_index
+
1
)
%
self
.palettes
.len
();
}
pub
fn
limited
(
&
self
)
->
bool
{
!
self
.unlimited
}
pub
fn
run
(
&
mut
self
)
{
// updates the icon of the window to reflect the image
// and style of the emulator
...
...
@@ -455,10 +462,15 @@ impl Emulator {
.ceil
()
as
u8
;
ticks
=
max
(
ticks
,
1
);
// updates the next update time reference to the current
// time so that it can be used from game loop control
self
.next_tick_time
+=
(
1000.0
/
self
.visual_frequency
)
*
ticks
as
f32
;
self
.next_tick_time_i
=
self
.next_tick_time
.ceil
()
as
u32
;
// in case the limited (speed) mode is set then we must calculate
// a new next tick time reference, this is required to prevent the
// machine from running too fast (eg: 50x)
if
self
.limited
()
{
// updates the next update time reference to the current
// time so that it can be used from game loop control
self
.next_tick_time
+=
(
1000.0
/
self
.visual_frequency
)
*
ticks
as
f32
;
self
.next_tick_time_i
=
self
.next_tick_time
.ceil
()
as
u32
;
}
}
let
current_time
=
self
.sdl
.as_mut
()
.unwrap
()
.timer_subsystem
.ticks
();
...
...
@@ -531,10 +543,15 @@ impl Emulator {
.ceil
()
as
u8
;
ticks
=
max
(
ticks
,
1
);
// updates the next update time reference to the current
// time so that it can be used from game loop control
self
.next_tick_time
+=
(
1000.0
/
self
.visual_frequency
)
*
ticks
as
f32
;
self
.next_tick_time_i
=
self
.next_tick_time
.ceil
()
as
u32
;
// in case the limited (speed) mode is set then we must calculate
// a new next tick time reference, this is required to prevent the
// machine from running too fast (eg: 50x)
if
self
.limited
()
{
// updates the next update time reference to the current
// time so that it can be used from game loop control
self
.next_tick_time
+=
(
1000.0
/
self
.visual_frequency
)
*
ticks
as
f32
;
self
.next_tick_time_i
=
self
.next_tick_time
.ceil
()
as
u32
;
}
}
let
current_time
=
reference
.elapsed
()
.as_millis
()
as
u32
;
...
...
@@ -569,6 +586,9 @@ struct Args {
#[arg(long,
default_value_t
=
false
)]
headless
:
bool
,
#[arg(long,
default_value_t
=
false
)]
unlimited
:
bool
,
#[arg(short,
long,
default_value_t
=
String::from(
"../../res/roms/demo/pocket.gb"
))]
rom_path
:
String
,
}
...
...
@@ -602,7 +622,8 @@ fn main() {
// both the video and audio sub-systems, loads default
// ROM file and starts running it
let
options
=
EmulatorOptions
{
auto_mode
,
auto_mode
:
Some
(
auto_mode
),
unlimited
:
Some
(
args
.unlimited
),
features
:
if
args
.headless
{
Some
(
vec!
[])
}
else
{
...
...
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