Game Engine Procedures
Segments
SBSeg segment PUBLIC 'DATA1'
ScreenBuffer DB 65535 dup(?)
SBSeg ENDS
BGSeg segment PUBLIC 'DATA2'
Background db 65535 dup(?)
BGSeg ENDS
FGSeg segment PUBLIC 'DATA3'
Foreground db 65535 dup(?)
FGSeg ENDS
ScrSeg segment PUBLIC 'DATA4'
ScratchPad db 65535 dup(?)
ScrSeg ENDS
TextSeg segment PUBLIC 'DATA5'
Text db 65535 dup(?)
TextSeg ENDS
Constants
- WALLBUFFER EQU 5 ,The closest you can get to any wall
- DEGREE_2 EQU 10
- DEGREE_4 EQU 20
- DEGREE_0 EQU 0
- DEGREE_90 EQU 480
- DEGREE_180 EQU 960
- DEGREE_270 EQU 1440
- DEGREE_360 EQU 1920
Variables
- MapLoc ,The location, in memory of the current map
- WorldSize, The size of the current map
- Player_X, The X-position of the kart
- Player_Y, The Y-position of the kart
- _view_Angle, Direction of the kart
- Delta_X, Floating point value for the change in the player's
X-position after a move.
- Delta_Y, Floating point value for the change in the player's
Y-position after a move.
- Camera_X, Floating point value for the change in the camera
X-position after a move.
- Camera_Y, Floating point value for the change in the camera
Y-position after a move.
- LapCount, Number of the current lap
- Accel, acceleration rate
- SDecel, rolling deceleration rate
- FDecel, braking acceleration rate
Keyboard Variables
- GAS, Variable used for up arrow
- BRAKE, Variable used for down arrow
- TURN_RIGHT, Variable used for right arrow
- TURN_LEFT, Variable used for left arrow
- ENTER_key, Variable used for ENTER key
- _Exit_Flag, Variable used for Esc key
Map Data Variables
Player Data Variables
- Accel# individual accleration rate
- SDecel# individual rolling deceleration rate
- FDecel# individual braking deceleration rate
- MaxSp# individual maximum speed
- LoadPCX
-
Owner: Brian Chang
- Purpose: Loads and decodes a 320x200 PCX file into memory and
sets VGA Palette registers to those used by the image.
- Inputs:
- ax = Destination segment address
- dx = pointer to a null-terminated string containing the filename
- Output: Fills destination (DestSeg:0) with image data. Fills
VGA palette registers with image colors
- InstKey / MyKeyInst / DeInstallKey
-
Owner: Brian Chang
- Purpose: Replace default keyboard interrupt routine.
- Inputs: Button presses
- Outputs:
- GAS set to 1 when Up Arrow is pressed, 0 when released
- BRAKE set to 1 when Down Arrow is pressed, 0 when released
- TURN_RIGHT set to 1 when Right Arrow is pressed, 0 when released
- TURN_LEFT set to 1 when Left Arrow is pressed, 0 when released
- ENTER_key set to 1 when Enter is pressed, 0 when released
- _Exit_Flag set to 1 when Esc is pressed, 0 when released
- _SetUpGameData
-
Owner: Brian Chang
- Purpose: Initialize the values given in the include file for
the specified map.
- Input: _KartChoice, _TrackChoice
- Output: Modifies the following:
- Player_X
- Player_Y
- _view_angle
- Track Data
- Player Data
- _CalcCamInfo
-
Owner: Brian Chang
- Purpose: Calculate camera position depending on player position
and view angle.
- Inputs: _Player_X, _Player_Y, _view_angle
- Ouputs: _Camera_X, _Camera_Y
- _ShowScreenBuffer
-
Owner: Brian Chang
- Purpose: Move 320x200 pixels of screen data from ScreenBuffer
to the screen. Then it clears the ScreenBuffer.
- Input: ScreenBuffer
- Ouputs:
- Writes directly to the screen.
- _DrawBound
-
Owner: Brian Chang
- Purpose: Draws a horizontal border strip scaled to the appropriate
width.
- Inputs: Scale, X
- Output: Places a horizontal strip of pixels into the ScreenBuffer.
- _CalculateMovement
-
Owner: Brian Chang
- Purpose: Calculates the Delta_X and Delta_Y variables needed
to move.
- Inputs:Accel, the acceleration rate
- SDecel, the rolling deceleration rate
- FDecel, the braking deceleration rate
- The keyboard variables
- Outputs: Delta_X, Delta_Y
- _ProcessMovement
-
Owner: Brian Chang
- Purpose: To check Delta_X and Delta_Y to see if they were valid
moves.
- Inputs: Delta_X, Delta_Y
- Outputs: Modifies Player_X and Player_Y if the move was valid.
- If Player has run into a wall parallel to the Y-axis, Delta_X is
negated. Likewise, if Player has run into a wall parallel to the X-axis,
Delta_Y is negated.
- Note:
- Bounce effect upon collision with walls. Maybe explosions?
- _DrawSky
-
Owner: Brian Chang
- Purpose: Draw a portion of a sky bitmap (blue space with pretty
clouds) that helps with the effect of rotating motion.
- Input: momentum_angle
- Output: A portion of sky is drawn to the ScreenBuffer.
- Note:
- We will create an image called SKY.PCX. The momentum_angle variable
will be converted into an offset to determine what part of SKY.PCX is moved
to the ScreenBuffer.
- _DrawForeground
- Owner: Brian Chang
- Purpose: Draw foreground items
- Inputs: FGPic
- Outputs: Kart, map, speedometer, time, lap counter drawn to
SBSeg. A red spot is drawn on the map to indicate position of player. If
this is a network game, the other player is also drawn onto the map as a
blue spot.
- _CheckDoor2
- Owner: Brian Chang
- Purpose: Checks if specified cell is a door.
- Inputs: BlockX, BlockY, Funct
- Outputs: If Funct is 1, ax is 1 if player may walk thru the
cell
- If Funct is 0, ax is 1 if cell is a doo