DUKE NUKEM 3D GAME SOURCE CODE GUIDE  v12-22-2017  Release 12   RTCM Corvin




DUKE3D  v1.2 | DUKE3D v1.7 | DUKE3D 3Dfx

FIXES 1.0 to 1.1 | FIXES 1.1 to 1.3D | FIXES 1.3D to 1.4 | FIXES 1.4 to 1.5



This Document provides Source Code information pertaining to the Duke Nukem 3D Game Code and Registered BUILD Engine code, including the Map Editor. Say 'Thank You' to 3D Realms Charlie Wiederhold for preparing the code for all of us to use and explore. The 3DR Duke3D Team was no longer part of 3DRealms at the time Charlie asked if he can help by 'fixing' the code. (3DRealms can not provide support for there source code release.)

Related Links: 3DRealms Legacy- Duke3D Atomic




Over several years Duke3D fans had been asking for the source code, yet 3DR kept denying all of us that goal of what they wanted, to improve it and later port it. As new WinNT systems game out especially Win2k and WinXP, a working Windows version of the game was badly needed. However with no code released, sites like RTCM where gathering instructions and methods and tools to help keep DN3D and the BUILD Games aloft.

After what seemed life a very long and agonizing term. 3DR finally released the source code. It took too long for them to release it and by the time anyone was interested in porting it, only a few programmers remained...

With the source released a few programmers released a Windows port of the game exe. Owners of Duke Nukem 1.3D, 1.4/1.5 you can use the Registered Data (some cases Shareware Data too) for usage with the newly compiled game exe's. Jonathon Fowler and his JFDuke Windows port was the 2nd one of the new ports to be released...


See: RTCMs Ken Build Source Support Page for even more information regarding released code and projects by Ken Silverman. Ken S original codes are what 3DR Based there coding off of (as well as other companies).



The Source Codes or Specifications Officially Released, Related to Duke3D are:


  • The 3DR Game Engine - { duke3dsource.zip } -Duke3D Team / 3D Realms Release v1.5 CD - April 1, 2003
    This is the complete source code for Duke Nukem 3D version 1.5 It contains the Apogee Sound System, By Jim Dose. Also Ken Silverman's released Data Files. (See below.) There is also an EXTRA Section containing code that was developed but not used. They did not include the source code for Duke3D map editor, but it was released later. (Duke GAME Engine-src: 95% C (Watcom C), A few routines in ASM: 5% ASM).


  • Duke3D BUILD Map Editor - { bldedtrsrc.zip } - Mark Dochtermann, Duke3D Team / 3DRealms Release v1.5 CD June 18th, 2003 This is the source code needed to compile the BUILD Map Editor that was available on the Atomic CD.


  • COMMIT Specs- { dukenet.zip } - Mark Dochtermann / 3DRealms Release v1.0 February 12, 1996
    A network/serial interface. COMMIT itself is an ipx/netbios/serial/modem communications package that simplifies the task of getting connected. If you want to write a custom driver to replace COMMIT you must follow the specifications described in this text. (Based off of Kens Code)
  • EXTERNAL Control Interface- { dukectrl.zip } - Mark Dochtermann / 3DRealms Release v1.0 February 19, 1996  - Many Build Games based off of 3Drealms Duke Game use nearly the same setup program which includes the external control interface. These specifications describe how the the control system works, and how you can interface to it. Coding a New Controller or an external program during the game.
  • Apogee Expanded MIDI (EMIDI) { emidi11.zip } - API Specs v1.1 - Lee Jackson Release 1997 - This document contains information on special EMIDI controller messages that we used to accomplish our tricks, such as track inclusion/exclusion, selective looping, and so on. These messages were used in MIDI files written for Duke Nukem 3D (original and Atomic Edition/Plutonium Pak) and the shareware version of Shadow Warrior. In order to play the raw MIDI files from these games properly, your player must support this EMIDI information. To my knowledge, only the games themselves support EMIDI at this time, but that can change. If you want to write a player that supports EMIDI, you'll need this API.


  • Unreleased Sources-  ,  SETUP.EXE and SETUPMAIN.EXE -Source Code presumed lost, hopes for it to be found.
    Setupmain.exe would be helpful so it could be imported as an in game menu.




These are some positive suggestions for porting Duke Nukem 3D to a Win32 Environment. The port should be basically an exact duplication of the original game, in all aspects. The end result should just be 'Windows Duke Nukem 3D' 

  • Add Network code for Internet play with "join in progress" (Very important)
  • Retain Modem to Modem if possible.
  • Direct X should be used for accessing hardware, video and sound.
  • Some type of texture smoothing should be used as a player approaches a low res texture or sprite.(maybe mip-mapping)
  • Anti-Alias to smooth the edges of the sprites.
  • Fixing perspective warping and allowing the player to look straight up and down.
  • Expand the video behind the Status Bar so we can have transparent full status bars.
  • Ensure to use a Vivid Digital to enhance the flat colored palette.
  • Direct Compatibility with all past Mods and TCs. Perhaps add a "1.3D Mode" so those Mods can be used.
  • The CON System shouldn't be altered. Compatibility could easily be lost, this one you should wait on.
  • The Map format should remain the same.
  • In general all formats should be retained.
  • The original sound engine should be used.(enhanced version)
  • All the original SETUPMAIN.EXE functions should be put in an in game menu.
  • Additional in game Menu Selections such as launching maps while in the game.
  • Replace 'play on ten' with a Internet session.
  • Command line functions should be done in an Unreal type of  'Console' along with the cheat codes.
  • Improving the sprites shouldn't go beyond using Voxels, models should be used. The sprites tend not to have enough angles to adequately determine which direction a player is looking.
  • Auto Aim should be a Toggle and for single player only. Rocket autoaim should have a lock-on feature like in Unreal.
  • Water/Jet pack controls, when moving forward/backward player should be able to point in direction he will go. Using Standard Movement keys.
  • Dodging controls should be added. Tap the key within a fraction of second to dodge, like Unreal.
  • Proper Mouse support, for 3 button mice with a wheel.
  • For Internet/Modem games the server should verify all players have the same exact game files.
  • Where possible use source code from other BUILD Games to continue on with the 'Build Style game'
  • Use features from other 'Build Style games' instead of looking elsewhere, we want to stay with the "Build feel and game design"
  • Add in a compatibility mode for use with NAM and WWIIGI Build Games.
  • Down the line the focus should be to capture all other build game features and add them in.  From games like Exhume and Poweslave, and all others.




