Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
snes9x2010
Commits
75139261
Commit
75139261
authored
Jun 03, 2021
by
Libretro-Admin
Browse files
Use persistent data buffer API extension (plus fallback for frontends
that don't support it)
parent
753abccb
Pipeline
#29445
passed with stages
in 2 minutes and 57 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
libretro/libretro-common/include/libretro.h
View file @
75139261
This diff is collapsed.
Click to expand it.
libretro/libretro.c
View file @
75139261
...
...
@@ -249,6 +249,10 @@ static retro_input_state_t input_cb = NULL;
static
retro_audio_sample_batch_t
audio_batch_cb
=
NULL
;
static
retro_environment_t
environ_cb
=
NULL
;
static
uint8
*
rom_buf
=
NULL
;
static
const
uint8
*
rom_data
=
NULL
;
static
size_t
rom_size
=
0
;
static
unsigned
frameskip_type
=
0
;
static
unsigned
frameskip_threshold
=
0
;
static
uint16_t
frameskip_counter
=
0
;
...
...
@@ -1408,9 +1412,10 @@ static void init_descriptors(void)
environ_cb
(
RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS
,
desc
);
}
bool
retro_load_game
(
const
struct
retro_game_info
*
game
)
bool
retro_load_game
(
const
struct
retro_game_info
*
info
)
{
int
loaded
;
const
struct
retro_game_info_ext
*
info_ext
=
NULL
;
struct
retro_memory_map
map
;
init_descriptors
();
...
...
@@ -1419,8 +1424,41 @@ bool retro_load_game(const struct retro_game_info *game)
map
.
descriptors
=
memorydesc
+
MAX_MAPS
-
memorydesc_c
;
map
.
num_descriptors
=
memorydesc_c
;
/* Snes9x 2010 requires a persistent ROM data buffer */
rom_buf
=
NULL
;
rom_data
=
NULL
;
rom_size
=
0
;
if
(
environ_cb
(
RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
,
&
info_ext
)
&&
info_ext
->
persistent_data
)
{
rom_data
=
(
const
uint8
*
)
info_ext
->
data
;
rom_size
=
info_ext
->
size
;
}
/* If frontend does not support persistent
* content data, must create a copy */
if
(
!
rom_data
)
{
if
(
!
info
)
return
false
;
rom_size
=
info
->
size
;
rom_buf
=
(
uint8
*
)
malloc
(
rom_size
);
if
(
!
rom_buf
)
{
if
(
log_cb
)
log_cb
(
RETRO_LOG_INFO
,
"[Snes9x 2010]: Failed to allocate ROM buffer!
\n
"
);
return
false
;
}
memcpy
(
rom_buf
,
(
const
uint8
*
)
info
->
data
,
rom_size
);
rom_data
=
(
const
uint8
*
)
rom_buf
;
}
/* Hack. S9x cannot do stuff from RAM. <_< */
memstream_set_buffer
((
uint8_t
*
)
game
->
data
,
(
uint64_t
)
game
->
size
);
memstream_set_buffer
((
uint8_t
*
)
rom_
data
,
(
uint64_t
)
rom_
size
);
loaded
=
LoadROM
(
""
);
if
(
!
loaded
)
...
...
@@ -1454,7 +1492,15 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i
return
false
;
}
void
retro_unload_game
(
void
)
{
}
void
retro_unload_game
(
void
)
{
if
(
rom_buf
)
free
(
rom_buf
);
rom_buf
=
NULL
;
rom_data
=
NULL
;
rom_size
=
0
;
}
unsigned
retro_get_region
(
void
)
{
...
...
Libretro-Admin
@libretro-admin
mentioned in commit
526706b9
·
Jun 03, 2021
mentioned in commit
526706b9
mentioned in commit 526706b985d24c245d0bc5ca24c2bcd94e3720ba
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment