Skip to content

Fix the quirked jump address, wrap the sprite start when clipping, and make Fx0A wait for release - #81

Open
HarianthK wants to merge 1 commit into
craigthomas:mainfrom
HarianthK:fix-jump-clip-and-keywait
Open

HarianthK wants to merge 1 commit into
craigthomas:mainfrom
HarianthK:fix-jump-clip-and-keywait

Conversation

@HarianthK

Copy link
Copy Markdown

The same three things as in craigthomas/Chip8Python#51 and craigthomas/Chip8C#61, found by reading the same routines in this port. Each has a unit test, and ./gradlew test passes (204 tests).

Quirked jump. With jumpQuirks on, Bxnn added only the low byte of the address to Vx, so jump0 0xE00 with vE at 0x9C landed at 0x09C instead of 0xE9C. The whole twelve bit address counts; its top nibble both names the register and is part of the address. testJumpToRegisterPlusValueJumpQuirks encoded the low byte reading, so it changes with this, with the jump row of Timendus' quirks test as the reference.

Clipping. With clipQuirks on, 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 the ERR2 the quirks test shows on its clipping row. Fixed in both drawNormalSprite and drawExtendedSprite. The screen mock in setUp now reports 64 by 32 so the wrap has something to wrap around; without that the existing testDrawSpriteInvoked divides by zero.

Fx0A. Execution resumed as soon as getCurrentKey reported a key down. The original hardware moves on when the key is released, and the keypad test's third check reports NOT RELEASED for this. The key seen going down is now remembered in keypressPending and the register written once isKeyPressed reports it up. Reading the key state rather than the last key pressed also means a press from before the wait began cannot satisfy it.

Not touched: Fx29 uses the whole register as a character number, as in the other two ports, so I have left it as you have it.

Checked that each new test fails on the current main and passes with the fix.

…d make Fx0A wait for release

With jumpQuirks on, Bxnn added only the low byte of the address to Vx,
so BE00 with vE at 0x9C landed at 0x09C instead of 0xE9C. The whole
twelve bit address counts. The existing test for the quirked jump
encoded the low byte reading and changes with this.

With clipQuirks on, a sprite whose start lay past the edge was not
drawn at all, because the position was only wrapped when clipping was
off. The start always wraps; clipping only applies to the overhang.

Fx0A moved on as soon as a key went down. The original hardware waits
for the key to come up. The key seen going down is remembered and the
instruction completes once it is released, read from the key state so
a press from before the wait cannot satisfy it.

Four tests added, one updated. The screen mock now reports a size so
the wrap has something to wrap around.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant