all repos — mgba @ 5d72a2be9d5e7e74bc9fc94ac0130442ae91dc86

mGBA Game Boy Advance Emulator

Python: Add BIOS loading, fix up reference errors
Vicki Pfau vi@endrift.com
Sat, 21 Oct 2017 17:24:51 -0700
commit

5d72a2be9d5e7e74bc9fc94ac0130442ae91dc86

parent

168cad7f9cb9df70fcad15b6d89769d8d96834d2

3 files changed, 12 insertions(+), 3 deletions(-)

jump to
M src/platform/python/mgba/core.pysrc/platform/python/mgba/core.py

@@ -139,9 +139,6 @@ if not success:

raise RuntimeError("Failed to initialize core") return cls._detect(core) - def _deinit(self): - self._core.deinit(self._core) - @classmethod def _detect(cls, core): if hasattr(cls, 'PLATFORM_GBA') and core.platform(core) == cls.PLATFORM_GBA:

@@ -163,6 +160,9 @@ return bool(self._core.isROM(vf.handle))

def loadROM(self, vf): return bool(self._core.loadROM(self._core, vf.handle)) + + def loadBIOS(self, vf, id=0): + return bool(self._core.loadBIOS(self._core, vf.handle, id)) def loadSave(self, vf): return bool(self._core.loadSave(self._core, vf.handle))
M src/platform/python/mgba/gb.pysrc/platform/python/mgba/gb.py

@@ -43,6 +43,9 @@

def attachSIO(self, link): lib.GBSIOSetDriver(ffi.addressof(self._native.sio), link._native) + def __del__(self): + lib.GBSIOSetDriver(ffi.addressof(self._native.sio), ffi.NULL) + createCallback("GBSIOPythonDriver", "init") createCallback("GBSIOPythonDriver", "deinit") createCallback("GBSIOPythonDriver", "writeSB")
M src/platform/python/mgba/gba.pysrc/platform/python/mgba/gba.py

@@ -33,6 +33,7 @@ super(GBA, self).__init__(native)

self._native = ffi.cast("struct GBA*", native.board) self.sprites = GBAObjs(self) self.cpu = ARMCore(self._core.cpu) + self._sio = set() @needsReset def _initCache(self, cache):

@@ -49,7 +50,12 @@ super(GBA, self)._load()

self.memory = GBAMemory(self._core, self._native.memory.romSize) def attachSIO(self, link, mode=lib.SIO_MULTI): + self._sio.add(mode) lib.GBASIOSetDriver(ffi.addressof(self._native.sio), link._native, mode) + + def __del__(self): + for mode in self._sio: + lib.GBASIOSetDriver(ffi.addressof(self._native.sio), ffi.NULL, mode) createCallback("GBASIOPythonDriver", "init") createCallback("GBASIOPythonDriver", "deinit")