Final Project: 3Alarm


Team Members:
Steve Holstein: Team Leader, Protected Mode, Game Engine, Graphic FX
Fa Yoeu: Sound FX, Status Screen
Damir Orucevic: Beta Tester
Azra Jaganjac: Menu System

Introduction:

Our game will be based on a text graphics game called PYRO II (available at the link).  Our version will be done in 640x480x256 with a four screen scrolling playfield.  The playfield will be rendered from 3D free rotating texture mapped cubical object primitives.  Explosion and fire will move, rotate, and destroy these objects, increasing the player's score.  The sound system will be able to play midi as well as raw files at the same time.  The game engine will operate on a message structure in order to incorporate future network and AI play.   We plan to minimize the use of stored images and at the same time increase the entertainment value of the game by modeling in code graphic effects such as fire, explosions, smoke, etc.  The large memory requirement of graphics and sound will be simplified by implementing our code in protected mode, using a dos extender.
 

Problem Description:

The most challenging part of coding this game was learning about how to get around in the protected mode environment.  Most of the things that will have been doing in class will have to be reimplemented.  No debugger can assist us while writing the code.  The overhead for this game will be enormous.  Our code will have be fully optimized.
 

Implementation:

We will be using the wdosX  windows protected mode extender.  This will grant us access to 4 gigs of memory.  The Playfield contains all of the objects.  Its dimensions are 80 by 60.  It hold all of the objects in a level.  A 20 by 20 section will be clipped and rendered to the screen on the fly on each frame update.  The keyboard and timer will be interface through virtual interrupts.  All 3D math will be solved using integer arithmetic in order to reduce processing time.  Fire will be modeled by a real time pixel averaging algorithm.  The game engine will handle the rules of the game and the movement of objects.  The game engine will call a series of update procedures: UpdatePlayer, UpdateFire, UpdateGas, and Explosion.  Sound effects will be provided to play RAW files.  To play midi, we will use Midpak.

Data Structures:
GameRate Speed at which the game will run
VideoSel Selector to the video memory.
ScrSel Selector for the Screen Buffer.
ScrHnd Handle for the screen buffer.
FileSel Buffer for the file input.
FileHnd Handle to a file buffer.
PCX_Sel Selector to PCX buffer.
PCX_Hnd Handle to PCX buffer.
FireBuffer Buffer for the fire modeler
Player Structure
    X, Y, Gas, Score, Damage, Lives, Level, Direction, NDir (next direction)
PlayField Array PlayFieldObj
    PlayFieldObj
        Floor, Gas, Wall, Fuse, Tank, and Stairs

RM_Register

Use for realmode callbacks.

Protected Mode (All procedures by Steve Holstein)


GetSelector
Purpose: Allocate memory and returns a selector.
Input: DX size in 64k segments of selector
Output: AX is a selector
             EBX is the memory handler
KillSelector
Purpose: Deallocate memory and selector.
Input: AX is the selector, EBX is the memory handler.
Output: None

Graphics (All procedures by Steve Holstein)


DrawScreen
Purpose: Clips a section of the playfield and renders it on to the screen.
Inputs: PlayerX, PlayerY, Playfield
Output: ScrSel
DrawBuffer
Purpose: Dumps the buffer to the video memory.
Input: AX selector to a buffer.
LoadPCX
Purpose: Loads a 640x480 file into memory along with the VGA palette.
Input: EDX offset to ASCIIZ filename
Output: Fills PCX_sel with image data
DrawPCX
Purpose: Dumps PCX_sel to the scr_sel.
InitFire
Purpose: Clear the fire buffer
UpdateFire
Purpose: Render a new fire in the fire buffer
DrawFire
Purpose: Draws a fire to the screen buffer.
Input: EBX=x, EAX=y
DrawWall
Purpose: Renders a 3D wall onto the screen.
Inputs: EBX=x, EAX=y

Sound (Coded by Fa Yoeu)

PlayTank:

     Purpose: Play a random sound

playRAW

Purpose: Play a sound
Input: SoundSeg segment of sound

InitSound

Purpose: read in sounds into a buffer

GetSndBuffer

Purpose load files into dos low memory area
Inputs  filename 0 terminated ascii string
Output  Sound_Sel  selector to data
             Sound_Seg  real mode segment of data
             Bsize size of data
PlayFM
Purpose: Sets up the sound card and plays the song.
Input: EDI is a selector to the song
StopFM
Purpose: Stops the song
PlayDSP
Purpose: If nothing is currently playing then it load the sound file into the DMA buffer and initializes the transfer and turns on the speaker.
Input: EDI selector to sample
StopDSP
Purpose: Turns off DMA transfer and turns off the speaker.

Game Engine (Coded by Steve Holstein)


Game Engine

UpdateGasFire

Purpose: Advance Gasoline and Fire by one tile. Explode Gasoline tanks.
Input: Playfield Array
Explosion
Purpose: Sets fire to a whole buch of stuff (Our favorite procedure).
Main
Purpose: Allocates all of the selectors.
Calls: Game intro, and Menu
LoadLevel
Purpose: Load a playfield from a level.
Output: Playfield Array
CopyPF
Purpose: Copies the playfield for use by UpdateGasFire.
GameIntro
Purpose: Introduction to the game.
GameMain
Purpose: Setup the Graphics Card and sound.   Initializes the game structure.  Handles the game engine.



Menu System (Coded by Azra Jaganjac)



Menu
Purpose: Setup game environment (Timer and Keyboard INT).
Calls: Game Main.
 

Interrupts (Coded By Fa Yoeu)


(these procedures were reimplemented from the previous MP)
MyTimerHandler
Purpose: Increments timer counts.
Input: TimerCount
Output: TimerCount is incremented.
Init_Timer
Purpose: Grabs the interrupt handler.
Hook_kyb
Purpose: Grabs the keyboard interrupt handler.
MyKeyHandler
Purpose: Check for the esckey, spacebar, and other control keys.

SetIRQvect (This is orginal)

Purpose: Uses DPMI calls to point protected mode int vector to our code
Input: x the interrupt number edx offset of interrupt handler
 

Status Screen (Coded by Fa Yoeu)


DrawStatusScr:

Purpose: update screen with status information (health, lives, score)
 

DisplayDamage:

Purpose: draw damage bar
Input: PlayerDmg

DisplayLives:

Purpose: draw lives info to screen
Input: PlayerLvs
 

DisplayScore:

Purpose: draw score to screen
Input: PlayerScr

External Routines (Borrowed from Lectures and MPs)


DSPWRITE

DSPREAD

ConvertSeg

Dsp_irqdone

LoadPCX (reimplemented see above)

deinit_timer

init_timer