mirror of https://github.com/mgba-emu/mgba.git
Python: Reindent, fix up TileView interface
This commit is contained in:
parent
5e0641cb0e
commit
303a7685a2
|
@ -4,6 +4,8 @@
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
from ._pylib import ffi, lib
|
from ._pylib import ffi, lib
|
||||||
|
from . import tile
|
||||||
|
from cached_property import cached_property
|
||||||
|
|
||||||
def find(path):
|
def find(path):
|
||||||
core = lib.mCoreFind(path.encode('UTF-8'))
|
core = lib.mCoreFind(path.encode('UTF-8'))
|
||||||
|
@ -43,6 +45,10 @@ class Core:
|
||||||
self.cpu = LR35902Core(self._core.cpu)
|
self.cpu = LR35902Core(self._core.cpu)
|
||||||
self.board = GB(self._core.board)
|
self.board = GB(self._core.board)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def tiles(self):
|
||||||
|
return tile.TileView(self)
|
||||||
|
|
||||||
def _deinit(self):
|
def _deinit(self):
|
||||||
self._core.deinit(self._core)
|
self._core.deinit(self._core)
|
||||||
|
|
||||||
|
|
|
@ -8,3 +8,11 @@ from ._pylib import ffi, lib
|
||||||
class GB:
|
class GB:
|
||||||
def __init__(self, native):
|
def __init__(self, native):
|
||||||
self._native = ffi.cast("struct GB*", native)
|
self._native = ffi.cast("struct GB*", native)
|
||||||
|
|
||||||
|
def _initTileCache(self, cache):
|
||||||
|
lib.GBVideoTileCacheInit(cache)
|
||||||
|
lib.GBVideoTileCacheAssociate(cache, ffi.addressof(self._native.video))
|
||||||
|
|
||||||
|
def _deinitTileCache(self, cache):
|
||||||
|
self._native.video.renderer.cache = ffi.NULL
|
||||||
|
lib.mTileCacheDeinit(cache)
|
||||||
|
|
|
@ -8,3 +8,11 @@ from ._pylib import ffi, lib
|
||||||
class GBA:
|
class GBA:
|
||||||
def __init__(self, native):
|
def __init__(self, native):
|
||||||
self._native = ffi.cast("struct GBA*", native)
|
self._native = ffi.cast("struct GBA*", native)
|
||||||
|
|
||||||
|
def _initTileCache(self, cache):
|
||||||
|
lib.GBAVideoTileCacheInit(cache)
|
||||||
|
lib.GBAVideoTileCacheAssociate(cache, ffi.addressof(self._native.video))
|
||||||
|
|
||||||
|
def _deinitTileCache(self, cache):
|
||||||
|
self._native.video.renderer.cache = ffi.NULL
|
||||||
|
lib.mTileCacheDeinit(cache)
|
||||||
|
|
|
@ -23,13 +23,8 @@ class Tile:
|
||||||
class TileView:
|
class TileView:
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
self.core = core
|
self.core = core
|
||||||
self.cache = ffi.gc(ffi.new("struct mTileCache*"), lib.mTileCacheDeinit)
|
self.cache = ffi.gc(ffi.new("struct mTileCache*"), core.board._deinitTileCache)
|
||||||
if core.platform() == core.PLATFORM_GBA:
|
core.board._initTileCache(self.cache)
|
||||||
lib.GBAVideoTileCacheInit(self.cache)
|
|
||||||
lib.GBAVideoTileCacheAssociate(self.cache, ffi.addressof(self.core.board._native, "video"))
|
|
||||||
if core.platform() == core.PLATFORM_GB:
|
|
||||||
lib.GBVideoTileCacheInit(self.cache)
|
|
||||||
lib.GBVideoTileCacheAssociate(self.cache, ffi.addressof(self.core.board._native, "video"))
|
|
||||||
lib.mTileCacheSetPalette(self.cache, 0)
|
lib.mTileCacheSetPalette(self.cache, 0)
|
||||||
|
|
||||||
def getTile(self, tile, palette):
|
def getTile(self, tile, palette):
|
||||||
|
|
|
@ -14,7 +14,7 @@ setup(name="${BINARY_NAME}",
|
||||||
url="http://github.com/mgba-emu/mgba/",
|
url="http://github.com/mgba-emu/mgba/",
|
||||||
packages=["mgba"],
|
packages=["mgba"],
|
||||||
setup_requires=['cffi>=1.6'],
|
setup_requires=['cffi>=1.6'],
|
||||||
install_requires=['cffi>=1.6'],
|
install_requires=['cffi>=1.6', 'cached-property'],
|
||||||
license="MPL 2.0",
|
license="MPL 2.0",
|
||||||
classifiers=classifiers
|
classifiers=classifiers
|
||||||
)
|
)
|
Loading…
Reference in New Issue