Skip to content
Lesson 12 of 13

Step 1 of 5 · Reading · ~2 min

Read

Production

Quirks: COSMAC vs Modern

If you write CHIP-8 emulators, you will be asked exactly one question: "why does game X work on Octo but not yours?" The answer is almost always a quirk.

CHIP-8 was implemented and re-implemented over four decades, and at each step the implementors had different ideas about edge cases. ROMs were written against specific interpreters and now depend on those quirks. There is no "right" behavior — there are programmable defaults.

The four big quirks

OpcodeCOSMAC (original)Modern (SCHIP / CHIP-48)
8XY6shift VY right, store in VXshift VX right in place
8XYEshift VY left, store in VXshift VX left in place
FX55store V0..VX, then I += X+1store V0..VX, I unchanged
FX65load V0..VX, then I += X+1load V0..VX, I unchanged
DXYNwraps in-sprite (some impls)clips in-sprite, wraps coords
BNNNpc = NNN + V0(SCHIP) BXNN: pc = XNN + V[X]

How to expose them

python

Then in your opcode handlers:

python

How to debug a failing ROM

When a ROM fails on your emulator but works on Octo:

  1. Visual glitch (sprites in the wrong place, ghosting on the edges)
    • DXYN wrap vs clip.
  2. Score / arithmetic wrong
    • Shift quirk. Test with LD V0, 0x80; SHR V0, V1 and see if V0 becomes 0 or 64 depending on V1.
  3. Game corrupts memory after a save/load
    • FX55/FX65 increment-I quirk.
  4. Game jumps to nonsense address after a 'select level' menu
    • BNNN vs BXNN.

Three sources for finding the right setting:

  • Timendus' chip8-test-suite ROM prints a quirks scorecard to the display.
  • Octo's compatibility database tags well-known ROMs with their required quirks.
  • Game-specific forums and emulator README files.

The takeaway

A CHIP-8 emulator that ships only one quirk set runs maybe 60% of the library. A toggleable emulator with COSMAC/SCHIP presets runs ~99%. The toggle is the feature.

Up nextBeyond CHIP-8Production

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…