Skip to content

Fix the quirked jump address, wrap a sprite's start under clip quirks, and make Fx0A wait for release - #61

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 I found in Chip8Python (craigthomas/Chip8Python#51) are in this port, found by reading the same routines. Each is fixed with a unit test.

Quirked jump. With jump_quirks 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. The existing test_jump_index_plus_value_jump_quirks encoded the low byte reading, so it changes with this, with the jump row of Timendus' quirks test as the reference.

Clipping. With clip_quirks 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 draw_normal_sprite and draw_extended_sprite.

Fx0A. Execution resumed on SDL_KEYDOWN. The original hardware moves on when the key is released, and the keypad test's third check reports NOT RELEASED for this. The key is now remembered on key down in a new keypress_pending global and the register written on the matching SDL_KEYUP.

Not touched: Fx29 uses the whole register as a character number, and test_load_sprite_index_integration asserts that with 0x10, so I have left it as you have it.

I could not link SDL2, SDL2_mixer and CUnit on this machine, so the changed files have been compiled with -fsyntax-only against the SDL 2.30 headers but the test binary has not been run here; the CI run on this pull request is its first. In the Python port the same three fixes took the quirks test from a crash on the SUPER-CHIP path and ERR2 on clipping to every row passing, and the keypad test from NOT RELEASED to ALL GOOD.

…, and make Fx0A wait for release

With jump quirks on, Bxnn added only the low byte of the address to Vx,
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 jump row of Timendus' quirks test as the reference.

With clip quirks on, a sprite whose start lay past the edge was not
drawn at all. 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.

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.

Three unit tests added; one updated.
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