dosbox3d · the multiplayer layer · November 2026

TIE Us Together: TIE Fighter Co-op

Related: the making of Wing Commander Multiplayer An 11 year journey to play DOS Wing Commander together From memory dumps in 2015 to a browser and a room code in 2026.
Watch on YouTube

Play it in your browser

While the Falcon, Tydirium Shuttle, Snowspeeder, and sometimes even the Y-Wing had both a pilot and co-pilot, the majority of vehicles in Star Wars had a solo pilot (you could argue that the Falcon also had a Solo pilot, as expounded upon in that self-referential Solo: A Star Wars Story scene no one asked for). With the introduction of X-Wing vs TIE Fighter and myriad follow-on clones and modifications, including Star Wars: Squadrons and even Star Wars Battlefront, multiplayer combat has been both common and enjoyable. However, the one aspect that has been missing for me is pure co-op multiplayer for the most memorable early Star Wars entry in the genre: TIE Fighter.

The charming magic of the pixelated Concourse, the cutscenes, and the arrogant Imperial officials as your commanders and colleagues immersed players in a galaxy far, far away in a way that I haven't seen perfectly reproduced. With the technology that broadcast the Wing Commander action across the network, it seemed plausible the same ideas could also work in TIE Fighter. However, TIE Fighter had challenges that required a new kind of sync.

Requirements

TIE Fighter's missions were very large, spread across kilometers. The original X-Wing vs TIE Fighter used a deterministic simulation and kept clients in sync exactly. This shook out a number of nondeterminism bugs for that title, but it required the network to operate at exactly physics-speed. This may have been a good option for LAN play with full control of the game engine. This project has neither: it adds multiplayer to TIE Fighter itself, the earlier game, where those nondeterminism bugs were never fixed.

For the chosen solution, it was useful to look at the requirements of this project:

Sections

01Linking together two battles

The solution was modeled on the Wing Commander multiplayer approach with a couple of key enhancements. Each pilot has the full simulation running on their own machine. The data being sent falls into four categories:

The overall design uses Lobbylink to bind together two browsers, giving them a peer-to-peer link. All the logic for how to apply the data from the wire to the game and from the game out to the wire exists in the modified DOSBox itself. The code for this resides in the TIE layer (src/cpu/wcnet_tie*.cpp). The patched DOSBox executable, compiled to WASM, runs in the browser and executes the unmodified game (Z_TIE__.EXE in the GOG release) under DOS/4GW.

HOST · a browser page or nativethe web pageroom · public lobby · chat · voice · controllersDOSBox (wasm in the page, or native)CPU core: is this instruction watched?TIE layer · src/cpu/wcnet_tie*.cppfindersessionowners + ratespuppetstrampolineflight controlscockpits + voicesoverlay + chatZ_TIE__.EXE under DOS/4GWcode 0x1FA000 · data 0x2A5000 (linear)its code never written: data and CPU state onlyGUEST · a browser pagethe web pageroom · public lobby · chat · voice · controllersDOSBox (wasm in the page, or native)CPU core: is this instruction watched?TIE layer · src/cpu/wcnet_tie*.cppfindersessionowners + ratespuppetstrampolineflight controlscockpits + voicesoverlay + chatZ_TIE__.EXE under DOS/4GWcode 0x1FA000 · data 0x2A5000 (linear)its code never written: data and CPU state onlyreliable, orderedbest effort, unorderedlobbylink: WebRTCdata channels(TCP for the test rigs)the host relays guestsTieHelloTieFrame (TieCraft × n)TieShot · TieHitTieEvent · TieOwnersTiePresence · Chat
How two machines coordinate a co-op session.

Here are two players' screens at the same moment of the new Z-95 Combat Chamber challenge (two Z-95 Headhunters against the Empire's own craft). Both targeting displays show the same TIE Bomber (T/B): 0.27 km from the host, 0.45 km from the guest.

The host's cockpit on the left and the guest's on the right, the same fight from two places, each targeting display showing T/B Red
The host (left) and the guest (right), the same frame of the same fight.
Note on the Z-95 Screenshot
  • The DOSBox mod creates the Z-95 challenge by altering every craft in the mission.
  • A table of equivalents swaps Rebel craft for Imperial ones and back.
  • The Z-95 cockpit is cut from the gunboat's at run time.
  • The Combat Chamber is treated identically to the campaign battles, allowing 2-3 pilots at once.

