GAME ENGINE BLACK BOOK WOLFENSTEIN 3D FABIEN SANGLARD 1st EDITION


How was Wolfenstein 3D made and what were the secrets of its speed? How did id Software manage to turn a machine designed to display static images for word processing and spreadsheet applications into the best gaming platform in the world, capable of running games at seventy frames per seconds? If you have ever asked yourself these questions, Game Engine Black Book is for you. This is an engineering book. You will not find much prose in here (the author’s English is broken anyway.) Instead, this book has only bit of text and plenty of drawings attempting to describe in great detail the Wolfenstein 3D game engine and its hardware, the IBM PC with an Intel 386 CPU and a VGA graphic card. Game Engine Black Book details techniques such as raycasting, compiled scalers, deferred rendition, VGA Mode-Y, linear feedback shift register, fixed point arithmetic, pulse width modulation, runtime generated code, self-modifying code, and many others tricks. Open up to discover the architecture of the software which pioneered the First Person Shooter genre.



Reader Reviews:


5.0 out of 5 stars

Buy this book. Worth the read if you have any interest in video game and engineering history!


I have been a fan of Fabien Sanglard’s articles when I first stumbled upon his blog in 2014. I remember spending a few hours reading all his articles and learning a lot about computer graphics and game engines through his reviews.


Fabien has a knack for explaining highly technical concepts in laymen’s terms. It’s what makes his articles fun to read.


To also be honest, he has been an inspiration for me since 2014. When I first read his Good Algorithms Books article, I was not great at algorithms and data structures at all. In fact, I was intimidated by them. But through that article… that one article, in which now I claim to really have taken my career to the next level, I was able to improve my programming skills immensely.


When Fabien wrote that article, I literally bought all the books he recommended and read through all of them. (Well, except TAOCP and bits and pieces of CLRS… but soon!). I owe it to him for indirectly influencing my software engineering career. Since then, I’ve been trying to ingest as many books as possible trying to improve my knowledge and learn as much as possible in this vast technical field.


So this review is not only a regular book review, but a thank you to Fabien and his writing for being influential in my software engineering life. I’m sure he’s inspired a lot of other engineers in the past who got started programming simply from the motivation of one day making games.


In 2014, Fabien posted that he would be writing a Game Engine Black Book. When he announced that, I was psyched! I thought to myself that there was no way I would not be buying! And after 3 long years, he finally published it!


Once it was available at Amazon, I quickly bought a copy and waited for the perfect weekend afternoon to read it. Today was pretty much the day. Reading through the book took about 4 hours as I was already accustomed to his writing, and owing to his way with explaining technical material in such a fluid manner.


Prior to reading this book, I actually had basic understanding of:

16-bit x86 architecture (286) and early 32-bit x86 architecture (386)

ISA system architecture

Basic VGA programming using DOS interrupts.

Real mode vs Protected mode

DOS memory model


Lots of random id history, trivia and a great interest in retro computing and gaming. :)


Therefore, the first few chapters was a leisurely read. I thought the first 2 chapters was very motivating in introducing the reader to the technical difficulties of achieving great performance on an IBM PC-compatible of that era. The IBM PC was not a machine built for gaming then — more for general purpose office work. Fabien stresses this to give us the context needed in order to appreciate the technical marvel of what Wolfenstein 3D was able to achieve given the hardware constraints of that time.


Chapter 3 was probably my favorite chapter. Prior to reading this book, I had not seen the internal tools used to develop some of the earlier id games. It was really interesting to see the tools and workflow used to construct the assets of Wolfenstein 3D.


The best chapter to read is chapter 4, where Fabien takes us on a journey into the Wolfenstein 3D codebase. This is the longest, densest and most fun chapter to read. What really interested me was the architecture of the game and engine itself.


I was really impressed with the memory manager and page manager implementation that id had done. The whole architecture reminded me of a mini-OS. This is not farfetched as DOS at the time was quite limiting.


Another concept that I had learned in which I never really had the chance to grasp very well was ray-casting. I remember reading a few tutorials about it in the past, but I would say that Fabien’s explanation of how ray-casting works is probably the best out there. I always mention in my book reviews that there’s a certain piece of the book one should definitely look out for that makes it a “must-buy” and I would say that the explanation on ray-casting is the “killer app” of this book.


The rest of the book concludes itself with post release reception of Wolfenstein 3D and along with how it has influenced the industry. I thought it was particularly interesting to see how Wolfenstein 3D has continued to thrive this present day simply due to the fact that it is now open-sourced. I would imagine if it was not, then the game would really fall into the abyss of present-day “incompatible abandonware”.


Essentially three years in the making, and this book shows it. Don’t mind Fabien’s english. ;) . He’s already warned us in the back cover that he has broken english, but it doesn’t matter — his explanations are superior to many resources out there online.



5.0 out of 5 stars

Fascinating, charming, and renewed my enthusiasm for making computers do the impossible


I really enjoyed this book. I have a vivid memory of first seeing Wolfenstein 3D at a "computer show" (remember those?) in 1992 when I was only 11 and quickly buying the shareware disks. This game, Doom, and the Quakes were a big part of what got me excited as a kid about programming and the endless possibilities computers offered.


So it is extremely satisfying to finally understand the intricacies, hacks, and genius behind the Wolf3D engine. I admittedly never attempted to read the source prior to this book, but a big reason for that (beyond lack of time) was that so much context is necessary to make sense of the code. Fabien's book provides a huge amount of necessary context for understanding both what the engine is doing and more importantly, WHY it is doing it. The book explains DOS memory limitations, the insane complexity of VGA graphics programming, and fixed point computations (which were necessary due to lack of floating point units), among many other things. Without all this background, the source code would not make much sense at all. As John Carmack has said about this book, it is a great piece of software archeology.


I came away from this book with all the more appreciation for the brilliance of the hacks that were used to get the game running at a reasonable framerate on the 386'es (and even 286'es!) of the early '90s. For example, Sanglard explains how Wolf3D draws walls one column at a time: the engine actually dynamically generates assembly routines that shrink or expand a wall texture to an exact number of vertical pixels (the height of the wall on the screen). Each of these routines contains only the assembly instructions necessary for this wall height and no loops.


It's really cool to read about this stuff and renews my enthusiasm for programming, finding creating solutions, and trying to make machines do what seems impossible. Though I wouldn't recommend this book for someone who isn't a programmer, Sanglard takes his role as software archaeologist seriously and provides tons of asides and anecdotes about the history of computing, the personalities behind id Software, and little details about things like map design. For example, he includes an architectural diagram of the house the team worked in. This is pointless from a technical perspective, but I greatly enjoyed all of these details. The book is also full of full-color (and large!) screenshots and illustrations.


My only criticism of this book is that it is a bit rough around the edges, particularly with regard to typos, of which there are many. In a way this adds to the book's charm, however. It isn't trying to be super polished, and you can tell that it was (lovingly) laid out and organized by one person, the author. It reads more like a hacker manifesto than a textbook, and I love it for that.