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
52e5c467
Verified
Commit
52e5c467
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: save state support for libretro
parent
55765e41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!31
System state save
Pipeline
#3269
passed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontends/libretro/res/boytacean_libretro.info
+3
-3
3 additions, 3 deletions
frontends/libretro/res/boytacean_libretro.info
frontends/libretro/src/lib.rs
+17
-3
17 additions, 3 deletions
frontends/libretro/src/lib.rs
with
20 additions
and
6 deletions
frontends/libretro/res/boytacean_libretro.info
+
3
−
3
View file @
52e5c467
...
@@ -16,12 +16,12 @@ systemid = "game_boy"
...
@@ -16,12 +16,12 @@ systemid = "game_boy"
# Libretro Features
# Libretro Features
supports_no_game = "false"
supports_no_game = "false"
database = "Nintendo - Game Boy|Nintendo - Game Boy Color"
database = "Nintendo - Game Boy|Nintendo - Game Boy Color"
savestate = "
fals
e"
savestate = "
tru
e"
savestate_features = "
null
"
savestate_features = "
serialized
"
cheats = "true"
cheats = "true"
input_descriptors = "true"
input_descriptors = "true"
memory_descriptors = "false"
memory_descriptors = "false"
libretro_saves = "
fals
e"
libretro_saves = "
tru
e"
core_options = "true"
core_options = "true"
description = "A Game Boy emulator that is written in Rust."
description = "A Game Boy emulator that is written in Rust."
This diff is collapsed.
Click to expand it.
frontends/libretro/src/lib.rs
+
17
−
3
View file @
52e5c467
...
@@ -9,6 +9,7 @@ use boytacean::{
...
@@ -9,6 +9,7 @@ use boytacean::{
pad
::
PadKey
,
pad
::
PadKey
,
ppu
::{
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
,
FRAME_BUFFER_SIZE
,
XRGB8888_SIZE
},
ppu
::{
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
,
FRAME_BUFFER_SIZE
,
XRGB8888_SIZE
},
rom
::
Cartridge
,
rom
::
Cartridge
,
state
::
StateManager
,
};
};
use
consts
::{
use
consts
::{
REGION_NTSC
,
RETRO_API_VERSION
,
RETRO_DEVICE_ID_JOYPAD_A
,
RETRO_DEVICE_ID_JOYPAD_B
,
REGION_NTSC
,
RETRO_API_VERSION
,
RETRO_DEVICE_ID_JOYPAD_A
,
RETRO_DEVICE_ID_JOYPAD_B
,
...
@@ -24,6 +25,7 @@ use std::{
...
@@ -24,6 +25,7 @@ use std::{
ffi
::
CStr
,
ffi
::
CStr
,
fmt
::{
self
,
Display
,
Formatter
},
fmt
::{
self
,
Display
,
Formatter
},
os
::
raw
::{
c_char
,
c_float
,
c_uint
,
c_void
},
os
::
raw
::{
c_char
,
c_float
,
c_uint
,
c_void
},
ptr
,
slice
::
from_raw_parts
,
slice
::
from_raw_parts
,
};
};
...
@@ -333,6 +335,8 @@ pub extern "C" fn retro_load_game_special(
...
@@ -333,6 +335,8 @@ pub extern "C" fn retro_load_game_special(
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
retro_unload_game
()
{
pub
extern
"C"
fn
retro_unload_game
()
{
debugln!
(
"retro_unload_game()"
);
debugln!
(
"retro_unload_game()"
);
let
instance
=
unsafe
{
EMULATOR
.as_mut
()
.unwrap
()
};
instance
.reset
();
}
}
#[no_mangle]
#[no_mangle]
...
@@ -348,18 +352,28 @@ pub extern "C" fn retro_get_memory_size(_memory_id: u32) -> usize {
...
@@ -348,18 +352,28 @@ pub extern "C" fn retro_get_memory_size(_memory_id: u32) -> usize {
}
}
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
retro_serialize_size
()
{
pub
extern
"C"
fn
retro_serialize_size
()
->
usize
{
debugln!
(
"retro_serialize_size()"
);
debugln!
(
"retro_serialize_size()"
);
let
instance
=
unsafe
{
EMULATOR
.as_mut
()
.unwrap
()
};
StateManager
::
save
(
instance
)
.unwrap
()
.len
()
}
}
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
retro_serialize
()
{
pub
extern
"C"
fn
retro_serialize
(
data
:
*
mut
c_void
,
size
:
usize
)
{
debugln!
(
"retro_serialize()"
);
debugln!
(
"retro_serialize()"
);
let
instance
=
unsafe
{
EMULATOR
.as_mut
()
.unwrap
()
};
let
state
=
StateManager
::
save
(
instance
)
.unwrap
();
unsafe
{
ptr
::
copy_nonoverlapping
(
state
.as_ptr
(),
data
as
*
mut
u8
,
size
);
}
}
}
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
retro_unserialize
()
{
pub
extern
"C"
fn
retro_unserialize
(
data
:
*
const
c_void
,
size
:
usize
)
{
debugln!
(
"retro_unserialize()"
);
debugln!
(
"retro_unserialize()"
);
let
instance
=
unsafe
{
EMULATOR
.as_mut
()
.unwrap
()
};
let
state
=
unsafe
{
from_raw_parts
(
data
as
*
const
u8
,
size
)
};
StateManager
::
load
(
state
,
instance
)
.unwrap
();
}
}
#[no_mangle]
#[no_mangle]
...
...
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