02Similarities to and changes from Wing Commander multiplayer

The multiplayer design was crafted for Wing Commander I and II.

TIE Fighter uses the same plumbing, including:

However, the 32-bit TIE Fighter has substantially more complex missions, with many flight groups and ships in the arena. Simply broadcasting every craft every frame would cost too much. To function, TIE Fighter needed the following additions:

With these additional features, the same multiplayer technique translated to this game and became more general for the next set of DOS games. The following table illustrates the differences between these two engines and which features were unique to each:

Wing Commander I and IITIE Fighter
The program16-bit real mode, overlays32-bit protected mode under DOS/4GW, one flat address space
Found byits segmentsa scan of memory for data only it has
Hooks keyed onCS:IPthe low word of EIP, then the full address
Framesthe host paces a fixed rate; the wingmen take the host's frameseach game keeps its own clock; frame times vary
Crafta few, inside a sphere of actionup to 32 at once, spread over tens of kilometers
Syncframes in stepan owner per craft, reports by distance

03Finding a 32-bit game inside a 16 MB machine

The first challenge was finding the game in memory: DOS/4GW loads the 32-bit program into extended memory itself, and nothing tells the emulator where. I remembered the rank table from the manual:

RankManual PointsExecutable Points
Flt. Officer10,00020,000
Lieutenant50,00050,000
Captain150,000100,000
Commander250,000250,000
General500,000500,000

I scanned the machine's memory for little-endian encodings of the manual's rank thresholds. Sadly, the game must have been rebalanced a bit after the manual went to print, so the final numbers were actually 20000, 50000, 100000, 250000, 500000 at 0xC1E10. The multiplayer harness repeats this scan four times per second until the game load completes. With the rank table found, the data is placed, and the code can be located below it: DOSBox searches for the first bytes of tie_updatetime and laser_createprojectile. The code and the data turned up at linear 0x1FA000 and 0x2A5000. These act as guideposts and the rest of the necessary functions and data are found relative to these guideposts.

linear memory of the emulated machine (16 MB)Scan: every dword above 1 MBconventionalDOS4GW.EXEvideoBIOSextendedDOS/4GWcode object (0xAAE83 bytes)image 0x10000 →data object0x46470 bytesfreeto 16 MB00xA00000x1000000x1FA0000x2A50000x2EB4700x10000000xAB000 apart (the LE header says 0xB0000)1 - when DOS loads DOS4GW.EXEevery 250 ms for a minute,every dword above 1 MB,read without faulting2 - The code object, belowtie_updatetime begins53 51 52 56 57 55 8B 2D(push ebx … ebp; mov ebp,[…])3 - Rank data only TIE.EXE hasranks 20000, 50000, 100000,250000, 500000 @ 0xC1E10and "RESOURCE\" @ 0xC1C98
Searching through the emulated machine's memory for the game's code and data, placed by DOS/4GW.

04Hooking TIE Fighter

Previously, the Wing Commander hooks were keyed on the 16-bit CS:IP. However, since TIE Fighter runs 32-bit code, its EIP register is too wide for that comparison. The hook is structured so that only the low 16 bits of an instruction's address are watched; on a hit, the full address is compared before the hook runs. This table lists every place in the game that is hooked to make TIE Fighter multiplayer:

