GERLA.CC

← Devlog

· Mega Drive

Mega Drive: assembly where needed, C where it counts

The Mega Drive build uses no SGDK, no libraries, but it's not all assembly, and that's a deliberate choice. Startup and vectors are 68k assembly (crt0.s), the title screen is pure asm; game logic and rendering are C (game_logic.c, main.c), compiled by gcc into 68000 machine code that goes into the ROM. Why C? First: it's standard 16-bit era practice. The 68000 was designed with compilers in mind, and loads of commercial Mega Drive games were C with assembly only in the hot spots. It's not a modern shortcut. Second: it's the trick that makes the port verifiable. I don't have a 68000 emulator to test the logic with, but the exact same C source also compiles natively on the Mac, where I play it frame by frame against the reference model: that's where the bit-exact guarantee across 1583 frames comes from. In pure 68k assembly I could only write code and hope. I watched the fake floor crumble by counting vanishing purple pixels: 4756, 4592, 4428. That's where the satisfaction lives. The dual-target method, and the other Mega Drive bugs, are in the behind the scenes.

All of the devlog