1# BootInvaders
2
3A functional Space Invaders clone implemented entirely within a 512-byte x86
4boot sector. Written in assembly (FASM) for the BIOS real mode.
5
6> [!IMPORTANT]
7> This is for educational purposes, demonstrating how to make a bootloader do
8> interesting stuff.
9
10## Technical Specifications
11
12- **Architecture:** x86 (16-bit Real Mode)
13- **Memory Address:** Loaded at `0x0000:0x7C00` by the BIOS.
14- **Display:** VGA Mode 13h (320x200, 256-color linear framebuffer).
15- **Video Memory:** Direct writes to segment `0xA000`.
16- **I/O & Interrupts:**
17 - `int 0x10`: Video services for mode setting and character output.
18 - `int 0x16`: Keyboard services for polling and reading scan codes.
19 - `int 0x1A`: Clock services used for frame timing and pseudo-random seed.
20 - `0x3DA`: VGA Status Register polling for vertical retrace synchronization.
21
22## Features
23
24- **Double Buffering Simulation:** Clears and redraws every frame synchronized
25 with the vertical retrace to prevent flickering.
26- **Physics & Collision:** AABB (Axis-Aligned Bounding Box) collision detection
27 for bullets, enemies, and player.
28- **Procedural Respawn:** Uses the system timer's lower bits to calculate the
29 next enemy X-coordinate.
30- **Score Tracking:** Real-time score display using a custom decimal-to-string
31 conversion routine.
32
33## Building and Running
34
35### Prerequisites
36- [FASM](https://flatassembler.net/) (Flat Assembler)
37- [QEMU](https://www.qemu.org/) (for emulation)
38
39### Commands
40```bash
41# Compile the source to a 512-byte binary
42make
43
44# Run the binary in QEMU as a raw disk image
45make run
46```
47
48## Controls
49- **Left Arrow:** Move Left
50- **Right Arrow:** Move Right
51- **Space Bar:** Fire Bullet
52- **Any Key:** Restart (on Game Over)
53
54## Resources
55
56- [x86 Instruction Set Reference](https://c9x.me/x86/)
57- [OS Dev Wiki](https://wiki.osdev.org/Expanded_Main_Page)
58- [Interrupt Jump Table (Ralf Brown's List)](https://www.ctyme.com/intr/int.htm)