Image addressPlaceWhy it was hooked
0x577F4tie_updatetimethe top of each frame: network in and out, controls
0x5CDA0user_inputforplanethe player's stick, once a frame
0x5F801, 0x5F831(inside user_inputforplane)sign-extend the joystick value (fixing an original bug from '95)
0x5FAE1(inside user_inputforplane)the bank into a turn, left out in "point to aim"
0x32448move_moveobjectscopies written; the trampoline's calls run here
0x2E0E4laser_createprojectilea shot fired
0x1433Ccollide_laserhitcrafta bolt meets a craft
0x148F0collide_damagecraftdamage applied
0x17BF8create_createcrafta craft made
0x16B8Ccreate_createmissionmission set up: to map players to craft
0x82504shipext_Get_Mission_Paththe mission file chosen so all play the same mission
0x218D8fediskio_loadspeciescraft types chosen: cockpits, voices

05Calling TIE's functions

Just as with the Wing Commander multiplayer effort, the most reliable way to make bolts, deal damage and credit kills is to call the original software's own functions. The trampoline for TIE Fighter is similar to the Wing Commander one, but it uses the Watcom register calling convention, which places up to four arguments in eax, edx, ebx and ecx, and simply pushes the return address onto the stack. Upon return, both ESP and EIP are back at their old values. At that point, just as before, either another queued call is executed or the entire register state is restored, including the flags.

1 · the game reaches P…its returnESPEIP = P(move_moveobjects)registers and flagssavedthe stack (grows down)2 · the call is set up…its returnPESPeax = argument 1edx = argument 2ebx = argument 3ecx = argument 4EIP = Fthe stack (grows down)3 · F returns to P…its returnESPEIP = P, ESP as saved→ the call is done→ the next call, orregisters and lazyflags given backthe stack (grows down)F: laser_createprojectile, collide_laserhitcraft, collide_damagecraft, collide_updatekills, msg_craftmessage, score_craftexitscoringan early return (tie_skip_call): at F's entry EIP = [ESP] and ESP += 4, since Watcom passes these arguments in registers
A call into the game made of CPU state alone. The 16-bit Wing Commander layer does the same in real mode.

06Craft memory layout

While the DeLorean may need to reach 88 miles an hour to time travel, a TIE Fighter instead requires 88 bytes for its flight record, including speed. Spacecraft occupy slots 0 to 31, projectiles are in 32 to 79 and finally debris and explosions occupy the remainder. Each craft also has a 0x21A-byte CraftData record: its AI, target, throttle, hull and shields. Syncing objects requires surprisingly few fields: place, attitude, velocity and the axes, then hull, shields, systems and the AI's countdown.

For TIE Fighter, slots are the same on every machine: the mission's own setup creates the same craft in the same slots, so a slot number names a craft across the network. This matters later, when distant craft are driven by each machine's own AI.

objects[120] @ 0xE38BC · 88 bytes eachcraft 0–31projectiles 32–79explosions and debris 80–119+0x00+0x04+0x08+0x0C+0x10+0x14+0x18+0x1C+0x20+0x24+0x28·gtypexyzprevious x, y, zhdgpitchroll·speed·radius+0x2C+0x30+0x34+0x38+0x3C+0x40+0x44+0x48+0x4C+0x50+0x54deathagei·s·fg·move vector·axes: 9 × int16 (forward, side, up)→ CraftDatag genus · i the object's own slot · s side · fg flight group · death the death timer (ticks) · radius the collision radius (a bolt's damage)crafts[32] @ 0xE6394 · 0x21A bytes each · the fields the sync uses+0x2A AI countdown (0x7FFF: held)+0x2C target+0x60 flight flag (6: arriving)+0x61 AI manoeuvre+0x9E throttle (65,500 = 100%)+0xA2 hull damage+0xAE systems+0xB8 inspected+0xCA / +0xCC shieldswritten into a copy from its owner's reportsread: which craft, whose side, alivenot used by the sync
// the units the game counts in
1 km                 = 40,960 world units
a mission second     = 236 ticks        (the clock: 4 ms ticks)
a frame at 59 fps    = 4 ticks          (frameticks, 0xEB712)
a full turn          = 65,536           (pitch 0x4000 = level)
a direction          = Q15, 16 bits     (move vector, rotational axes)
a T/F's top speed    = 225              (3,600 in hyperspace)
a laser's damage     = its bolt's collision radius 

07Design choice: whether to run in lockstep

Since both machines load the same mission file with the same random seed, it stands to reason that, with a deterministic timestep and deterministic physics, only the inputs would be required to simulate the game forward. In fact, that was the basis of the entire design of the TIE Fighter sequel, X-Wing vs TIE Fighter. However, this approach is also quite difficult, and its lead programmer wrote an illuminating article on the challenges they faced along the way: The Internet Sucks: Or, What I Learned Coding X-Wing vs. TIE Fighter.

