Heretic source code


The Heretic source code, the C language files from which the HERETIC.EXE file can be generated by a compiler, were released in January, 1999, by Kenn Hoekstra of Activision, acting in concert with Raven Software, shortly following the release of the Doom source code by John Carmack of id Software. It was simultaneously released with the Hexen source code.


The Heretic source was initially released under a standard Activision EULA which limited the legal ability of many source ports, particularly those which had transitioned to the GNU General Public License in late 1999, to use the code. This was later corrected in a re-release by James Monroe after a long campaign by the community to have the license changed.

Technical details[edit]

Unlike the Doom source release, which was based on the Linux sources to avoid release of any of the proprietary DMX sound library's API or code, the Heretic source as released is for the original MS-DOS version of the game (Heretic itself was not ported to any other platforms, so there was little choice to be made in this matter). As a result, the sources as released cannot be compiled without substantial modification to remove dangling calls to the DMX API.

Significant technological additions made by Raven to the Doom engine for Heretic include translucency for sprites and screen patches, ambient sounds, the ability of the player to look up and down to a limited degree, and an inventory system. In addition, many modules were entirely rewritten with similar but different functionality, including the entirety of the menus, status bar, intermission, multiplayer chat system, HUD, save game code, and low-level video refresh.

It is of particular note that Heretic runs in a DOS planar video Mode 13h, as opposed to the tweaked non-planar Mode Y which was used by Doom. Both modes have an effective resolution of 320x200 with a physical aspect ratio of 4:3, but Mode 13h notoriously does not support page flipping, which can cause a perceived lower framerate.

Compared to the Doom source code, there is significant enjambment of unrelated functionality into single modules, and a severe lack of well-separated header files, resulting in a complete rebuild of the engine with even minor modifications to the code. It is believed the much improved state of the Doom source release by comparison was thanks to the work done by Bernd Kreimeier for his planned book release, and that as a result, the Heretic source release is a much better representation of what the Doom engine looked like in its most unadulterated form.


Files Description
am_data.h Two-dimensional line models for the automap, included into am_map.c
am_map.c, am_map.h Automap; modified in particular to display keys on the easiest skill, and to draw a parallax scrolling parchment background.
ct_chat.c, ct_chat.h Re-implementation of multiplayer chat, partially derived from Doom's hu_stuff.c
d_main.c System-independent main function, and setup code; a notable addition is the text-mode startup screen similar to ENDOOM
d_net.c System-independent networking code Watcom assembler header containing various macro definitions for rendering code
doomdata.h Basic data structures used to represent levels on disk
doomdef.h Constants used throughout the source code
dstrings.h String constants used throughout the game engine, including episode end texts. Some texts are left over from Doom.
f_finale.c Finale screen code; largely but not entirely rewritten from Doom
g_game.c High-level game stuff: transitions between game states, level exits, main game event responder, setting up new games, demo recording
i_cyber.c Code for interfacing with the Logitech CyberMan 3D mouse. This code was also used by the DOS version of Doom.
i_header.h Header for the low-level sound engine code, for both digital sound effects and music.
i_ibm.c Main entry point; sound and music; joystick, mouse, and keyboard code; low-level screen update and video mode initialization; DPMI and timer initialization; low-level networking.
i_ibm_a.asm x86 assembly for a division by zero exception handler which causes the error to be ignored, and low-level joystick interfacing.
i_sound.c, i_sound.h Additional system-dependent sound code; interface to the DMX library
in_lude.c Heretic intermission, for display of player scores/frags and episode maps between levels. Completely original, not based on Doom's wi_stuff.c
info.c, info.h Tables of data used by the game: sprite name table, thing data table, frame table. Generated by id's multigen tool from a script.
linear.asm x86 assembly versions of Doom core drawing routines R_DrawSpan and R_DrawColumn.
m_misc.c Miscellaneous functions: text rendering, configuration file loading, writing screenshots
mn_menu.c Heretic menu system. Completely original, not based on Doom's m_menu.c
m_swap.c, m_swap.h Endianness conversion routines
p_ceilng.c Ceiling movement
p_doors.c Door movement
p_enemy.c Monster AI
p_floor.c Floor movement
p_inter.c Object interaction: item pickup functions, object damage functions
p_lights.c Animated lights
p_local.h Global header for functions in the p_* section
p_map.c Object movement: collisions, teleportation, detecting for injury
p_maputl.c Library functions for p_map.c: blockmap code
p_mobj.c Basic object control functions: creating/destroying objects, movement, etc.
p_plats.c Lifts and platforms
p_pspr.c PSprite (weapon sprite) functions
p_setup.c Loading of map data and setup
p_sight.c Line-of-sight/visibility checking for monsters. Highly notable for containing the faster but buggier LOS algorithm also used by Doom 1.2 and prior versions.
p_spec.c, p_spec.h Special effects: texture animations, line triggers, floor/ceiling/lighting changes
p_switch.c Wall switches
p_telept.c Handling of teleporter lines
p_tick.c Base thinker code
p_user.c Player point-of-view code (weapon bobbing, player object thinker, etc.)
r_bsp.c BSP tree traversal
r_data.c Initialisation of data (textures, etc.) for use in the rendering code
r_draw.c Fast drawing functions
r_local.h Header containing declarations for all r_* modules; significantly larger than in the Doom source release.
r_main.c Entrypoint into rendering code
r_plane.c Rendering of planes (floor/ceilings)
r_segs.c Rendering of walls
r_things.c Rendering of sprites
sb_bar.c Heretic status bar and HUD code. Completely new code, not based on Doom's st_stuff.c, st_lib.c, or hu_stuff.c
sounds.c, sounds.h Sound/music tables
soundst.h Declarations for the high-level sound and music code.
tables.c Lookup tables for fast sine/cosine
v_video.c Generic image patch rendering (for menu, etc.)
w_wad.c WAD loading code
z_zone.c Zone memory allocator

Non-source and obsolete files[edit]

Several non-source-code and obsolete source files were included with the Heretic source release.

Files Description
colormap.lmp A copy of the COLORMAP lump from the IWAD.
d_netbak.c A version of d_net.c with a comment from Chris Rhinehart. Unclear if this should be included when compiling rather than d_net.c.
demo1.lmp A copy of the DEMO1 lump from the IWAD.
drcoord.h An Objective-C header file, probably from one of id's development tools such as DoomEd.
dstrings.bak Obsolete version of dstrings.h
g_old.c Obsolete version of g_game.c
h.bat A DOS batch file used to playtest a fresh build of the game.
hdemo1.lmp - hdemo3.lmp The three demos from the registered version of the IWAD.
heretic.lnt Configuration file for running the lint analysis tool on the source code.
in_lude.old Obsolete version of in_lude.c
license.txt Copy of the official text of the GNU General Public License, version 2.0
make.bat DOS batch file used to run wmake, Watcom's make program, with up to nine arguments.
MAKEFILE Primary MAKEFILE for compiling, assembling, linking, and stripping the heretic.exe file, and appending the DOS extender stub.
netold.c, oldd_net.c Yet two more obsolete versions of d_net.c
SourceReadme.txt Plain-text readme file stating the factuals of the source release by Activision and Raven.
tic.lnk Linker directive file for Watcom's linker, to generate the executable from the compiled objects. A debugging map file showing the compiled addresses of all symbols in the last build of heretic.exe as performed by Raven.
tinttab.lmp A copy of the TINTTAB lump from the IWAD
vgaview.h Another Objective-C header, probably part of id's development tool chain.
wadlink.txt, wadlink.wl Scripts for building the various versions of the Heretic IWAD using id's Wadlink tool

See also[edit]

External links[edit]