diff --git a/README.md b/README.md index b2607c7..9fa0d77 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,6 @@ which maps to 7 8 9 E A 0 B F -Sound ------ -Not yet implemented - Games ----- Get some [here](http://www.pong-story.com/chip8/) or [here](https://github.com/dmatlack/chip8/tree/master/roms) diff --git a/sipsi-8.py b/sipsi-8.py index 63bf03b..bbbb38a 100644 --- a/sipsi-8.py +++ b/sipsi-8.py @@ -357,7 +357,15 @@ def tick_timers(): # The timer should tick down at 60Hz delay_timer -= 1 - # TODO: Do sth about the sound timer + # Play a sound using pyglet if we have a non-zero sound timer + # It will run asynchronously from the other parts, which means it + # won't experience slowdown similarily to the delay timer + # Unsure if this is good or bad + if sound_timer > 0: + # sound_timer is in the unit of 1/60th of a second, while + # Square takes length in seconds + pyglet.media.procedural.Square(sound_timer/60).play() + sound_timer = 0 def advance_interpreter(dt): global cpu_speed @@ -610,7 +618,6 @@ def initialize_screen(): def initialize_timers(): global delay_timer, sound_timer - # Tick timers down at 60Hz delay_timer = 0 sound_timer = 0