written by - Akshat Joshi
Sometime back, I set myself a crazy constraint:
Load only one thing at boot - A Pong game that fits in one floppy disk sector — 512 bytes.
Why would I build this?
I have played with Operating Systems and their workings by customizing them and tweaking their behavior. But this was about pushing constraints to the extreme. Can I have an OS which just loads one PONG GAME ?
The challenge
- No operating system.
- No drivers.
- No libraries.
- Just raw x86 assembly, BIOS interrupts, and the video memory at 0xB800.
The boot sector is the first 512 bytes a computer loads from disk. It has to end with the magic bytes 0x55 0xAA — leaving only 510 bytes for actual code.
I wanted to see if I could fit:
- Player paddle (W/S keys)
- CPU opponent
- Ball with velocity
- Scoring
- Color toggle (C key)
- Full reset (R key)
After learning about Operating systems and the bootup flow, I finally managed to get a pong game running 😄
How it works!
The game runs in 80x25 text mode (VGA mode 03h) using BIOS interrupt 10h.
Everything is drawn directly into video memory (0xB800) with stosw — of course no graphics libraries here.
Controls
W / S — Move your paddle
C — Cycle paddle and midline colors
R — Reset game (reboots the sector)
It’s a deterministic ball-tracking logic. It checks the ball’s Y position every frame:
- If ball is above paddle → move up
- If below → move down
- Never goes off-screen
Simple. Fast. Fits in 510 bytes.
Demo run
Key Technical Highlights
- Video Memory Direct Access Used ES:DI = 0xB800:0000 and rep stosw to clear screen in one instruction.
- Efficient Positioning - imul di, [playerY], 160 → converts row to video offset (80 cols × 2 bytes per char).
- Real-Time Input - BIOS int 0x16 with ah=1 (peek) → non-blocking keyboard check.
- Physics & Collision - Ball velocity stored in single bytes (ballVeloX, ballVeloY). Reversed on wall/paddle hit using neg byte.
- Delay Loop - Used BIOS timer at 0x46C for frame pacing — no hlt, no busy-wait burn.
- Color Cycling - C key increments drawColour by 0x10 → rotates through 16 background colors.
The Full Code
The entire game is in one file: pong.asm
Publicly available on GitHub:
https://github.com/akshat666/-bootponggame
Run It Yourself
- Clone the repo
- Assemble with NASM
- Run in QEMU (or burn to USB and boot on old hardware)