These Bugs and Errors are compiled from problems with Duke3D.exe 1.3D/1.5, CONs, Maps, Build, Setup and only reflects 3D Realms released game. There are new bugs listed here that are just now being mentioned or discovered (2003).

  • Nukebutton and Fragged - If a player actives a nukebutton and is fragged during the final animations before the level ends, he dies normally like he should. But if you let the game continue on its own without pressing the space-bar to restart, the level with end normally as if the player didn't die. This in turn will allow the player to start the next level at 100% health with all weapons and items they had on the last level. A player could intentionally inflict a fras on themselves to spawn this bug and cheat. This bug is present on all versions v1.0-1.5
  • When you're shrunk and Jet Pack up to the ceiling, and then grow back, your head crashes into the ceiling and you die. Unshrink near roof kill
  • When you're shrunk, no damage can be done to you. but all the damage that should have come to you from exploding weapons is done to you at the second you finish growing up. Damage is assessed after unshrunk.
  • Swinging doors that kill if they are at the same height as the room and being opened while running at them. Swing door alignment, Fixed in Atomic maps.
  • A pipe bomb that is set in a little higher position of center doesn't do any damage.
  • RPGs and slopes. If the RPG missile hits below you, you'll take damage, but if you're a little below it,damage isn't inflicted.
  • Perspective Warping
  • Viewing some maps in build before playing alters the map.
  • When saving or upon reload of a saved game, sometimes cause certain maps to be altered.
  • The ifprunning command is not effected by the AutoRUN ( CapsLock ) feature of duke.
  • If you use the view option (F7) in duke while the auto run feature is locked on, you will notice that dukes animation remains that of walking, but he is moving about at running speed. (An oversight I found when I was trying to tweak out the Footstep snd I added to the kit)
  • Clipping in build tends to produce "slips" that allow the players to pass through or slip into an adjacent sector.
  • If you shrink a stripper, then freeze them while they're shrunk, when they grow back they're invincible.
  • In the Atomic version of Duke Nukem 3D there is a line in the user.con file to adjust the expander's ammo, its does not function.
  • When playing some of the higher levels, the game slows down, eventually to a stop! This is a problem with the game engine in v1.3d and 1.4. What's happening is that the game is spawning an almost infinite number of game enemies in memory (you can't actually see them), and because of this, it's slowing the game to a crawl.
    (See the "v1.4 to v1.5 bug Fixes" listed below)
  • Explosion higher than you, If you are ducking in one sector and an explosion goes off in another sector, no damage. Like with RPG rockets.
  • 1.3d shattered frozen dukes spawns a dead duke when player respawns (leaves)
  • stomp kill spawns a dead duke body that lasts forever (you can't tell)
  • stomped if you respawn by a player (after being stomped)
  • 1.3d aim lock into floor if opponent is shrunk
  • Recording demos in 1.3d, the names and player chat don't show up.
  • stomped by nearby player if hit by shrinker while on steroids
  • stayput Vs respawn
  • 1.3d turret gun slowly drops
  • respawn marker appears for deleted item or double respawn marker (you can't tell)
  • if you freeze an opened egg, when it thaws it becomes an unhatched egg. Frozen pig cops spawn extra shotguns.
  • water pools underwater (freeze kill)-cosmetic
  • underwater explosion kill spawns a dead duke body-cosmetic
  • dead dukes look partially under the blood pool-cosmetic
  • stomp spawns two blood pools-cosmetic
  • exploded dukes spawn blood pools. ifonwater should be no spawn bloodpool-cosmetic
  • 1.3D MAP Bugs - Kinda irrelevant to be concerned about, since these can be corrected via BUILD and no src needed. The Duke 3DR map team corrected map problems as they where found. The 1.3 maps where highly improved. They basically spaced the walls and rooms a bit farther a part to eliminate allot of clipping and warping problems in 1.4/5 The following related link documents provide information concerning the Warps and Bugs in 1.3
    Related Links: BugTEAM Level Bug Board , WHY and HOW are there Level Bugs



Here are some Problems with the DOS game vs Hardware and OS issues due to the game being older. (However in now (2017) with the popular DOSBox Emulator program, the games can run on modern computers properly.)


  • PCI sound cards - On systems that use PCI snd cards under Window 95/98 systems can cause Duke and other Build Games to crash ( Even in DOS )
    The problem is an Echo effect, crashing a game (not the games fault). Newer PCI Sound Card Hardware are not properly compatible with this particular effect. Ken Silverman has made a workaround that turns off the Echo Effect. However, Upon doing so, we also loose Reverb sound effects aswell.
    See the RTCM Windows Sound Setup Document for more details about this PCI bug.


  • Newer video cards - On systems with the first few released set of 3D video cards can cause Duke and other Build Games to crash. They had poor compatibility with older games.  Just make sure you card handles 2D mode, VESA 2.0 or 3.0  and make sure your card is setup correctly to run 2D mode games. Have your configurations setup correctly as well in the games launcher, Setup.
    See the RTCM Setup Documents for further details.


  • Full 3D video cards WinNT/2K/XP- This problem is terrible. The game will not display and drops out. The thing is many/most video card manufactures are leaving out DOS video and Vesa support, or it has to be accessed in uncommon ways. Ken Silverman has a workaround that actually tricks Windows in thinking that the game is not using Vesa2.0. However This in-turn looses the linear frame buffer and slows the game down.


  • Windows NT/2000/XP - The game will run on most systems in low resolution, but the NT OS provides no compatibility with DOS sound. Windows XP's built in Sound Blaster emulator works with most systems, however sound is choppy at best and is mono.  Many users have used VDM Sound System, a free DOS Sound Emulator to obtain sound in all three OS's. Supports more than Sound Blaster, but sound is broken up at best. . To obtain higher resolution, again you can use Ken Silvermans VESA patch workaround. Results vary.
    See RTCMs Duke3D Patch Guide Document for instructions and downloads.


DUKE3D v1.2

This version of duke was NOT released by 3DRealms publicly, but was a press-leak (minimum copies where distributed). 3DRealms instead made some minor changes and officially released v1.3d
The "d" in the version number is only to represent "3D" cause it "sounded cool".
There is no previous lettered versions.



DUKE3D v1.7

This version was NOT a 3dRealms release. It was distributed as a modified Atomic(v1.5) .EXE and incorrectly noted as v1.7
The Atomic Edition " developer version gt.0411"
There are NO Upgrades or enhancements to the game in anyway. It simply removes some annoying repetitive screens that are useless for game play.

Removed Functions:

  • It removes the Ten screen at the end of the game completely.
  • All the credits when the game has been closed.

Other Confusion:

  • There also has been a Duke v1.5 plus Duke it out in D.C. developer combo package which allows you to select the extra DC episode. Either way v1.7D is not a true update by any means.
  • There's also a Quake add-on that contains various version numbers, one which happens to be  Duke17.zip




This version or patch was never completed by the 3Drealmers, it proved to provide little if any improvement to the game - project was dropped.

Note: See Shadow Warriors and Bloods 3Dfx patches for an idea. Those patches where sub-contracted to an outside company, 3DFX to add the glide code (src for the patches, presumed lost). See RTCMs Ken Build Source Support Page for more information about the limits of 3DFX and the BUILD Engine Combo.



FIXED 1.0 to 1.1

These are 3DR Duke Team Change logs for the game.

  • Restore game bug fixed.
  • AWE32 doesn't need E620 in the SET BLASTER parameters anymore.
  • Added optional mouse aiming method by popular demand. Press "U" while playing the game. You can then use the mouse to aim up/down. You will need to re-configure your keys to get optimum performance. Also experiment with making a mouse button do this.
  • Added optional crosshair toggle by popular demand. Press "I" while in the game to toggle the crosshairs.
  • You can now run with the GamePad; everything else works as it should.
  • Added Enhanced Joystick Support (FlightStick/SideWinder/throttle/etc).
  • Added HAT support for joysticks.
  • Duke screams in DukeMatch now when he dies.
  • Can detonate Pipe Bombs while looking in monitors. This is great. Lay some bombs in a spot that can be seen in a monitor, look in the monitor, and wait for a victim. Press FIRE. Boom.
  • Can back out of monitors with up/down movements. This is good for when you get surprised.
  • Removed much more bad language from Parental lock. Now safe for kids, sensitive adults.
  • "Adult Content" added to title screen.
  • Mouse strafing speed improved.
  • Mouse left/right movements are now equal.
  • More variable range for pipe bombs, plus you can DUCK and place one in specific place, without it rolling around.
  • Fixed crashing when exiting some levels by improving memory detection. (was due to low memory). If you only have 8 megs, BOOT CLEAN!
  • Can be shrunk in GOD mode now. Far less annoying.
  • Can redefine "D" or "N" key and STILL activate cheats.
  • Steroids key added to hot keys list. Press "R".
  • Longer demos allowed. No real limit now.
  • Duke doesn't disappear off the map now when zooming far away.
  • Lowering a weapon, then getting a new one bug fixed.
  • Play with the "Doomed Space Marine". By popular request.
  • F1 help screen updated.
  • NexGen CPU's can be fixed with a patch they provide. See DN3DHELP.EXE for more details.
  • HoloDuke lasts longer (about a minute and a half).
  • Reversed Stereo setting in SETUP is carried over into game correctly.
  • Duke flashes better now when he shoots in DukeMatch.
  • By default, internal .CONs are now used for DukeMatch, UNLESS... the /o option is used at a command line.
    You can use external .CONs by typing:
    SETUP /o or...
    COMMIT /o or...
    DUKE3D /o
  • CON Change: Red Trooper doesn't 'beam' away as much, and don't respawn into walls.
  • CON Change: The BLAST RADIUSES for various weapons are redefinable.
  • CON Change: Respawn times have been split into two separate variables, RESPAWNACTORTIME and RESPAWNITEMTIME.
  • CON Change: Duke's running speed/friction is redefinable.
  • CON Change: Minor weapon hit point balance adjustments.
  • Known problems
    • Game might get out of sync from either slow computers mixed with faster ones in net play, or the use of too many monsters in DukeMatch. We are looking into these.
    • If the game gets out of sync at the very start of a level, restart. You might also check to be sure you have the same *.CON files.
    • Sound problems in OS/2. We might look at this if we get a chance. Thanks to all of those who wrote about it. Don't get your hopes up, but we will at least look into it for you.
    • Daughterboard sound problems. We are still looking into this. Will try to address it in v1.2.


FIXED 1.1 TO 1.3D


  • The major addition to v1.3D is that the full version of the game is done as well.
  • X,Y axis sensitivity controls for mouse (in SETUP).
  • TEN (Total Entertainment Network) support from SETUP.  NOTE: TEN is no-longer
  • New load screen art.
  • FAKE-Bots(Static) for map testing.
  • Ability to record demos from the OPTIONS menu (single or multiplay game) NOTE: In multiplay, the "master" has to select DEMO ON.
  • Some new voice sayings.
  • F5 - Change Music. Shift-F5 to select song.
  • Inventory items like Steroids and HoloDuke now deplete if you are looking into a monitor.
  • Should sound a little better, changed the sound mixing and you should get less "crackle" and "pops" from your speakers.
  • Smoke trails for rockets.
  • Some more little things.
  • Multiplay changes:
    • Respawning items markers. These markers default to ON and can be turned on or off. They mark where items will respawn once gotten. If the Nuke symbol marker is red, an item is 15-30 seconds away, Yellow means 7-15 seconds and Green means 0-7 seconds. Experienced players might want to play with or without these, but they do add a new element of gameplay and help out new players by showing them where the items are.
    • Inclusion of DukeMatch-NOSPAWN Mode. In this mode, nothing respawns except the inventory items. No more running for the next health atom as they will be gone once grabbed. Also, no more hoarding rocket ammo and the like. The resources are scarce and this mode is a more true test of skill, as once you get down to a pistol, things get hairy.
    • Co-Op works like NOSPAWN mode. The weapons stay around, so 8 players can all get the Rocket launcher and not have to wait for something. The Co-Op rules work just like NOSPAWN mode where only the inventory items espawn. Also, you get to keep what you have collected from level to level.
    • More DukeMatch screams and yells. The more severe the damage, the more extreme the sound.
    • Messages in modem mode work now. They do not overlap each other anymore.
    • You can type messages with the game paused.
    • Mouse turning speed made more like v1.0 where quick 180 flicks are easy to do. BUG: Mouse Control Too Fast after Patching to v1.3d shareware from v1.1 . Delete your config file, and then reconfigure.
    • Better start points on E1L1. No more unfair roof starts.
  • There was also an attempt to fix the Win95 key from inside the game.
  • Flame-Thrower, laser gun, Space Suite, Gravity have been scrapped.
    • Gravity/Lunar Surfaces were 1/6 of earth's and you could jump a long distance, added forcefields over the windows, Easy fix...
    • "The suit will never come back, maybe in a future Duke." It just kept you from dying outside on the lunar surfaces
  • The registered version is on CD-ROM only. There is no floppy disk based version.
  • Known problems
    • Playing some of the higher levels causes the game to slow down, eventually to a stop!
      Memory leak that hogged needed RAM(see v 1.4 to 1.5 below)
    • infinite sprites bugs (To spot the bug-The frame rate will eventually drop low and remain low)

      This is a problem with the game engine in v1.3d. What's happening is that the game is spawning an almost infinite number of game enemies in memory (you can't actually see them), and because of this, it's slowing the game to a crawl or stop, your HD may operate constantly. We're looking into this for v1.4.

    • If you use modem connect, and select ALREADY CONNECTED, you connect to yourself, start the game with TWO dukes... ...and if you press forward, for example, the TWO dukes move forward and both shoot.
    • Recording demos in 1.3d, the names and player chat didn't show up.


FIXED 1.3D  to 1.4


  • Record+K "Spy" Cheating Bug fixed
  • Expander weapon added-doubled up on one key
  • 20MB of new art/sounds and levels
  • 1 new episode with 11 levels added- 9 standard, 2 secret
  • 1 new boss and a few new monsters
  • 25-30 new Duke voice sayings
  • Old (1.3d) maps retouched-some slipping fixed and doors
  • All setup bugs
  • User actors added and other con enhancements
  • Fixed, Recording demos in 1.3d, the names and player chat didn't show up.
  • Setup config file converter/updater added
  • Mouse speed settings changed
  • Controller speed settings changed
  • Fixed, infinite maps now in setup
  • User map Directory now is possible
  • RTS user directory now is possible
  • Modem Bug fixed, caused connection problems
  • Some work was done to the net/modem code
  • A.I. Bots added for game play - Bot Production ~ 1 day

    Bots where added late in the coding process and are only Hard Coded
    They where never intended to be a "real" feature until Ken S. coded them.
    3drealms- "We hacked them into Duke at the very end" A freebie, not  production code.
    A Test, They are not supposed to be anything more than a minor diversion.
    "Despite this the BOTS and the New A.I. Cons sold the game" - Corvin
    3drealms- "...If they are popular, we will do better ones in Shadow Warrior and Blood"

    • Pistol targeting in open areas is accurate
    • they don't attack enemies
    • they may "use" a teleporter they have problems with overlapping sectors
    • bots kicking doors are heard far
    • close up, the bots are near impossible to hit
  • Gravity added back in.
  • Added co-op, net save games
  • Friendly fire option for co-op

  • Known problems
    • Install problem on machines with 64MB or more of memory(see v1.4 to 1.5 below)
    • Memory leak that hogged needed RAM(see v 1.4 to 1.5 below)
    • Infinite sprites bugs (A hot spot for this bug is when u go from level 1 to level 2 in episode 4)


FIXES 1.4 to v1.5


Quick List of Changes. Production: one week

  • The 'slowdown' bug

    The major bug was fixing a memory corruption error (memory overwrite) that definitely caused a 'slowdown' bug. This bug probably fixed various other things like some random crashes, and save/load problems. While it might not fix everything,( it only shows up on a few computers. we still don't know why, it might not really be a bug, just require more memory ) memory corruption is the worst possible bug, and this one was fixed and the slowdown/massive caching seemed to go away. If you still experience lots of disk caching when playing the game, load Smartdrv at DOS before you play the game. Typing "smartdrv 4000" works well. NOTE: You will need more than 8 megs to do this.

  • Fixed a bug where the game would pop up the "Mighty Foot" weapon, when other weapons were available. Really annoying.
  • Fixed the bug where if you save a game, exit to DOS and reload from the main menu, you got E1L1 music, no matter what level it was.
  • CON: the differences are pretty minor, there's a fix for the BLIMP sprite respawning and what is probably a crash fix for the Expander in multiplayer.
  • If you had the problem with the Plutonium PAK v1.4 where your computer had 64Mb of memory or more, and couldn't install the game, you can use the Ppack15.zip patch to upgrade from v1.4 to v1.5. Run this patch, make sure that your CD-ROM is in the drive. This "install bug" was from the people that made the installer, not 3Drealms.

3DRealms Statement - "We won't do v1.6 until we have lots of things to do, or a really major bug in 1.5, If so BOTS will be improved and may have mmx." (1.5 was the last version released from 3D Realms).

Unreleased Code - 1.5 to 1.5+  -Added some room over room effects. Project features later where incorporated into Shadow Warrior.




Just some miscellaneous information on the 3DR Sound Engine.

Apogee Sound System v1.1

Supported Devices:

Does not support PC speaker.
Does not support the Windows Sound System.
Supports directly and *indirectly:
   ISA and ISA PnP
   PCI  PnP*
   DOS compatible Sound Card 33
   Gravis UltraSound
   Pas 16
   General MIDI, Extended Sounscape General Midi, Ultra Midi
   Software and Hardware Wavesynth and Wavetables 2 or 4 or 8 Meg Midi WAV Sets


    Max voice playback:  8, 32, 64 - 600 System dependant
    Max channels: 2 Left and Right (switchable)
    Max Playback Sample rate:  44 kHz  (22 kHz per channel)mono .voc/.wav
    Record:  Mono sound files .voc/.wav
    Playback:  (Digital) Mono sound files .voc/.wav
    Stereo Mixing:  Internal, Adds spatial effects with combined mono sounds.
    Formats: 8-bit and 16-bit .voc/.wav
    Compression:  unsigned or other COMMON methods

Blood uses an enhanced version of the above, Including 3D Depth. However sounds in Blood are only 8-bit, mixed at 11025Hz and 22050Hz.