In this source port for Windows you can compile examples of programs from each chapter of the book using the LLVM or GCC compiler in IDE Code::Blocks, Visual Studio or VS Code. https://github.com/myfoundation/Game-Programming-Gurus-Reloaded
In the book, algorithms are first written in C and then, in rare cases, they are rewritten in assembler. Under Windows, you can only to use the C version of the algorithms.
If you want to repeat the code in DOS mode with assembler inserts, follow this guide.
Author: José Benavente https://github.com/BGMP
Source: #2
For future readers,
After some trial and error, I managed to set up a working development environment for chapter 2! In the end, I opted for using DOSBox, plus a couple of enviornments to make it all build and link together.
Here's a step by step guide I crafted along the way:
Simply download DOSBox for your OS. I've left a link to their downloads page down in the references.
Once installed, mount your C drive as some local directory in your host machine. I just made a directory called DOSPROGS/ in my Desktop and that worked just fine.
Get Microsoft Macro Assembler, link in the references! Then, extract the disks' content to a folder in your MS DOS C Drive. I settled for C:\DOSPROGS\MASM611\.
From DOS' command line, run the SETUP.EXE file that comes with MASM611. The installer will then prompt you with an installation screen. Follow the instructions and select all the defaults you see fit.
Get Borland Turbo C++, link in the references! Much like you did with MASM, extract the disks' content to a folder in your MS DOS C Drive. I used C:\DOSPROGS\TCC\.
From DOS' command line, run the INSTALL.EXE file that comes with TCC. The installer will then prompt you with an installation screen. Follow the instructions and it will install accordingly. Also, at one point in the installation process, TCC will ask you what folder it should install itself to. In my case, I selected C:\TC\.
First off, you will have to write down an assembly file and use MASM to assemble it. Here's a listing taken from the book:
Listing 2.8 - An assembly procedure to set the video mode (SETMODEA.ASM)
.MODEL MEDIUM, C
.CODE
PUBLIC Set_Mode
Set_Mode PROC FAR C vmode:WORD
mov AH,0
mov AL, BYTE PTR vmode
int 10h
ret
Set_Mode ENDP
ENDTo assemble with MASM:
CD C:\MASM611\BIN
MASM SETMODEA.ASM;This will create a SETMODEA.OBJ file. Keep this file around, you will have to link it later!
Now, you will need the C function that calls what you have defined in your ASM file. Save the following listing to a file:
Listing 2.9 - A C function to test the video mode (SETMODEC.C)
#include <stdio.h>
#define VGA256 0x13
#define TEXT_MODE 0x03
extern Set_Mode(int mode);
void main(void)
{
// This sets the video mode to 320x200, 256 colour mode.
Set_Mode(VGA256);
// Wait for keyboard to be hit.
while (!kbhit()) {}
// Put the computer back into text mode.
Set_Mode(TEXT_MODE);
} // end mainTo compile with TCC:
CD C:\TC\BIN
TCC -IC:\TC\INCLUDE -mm -c SETMODEC.C;This will create a SETMODEC.OBJ file. Keep this file around, you will have to link it later!
Still from the TC directory, bring SETMODEA.OBJ into it, and link it together with SETMODEC.OBJ. You may do so as follows:
TLINK c0m SETMODEC.OBJ SETMODEA.OBJ,SETMODE.EXE,,cm -LcC:\TC\LIBSimply run the executable file to test the results:
The -mm flag passed to TCC, and the arguments c0m and cm passed to TLINK represent the type of memory model that's being used for the program. In this case, it's all ms because we're using the MEDIUM model.
Like so, you must replace these arguments to work with other models accordingly:
- TINY:
-mt;c0tandct. - SMALL:
-ms;c0sandcs. - COMPACT:
-mc;c0candcc. - MEDIUM:
-mm;c0mandcm. - LARGE:
-ml;c0landcl. - HUGE:
-mh;c0handch.
Well, that's it! I'll keep on reading now, hopefully this guide will help you get started.
DOSBox - https://www.dosbox.com/download.php?main=1
Microsoft Macro Assembler 6.11 (3.5) (MASM611) - https://winworldpc.com/product/macro-assembler/6x
Borland Turbo C++ 3.0 (3.5-720k) (TC) - https://winworldpc.com/product/turbo-c/3x