How NetWars Works Chapter 16 of 21, plus appendices

16. Model and asset catalogue

Everything NetWars draws that is data rather than code: the 22 three-dimensional models, the 16 colours, the 8 × 8 font, the star and explosion directions and the three bitmap pictures. Each model can be turned with the mouse and drawn the way the original draws it, in Polygons or Lines mode. The numbers on this page are computed from the repository's assets/ files, so you can check your own copy of the data against them.

Chapter 9 explained how a model becomes a picture. This chapter is the reference you need when you load the data into your own program: what each model is for, how big it really is in the world, which colours it uses, and what is special about it. Words used here: a model is a list of corner points (vertices) and flat faces; a world unit is the distance unit of chapter 3 (pods sit 1000 units from the centre): a position is three 64-bit numbers, and one world unit is one step of the middle 16-bit word of each; model units are the small numbers stored in a model file (at most 96 in size); the scale of a model says how many world units one model unit is.

Where the data lives and what it looks like

The program keeps all 22 models in one block of its data segment, each in a fixed-size record of 0x4A6 = 1190 bytes O. The repository has each model twice, with the same values (tests/test_assets.py checks this): as C source that the byte-identical build uses, src/data/model_<name>.h, and as a readable text file, assets/models/<name>.model. The model names are ours; the original names were lost.

Exact rules: one model record
OffsetSizeField
0x00016-bitscale: one model unit = 2scale world units. Stored as 0 in every record; the game raises it at start-up (below).
0x00216-bitnumber of vertices in use (at most 48)
0x00416-bitnumber of faces in use (at most 64)
0x00648 × 3 × 16-bitvertices (x, y, z): x along the object's right axis, y along its up axis (which the camera draws downward, chapter 3), z along its forward axis. Signed whole numbers, all within −96..96. Unused slots are zero.
0x12664 × 7 × 16-bitfaces: colour (EGA index 0..15), n (2..5), then 5 vertex numbers (the first n are used). n = 2 is a line face (a single line: antennas, spikes, outlines); n ≥ 3 is a flat convex polygon. Polygon corners are listed clockwise as seen from the outside, as they appear on the screen: that order decides which side is the front (back-face culling).

The text form (.model), line by line:

# NetWars 2.06 model "pod" — DGROUP:86D0, 0x4A6-byte record ...   (comments start with #;
# ...                                                               the first names the record address)
scale 0                     the stored scale (always 0)
vertices 12                 number of vertices in use
v      0      0     72      one line per vertex: x y z, in vertex-number order from 0
...
faces 14                    number of faces in use
f colour  5 n 4 idx  0  1  4  0  0    colour, n, then all 5 index slots (only the first n count)
...

Unused vertex and face slots are left out (in the record they are zero). Text after # is a comment.

The scale is the only value the game changes. At start-up, before the title screen, main (src/main.c) sets it to 1 for the four player ships, the four aliens, the mutant and the pod, and to 2 for title model A; all other models keep 0 O. So ships, aliens and pods are twice as big in the world as their numbers say, and satellites and missiles are not. The scale also counts in every distance test that uses the object's distance exponent (chapter 3: the exponent starts at the scale, so a scale-1 object is "near" at twice the distance): a collision with you (exponent ≥ 7), a missile reaching its target (≥ 6), the switch to the far "+" mark (exponent < 0, chapter 9), and the hit sizes of shots (chapter 6). The radar removes it again: blips do not depend on the scale (chapter 15). The cards below give each model's size after this scaling.

For a rebuild

Load the .model files as they are and apply the scales of the table below yourself (do not edit the files: they mirror the original data). Keep each face one flat colour from the 16-colour palette, keep the corner order (it is your front-face rule), and draw line faces as 1-pixel lines. Title model B also needs the start-up shift described on its card.

The models

Each card shows a model turning slowly about its up axis. Drag on the picture to turn it yourself (sideways: about the up axis; up and down: tip it forward or back). The picture is a 360 × 260-pixel window of the original 640 × 350 screen, drawn with its tall pixels, using the original rules from chapter 9:

