Add a 640x480 two-colour graphics mode; start in white
The graphics memory doubles as 640x480 at a bit a pixel (port 38), four pixels to an entry, plotted by read-modify-write, in two colours from port 39 (0 transparent). BASIC gets SCREEN 0 / SCREEN 1 [,set[,clear]]; a plain fill (as every game does) returns to 320x240 and BASIC follows. The text now starts in white (SW5:4 = 00; 10 is green). The README is rewritten to stand on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71fd403294
commit
bda9bb67b6
13 files changed
+2985
-2680
No files matched your search
+22
-6
@@ -47,6 +47,8 @@ class Board(RV32):
|
||||
self.frame_at = -1000
|
||||
self.joy = 0
|
||||
self.gfx = bytearray(320 * 240)
|
||||
self.hgfx = bytearray(640 * 480) # 640x480 mode (port 38): 0 or 1 a pixel
|
||||
self.g_cols = 0x0F
|
||||
self.gxv = self.gyv = 0
|
||||
self.spr = [[0, 0, 0, 0] for _ in range(32)] # x, y, shape, ctl
|
||||
self.sel = 0
|
||||
@@ -70,24 +72,37 @@ class Board(RV32):
|
||||
if p == 0x88:
|
||||
return self.joy
|
||||
if p == 0x33:
|
||||
if self.g_hires:
|
||||
return self.hgfx[self.gyv * 640 + self.gxv] if self.gxv < 640 and self.gyv < 480 else 0
|
||||
return self.gfx[self.gyv * 320 + self.gxv] if self.gxv < 320 and self.gyv < 240 else 0
|
||||
if p == 0x34:
|
||||
return 0
|
||||
if p == 0x38:
|
||||
return self.g_hires
|
||||
return 0xFF
|
||||
|
||||
def io_out(self, port, v):
|
||||
p = port & 0xFF
|
||||
if p == 1:
|
||||
self.text.append(v)
|
||||
elif p == 0x30: self.gxv = (self.gxv & 0x100) | v
|
||||
elif p == 0x31: self.gxv = (self.gxv & 0xFF) | (v & 1) << 8
|
||||
elif p == 0x32: self.gyv = v
|
||||
elif p == 0x30: self.gxv = (self.gxv & 0x300) | v
|
||||
elif p == 0x31:
|
||||
self.gxv = (self.gxv & 0xFF) | (v & 3) << 8
|
||||
self.gyv = (self.gyv & 0xFF) | (v & 4) << 6
|
||||
elif p == 0x32: self.gyv = (self.gyv & 0x100) | v
|
||||
elif p == 0x33:
|
||||
if self.gxv < 320 and self.gyv < 240:
|
||||
if self.g_hires:
|
||||
if self.gxv < 640 and self.gyv < 480:
|
||||
self.hgfx[self.gyv * 640 + self.gxv] = int(v != 0)
|
||||
elif self.gxv < 320 and self.gyv < 240:
|
||||
self.gfx[self.gyv * 320 + self.gxv] = v & 15
|
||||
self.gxv = (self.gxv + 1) & 0x1FF
|
||||
self.gxv = (self.gxv + 1) & 0x3FF
|
||||
elif p == 0x34:
|
||||
self.gfx[:] = bytes([v & 15]) * (320 * 240)
|
||||
if self.g_hires and v & 0x80:
|
||||
self.hgfx[:] = bytes([int(v & 15 != 0)]) * (640 * 480)
|
||||
else:
|
||||
self.gfx[:] = bytes([v & 15]) * (320 * 240)
|
||||
self.hgfx[:] = bytes(640 * 480)
|
||||
if not v & 0x80:
|
||||
for s in self.spr: s[3] &= ~1
|
||||
self.scroll_x = self.scroll_y = 0
|
||||
@@ -97,6 +112,7 @@ class Board(RV32):
|
||||
self.scroll_x = (self.scroll_x & 0xFF) | (v & 1) << 8
|
||||
self.border = bool(v & 2)
|
||||
elif p == 0x37: self.scroll_y = v - 240 if v >= 240 else v
|
||||
elif p == 0x39: self.g_cols = v
|
||||
elif p == 0x70: self.sel = v & 31
|
||||
elif p == 0x71: self.xst = (self.xst & 0x100) | v
|
||||
elif p == 0x72: self.xst = (self.xst & 0xFF) | (v & 1) << 8
|
||||
|
||||
Reference in new issue
Block a user