Experiences from the X-Wing vs TIE Fighter developers
  • We knew this approach would have its own problems. The problem we anticipated with the most anxiety was the one we had seen many times before in our "VCR" feature. When playing back a recording of the player’s input, the game would sometimes produce results that were completely different from the original flight. In the past, bugs in the code that were otherwise harmless inevitably caused these "divergence" problems.
  • For example, we might use a local variable as a Boolean flag to decide between two possible actions for a non-player craft. If the variable were accidentally used before being set, the decisions would be random depending on the value of the variable’s location on the stack. This type of bug was usually not noticeable, except when playing back a film. But when playing back a film, the bug could cause a craft to take a different action from the action it had taken when the film was recorded. This difference would quickly "ripple" through the rest of the game world, as craft that were dependent on the actions of that craft made different decisions as well.
  • If this kind of thing happened during a multi-player game, the players would quickly be experiencing two completely different simulations. We hoped to deal with this "out of sync" problem in two ways. First, we hoped that we would be able to find most of these bugs, and thereby avoid the problem occurring in the first place. Second, we devised a mechanism for detecting when the problem occurred, and "re-syncing" the game by sending the data that had diverged.
  • We were able to develop some pretty effective techniques for finding "out-of-sync" bugs. Thanks to those techniques and the long period of testing, we actually found most of those bugs. We were also able to work on the "re-sync" mechanism, and we found that on the LAN, we could re-sync a game so quickly that you hardly even noticed when an "out-of-sync" bug had occurred.

Initially, both machines load the same mission file with the same random seed, so TIE Fighter starts out well: the same craft arrive with the same orders on both machines. However, each frame moves everything by its own measured frameticks, and the frame rate wanders with what is on screen: from 59+ in an empty region of space to 33 in a busy one. Two games agree only with the same inputs at the same frame times, and two machines never have those. The only possible lockstep solution would be to pin frameticks to the slower machine's, but that could cause variable gameplay, and it would require per-frame synchrony. Based on these facts, the simpler approach, chosen here, was to give each craft one owner, a machine that is authoritative for it, and to have every other machine show a copy kept in step by the owner's reports.

08Who flies what

From the outset, the game host owned most of the craft. However, this could cause unexpected twitches in the fast-moving targets on the guest machine, and it would result in an unacceptable aiming experience. A copy steered by reports would arrive a few milliseconds late and appear as a jump. TIE Fighter, more than other games, rewarded keen prediction and aiming capabilities. To add network jitter into the mix would dilute the skill aspect of the game.

