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
libretro-handy
Commits
1b5afcaa
Unverified
Commit
1b5afcaa
authored
Apr 14, 2022
by
jdgleaver
Committed by
GitHub
Apr 14, 2022
Browse files
Improve save state efficiency (#102)
parent
8133b0a0
Pipeline
#102006
passed with stages
in 1 minute and 20 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
libretro/libretro.cpp
View file @
1b5afcaa
...
...
@@ -753,12 +753,14 @@ size_t retro_serialize_size(void)
bool
retro_serialize
(
void
*
data
,
size_t
size
)
{
LSS_FILE
fp
;
if
(
!
lynx
)
return
false
;
fp
.
memptr
=
(
UBYTE
*
)
data
;
fp
.
memptr
=
(
UBYTE
*
)
data
;
fp
.
index
=
0
;
fp
.
index_limit
=
size
;
fp
.
nul_stream
=
0
;
return
lynx
->
ContextSave
(
&
fp
);
}
...
...
@@ -766,12 +768,14 @@ bool retro_serialize(void *data, size_t size)
bool
retro_unserialize
(
const
void
*
data
,
size_t
size
)
{
LSS_FILE
fp
;
if
(
!
lynx
)
return
false
;
fp
.
memptr
=
(
UBYTE
*
)
data
;
fp
.
memptr
=
(
UBYTE
*
)
data
;
fp
.
index
=
0
;
fp
.
index_limit
=
size
;
fp
.
nul_stream
=
0
;
return
lynx
->
ContextLoad
(
&
fp
);
}
...
...
lynx/system.cpp
View file @
1b5afcaa
...
...
@@ -66,9 +66,11 @@ extern void lynx_decrypt(unsigned char * result, const unsigned char * encrypted
int
lss_read
(
void
*
dest
,
int
varsize
,
int
varcount
,
LSS_FILE
*
fp
)
{
ULONG
copysize
=
varsize
*
varcount
;
if
((
fp
->
index
+
copysize
)
>
fp
->
index_limit
)
copysize
=
fp
->
index_limit
-
fp
->
index
;
memcpy
(
dest
,
fp
->
memptr
+
fp
->
index
,
copysize
);
if
(
!
fp
->
nul_stream
)
{
if
((
fp
->
index
+
copysize
)
>
fp
->
index_limit
)
copysize
=
fp
->
index_limit
-
fp
->
index
;
memcpy
(
dest
,
fp
->
memptr
+
fp
->
index
,
copysize
);
}
fp
->
index
+=
copysize
;
return
copysize
;
}
...
...
@@ -76,7 +78,11 @@ int lss_read(void* dest, int varsize, int varcount, LSS_FILE *fp)
int
lss_write
(
void
*
src
,
int
varsize
,
int
varcount
,
LSS_FILE
*
fp
)
{
ULONG
copysize
=
varsize
*
varcount
;
memcpy
(
fp
->
memptr
+
fp
->
index
,
src
,
copysize
);
if
(
!
fp
->
nul_stream
)
{
if
((
fp
->
index
+
copysize
)
>
fp
->
index_limit
)
copysize
=
fp
->
index_limit
-
fp
->
index
;
memcpy
(
fp
->
memptr
+
fp
->
index
,
src
,
copysize
);
}
fp
->
index
+=
copysize
;
return
copysize
;
}
...
...
@@ -84,7 +90,11 @@ int lss_write(void* src, int varsize, int varcount, LSS_FILE *fp)
int
lss_printf
(
LSS_FILE
*
fp
,
const
char
*
str
)
{
ULONG
copysize
=
strlen
(
str
);
memcpy
(
fp
->
memptr
+
fp
->
index
,
str
,
copysize
);
if
(
!
fp
->
nul_stream
)
{
if
((
fp
->
index
+
copysize
)
>
fp
->
index_limit
)
copysize
=
fp
->
index_limit
-
fp
->
index
;
memcpy
(
fp
->
memptr
+
fp
->
index
,
str
,
copysize
);
}
fp
->
index
+=
copysize
;
return
copysize
;
}
...
...
@@ -422,15 +432,14 @@ void CSystem::Reset(void)
size_t
CSystem
::
ContextSize
()
{
LSS_FILE
fp
;
const
int
max_size
=
0x40000
+
HANDY_AUDIO_BUFFER_SIZE
;
fp
.
memptr
=
(
UBYTE
*
)
malloc
(
max_size
);
fp
.
index
=
0
;
fp
.
index_limit
=
max_size
;
fp
.
memptr
=
NULL
;
fp
.
index
=
0
;
fp
.
index_limit
=
0
;
fp
.
nul_stream
=
1
;
ContextSave
(
&
fp
);
free
(
fp
.
memptr
);
return
fp
.
index
;
}
...
...
lynx/system.h
View file @
1b5afcaa
...
...
@@ -139,6 +139,7 @@ typedef struct lssfile
UBYTE
*
memptr
;
ULONG
index
;
ULONG
index_limit
;
UBYTE
nul_stream
;
}
LSS_FILE
;
int
lss_read
(
void
*
dest
,
int
varsize
,
int
varcount
,
LSS_FILE
*
fp
);
...
...
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