all repos — mgba @ e2652ee5f4759ee8cf92ef9590cafc6914147a39

mGBA Game Boy Advance Emulator

Python: Add raw state save/load
Vicki Pfau vi@endrift.com
Sat, 01 Sep 2018 12:22:24 -0700
commit

e2652ee5f4759ee8cf92ef9590cafc6914147a39

parent

0b47bb1204d48d0ca3497a352b9ad16fb68057f1

1 files changed, 15 insertions(+), 0 deletions(-)

jump to
M src/platform/python/mgba/core.pysrc/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