| ECE291 |
Computer Engineering II |
Spring 1998 |

| Assignment: |
To write our own machine problem |
| Due Date for Demo: |
Thursday, April 30 |
| Final Due Date: |
Friday, May 1 |
| Purpose: |
Create an improved version of Scorched Earth that incorporates a 3D world,
networking, graphics, and sound |
| Project Goal: |
Create an awesome game, get an A, and take home all those nifty awards and
prizes |
Group Members and tasks:
Problem Description
This project combines challenges seen in previous MPs such as graphics rendering,
player movement, input/output, as well as new challenges like networking and sound
integration. It also adds the most obvious and probably the hardest challenge -
working as a group to complete the project. Completing and testing an individual
section of the program, such as all the tasks that were assigned to a member, does not
mean that section is complete. It must still be integrated with the routines written
by the other members. After integration, the whole program must be thoroughly tested
to ensure that the combined procedures interact and function properly with all the other
procedurs. We are planning on finishing the individual routines a week before
demonstration to allow a full week for integration. If all goes well, we will finish
integration early and have some extra days before the demonstration to add a few features
we had to hold off on during planning.
We will have to design our own engines for every aspect of the game. The hardest
of them being the graphics engine. It will have to render the overhead view, side
view, and of course the hardest part, the forward looking view. Another difficult
aspect will be integrating the networking with the rest of the program. Juggling
packets from multiple players and interpreting all of them within a given time period will
require excellent programming and thorough testing. Another challenge, the user
interface, needs to combine ease of use with functionality. After all, if no one can
get past the main menu, the can't play the game. Another difficult part of the
program will be the game play itself. Keeping track of up to ten tanks and ten
weapons along with a constantly changing terrain all at the same time is difficlut a task.
Add to that the control of the computer AI, and you've got quite a challenge.
Mixing the correct sound effects to flow smoothly with the action adds an important
aspect that is needed for any good game. All good games also require an introduction
sequence that grabs the user's attention. Creating the correct sequence is another
formidable task.
Game Description and Operation
This project implements an improved version of the classic Scorched Earth
game. It combines a real time game taking place in a 3D world with 320x200 VGA
graphics, sound, single player against the computer, or multi-player over a network.
The game starts with an introduction screen followed by the main menu with game
type options and game setup options. The actual game screen is divided into a large
display showing the view from the front of the tank, two smaller displays showing an
overhead shot of the whole battlefield and a side view much like the original Scorched
Earth screen, along with a section dedicated to tank status such as turret angle, weapon
power, inventory, health, fuel, etc.
The play will use both the mouse and keyboard (with user defined keys) to
control all aspects of the game play. During the game, the user will be able to
change the view angle, switch weapons, adjust turret angle and weapon velocity, and
navigate the terrain with the mouse and keyboard controls. After targeting an enemy,
the player can select from an arsenal of purchased weapons and let one fly. The real
time nature of the game is somewhat limited in order to preserve the strategic element of
the original game. Due to reload time, players may only shoot their weapons every 10
seconds. Another complication with the weapon system, which is still left
unexplained by the tank's engineers, prevents two weapons from the same player to be in
flight at the same time. Attempting to fire a second weapon causes the first one to
be destructed. If utilized correctly, this "feature" as the engineers
prefer to call it can be used to detonate a near miss directly over an enemy's head,
causing considerable damage.
The battle continues until only one tank is left standing, at which point
the winner of that round is declared, and players receive their money based on performance
in the previous round. The game then enters the buying screen where players may
spend their hard earned money on better weapons, increased shields, and fuel. After
all players (including the computer) have replenished and upgraded their stockpile of
weapons and supplies, the next round begins. Battle after battle are fought until
the previously determined number of rounds have been played, after which the overall
winner is decided and rewarded with a congradulations screen. After the battles, all
the players are returned to the main menu where another battle may be set up to settle
once and for all who the best player is.
Implementation
This program was written entirely in assembly, completely from scratch
(excluding a few adapted functions), including all graphics. The first task was to
divide the game areas between all the members, and each come up with procedures,
variables, and data structures necessary to complete our part of the game. We came
up with five major sections (which is good becaue we have five people in our group) to
break the game into: User interface - I/O & menues, Graphics and sound, Networking,
Game play & AI, and the Game play graphics - 3D rendering.
Next we started on a preliminary game loop that tied together everyone's
functions and gave a good idea exactly what needs to be done. The next task was to
split up and each write our functions, keeping in mind that they need to interact with
eachother's procedures. The main goal for the first week of programming was to get
basic working functions so they can be put together as early as possible. But that
phase ran over the first week, and into the second. We were finally ready to start
integrading code on the Saturday before the project was due. The integration turned
up countless bugs in everyone's procedures that had to be fixed before we could continue.
This continuous integration of new code with the already functional base code
continued until the due date.
We had a playable, yet very buggy alpha version finished
by Tuesday night. It didn't include the forward looking 3D screen, any type of AI
(all computers took the same shot every time), or sound. The 3D rendering was
completed late Wednesday night, the AI was finialized around 4:00 Thursday morning, and
the sound was integrated around 7:00 Thursday morning. Other additions to the alpha
were an improved menu structure, game play that included a dynamic terrain, and other
fixes with the tank and weapon movement and calculation. The beta
version came together at 8:45 Thursday morning, just in time for the 9:00 handin.
This beta still didn't include tanks in the main 3D screen (although they were
visible in the two side screens), networking, or economics. Our demonstration of the
beta Thursday night was flawless.
Screen Shots
 One of the first working alpha's |
 First playable alpha. All the numbers in the main scren
