From 853918f4b7e9f3724be4d71014689c18c28fe61e Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 17 May 2024 09:17:47 +0300 Subject: Add hotspot analysis --- atk16_emu/peripherals.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'atk16_emu/peripherals.py') diff --git a/atk16_emu/peripherals.py b/atk16_emu/peripherals.py index 3bc0443..9b65410 100644 --- a/atk16_emu/peripherals.py +++ b/atk16_emu/peripherals.py @@ -1,5 +1,5 @@ import pygame -import sys +from sys import stdout import os import random from .memory import RAM, ROM @@ -8,18 +8,19 @@ from typing import Callable IRQ_LINE_KEYBOARD = 0 class Peripherals: - def __init__(self, set_irq_line: Callable[[int], None]): + def __init__(self, set_irq_line: Callable[[int], None], request_quit: Callable[[], None]): pygame.init() self.graphics = Graphics() self.keyboard = Keyboard(set_irq_line=set_irq_line) self.terminal = Terminal() + self.request_quit = request_quit self.set_irq_line = set_irq_line def step(self): for event in pygame.event.get(): if event.type == pygame.QUIT: - sys.exit(0) + self.request_quit() elif event.type == pygame.KEYDOWN: self.keyboard.set_key_down(event.key) elif event.type == pygame.KEYUP: @@ -242,4 +243,4 @@ class Terminal: def write(self, s: int): print(chr(s), end="") - sys.stdout.flush() + stdout.flush() -- cgit v1.3