Projection: screen x = 512 · x ÷ z, screen y = 384 · y ÷ z, both truncated toward zero (chapter 9). The distance from the eye is chosen per card so that the model fills the window; in the game it varies. Our polygon fill is a simple scan-line fill and may differ from the original (src/polygon.c) by a pixel at the edges.

All models:

Player ships (4)

One ship per multiplayer slot: the table of ship models (g_ship_models, src/globals.c) is indexed by slot. In flight you never see your own ship (the view is from the cockpit); you see the other players' ships. Ships 1 and 2 are green, ships 3 and 4 blue (their face colours, O), all four with some red (4) faces.

Aliens (4) and the mutant

Single player only. The alien type table (g_alien_types, src/tables.c) gives each type its model; their behaviour is chapter 7. The same models spin on the instructions screen (one row of four) and on the level introduction (one row per type).

Pod

Satellites (5)

Satellites are the pick-ups (chapter 7). Every new satellite takes the next kind in a fixed cycle: a counter (g_satellite_counter) starts at 0 when the program starts, is increased by one before each satellite and is never reset, and the counter modulo 4 picks 1 → thrust, 2 → fire power, 3 → shields, 0 → missiles or cloak. So the first satellite of a program run is thrust, then fire power, shields, missiles/cloak, thrust …, and a new game continues the cycle where the last one stopped; kind 2 is missiles in single player and cloak in multiplayer, with a model each, so there are five satellite models for four kinds (satellite_spawn, src/satellite.c) O. All keep scale 0.

Missiles (3)

Enemy missiles come in two kinds; the alien's type decides which (the missile field of the type table: Pirates launch kind 1, Commanders kind 2; Fighters and Guardians never launch, enemy_missile_launch in src/aliens.c). All three missiles keep scale 0 and explode with 12 sparks.

Title logo (2 models, and how they are combined)