The approach we took was simple: the guest takes ownership of very near craft in its view that the host is not targeting, and keeps ownership of its own target. This lets a player target a craft and fire a few lasers to dispatch it without any network jitter. Specifically, a guest takes a craft within 2.5 km and 45° of its nose (lasers' reach), or its own target within 4 km, unless the host is targeting it. Ownership is a bit sticky to avoid too much flapping: a craft is given back only once it is past 1.25 × the reach or 60° off the nose, or the target is dropped. Moreover, a craft changes owner at most once a second. Between two guests, the first to target a craft has priority, then the nearer one.

2.5 km: taken× 1.25: let go4 km: the guest's own target± 45°± 60°guesthostthe host's targetthe guest's targetABCDE1 kmflown by the guest's machineflown by the host's machine
A: in reach and in view: the guest's. B: near but behind: the host's. C: the guest's target, 3.8 km out: the guest's. D: in the guest's view but the host's target: the host's. E: far from every guest: the host's.

09Near, mid and far

A battle can hold 30 craft spanning across 40 km, dotted through more than thirty thousand cubic kilometers. Sending all of them every frame would cost about 50 KB a second. Instead, borrowing ideas from my thesis, among others, I made the update rate fall with the distance from the other pilot. Far craft are flown by each machine itself, which approximates their behavior. For instance, distant Star Destroyers will fire their own turbolasers.

near: every framemid: every 10th framefar: one craft every 30 frames, in turn02.5 km55.510 kmdistance from the other pilota copy: placed from its owner's reportsbeyond 5.5 km: flown by this machine's AI, pulled toward the reports↔
How often a craft is reported, and who flies it on the machine that does not own it.
A craft close up, under the gunsight

Nearunder 2.5 km

  • reported every frame
  • within 10 m: written as reported; further: eased in at 300 m/s at most
  • its AI held; its owner's shots come over
  • hits: the shooter decides, the owner applies
A craft a little way off, its targeting box around it

Mid2.5 to 10 km

  • every 10th frame
  • between reports the game's own move carries the copy along its move vector
  • still a copy within 5 km: no AI of its own
A distant craft, a few pixels inside its targeting box

Farpast 10 km

  • one craft every 30 frames, in turn: each every 10 to 20 s, sent reliably
  • beyond 5.5 km of this pilot: flown by this machine's own AI
  • its shots shown for show; damage only on its owner's machine
  • pulled toward each report over the time until the next
HOST's screenGUEST's screenTieCraftfrom whichever machine owns itslot · x, y, z (int32) · heading, pitch, roll (16-bit)speed · move vector (Q15) · the nine axis wordshull · shields · systems · dying · killerwritten at move_moveobjects's entry, onlyinto a slot holding the same ship;its AI countdown held at 0x7FFF
This illustrates how the same craft appears on both host and guest machines.

10The anatomy of a frame

Applying updates from afar requires care, and the order in which they are applied matters. Outgoing reports are taken at the beginning of each frame; any later, and the local dynamics have already nudged the craft. Likewise, incoming reports are written into the copies after the AI, weapons and physics have run, but before anything moves.

tie_updatetime0x577F4read the sockets · send our craft (best effort; a reliable copy once a second)add the stick's mickeys · the report is taken here: what the last frame drewuser_inputforplane0x5CDA0the stick made signed at 0x5F801 and 0x5F831the bank into a turn left out at 0x5FAE1 ("point to aim")the AI plannerpai_updateplaneaia copy's countdown (CraftData +0x2A) held at 0x7FFF: it never plans, never firesa far copy's set to 0: this machine's AI flies itlaser_createprojectile0x2E0E4a shot of a craft we fly, near another pilot: sent (TieShot)a near copy's own shot here: cancelled (the owner's comes over)the dynamicsnot hooked: the game turns and speeds up everything, copies includedmove_moveobjects0x32448entry: every copy written (place, attitude, speed, move vector, axes)queued calls run: remade shots, applied hits, kills, eventscollide_laserhitcraft0x1433Cour bolt meets another machine's craft: TieHit, a flash and a preview herecollide_damagecraft 0x148F0: damage only to craft this machine fliesthe picturedrawn by the game; the emulator then draws its aim ring, notices and comms line over ita hook: an instruction the emulator watches
A frame in the order the game runs it, and what the layer does at each watched place.

11Teaching the Imperial stormtroopers to aim

Since TIE Fighter is focused on precision and aim, lasers are a place where latency can disrupt gameplay. A rule of thumb helped bring the question about lasers into focus: whoever fired a bolt decides whether it hit based on that client's view of the full scenario.

If the laser bolt is created near enough to another pilot, then it is sent to that pilot and the other pilot's machine creates the bolt using laser_createprojectile from the original code, using its view of the shooter's craft location. The call to collide_damagecraft is skipped for a bolt that hits a craft owned by another machine. Instead, the shooter's machine sends a TieHit and shows a preview of the damage (the struck shield first, then the hull). The owner then puts a stand-in bolt in a free projectile slot (its segment, type, radius and shooter) and calls collide_laserhitcraft directly. Shields, components, messages and the flash all come from the game. The owner remembers whose hit began a death and names that pilot in its reports; the shooter's machine then calls collide_updatekills, so the kill is credited to the right pilot.

