mirror of
https://github.com/jtauber/applepy.git
synced 2024-12-29 15:29:16 +00:00
added HIRES graphics support based on code from ghewgill: 5aa8ca2caa
This commit is contained in:
parent
8f3b640393
commit
e37c4dcbcd
60
applepy.py
60
applepy.py
@ -133,14 +133,16 @@ class Display:
|
|||||||
|
|
||||||
def update(self, address, value):
|
def update(self, address, value):
|
||||||
if self.page == 1:
|
if self.page == 1:
|
||||||
start = 0x400
|
start_text = 0x400
|
||||||
|
start_hires = 0x2000
|
||||||
elif self.page == 2:
|
elif self.page == 2:
|
||||||
start = 0x800
|
start_text = 0x800
|
||||||
|
start_hires = 0x4000
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if start <= address <= start + 0x3FF:
|
if start_text <= address <= start_text + 0x3FF:
|
||||||
base = address - start
|
base = address - start_text
|
||||||
hi, lo = divmod(base, 0x80)
|
hi, lo = divmod(base, 0x80)
|
||||||
row_group, column = divmod(lo, 0x28)
|
row_group, column = divmod(lo, 0x28)
|
||||||
row = hi + 8 * row_group
|
row = hi + 8 * row_group
|
||||||
@ -173,19 +175,43 @@ class Display:
|
|||||||
pixels[x][y + 1] = (0, 0, 0)
|
pixels[x][y + 1] = (0, 0, 0)
|
||||||
pixels[x + 1][y + 1] = (0, 0, 0)
|
pixels[x + 1][y + 1] = (0, 0, 0)
|
||||||
else:
|
else:
|
||||||
lower, upper = divmod(value, 0x10)
|
if not self.high_res:
|
||||||
|
lower, upper = divmod(value, 0x10)
|
||||||
for dx in range(14):
|
|
||||||
for dy in range(8):
|
for dx in range(14):
|
||||||
x = column * 14 + dx
|
for dy in range(8):
|
||||||
y = row * 16 + dy
|
x = column * 14 + dx
|
||||||
pixels[x][y] = self.lores_colours[upper]
|
y = row * 16 + dy
|
||||||
for dy in range(8, 16):
|
pixels[x][y] = self.lores_colours[upper]
|
||||||
x = column * 14 + dx
|
for dy in range(8, 16):
|
||||||
y = row * 16 + dy
|
x = column * 14 + dx
|
||||||
pixels[x][y] = self.lores_colours[lower]
|
y = row * 16 + dy
|
||||||
|
pixels[x][y] = self.lores_colours[lower]
|
||||||
del pixels
|
del pixels
|
||||||
|
|
||||||
|
elif start_hires <= address <= start_hires + 0x1FFF:
|
||||||
|
if self.high_res:
|
||||||
|
base = address - start_hires
|
||||||
|
row8, b = divmod(base, 0x400)
|
||||||
|
hi, lo = divmod(b, 0x80)
|
||||||
|
row_group, column = divmod(lo, 0x28)
|
||||||
|
row = 8 * (hi + 8 * row_group) + row8
|
||||||
|
|
||||||
|
if self.mix and row >= 160:
|
||||||
|
return
|
||||||
|
|
||||||
|
if row < 192 and column < 40:
|
||||||
|
|
||||||
|
pixels = pygame.PixelArray(self.screen)
|
||||||
|
for b in range(7):
|
||||||
|
c = 0xFFFFFF if (value & (1 << b)) else 0
|
||||||
|
x = 2 * (column * 7 + b)
|
||||||
|
y = 2 * row
|
||||||
|
pixels[x][y] = c
|
||||||
|
pixels[x + 1][y] = c
|
||||||
|
pixels[x][y + 1] = c
|
||||||
|
pixels[x + 1][y + 1] = c
|
||||||
|
del pixels
|
||||||
|
|
||||||
|
|
||||||
class RAM:
|
class RAM:
|
||||||
@ -301,6 +327,8 @@ class Memory:
|
|||||||
self.ram.write_byte(address, value)
|
self.ram.write_byte(address, value)
|
||||||
if 0x400 <= address < 0x800 and display:
|
if 0x400 <= address < 0x800 and display:
|
||||||
self.display.update(address, value)
|
self.display.update(address, value)
|
||||||
|
if 0x2000 <= address < 0x5FFF and display:
|
||||||
|
self.display.update(address, value)
|
||||||
|
|
||||||
|
|
||||||
class Disassemble:
|
class Disassemble:
|
||||||
|
Loading…
Reference in New Issue
Block a user