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
1dcaecde
Verified
Commit
1dcaecde
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: added write and read unsafe
parent
06bd16df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!31
System state save
Pipeline
#3295
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mmu.rs
+37
-2
37 additions, 2 deletions
src/mmu.rs
src/state.rs
+2
-2
2 additions, 2 deletions
src/state.rs
with
39 additions
and
4 deletions
src/mmu.rs
+
37
−
2
View file @
1dcaecde
...
...
@@ -498,23 +498,58 @@ impl Mmu {
}
}
/// Reads a byte from a certain memory address, without the typical
/// Game Boy verifications, allowing deep read of values.
pub
fn
read_unsafe
(
&
mut
self
,
addr
:
u16
)
->
u8
{
match
addr
{
_
=>
self
.read
(
addr
),
}
}
/// Writes a byte to a certain memory address without the typical
/// Game Boy verification process. This allows for faster memory
/// access in registers and other memory areas that are typically
/// inaccessible.
pub
fn
write_unsafe
(
&
mut
self
,
addr
:
u16
,
value
:
u8
)
{
match
addr
{
_
=>
self
.write
(
addr
,
value
),
}
}
pub
fn
read_many
(
&
mut
self
,
addr
:
u16
,
count
:
u16
)
->
Vec
<
u8
>
{
let
mut
data
:
Vec
<
u8
>
=
vec!
[];
for
index
in
0
..
count
{
let
byte
=
self
.read
(
addr
+
index
);
data
.push
(
byte
);
}
data
}
pub
fn
write_many
(
&
mut
self
,
addr
:
u16
,
data
:
&
[
u8
])
{
for
(
index
,
byte
)
in
data
.iter
()
.enumerate
()
{
self
.write
(
addr
+
index
as
u16
,
*
byte
)
}
}
pub
fn
read_many
(
&
mut
self
,
addr
:
u16
,
count
:
u16
)
->
Vec
<
u8
>
{
pub
fn
read_many
_unsafe
(
&
mut
self
,
addr
:
u16
,
count
:
u16
)
->
Vec
<
u8
>
{
let
mut
data
:
Vec
<
u8
>
=
vec!
[];
for
index
in
0
..
count
{
let
byte
=
self
.read
(
addr
+
index
);
let
byte
=
self
.read
_unsafe
(
addr
+
index
);
data
.push
(
byte
);
}
data
}
pub
fn
write_many_unsafe
(
&
mut
self
,
addr
:
u16
,
data
:
&
[
u8
])
{
for
(
index
,
byte
)
in
data
.iter
()
.enumerate
()
{
self
.write_unsafe
(
addr
+
index
as
u16
,
*
byte
)
}
}
pub
fn
write_boot
(
&
mut
self
,
addr
:
u16
,
buffer
:
&
[
u8
])
{
self
.boot
[
addr
as
usize
..
addr
as
usize
+
buffer
.len
()]
.clone_from_slice
(
buffer
);
}
...
...
This diff is collapsed.
Click to expand it.
src/state.rs
+
2
−
2
View file @
1dcaecde
...
...
@@ -791,7 +791,7 @@ impl State for BeesCore {
// The loading of the registers should be done in a much
// more manual way like SameBoy does here
// https://github.com/LIJI32/SameBoy/blob/7e6f1f866e89430adaa6be839aecc4a2ccabd69c/Core/save_state.c#L673
gb
.mmu
()
.read_many
(
0xff00
,
128
)
.try_into
()
.unwrap
(),
gb
.mmu
()
.read_many
_unsafe
(
0xff00
,
128
)
.try_into
()
.unwrap
(),
);
core
.ram
.fill_buffer
(
gb
.mmu
()
.ram
());
core
.vram
.fill_buffer
(
gb
.ppu
()
.vram_device
());
...
...
@@ -831,7 +831,7 @@ impl State for BeesCore {
// The registers should be handled in a more manual manner
// to avoid unwanted side effects
// https://github.com/LIJI32/SameBoy/blob/7e6f1f866e89430adaa6be839aecc4a2ccabd69c/Core/save_state.c#L1003
gb
.mmu
()
.write_many
(
0xff00
,
&
self
.io_registers
);
gb
.mmu
()
.write_many
_unsafe
(
0xff00
,
&
self
.io_registers
);
gb
.mmu
()
.set_ram
(
self
.ram.buffer
.to_vec
());
gb
.ppu
()
.set_vram
(
&
self
.vram.buffer
);
...
...
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