GUEST's machinelobbylinkHOST's machine (owns craft 7)the trigger: laser_createprojectile, a bolt hereTieShot { craft, hardpoint, type }the trampoline calls laser_createprojectile(guest's craft, …)the same bolt, from where the guest's craft is herecollide_laserhitcraft(bolt, craft 7): not oursa flash, and a preview by the game's sums(shields first, then the hull; never a death)TieHit (reliable) { target, offset, the bolt'stype, genus, radius, shooter, segment, impact }a stand-in bolt in a free projectile slot (32–79)laserx / laserxold = the segment · collidexoff = the impactcollide_laserhitcraft → collide_damagecraft: the game's ownTieCraft { hull, shields, systems }the owner's figures taken 600 ms after the previewits death timer runs: dying reports name the killerTieCraft { dying, killer = guest's craft }collide_updatekills: the kill is the guest's
A guest's shot at a craft the host flies, from the trigger to the kill.

On a network, what a pilot sees is always a little old. With 150 ms of lag each way, the guest could observe each hit 170 to 190 ms before the host applied it. But in the end both copies' hulls agreed. Friendly fire works identically: a shot that leads its target and hits a friend behind it is applied like any other hit.

At a T/F's top speed (225: 4,100 units, 100 m, a second), 100 ms of lag moves it 410 units, a third of its own length. A perfectly aimed shot, tested on another machine against its older picture, would miss by that much.

Instead, the design was built on three assumptions to mitigate lag:

on the GUEST's screen, frame non the HOST's screen, the same momentcraft 7, as the guest sees itthe bolt meets it here: a hitthe hit is decided here, by the game's own testwhere the guest saw it (a report earlier)craft 7 here, moved onTieHit: craft 7 + the impact's offset from its middle (collidexoff)applied with a stand-in bolt: the flash lands on the craft, not in empty spaceTieHit1 · aim at what you flycraft near your nose (2.5 km, 45°)or your target (4 km) are flown byyour machine: no network in the loop2 · your screen decidesthe game's own hit test runs where theshot was aimed; the owner neverre-tests it against its own picture3 · the owner applies itshields, hull, systems, messagesand the kill by the game's own calls,the flash at the shooter's impact
The hit is decided on the guest's screen and sent as the craft and the impact's offset from its middle. On the host, the craft has moved on; the flash still lands on it.

One assumption still being tuned is that ownership does not flip in the middle of a burst: a craft leaves the guest only past 1.25 × the reach, 60° off its nose, or with the target dropped, and changes owner at most once a second. These feel like arbitrary constants because they are, and they will likely need to be adjusted in the future. The exception is a craft the host is targeting too: it stays the host's, and the guest sees a copy written from the host's reports every frame. Either way, the guest's hits on it are still decided on the guest's screen, so they still count even though another machine flies the craft. The price is the famous tradeoff in shooter-decides netcode: on the target's screen, a hit can arrive a moment after the shot looked like a miss. Luckily, this is a co-op game against AI pilots, so the trade is unlikely to cause much consternation.

An AI craft that the guest's machine flies works the same way. Its AI aims at the host's craft as the guest's machine shows it (a pilot's craft is reported every frame), and its hits are decided on the guest.

A bolt…Decided onApplied onSeen in the tests
of the guest, on a craft the guest fliesthe guestthe guest: the game's own callthe usual case: the ownership rule gives the guest what is in its sights
of the guest, on a craft the host fliesthe guestthe host, by a stand-in boltHI2W: 20 and 28 a run, every one applied
of an AI craft the guest flies, on the hostthe guestthe hostHG3M: the host shot down by one
remade from a TieShot, touching anythingnowherenowhere: its shooter's machine decidesevery shot shown on both screens: 327 and 245 in HI2W
of a far craft this machine's AI flieshere, for showonly its owner's game deals damage299 shown on a guest in battle 2 mission 1
on a craft already dead on its owner's machinethe shooterdropped: "not ours to apply"18 of 19 applied in battle 2 mission 1

12Events that needed to be synced

Mission triggers run on every machine, but the machines can disagree about a craft, especially at a transition such as a craft entering a hangar or reinforcements arriving. Examples of this kind of divergence include:

In response, each is now sent as a reliable TieEvent the moment it happens. The recipient of the TieEvent does the game's bookkeeping: setting flags, showing messages, or scoring the exit. Here is a running log of two connected machines:

machine A0craft1craft2Lambda3craft4craft5craft6craft7craft8craft9craft10·11·12·13·machine B0craft1craft2missed3craft4craft5craft6craft7craft8craft9craft10Lambda11·12·13·the same craft, different slotsa far craft in slot 2 dies; its death lasts some 60 ticks, between two of its reports, so B never sees it.The next arrival takes the first free slot: 2 on A, 10 on B. Now a TieEvent associates it immediately.
Slots drift apart after a missed death; identified when a craft failed to show up for one player.

13A sign bug from 1995

When trying the Z-95 Headhunter, one of the less maneuverable craft, I noticed that steering left turned it left, then rapidly right. The user_inputforplane function scales the stick by the craft's turn rate with xor eax,eax; mov ax,[inputdelta]; imul eax,ebx; sar eax,15. The stick is a signed value, but mov ax into a cleared eax reads it unsigned and does not sign-extend it. Thus an axis of −d becomes 65,536 − d, so the result is 2·scale − d·scale/32,768, kept as 16 bits. When the scale is almost 0x8000, 2·scale wraps to nearly zero and the error vanishes.

