src/platform/python/mCore.py (view raw)
1from _pylib import ffi, lib
2
3def find(path):
4 core = lib.mCoreFind(path.encode('UTF-8'))
5 if core == ffi.NULL:
6 return None
7 return mCore(core)
8
9class mCore:
10 def __init__(self, native):
11 self._core = ffi.gc(native, self._deinit)
12
13 def init(self):
14 return bool(self._core.init(self._core))
15
16 def _deinit(self):
17 self._core.deinit(self._core)
18
19 def loadFile(self, path):
20 return bool(lib.mCoreLoadFile(self._core, path.encode('UTF-8')))
21
22 def autoloadSave(self):
23 return bool(lib.mCoreAutoloadSave(self._core))
24
25 def autoloadPatch(self):
26 return bool(lib.mCoreAutoloadPatch(self._core))
27
28 def platform(self):
29 return self._core.platform(self._core)
30
31 def desiredVideoDimensions(self):
32 width = ffi.new("unsigned*")
33 height = ffi.new("unsigned*")
34 self._core.desiredVideoDimensions(self._core, width, height)
35 return width[0], height[0]
36
37 def reset(self):
38 self._core.reset(self._core)
39
40 def runFrame(self):
41 self._core.runFrame(self._core)
42
43 def runLoop(self):
44 self._core.runLoop(self._core)
45
46 def step(self):
47 self._core.step(self._core)