Click here if you are stuck in someone else's frames.
Updating the Game Library

Okay, we're now ready to update our library with the updated code.  If you made any of the perscribed changes to VMODE.C and VMODE.H, you must recompile them.  Here, we can use the old standby DOS command for Turbo C++.

    tcc -c -1 -mm vmode.c

If you've updated the SetPixel macro and you want the Line and Circle functions to make use of the new code, you must recompile them also.

    tcc -c -1 -mm line.c
    tcc -c -1 -mm circle.c

If you use a function for SetPixel instead of a defined macro, recompiling LINE.C and CIRCLE.C is not necessary.

Files that you've recompiled must be added to the library over their existing modules.  This is easy to do, to add a new VMODE module into the game library over the existing VMODE module already in the game library, use this:

    tlib gamelib.lib -+vmode.obj, gamelib.txt

If you've recompiled the LINE.C and CIRCLE.C files, their code must also be added to the game library.  Add them the same way we just added the VMODE.OBJ file to the game library.


Hmmm...  We have a lot of files don't we?  If we're to continue to create new files and add them to our library, we better think about ways of organizing them.  You can use any method you want, but here's one I use and recommend.

First, I created a main directory and named it GAMELIB.  In that directory (or folder) I created two directories and named them C and BASIC.  In the BASIC directory, I stored all my files pertaining to QuickBASIC programming.  In the C directory, I created three directories and named them SOURCE, INCLUDE, and LIB.  Also, in the C directory, I created two batch files for my convenience and named them COMPILE.BAT and MAKE.BAT.  The file called COMPILE.BAT compiles source files to their object form using the following command:

    tcc -c -1 -mm %1 %2 %3 %4 %5 %6 %7 %8 %9

The MAKE.BAT file compiles source files to EXE using the following command:

    tcc -1 -mm %1 %2 %3 %4 %5 %6 %7 %8 %9 .\lib\gamelib.lib

In the INCLUDE directory, I stored the header files for all the library functions contained in GAMELIB.LIB.  Files like FGRAPH.H and VMODE.H.

The SOURCE directory contains all the source files.  Files like VMODE.C, LINE.C, and CIRCLE.C.  Also, these files were modified to work properly in the new directory structure.  In VMODE.C, for example, the following include line:

    #include "vmode.h"

Was changed to:

    #include "include\vmode.h"

because VMODE.H is now in the INCLUDE directory.  All source and header files that reference other header files that we create and store in the INCLUDE directory must be changed in like fashion.

The LIB directory contains our object code files for the library files: VMODE.OBJ, LINE.OBJ, and CIRCLE.OBJ.  The library file itself, GAMELIB.LIB, and the listing file, GAMELIB.TXT.

Ultimately, it's up to you as to how you want to organize your files for you library.  You could store them in the INCLUDE and LIB directories of your compiler itself.  That way you could reference them like so:

    #include <vmode.h>

for example.

If you use my directory structure, you need to compile everything from the directory that contains the MAKE.BAT and COMPILE.BAT files.  Of course, you need not re-compile everything right now, just when you make changes or want to add new files to your library.

Let's say that you made this directory structure and for some reason you need to recompile VMODE.C and update GAMELIB.LIB with it.  If you had stored this directory structure starting from the root directory of a floppy in drive A, then first you would change to the A:\GAMELIB\C path (since in contains the batch files).  Next, you would enter the following command:

    compile source\vmode.c

Then, to add the VMODE.OBJ file to GAMELIB.LIB that is stored in the LIB directory, just move VMODE.OBJ to the LIB directory.  Then, change to the LIB directory and type:

    tlib gamelib.lib -+vmode.obj, gamelib.txt

After adding the object code to the library file, you can delete the object file itself to save disk space.  If you ever need that object file again, you can either re-compile the source file, or extract it from the library file.

    tlib gamelib.lib *vmode, gamelib.txt

Okay, I think we've beaten these files to death and it's time to move on.  If you have any questions over what we've covered so far, feel free to contact me.  For now, let's go onto to something more interesting, or at least important in making games and that is how to accept input.  That is, how to write functions that will return inputs from external devices and process them for us.

Previous Page | Main Page | Next page

Send your questions, comments, or ideas to: garyneal@geocities.com