aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_emu/peripherals.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-12 19:01:52 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-04-12 19:01:52 +0300
commitd993f522cfd091d35e538a8c3f77bc233a560bf2 (patch)
tree0cab4973e13b5972a4b1038ebf45c3910135d003 /atk16_emu/peripherals.py
parent4f78086920cd4e2cee6d970decaee7025875f2a9 (diff)
Add initial TPU emu
Diffstat (limited to 'atk16_emu/peripherals.py')
-rw-r--r--atk16_emu/peripherals.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/atk16_emu/peripherals.py b/atk16_emu/peripherals.py
new file mode 100644
index 0000000..dc35e3e
--- /dev/null
+++ b/atk16_emu/peripherals.py
@@ -0,0 +1,59 @@
+import pygame
+
+class TPU:
+ def __init__(self):
+ self.surface: pygame.Surface | None = None
+ self.text_mem = []
+
+ def frame(self):
+ # TODO
+ pass
+
+class Graphics:
+ def __init__(self):
+ pygame.init()
+ pygame.display.init()
+
+ self.surface = None
+ self.clock = pygame.time.Clock()
+ self.tpu = TPU()
+ self.active_picture_unit: TPU | None = None
+
+ def activate_tpu(self):
+ if self.active_picture_unit:
+ pygame.display.quit()
+
+ pygame.display.init()
+ self.surface = pygame.display.set_mode((320, 240))
+ self.active_picture_unit = self.tpu
+ self.active_picture_unit.surface = self.surface
+
+ def activate_ppu(self):
+ raise NotImplementedError()
+
+ def deactivate(self):
+ self.active_picture_unit = None
+ pygame.display.quit()
+
+ def step(self):
+ if self.active_picture_unit:
+ self.active_picture_unit.frame()
+
+ pygame.display.flip()
+ self.clock.tick(60)
+
+class DummyGraphics:
+ def __init__(self):
+ pass
+
+ def activate_tpu(self):
+ pass
+
+ def activate_ppu(self):
+ pass
+
+ def deactivate(self):
+ pass
+
+ def step(self):
+ pass