|
Screenshots:
 |
|
Implementation: |
Lager, deep down, is
a simple loop calling many outside functions. There is a load of
variables (one for keyboard, one for what part of the game to be
running in, etc) that tell the game what to do and where to go, based
on input from the keyboard and other game functions.
When the game first starts, it loads all the graphics, sounds, and
installs appropriate ISRs. It checks the main game variable to see
what it should do, and being the beginning of the program, it opens
the menu. Going through the menu, the player can choose to play the
game, check high scores, or quit. The variable changes, and the main
game loop then runs the chosen function.
When the game starts, the variables are all cleared, the level is made
(cars are placed, etc), and the player starts out at the bottom, with
a set amount of time on the clock depending on what level the player
is at. The player can move with the keyboard, and if the player comes
within the area of a car graphic, the function to kill the player is
called. The player can also die if the clock variable reaches 0.
The cars themselves are stored in a series of 256 reserved bytes. Each
car uses 8 bytes (two words to store its X position, two for its Y
position, two for what type of car it is, and two used for other
things by other functions). This means any functions that deal with
the car parse through this array of memory looking for the values they
need. The maximum number of cars used in each level is stored as a
constant, so depending on the level, each function knows how far to go
into the array.
If the player reaches the top of the level, the functions to end the
level are called. These draw graphics and call the function that adds
the score up based off of the current level and the amount of time
remaining. At the end of four levels, or when the player dies, the "GameOver"
function is called. It calls a screen to tell the player whether they
won or lost, depending on the number of lives they have left. It then
calls the functions that check whether the current score is in the
high score list. If it is, the functions to ask the player for their
name and to write the name and high score into the list are then
called.
Pressing P at any time will call the pause function. This will stop
the TimerISR from incrementing any of the time variables (it does this
by setting a variable that TimerISR reads every time it is called),
and it brings up a graphic. The Pause function continually loops until
the P key is pressed again, at which point is clears out its variable
and exits back into the main game loop. Pressing Escape will set the
game variable back to zero and exit the program out to the menu.
If the player chooses to check the high scores, he score file is open,
read into memory, and then drawn out to the screen. When a button is
pressed, the game variable is cleared out and the game goes back to
the menu.
If the player chooses to quit from the main menu, everything is
uninstalled and the program is exited. |
|
Functions: |
|
Main Function |
Function:
Developer:
Purpose:
Input:
Output:
Calls:
|
void _main()
Joe Greathouse
Calls other functions based on gameflags set in _menu
none
none
_menu, _game, _highscores |
|
Main
Subfunctions |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
void _menu()
Joe Greathouse
Takes the input from the menu and changes game_flags based on
input from a graphical menu. You can choose to start a game, check
high scores, or quit the game.
None. Will check keyboard flags to go through menu options.
Changes game_flags depending on choice.
_UpdateSound, _PlayEffect,
_DrawMenu
|
|
Function:
Developer:
Purpose:
Input:
Output:
Calls:
|
void _game()
Joe Greathouse
Runs the game itself. Starts at level one when you enter the
function, then runs through checking player movement, car movement,
and time to see if the game continues or stops.
None. Reads from game variables.
None
_DecrementLives, _MakeLevel, _DrawScreen, _UpdateSound, _PlayEffect, _CheckTime,
_MovePlayer, _PlayerHit, _Pause, _MoveCars, _CheckLevelOver, _PlayerTimerOver,
_PlayerDead, _GameOver, _EndLevel, _StopEffect |
|
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_highscores()
Joe Greathouse
Reads through an external score file, displays the top scores, and
exits when you press escape.
None. Reads scores from an external file.
Outputs to the screen only.
_OpenFile, _CloseFile, _ReadFile, _DrawHighScores, _UpdateSound, |
|
_game Subfunctions (w/o Draw functions) |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_Initialize()
Joe Greathouse
Resets all game variables in preparation for starting the game.
None
Resets variables.
None |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_MakeLevel()
Chris Burke
Places all cars in the level, and sets up the player
None. Reads external variables.
None.
_Random, _CarFits |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_CheckTime()
Chris Burke
Returns 1 if time over for the level,also updates time to be displayed
None. Reads _time variable
1 if time is up. 0 if not.
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_GameOver()
Joe Greathouse
Ends the game, clears out all the variables and arrays, and checks the
high score vs. the current high score list. Shows Win or Lose graphic
depending on input. Also updates HS list if need be.
None. Reads from the _lives variable to see if it's a win or
lose.
Can output to the high score file if need be.
_DrawLose, _DrawWin, _UpdateSound, _CheckScores, _AddNameScores, _FormatScores,
_WriteHighScores, _HighScores |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_PlayerTimeOver()
Chris Burke
Calls functions that will tell the player he is out of time, then
decrements the number of lives.
None.
Changes the Lives variable.
_DecrementLives, _DrawScreen, _DrawTimeOver, _UpdateSound, |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DecrementLives()
Chris Burke
Edits Lives Variable and Updates text string that is displayed
None. Reads from the _lives variable.
Changes the Lives variable.
BinAsc |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_MovePlayer()
Scott Wettstein
Changes the player's position in the grid based on the input
direction.
None. Reads from the KeyboardVar
Updates the player's position if there are no object collisions
_PlayEffect |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_PlayerHit
Chris Burke
Runs through _carsArray and determines if the player has been hit by a
car
None. Uses the player variables to compare to the car array.
Returns a 1 if there was a collision, 0 if there wasn't.
_CarCollision |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_Pause()
Joe Greathouse
Pauses the game and brings up a pause graphic. Break out with 'P'
again.
None.
None.
_DrawPause, _UpdateSound |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_MoveCars
Chris Burke
Moves all cars on the map.
None. Reads from the _carsArray, and the _NumCarsLevel variable.
Changes the Cars array and its X and Y values.
_PlayEffect, _Distance |
|
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_CheckLevelOver()
Joe Greathouse
Checks to see whether the level ended successfully or not. This means
the player is on the very top row; where they need to be.
Checks players position in the player variables.
Outputs a 1 if the level was completed successfully, or a 0 otherwise.
None. |
|
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_EndLevel()
Joe Greathouse
Updates the score variable based on level.
None. Reads from the level and time variables.
Updates the Score variable.
_DrawLevelOver, _UpdateSound, |
|
Internal Main Sub-Functions: |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_CarFits()
Chris Burke
Returns 1 if car fits at (Xpos,Ypos)
None. Reads game variables.
1 if car fits, 0 if otherwise.
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_Distance
Chris Burke
Returns player's distance in front of car if in same lane, -1
otherwise
Pointer to the car to check.
Distance in front of car or -1
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_CarCollision
Chris Burke
Checks if the player has been hit by a car and is thus dead.
Pointer to the car to check.
1 if player is dead. 0 otherwise.
_PlayEffect |
|
HighScore Functions: |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_AddNameScores()
Joe Greathouse
Lets the player enter his name into the high score list.
None. Takes input from what the player chooses on the screen.
And updated newHighScoreName
_DrawEnterName, _UpdateSound |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_FormatScores
Joe Greathouse
Changes the Scores variable into an ASCII string to write to the
external file.
None. Takes input from the score variable.
Data into NewHighScoreScore.
BinAsc |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_FormatScore
Joe Greathouse
Changes the Scores variable into an ASCII string to write to the
screen.
None. Takes input from the score variable.
Data into NewScoreScore.
BinAsc |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_CheckHighScore()
Joe Greathouse
Reads through an external score file, checks its scores versus score
variable. Returns the place, 1st to 5th, of score variable in file. If
score isn't high enough to get into list, return 0.
None. External File.
Integer. Place in high score list, 0 if not in.
_OpenFile, _ReadFile, _CloseFile, AscBin, |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
void _WriteHighScore()
Joe Greathouse
; Reads through an external score file, puts the new score and name
into the external file.
Spot, 1-5, to put the name in the high score list.
An updated score list.
_OpenFile, _CloseFile, _ReadFile, _WriteFile, |
|
Interrupt Functions: |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
void _InstallKeyboard()
Installs the KeyboardISR
None.
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
void _RemoveKeyboard()
Removes the KeyboardISR
None.
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls:
Returns: |
long _KeyboardISR()
Chris Burke for MP4. Modified by Joe Greathouse for Lager.
Sets the variable flags based on which keys are pressed.
Keypress at port [_kbPort], [_kbIRQ]
[_Gameflags]
None.
Value to not chain original handler. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
void _InstallTimer()
Installs the TimerISR
None.
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
void _RemoveTimer()
Removes the TimerISR
None.
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls:
Returns: |
long _TimerISR()
Joe Greathouse
Updates the TimerTicks for movement and clock functions,
unless Pause flag
is set, then just exits.
None.
[_TimerTicks]
None.
Value to not chain original handler. |
|
Graphics Functions: |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawCursor
Ed Lieb
Draw the cursor for the menu
where to draw cursor (from _menu)
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawMenu
Ed Lieb
Draw the menu
None.
draws to screen buffer
_Buf2Buf, _DrawCursor |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawHighScores
Ed Lieb
Draw the scores to the screen
strings to display on the screen
draws to screen buffer
_BlackScreen, _DrawText |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawScreen
Ed Lieb
Calls all the draw functions if needed; checks a variable to see what
to draw/redraw
variable for what to redraw
draws to screen buffer
_DrawPlayer, _DrawCars, _DrawLevel, _DrawPlayerHit, _DrawPause, _DrawPlayerWin,
_DrawPlayerLose, _DrawPlayerTimeUp, _DrawTime, _DrawScore |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawPlayerWin
Ed Lieb
Draws the player win screen
None.
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawPlayerLose
Ed Lieb
Draws the player lose screen
None.
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawPlayerTimeUp
Ed Lieb
Draws the player timeup screen
None.
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawPause
Ed Lieb
Draws the pause screen over the game area so that you can't cheat
while paused
none.
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawPlayer
Ed Lieb
Draws the player to the game area
(x,y) pos of player
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawPlayerHit
Ed Lieb
Draws the player to the game area for a certain amount of time
(x,y) pos of player
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawCars
Ed Lieb
Draws a car for each car that exists in memory
(x,y) positions of the cars
draws to screen buffer
_DrawCar |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawCar
Ed Lieb
Draws a car at an (x,y)
(x,y) position of car
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawCars
Ed Lieb
Draws a car for each car that exists in memory
(x,y) positions of the cars
draws to screen buffer
_DrawCar |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawLevel
Ed Lieb
Draws the borders and the game map to the screen
None.
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawTime
Ed Lieb
Draws the time left to complete the level
time to display
draws to screen buffer
_DrawText |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawScore
Ed Lieb
Draws the player's score
player's score
draws to screen buffer
_DrawText |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_DrawText
Ed Lieb
Draws text to screen
(x,y) position to draw text
draws to screen buffer
_Buf2Buf |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_Buf2Buf
Ed Lieb
Copies image from one buffer to another
source image, source pitch, source left, source top, destination
buffer, destination pitch, destination left, destination top, width,
height
None.
_AlphaCompose |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_AlphaCompose
Ed Lieb
Alpha composes a pixel; this is much different from the function for
mp4 because it works for all backgrounds, not just black.
foreground pixel, background pixel
alpha composed pixel
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_BlackScreen
Ed Lieb
Draws a blacked-out screen
None.
Draws to screen buffer
None. |
|
Sound Functions: |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_ReadWav
Chris Burke
Reads a wave with [*filename], stores it at offset, and puts the
length into legnth
pointer to the filename,pointer to the offset, pointer to the location
to put the lenght, and a MaxSize to read
Updates all the inputed variables
_AllocMem, _OpenFile, _ReadFile, _CloseFile |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_SoundISR
Chris Burke
Checks if we need to update the DMA buffer and selects the appropriate
half
None. reads from [_curDMAOff],[_updateDMA]
None. Writes to [_curDMAOff],[_updateDMA]
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_StartSound
Chris Burke
Starts all sound in game
None. _curMusOff,_nextMusOff,_DMASel,_DMAChan,_DMAAddr
None. updates _nextMusOff
_GetNextSong,_DMA_Start,_SB16_Start |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_UpdateSound
Chris Burke
Updates the DMA buffer with the latest sound data
None. _curMusOff, _curMusLeft, _nextMusOff, _nextMusLeft, _DMASel,
_cursndfxLeft, _cursndfxOff, _soundMixer, _sndBuf, _newBG, _updateDMA,
_curDMAOff
None. updates _curMusOff, _curMusLeft, _nextMusOff, _nextMusLeft,
_DMASel, _cursndfxLeft, _cursndfxOff, _soundMixer, _sndBuf, _newBG, _updateDMA,
_curDMAOff
_GetNextSong,_DMA_Start,_SB16_Start |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_GetNextSong
Chris Burke
Randomly choose one of 10 bg songs
None. Reads _bgMus.
None. _nextMusOff,_nextMusLength
_Random |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_StopSound
Chris Burke
Immediately stops all sound
None.
None.
_DMA_Stop,_SB16_Stop |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_PlayEffect
Chris Burke
plays effectNum soundeffect, doesnt restart it if effectNum effect
already playing
.effectNum, reads from _cursndfxLeft,_cursndfxOff,_sndfx
None. updates _cursndfxLeft,_cursndfxOff
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_StopEffect
Chris Burke
stops effectNum soundeffect from playing, if already playing does
nothing
.effectNum, reads from _cursndfxLeft
None. Writes to _cursndfxLeft
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_Random (modified from MP4)
Chris Burke
Returns between 0 and MaxNum inclusive in ax
.MaxNum
Updates _seed
None. |
Function:
Developer:
Purpose:
Input:
Output:
Calls: |
_Initialize Sound
Chris Burke
Initializes all of the various sound things
None. _bgMusicXFn, _sndfxXFn
[_DMASel],[_DMAChan], all of the _bgMus, and _bgMusLength variables
all of the _sndfx and _sndfxLengths
None. |