ECE 291 Final Project: 3D PacMan

The Team


Introduction

3d PacMan is an 80x86 assembly program that recreates PacMan in a 3d environment. The player looks through the eyes of PacMan and runs frantically through a 3d Maze to eat pellets and super-pellets and avoid 4 vicious ghosts. 3d PacMan exploits the wonders of the 20th century to recreate PacMan with wonderful .wav audio files and provide textured 3d walls. In addition Pellets, super-pellets, walls, and ghosts are all represented in their true size, so distant and orientation are essential to recreating a real-to-life recreation. Bitmap Scaling becomes vital in this implementation. Procedure ScaleTank from MP4 was modified for this purpose. The modification allowed the scaling of any object given the appropriate .PCX file. To complement the scaled 3d objects, textured 3d walls were provided for the Maze. Practically any texture map could be used due the excellent universality of the implementation. Any .PCX file with some minor modifications to its texture map can easily transform the walls into any design desired. A default "fire" wall is provided. However, future modifications are made extremely easy due to this feature.

Meanwhile, PacMan often times gets bored running through the wonderfully textured world of PacWorld. For this reason, .wav files provide sound effects for PacMan and the user's listening pleasure. Sound effects are played when PacMan eats a Pellet, another sound for the eating of Super-Pellets, and yet another sound for when PacMan gets killed. Implementation of the sound becomes very challenging when a large number of effects are forced to be played at a rapid rate. The eating of pellets is one such situation. To overcome the problem a new approach was taken. All the .wav files were simultaneously loaded into memory segments, thus enabling faster sound effects and a great reduction in delay.

Realizing that playing in a solely 3d environment is very difficult, we include an optional 2d screen besides the 3d view. The user can toggle on or off the 2d screen using the "tab" key. The 2d screen provides a quick view to PacMan of where his foes are and where his pellets are. In addition a Scoreboard and lives-remaining indicator were provided. 3d PacMan is just the first of many innovative steps taken to improve upon classic, well-loved arcade games of the past. Hopefully, 3d PacMan will provide great joy to the future generation of video-game loving children, and provide a flashback for adults back to the days when they too played video games. Enjoy!


Implementation

We divided this project into 5 parts: artificial intelligence, background 3D graphics, foreground 3D graphics, 2D graphics and sound. Each part was handled separately by a team member. The video screen was divided into 2 sections: on the left was a 3D section that showed the maze from PacMan's perspective, and on the left was a 2D section that displayed the maze. The 2D maze was included to prove that the ghost AI worked. To play real 3D PacMan, the TAB key could be used to turn the 2D screen on or off.

All our code was written in a modular way. Each of us was responsible for a single ASM file that would be included in the code segment of the MAIN.ASM file. Everything was compiled as a single file. Global variables, constants and PROTO statements were included in separate include files. Compilation was automated using the NMAKE utility. Each person's code would then be called from within Main.

The program is controlled via the main loop. Key presses are handled using our own keyboard interrupt. PacMan's movements are controlled by the arrow keys via this keyboard interrupt, and the PacManMove procedure is called from the interrupt handler to update the Maze. Within the main loop, there is a delay after which the MoveGhosts procedure is called to move the ghosts. The AI procedures are called from MoveGhosts. Anytime something changes (eg. either PacMan or the ghosts move,) the screen is updated.


Description of Main.ASM

The sequence of events in the main loop is:


Data Representation

Our maze is described in the file Maze1.dta. This is read into the MazeData variable as an array, and accessed accordingly.

Global variables are used to describe parameters, like PacMan's and the Ghosts' positions in this maze, what is underneath each ghost (empty, pellet or super pellet), etc. These global variables are defined in var.inc (an include file).


AI Procedures - AI.ASM


2D Graphics Procedures - TwoD.ASM


3D Background Graphics - Backtd.ASM


3D Foreground Graphics - Fore3d.ASM


Sound Procedures - Sound.ASM