0. How to read this document
What NetWars is, what this document is for, and the few conventions you need before chapter 1.
What NetWars is
NetWars is a 3-D space shooter. You sit in the cockpit of a small ship floating in empty space, see the world in perspective through the front window, and fight. In single player you defend six "pods" against waves of alien ships. In multiplayer up to four people on a local network fly in the same space and shoot each other.
The game was written by Edward Hill (copyright 1989, 1992) and published by Novell in 1993 as release 2.06. It runs under MS-DOS on an IBM PC with EGA or VGA graphics (the PC graphics cards of the time): 640 × 350 pixels, 16 colours, the PC speaker for sound, and Novell's IPX protocol (the office-network protocol of the day; a modern version would use the internet instead). Everything you see is drawn by the program itself, line by line and polygon by polygon; there is no 3-D hardware.
Why study it? Two things make it interesting. It draws a 3-D world in real time on a 1993 PC with nothing but integer arithmetic. And its multiplayer has no server and no host: every player's computer is equal, and people can join and leave a running game at any moment.
What this document is for
It explains how the game works: the ideas, the rules and the numbers behind them, in an order that builds up understanding step by step. The aim is that after reading it you could write your own NetWars in any language with any framework, and it would play like the original: the same ships and models, the same physics, the same weapons, opponents and rules, the same way the multiplayer game behaves.
What it does not try to do:
- Reproduce the original bit for bit. The original computes everything with whole numbers in a 16-bit program (its basic numbers run from −32768 to 32767, with no fractions). A new version can use ordinary floating-point numbers with decimals, a higher resolution and a smoother frame rate. Where the whole-number details change how the game plays, the document says so: for example a fast shot can jump past a ship between two frames (chapter 6), and "is it near?" is often checked with a cube rather than a sphere (chapter 3).
- Talk to the original over the network. The text explains what players exchange and why, not the exact bytes on the wire. (The byte layout is in the repository's docs/network-protocol.md if you want it.)
- Show program code. Instead it points to the reconstructed source files where you can look the details up.
Where the facts come from
The original source code of NetWars is not available. This repository rebuilt it from the program file: every byte of the original NETWARS.EXE has been turned back into C and assembly source that compiles to exactly the same file. So src/ is a faithful, compilable copy of the original program. The names in it are ours (the author's were lost), and the low-level parts are assembly language, so it is a reference to look things up in, not easy reading. On top of that the game was run in an emulator (DOSBox-X) and watched: screenshots, recordings, network captures. Facts in this document come from those two places, and each important one carries a mark:
| Mark | Meaning |
|---|---|
| O observed | Read directly in the program's code or data, or seen in a recorded run. |
| D derived | Worked out from observed facts by reasoning or arithmetic (for example, what a formula gives for a certain input), but not watched happening. |
| H hypothesis | A plausible guess, for example about why the author did something. Treat with care. |
| ? unknown | Not known. The document says so instead of guessing. |
Sentences without a mark are O or D; a mark is written as a small badge after a claim where it matters, like this H. File references look like src/main.c and are links into the repository. The links work in a local copy of the repository (which is private). The document itself was tested: a reader with nothing but these chapters rebuilt seven subsystems from them, and the results were compared with the original code (tools/doccheck/); every gap found was written back into the chapters. Numbered observations such as "runtime #35" point to the lab notebook docs/runtime-baseline.md; you never need to open it, it is there for checking.
What you need
School maths is enough: coordinates, a little trigonometry (sine and cosine). Vectors, fixed-point numbers, projection and the rest are explained when they appear. To see the game itself, look at the screen picture in chapter 1, or run original/extracted/netwars.exe in the DOSBox-X emulator (the repository's tools/dosbox_session.py does this).
How the chapters are ordered
From the outside in:
- Chapter 1 describes the game as a player meets it. If you have never played NetWars, start there; every later chapter refers back to it.
- Chapters 2 and 3 give the two foundations everything else stands on: the program is a loop that redraws the screen many times a second, and the world is a space of very large integer coordinates with orientations stored as three arrow-like vectors.
- Chapters 4 to 7 are the simulation: how the ship moves, what objects exist, how shooting and collisions work, how the aliens behave and how a single-player game is scored.
- Chapter 8 is multiplayer: what each player's computer sends, who decides what, and why no server is needed.
- Chapter 9 is the renderer: how a list of 3-D models becomes a picture.
- Chapters 10 to 12 cover sound, input and menus, and the bugs and oddities.
- Chapter 13 brings it together for a modern rebuild, in a browser, with friends joining by a link, and lists what the original could have done better.
- Appendices: where the data (models, tables, texts) lives, a table of all constants, and the open questions.
In a hurry to build? Read chapters 1, 2 and 3, then 13, and dip into the others as needed.
Boxes like these appear throughout:
Advice for your own version: what must stay the same to keep the feel of the game, and what you are free to change.
Something the original does that looks like a mistake or a surprise. Decide for each one whether your version keeps it.
Words used throughout
Each of these is explained properly where it first matters; this list is for looking them up.
| Word | Meaning here |
|---|---|
| frame | One pass of the main loop: read input, move everything, draw one picture, show it. Most rules are "per frame" (chapter 2). |
| tick | One beat of the PC's timer, 18.2 times a second (about 55 ms). Used to cap the frame rate and to time things (chapter 2). |
| frame, frame rate | One picture; frames per second (FPS) is how many are drawn each second. |
| world unit | The unit of distance used in this document (chapter 3 defines it). Pods sit 1000 units from the centre; a new alien appears 16384 units away; a laser shot flies 1024 units per frame (plus the ship's own speed) for 24 frames. |
| vector | An arrow: a direction and a length, written as three numbers (x, y, z). Positions, speeds and directions are all vectors. |
| axes | Three arrows of length 1 fixed to a ship (or the camera): forward, right and up (mathematicians call such a set a basis). Turning the ship means turning these arrows (chapter 3). |
| camera | The point and direction the picture is drawn from; in NetWars always your own ship's cockpit. |
| Q14 | A fixed-point number: a whole number of which the last 14 bits are the fraction, so 16384 means 1.0 and 8192 means 0.5 (chapter 3). |
| distance exponent | A rough, power-of-two measure of how near something is, which the game uses instead of exact distances: one step up means about half as far (chapter 3). |
| shields | Your ship's health: 32 at most; a hit takes 1 or 2. |
| body | The record the game keeps for any solid moving thing: an alien, a missile, a pod, a satellite, another player's ship (chapter 5). |
| shot | A laser bolt. It has no model and no steering, so the game keeps it in a separate, smaller record (chapter 6). A missile, by contrast, is a body that steers toward its target. |
| pod | One of six stationary objects the player must protect in single player (chapter 7). |
| satellite | A pick-up that drifts in space; flying into it gives extra shields, missiles, thrust or fire power (chapter 7). |
| universe | One of 8 independent multiplayer games that can run on the same network at once (chapter 8). |
| slot | One of the 4 player positions in a universe (PLAYER 1 to 4); a fifth role is the spectator, who only watches (chapter 8). |
| peer, peer-to-peer | A peer is another player's computer in the same universe. Peer-to-peer means the computers talk to each other directly, with no server in the middle (chapter 8). |
| model | A ship's shape: points (vertices) and the flat faces between them (chapter 9). |
| draw list | The list of faces collected during a frame, sorted by distance and then drawn far to near, so nearer faces paint over farther ones (the "painter's algorithm", chapter 9). |