are for debugging the tanks and weapons |
|
|
 Another shot of the playable alpha. This time the numbers
are used for debugging the AI. |
 The playable beta |
|
|
 Another of the beta |
 Yet another one |
|
|
 This is the last one, don't worry |
|
Main Procedure
- Owners: Brandon Tipp, Mike Soukup, Jim Papp, Kevin Slanicky, Marcin
Chwierut
- Purpose: Main game engine that calls and controlls everything.
- Description: It needs to make calls to introduce the game, start the
main menu, drive the game, keep track of type of game, keep track of network or AI
depending on game type, draw the screen, and exit the game.
- Inputs:
- Outputs:
- Calls: almost everything
- Flow of Main:
1) Set up the game - interrupts, tables, etc.
2) Show the introduction and enter the main menu where options can be set, game type can
be selected, and program can be exited.
3) Starts the actual game by asking for the player's name and setting up either a network
or single player game.
4) Give player the option to purchace weapons, and have computer buy weapons (if single
player).
5) Generate the random terrain for the next battle.
6) Enter Battle loop where all player's and computer's (if single player) movements,
shots, and hits are calculated, packets are transmitted and received, and the screen is
rendered and drawn. Stay in loop until only one tank remains.
7) Repeat Battles until desired amount has been reached, and return to the main menu.
8) If player chooses exit, show credits and exit the game.
Miscellaneous Procedures
_SetUpTables
- Owner: Brandon Tipp
- Purpose: To fill in the _SinTable, _CosTable, _CotTable, and the
_DeltaZTable.
- Description: C function that generates look-up tables for functions so
the index into the table will give that function of the angle.
- Variables: none
- Inputs: none
- Outputs:
- _SinTable
- _CosTable
- _CotTable
- _DeltaZTable
- Calls: none
SetUpProgram
- Owner: Brandon Tipp
- Purpose: To set the environment so we can run the game.
- Description: Places computer in 320x200x256 graphics mode and installs
the interrupts.
- Variables: none
- Inputs: none
- Outputs: none
- Calls:
FinishProgram
- Owner: Brandon Tipp
- Purpose: To reset the environment when the game is done.
- Description: Places the computer back into text mode and deinstalls the
interrupts.
- Variables: none
- Inputs: none
- Outputs: none
- Calls:
- DeInstallKey
- DeInstallTimer
RandVal
- Owner: BrandonTipp
- Purpose: Generates a random number.
- Description: Makes a BIOS call to the computer's clock to return the
number of ticks past midnight. This value is then used to initialize _RandSeed.
- Variables:
- Inputs:
- Outputs: none
- Calls: none
QuickRand
- Owner: Brandon Tipp
- Purpose: Generate a random number quickly.
- Description: Multiplies _RandSeed by a prime number and adds in another
prime number to generate a pseudo random number.
- Variables:
- Inputs: none
- Outputs:
- ax - a number between 0000h and FFFFh
- Calls: none
WorldHeight
- Owner: Brandon Tipp
- Purpose: Determine the height of the world at a point.
- Description: If dx is 0, determine the height of the world at the
nearest world cell. If dx is 1, determine the height of the position by
interpolating the four nearest ponts.
- Variables:
- Inputs:
- ax - x position (in 256ths of a cell)
- bx - y position (in 256ths of a cell)
- dx - method of calculation, 0 returns nearest value, 1 interpolates
- Outputs:
- ax - the height (in 256ths of a cell)
- Calls: none
CalculateWorldPosition
- Owner: Brandon Tipp
- Purpose: Calculate the X, Y, and Z position in the world given a
starting point, a heading, a declination, and a range.
- Description:
- Variables: none
- Inputs:
- _X, _Y, _Z - starting points of tank
- _ViewAngle - heading (in 1/3 degrees from +x)
- ax - offset from heading (signed in 1/3 degrees from +x)
- dx - declination (signed in 1/3 degrees from the horizon
- bx - range (index into the Range array pointing to the range)
- WorldArray
- Outputs:
- ax - the x position in 256ths of a cell
- bx - the y position in 256ths of a cell
- cx - the z position in 256ths of a cell
- Calls: none
ChooseHostRandoms
- Owner: Kevin Slanicky
- Purpose: Choose random values for terrain and tank positions.
- Description: Selects random values used to generate the terrain, and
selects random values for placing the host computer.
- Variables:
- TankArray
- _XScale1
- _YScale1
- _XScale2
- _YScale2
- _XPhi1
- _YPhi1
- _XPhi2
- _YPhi2
- Inputs: none
- Outputs: none
- Calls:
ChooseClientRandoms
- Owner: Kevin Slanicky
- Purpose: Choose random values for the Client's position.
- Description: Selects a position for the tank.
- Variables:
- Inputs: none
- Outputs: none
- Calls:
ChooseSingleRandoms
- Owner: Kevin Slanicky
- Purpose: Choose random values for a single player game.
- Description: Selects random values used to generate the terrain, and
selects random values for placing the players.
- Variables:
- TankArray
- NumberOfPlayers
- _XScale1
- _YScale1
- _XScale2
- _YScale2
- _XPhi1
- _YPhi1
- _XPhi2
- _YPhi2
- Inputs: none
- Outputs: none
- Calls:
_CalculateTerrain
- Owner: Brandon Tipp
- Purpose: From the chosen random values, use sine functions to generate
the terrain.
- Description: For a given X and Y coordinate in the world array, the
value of 128 + 128 * {(XScale1/FFFFh*sin(X*pi/125+_XPhi1) +
(_XScale2/FFFFh*sin(X*pi/250+_XPhi2)} * {(YScale1/FFFFh*sin(Y*pi/125+_YPhi1) +
(_YScale2/FFFFh*sin(Y*pi/250+_YPhi2) It does this by filling in the XTable and
YTable, then multiplying the waves stored in these tables by each other.
- Variables:
- XTable
- YTable
- _XScale1
- _YScale1
- _XScale2
- _YScale2
- _XPhi1
- _YPhi1
- _XPhi2
- _YPhi2
- _WorldArray
- Inputs: none
- Outputs: none
- Calls: none
Graphics Procedures
Intro
- Owner: Marcin Chwierut
- Purpose: Introduces the game.
- Description: Displays the introduction screens allowing the procedure
to be interrupted by pressing ESC buton
- Variables: none
- Inputs: none
- Outputs: none
- Calls:
- _InstKey
- _DeInstallKey
- MLoadPCX
- MShowScreenBuffer
- ZoomLogo
- Fade
- MoveScreendn
Outro
- Owner: Marcin Chwierut
- Purpose: Display ending screens.
- Description: Displays ending screens, allows the procedure to be
interrupted by pressing ESC button.
- Variables: none
- Inputs: none
- Outputs: none
- Calls:
- _InstKey
- _DeInstallKey
- MLoadPCX
- MShowScreenBuffer
- Fade
- MoveScreendn
ZoomLogo
- Owner: Marcin Chwierut
- Purpose: Zooms the logo in.
- Description: By taking the starting position and the starting scale
factor, the pcx is scaled to fit the 320x200 screen
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
MLoadPCX
- Owner: Marcin Chwierut
- Purpose: Loads and decodes PCX file into memory.
- Description: Given the offset of the pcx file, and the destination
segment the pcx is loaded to the given buffer.
- Variables: none
- Inputs:
- ax - destination segment address
- dx - offset of the pcx file
- Outputs:
- Fills destination segment with image data
- Calls: none
MShowScreenBuffer
- Owner: Marcin Chwierut
- Purpose: Move 320x200 pixels of screen data from ScreenBuffer to the
screen
- Description: Moves the information in ScreenBuffer to the screen.
- Variables: none
- Inputs:
- Outputs:
- writes data to the screen
- Calls: none
MoveScreenDn
- Owner: Marcin Chwierut
- Purpose: Scroll the screen down.
- Description: Scrolls the screen down by putting the number of lines
into the background buffer and the moving it to screenbuffer after displaying that data.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
Fade
- Owner: Marcin Chwierut
- Purpose: Fades out the screen
- Description: Fades out the screen by decrementing the intensities of
each color in the color palette of the video card until they reach 0.
- Variables: none
- Inputs: none
- Outputs:
- writes to the color palette in video card
- Calls: none
_InstKey
- Owner: Marcin Chwierut
- Purpose: Install new keyboard interrupt.
- Description: Replaces the old interrupt vecor to the new one.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
_DeInstallKey
- Owner: Marcin Chwierut
- Purpose: Reinstall the old keyboard interrupt.
- Description: Replaces the new interrupt vector by the old one.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
MyKeyInt
- Owner: Marcin Chwierut
- Purpose: The acutal key interrupt vector.
- Description: The only key accepted is the ESC key.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
_ClearBuffer
- Owner: Marcin Chwierut
- Purpose: Clears a buffer
- Description: This procedure is used to clear the screen buffer in orer
to output it to the screen between different screens are loaded.
- Variables: none
- Inputs: Segment to be cleared
- Outputs: clean buffer
- Calls: none
DelayProc
- Owner: Marcin Chwierut
- Purpose: Delay
- Description: Used to delay various operations.
- Variables: none
- Inputs: delay amount
- Outputs: none
- Calls: none
Sound Procedures
ProgramDSP
- Owner: Marcin Chwierut
- Purpose: Make appropriate writes to the DSP in order to output the
sound file through the speakers.
- Description: First the speaker is turned on by writing 0D1h to the dsp,
next the output frequency is written to the sound card, then the time constant is written,
and finally the file length is written to the sound card - at this point sound card is
ready to output the file.
- Variables: none
- Inputs: none
- Outputs: none
- Calls:
ProgramDMA
- Owner: Marcin Chwierut
- Purpose: Setup DMA for data transfer
- Description: This procedure first calculates the page and offset, then
disables the dma channel, writes the length of the file in order for the dma to transfer
the right amount of data to the sound card, then it enables the dma channel.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
DSP_Reset
- Owner: Marcin Chwierut
- Purpose: Resets the sound card.
- Description: This procedure writes 1 to the reset port, than it waits
for 3 microseconds, next it writes 0 to the reset port, then it polls the read-buffer
status port, and finally polls the read data port.
- Variables: none
- Inputs:
- Outputs:
- ax - 00h if sound card was sent successfully, AAh if reset was unsuccessful
- Calls: none
PlayWave
- Owner: Marcin Chwierut
- Purpose: Calls appropriate procedures in order to output the wav files
- Description: Main sound effects procedure. First it makes a call
to RESET_DSP, then it sets appropriate volume level, loads the wave file into the
appropriate buffer, calls ProgramDMA. Next it calls ProgramDSP procedure, after that
last call wave file is sent to the sound card and heard through the speakers
- Variables: none
- Inputs:
- ax - offset of the wav file
- cl - LSB left channel volume level, MSB right channel volume level
- Outputs:
- Calls:
- DSP_reset
- ProgramDMA
- ProgramDSP
InstallSBISR
- Owner: Marcin Chwierut
- Purpose: Install the new sound card ISR.
- Description: Based on sound card's interrupt, the new ISR is installed.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
DeinstallSBISR
- Owner: Marcin Chwierut
- Purpose: De-install the sound's ISR
- Description: The old interrupt service routine is set in its oritinal
place
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
DSP_IRQdone
- Owner: Marcin Chwierut
- Purpose: The actual new interrupt routine
- Description: Outputs the value 20h to the interrupt coutroller port 20h
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
PlayMidi
- Owner: Marcin Chwierut
- Purpose: Output the midi file to the sound card.
- Description: Making appropriate int66h calls this procedure sends the
file to the sound card
- Variables: none
- Inputs:
- ax - offset of the midi file
- Outputs: midi file is played
- Calls: none
GetSBSettings
- Owner: Marcin Chwierut
- Purpose: Extract the DMA, IRQ, and sound blaster base address values
from the DOS environment variables.
- Description: Searches for the word BLASTER in the DOS env vars, after
which the IRQ, DMA, and sound blaster base address vlues are located.
- Variables: none
- Inputs: none
- Outputs:
- irq, dmachannel, & sb_addr values are updated
- Calls: none
SetDMA
- Owner: Marcin Chwierut
- Purpose: Set appropriate DMApage, DMAaddress, and DMAcount variables.
- Description: Based on the DMAchannel extracte by the GetSBSettings
procedure, the DAMpage, DAMaddress, and DMAcount values are updated.
- Variables:
- DMAchannel
- DMApage
- DMAaddres
- DMAcount
- Inputs: none
- Outputs: none
- Calls: none
GamePlay Procedures
CalculateMovement
- Owner: Mike Soukup
- Purpose : Controls the movement and firing of a tank.
- Description: Based on the keyboard variables, determines what actions
the tank should perform, and creates a weapon in WeaponArray if necessary. Is also
responsible for playing sound effects.
- Variables:
- Keyboard state variables: TurnRight, TurnLeft, GoForward, GoBack, TurretUp, TurretDown,
VelocityUp, VelocityDown, Shoot, Recharge, SpeedUp, Suicide)
- TankArray - X position, Y position, Z position, View Angle, TurretAngle, Projectile
Velocity, Fuel, Ammunition, and Time Until Next Shot
- WeaponArray (if shot is fired) - all
- Inputs:
- Outputs: none
- Calls:
- WorldHeight
- Sound functions
CalculateWeapon
- Owner: Mike Soukup
- Purpose: Controls the flight of a weapon.
- Description: Calculates where the weapon will be in the next frame
using current position and velocity. Checks if weapon hits a tank or the ground, if
so, detonate it. Also calculates any damage done to tanks or the ground..
- Variables:
- WeaponArray - all
- NukeOnScreen
- WindX
- WindY
- Gravity
- Inputs:
- Outputs: none
- Calls:
CalculateWorldDamage
- Owner: Mike Soukup
- Purpose: Calculates any changes (addition or subtraction of dirt) to
the terrain due to weapon explosions.
- Description: Takes the current blast radius of the exploding weaon and
subtracts or adds dirt to the terrain by iterating through an array containing dirt
decrements/increments and adding/subtracting the value.
- Variables:
- NumberOfPlayers
- WeaponArray
- Radius5, Radius10, Radius15, Radius20, Radius25
- WorldArray
- Inputs: none
- Outputs: none
- Calls: none
SetUpWar
- Owner: Mike Soukup
- Purpose: Reset the variables to starting values.
- Description: Resets the weapon & shield inventory, RoundsWon, and
LastKilledBy fields in the TankArray back to the starting values.
- Variables:
- TankArray
- Rounds
- RoundsLeft
- Inputs: none
- Outputs: none
- Calls: none
SetUpBattle
- Owner: Mike Soukup
- Purpose: Reset TankArray and WeaponArray for the start of a Battle.
- Description: Places tank in a random position on the map, resets the
view agle, turret angle, projectile velocity, heath, and time until next shot.
- Variables:
- TankArray - X position, Y position, Z position, View Angle, Turret Angle, Projectile
Velocity, Health, and Time Until Next Shot
- WeaponArray - all
- Inputs: none
- Outputs: none
- Calls:
ResetBattleLoop
- Owner: Mike Soukup
- Purpose: Resets variables used in battle loop.
- Description: Resets to 0 variables set by CalculateTank and
CalculateWeapon and used by graphics and rendering.
- Variables:
- Selected_Weapon
- WeaponSelect
- Shield_Selected
- ShieldSelect
- NukeOnScreen
- DamageTaken
- NumberOfPlayers
- DamageArray
- Inputs: none
- Outputs: none
- Calls: none
CheckBattleDone
- Owner: Mike Soukup
- Purpose: Check if the battle is over.
- Description: Check if only one tank is alive, and all weapons have been
detonated, which means the battle is over.
- Variables:
- TankArray
- WeaponArray
- NumberOfPlayers
- Inputs: none
- Outputs:
- ax - 1 if battle is finished, 0 if battle is still going
- Calls: none
AI Procedures
ComputerBuy
- Owner: Mike Soukup
- Purpose: Determines what weapons and shields the computer player
purchases.
- Description: Simply picks random weapons for the computer to buy, but
makes sure not to go bankrupt.
- Variables:
- TankArray - Money, Ammunition
- Inputs:
- Outputs: none
- Calls: none
CalculateAI
- Owner: Mike Soukup
- Purpose: Does all the AI work
- Description: Function that is called by main, so it is responsible for
all the AI calls. Calculates any computer movement as a result of terrain changes,
determines who the computer targets, calculates a correct shot, deviates a bit from the
shot, and shoots.
- Variables:
- TankArray
- NumberOfPlayers
- Rounds
- RoundsLeft
- OverallWinner
- WinnerOfLastRound
- Inputs:
- Outputs: none
- Calls:
- WorldHeight
- CalculateCloseShot
- CalculateBetterShot
- ComputerShot
- QuickRand
CalculateCloseShot
- Owner: Mike Soukup
- Purpose: Given a target tank, calculate a shot that will come close to
its target.
- Description: Takes the tank position and target position and calculates
a shot that will hit the target if wind and altitude changes are disregarded.
- Variables:
- Inputs:
- Outputs: none
- Calls: none
CalculateBetterShot
- Owner: Mike Soukup
- Purpose: Change the starting velocity, angle, and turret angle, so a
closer shot is generated.
- Description: By figuring out the distance and angle the previous shot
missed its target by, adjust the velocity, angle, and turret angle, based on how close the
previous shot came.
- Variables:
- Inputs:
- Outputs: none
- Calls: none
ComputerShot
- Owner: Mike Soukup
- Purpose: Have the computer shoot its weapon.
- Description: Creates a weapon in WeaponArray.
- Variables:
- TankArray
- WeaponArray
- _SinTable
- _CosTable
- Inputs:
- Outputs: none
- Calls:
Graphics and Rendering Procedures
RenderGameText
- Owner: Jim Papp
- Purpose: Display any text on the battle screen.
- Description: Writes text to the screen. Fills in numbers next to
the weapons to indicate number left. Writes the message in ScreenTextBuffer to the
bottom of the 3D window.
- Variables:
- TankArray
- ScreenTextBuffer
- SBseg
- Inputs: none
- Outputs: none
- Calls:
RenderOverhead
- Owner: Brandon Tipp
- Purpose: Fill in the 50x50 overhead view of the batle screen.
- Description: Writes to the screen an overhead of the world with
tanks. Shows your position in white and each of the other living tanks in a
different color. All moving weapons on the screen are rendered in red, while
exploding weapons are rendered as an intense red circle.
- Variables:
- WorldArray
- TankArray
- WeaponArray
- SBseg
- Inputs: none
- Outputs: none
- Calls:
RenderSide
- Owner: Brandon Tipp
- Purpose: Fill in the 50x50 side view box.
- Description: Writes to the screen a side view of everything in front of
you including tanks and weapons, limited to a range of MaxRange. (The world is 2500m
across) The weapon is rendered as a red dot when not exploding, and as an intense
red circle when exploding.
- Variables:
- WorldArray
- TankArray
- WeaponArray
- SBseg
- Inputs: none
- Outputs: none
- Calls:
Render3D
- Owner: Brandon Tipp
- Purpose: Fill in the 180x180 forward 3D view box.
- Description: Calls functions that determine the proper color of each
pixel on the screen, and draws the points.
- Variables: SBseg
- Inputs: none
- Outputs: none
- Calls:
- CalculateWorldPosition
- ScaleSprite
- CastBack
CastBack
- Owner: Brandon Tipp
- Purpose: Determine the relative angle, and declination of an object.
- Description: Determines the position on the screen where an object
would be drawn using trig. Since it is a wrap around world, the function attempts to
wrap the object around so ax will be between -30*3 and 30*3. di points to the
location in the screenbuffer where a point would be drawn on the screen at these
coordinates.
- Variables:
- _X, _Y, _Z - tank position to cast from
- _ViewAngle - reference heading to start from
- Inputs:
- ax - X position of the object
- bx - Y position of the object
- dx - Z position of the object
- Outputs:
- ax - the angle to the object relative to the view angle (-180*3 to 180*3)
- bx - the declination to the object relative to the horizon (-90*3 to 90*3)
- dx
- 0 - |ax| > 30*3 or |bx| > 30*3
- 1 - otherwise
- di - if dx = 1, 320 * 189 + (bx +30*3) * 320 + (ax +30*3)
- Calls: none
WorldHeight
- Owner: Brandon Tipp
- Purpose: Determine the height of the world at a point.
- Description: If cx is 0, determine the height of the world at the
nearest world cell. If cx is 1, determine the height of the position by
interpolating the four nearest points.
- Variables: none
- Inputs:
- ax - X position (in 256ths of a cell)
- bx - Y position (in 256ths of a cell)
- cx - method of calculation, 0 returns nearest value, 1 interpolates
- Outputs:
- dx - the height (in 256ths of a cell)
- Calls: none
ScaleSprite
- Owner: to be assigned
- Purpose: Scale a sprite
- Description:
- Variables: none
- Inputs:
- ax - the sprite number to scale
- bx - the square dimensions of the final sprite image
- Outputs:
- ScratchSeg - a square matrix (starting at offset 0) bx*bx large, containing the scaled
sprite with 0's as the invisible color. The maximum size that will be taken up is
180x180, with the image scaled and cropped to fit.
- bx - the actual size of the scaled bitmap. This equals the input if it was less
than 180, and 180 otherwise
- Calls: none
Network Procedures
ProcessInfo
- Owner: Kevin Slanicky
- Purpose: Processes all incoming packets
- Description: First determines which type packet is, the based on type
processes all the information contained in the packet.
- Variables:
- TankArray
- WeaponArray
- RXBuffer
- Inputs: none
- Outputs: none
- Calls: none
GenerateGame
- Owner: Kevin Slanicky
- Purpose: Responsible for setting up a server on the computer that wants
to host a game.
- Description: Adds the group name "ScorchedFinalPrj" then adds
the unique name "ScorchedFina00$$" as the first player. Then it sends out
a packet every 1/18th of a second waiting for NumberOfPlayers more people to join the
game. It then responds back acknowledging their admittance into the game.
- Variables:
- Inputs: none
- Outputs: none
- Calls: none
JoinGame
- Owner: Kevin Slanicky
- Purpose: Allow other players to search for a game to play in.
- Description: The new player waits to receive data from a host that is
sending out its information. Once it has found a game, it returns 1 for success.
- Variables: none
- Inputs: none
- Outputs:
- ax - 1 for success, 0 for failure to locate game
- Calls: none
SendRandoms
- Owner: Kevin Slanicky
- Purpose: Send random numbers used to generate terrain.
- Description: Sends the random variables that the host generated in
order to have one terrain in use by all players.
- Variables:
- Inputs: none
- Outputs: none
- Calls: none
GetHostRandoms
- Owner: Kevin Slanicky
- Purpose: Recieve terrain information from host.
- Description: Allows client players to get the data that the host
created in regards to the terrain.
- Variables:
- Inputs: none
- Outputs: none
- Calls: none
CheckNetworkReady
- Owner: Kevin Slanicky
- Purpose: Make sure all players are ready for battle to start.
- Description: Waits until the host has received a packet from all
players indicating they are ready to play.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
WaitNetworkReady
- Owner: Kevin Slanicky
- Purpose: Make hosts wait for game to begin.
- Description: The function the clients use to wait for the host to
finish up. It will receive information that is generated in the CheckNetworkReady
function.
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
SendPosition
- Owner: Kevin Slanicky
- Purpose: Inform host of position in terrain.
- Description: Sends out to all computers the information regarding its
present location.
- Variables:
- Inputs: none
- Outputs: none
- Calls: none
SendBattlePacket
- Owner: Kevin Slanicky
- Purpose: Inform everyone about the tank's current position as well as
the position of its weapon.
- Description: The information is sent to all computers so that each
client can determine if it is affected by the tank that is sending data.
- Variables:
- Inputs: none
- Outputs: none
- Calls: none
I/O Procedures
_InstKey
- Owner: Jim Papp
- Purpose: Installs the keyboard interrupt, and saves the old vector.
- Description:
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
_DeInstallKey
- Owner: Jim Papp
- Purpose: Restores the default keyboard interrupt.
- Description:
- Variables: none
- Inputs: none
- Outputs: none
- Calls: none
_MyKeyInt
- Owner: Jim Papp
- Purpose: Interprets keyboard interrupts.
- Description: Called by vector table on interrupt 9 ( IRQ 1).
- Variables:
- Inputs: none
- Outputs: none
- Calls: none
_UpdateGlobalIO
- Owner: Jim Papp
- Purpose: Sets all the globals that are controlled by user I/O.
- Description: Monitors KeyStateTable for user input, and updates global
I/O variables accordingly. Allows for customizable controls.
- Variables:
- KeyStateTable
- Global I/O variables
- Inputs: none
- Outputs: none
- Calls: none
Main_Menu
- Owner: Jim Papp
- Purpose: Give user access to game.
- Description: Gives access to physics, economics, and other menus.
Each of these will be its own screen, with its own controls and menu, but will
essentially be the same, returning to Main_Menu when they are done, and setting their own
globals.
- Variables: none
- Inputs: none
- Outputs: none
- Calls:
Blit_Char
- Owner: Jim Papp
- Purpose: Displays an 8x8 character to video memory
- Description: Uses the ROM on the video card to display the character
- Variables: none
- Inputs:
- ax - x position
- bx - y position
- ch - character
- cl - color
- dl - transparency flag
- Outputs: none
- Calls: none
Blit_Integer
- Owner: Jim Papp
- Purpose: Displays an 8x8 integer to the screen
- Description: Uses the ROM on the video card to display the character
- Variables: none
- Inputs:
- ax - x position
- bx - y position
- ch - integer
- cl - color
- dl - transparency flag
- Outputs: none
- Calls: none
DrawBars
- Owner: Mike Soukup
- Purpose: Draws a bar on the screen of varying length, offset, and color
- Description: Given a starting X and Y offset and two numbers, draws a
line scaled to represent the fraction CurrNumber/MaxNumber
- Variables: none
- Inptus:
- ax - Maximum width of bar
- bx - Current number
- cx - Maximum number
- bl - color
- WordBuffer - XStart
- WordBuffer2 - YStart
- Outputs: none
- Calls: none
Constants
Tank Related
| TANK_ARRAY_SIZE |
EQU 63 |
| WEAPON_ARRAY_SIZE |
EQU 19 |
| TANK_START_TIME |
EQU 300 |
| TURRET_SPEED |
EQU 1 |
| TURRET_MAX |
EQU 90 |
| POWER_SPEED |
EQU 1 |
| POWER_MAX |
EQU 1000 |
| POWER_START |
EQU 200 |
| HEALTH_START |
EQU 100 |
|
|
| TANK_SPEED |
EQU 3 |
| TURN_FAST |
EQU 6 |
| TURN_SLOW |
EQU 1 |
| DEGREE_0 |
EQU 0 |
| DEGREE_360 |
EQU 360*3 |
Global Variables and Structures
Keyboard/Mouse variables
- TurnRight
- TurnLeft
- GoForward
- GoBack
- TurretUp
- TurretDown
- PowerUp
- PowerDown
- Shoot
- Recharge
- SpeedUp
- Suicide
Store information about Tanks and Weapons
- TankArray - holds 10 Tank structures
- WeaponArray - holds 10 Weapon structures
- Tank - Structure that holds all information about a tank
| Tank |
STRUCT |
|
|
|
BabyMissile_ |
Word 0FFFFh |
; Amount of each weapon left |
|
Missile_ |
Word 0 |
|
|
BabyNuke_ |
Word 0 |
|
|
Nuke_ |
Word 0 |
|
|
DirtBall_ |
Word 0 |
|
|
TonOfDirt_ |
Word 0 |
|
|
BabyRiotBomb_ |
Word 0 |
|
|
RiotBomb_ |
Word 0 |
|
|
PlazmaBlast_ |
Word 0 |
|
|
RegShield_ |
Word 0 |
|
|
MedShield_ |
Word 0 |
|
|
HeavyShield_ |
Word 0 |
|
|
Status |
Byte 0 |
; 0 = dead, 1 = alive |
|
XPos |
Word 0 |
|
|
YPos |
Word 0 |
|
|
ZPos |
Word 0 |
|
|
ViewAngle |
Word 0 |
; View angle in X-Y plane |
|
TurretAngle |
Word 0 |
; View angle from X-Y plane to Z axis |
|
Power |
Word 0 |
; Initial velocity of shot |
|
Money |
DWord 0 |
|
|
WeaponSelected |
Byte 0 |
; Which weapon is currently selected |
|
Health |
Byte 0 |
; Health of tank |
|
ShieldHealth |
Byte 0 |
; Amount of shields left |
|
Fuel |
Byte 0 |
; Amount of fuel left |
|
Batteries |
Word 0 |
|
|
Time |
Word 0 |
; Time until next shot |
|
ShieldTime |
Word 0 |
|
|
RoundsWon |
Word 0 |
|
|
KillsInRound |
Word 0 |
|
|
; Used in AI |
|
|
|
Target |
Byte 0 |
; Who the tank is targeting |
|
LastKilledBy |
Byte -1 |
; Who killed the tank last |
|
CloseVelocity |
Word 0 |
; Shot that will hit target |
|
CloseTurret |
Word 0 |
|
|
CloseAngle |
Word 0 |
|
- Weapon - Structure that holds all information about a tank's weapon in the air
| Weapon |
STRUCT |
|
|
|
Status |
Word 0 |
; 0 = none, 1 = in air 2+ = exploding |
|
Kind |
Word 0 |
; Type of weapon |
|
XPos |
Word 0 |
; Position of weapon |
|
YPos |
Word 0 |
|
|
ZPos |
Dword 0 |
|
|
XVel |
Word 0 |
; Velocity of weapon |
|
YVel |
Word 0 |
|
|
ZVel |
Word 0 |
|
|
Increment |
Byte 0 |
; Used to slow explosion rate |
Special Thanks:
- Kevin Huffenberger for his help with the physics.
- All the members of other groups who helped us out and kept us entertained during all
those long nights/mornings.
- Pepsi-Cola, the makers of Mountain Dew.
This page is created and maintained by Mike
Soukup
This page was last updated Friday, May 1, 1998