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
retro8
Commits
26b11781
Commit
26b11781
authored
Dec 24, 2019
by
Jack
Browse files
added backup of cartridge do be used with reload
parent
3848b4b0
Changes
3
Show whitespace changes
Inline
Side-by-side
src/views/game_view.cpp
View file @
26b11781
...
...
@@ -81,9 +81,10 @@ void GameView::render()
retro8
::
io
::
Loader
loader
;
if
(
_path
.
empty
())
_path
=
"cartridges/
lands-of-yocta
.png"
;
_path
=
"cartridges/
pico-racer
.png"
;
loader
.
load
(
_path
,
machine
);
machine
.
memory
().
backupCartridge
();
int32_t
fps
=
machine
.
code
().
require60fps
()
?
60
:
30
;
manager
->
setFrameRate
(
fps
);
...
...
src/vm/lua_bridge.cpp
View file @
26b11781
...
...
@@ -784,6 +784,18 @@ namespace platform
return
0
;
}
int
reload
(
lua_State
*
L
)
{
assert
(
lua_gettop
(
L
)
<=
3
);
address_t
dest
=
lua_to_or_default
(
L
,
number
,
1
,
0
);
address_t
src
=
lua_to_or_default
(
L
,
number
,
1
,
0
);
int32_t
length
=
lua_to_or_default
(
L
,
number
,
1
,
address
::
CART_DATA_LENGTH
);
std
::
memcpy
(
machine
.
memory
().
base
()
+
dest
,
machine
.
memory
().
backup
()
+
src
,
length
);
return
0
;
}
int
btn
(
lua_State
*
L
)
{
...
...
@@ -971,6 +983,7 @@ void lua::registerFunctions(lua_State* L)
lua_register
(
L
,
"peek"
,
platform
::
peek
);
lua_register
(
L
,
"memset"
,
platform
::
memset
);
lua_register
(
L
,
"memcpy"
,
platform
::
memcpy
);
lua_register
(
L
,
"reload"
,
platform
::
reload
);
lua_register
(
L
,
"flip"
,
platform
::
flip
);
}
...
...
src/vm/memory.h
View file @
26b11781
...
...
@@ -31,11 +31,14 @@ namespace retro8
static
constexpr
address_t
TILE_MAP_LOW
=
0x1000
;
static
constexpr
address_t
TILE_MAP_HIGH
=
0x2000
;
static
constexpr
int32_t
CART_DATA_LENGTH
=
0x4300
;
};
class
Memory
{
private:
uint8_t
_backup
[
address
::
CART_DATA_LENGTH
];
uint8_t
memory
[
1024
*
32
];
static
constexpr
size_t
BYTES_PER_PALETTE
=
sizeof
(
retro8
::
gfx
::
palette_t
);
...
...
@@ -54,6 +57,12 @@ namespace retro8
cursor
()
->
reset
();
}
void
backupCartridge
()
{
std
::
memcpy
(
_backup
,
memory
,
address
::
CART_DATA_LENGTH
);
}
const
uint8_t
*
backup
()
const
{
return
_backup
;
}
uint8_t
*
base
()
{
return
memory
;
}
gfx
::
color_byte_t
*
penColor
()
{
return
as
<
gfx
::
color_byte_t
>
(
address
::
PEN_COLOR
);
}
...
...
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