ECE 291 Final Project

ATTACK!
Russian Air Strike
Programmers:
Project Members:
Craig Poirier,
Vladimir Peck
Introduction:
The point of the game is to invade the United States and drop off Boris Yeltsin at the White House.
The game will be similar to 1942, in which an airplane will fly up a scrolling backgound. Our game will
involve a helicopter moving up a scrolling background. The object of the game will be to destroy enemy
helicopters. We will use animation, scrolling background, vga graphics, midi sound, and digital sound effects.
The game will keep track of scoring. The main goal of the project is to get a scrolling foreground that works with
a scroling background that works functioning score and music.
Problem Description:
The biggest challenge our group faces is the foreground. The foreground needs to keep
track of all the enemy helicopters, your helicopter, and friendly and enemy gunfire. The foreground must see
if collision occurs between any of these objects and must also keep track of the gun fire for each
plane. The Scrolling background is also something new to us which will take time to implement. Sound of course
will be a challenge since we are trying to have midi throughout the game and digital sound effects for the gunfire
and explosions in the game.
Implementation:
The game is implemented with a vertically scrolling background. Three Segments are used for minipulating
the backgrounds since the program can used an unlimitted number of background PCXs. Foreground, score, music,
and sound also have there own segments loaded with their respective data. All keyboard commands will be
controled by setting the certain variables to one or zero depending on if the key is pressed or not.
Score and lives will be stored in an array. In addition to just showing the score, the score can be incremented
correctly by using Scorearray. Then, Scorearray is used to access the correct offsets of the score graphics.
The same procedure is used in the menu screen for the choice button. Midi is implemented with midpak, and
sound effects with digpak. The hardest part, the foreground, is implemented with an array that maps the positions
of the 320*200 screen occupied by a helicopter or gun fire.
ScreenShots
Procedures:
- LoadPCX (by Craig Poirier)
- Inputs:
ax - Destination segment address
dx - Pointer to a null-terminated string containing the filename
- Outputs:
Destination segment - fills this with image data
VGA palette - palette registers filled with image colors
- Description:
Decodes a PCX file to the destination segment.
Also, sets pallete with the colors specified in the PCX file.
- LoadPCXPallete (by Craig Poirier)
- Inputs:
ax - Destination segment address
dx - Pointer to a null-terminated string containing the filename
- Outputs:
Destination segment - fills this with image data
- Description:
Does everything LoadPCX does but does NOT load VGA palette.
- ShowScreenBuffer (by Craig Poirier)
- Inputs:
ScreenBuffer
- Outputs:
Writes directly to the screen
- Description:
Transfers data that is in screen buffer to the screen.
- CopySegment (by Craig Poirier)
- Inputs:
AX - SEG ONE
- Outputs:
BX - SEG TWO
- Description:
Loads the Segment specified by AX into Segment specified by BX.
- MoveSegments (by Craig Poirier)
- Inputs:
AX - SEG ONE
BX - SEG TWO
EDX - SplitPoint(0..63680)
- Outputs:
NONE
- Description:
Loads ScreenBuffer With AX(SEG)+BX(SEG) Split By EDX(0..36380).
AX is loaded to the top half of the buffer, and BX into the bottom half.
- SwapSegments (by Craig Poirier)
- Inputs:
AX - SEG ONE
- Outputs:
BX - SEG TWO
- Description:
Swaps the Segment specified by AX with the Segment specified by BX.
- Intro (by Craig Poirier, Vladimir Peck, Kevin Mueller)
- Inputs:
NONE
- Outputs:
ScreenBuffer
- Description:
Displays game introductory screens.
This involves displaying several PCX files which are advanced by pressing enter or exited by pressing escape. Calls LoadPCX, StartMenu, WaitForKey.
- Setup (by Craig Poirier)
- Inputs:
Segments - The segments needed for background, foreground, score, sound, and midi
- Outputs:
NONE
- Description:
Loads all the screens and sounds needed for the game into their respected segments. Calls LoadPCX, ShowScreenBuffer.
- ShowScore (by Craig Poirier)
- Inputs:
ScoreArray - The Current score of the player
LookUpScore - An array with pixel offsets accessed by ScoreArray
- Outputs:
Screenbuffer - Segment Which will be outputed to the screen
- Description:
Moves the score characters to the Screenbuffer so that it can be displayed on the screen.
- CalculateScore (by Craig Poirier)
- Inputs:
ADDSCORE - If 1 Then increment Score
- Outputs:
ScoreArray - Incremented if ADDSCORE is 1
- Description:
Increments the Score array if addscore is 1 and only allows each word in the array to get as big as 9 then resets it to zero.
- ShowLives (by Craig Poirier)
- Inputs:
Lives - Number of lives left for the player
- Outputs:
Screenbuffer - What will be shown on the screen
- Description:
Shows the number of lives which the player has left on the screen.
- StartMenu (by Craig Poirier)
- Inputs:
CurrentMenuButton - What the button points to
MenuButtonArray - Offsets of where the button should be on the screen
- Outputs:
NONE
- Description:
Helper function for Intro Procedure. Displays the menu screen and allows user to move the pointer on the screen. Calls ShowInstructions, ShowHistory, LoadPCX, ShowScreenBuffer.
- ShowInstructions (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Shows the instruction screens for the game. Calls LoadPCX, ShowScreenBuffer.
- ShowHistory (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Shows the History screens for the game. Calls LoadPCX, ShowScreenBuffer.
- WaitKeyPress (by Craig Poirier)
- Inputs:
RETURN - 1 if return is pressed
_ExitFlag - 1 if escape is pressed
- Outputs:
NONE
- Description:
Will wait until return is pressed or escape key is pressed. If escape is pressed it will call ExitGame Procedure
- MyKeyInt (by Craig Poirier)
- Inputs:
Buttons - Buttons pressed on the keyboard
- Outputs:
_ExitFlag - Set to 1 if esc is pressed
RIGHT_ARROW - Set to 1 if Right Arrow is pressed
LEFT_ARROW - Set to 1 if Left Arrow is pressed
UP_ARROW - Set to 1 if Up Arrow is pressed
DOWN_ARROW - Set to 1 if Down Arrow is pressed
SPEEDUP - Set to 1 if Z is pressed
FIRE - Set to 1 if CNTR is pressed
- Description:
Replaces the default keyboard interrupt routine with our own routine.
- InstKey (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Stores the old keyboard vectors so when the program stops it can restore the old vectors. Also Initializes the Keyboard handler.
- DeInstallKey (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Restores the old Keyboard vectors so dos can function correctly again.
- ExitGame (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Safely exits the game by deinstalling the keyboard, setting back to text mode, and calling DOSXIT. Call DeInstallKey, ModeText, DOSXIT.
- PlayerPosition (by Vladimir Peck)
- Inputs:
Player_X - X position of player
Player_Y - Y position of player
Keyboard variables - variables describing state of game keys
- Outputs:
None
- Description:
Processes player movements. Checks for collisions with other objects and boundaries.
Calls Collision, DrawObject, ClearObject.
- EnemyPosition(1-4) (by Vladimir Peck)
- Inputs:
Enemy(1-4)_X - X position of enemy
Enemy(1-4)_Y - Y position of enemy
Enemy(1-4)Wait - how long to wait before enemy reappears
Enemy(1-4)Count - how far to move in the same direction each time
Randval - random number used to give a random direction of movement for the enemy
Player_X - X position of player
Player_Y - Y position of player
- Outputs:
None
- Description:
Processes enemy movements. Checks for collisions with other objects and boundaries.
Checks for collisions with other enemies and the player. Calls Collision, DrawObject, ClearObject.
- GunFire(1-3) (by Vladimir Peck)
- Inputs:
BulletLoc(1-3) - Offset of position to start bullet
Enemy(1-4)_X - X position of enemy
Enemy(1-4)_Y - Y position of enemy
- Outputs:
None
- Description:
Processes gunfire movement. Checks for collisions with other objects and boundaries.
Checks for collisions with enemies. Calls Collision, DrawObject, ClearObject.
- EnemyGun(1-4) (by Vladimir Peck)
- Inputs:
EnemyBulletLoc(1-4) - Offset of position to start bullet
Enemy(1-4)Wait - X position of enemy
Enemy(1-4)_X - X position of enemy
Enemy(1-4)_Y - Y position of enemy
EBCount(1-4) - count to wait before firing next bullet
Player_X - X position of player
Player_Y - Y position of player
- Outputs:
None
- Description:
Processes enemy gunfire movement. Checks for collisions with other objects and boundaries.
Checks for collisions with player and other enemies. Calls Collision, DrawObject, ClearObject.
- DrawObject (by Vladimir Peck)
- Inputs:
Ax - Location in FGSeg of the ship
Bl - Code for the ship
- Outputs:
Updated foreground array
- Description:
Updates foreground array with information regarding ship code and location on screen.
Draws the coded ship to the ScreenBuffer.
- ClearObject (by Vladimir Peck)
- Inputs:
Ax - Location in FGSeg of the ship
Bl - Code for the ship
- Outputs:
Updated foreground array
- Description:
Clears the ship in the foreground array.
- Collision (by Vladimir Peck)
- Inputs:
Ax - Location in FGSeg of the ship
Bl - Code for the ship
- Outputs:
Ax = 1 - Collision
Ax = 0 - No collision
- Description:
Checks the Ax location (plus dimensions) for zeroes (no ships or bullets). If non-zero value, triggers collision.
- RestartTheGame (by Craig Poirier)
- Inputs:
Lives - Number of lives left for player
- Outputs:
Player_X - reset X location of player
Player Y - reset Y location of player
ScoreArray - holds score for the game
ScreenDivider - when to split the background screen
ScreenNumber - number of screen to show in the background
RestartGame - 0 - game continues
2 - game restarts
- Description:
Checks number of lives. If more than zero, resets player position and decrements lives.
Otherwise restarts game by reseting all game variables.
- DrawExplosion (by Craig Poirier)
- Inputs:
ExplosionLoc - location to draw explosion
ExplosionOffsets - the offsets accessed by ExplosionNumber for explosion graphics
ExplosionNumber - number of explosion graphic to draw
ExplosionCount - frames until next explosion graphic in sequence
- Outputs:
ScreenBuffer - what will be drawn to the screen
- Description:
Draws an explosion on the screen by accessing 8 different explosion frames located in the
textseg.
- DrawBlade (by Craig Poirier)
- Inputs:
AX - location to draw blade
ImageBlade - number of helicopter blade to draw
BladeOffset - the offset to the helicopter blade graphics
- Outputs:
ScreenBuffer - what will be drawn to the screen
- Description:
Draws the blades on the screen. Draws four different blade...one for each frame.
- Random (by Craig Poirier)
- Inputs:
Randval - the previous random value
- Outputs:
Randval - the next random value
- Description:
Calculates a random number by manipulating large prime numbers.
- Delay (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Burns clock cycles.
- LoadSound (by Craig Poirier)
- Inputs:
AX - Segment of sound data
DS:[DX] - Points to the sound file name
CX - Length of sound (number of bytes to read)
DI - Offset in memory to write sound to
- Outputs:
NONE
- Description:
Loads sound data from a file into memory. Opens, reads, and closes the file using DOS funtion INT 21h.
- UZI (by Craig Poirier)
- Inputs:
ax - Sound Segment
bx - Offset of the sound
dx - Length of the sound
- Outputs:
NONE
- Description:
Outputs the Uzi Sound for GunFire
- Explosion (by Craig Poirier)
- Inputs:
ax - Sound Segment
bx - Offset of the sound
dx - Length of the sound
- Outputs:
NONE
- Description:
Outputs the Explosion sound for hits and crashes
- SetupMidi (by Craig Poirier)
- Inputs:
ES - Segment address of midseg
SI - Offset of midi file
- Outputs:
NONE
- Description:
Registers an XMIDI file by address for playback by calling function 704 in midpak.
- PlayMidi (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Plays Midi with a function in MidPaK
- StopMidi (by Craig Poirier)
- Inputs:
NONE
- Outputs:
NONE
- Description:
Stops the Midi sound with A function in MidPaK
Borrowed Procedures: We did NOT code these but used them in our prject.
- ModeGraph
- Inputs:
NONE
- Outputs:
NONE
- Description:
Sets video mode to VGA 320 by 200
- Source:
Mr. LockWood MP4
- ModeText
- Inputs:
NONE
- Outputs:
NONE
- Description:
Switch to Text Mode
- Source:
Mr. LockWood MP4
- DOSEXIT
- Inputs:
NONE
- Outputs:
NONE
- Description:
Exits to Dos
- Source:
Mr. LockWood's ECE291.LIB
- RSAVE
- Inputs:
Most of the registers
- Outputs:
NONE
- Description:
Pushes most of the registers
- Source:
Mr. LockWood's ECE291.LIB
- RREST
- Inputs:
NONE
- Outputs:
Most of the registers
- Description:
Pops most of the registers
- Source:
Mr. LockWood's ECE291.LIB
- PlaySound
- Inputs:
AX - Sound segment where sound data is stored.
BX - Offset to selected sound data.
DX - Length of the sound to be played.
SI - Offset of SOUND structure used by Digpak.
- Outputs:
NONE
- Description:
Plays sound effect.
- Source:
From the Web