Fix the sound timer, sprite wrapping under clip quirks, the quirked jump address, and Fx0A waiting for release - #51
Open
HarianthK wants to merge 1 commit into
Conversation
…ump address, and Fx0A waiting for release Four things, found by running Timendus' test suite through the CPU with no window. The sound timer only counted down while the delay timer was above zero, a one character slip, so a program that set the sound timer on its own buzzed forever. With clip quirks on, a sprite whose start lay past the edge was not drawn at all. The starting position always wraps around the screen; clipping only decides what happens to the part that hangs over. This is the ERR2 the quirks test showed on its clipping row. With jump quirks on, Bxnn added only the low byte of the address to the register, so jump0 0xE00 with vE at 0x9C landed at 0x09C rather than 0xE9C. The whole twelve bit address counts, including the nibble that names the register. The existing unit test encoded the low byte reading and is updated, with the quirks test's jump row as the reference. Fx0A resumed when a key went down. The original hardware moves on when the key is released, which the keypad test checks for. The key is now remembered on press and the register written on release, with a KEYUP handler in the emulator loop. With these the quirks test passes every row as SUPER-CHIP and XO-CHIP, and every row but display wait as CHIP-8, which was never implemented. The opcode, flags and keypad tests pass. Five unit tests added, and all 140 pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran Timendus' test suite through
Chip8CPUwith no window, using a small stand-in for pygame and a plain screen object, and found four things. Each is fixed here with a unit test.Sound timer.
decrement_timershadself.sound -= 1 if self.delay > 0 else 0, so the sound timer only counted down while the delay timer was running. A program that sets only the sound timer buzzed forever. One character.Clipping. With
clip_quirkson, a sprite whose start position lay past the edge was not drawn at all, because the position was only wrapped when clipping was off. The start always wraps around the screen; clipping only decides what happens to the part that hangs over. That is theERR2the quirks test shows on its clipping row. Fixed in bothdraw_normalanddraw_extended.Quirked jump. With
jump_quirkson,Bxnnadded only the low byte of the address toVx, sojump0 0xE00withvEat0x9Clanded at0x09Cinstead of0xE9C. The whole twelve bit address counts; its top nibble both names the register and is part of the address. The existing unit test encoded the low byte reading, so it changes with this, with the jump row of the quirks test as the reference.Fx0A. Execution resumed when a key went down. The original hardware moves on when the key is released, and the keypad test's third check reportsNOT RELEASEDfor this. The key is now remembered on press (decode_keypress_and_continue) and the register written on release (decode_keyrelease_and_continue, called from a newKEYUPbranch in the emulator loop).Results
logic_quirks,clip_quirks)shift,index,jump,clip)0x09CFx0Apython -m unittestpasses, 140 tests including the five new ones. The harness that ran the suite is a throwaway and not included.