Master the fundamental concepts of emulation through this focused micro-challenge.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksPassing opcode tests is how emulator authors prove correctness. Community ROMs exercise every instruction and expose COSMAC VIP quirks modern interpreters handle differently.
Popular ROMs:
Known divergences:
For example, a failing shift test often means your \`8XY6\` updates the wrong register.
Validation workflow:
When a ROM fails, isolate one opcode family at a time using Timendus subtests. Fixing shift behavior before jump behavior avoids chasing multiple bugs from one failing display pattern.
This exercise asks you to document test ROM usage and quirk tables. You will explain how to validate your emulator against community suites and reconcile VIP versus modern behavior.
You will use the same mental model here when reading production interpreter source later in the track. Sketch one concrete input on paper, predict the outcome, then confirm with code. That discipline catches logic errors early and makes debugging far faster when you extend the implementation in follow-on tasks.
Real CHIP-8 test ROMs (Timendus' quirks test, corax89's opcode test) exist because "CHIP-8" means several slightly different machines. Add the five classic quirk switches and the platform profiles to your interpreter. Then build a test harness: it loads small probe programs, runs each to its jump-to-self halt, and checks registers, memory and pixels against expectations, printing PASS/FAIL like a ROM test report.
| quirk | on | off |
|---|---|---|
vf_reset | 8xy1/8xy2/8xy3 set VF = 0 after the operation | VF untouched |
memory | Fx55/Fx65 leave I = I + x + 1 | I unchanged |
shifting | 8xy6/8xyE shift Vx in place | Vx = Vy shifted (the original COSMAC VIP) |
jumping | Bxnn jumps to xnn + Vx | nnn + V0 |
clipping | sprites clip at the right/bottom edge | sprites wrap around |
The profiles:
| profile | vf_reset | memory | shifting | jumping | clipping |
|---|---|---|---|---|---|
vip | on | on | off | off | on |
schip | off | off | on | on | on |
xochip | off | on | off | off | off |
modern (the default) | off | off | on | off | on |
Everything else is the CHIP-8 core from the previous task: flags written after the result, the font at 0x050, the program at 0x200, and the timers ticking every 10 instructions.
cLoading…
# starts a comment. Expectation items:
V3=0A (hex register)I=302M300=07 (the memory byte at hex address 300)px=X,Y (the pixel is lit) and dark=X,Y (the pixel is unlit), in decimalcLoading…
cycle limit 10000 reached, …) is a FAIL with that reason.; . Values print as %02X, and I as %03X.unknown profile Xunknown quirk setting X Ybad expectation X (the item is skipped)bad program word: Xtest NAME: missing expect (at the end of input; it counts as a failed test)P/T tests passed.Input:
cLoading…
Output:
cLoading…
Hidden tests cover the schip and xochip profiles, toggling single quirks, sprite wrap versus clip, abnormal halts, and bad profile, quirk and expectation input.