The Book. This page deals with my dalliances with code described in the book: "Amazing 3-D Games Adventure Set" by Lary Myers. It is published by the Coriolis Group, Inc, 1995. I first encountered the ACK when Mr. Myers had circulated the code as a combination of 16-bit C and assembler. This early code is still available from the programming archive at x2ftp.oulu.fi in the ACK directory. The code was written for the Borland C++ 3.1 compiler and MASM v.5.0. I don't know when he started the ACK project but many of the files I have are dated mid-1993. This freeware became the nucleus for the above mentioned book published two years later. Of the various "tutorials" that have been offered as programming guides, this has been one of the most useful to me, probably since I have been developing an application that uses a 3D engine and the ACK engine was a good starting point.

The code in the book has been 'updated' to 32-bit DOS, primarily for the Borland C++ compiler v.4.x with the DOS Powerpack add-on for DPMI support and TASM32. There is also some code on the CD-ROM that has been ported to Watcom C v.10.0. A Win32s version is also presented, although it runs pretty slow compared to the DOS version.

The source for the Watcom version of ACK-3D along with an updated Windows-based map editor can be found on Lary Myers' webpage at http://inet.ny.synquest.com/users/LMyers . I haven't checked this code yet to know if it contains the bugs in the Watcom source supplied with the book (see below).

The Engine. ACK is a raycasting engine that can also texture map flat floors and ceilings. The map is grid-based and like most raycasting engines, restricts wall placement to right angles. It relies on a linked list of structures to manage depth sorting and placement of objects. It is limited to mode 13H (320 x 200 x 256 colors) and has no provisions for jumping or look up/down. Despite these limitations, it is still a good starting point for beginning game programmers who want to get into 3D in a hurry, since ALL the source code is provided on the CD-ROM and is well documented in the book. Moreover, Lary Myers makes it clear that the code is freeware and can be used royalty-free. As an example, the book, "NetWarriors in C" by Joe Gradecki (1995, John Wiley & Sons) is based on the older 16-bit version of the ACK engine to which the author had added cooperative network play routines.

The Code. The engine is demonstrated in the example program "FDEMO". The Borland version of FDEMO is not too bad, but the Watcom version looks like a it was hastily done the night before the deadline. You may be able to recompile fdemo.c if you stick to the library of all the other ACK routines, but forget it if you want to start from scratch. This section describes what I had to do in order to fix the broken code to successfully generate a stable Watcom DPMI executable.

I found that while the fdemo.exe program supplied worked fine, I could not compile the supplied source and produce a stable executable. I used the Watcom Windows IDE to generate the makefiles and then dropped to DOS and used MultiEdit to edit and debug the code via the Watcom command line tools. Those new to Watcon C will find that debugging DPMI apps in Windows is often not worth the effort. Part of the problem is due to the fact that Windows provides DPMI version 0.9 and the Watcom debugger wants version 1.0. So, it just works better to develop and debug DPMI apps in native DOS. Dual-monitor debugging also works much smoother in DOS.

A note about the assember code. The assembly routines supplied on the CD-ROM (ie. ackrtn.asm through ackrtn5.asm) were written to use the Borland Turbo Assembler IDEAL mode. Therefore, WASM will not assemble these sources as provided on the CD. In order to edit and assemble these routines, they will either have to be rewritten to accomodate the more restrictive WASM syntax, or recompiled with MASM or TASM. Since I had both the Watcom and Borland compilers/assemblers, I used TASM32 4.0 to edit and re-assemble these files. Fortunately, the TASM32 object files will link successfully with the Watcom linker. Moreover, once I got the assembly routines to where I wanted them, I created a link library with the Borland C/C++ 4.5 IDE, which could also be successfully linked into the Watcom project.

One other thing I did was to get rid of all those typecast abbreviations, like UINT, UCHAR and so forth. Just my personal preference (yeah, I know- real Windows programmers use 'em-- but I'm not a real programmer).


The Bugs. The following list summarizes the modifications that I have made to the Watcom DOS version of the code in order to produce a stable version of "FDEMO.EXE" .

In the header file "ack3d.h" there is an open comment which can cause compile errors:

/*short AckCreateObject(ACKENG *ae,short ObjNumber,short NumBitmaps,UCHAR *bmNums);
short AckCreateObject(ACKENG *ae,short ObjNumber); /* Fills in ObjList structure with information passed */