The title screen (game_mode_menu, src/screens.c) shows a turning 3-D logo 2500 world units ahead, under the "NetWars" bitmap. It is built from two models: title model A is a diagonal half of the striped Novell "N" square: drawn once as stored and once turned upside down, the two halves make the full square. Each frame the game draws A, then B, then A again rolled half a turn about its forward axis (x → −x, y → −y), all in one depth-sorted draw list, so the two copies of A make the full square O. The object turns by 16/2048 of a turn per frame about its up axis. The last card shows the three parts together, as on the title screen; a recorded title screen shows the same picture (runtime #1, evidence/runtime/boot_t003.0.png) O.

Unused: "Net" and "Wars"

Two models that nothing in the program refers to O: flat outline letters spelling Net and Wars, red (12) fills with yellow (14) outlines, all z = 0. A routine that draws a model flat, ignoring z (draw_model_2d, src/render.c), is never called either; it was probably meant for them H. They are turned here with the 3-D rules like any other model; seen from behind, the filled faces are culled and only the outlines remain.

All models at a glance

Sizes are the extent along each model axis (right × up × forward) in world units, after the start-up scale: (largest − smallest coordinate) × 2scale. "Lines" counts the line faces among the faces. Addresses are the record offsets in the data segment (DGROUP).

ModelDGROUPScaleVertices Faces (lines)ColoursSize (world units)
Quirks

The 16 colours

The game runs in EGA/VGA mode 10h with the standard 16-colour palette, which the BIOS sets when the mode is switched on; the game never changes it (a palette routine in the program is never called, chapter 12) O. Each channel has four levels, 0x00, 0x55, 0xAA and 0xFF; on a VGA card the same colours come from the DAC values 0, 21, 42, 63 of 63. Colour 6 is brown (not dark yellow): the EGA default palette gives it half green.

Monochrome (/M)

The /M command-line switch does not change the palette. It replaces colour numbers as they are drawn O:

WhatNormalWith /M
Model faces (Polygons mode) and line facesown colourcolour > 8 → 15, colour < 8 → 7, 8 stays 8 (so black 0 would become light grey; no model uses 0)
Polygon edges in Lines modebright version (c < 8 → c + 8, then 8 → 7)15
Explosion sparks14 (even), 12 (odd)15
Laser shots15, powered 1415 (no powered colour)
Ring of an exploding shot (a hit)1215
The colour roles of the interface (g_colors, chapter 15)4, 12, 10, 10, 14, 15, 13, 10, 12, 14, 12, 14 8, 7, 15, 7, 15, 15, 7, 7, 7, 15, 15, 7

The twelve roles, in order: frames and scales, instruments, highlight / locked target, alien, enemy missile, satellite, pod, collision flash, hit flash, powered-hit flash, logo faces, logo extrusion (src/globals.c, src/main.c).

The 8 × 8 font

All text on the screen (menus, messages, numbers on the instruments) is drawn with one font of 256 characters, 8 × 8 pixels each, stored in the program (tbl_font8x8, src/graphics.asm; readable form assets/fonts/font8x8.txt). Each glyph is 8 bytes, one per row from the top; bit 7 is the leftmost pixel. The character codes follow the IBM PC character set (code page 437): 0x03 is a heart, 0xB3 a box-drawing bar, 0xDB a full block, 0xE1 the German ß D. The program does not use the BIOS font for its own text, although it loads it O. Point at a character to see its code.

 

Exact rules: drawing text (draw_text)

The large digits on some screens and the letters on the gauges use a second font made of lines (26 letters and 10 digits, draw_vector_char in src/effects.c, tables in src/tables.c); chapter 15 covers it.

Star directions

The star field is a table of 256 fixed directions (g_stars, src/globals.c): vectors in Q14 (16384 = 1.0) of length very nearly 1, in world axes. Stars are infinitely far away: they turn with your ship but never move when you fly O. The map below shows all 256 as seen from the centre of the world: across, the angle around the y axis (0 = the +z direction); up and down, the angle from the x–z plane, with +y drawn downward as the game's camera does. The first 64 (the only ones Lines mode uses) are bright, the others grey; the dashed frame is roughly the screen when you look along +z.

 

Exact rules: drawing the stars (draw_starfield, src/screens.c)

Explosion spark directions

An explosion is a cloud of small discs (sparks) flying apart from the exploding object's centre (draw_explosion, src/effects.c). Each spark follows one fixed direction from the table g_particle_dirs (src/globals.c): 70 small vectors of length 18.5 to 20; the first six point along ±x, ±y and ±z. An object uses the first N of them: N = 38 for aliens, pods and other players' ships in Polygons mode, 12 in Lines mode, and always 12 for missiles and satellites. Entries 38 to 69 are never used D. The left picture shows the directions seen along z; the right one plays an explosion with the original rules, seen from a distance you choose.

 

Exact rules: one explosion frame (nearby case)

The bitmaps

Three 1-bit pictures, each 600 × 100 pixels, are stored in their own far data segments (src/bmp_face.c, src/bmp_extr.c, src/bmp_dos7.c; readable as assets/bitmaps/*.pbm). Each starts with its width and height (16-bit words), then the rows, 75 bytes each, bit 7 = leftmost pixel. draw_bitmap paints the 1-bits in one colour and leaves the 0-bits alone, so two bitmaps can be laid over each other in two colours.

The title logo

The title screen draws the letter faces in colour 12 (light red), then the extrusion in colour 14 (yellow) on top, both with their top-left corner at (−300, −174) from the screen centre, i.e. screen pixel (20, 1); draw_bitmap rounds x down to a whole byte, so the picture starts at pixel column 16 D. Below, drawn with tall pixels as on a 4:3 monitor:

The two parts separately (letter faces, then extrusion), in white:

The unused wordmark

The third bitmap is the "Novell DOS 7" wordmark; no code refers to it O (chapter 12: a credits screen that never runs). Drawn here in white:

 

For a rebuild

Everything on this page can be loaded straight from assets/: models as text, the font as a picture per glyph, the bitmaps as PBM images (any image library reads them). The star and spark tables are only in src/globals.c; this page's data file, catalogue-data.js, holds them in JavaScript form. The Novell logo models and the Novell pictures are Novell's artwork: a published rebuild should not use them without permission (chapter 12); the "Net" and "Wars" models and the NetWars bitmaps are the game's own logo.