
ECE 291 Final Project
- Pacman's Great Adventures
This game is a re-make of the classic
Pacman game, revamped for the 80x86 with VGA graphics, SoundBlaster audio,
and new game features. Pacman roams around the mazes trying to collect
as many pellets as possible without being caught by the ghosts. The
game has many levels to play and different difficulty levels. The
special two-player head-to-head mode allows the second player to control
the four ghosts.
Implementation
The game is broken down into five major parts:
AI, gameplay/game engine, 2D animation, 2D graphics, sound. We are
trying for an AI that gets progressively harder based on difficulty and
level, also showing the different "personalities" of each ghost.
The gameplay/game engine consists of the interface with the keyboard and
mouse, and the logic behind the movement of the characters in the game.
To make the game look more continuous, 2D animation must be used.
Using PCX files and 2D graphics procedures, we load the images of our game
from files, then translate it to a playable map based on data maps.
This also allows other PCX file images to be used so that we can easily
change what the pieces of the game look like. We will use SoundBlaster
sound effects, and also MIDI quality music to improve the general gameplay.
One neat feature of our game is the addition of a Board Editor. It allows
the user to create his or her own levels.

2D Graphics
The moveable components of the game (i.e. ghosts,
pacman, fruit), work on a continuous X,Y basis. The non-moving components
use a Board array that works in a "block" format. The DataArray
consists of numbers telling the engine what to display at that "block"
(our gameboard is 20x20 blocks). The moveable components can move
within blocks however, to simulate animation, and so that pacman doesn't
have to be exactly on a block to be killed by or to eat a ghost.
Continuous X,Y is the same as the pixel value, so unlike the blocks, the
moveable components can have 320x200 values. There will be a constant
step value for pacman and fruit, because they will probably move more than
1 pixel at a time. There is also a ghost step value, but this changes
with difficulty and level, thus simulating a faster ghost.
Team Members
- Raymond Chen - AI, Gameplay
- David Ripley - 2D Animation/Graphics
- Rob Yepez - 2D Graphics, PCX Development/Implementation
- Chris McGlone - 2D Graphics, Gameplay
- Daryl Kowalski - Sound and Music
Constants
Constants relating to board and
block dimensions:
BOARDEDGE
EQU 60
BLOCKDIM
EQU 10
BOARDDIM
EQU 20
OVERLAP
EQU 2
Movement constants:
GOUP
EQU 0
GORIGHT
EQU 1
GODOWN
EQU 2
GOLEFT
EQU 3
Look-Up Tables
DeltaFruitX - change in x coordinates
for indexed direction
DeltaFruitY - change in y coordinates
for indexed direction
Intersection - table containing
values of intersections
DeltaBlockX - block x-coordinate
change
DeltaBlockY - block y-coordinate
change
DeltaPacX - Change in pacman's
pixel x-coordinate
DeltaPacY - Change in pacman's
pixel y-coordinate
DeltaGstX - Change in ghost pixel
x-coordinate
DeltaGstY - Change in ghost pixel
y-coordinate
WarpX - Change in x-coordinate
of warping
WarpY - Change in y-coordinate
of warping
OpDirTable - opposite direction
lookup table
OpAxisDir - opposite axis diections
GhostTimer - lookup table to see
when ghosts leave the box
Method - Computer AI lookup table
based on difficulty and personality
FruitScoreIndex - index for offsets
of fruit score
GhostScoreIndex - index for offsets
of ghost score
Global Variables
The procedures of the game input and output,
primarily global variables. This is the list of variables used by
our game:
WORD GhostX - array of the
four ghost X-positions
WORD GhostY - array of the four
ghost Y-positions
WORD PacX - X-position of Pacman
WORD PacY - Y-position of Pacman
WORD FruitX - X-position of fruit/bonus
piece
WORD FruitY - Y-position of fruit/bonus
piece
WORD FruitDir - angle/direction
of Fruit movement
WORD PacDir - View angle/direction
Pacman is facing
WORD GhostDir - array of the four
ghost view angles
WORD BoardLocation - Offset of
the DataArray
WORD PacState - current state
of pacman (animation of pacman opening and closing mouth)
WORD LevelData - array of offsets
pointing to filenames of each level's map data
WORD TotalPellets - Total pellets
on the current board
WORD Pelletsleft - number of pellets
left on the current level
WORD GhostSelect - flags which
ghost is being controlled by the second player
WORD Randval - random value seed
WORD MemLoc - 20-bit linear address
used by sound procedure
DOUBLE EngineCycles - numebr of
mainloop iterations for the current level
BYTE Pause_Flag -
flag determining when game is paused
BYTE Quit - flag for
quitting of game
BYTE PacLives - Number
of lives left
BYTE MoveBuffer1 -
next move pacman will make
BYTE MoveBuffer2 -
next move the selected ghost will make
BYTE PowerPelletFlag
- array of flags determining when and which ghosts are vunerable
BYTE GhostData - array
that holds information about ghost AI
BYTE GhostStep - translates
to the "speed" of the ghosts, which changes throughout the game
BYTE BlockPX - block
X-position of pacman
BYTE BlockPY - block
Y-position of pacman
BYTE Gamedata - string
holding filename of TextSeg file
BYTE DelayC - Delay
Consant
BYTE Length1 - length
of file for sound procedure
Segments
SBSeg: screen buffer segment
-> outputs directly to screen
LevelSeg: wall, pellet element
segments (changes per level)
ScratchSeg: scratch segment (used
by LoadPCX)
TextSeg: textures segment, containing
ghost, pacman, and fruit images
Procedures
Gameplay/Game Engine
InstKey/GameKeyInt/DeinstKey
- Author: Rob Yepez
- Inputs: button press
- Outputs: Quit, Pause_Flag,
MoveBuffer1, MoveBuffer2, GhostSelect
- Description: Replaces default
keyboard interrupt routine
- Assumptions: Quit, Pause_Flag
are flags showing the state of the game. MoveBuffer 1 and 2 output
according to a direction table. GhostSelect is changed as the 2nd
player TABs through the ghosts.
Mouse_Control
- Author: Rob Yepez
- Inputs: Mouse
- Outputs: Two_Player, One_Player,
Quit
- Calls: LoadPCX, ShowScreenBuffer
- Description: Checks location
of mouse cursor on screen to see if it is over a valid button, then loads
a toggled button image and outputs it to the screen.
MoveGhost
- Author: Ray Chen
- Inputs: GhostX, GhostY, GhostDir,
GhostData, GhostStep, PowerPelletFlag, MoveBuffer2
- Outputs: GhostX, GhostY, GhostDir
- Description: This procedure
takes the current position, direction, and attempt for next move (which
is contained in GhostData) and changes the position accordingly.
This procedure must check for valid moves for each of the ghosts, and if
a 2nd player is controlling a ghost, then the move which is given by GhostData
is overridden by the players input. GhostStep is not actually changed
by this procedure, but evaluated in conjunction with PowerPelletFlag to
determine how far the ghosts move. GhostX, GhostY, and GhostDir are
updated and outputed.
MovePacMan
- Author: Chris McGlone
- Inputs: PacX, PacY, PacDir,
MoveBuffer1, PacState
- Outputs: PacX, PacY, PacDir,
PacState
- Description: This procedure
takes the current position and direction of pacman and determines if it
can move, and how it moves based on the control of the player. PacState
is changed if pacman moves, thus animating the eating of pacman.
PacX, PacY, PacDir, and PacState are updated and outputed.
CalcBlockRound
- Author: Ray Chen
- Inputs: cx - x-coordinate(pixel),
dx - y-coordinate(pixel)
- Outputs: al - x-coordinate(block),
ah - y-coordinate(block)
- Description: This procedure
converts continuous coordinates to 10x10 block coordinates
GetBoardValue
- Author: Chris McGlone
- Inputs: al - block x-position,
ah -block y-position
- Outputs: bx - board value
at block X, block Y
- Description: This procedure
takes a block position within the board then looks up Board array to see
what kind of block occupys that position.
PutBoardValue
- Author: Chris McGlone
- Inputs: al - block x-pos,
ah - block y-pos, bx - value
- Outputs: Board
- Description: Takes a block
x and y position (al,ah), and puts the value in bx into the board array
at that position.
BlockXY
- Author: Ray Chen
- Inputs: cx - x-coordinate,
dx - y-coordinate
- Outputs: BlockXY
- Description: takes continuous
x and y coordinates and tells if it is in a column, row, or both
ExitGhost
- Author: Ray Chen
- Inputs: GhostX, GhostY, EngineCycles,
GhostBox, GhostTimer
- Outputs: GhostDir, GhostY,
GhostBox
- Description: Checks if ghosts
are in box then moves them out of box depending on values in GhostTimer
and EngineCycles.
SetUpGameData
- Author: Chris McGlone
- Inputs: GameData
- Outputs: TextSeg
- Calls: LoadPCX
- Description: Loads general
textures into TextSeg
InitHighScore
- Author: Chris McGlone
- Inputs: InitHigh
- Description: This procedure
initializes the high score file to the InitHigh variable.
ChangePacState
- Author: Chris McGlone
- Inputs: PacState, PAcStateDir
- Outputs: PacState
- Description: calculates the
next appropriate state of pacman.
SetUpLevelData
- Author: Chris McGlone
- Inputs: LevelData, BoardLocation
- Outputs: GhostStep, GhostX,
GhostY, PacX, PacY, PelletsLeft, DataArray
- Calls: LoadPCX, DrawArray,
DrawGhost, DrawPacman
- Description: Initializes level
by intializing starting ghost and pacman positions, filling DataArray with
the data from the level's data file. Initializes PelletsLeft, and GhostStep
based on level.
CheckArray
- Author: Chris McGlone
- Inputs: BoardLocation, PacX,
PacY
- Outputs: DataArray, PowerPelletFlag,
PelletsLeft
- Description: Updates contents
of DataArray, based on when Pacman has fully entered a new block (i.e.
his continuous position is equal to that of a block). Then it updates
PelletsLeft if a pellet is eaten, and PowerPelletFlag if a power pellet
is eaten as well.
2D Animation
Pacman_Death
- Author: Rob Yepez
- Inputs: AX - offset of block
where animation takes place
- Calls: ShowScreenBuffer
- Description: Animate Pacman's
brutal demise.
Ghost_Death
- Author: Rob Yepez
- Inputs: AX - offset of block
where animation takes place
- Calls: ShowScreenBuffer, DrawRectangle,
ClearScreenBuffer, DrawArray, DrawScore, DrawPacLife, DrawPacKill, DrawFruitLevel,
Delay
- Description: Animation of
ghost's death.
Fruit_Death
- Author: Rob Yepez
- Inputs: AX - offset
- Calls: ShowScreenBuffer
- Description: eating of fruit
CheckDeath
- Author: Rob Yepez
- Inputs: PowerPelletFlag, GhostX,
GhostY, FruitX, FruitY, PacX, PacY
- Outputs: GhostX, GhostY, PowerPelletFlag,
FruitX, FruitY, PacX, PacY
- Calls: PlaySequence, Ghost_death,
Pac_death, Fruit_Death
- Description: Check who dies
and if powerpelletflag is on the ghost dies, otherwise pacman dies, clears
flag if necessary.
DrawPacman
- Author: David Ripley
- Inputs: PacState, PacDir,
PacX, PacY, TextSeg
- Outputs: DI - offset of place
to be drawn in ScreenBuffer, SI - Offset in the Textseg to access
- Calls: DrawBlock
- Description: Calculates the
top left offset position in ScreenBuffer of the block of pacman to be drawn
based on PacX and PacY (outputs into SI). The proper texture offset
is calculated through a lookup table and is based on PacState and PacDir
(outputs into DI).
DrawGhost
- Author: David Ripley
- Inputs: GhostX, GhostY, GhostDir,
PowerPelletFlag, GhostSelect, TextSeg
- Outputs: DI - offset of place
to be drawn in ScreenBuffer, SI - offset in the TextSeg to access
- Calls: DrawBlock
- Description: This procedure
works much the same as DrawPacman with respect to the offset of the ScreenBuffer(SI
output). The offset of the texture segment is calculated based on
GhostDir, PowerPelletFlag, and GhostSelect, because not only are there
different eye directions, but a different color for vulnerable ghosts,
and when a ghost is being controlled by a 2nd player, it is another color
as well. This process is looped through four times, for each of the
ghosts, with DrawBlock being called four times.
DrawFruit
- Author: David Ripley
- Inputs: FruitX, FruitY, Level
- Outputs: DI - offset of the
place to be drawn in ScreenBuffer, SI - offset in the TextSeg to access
- Calls: DrawBlock
- Description: Same as above
procedures for the calculation of SI, but DI is based on the level.
2D Graphics
Introduction
- Author: Rob Yepez
- Calls: IntroMouseControl,
IntroductionAnimation, ClearScreenBuffer, DrawIntroScreen, ShowScreenBuffer
- Description: Displays the
introduction screen and menu, then calls Mouse_Control and waits for selection
of a valid option.
ExitDisplay
- Calls: LoadPCX, ShowScreenBuffer
- Description: Displays credit/exit
screen when game is exited.
DrawScore
- Author: Chris McGlone
- Inputs: P1Score, P2Score,
HiScore, Ghost Select
- Outputs: ScreenBuffer
- Calls: DrawRectangle, DrawDigits
- Description: draws the appropriate
scores to screen buffer depending on play mode
DrawDigits
- Author: Chris McGlone
- Inputs: si, di
- Outputs: ScreenBuffer
- Calls: DrawRectangle
- Description: Draws the proper
digit to the inputed offset.
DrawPacLife
- Author: David Ripley
- Inputs: PacLives
- Outputs: screen
- Calls: DrawRectangle
- Description: Draws an image
of pacman to the bottom left of the screen for each life that pacman has
in addition to the one pacman is using.
DrawFruitLevel
- Author: David Ripley
- Inputs: Level, TextSeg
- Outputs: screen
- Calls: DrawRectangle
- Description: All of the fruits
that have appeared for each level played and including the present level
are shown on the screen to the left of the board. Hence, the number
of fruits shown will be equal to the present level.
DrawBlockPart
- Author: Chris McGlone
- Inputs: bx, si, di
- Outputs: ScreenBuffer
- Description: Draws given number
of lines of specified texture into screen buffer. si = offset of texture
in text seg, di = offset to print in SBseg, bx = number of lines to print
DrawBoardPart
- Author: Chris McGlone
- Inputs: si - offset of board
part in texture segment, di - offset of destination in screen buffer
- Output: ScreenBuffer
- Description: Draws a part
of the board from the texture segment into the screen buffer.
DrawArray
- Author: Chris McGlone
- Inputs: BoardLocation, LevelSeg
- Output: screen
- Calls: ShowScreenBuffer
- Description: Draws static
board elements from LevelSeg to ScreenBuffer, based on contents of the
DataArray.
DrawPacKills
- Author: David Ripley
- Inputs: PacLives
- Outputs: screen
- Calls: DrawRectangle
- Description: When pacman dies,
print an image of pacman with an 'X', through him, to the bottom right
of the screen. Only do this when in two player mode. The number
of images that are on the screen at any one time should equal the number
of deaths of Pacman.
DrawRectangle
- Author: Chris McGlone
- Inputs: ax - segment, cx -
width, dx - height, si - offset of texture, di - offset of screenbuffer
- Outputs: ScreenBuffer
- Description: Draws a rectangular
picture in screenbuffer from the texture (for any non-square block)
DrawBlock
- Author: David Ripley
- Inputs: DI, SI, SBSeg, TextSeg
- Outputs: ScreenBuffer
- Description: To draw a block
from the texture segment to the screen buffer segment. SI: source
offset, DI: destination offset.
- Notes: This procedure is called
by DrawPacman, DrawGhost, DrawFruit. The texture drawn into ScreenBuffer
is a block. Transparent pixels will be used to draw only the part
of the block containing actual ghost, pacman, or fruit.
ClearScreenBuffer
- Author: Chris McGlone
- Outputs: ScreenBuffer
- Description: Clears the screen
buffer.
ShowScreenBuffer
- Author: David Ripley
- Inputs: SBSeg, ScreenBuffer
- Outputs: screen
- Description: Draws ScreenBuffer
to screen.
LoadPCX
- Author: David Ripley
- Inputs: AX, DX
- Outputs: DestSeg, ScratchSeg
- Description: Loads PCX image
into a VGA segment.
- Notes: AX = Destination segment
address, DX = pointer to a null-terminated string containing the filename
Artificial Intelligence
ComputeAI
- Author: Ray Chen
- Inputs: PowerPelletFlag, Difficulty
- Outputs: GhostData
- Calls: BlockPosition
- Description: This procedure
calls BlockPosition to get the block X,Y positions of the ghosts and pacman.
Based on the positions, difficulty, level, and the powerpelletflag, the
next movements of the ghosts are generated and outputed to GhostData.
Sound and Music
RegisterXmidi
- Author: Daryl Kowalski
- Inputs: AX - Command number,
BX - offset of far address of XMIDI, CX - segment of far address of XMIDI,
SI - low word of length XMIDI, DI - High word of length XMIDI
- Outputs: AX
- Description: Registers an
AXMIDI file by address for playback. AX = 0 if unable to register XMIDI
data, and 1 when registered resident
PlaySequence
- Author: Daryl Kowalski
- Inputs: AX - Command Number,
BX - Sequence number to be played
- Outputs: AX
- Description: Plays selected
WAV sound based on position and situation of pacman and/or ghosts.
AX = 1 when sequence is being played and 0 when sequence is not available.
- Notes: Called whenever pacman
is in a situation requiring sound.
MidiStop
- Author: Daryl Kowalski
- Inputs: AX - Command number
- Description: Procedure is
called to stop playing the current MIDI sequence.
ResumePlaying
- Author: Daryl Kowalski
- Inputs: AX - Command number
- Description: Resume PLaying
stopped sequence.
Board Editor Procedures
CalcCursorBlock
- Author: Chris McGlone
- Inputs: cx - x-position of
cursor, dx- y-position of cursor
- Outputs: al - block-x position,
ah- block-y position
- Description: Calculates the
block position of the cursor based on the continuous x and y coordinates.
EditMouseControl
- Author: Rob Yepez
- Outputs: BoardBE - Flag indicating
board was clicked, SaveBE - flag indicating SaveBoard, ClearBE - Clear
editor flag, ExitBE- exit editor flag, BlockBE- block was clicked flag,
AX - tile that was clicked
- Description: This procedure
gets the input from the user via mouse and sets the proper flags for processing
as indicated above.
DrawEditor
- Author: Rob Yepez
- Calls: DrawArray, DrawBoardPart
- Description: Draws the editor
screen, with buttons and tiles.
BoardEditor
- Author: Chris McGlone
- Input: custom_file
- Calls: ClearScreenBuffer,
DrawEditor, ShowScreenBuffer, EditMouseControl, CalcCursorBlock, PutBoardValue
- Description: This procedure
allows the user to design and save custtom board file. Control loop
for the board editor.
General Procedures
RandVal
- Author: Ray Chen
- Inputs: Randval
- Outputs: AX - random number,
Randval- next value seed
- Description: Takes a random
seed and computes a random value.
Delay
- Author: Rob Yepez
- Inputs: DelayC
- Description: Wastes CPU cycles.
Delays DelayX*AFFFh cycles.
DefineCustom
- Author: Chris McGlone
- Description: Clears the board
array and writes ocntents of clear board array to clear board file.
IntroMouseControl
- Author: Rob Yepez
- Outputs: CX, DX
- Calls: DrawIntroButton
- Description: Gets user input
via mouse and does a toggle
DrawIntroScreen
- Author: Rob Yepez
- Outputs: screen
- Calls: DrawIntroButton, ClearScreenBuffer
- Description: Displays the
intro menu.
DrawIntroButton
- Author: Rob Yepez
- Inputs: si, di
- Outputs: es
- Description: Draws button
to video segment.
IntroductionAnimation
- Author: Rob Yepez
- Outputs: screen
- Description: Animates pacmand
and ghost for introduction opening.
DrawIntroImages
- Author: Rob Yepez
- Inputs: si, di
- Outputs: es
- Description: Draw ghost or
pacman to segment and check for bounds.
CreditAnimation
- Author: Rob Yepez
- Outputs: screen
- Description: Animates the
credit screen
DrawCreditImages
- Author: Rob Yepez
- Inputs: si, di
- Outputs: es
- Description: Draws credits
from bottom to top and must check for bounds.
Credits
- Author: Rob Yepez
- Outputs: screen
- Calls: IntroMouseControl,
IntroductionAnimation, ClearScreenBuffer, DrawIntroScreen, ShowScreenBuffer
- Description: This procedure
displays the animation and credits.