Bringing My College Nibbles Game Back to Life in the Browser
- m68k
- 68000
- assembly
- nibbles
- emulation
- react
- ansi
- retrocomputing
Rediscovering Nibbles
When I came across Gianluca Rea's browser-based M68K interpreter, I immediately thought of a Nibbles clone I had written for a college assembly class. The source was still on GitHub, and here was a Motorola 68000 interpreter running in a browser. Could I use it to get my old game running again?
The original Nibbles 68000 title screen and difficulty selection.
1 / 2That question started my m68k-interpreter fork. Gianluca's editor and interpreter gave me a foundation; my first goal was to load the assembly and get the snake moving. Nibbles made a useful test: menus, keyboard input, movement, food, and collisions all depended on the program running continuously and updating its screen. Each visible action would tell me whether several parts of the interpreter were working together.
Recreating its serial terminal
Nibbles was originally designed to run through a serial TTY terminal. The assembly sent ANSI control sequences to position the cursor, change colors, clear the display, and draw individual characters. Moving the snake meant erasing one cell and painting another while the terminal retained the rest of the arena. The screen itself was part of the environment the game expected.
The original source included routines for a TTY serial interface alongside simulator input and output. Running it in the browser meant recreating enough of that environment for the drawing routines and keyboard handling to work. Executing the instructions alone would leave the game without the terminal it depended on.
That led me to build react-retro-display-tty-ansi-ascii, a React component that interprets ANSI output and maintains a grid of character cells, cursor positions, and colors. It also needed to render the block and border characters that formed the playing field. I published it as a separate package so other projects could use the same display. You can explore it in the Storybook.
Getting the game running
With the terminal connected, I could see the title screen, test the difficulty menu, and follow the snake across the arena. Those were useful checkpoints: a misplaced character or an unresponsive menu gave me something concrete to investigate in the assembly and runtime.
Keyboard input needed a reliable path from the browser into the running program. The execution loop also had to give the browser time to process input and paint updates. Getting those pieces to cooperate made the game playable while keeping the surrounding interface responsive.
The movement, food generation, score, and collision decisions still came from the original assembly program. Seeing those routines drive the game again was the milestone I had wanted when I started. You can play Nibbles in your browser, or open the IDE to inspect the source and machine state alongside it.
Building an IDE around a running program
A running game gave me a reason to improve the tools around the interpreter. Investigating a movement or collision problem meant moving between source code, registers, memory, and terminal output. I grouped the register displays more clearly and made condition flags easier to follow, so I could connect a comparison in the source to the branch it caused.
Dockable panels let me arrange the workspace around that investigation. While playing, I could give the terminal most of the space and keep the source beside it. While debugging, I could bring registers, memory, and execution controls into view together. Resizing and rearranging the panels also made the IDE more comfortable on a laptop screen.
Breakpoints, stepping, and watches made it possible to pause where a decision happened and inspect the values involved. For Nibbles, that meant following a movement routine or checking a collision at the relevant instruction. Together, these changes made the IDE much more useful for understanding a program as it ran.
Growing beyond Nibbles
The same environment grew to support graphics, sound, and trainer-style hardware panels. Easy68K-compatible services give assembly programs access to drawing and audio, while LEDs, switches, buttons, and seven-segment displays provide interactive hardware examples. A program can draw a shape, play a sound, or react to a switch, with dedicated panels showing the result. These services sit around the CPU and give its instructions visible effects.
I also expanded the CPU implementation through the full MC68000 instruction set, including addressing modes, condition flags, and exception handling. The generated instruction inventory and conformance report document coverage across 116 instruction forms. Nibbles exercises the system as a whole; the automated instruction tests cover cases the game may never reach.
That coverage describes functional instruction behavior. Timing and bus-cycle differences remain documented, so a working instruction set does not establish cycle-exact reproduction of a physical machine. Keeping that distinction clear helps explain what the browser interpreter can demonstrate and where its limits remain.
I eventually improved the game itself, too. The original assumed fixed terminal dimensions, but browser windows and docked panels change size. The runtime now passes the terminal's available rows and columns to the game, which uses them to calculate its layout and redraw through ANSI commands.
That lets the borders, menus, and playing area adapt to the available space while preserving the character-based presentation. Recreating the original environment had given me a way back into the code; responsive sizing was a chance to give that old code a capability it had never needed on a fixed display.
Where it led
An old college project gave the interpreter a practical direction. Getting Nibbles running called for a terminal, input handling, debugging tools, and a workspace suited to a live program. Each improvement helped the game and made the environment useful for other assembly projects.
I now have a game I can open in a browser, a reusable React terminal, and a place to keep experimenting with 68000 assembly. The interpreter source and original Nibbles source are available if you want to explore how the pieces fit together.