11. Input and menus
How the game reads the keyboard and the mouse, which keys each screen accepts, the pull-down menus and the command line. Most of it is ordinary; a few details (key latches, the two keyboard modes) matter for getting the feel of the controls right.
Two ways of reading the keyboard
The game switches between two keyboard modes:
- Key table (flight, level introduction, level completed, death screen). The game takes over the keyboard interrupt itself and keeps a table with one entry per key. When a key goes down its entry gets two marks: "held now" and a latch ("was pressed"). When it goes up only "held now" is removed; the latch stays until the code that uses the key clears it. So a tap shorter than a frame is never lost, and each reader decides whether it wants "held" (steering, throttle) or "pressed once" (missile, radar zoom). Keys typed here never reach the normal keyboard buffer.
- Typed keys (title, instructions and high scores, start-level menu, lobby, name and initials entry, help). The game reads ordinary key presses one at a time from the keyboard buffer, like any text program.
| Key (flight) | Read as | Effect |
|---|---|---|
| ↑ ↓ ← → (arrow keys and keypad arrows alike) | held | steering (keyboard mode only) |
| either Shift / either Ctrl | held | throttle up / down |
| Space | held, and latched | fire while held (every 3rd frame); a tap shorter than a frame still fires once; the mouse button works the same |
| Enter, Caps Lock | once per press | missile (single player) / cloak on-off (multiplayer); Enter also accepts on the level and death screens |
| keypad + / − | once per press | radar zoom |
| F2 | once per press | pause (single player; ignored in multiplayer) |
| Esc | once per press | leave, with the score set to 0 (both modes): single player to the high-score check, multiplayer to the name screen, a spectator to the lobby |
In flight no other key does anything (PrtSc still prints the screen). Holding a key makes the keyboard repeat it, so a held Enter or keypad + repeats at the keyboard's repeat rate.
- Latches survive screens. Only Esc and Enter are cleared when the level introduction starts, so Space, Caps Lock or keypad +/− pressed there act in the first frame of the flight.
- Pause (F2) freezes the picture with no "paused" text; the timer and the sound keep running. Holding F2 past the key-repeat delay ends the pause by itself D.
- Alt is always taken by the game and never used, which also blocks Ctrl+Alt+Del while the game runs D.
- In a browser, a held key repeats
keydown; set the latch again on each repeat to match the keyboard repeat described above.
The mouse
- Switched on at start only if a mouse driver answers (then "Normal Mouse" is the default).
- Menus: an arrow pointer anywhere on the screen. Where it selects differs by screen: on the title screen a click anywhere accepts the current choice; on the start-level menu its height picks the level (and the arrow keys are then ignored); in the lobby it selects the slot under it; on the instructions and high-score screens only the menu bar reacts to clicks. The exact hit areas are in the comments of src/screens.c, src/players.c and src/menu.c.
- Flight: a small box pointer kept inside most of the view (x 44 to 587, y 28 to 313); its offset from the centre sets the turn rates (chapter 4); the left button fires.
- Reversed Mouse mirrors the vertical direction in flight: pushing the mouse forward lowers the nose, like a flight stick (with Normal Mouse it lifts it). The box pointer is drawn at the mirrored height, so it moves opposite to your hand.
- The right button does nothing. The button works like a key: a click is latched until used.
The screens and their keys
| Screen | Keys |
|---|---|
| title | ↑/↓ or mouse choose Single or Multi; Enter/click accept; Esc quits the program at once. If the network is missing: an error message, then Esc quits. |
| instructions ⇄ high scores (alternating every 11 s) | Enter start; Esc back to the title; F1 help; the menu bar |
| select start level | ↑/↓ (levels 1–8, always starting at 1) or mouse height; Enter play; Esc back |
| level introduction, level completed | Enter/click continue; Esc ends the game (after a level the score, bonus included, still counts for the high-score table) |
| death screen | input ignored for 64 frames; then Enter/click restart (or straight to the initials after a top-ten score). Esc, even in the first 64 frames, leaves with the score set to 0. |
| lobby | ←/→ move between slots (wrapping); Enter/click take a free slot (an occupied one is ignored); letters are menu hotkeys; F1 help; Esc title |
| name entry | up to 15 characters (space allowed); Backspace/Del erase; Enter fly; Esc back to the lobby. It also comes back after every Esc in flight, and shows the scores. |
| initials entry | up to 3 characters (no space); Backspace/Del erase; Enter or Esc store |
| help page | Esc, Enter or a click closes it |
- The name editor always starts at length 0: the first key replaces an old name, and Backspace cannot shorten an old name D.
- A click that closes the help page stays latched. If the pointer is still on the right half of the menu bar, the click opens the help page again at once; in the lobby, with the pointer off the bar, it takes the selected slot D.
- In the lobby there is an invisible spot at the left edge of the screen, level with the upper half of the slot row: clicking there makes you a spectator. It comes from the code reading one entry past the end of a list of slot positions O.
- Choosing a mouse setting without a mouse is allowed: the start-level menu then sticks at level 4, and in flight the parked pointer sits in the dead zone, so you cannot steer at all D.
The menu bar
The instructions/high-score screens and the lobby show a pull-down menu bar at the top. Each title has a hotkey letter, shown underlined: Game, Controls, Sound, Graphics and, in the lobby, Universe.
- The hotkey opens a menu; with a menu open, ↑/↓ move, ←/→ switch menus, Enter chooses and closes, Space chooses and keeps it open, Esc closes. With the mouse: click a title, hover an item, click to choose; a click on the right half of the bar opens the help page.
- Options are radio buttons with a ▶ mark at the current choice.
| Menu | Items | Effect |
|---|---|---|
| Game | Start new game (single) / Spectate current game (multi); Exit this mode | like Enter (or spectate); like Esc |
| Controls | Keyboard, Normal Mouse, Reversed Mouse | steering device |
| Sound | None, PC Speaker | chapter 10 |
| Graphics | Lines, Polygons | chapter 9 (also 64 or 256 stars, 12 or 38 explosion sparks) |
| Universe (lobby only) | 1 … 8 | switch to another universe (chapter 8) |
Nothing is saved: the options last until the program ends. The only file the game ever writes is the high-score table, HISCORES.DAT.
Starting and stopping
- Command line: NETWARS /M uses greys and white for a monochrome monitor; /? or /H print a short usage text and exit. Only the character after the slash counts, in either case (/mono works as /M); anything else is ignored.
- Defaults at start: mouse if a driver answers, otherwise keyboard; PC speaker on; Lines mode on computers older than a 386, Polygons otherwise; universe 1; the high-score table from the file, or the built-in one (1000 to 10,000).
- Start-up checks: no EGA/VGA → "This software requires an EGA or VGA display."; not enough memory for the draw list → "Not enough memory".
- Quitting from the title screen (Esc) or the network-error screen: back to text mode, no goodbye. A failed universe change also ends the program, without a message.
Keep a key table with "held" and "latched" per key, filled by keydown/keyup,
and let each reader clear the latch it consumes; that reproduces exactly when actions fire. Use
typed-key events for text entry. Offer the original keys but avoid browser shortcuts (chapter 13).
Remembering the options between sessions (local storage) is a harmless improvement.