2727WHITE = 0xFFFFFFFF
2828BLACK = 0
2929TIMER_DELAY = 1 / 60 # in seconds... about 60 hz
30- FRAME_TIME_EXPECTED = 1 / 500 # for limiting VM speed
30+ FRAME_TIME_EXPECTED = 1 / 500 # for limiting VM speed
3131ALLOWED_KEYS = ["0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" ,
3232 "a" , "b" , "c" , "d" , "e" , "f" ]
3333
@@ -102,7 +102,7 @@ def play_sound(self) -> bool:
102102
103103 # Draw a sprite at *x*, *y* using data at *i* and with a height of *height*
104104 def draw_sprite (self , x : int , y : int , height : int ):
105- flipped_black = False # were any pixels where this was drawn flipped from white to black?
105+ flipped_black = False # did drawing this flip any pixels from white to black?
106106 for row in range (0 , height ):
107107 row_bits = self .ram [self .i + row ]
108108 for col in range (0 , SPRITE_WIDTH ):
@@ -116,7 +116,7 @@ def draw_sprite(self, x: int, y: int, height: int):
116116 flipped_black = True
117117 new_pixel = new_bit ^ old_bit # Chip 8 draws by XORing, which flips everything
118118 self .display_buffer [px , py ] = WHITE if new_pixel else BLACK
119- self .v [0xF ] = 1 if flipped_black else 0 # set flipped flag in register for collision detection
119+ self .v [0xF ] = 1 if flipped_black else 0 # set flipped flag for collision detection
120120
121121 def step (self ):
122122 # we look at the opcode in terms of its nibbles (4 bit pieces)
0 commit comments