The Empire's fighters happen to have almost exactly the right scale to hide the bug (0x7FFF: the error is 2 units). However, the Z-95 has 0x5555, so a soft left becomes a hard left, and past two thirds of the stick the sign flips to a hard right. The shuttle and Y-Wing are affected by the same bug. The fix sets one register at the instruction after each sar, so that eax holds the signed product. OpenTIE has a similar fix in its own port.

-32,768-16,384016,38432,767−24,448−16,384016,38424,448the stick across, game units (128 to a mickey; 191 mickeys is full)rightleftdead zonemeasured −24,918: a hard left−3,071 signedhard righta Z-95 as the game computes it (roll scale 0x5555)a Z-95, signed: the fix at 0x5F801 and 0x5F831a T/F (scale 0x7FFF): either way, within 2
The turn the game takes from the stick across: a Z-95 as the game computes it, and signed.

Drag-to-aim was endearing in the old game, and my mouse went through kilometers and kilometers of wheel motion as I brought my TIE around for another pass. But modern games usually prefer a point-to-aim mechanic for steering. This mechanic steers by the square of the pointer's distance once it leaves a small dead zone, an 8 × 8 pixel box around the gunsight. By default, craft bank as they turn, but this felt counterintuitive with point-to-aim. To zero out the banking, a hook at 0x5FAE1 hands the bank amount a zero. Sadly, TIE Fighter has no keyboard laser trigger. Space is largely unused, so the code now binds Space to hold the left mouse button in flight, except when the game itself is waiting for Space.

14Knowing when a flight is over

The DOS build leaves maingameflag at 1 from a flight's end until the next flight is set up. So it cannot tell the debriefing from the flight, which left an awkward aiming reticle over the serious debrief conversation. It also took over the mouse, so that the player could only leave the debrief room by flying the mission again, like the Emperor's very own Mr. Bones' Wild Ride for his elite pilots. The mission end flag is a better trigger, with a caveat: the hyperspace arrival is a scene of its own that ends with the flag set for some 155 ms. For now, the workaround is to count a flight as over only once the flag has been set for 1.5 seconds.

