Python: gamedata integration

This commit is contained in:
Vicki Pfau 2017-10-09 11:41:02 -07:00
parent 6b0847c472
commit 5fe6eb97ea
2 changed files with 26 additions and 0 deletions

View File

@ -258,6 +258,10 @@ class Core(object):
def addFrameCallback(self, cb):
self._callbacks.videoFrameEnded.append(cb)
@property
def crc32(self):
return self._native.romCrc32
class ICoreOwner(object):
def claim(self):
raise NotImplementedError

View File

@ -0,0 +1,22 @@
# Copyright (c) 2013-2017 Jeffrey Pfau
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
try:
import mgba_gamedata
except ImportError:
pass
def search(core):
crc32 = None
if hasattr(core, 'PLATFORM_GBA') and core.platform() == core.PLATFORM_GBA:
platform = 'GBA'
crc32 = core.crc32
if hasattr(core, 'PLATFORM_GB') and core.platform() == core.PLATFORM_GB:
platform = 'GB'
crc32 = core.crc32
cls = mgba_gamedata.registry.search(platform, {'crc32': crc32})
if not cls:
return None
return cls(core.memory.u8)