-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
1,539 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
import pygame | ||
import RAM | ||
|
||
pygame.init() | ||
resolution = (256, 256) | ||
scale = 4 | ||
width, height = resolution[0] * scale, resolution[1] * scale | ||
screen = pygame.display.set_mode((width, height)) | ||
clock = pygame.time.Clock() | ||
|
||
def init_display(scale): | ||
resolutionX = 256 | ||
resolutionY = 256 | ||
width = resolutionX * scale | ||
height = resolutionY * scale | ||
|
||
def refresh(): | ||
pygame.init() | ||
screen = pygame.display.set_mode((width, height)) | ||
# clock = pygame.time.Clock() | ||
return screen | ||
|
||
|
||
def update_display(screen, scale): | ||
x = RAM.read(252, False) | ||
y = RAM.read(253, False) | ||
r = RAM.read(249, False) | ||
g = RAM.read(250, False) | ||
b = RAM.read(251, False) | ||
mode = RAM.read(254) | ||
if mode == 1: | ||
# print("set color") | ||
pixel_color = (r, g, b) | ||
pixel_rect = pygame.Rect(x * scale, y * scale, scale, scale) | ||
pygame.draw.rect(screen, pixel_color, pixel_rect) | ||
elif mode == 2: | ||
# print("reset color") | ||
pixel_color = (0, 0, 0) | ||
pixel_rect = pygame.Rect(x * scale, y * scale, scale, scale) | ||
pygame.draw.rect(screen, pixel_color, pixel_rect) | ||
elif mode == 3: | ||
print("fill screen with color data") | ||
|
||
def start(): | ||
running = True | ||
while running: | ||
for event in pygame.event.get(): | ||
if event.type == pygame.QUIT: | ||
running = False | ||
pygame.display.flip() | ||
|
||
# print("fill color") | ||
pixel_color = (r, g, b) | ||
# pixel_rect = pygame.Rect(0, 0, 256 * scale, 256 * scale) | ||
# pygame.draw.rect(screen, pixel_color, pixel_rect) | ||
screen.fill(pixel_color) | ||
RAM.write(254, 0, True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Port | ||
import pygame | ||
|
||
# Mapping keys to their respective bitmasks | ||
# key_bitmasks = { | ||
# pygame.K_w: 0b10000000, | ||
# pygame.K_a: 0b01000000, | ||
# pygame.K_s: 0b00100000, | ||
# pygame.K_d: 0b00010000, | ||
# pygame.K_UP: 0b00001000, | ||
# pygame.K_LEFT: 0b00000100, | ||
# pygame.K_DOWN: 0b00000010, | ||
# pygame.K_RIGHT: 0b00000001, | ||
# } | ||
|
||
key_bitmasks = { | ||
pygame.K_SPACE: [0, 0b10000000], | ||
pygame.K_BACKQUOTE: [0, 0b01000000], | ||
pygame.K_1: [0, 0b00100000], | ||
pygame.K_2: [0, 0b00010000], | ||
pygame.K_3: [0, 0b00001000], | ||
pygame.K_4: [0, 0b00000100], | ||
pygame.K_5: [0, 0b00000010], | ||
pygame.K_6: [0, 0b00000001], | ||
pygame.K_7: [1, 0b10000000], | ||
pygame.K_8: [1, 0b01000000], | ||
pygame.K_9: [1, 0b00100000], | ||
pygame.K_0: [1, 0b00010000], | ||
pygame.K_MINUS: [1, 0b00001000], | ||
pygame.K_EQUALS: [1, 0b00000100], | ||
pygame.K_q: [1, 0b00000010], | ||
pygame.K_w: [1, 0b00000001], | ||
pygame.K_e: [2, 0b10000000], | ||
pygame.K_r: [2, 0b01000000], | ||
pygame.K_t: [2, 0b00100000], | ||
pygame.K_y: [2, 0b00010000], | ||
pygame.K_u: [2, 0b00001000], | ||
pygame.K_i: [2, 0b00000100], | ||
pygame.K_o: [2, 0b00000010], | ||
pygame.K_p: [2, 0b00000001], | ||
pygame.K_LEFTBRACKET: [2, 0b00000001], | ||
pygame.K_RIGHTBRACKET: [3, 0b10000000], | ||
pygame.K_BACKSLASH: [3, 0b00100000], | ||
pygame.K_a: [3, 0b00010000], | ||
pygame.K_s: [3, 0b00001000], | ||
pygame.K_d: [3, 0b00000100], | ||
pygame.K_f: [3, 0b00000010], | ||
pygame.K_g: [3, 0b00000001], | ||
pygame.K_h: [4, 0b10000000], | ||
pygame.K_j: [4, 0b01000000], | ||
pygame.K_k: [4, 0b00100000], | ||
pygame.K_l: [4, 0b00010000], | ||
pygame.K_SEMICOLON: [4, 0b00001000], | ||
pygame.K_QUOTE: [4, 0b00000100], | ||
pygame.K_z: [4, 0b00000010], | ||
pygame.K_x: [4, 0b00000001], | ||
pygame.K_c: [5, 0b10000000], | ||
pygame.K_v: [5, 0b01000000], | ||
pygame.K_b: [5, 0b00100000], | ||
pygame.K_n: [5, 0b00010000], | ||
pygame.K_m: [5, 0b00001000], | ||
pygame.K_COMMA: [5, 0b00000100], | ||
pygame.K_PERIOD: [5, 0b00000010], | ||
pygame.K_SLASH: [5, 0b00000001], | ||
pygame.K_BACKSPACE: [6, 0b10000000], | ||
pygame.K_TAB: [6, 0b01000000], | ||
pygame.K_RETURN: [6, 0b00100000], | ||
pygame.K_LSHIFT: [6, 0b00010000], # Combined Shift | ||
pygame.K_RSHIFT: [6, 0b00010000], # Combined Shift | ||
pygame.K_UP: [6, 0b00001000], | ||
pygame.K_LEFT: [6, 0b00000100], | ||
pygame.K_DOWN: [6, 0b00000010], | ||
pygame.K_RIGHT: [6, 0b00000001], | ||
pygame.K_CAPSLOCK: [7, 0b10000000], | ||
pygame.K_LCTRL: [7, 0b01000000], # Combined Control | ||
pygame.K_RCTRL: [7, 0b01000000], # Combined Control | ||
pygame.K_LALT: [7, 0b00010000], # Combined Alt | ||
pygame.K_RALT: [7, 0b00010000], # Combined Alt | ||
pygame.K_ESCAPE: [7, 0b00001000], | ||
pygame.K_PRINTSCREEN: [8, 0b00000100], | ||
pygame.K_INSERT: [8, 0b00000010], | ||
pygame.K_DELETE: [8, 0b00000001], | ||
} | ||
|
||
|
||
def handle_key_event(event): | ||
if event.type == pygame.KEYDOWN: | ||
if event.key in key_bitmasks: | ||
index, bitmask = key_bitmasks[event.key] | ||
Port.Ports[index] ^= bitmask # Use the index and bitmask | ||
|
||
elif event.type == pygame.KEYUP: | ||
if event.key in key_bitmasks: | ||
index, bitmask = key_bitmasks[event.key] | ||
Port.Ports[index] &= ~bitmask # Use the index and bitmask |
Oops, something went wrong.