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
b819f6b8
Verified
Commit
b819f6b8
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: gracefull fail of default ROM loading
parent
61369b73
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3142
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontends/sdl/src/main.rs
+13
-1
13 additions, 1 deletion
frontends/sdl/src/main.rs
src/util.rs
+3
-0
3 additions, 0 deletions
src/util.rs
with
16 additions
and
1 deletion
frontends/sdl/src/main.rs
+
13
−
1
View file @
b819f6b8
...
...
@@ -43,6 +43,10 @@ const VOLUME: f32 = 64.0;
/// backed RAM is going to be stored into the file system.
const
STORE_RATE
:
u8
=
5
;
/// The path to the default ROM file that is going to be
/// loaded in case no other ROM path is provided.
const
DEFAULT_ROM_PATH
:
&
str
=
"../../res/roms/demo/pocket.gb"
;
pub
struct
Benchmark
{
count
:
usize
,
cpu_only
:
Option
<
bool
>
,
...
...
@@ -752,7 +756,7 @@ struct Args {
)]
cycles
:
u64
,
#[arg(short,
long,
default_value_t
=
String::from(
"../../res/roms/demo/pocket.gb"
),
help
=
"Path to the ROM file to be loaded"
)]
#[arg(short,
long,
default_value_t
=
String::from(
DEFAULT_ROM_PATH
),
help
=
"Path to the ROM file to be loaded"
)]
rom_path
:
String
,
}
...
...
@@ -787,6 +791,14 @@ fn main() {
};
let
auto_mode
=
args
.mode
==
"auto"
;
// in case the default ROM path is provided and the file does not
// exist then fails gracefully
let
path
=
Path
::
new
(
&
args
.rom_path
);
if
&
args
.rom_path
==
DEFAULT_ROM_PATH
&&
!
path
.exists
()
{
println!
(
"No ROM file provided, please provide one using the --rom-path option"
);
return
;
}
// creates a new Game Boy instance and loads both the boot ROM
// and the initial game ROM to "start the engine"
let
mut
game_boy
=
GameBoy
::
new
(
Some
(
mode
));
...
...
This diff is collapsed.
Click to expand it.
src/util.rs
+
3
−
0
View file @
b819f6b8
...
...
@@ -8,6 +8,8 @@ use std::{
pub
type
SharedMut
<
T
>
=
Rc
<
RefCell
<
T
>>
;
/// Reads the contents of the file at the given path into
/// a vector of bytes.
pub
fn
read_file
(
path
:
&
str
)
->
Vec
<
u8
>
{
let
mut
file
=
match
File
::
open
(
path
)
{
Ok
(
file
)
=>
file
,
...
...
@@ -18,6 +20,7 @@ pub fn read_file(path: &str) -> Vec<u8> {
data
}
/// Writes the given data to the file at the given path.
pub
fn
write_file
(
path
:
&
str
,
data
:
&
[
u8
])
{
let
mut
file
=
match
File
::
create
(
path
)
{
Ok
(
file
)
=>
file
,
...
...
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