Post by Freddie on Oct 25, 2019 16:33:40 GMT 1
The Global Network
Source Code: First contact
The source code has never been officially released but it is everywhere on the internet. I will obviously not provide a link to the source or even show code snippets but I think to provide a roadmap for historical value is acceptable and will probably help fellow code readers.
The solution is for Visual Studio 6.0 (development started on VS 4.1 but C++ support was not satisfactory: The team updated the dev tools as soon as a new version became available). It can be automatically converted to a modern version of Visual Studio (2008/2010/2012). Attempting to compile shows that the source code has heavily suffered from erosion: C++ has evolved a lot since 1998 and certain things are not permited anymore (like things that now require the typename keyword).
Before starting to open files and read, I ran a few metrics since cloc can give an idea of the volume of code to read:
fabiensanglard$ cloc jp2_pc
1596 text files.
1555 unique files.
418 files ignored.
cloc.sourceforge.net v 1.60 T=14.08 s (88.1 files/s, 40859.1 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 469 64881 86607 195287
C/C++ Header 762 32170 89234 105606
C 2 253 177 884
DOS Batch 7 5 0 174
Teamcenter def 1 0 0 8
-------------------------------------------------------------------------------
SUM: 1241 97309 176018 301959
-------------------------------------------------------------------------------
Standing alone, those numbers don't mean much. But comparing them to others games (Quake,Doom,Duke3D,...) helps a lot:
-------------------------------------------------------------------------------
Game Year files blank comment code
-------------------------------------------------------------------------------
Wolfenstein3D 1992 80 7223 7516 27311
Doom 1993 149 10213 10234 39080
Duke 3D 1996 182 18537 11364 77166
Quake 1 1996 543 45550 38262 171065
Quake 2 1997 399 37743 31735 163928
Trespasser 1998 1241 97309 176018 301959
Quake 3 1999 799 65988 93977 313311
Doom 3 2004 1466 137589 164894 593899
Doom iOS 2009 237 15080 24054 70766
Wolfenstein iOS 2009 326 20403 20170 63609
Doom 3 BFG 2012 977 92735 119965 363239
-------------------------------------------------------------------------------
The volume of code is twice more than other titles released at the same time. The volume is very representative of the complexity of the engine and the collosal scope of features. What really stands out is the volume of comment: Trespasser code base is exceptionnaly well commented and that is usually an indication of high skills.
The solution contains 23 projects which clearly show the different subsystems but I suspect was done to make compile time bearable. Even on a modern machine a full built take close to 10mn. I would not be surprised if 1998 and its lack of precompiled header took an hour for a full build.
An interview of Seamus Blackley (Lead developer on Trespasser) shows that compile time was a problem back in the days:
Qtrescom.org : What fraction of the development time was spent waiting on the C++ compiler?
Seamus Blackley : It felt like 103%
Details of each projects :
Projects Generates Notes:
AI Artificial Intelligence subsystem A lot of code unused since most traits had to be disabled.
AI Test JP2_PC.exe A standalone program allowing to test AI with graphics.
Audio Audio.lib The audio sub-system static library featuring the "real time Foley".
Bug Bugs.exe A project concentrating all compiler errors. Since the team switched from VS4 to VS4.1 to VS4.2 to VS6.0 it was usefull
CollisionEditor CollisionEditor.exe Sound effects editor to test the audio engine (very powerful at the time)
EntityDBase EntityDBase.lib Classes representing all objects in the game.
File File.lib Abstraction classes for File and Images, used to build the Groff archives.
File Test File Test for the file and image abstractions.
Game Game.lib Glue, triggers, Player, Gun classes.
GeomDBase GeomDBase.lib The 3D representation (Geometry) of all objects defined in EntityDBase.
GroffBuild GroffBuild.exe The tool in charge of gathering all game assets (3d,sounds,maps) in one GOFF file.
GroffExp GroffExp.dle The DLL loaded by 3DS Max that export all data to GOFF sections. This was originally outsourced to an other dev and is standalone.
GUIApp GUIApp.exe A wrapper around the game. The GUI allows to change the game values at runtime for testing. Like the console allowing to change the cvar in Quake engines.
Loader Loader.lib The library loading GOFF assets to RAM.
Math Math.lib The math library (features a fInvSqrt that is not as good as QuakeIII's InvSqrt since it uses a lookup table but also uses Newton-Raphson).
Math Test MathTest.exe A few functions to test the speed of the math routines.
Physics Physics.lib The pelvis heavy, penalty force based Physic engine library.
PhysicsTest PhysicsTest.exe A sandbox level where physic can be tested.
PipeLineTest PipeLineTest.exe Testbed for the rendering pipeline
Processor Processor.dll Uses CPUID to detect 8086, 80286, 28386 or a 80486, Pentium, K6-3and K7, Detect Floating Point Unit and CPU speed. Loaded at runtime by System project in order to set automatically details level (based on CPU Mhz).
QuantizerTool QuantizerTool.exe Aborted project. Does nothing.
Render3D Render3D.lib The hybrid software/Direct3D renderer.
ScreenRenderDWI ScreenRenderDWI.lib Pentium, PentiumPro and K6_3D specific code ASM optimized code for scanline and cache rendering. Direct3D code.
Std Std.lib Extension of STL. An horrible mess of specific containers of containers of set of hashmap. Arg.
System System.lib Contains scheduler, Virtual Memory. Thread control. SetupForSelfModifyingCode (via modify the page tables associated with the application). Many things are not used.
trespass trespass.exe The game we played.
View View.lib Raster to window code. Blitter, DirectDraw, Direct3D, software palette viewers.
WaveTest WaveTest.exe Shell to test wave modeling.
WinShell WinShell.lib win32 windows creation and management librar
Source Code: First contact
The source code has never been officially released but it is everywhere on the internet. I will obviously not provide a link to the source or even show code snippets but I think to provide a roadmap for historical value is acceptable and will probably help fellow code readers.
The solution is for Visual Studio 6.0 (development started on VS 4.1 but C++ support was not satisfactory: The team updated the dev tools as soon as a new version became available). It can be automatically converted to a modern version of Visual Studio (2008/2010/2012). Attempting to compile shows that the source code has heavily suffered from erosion: C++ has evolved a lot since 1998 and certain things are not permited anymore (like things that now require the typename keyword).
Before starting to open files and read, I ran a few metrics since cloc can give an idea of the volume of code to read:
fabiensanglard$ cloc jp2_pc
1596 text files.
1555 unique files.
418 files ignored.
cloc.sourceforge.net v 1.60 T=14.08 s (88.1 files/s, 40859.1 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 469 64881 86607 195287
C/C++ Header 762 32170 89234 105606
C 2 253 177 884
DOS Batch 7 5 0 174
Teamcenter def 1 0 0 8
-------------------------------------------------------------------------------
SUM: 1241 97309 176018 301959
-------------------------------------------------------------------------------
Standing alone, those numbers don't mean much. But comparing them to others games (Quake,Doom,Duke3D,...) helps a lot:
-------------------------------------------------------------------------------
Game Year files blank comment code
-------------------------------------------------------------------------------
Wolfenstein3D 1992 80 7223 7516 27311
Doom 1993 149 10213 10234 39080
Duke 3D 1996 182 18537 11364 77166
Quake 1 1996 543 45550 38262 171065
Quake 2 1997 399 37743 31735 163928
Trespasser 1998 1241 97309 176018 301959
Quake 3 1999 799 65988 93977 313311
Doom 3 2004 1466 137589 164894 593899
Doom iOS 2009 237 15080 24054 70766
Wolfenstein iOS 2009 326 20403 20170 63609
Doom 3 BFG 2012 977 92735 119965 363239
-------------------------------------------------------------------------------
The volume of code is twice more than other titles released at the same time. The volume is very representative of the complexity of the engine and the collosal scope of features. What really stands out is the volume of comment: Trespasser code base is exceptionnaly well commented and that is usually an indication of high skills.
The solution contains 23 projects which clearly show the different subsystems but I suspect was done to make compile time bearable. Even on a modern machine a full built take close to 10mn. I would not be surprised if 1998 and its lack of precompiled header took an hour for a full build.
An interview of Seamus Blackley (Lead developer on Trespasser) shows that compile time was a problem back in the days:
Qtrescom.org : What fraction of the development time was spent waiting on the C++ compiler?
Seamus Blackley : It felt like 103%
Details of each projects :
Projects Generates Notes:
AI Artificial Intelligence subsystem A lot of code unused since most traits had to be disabled.
AI Test JP2_PC.exe A standalone program allowing to test AI with graphics.
Audio Audio.lib The audio sub-system static library featuring the "real time Foley".
Bug Bugs.exe A project concentrating all compiler errors. Since the team switched from VS4 to VS4.1 to VS4.2 to VS6.0 it was usefull
CollisionEditor CollisionEditor.exe Sound effects editor to test the audio engine (very powerful at the time)
EntityDBase EntityDBase.lib Classes representing all objects in the game.
File File.lib Abstraction classes for File and Images, used to build the Groff archives.
File Test File Test for the file and image abstractions.
Game Game.lib Glue, triggers, Player, Gun classes.
GeomDBase GeomDBase.lib The 3D representation (Geometry) of all objects defined in EntityDBase.
GroffBuild GroffBuild.exe The tool in charge of gathering all game assets (3d,sounds,maps) in one GOFF file.
GroffExp GroffExp.dle The DLL loaded by 3DS Max that export all data to GOFF sections. This was originally outsourced to an other dev and is standalone.
GUIApp GUIApp.exe A wrapper around the game. The GUI allows to change the game values at runtime for testing. Like the console allowing to change the cvar in Quake engines.
Loader Loader.lib The library loading GOFF assets to RAM.
Math Math.lib The math library (features a fInvSqrt that is not as good as QuakeIII's InvSqrt since it uses a lookup table but also uses Newton-Raphson).
Math Test MathTest.exe A few functions to test the speed of the math routines.
Physics Physics.lib The pelvis heavy, penalty force based Physic engine library.
PhysicsTest PhysicsTest.exe A sandbox level where physic can be tested.
PipeLineTest PipeLineTest.exe Testbed for the rendering pipeline
Processor Processor.dll Uses CPUID to detect 8086, 80286, 28386 or a 80486, Pentium, K6-3and K7, Detect Floating Point Unit and CPU speed. Loaded at runtime by System project in order to set automatically details level (based on CPU Mhz).
QuantizerTool QuantizerTool.exe Aborted project. Does nothing.
Render3D Render3D.lib The hybrid software/Direct3D renderer.
ScreenRenderDWI ScreenRenderDWI.lib Pentium, PentiumPro and K6_3D specific code ASM optimized code for scanline and cache rendering. Direct3D code.
Std Std.lib Extension of STL. An horrible mess of specific containers of containers of set of hashmap. Arg.
System System.lib Contains scheduler, Virtual Memory. Thread control. SetupForSelfModifyingCode (via modify the page tables associated with the application). Many things are not used.
trespass trespass.exe The game we played.
View View.lib Raster to window code. Blitter, DirectDraw, Direct3D, software palette viewers.
WaveTest WaveTest.exe Shell to test wave modeling.
WinShell WinShell.lib win32 windows creation and management librar