refactor: port to python3

This commit is contained in:
shokre 2023-10-21 05:23:40 +02:00
parent 04a34eaf44
commit 2ec18cc353
4 changed files with 9 additions and 4 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# -*- coding: utf8 -*-
import pygame, numpy, sys, datetime

View file

@ -136,7 +136,9 @@ class CPU(object):
self.sp = (self.sp + 1) & 0xFF
return self.get_byte(256 + self.sp)
def stack_push_word(self, val): map(self.stack_push, [(val >> 8) & 0xFF, val & 0xFF])
def stack_push_word(self, val):
self.stack_push((val >> 8) & 0xFF)
self.stack_push(val & 0xFF)
def stack_pop_word(self): return self.stack_pop() + (self.stack_pop() << 8)
###########################################################################

View file

@ -20,7 +20,7 @@ _kbd = {
def listener(event, cpu):
if event.type in [pygame.KEYDOWN, pygame.KEYUP]:
for address, keycodes in _kbd.iteritems():
keys = map(pygame.key.get_pressed().__getitem__, keycodes)
for address, keycodes in _kbd.items():
keys = list(map(pygame.key.get_pressed().__getitem__, keycodes))
cpu.memory[address] = ~numpy.dot(keys, [16, 32, 64, 128][:len(keys)]) & 0xFF

3
requirements.txt Normal file
View file

@ -0,0 +1,3 @@
numpy==1.26.1
pygame==2.5.2
Wave==0.0.2