Python: Add BIOS loading, fix up reference errors

This commit is contained in:
Vicki Pfau 2017-10-21 17:24:51 -07:00
parent 168cad7f9c
commit 5d72a2be9d
3 changed files with 12 additions and 3 deletions

View File

@ -139,9 +139,6 @@ class Core(object):
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:
@ -164,6 +161,9 @@ class Core(object):
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))

View File

@ -43,6 +43,9 @@ class GB(Core):
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")

View File

@ -33,6 +33,7 @@ class GBA(Core):
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,8 +50,13 @@ class GBA(Core):
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")
createCallback("GBASIOPythonDriver", "load")