This is the reconstructed C and C++ source of Wing Commander as shipped in Wing Commander: The Kilrathi Saga (1996), with the SDL2 port's code stripped out. Built with Microsoft Visual C++ 4.20, it reproduces the original Win32 WC1.EXE byte for byte.
Source files
Each group lists its files in link order, the order of their code in WC1.EXE.
Startup and Win32 shell
| File | Contents |
| winmain.c | Win32 shell (window creation, message loop, exit paths and the guarded debug allocator) and the asteroid and mine hazard fields. |
| winsys.c | Win32 system services: mouse, keyboard and clock wrappers, font workspaces, CD-ROM location and disc-swap prompts. |
| mono.c | Data-file wrappers, scaled interstitial text, canned sequences and the MONODEBG.VXD developer console. |
| joystick.c | Interactive joystick calibration and button waits. |
| version.c | The game's version string. |
| debug.cpp | The Win32 developer overlay console. |
| init.c | Game startup, graphics defaults and Origin FX initialization. |
| timer.c | Win32 frame timer and developer step waiting. |
| install.c | Installation-file loading, start-up arguments and disk-prompt setup. |
| input.c | Joystick transitions and menu input polling. |
| joycal.c | Joystick calibration and graphics setup data. |
| eventmgr.c | Event manager, mouse pointer and frame timer. |
Graphics
| File | Contents |
| fade.c | Incremental palette transitions, and the DOS string-append shim beside them. |
| view.c | Scripted views, constellation effects and cockpit target rendering. |
| screen.c | Mission requests, viewport setup and packet-memory management. |
| video.c | Video resource shutdown and palette allocation. |
| dib.c | DirectDraw back end: frame buffer, palette and screen updates. |
| raster.asm | Hand-written raster library: RLE sprites, clipped lines, fills and ellipses, and IFF, PCX and GIF image decoding. |
| gr.c | Rasteriser primitives, screen-space effects and the music streamer's wrappers. |
Data, files and memory
| File | Contents |
| objdata.c | Object definitions, animation streams and weapon display coordinates. |
| nearheap.c | Near-heap descriptor allocation and compaction carried over from DOS. |
| geom.c | Vector, angle and fixed-point geometry, and ship speed and fuel limits. |
| mathutil.c | Integer min and max, a packet-release helper, and the single-precision angular constants. |
| disk.c | Data files and packet fetching with retries, text-font setup and input waits. |
| pload.c | The packet loader. |
| game.c | Shared game state, mission and manoeuvre tables, and the information display. |
| data.c | Shared initialized data: event queue, cursor and screen geometry, direction-frame tables and cockpit display tables. |
| mathfp.c | Random numbers, fixed-point arithmetic and trigonometry computed in floating point, and text-cursor and shape-frame helpers. |
| strdos.c | 16-bit DOS C string and memory shims, and the event manager's set-up entries. |
Flight and combat
| File | Contents |
| auto.c | Autopilot travel and interstitial flight sequences. |
| eject.c | Ejection and stranded-pilot sequences. |
| fl.c | Flight manoeuvre handlers and their dispatch. |
| brains.c | NPC pilot intelligence (the original BRAINS.C). |
| mission.c | Mission setup, ship resources, formation placement and pilot speech. |
| nav.c | Navigation map, objective labels and the in-flight computer. |
| spc.c | Space-object simulation and the fleet overview camera. |
| ship.c | Ships: damage, explosions and weapons. |
| logic.c | Ship mission logic, resource ownership and scene animation. |
| main.c | WINGLEADER's main module: process services, flight control and the HUD. |
| targ.c | Objective arrival, warp transitions, mines and cockpit cleanup. |
| select.c | Gun and missile selection. |
| smart.c | Collision avoidance, formation flying and manoeuvre selection. |
Cockpit
| File | Contents |
| cockpt.c | Cockpit HUD: weapon, damage, target, objective, message and pilot displays. |
| damage.c | The cockpit's component-damage display. |
| comm.c | Communication menus and video transmissions. |
Campaign and carrier scenes
| File | Contents |
| cmpgn.c | Conversation animation, the briefing, debriefing and office scenes, and campaign mission packet decoding. |
| cutscene.c | Scramble, landing and funeral scenes, and the animation demo. |
| gameflow.c | Campaign flow and mission scoring. |
| title.c | Opening cinematic, credits and title menu. |
| barracks.c | The barracks: campaign save and load. |
| pilot.cpp | Inter-scene transitions, answer prompts, and the developer console's instance and wrappers. |
| trainsim.c | Training simulator: menus, pilot name entry, high scores and the mission loop. |
| launch.c | Carrier departure and cockpit launch sequences. |
| ending.c | Campaign victory, retreat and ending scenes. |
| screens.c | Briefing, debriefing, medal and funeral screens, and the conversation scene director. |
| killbrd.c | The bar, the kill board, conversation scenes and the initial campaign state. |
Sound and music
| File | Contents |
| sound.c | Sound-effect samples, playback and saved volume settings. |
| music.c | Music state machine and the streaming music script. |
ix audio library (C++)
| File | Contents |
| ixlog.cpp | The diagnostic printer, ix_log_printf. |
| lzo1x.cpp | Hand-written LZO1X decoder for packed streams. |
| ixfile.cpp | stdio wrappers used by the streamer and its thread. |
| streamer.cpp | Streamer API and package management. |
| thread.cpp | The streamer's worker thread. |
| streamfile.cpp | Stream-file methods. |
| dsp.cpp | DirectSound device control and shared configuration. |
| dsps.cpp | Sample stream control. |
| mixer.cpp | DirectSound driver opening and the mixer service thread. |
| dspv.cpp | Voice control. |
| dspmix.asm | Hand-written software sample mixer. |
| system.cpp | Sound-system state and voice allocation. |
| sound.cpp | Sound objects: initialization, volume, pan, frequency and priority. |
| sample.cpp | Sample objects: AIFF, WAV and raw loading. |
| ix.h | The library's classes and shared declarations. |
Headers
| File | Contents |
| globals.h | Globals shared between compilation units. |
| main.h | Option flags set from the command line, the configuration file and the registry. |
| wc1.h | Umbrella header for the game core. |
| wc1base.h | Common types, macros and utility prototypes. |
| wc1extern.h | Three prototypes that nothing calls, kept for the exact build. |
| wc1funcs.h | Prototypes of every reconstructed function, in address order. |
| wcdata.h | Game data enumerations and on-disk record layouts. |
| winmain.h | Declarations for the Win32 shell. |