all repos — mgba @ 5fe6eb97ea87f46e38a4a283f2228f4cf506b3f3

mGBA Game Boy Advance Emulator

Python: gamedata integration
Vicki Pfau vi@endrift.com
Mon, 09 Oct 2017 11:41:02 -0700
commit

5fe6eb97ea87f46e38a4a283f2228f4cf506b3f3

parent

6b0847c4725c89f937f8107c28cc4fef611a85d4

2 files changed, 26 insertions(+), 0 deletions(-)

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

@@ -258,6 +258,10 @@

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
A src/platform/python/mgba/gamedata.py

@@ -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)