Apparently, the first definition for AckCreateObject is obsolete, so just insert "/*" at the end of that definition.

In the files: "fdemo.c" and "ackdisp.c", add "#include <conio.h>" for the inp and outp function definitions.

In the file: "fdemo.c" add ‘#include <ctype.h>’ to prototype the ‘toupper’ function.

In the file: "ackiff.c", change #ifdef to select the Watcom header files.

In the file: "iff.h", delete the prototype for the ‘short swab(unsigned short)’ function, since it’s not used.

In the file: "fdemo.c", change ‘int LoadAndShow(char *fname)’ to ‘char LoadAndShow(char *fname)’.

In "fdemo.c", change ‘int initialize(short oflag)’ to ‘char initialize(short oflag)’

In the file: "ackiff.c", change the variable definition from ‘char value’ to ‘signed char value’. This is very important, since the Watcom compiler will default to unsigned char unless the -j command line parameter is used. This is the cause of the ubiquitous "Error Loading Font BBM" bug. This error also prevents any of the other Deluxe Paint graphics from loading. Incidentally, this code worked fine with Borland C, since it doesn’t default to unsigned char when going from 16 to 32 bit code.

In the file: "ackrtn.asm", in the AckDrawPage procedure, you must save and restore the ebp register, or the system will become unstable. Do this by pushing ebp on the stack before pushing esi, and pop it off the stack after popping esi at the end of the procedure.

In the file: "mouse.c" change all occurrences of integer variable definitions to shorts.

I found that if light shading was turned off, the bitmaps were drawn upside down and the program crashed often, usually when trying to render a single height wall and then moving to a multi height wall. The first clue was the observation that the tower in the starting courtyard of the Fdemo program was only visible in low resolution (I rewrote the floor and ceiling code to optionally draw them with slightly better resolution); moreover, the crash location was influenced by the viewport size.

This is due to the fact that there are some serious problems with the ‘ShowColNS’ procedure in the Watcom version of "ackrtn4.asm". The easiest way to fix this is to replace it with the corresponding routine from the Borland version of ackrtn4.asm on the CD-ROM. Just make sure that you retain the procedure definition, since procedures are defined slightly differently for the two compilers. Also, add the following statements above the .CODE directive.

.DATA
SAVTABLE dd ?
SAVEVID dd ?
SAVEROW dd ?

I’m sure that there’s a lot more bugs yet to be found, but this takes it to the point where you can get a stable executable that seems to work right. I just thought that I would pass this info along to anyone who might still be struggling with this code.


DOWNLOAD SECTION

The repaired assembly routines are contained in the file ackassem.zip, along with the object files and a library file that can be linked into a Watcom C project. Download ackrem4d.zip to obtain ackrem4.exe, which is a modified version of FDEMO.EXE that comes with the book, that was recompiled with the bug fixes described above. There also are some additional features. See the readme file for details.

File Name

Size

Description

ackassem.zip 19K The repaired assembly files ackrtn.asm, ackrtn4.asm, the *.obj files and the library file containig all the assembly routines.
ackrem4d.zip 448K A modified version of the FDEMO example of the ACK3D engine with sound support and snazzier mouse controls (demo only)

Some additional information about ACKREM4 can be found  HERE .

 

LEGACY SOURCECODE
Filename

Date

Description

ackkit.lzh 04/19/94 Early version of ACK-3D engine (151 Kb)
acksrc.lzh 04/19/94 ACK-3D early sources (147 Kb)
ackcpp.zip 05/07/95 ack source for TC++/TASM with fixes and doomtech.doc (275 Kb)
pcx2img.zip 05/07/95 PCX -> IMG (ack3d) files (3.4 Kb)
ackwin.zip 08/07/95 ACK 3-D for Windows WinG by J.Lundy (1.17 Mb)
nackdms.zip 04/16/97 Station Escape source - ACK3D demo by Lary Myers (98.5 Kb)
nackeng.zip 04/16/97 Newer version of ACK3D Animation Construction Kit 3D engine (193.4 Kb) 
nackexp.zip 04/16/97 ACK3D example - move around in 3D world (137 Kb)

Created 22 November 1997

Hit Counter visitors since last update

tiny_eledarlogo.gif (1592 bytes)    HOME
www.eledar.net