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, lib
7
8class LR35902Core:
9 def __init__(self, native):
10 self._native = ffi.cast("struct LR35902Core*", native)
11
12 @property
13 def a(self):
14 return self._native.a
15
16 @property
17 def b(self):
18 return self._native.b
19
20 @property
21 def c(self):
22 return self._native.c
23
24 @property
25 def d(self):
26 return self._native.d
27
28 @property
29 def e(self):
30 return self._native.e
31
32 @property
33 def f(self):
34 return self._native.f
35
36 @property
37 def h(self):
38 return self._native.h
39
40 @property
41 def l(self):
42 return self._native.l
43
44 @property
45 def sp(self):
46 return self._native.sp
47
48 @property
49 def pc(self):
50 return self._native.pc
51
52 @property
53 def af(self):
54 return (self.a << 8) | self.f
55
56 @property
57 def bc(self):
58 return (self.b << 8) | self.c
59
60 @property
61 def de(self):
62 return (self.d << 8) | self.e
63
64 @property
65 def hl(self):
66 return (self.h << 8) | self.l
67
68 @a.setter
69 def a(self, value):
70 self._native.a = value
71
72 @b.setter
73 def b(self, value):
74 self._native.b = value
75
76 @c.setter
77 def c(self, value):
78 self._native.c = value
79
80 @d.setter
81 def d(self, value):
82 self._native.d = value
83
84 @e.setter
85 def e(self, value):
86 self._native.e = value
87
88 @f.setter
89 def f(self, value):
90 self._native.f.packed = value
91 self._native.f.unused = 0
92
93 @h.setter
94 def h(self, value):
95 self._native.h = value
96
97 @l.setter
98 def l(self, value):
99 self._native.l = value
100
101 @sp.setter
102 def sp(self, value):
103 self._native.sp = value
104
105 @af.setter
106 def af(self, value):
107 self.a = value >> 8
108 self.f = value & 0xFF
109
110 @bc.setter
111 def bc(self, value):
112 self.b = value >> 8
113 self.c = value & 0xFF
114
115 @de.setter
116 def de(self, value):
117 self.d = value >> 8
118 self.e = value & 0xFF
119
120 @hl.setter
121 def hl(self, value):
122 self.h = value >> 8
123 self.l = value & 0xFF