|
|
|
RoadWarrior
Team Members:
Mike Leib
Chris Berry
Jason Miller
Nate Nuyles
David Barenie
Introduction
-
Road Warrior will be an overhead view, scrolling,
2D racing/shooter game based on the movie Road Warrior. The objective of
the game will be to score points by destroying opponent cars while collecting
powerups to maintain your car, including gas and ammunition. Your vehicle
will have multiple weapons at its disposal. The game will have CD sound,
320x200x256 graphics, enemy AI, and sound effects for now. Time permitting,
we would like to implement joystick and/or multiplayer support.
Project Description
Our design project is a 2-D scrolling game in which the player controls
a car that travels over desert terrain, dodging rocks, bushes, and other
AI controlled cars. Different weapons will be available to the player
to defend himself. The player must also collect ammo and gas for
his car or likely face defeat.
Our design uses arrays of structs to keep track of data for the player
cars, AI cars, weapons, and obstacles that appear on the screen.
Variables are kept in the structs, and are edited by various functions
that take in the offset of a struct to operate on. Two PCX files are used
for the game; one for the cars and objects, another for the background.
The background is a desert image that will scroll down the screen repeatedly
throughout the game. The cars and objects are laid over the background
after scrolling is done and movement is updated. We will use double
buffering for graphics, keeping track of the screen in an image buffer,
then blasting it to the screen when the image is complete.
Direction handling will be done by the keyboard and joystick handlers.
These handlers will set variable values depending on what direction was
most recently pressed by the player, as was done in MP3.
Collisions are handled in a separate buffer. In the collision buffer,
all cars and objects will be approximated as a rectangle, and drawn in
the buffer using an id number specific to each object. To check for collisions,
we check in each direction from the two corners and the midpoint of each
side. This assumes that no object is less that half the length or
width of any other, but it makes for fewer comparisons for AI movement.
Only cars and bullets perform collision checking, and they will call the
appropriate function when a collision occurs. Because of this, obstacles
and items are updated first, then the AI and players are updated.
This is the basic outline of our project implementation. Details concerning
functions and variables can be found in the write-up itself.
Below is a list of constants, variables
and data structures as well as outlines for the procedures we will use.
Constants
The following constants have been defined
for use in our project:
VIDSEG EQU 0A000h ; VGA Video Segment
Adddress
VIDTEXTSEG EQU 0B800h
CLEARPIX EQU 215 ; Clear Pixel in sprite
LINESCR EQU 1 ; How many lines to scroll
at once, used by drawback
NEWCOUNT EQU 8192
OLDVECCOUNT EQU 8
;Constants for the Keyboard handler. (Scan
Codes)
p1_U EQU 72 ;'8'
p1_L EQU 75 ;'4'
p1_D EQU 80 ;'2'
p1_R EQU 77 ;'7'
p2_U EQU 17 ;'w'
p2_L EQU 30 ;'a'
p2_R EQU 32 ;'d'
p2_D EQU 31 ;'s'
;Direction constants
UPLEFT EQU 0
UP EQU 1
UPRIGHT EQU 2
LEFT EQU 3
RIGHT EQU 4
DOWNLEFT EQU 5
DOWN EQU 6
DOWNRIGHT EQU 7
NOMOVE EQU 8
aiup equ 0 ; tells AI which direction
to favor, 0 for up, 4 for down
aidown equ 4
maxhealth equ 200
colminy1 equ 10
colminy2 equ 11
colminy3 equ 12
colminx1 equ 10
colminx2 equ 11
colminx3 equ 12
colmaxy1 equ 20
colmaxy2 equ 21
colmaxy3 equ 22
colmaxx1 equ 20
colmaxx2 equ 21
colmaxx3 equ 22
xmin equ 1
xmax equ 300
ymin equ 1
ymax equ 177
itempos1 equ 0
itempos2 equ 30
itempos3 equ 60
itempos4 equ 80
itempos5 equ 97
itempos6 equ 115
itempos7 equ 132
itempos8 equ 150
itempos9 equ 173
itempos10 equ 195
itempos11 equ 217
itempos12 equ 240
itempos13 equ 262
itempos14 equ 285
itempos15 equ 305
objupmax equ -31
objdownmax equ 201
SceneryMov equ 1 ;how much an rock should
move
NumScenery equ 5
PowerupMov equ 1
NumPowerup equ 3
fireadjust equ 8
FireMov equ 3
NumP1Fire equ 10
NumP2Fire equ 10
fireadjust equ 8
numAI equ 3
FuelAmt equ 20
AmmoAmt equ 100
HealthAmt equ 10
FuelID equ 6
HealthID equ 7
PlayerID equ 32
CarDamage equ 5
CarMovement equ 8
WeaponDamage equ 1
AIMinHealth equ 5
ColAboveLeft equ 0
ColAbove equ 2
ColAboveRight equ 4
ColLeft equ 6
ColRight equ 8
ColBelowLeft equ 10
ColBelow equ 12
ColBelowRight equ 14
; Sound Constants
SAMPLERATE EQU 22025
WAVFile0LENGTH EQU 45312 ;'sounds\deadmsg.wav'
WAVFile1LENGTH EQU 8954 ;'sounds\carhit.wav'
WAVFile2LENGTH EQU 15230 ;'sounds\macgun2.wav'
WAVFile3LENGTH EQU 46874 ;'sounds\morlife.wav'
WAVFile4LENGTH EQU 28774 ;'sounds\diefire3.wav'
WAVFile5LENGTH EQU 38520 ;'sounds\morfuel.wav'
WAVFile6LENGTH EQU 32638 ;''
WAVFile7LENGTH EQU 44414 ;''
WAVFile8LENGTH EQU 44734 ;''
WAVFile9LENGTH EQU 54020 ;''
WAVFile10LENGTH EQU 46874 ;''
WAVFile11LENGTH EQU 38520 ;''
WAVFile12LENGTH EQU 15230 ;''
;PCX File offsets
explosion1offset equ 16961
explosion2offset equ 16983
explosion3offset equ 17005
explosion4offset equ 17028
explosion5offset equ 17052
explosion6offset equ 17075
explosion1w equ 20
explosion1h equ 18
explosion2w equ 21
explosion2h equ 20
explosion3w equ 22
explosion3h equ 20
explosion4w equ 23
explosion4h equ 21
explosion5w equ 24
explosion5h equ 21
explosion6h equ 24
explosion6w equ 21
pcar1offset equ 7681
pcar2offset equ 7701
pcar3offset equ 7721
pcar4offset equ 7741
aicar1offset equ 7761
aicar2offset equ 7777
aicar3offset equ 7793
aitankoffset equ 7809
bossoffset equ 7826
; Widths&Heights for Sprite images
pcarw equ 20
pcarh equ 23
aicarw equ 16
aicarh equ 24
aitankw equ 16
aitankh equ 22
bosswh equ 26
rockoffset equ 24321
rockw equ 33
rockh equ 25
wrenchoffset equ 33282
wrenchw equ 15
wrenchh equ 13
bulletsoffset equ 33968
bulletw equ 4
bulleth equ 3
fueloffset equ 32057
fuelw equ 13
fuelh equ 15
explosion1offset equ 16961
explosion2offset equ 16983
explosion3offset equ 17005
explosion4offset equ 17028
explosion5offset equ 17052
explosion6offset equ 17075
explosion1w equ 20
explosion1h equ 18
explosion2w equ 21
explosion2h equ 20
explosion3w equ 22
explosion3h equ 20
explosion4w equ 23
explosion4h equ 21
explosion5w equ 24
explosion5h equ 21
explosion6h equ 24
explosion6w equ 21
pcar1offset equ 7681
pcar2offset equ 7701
pcar3offset equ 7721
pcar4offset equ 7741
aicar1offset equ 7761
aicar2offset equ 7777
aicar3offset equ 7793
aitankoffset equ 7809
bossoffset equ 7826
pcarw equ 20
pcarh equ 23
aicarw equ 16
aicarh equ 24
aitankw equ 16
aitankh equ 22
bosswh equ 26
rockoffset equ 24321
rockw equ 33
rockh equ 25
wrenchoffset equ 33282
wrenchw equ 15
wrenchh equ 13
bulletsoffset equ 33968
bulletw equ 4
bulleth equ 3
fueloffset equ 32057
fuelw equ 13
fuelh equ 15
; Constants for sounds
WAVFile0LENGTH EQU 45312 ;'sounds\deadmsg.wav'
WAVFile1LENGTH EQU 8954 ;'sounds\carhit.wav'
WAVFile2LENGTH EQU 15230 ;'sounds\macgun2.wav'
WAVFile3LENGTH EQU 46874 ;'sounds\morlife.wav'
WAVFile4LENGTH EQU 28774 ;'sounds\diefire3.wav'
WAVFile5LENGTH EQU 38520 ;'sounds\morfuel.wav'
Variables and Structures
GamePlay (variables used throughout
the game)
NumEnemy- the number of enemies
on the screen
NumScenery-the number of rocks
and other obsticles on the screen
NumPowerUp- the number of powerups
on the screen
NumAmmo- the number of ammo boxes
on the screen
Images
Desert – background graphic
End - end of game graphic
Menu - startup graphic
P1menu, P2menu - Menus for player
configuration
Center, Downrgt, Upleft - Used
for gamepad/joystick calibration
Sprite- graphic file containing
letters and sprites
Buffers (each contained in
their own segment)
CollisionBuffer - a 320 x 200
buffer used to detect collisions during game play
- each entry will contain an id specific to an object
BackgroundBuffer – a 320 x 200
buffer used to hold the background PCX file
SpriteBuffer – a 320 x 200 buffer
used to hold letters and sprites
SoundBuffer – a buffer used hold
sound files
ScreenBuffer – a 320 x 200 buffer
used to hold the video image
ScratchPad – a buffer used by
LoadPCX
Arrays
SceneryArray - contains offsets
to scenery structures
P1FireArray,P2FireArray - contains
offsets to ammo structures for P1 and P2
EnemyArray - contains offsets
to enemy structures
PowerUpArray - contains offset
to powerup (fuel, health, etc) structures
PlayerArray - contains offsets
to player structures
Player Struct
SpriteX - x coordinate
to the upper-left hand corner
SpriteY - y coordinate to the
upper-left hand corner
SpriteW –width of the image graphic
SpriteH –height of the image graphic
SpriteOffset - Offset of sprite
in sprite.PCX
CollisionW - width of the area
in which a collision may occur
CollisionH - height of the area
in which a collison may occur
State – defines state of the player
(i.e active, blowing up, etc)
Health –amount of damage the player
may take
Direction –direction player is
headed
WeaponType –kind of ammo the player
shoots
Gas –amount of gas the player
has
Ammo –amount of ammo the player
has
Score – player score
ColX1 - Left Collision X coordinate
ColX2 - Middle "
ColX3 - Right "
ColY1 - Upper Collision Y coordinate
ColY2 - Middle "
ColY3 - Bottom "
ID - ID for use in CollisionBuffer
InitDir - Used by AI players,
0 = move up, 4 = move down
AIState - Used by AI player to
determine how agressive AI is
Item Structure (Includes Rocks,
PowerUps, and Bullets)
SpriteX - x coordinate
to the upper-left hand corner
SpriteY - y coordinate to the
upper-left hand corner
SpriteW –width of the image graphic
SpriteH –height of the image graphic
SpriteOffset - Offset of sprite
in sprite.PCX
CollisionW - width of the area
in which a collision may occur
CollisionH - height of the area
in which a collison may occur
State – defines state of the powerup
ID - ID for use in CollisionBuffer
Direction – direction powerup
is moving
Unless Otherwise stated, all procedures will
be C style procedures
‘*’indicates a non-C style procedure
GameMenu - Chris Berry
Purpose: Display Intro, Get game
options
Input: MenuChoice (Input From Keyboard)
Outputs: numGamePlayers, p1Control,
p1Control, Joystick Calibration values
DrawBack - Mike Leib
Purpose: Draws background into
ScreenBuffer (Scrolls background)
Inputs: BGPCXfile
Outputs: A scrolling background in ScreenBuffer
DrawSprite - Mike Leib
Purpose:Draws a sprite whose
upper left corner is (x,y) with width W, height H, and an offset to the
sprite
Notes: modified DrawRectangle from mp4
DrawPlayer - Mike Leib
Purpose: Uses DrawSprite to draw
players to screenbuffer
Inputs: Player1 and Player2 structures
Outputs: Player sprites in DrawScreen
DrawScenery - Mike Leib
Purpose: Uses DrawSprite to draw
Scenery(rocks) to screenbuffer
Inputs: SceneryArray
Outputs: Rocks/scenery drawn to screenbuffer
DrawPowerUp - Mike Leib
Purpose: Uses DrawSprite to draw
PowerUps to screenbuffer
Inputs: PowerUpArray
Outputs: PowerUps (gas, ammo, health)
drawn to screenbuffer
DrawP1Fire/DrawP2Fire - Mike Leib
Purpose: Uses DrawSprite to draw P1/P2
Fire to screenbuffer
Inputs: P1FireArray/P2FireArray
Outputs: P1Fire/P2Fire written to screenbuffer
DrawAI - Mike Leib
Purpose: Uses DrawSprite to draw
AI players to screenbuffer
Inputs: AIPlayerArray
Outputs: AI players written to screenbuffer
UpdateAI - Mike Leib
-
Purpose: Updates the AI array
-
Inputs: EnemyArray
-
Outputs: Sets new SpriteX, SpriteY, CollisionW,
CollisionH, SpriteH, SpriteW, Direction for the AI player
Note: This function also contains the
AI for enemy vehicles. Assistance may be provided by David Barenie
EnemyAI - Mike Leib
Purpose: Determines the next
direction for the AI player by comparing the AI's X,Y coords with the player's
X,Y coords and checking CollisionBuffer for obstacles.
Inputs: Xposai, Yposai, Xplayer, Yplayer,
AIplay
Outputs: aidir, new direction for AI
UpdatePlayer1Pos - David Barenie
-
Purpose: Updates the Player’s structural
varibles
-
Inputs: p1KeyDir, player struct
Outputs: Sets new SpriteX, SpriteY, Colx1,
Colx2, Colx3, Coly1, Coly2, Coly3, and Direction for the Player
PlayerExplosion - David Barenie
-
Purpose: Sets the player object to display
an explosion
-
Input: play (a player structure)and uses
setplayerexplosion
Output: a player stuct modified so that
it displays an explosion
SetPlayerExplosion - David Barenie
-
Purpose: initializes a player struct with
the given explosion image
-
Inputs: play(a player struct), explosionoffset(an
offset to the explosion in the sprite buffer) explosionw(the width of the
explosion), explosionh(the height of the explosion)
Outputs: an initialized player with explosions
as image
UpdateObjectPosition - Jason Miller
Purpose: This macro is used to
update the positions of rocks, fuel, health, ammo, and weapon fire.
Inputs: Num -- the number of objects
array -- an array of objects
struct -- the type of structure
movement -- the amount the objects are to move
Outputs: updates the y positions of the
objects
Notes: all original code that combined
the updating of specific objects into one macro
UpdateSceneryPos – Jason Miller
-
Purpose: Updates all scenery structrual varibles
-
Inputs: SceneryArray
-
Outputs: Sets new SpriteX, SpriteY, CollisionW,
CollisionH, SpriteH, SpriteW, for the scenery
-
Notes: uses UpdateObjectPosition macro
UpdateP1FirePos – Jason Miller
-
Purpose: Updates all ammo structrual varibles
Inputs: AmmoArray
-
Outputs: Sets new SpriteX, SpriteY, CollisionW,
CollisionH, SpriteH, SpriteW for the ammo
-
Notes: uses UpdateObjectPosition macro
UpdatePowerPos – Jason Miller
-
Purpose: Updates all the fuel stuctural varible
-
Inputs: PowerUpArray
Outputs: Sets new SpriteX, SpriteY, CollisionW,
CollisionH, SpriteH, SpriteW for the fuel
-
Notes: uses UpdateObjectPosition macro
UpdateTime1 - Jason Miller
Purpose: Keeps track of player
1 time
Inputs: uses timescore1
Outputs: sets player 1 seconds and minutes
Notes: timescore1 is compared to 144
to make close to real time as possible
UpdateTime2 - Jason Miller
Purpose: Keeps track of player
2 time
Inputs: uses timescore2
Outputs: sets player 2 seconds and minutes
Notes: timescore2 is compared to 144
to make close to real time as possible
GenerateObjects – David Barenie
-
Purpose: Decides whether or not to add more
objects to the screen
-
Inputs: EnemyArray, SceneryArray, PowerUpArray
Outputs: Activites a new enemy, scenery,
and power up for the game
Generateai - David Barenie
-
Purpose: Creates a car and activates it only
if that car is currently inactive by calling generateaicar
Inputs: uses ai cars, calls generateaicar
Output: initialization of an enemy car
so that it can be put on screen
-
-
GenerateAIcar - David Barenie
-
Purpose: initializes a player structure
-
Inputs: playe (a player struct), x1, x2,
x3,(positions in the x direction), y1, y2, y3, (positions in the y direction),
aiir (direction), uses randomnumgen
Output: an initialized player structure
Generateobjects - David Barenie
-
Purpose: uses output from random generator
to create rocks and powerups
-
Inputs: uses randomnumgen, generatepoverups,
generaterocks
Output: initializes one item on the screen
each time it is called
-
Generaterocks - David Barenie
-
Purpose: initializes a rock at the given
position
-
Inputs: generatepos uses generateitem
Outputs: an initialized rock
-
Generatepowerups - David Barenie
-
Purpose: uses a random number to determine
which power up to generate
-
Input: generatepos (an item position) uses
randomnumgen, generateitem
Output: an initialized powerup
-
Generateitem - David Barenie
-
Purpose: Initializes an item structure
-
Inputs: item2b (offset of the item(a struct
type) to be generated), x (x position to generate item at) y (y position
to generate item at), z (byte representing the direction)
Output: an initialized item struct
RandomNumGen - Mike Leib
-
Purpose: Generates a random number less than
X
-
Inputs: X- word
Outputs: A psuedo random number in randnum
(a word)
InitColBuf - Jason Miller
Purpose: Initialize the Collision
Buffer every game cycle
Inputs: none
Outputs: Initialized Collision Buffer
Notes: Modified InitBuffer from mp4
DrawColPoint - Jason Miller
Purpose: draws a valid point
in collision buffer if no collision is detectet if collision is detected
then set ColHappened and give ColId the id of what was already in Collision
Buffer
Inputs: X and
Y location of the point to be drawn the id of what is being drawn
Outputs: Draws a point in Collision Buffer
Notes: Modified
DrawPoint from mp4
DrawColObj - Jason Miller
Purpose: draws an outline of
an object in Collision Buffer
Inputs: the upper right corner of object
(X,Y) the width and height of the object the id of the object
Outputs:an outline of an object in Collision
Buffer
Notes: original code that draws a rectangular
ouline of all the objects
that will be used in collision checking
CollisionBuffer - Jason Miller
Purpose: Provides all the collisions
for the RoadWarrior game. In doing so it provides a buffer of all the
objects for the Ai to use.
Inputs: SceneryArray, AmmoArray, PlayerArray,
PowerUpArray
Outputs: Checks for collisions between
all objects in RoadWarrior
Notes: All original code. This is the
heart of the game play.
DrawStats – David Barenie
-
Purpose: takes information from the player
struct and from global variables and puts it on the screen
-
Inputs: uses player1, player2, drawtext and
binasc
Output: puts status on screenbuffer
-
StickHandler - Chris Berry
-
Purpose: Grabs game control commands from
the joystick.
StickHandler: Sets weaponPressed to (1)
if P1_weapon was pressed
Sets p1KeyDir to one of 8 directions, depending on P1U, P1D, P1L, or P1R
-
Inputs:
none
-
Outputs:
p1KeyDir, Fire1
-
Notes:
calls SetDirection to calculate direction
Calibrate - Chris Berry
-
Purpose: Sets values for max, min, and center
positions of the X and Y axes.
-
Inputs: None
-
Outputs: x1Max, y1Max, x1Min, y1Min, x1Cen,
y1Cen, Fire1
-
Notes: Uses a polling loop to get values
SetDirection/SetDirection2 - Chris
Berry
-
Purpose - Set player direction variable
-
Inputs - Current keypress directions
-
Outputs: p1KeyDir, p2KeyDir
-
Notes: Uses keyboard values to detect the
next direction of the given player
Functions by Nate Nuyles\
InstallSoundIntV
-
Purpose: Installs soundcard interrupt vector
Inputs: SBIRQ=IRQ of soundcard
Outputs:
OldSoundV = Far address stored at interrupt
vector tabl
-
SoundISR address put into interrupt vector
table
-
Calls: None
DeinstallSoundIntV
-
Purpose: Deinstalls soundcard interrupt vector
Inputs: SBIRQ=IRQ of soundcard
-
Outputs:OldSoundV – Far address stored at
interrupt vector table
Original vector address put into interrupt vector table
-
Calls: None
DSPReset
-
Purpose: Reset the SoundBlaster DSP so that
it can be programmed.
Inputs:
SBAddr = SoundBlaster DSP Base address
Outputs: AL = 0 reset unsuccessful
(wrong port, no card found)
AL = AAh card found and reset successfully
Calls:
None
Notes: Writes
a 1 to the reset port
Waits 3 microseconds
Writes a 0 to the reset port
Polls read buffer status until bit 7 is set
Polls read data port until AAh is received
DSPRead
-
Purpose: Reads in.data from the DSP when
the data is available from the read data port
Inputs:
SBAddr = SoundBlaster DSP base address
Outputs: AL = byte read in
Calls:
None
Notes:
DSP ready for read when bit 7 of SBAddr+0Eh is set
DSPWrite
-
Purpose: Sends commands and data into
the DSP via the write data port
Inputs: AL =
DSP command
SBAddr = Sound Blaster DSP base address
Outputs: Writes data to the DSP
Calls:
None
Notes: DSP ready
for write when bit 7 of SBAddr+0C is cleared
SpeakerOn
-
Purpose: Turns on speaker
Inputs:
None
Outputs: Turns on the speaker
Calls:
DSPWrite
Notes: Calls
DSPWrite with AL = 0D1h
SpeakerOff
-
Purpose: Turns off speaker
Inputs: None
Outputs:
Calls: DSPWrite
Notes: Calls DSPWrite with AL =
0D3h
DMASetup
-
Purpose: Sets up DMA controller for transfer
Inputs:
DX = segment of the file to be transferred
SI = offset of the file to be transferrred
SBAddrr = SoundBlaster base address
FileLength = length of the file transferred
-
TimeConstant=256-1000000/freq
Outputs: None
Calls:
None
Notes:
Does the following steps:
Calculates page and page offset of the memory block to be transferred
Turns off DMA channel, masks off the mask register
Clear the byte pointer flip/flop
Write the transfer mode to the mode register
Write the page offset to the DMA base address
Write the length to the count register = samplelength-1
Write the page # to the page register
Re-enable the DMA channel, masks off the mask register
PlayWAV
-
Purpose: Loads WAV file into SoundBuffer,
sets the time constant, and plays the WAV file
Inputs:
WAVNum=# of wave file to be played
Outputs: Plays the WAV file
SoundWAVOn = 1
Calls:
LoadSound
DMASetup
-
DMAReset
LoadSound
-
Purpose: Loads sound file into memory, soundBuffer
Inputs:
DX = Source offset of the sound file
Outputs: SoundBuffer
segment contains the sound file
Calls:
None
Notes: Uses DOS
file commands to open and load sound files into SoundBuffer segment
SetMixerVol
-
Purpose: Sets the Master
Inputs:
SBAddr = SoundBlaster DSP base address
Outputs: Sets the Master
volume
Notes:
Writes the index of the mixer chip to the address port at SBAddr+04h
Writes the mixer register value to the data port at SBAddr+05h
3 bits per channel, giving 8 levels. 0 to 7, -46dB to 0dB in approcimately
4dB steps (default is 4 = -11dB)
SoundISR
-
Purpose: The interrupt service routine that
handles the hardware interrupts (IRQ) generated by the DSP.
Inputs:
SBAddr = SoundBlaster DSP base address
Outputs: Sends IRQ acknowledge
signals to DSP and PIC
Calls:
None
Notes: When DMA
transfer is complete an interrupt is generated.
Interrupt number depends on SoundBlaster’s IRQ
To service:Acknowledge the DSP interrupt
by reading data available port SBAddr+0Eh once
If more blocks to transfer set then up
-
Output to EOI 20h to PIC at port 20h
CDAPlay
-
Purpose: Play desired CD track
Inputs: None
Output: CD Music
Calls:
None
CDAStop
-
Purpose: Stop playing CD
Inputs:
None
Output: Stops
CD Music
Calls:
None
-
Predefined procedures borrowed from mps.
*InstTimer, *DeInstTimer, *MyTimerHandler
– modifications made by Chris Berry
-
Purpose: Controls pace of game through timer
interrupts
-
InstTimer:Saves default interrupt vector
in OldTimerV.
Points the timer interrupt to MyTimerHandler.
Configures timer chip to send a signal ? times per second. DeInstTimer
-
Restores OldTimerV as the default timer routine.
Reconfigures the timer chip to send a signal 18 times per second.
MyTimerHandler: Increments timerCount
each time that it is called.
Calls OldTimerV 18 times per second (i.e., every fourth time).
Sends ACK and end-of-intterrupt.
-
Inputs: none
for InstTimer
OldTimerV for DeInstTimer
timerCount for MyTimerHandler
Outputs: OldTimerV for InstTimer
none for DeInstTimer
timerCount for MyTimerHandler
*InstKey, *DeInstKey, *MyKeyHandler
- modifications made by Chris Berry
-
Purpose: Grabs game control commands from
the keyboard
-
InstKey: Saves default interrupt vector in
OldKeyV
DeInstKey: Restores default interrupt
vector from OldKeyV
MyKeyHandler: Sets escPressed to one
(1) if the escape key is pressed.
-
Sets KeyDir to one of 8 directions, depending on whether
-
which directional key is pressed were pressed.
-
Values are set until key is released
Sets weaponPressed to (1) depending on whether P1_weapon was pressed.
Sends ACK and end-of-interrupt.
-
Inputs:
none for InstKey
OldKeyV for DeInstKey
none for MyKeyHandler
-
Outputs:
OldKeyV for InstKey
none for DeInstKey
escPressed, p2KeyDir, p1KeyDir, Fire1, Fire2
ModeGraph
-
Purpose: Changes mode to 13h
ModeText
-
Purpose: Changes to 80 x 50 text mode
DrawScreen
-
Purpose: Draws ScreenBuffer to Video memory
Inputs: ScreenBuffer
Outputs: Writes ScreenBuffer to memory
DrawText
-
Purpose: Draws a text string with upper-left
corner starting at (X,Y) and color Color.
Inputs: (X,Y, and Color), SI=string offset
Outputs: Writes points representing a
text string to Screenbuffer
*LoadPCX
-
Purpose: Loads and decodes a 320x200 PCX
file into memory and sets VGA Palette registers to those used by the image.
Inputs: AX =
Segment in memory where image content should be written.
DX = Offset of a null-terminated string containing the filename.
Outputs: Fills destination (DestSeg:0)
with image data.
Fills VGA palette registers with image colors.
Uses ScratchPad to hold compressed image data.
-
Main()
-
Set interrupt handlers
-
Call intro
-
Call control menu
-
Load background and sprites
into memory
-
Check for end of game,
jump to 11
-
Draw background, objects
and stats to Screenbuffer
-
Draw buffer to screen
-
Update positions of background
and objects
-
Clear collision buffer,
draw new collision buffer and check for collisions
-
Loop to 5 unless escPressed
is 1
-
Call game end
-
Restore interrupt handlers
-
Exit to dos
|