mirror of
https://github.com/jtauber/applepy.git
synced 2025-02-17 08:30:51 +00:00
simplified screen address to col/row translation based on code from 2006
This commit is contained in:
parent
80f221b0f5
commit
55d700fc68
31
applepy.py
31
applepy.py
@ -41,29 +41,11 @@ class Memory:
|
|||||||
return self.read_byte(address) + (self.read_byte(address + 1) << 8)
|
return self.read_byte(address) + (self.read_byte(address + 1) << 8)
|
||||||
|
|
||||||
def write_screen(self, address, value):
|
def write_screen(self, address, value):
|
||||||
address_hi, address_lo = divmod(address, 0x100)
|
base = address - 0x400
|
||||||
|
hi, lo = divmod(base, 0x80)
|
||||||
if address_lo < 0x28:
|
row_group, column = divmod(lo, 0x28)
|
||||||
a = 0x01
|
row = hi + 8 * row_group
|
||||||
b = 0x00
|
assert row_group != 3 # @@@
|
||||||
elif address_lo < 0x50:
|
|
||||||
a = 0x09
|
|
||||||
b = 0x28
|
|
||||||
elif address_lo < 0x80:
|
|
||||||
a = 0x11
|
|
||||||
b = 0x50
|
|
||||||
elif address_lo < 0xA8:
|
|
||||||
a = 0x02
|
|
||||||
b = 0x80
|
|
||||||
elif address_lo < 0xD0:
|
|
||||||
a = 0x0A
|
|
||||||
b = 0xA8
|
|
||||||
else:
|
|
||||||
a = 0x12
|
|
||||||
b = 0xD0
|
|
||||||
|
|
||||||
x = address_lo - b
|
|
||||||
y = 2 * (address_hi - 0x04) + a
|
|
||||||
|
|
||||||
c = chr(0x20 + ((value + 0x20) % 0x40))
|
c = chr(0x20 + ((value + 0x20) % 0x40))
|
||||||
|
|
||||||
@ -76,8 +58,7 @@ class Memory:
|
|||||||
else:
|
else:
|
||||||
attr = curses.A_DIM
|
attr = curses.A_DIM
|
||||||
|
|
||||||
if x < 0x28:
|
self.win.addch(row, column, c, attr)
|
||||||
self.win.addch(y, x, c, attr)
|
|
||||||
|
|
||||||
|
|
||||||
class CPU:
|
class CPU:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user