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
957262ff
Verified
Commit
957262ff
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: reset support for SDL frontend
parent
442576f2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontends/sdl/src/main.rs
+18
-4
18 additions, 4 deletions
frontends/sdl/src/main.rs
with
18 additions
and
4 deletions
frontends/sdl/src/main.rs
+
18
−
4
View file @
957262ff
...
...
@@ -47,6 +47,7 @@ pub struct Emulator {
graphics
:
Option
<
Graphics
>
,
audio
:
Option
<
Audio
>
,
title
:
&
'static
str
,
rom_path
:
String
,
logic_frequency
:
u32
,
visual_frequency
:
f32
,
next_tick_time
:
f32
,
...
...
@@ -63,6 +64,7 @@ impl Emulator {
graphics
:
None
,
audio
:
None
,
title
:
TITLE
,
rom_path
:
String
::
from
(
"invalid"
),
logic_frequency
:
GameBoy
::
CPU_FREQ
,
visual_frequency
:
GameBoy
::
VISUAL_FREQ
,
next_tick_time
:
0.0
,
...
...
@@ -163,8 +165,9 @@ impl Emulator {
self
.audio
=
Some
(
Audio
::
new
(
sdl
));
}
pub
fn
load_rom
(
&
mut
self
,
path
:
&
str
)
{
let
rom
=
self
.system
.load_rom_file
(
path
);
pub
fn
load_rom
(
&
mut
self
,
path
:
Option
<&
str
>
)
{
let
path_res
=
path
.unwrap_or
(
&
self
.rom_path
);
let
rom
=
self
.system
.load_rom_file
(
path_res
);
println!
(
"========= Cartridge =========
\n
{}
\n
============================="
,
rom
...
...
@@ -175,6 +178,13 @@ impl Emulator {
.window_mut
()
.set_title
(
format!
(
"{} [{}]"
,
self
.title
,
rom
.title
())
.as_str
())
.unwrap
();
self
.rom_path
=
String
::
from
(
path_res
);
}
pub
fn
reset
(
&
mut
self
)
{
self
.system
.reset
();
self
.system
.load_boot_default
();
self
.load_rom
(
None
);
}
pub
fn
benchmark
(
&
mut
self
,
params
:
Benchmark
)
{
...
...
@@ -262,6 +272,10 @@ impl Emulator {
keycode
:
Some
(
Keycode
::
Escape
),
..
}
=>
break
'main
,
Event
::
KeyDown
{
keycode
:
Some
(
Keycode
::
R
),
..
}
=>
self
.reset
(),
Event
::
KeyDown
{
keycode
:
Some
(
Keycode
::
B
),
..
...
...
@@ -301,7 +315,7 @@ impl Emulator {
Event
::
DropFile
{
filename
,
..
}
=>
{
self
.system
.reset
();
self
.system
.load_boot_default
();
self
.load_rom
(
&
filename
);
self
.load_rom
(
Some
(
&
filename
)
)
;
}
_
=>
(),
}
...
...
@@ -437,7 +451,7 @@ fn main() {
// ROM file and starts running it
let
mut
emulator
=
Emulator
::
new
(
game_boy
);
emulator
.start
(
SCREEN_SCALE
);
emulator
.load_rom
(
"../../res/roms/pocket.gb"
);
emulator
.load_rom
(
Some
(
"../../res/roms/pocket.gb"
)
)
;
emulator
.toggle_palette
();
emulator
.run
();
}
...
...
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