src/platform/python/mgba/lr35902.py (view raw)
1# Copyright (c) 2013-2016 Jeffrey Pfau
2#
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6from ._pylib import ffi # pylint: disable=no-name-in-module
7
8
9class LR35902Core:
10 # pylint: disable=invalid-name
11 def __init__(self, native):
12 self._native = ffi.cast("struct LR35902Core*", native)
13
14 @property
15 def a(self):
16 return self._native.a
17
18 @property
19 def b(self):
20 return self._native.b
21
22 @property
23 def c(self):
24 return self._native.c
25
26 @property
27 def d(self):
28 return self._native.d
29
30 @property
31 def e(self):
32 return self._native.e
33
34 @property
35 def f(self):
36 return self._native.f
37
38 @property
39 def h(self):
40 return self._native.h
41
42 @property
43 def l(self):
44 return self._native.l
45
46 @property
47 def sp(self):
48 return self._native.sp
49
50 @property
51 def pc(self):
52 return self._native.pc
53
54 @property
55 def af(self):
56 return (self.a << 8) | self.f
57
58 @property
59 def bc(self):
60 return (self.b << 8) | self.c
61
62 @property
63 def de(self):
64 return (self.d << 8) | self.e
65
66 @property
67 def hl(self):
68 return (self.h << 8) | self.l
69
70 @a.setter
71 def a(self, value):
72 self._native.a = value
73
74 @b.setter
75 def b(self, value):
76 self._native.b = value
77
78 @c.setter
79 def c(self, value):
80 self._native.c = value
81
82 @d.setter
83 def d(self, value):
84 self._native.d = value
85
86 @e.setter
87 def e(self, value):
88 self._native.e = value
89
90 @f.setter
91 def f(self, value):
92 self._native.f.packed = value
93 self._native.f.unused = 0
94
95 @h.setter
96 def h(self, value):
97 self._native.h = value
98
99 @l.setter
100 def l(self, value):
101 self._native.l = value
102
103 @sp.setter
104 def sp(self, value):
105 self._native.sp = value
106
107 @af.setter
108 def af(self, value):
109 self.a = value >> 8
110 self.f = value & 0xFF
111
112 @bc.setter
113 def bc(self, value):
114 self.b = value >> 8
115 self.c = value & 0xFF
116
117 @de.setter
118 def de(self, value):
119 self.d = value >> 8
120 self.e = value & 0xFF
121
122 @hl.setter
123 def hl(self, value):
124 self.h = value >> 8
125 self.l = value & 0xFF