Combat Chamberarrivalthe flightdebriefing, Mission Goalsnext flightmaingameflag 0xEB763end flag 0xEB4E5"in flight", before"in flight", nowthe debriefing taken for a flight~155 msh: the end1.5 s"in flight" = maingameflag 1 and the end flag clear, or set for under 1.5 s (the arrival's 150–160 ms will not trigger the end state)
The two flags through a flight, and the layer's "in flight" before and after the fix.

15Two new cockpits for fan favorites

When playing TIE Fighter, the minute I heard the officer say "How pathetic. They must really wish to die flying those Z-95 Headhunters," I always wondered what it would be like to actually be inside one of those Z-95s. They seemed so inferior to the TIE Fighter, yet sported shields (paper thin) and the extra power that went along with them. Since the TIE Combat Chamber missions were tutorials for the controls, they seemed like excellent candidates to modify to use the Z-95 Headhunter. It would also be a chance to recycle that memorable line. However, the ship lacked a cockpit.

Similarly, after seeing Return of the Jedi, I always wondered what it was actually like to pilot an Imperial shuttle. Plenty of the Cygnus Spaceworks Assault Gunboat missions were solo missions. Since the Assault Gunboats were so much more capable than the Imperial shuttles, there was an argument that adding a second gunboat would be too strong. Instead, the second player (or both, if ion cannons were not required) would be put in the other Cygnus Spaceworks craft: the Lambda-class T-4a shuttle, the type the Rebels flew as the Tydirium.

Neither has a cockpit in the game's files. The shuttle's craft record names no cockpit at all; the game would ask for CP640\.INT. The Z-95's borrows the name XWING, and TIE Fighter ships no such cockpit. Since the game's art is never shipped with the page, anything new has to be made from the files in the player's own GOG package, so both cockpits are made at run time, by code, from the player's gunboat files.

the gunboatthe player's own filesforwardleft forward (keypad 7)the shuttlemade by code from the gunboat'sthe Z-95made by code from the gunboat's
Left, the gunboat as the game draws it. Middle and right, the shuttle and the Z-95: every pixel moved, cut or recolored by code from the gunboat's files.

When fediskio_loadspecies is called, the mission has been read and its craft types marked, but no craft or cockpit has loaded yet. There the player's craft is named SHUTTLE or Z95, and the files are written out beside the game's own. A cockpit's description (.INT) lists 28 views of 36 bytes, 95 instruments of 6 bytes from 0x3F0, and the instruments' sprite file. The new ones are the gunboat's with the view names changed, so gauges, scopes and displays sit where the gunboat's do. A view file holds a PANL sprite (the panel), a MASK (where space shows through), and a palette.

fediskio_loadspeciesthe hook: the mission read,the craft not yet loadedon every machineread the player's filesGUNBOAT.INTGUNBT12.LFD (PANL, MASK, PLTT)GUNBOATP.PNL, side viewsdecode · edit · encodethe sprite's runs, the mask'sruns, the palette by brightnessfor new pixelswrite beside the game's filesSHUTTLE.INT, SHUTFWD, SHUT10, SHUTUPZ95.INT, Z95FWD, Z9508/09/10, Z95UP,Z95P.PNL (the instruments' sprites)the shuttle's record names no cockpit (the game would ask for CP640\.INT); the Z-95 borrows XWING, which TIE ships no cockpit for:both are named at the hook. While one flies, the targeting display's mask is the gunboat's: 480 bytes (0xC6C63) over the default (0xC66C3), put back after
From the player's gunboat files to two new cockpits, at one hook, before the game looks for them.
// PANL: the panel sprite, one byte code at a time
0..250        a run of (op & 3) + 1 pixels of base + (op >> 2)
251 b         a new base colour
252 c n       n + 1 pixels alternating c, c + 1
253 n c       n + 1 pixels of colour c          (colour 253 itself: see-through)
254           end of the row
255           end of the sprite
// MASK: for each of the 3-D view's rows (325 of 480 forward)
a signed state (not negative: space first), then run lengths that flip it
a run past 255: 0, then the rest − 256; past 511: 0, 0, the rest − 512
the gunboat's mask, its struts foundamber: a hidden run with space on both sides,followed row to row (117–243, 120–268)green: a line fitted to their middlesthe shuttle'sthe V's bands cut (9 pixels wider each side)two legs of an A, leaning in 122 pixelsover 282 rows; a 24-row bar along the topthe Z-95'san ellipse's upper half, its legs downto the side consoles; a long nose to thehorizon, its foot on row 277dark: space shows through; grey: the cockpit. 325 rows of the 3-D view, 640 wide; each row a signed state, then runs that flip it.
What the code works on: the masks, before and after. The struts on the left are found again here, for the picture, the way the code finds them: every row of both stretches.

The Z-95 reads its instruments from its own sprite file, the gunboat's with sprites 30 to 33 redrawn. The shield display's picture of your craft from behind is now a simple Z-95 rear view, --8[]8--, one of the simplest and most accurate ASCII art views (a wing with a gun at each tip, an engine each side, the canopy on top). The targeting display's mask is chosen inside the program by the craft's number. While a shuttle or Z-95 flies, the emulator writes the gunboat's 480 bytes over the default and puts them back afterwards. Finally, the side views (keypad 7, 4, 1 and up; the game mirrors 9, 6, 3) are cut the same way. The shuttle's left-forward view gets the A's leg, the Z-95's the canopy hoop.

The gunboat's cockpit with V-shaped struts on the left and the shuttle's, made from it, with A-shaped struts on the right
In flight, battle 10 mission 1: the host's gunboat (left) and the guest's shuttle (right).

16Conclusion

In conclusion, the majority of the work was accomplished by adding the initial multiplayer to Wing Commander. Adding it to TIE Fighter proved that it was a repeatable pattern that could be applied to virtually any DOS game. Lobbylink continues to be an excellent, protocol-independent way to set up peer-to-peer links. I was worried that TIE Fighter's more crowded missions and precise aiming would be a poor fit for a loosely synced design where state is sent between peers repeatedly, but instead a simple design worked well. It's still very likely that, during the modem era, the best design for X-Wing vs TIE Fighter was the path its developers chose, sending inputs and keeping the simulations in lockstep, but in the current era of the Internet, it seems possible to sync craft of interest at high enough rates to make a game like TIE Fighter playable across the net.