ZGloom code layout - Swizpig/ZGloom GitHub Wiki

binresource.cpp

Graphics baked into the Gloom executable. Currently only bullets and sparks.

config.cpp

The global configuration handler. Read/write from config.txt.

decrunchmania.cpp

Robert Leffman's decompression code to decrunch the original Gloom data files. http://aminet.net/package/util/pack/decrunchmania_os4

font.cpp

Loading and rendering the Blitz Basic shape files that make up the font.

gamelogic.cpp

Update() is called 25 times per second to update the player/monster positions, handle collisions, trigger events etc.

gloommap.cpp

Loads and sets up the map object, along with things like textures and events that any particular map uses.

gloommaths.h

Trigonometric/squareroot implementation and lookup tables. Rotation matrix and random number functions.

hud.cpp

Health/ammo and gun overlay rendering.

iffhandler.cpp

IFF ILBM decoding. Gloom uses a slightly weird format in that it's removed most of the header information.

menuscreen.cpp

In-game menu rendering and logic.

monsterlogic.cpp

The AI for the monsters (and some other things - for instance, this code also animates pickups).

Gloom uses a big list of all objects in the level. Each object has a "logic" field that's a pointer to a 68K subroutine, which is executed every 1/25th of a second. This field can be switched out with other routines (allowing monsters to switch from "wandering" to "charging" states, for instance). This has been implemented with function pointers. Each object also has "hit" and "die" functions that work in a similar way.

The separation between this and gamelogic.cpp isn't as clean as I'd like.

objectgraphics.cpp

Loads and converts the monster graphics into SDL bitmaps.

quick.cpp

Some 16.16 fixed point helper functions.

renderer.cpp

The, well, game renderer. All software rendering to a 32bit framebuffer.

script.cpp

Handles Gloom's script file, which specifies which level to load next, the intermission screen to use, etc.

soundhandler.cpp

Loading and playing of sound samples. Converts Amiga raw sampledata into something SDL_Mixer can use.

titlescreen.cpp

Handles the titlescreen menu.

zgloom.cpp

The main entry point. Sets up SDL, SDL_Mixer, XMP, etc. The main loop, which uses script.cpp to parse and execute the script.