Python: Add raw state save/load
Vicki Pfau vi@endrift.com
Sat, 01 Sep 2018 12:22:24 -0700
1 files changed,
15 insertions(+),
0 deletions(-)
jump to
M
src/platform/python/mgba/core.py
→
src/platform/python/mgba/core.py
@@ -230,6 +230,21 @@ @needs_reset
def step(self): self._core.step(self._core) + @needs_reset + @protected + def load_raw_state(self, state): + if len(state) < self._core.stateSize(self._core): + return False + return self._core.loadState(self._core, state) + + @needs_reset + @protected + def save_raw_state(self): + state = ffi.new('unsigned char[%i]' % self._core.stateSize(self._core)) + if self._core.saveState(self._core, state): + return state + return None + @staticmethod def _keys_to_int(*args, **kwargs): keys = 0