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
9cbd4b77
Verified
Commit
9cbd4b77
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: new error support
parent
4bcd59a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!31
System state save
Pipeline
#3294
passed
1 year ago
Stage: build
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
frontends/sdl/src/main.rs
+1
-1
1 addition, 1 deletion
frontends/sdl/src/main.rs
src/gb.rs
+3
-3
3 additions, 3 deletions
src/gb.rs
src/rom.rs
+1
-1
1 addition, 1 deletion
src/rom.rs
src/util.rs
+7
-6
7 additions, 6 deletions
src/util.rs
with
12 additions
and
11 deletions
frontends/sdl/src/main.rs
+
1
−
1
View file @
9cbd4b77
...
@@ -395,7 +395,7 @@ impl Emulator {
...
@@ -395,7 +395,7 @@ impl Emulator {
// into a *.sav file in the file system
// into a *.sav file in the file system
if
counter
%
store_count
==
0
&&
self
.system
.rom
()
.has_battery
()
{
if
counter
%
store_count
==
0
&&
self
.system
.rom
()
.has_battery
()
{
let
ram_data
=
self
.system
.rom
()
.ram_data
();
let
ram_data
=
self
.system
.rom
()
.ram_data
();
write_file
(
&
self
.ram_path
,
ram_data
);
write_file
(
&
self
.ram_path
,
ram_data
)
.unwrap
()
;
}
}
// obtains an event from the SDL sub-system to be
// obtains an event from the SDL sub-system to be
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
3
−
3
View file @
9cbd4b77
...
@@ -990,7 +990,7 @@ impl GameBoy {
...
@@ -990,7 +990,7 @@ impl GameBoy {
}
}
pub
fn
load_boot_path
(
&
mut
self
,
path
:
&
str
)
{
pub
fn
load_boot_path
(
&
mut
self
,
path
:
&
str
)
{
let
data
=
read_file
(
path
);
let
data
=
read_file
(
path
)
.unwrap
()
;
self
.load_boot
(
&
data
);
self
.load_boot
(
&
data
);
}
}
...
@@ -1031,10 +1031,10 @@ impl GameBoy {
...
@@ -1031,10 +1031,10 @@ impl GameBoy {
}
}
pub
fn
load_rom_file
(
&
mut
self
,
path
:
&
str
,
ram_path
:
Option
<&
str
>
)
->
&
mut
Cartridge
{
pub
fn
load_rom_file
(
&
mut
self
,
path
:
&
str
,
ram_path
:
Option
<&
str
>
)
->
&
mut
Cartridge
{
let
data
=
read_file
(
path
);
let
data
=
read_file
(
path
)
.unwrap
()
;
match
ram_path
{
match
ram_path
{
Some
(
ram_path
)
=>
{
Some
(
ram_path
)
=>
{
let
ram_data
=
read_file
(
ram_path
);
let
ram_data
=
read_file
(
ram_path
)
.unwrap
()
;
self
.load_rom
(
&
data
,
Some
(
&
ram_data
))
self
.load_rom
(
&
data
,
Some
(
&
ram_data
))
}
}
None
=>
self
.load_rom
(
&
data
,
None
),
None
=>
self
.load_rom
(
&
data
,
None
),
...
...
This diff is collapsed.
Click to expand it.
src/rom.rs
+
1
−
1
View file @
9cbd4b77
...
@@ -335,7 +335,7 @@ impl Cartridge {
...
@@ -335,7 +335,7 @@ impl Cartridge {
}
}
pub
fn
from_file
(
path
:
&
str
)
->
Self
{
pub
fn
from_file
(
path
:
&
str
)
->
Self
{
let
data
=
read_file
(
path
);
let
data
=
read_file
(
path
)
.unwrap
()
;
Self
::
from_data
(
&
data
)
Self
::
from_data
(
&
data
)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/util.rs
+
7
−
6
View file @
9cbd4b77
...
@@ -10,23 +10,24 @@ pub type SharedMut<T> = Rc<RefCell<T>>;
...
@@ -10,23 +10,24 @@ pub type SharedMut<T> = Rc<RefCell<T>>;
/// Reads the contents of the file at the given path into
/// Reads the contents of the file at the given path into
/// a vector of bytes.
/// a vector of bytes.
pub
fn
read_file
(
path
:
&
str
)
->
Vec
<
u8
>
{
pub
fn
read_file
(
path
:
&
str
)
->
Result
<
Vec
<
u8
>
,
String
>
{
let
mut
file
=
match
File
::
open
(
path
)
{
let
mut
file
=
match
File
::
open
(
path
)
{
Ok
(
file
)
=>
file
,
Ok
(
file
)
=>
file
,
Err
(
_
)
=>
panic
!
(
"Failed to open file: {}"
,
path
),
Err
(
_
)
=>
return
Err
(
format
!
(
"Failed to open file: {}"
,
path
)
)
,
};
};
let
mut
data
=
Vec
::
new
();
let
mut
data
=
Vec
::
new
();
file
.read_to_end
(
&
mut
data
)
.unwrap
();
file
.read_to_end
(
&
mut
data
)
.unwrap
();
data
Ok
(
data
)
}
}
/// Writes the given data to the file at the given path.
/// Writes the given data to the file at the given path.
pub
fn
write_file
(
path
:
&
str
,
data
:
&
[
u8
])
{
pub
fn
write_file
(
path
:
&
str
,
data
:
&
[
u8
])
->
Result
<
(),
String
>
{
let
mut
file
=
match
File
::
create
(
path
)
{
let
mut
file
=
match
File
::
create
(
path
)
{
Ok
(
file
)
=>
file
,
Ok
(
file
)
=>
file
,
Err
(
_
)
=>
panic
!
(
"Failed to open file: {}"
,
path
),
Err
(
_
)
=>
return
Err
(
format
!
(
"Failed to open file: {}"
,
path
)
)
,
};
};
file
.write_all
(
data
)
.unwrap
()
file
.write_all
(
data
)
.unwrap
();
Ok
(())
}
}
/// Replaces the extension in the given path with the provided extension.
/// Replaces the extension in the given path with the provided extension.
...
...
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