
ECE 291
Spring 1998
Programmers:
- Brett Edwards: Game play/graphics
- Todd Wilson: Sound/Web design
- David Dixson: Game play/graphics
- Cathy Weber: GUI
Introduction:
This program
will emulate the old Atari game Centipede. The player is shown at the bottom
of the screen and is able to move left and right and up and down (to an
extent). The player is also allowed to shoot one bullet at a time. If a
bullet is still shown on the screen, the player cannot shoot again until
the bullet hit something or is off of the board. Also in the game is a
centipede figure made out of 10 segments. If you shoot a segment it turns
into a head (so the centipede actually divides into two different centipedes
with different lengths). If you shoot a centipede that has only one segment,
it turns into a mushroom. The goal of the game is to kill the centipede.
If the centipede touches you, you loose a life. You will be given 3 lives
before the game is over. Also in the game are obstacles called mushrooms.
They are placed on the screen randomly and nothing can get by them. You
can, however, shoot the mushroom, but it takes 3 hits for the mushroom
to disappear completely. The mushroom gets smaller each time you shoot
it until it dissappears. Our program will have sound and also different
levels of play (the centipede moves faster on harder levels).
Problem Description:
The main problem that we will try to solve is to emulate the centipede
game from scratch. . We will link the centipede sections together, which
will be a challengin way to implement the game play. We also plan to do
our project completely in assembly language.
External Procedures:
We used LIB291 as our only external procedure. We also used some of
the code that we wrote for Mp4 like ShowScreenBuffer, the keyboard routines,
and LoadPCX. We used the idea from MP3 for a delay but wrote our own.
Implementation:
For sound we are using Midpak and Digpak. Use PCX files for development
of all the graphics. Bullet, player, centipede, and mushrooms are all controlled
seperately. We will use arrays for the centipede and mushroom locations.
Bullet and player of the large (32X20 array to hold 10X10 pixel tiles),
mushrooms required to fit exactly into map array. Centipede can overlap
into several tiles. Player and bullet movement check to see if they move
into a tile occupied by the centipede or mushroom. Player can't pass thru
mushrooms and is limited to the bottom portion of screen. If the centipede
is hit, that section turns into a mushroom. Mushrooms change to a smaller
mushroom if hit with a bullet until totally destroyed (3 hits). Each version
of the mushroom requires 1 image. Levels add more mushrooms and centipede
speed increases.
Pictures Used in the game play:
This picture
is what is used for the pieces of the game play. Each image is 10 pixels
wide by 10 pixels tall and seperated by a 6x6 blue border.
Variables:
| Lives |
db 3 |
| Fire |
db 0 |
| Level |
db 1 |
| Score |
dw 0 |
| HitMushroom |
db 0 |
| HitCentipede |
db 0 |
| Death |
db 0 |
| Highscore |
dw 0 |
| Player_Pos |
dw 63675 |
| head_1_pos |
dw ? |
| head_1_direction |
db ? |
| head_2_pos |
dw ? |
| head_2_direction |
db ? |
| head_3_pos |
dw ? |
| head_4_direction |
db ? |
| head_5_pos |
dw ? |
| head_5_direction |
db ? |
| head_1_valid |
db ? |
| head_2_valid |
db ? |
| head_3_valid |
db ? |
| head_4_valid |
db ? |
| head_5_valid |
db ? |
| randval |
dw 3 |
| length_1 |
db 10 |
| length_2 |
db 0 |
| length_3 |
db 0 |
| length_4 |
db 0 |
| length_5 |
db 0 |
| mushroom_num |
dw 25 |
| delayC |
db 3 |
| delayP |
db 3 |
| map_array |
db ? |
| bullet_pos |
dw ? |
| go_left |
db 0 |
| go_right |
db 0 |
| go_up |
db 0 |
| go_down |
db 0 |
| shoot |
db 0 |
| shootenable |
db 1 |
| _ExitFlag |
db 0 |
| VidSeg |
EQU 0A000h |
| VidTextSeg |
EQU 0B800h |
| CR |
EQU 13 |
| LF |
EQU 10 |
| Thousands |
dw 0 |
| Hundreds |
dw 0 |
| Tens |
db 0 |
| Ones |
db 0 |
| LevelTens |
db 0 |
| LevelOnes |
db 0 |
| centi_pos |
dw 90 |
|
dw 80 |
|
dw 70 |
|
dw 60 |
|
dw 50 |
|
dw 40 |
|
dw 30 |
|
dw 20 |
|
dw 10 |
|
dw 0 |
| centi_dir |
db 10 dup(1) |
| centi_valid |
db 10 dup(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Notes On Certain Variables:
- For the head_X_direction variables, 0=up, 1=right, 2=down, 3=left.
- Map_array is a 32X20 variables.
- For the go_X variables, 0=not going that direction, 1=you are going
that direction.
- Shootenable is 0 if you cannot shoot and 1 if you can shoot.
Functions:
- Random (Dave)
- Purpose: To create a random number and return
a pseudo-random number by multiplication and addition of large prime constants
to a random number.
- Input: Randval
- Output: AX - random number between 0..2^16-1
- Setup_Mushroom (Dave)
- Purpose: Places mushrooms randomly in the map_array.
- Inputs:
- Mushroom_Num has the number of mushrooms to put in array.
- Map_array
- Calls: Random
- Delay (Cathy)
- Purpose: To burn CPU cycles for the centipede
so that it doesn't go extremely fast.
- Input: DelayC
- Update_Mushroom (Dave)
- Purpose: If a mushroom is hit, this function either
creates a smaller mushroom in the same place, or if the mushroom is killed,
it eliminates it from the screen and is no longer an obstacle.
- Input: DX - has the location of the mushroom in
the map array.
- Draw_Tray (Dave)
- Purpose: To refresh score, level, and lives tray
at the bottom of the screen.
- Input: ???
- Output: To the screen
- KeyInstall/KeyboardController/KeyDeinstall (Todd)
- Purpose: Replace default keyboard interrupt routine.
- Input: Button presses.
- Outputs:
- _ExitFlag set to 1 when Esc is pressed
- Go_Right is set to 1 when right arrow is pressed, 0 when released.
- Go_Left is set to 1 when left arrow is pressed, 0 when released.
- Go_Up is set to 1 when the up arrow is pressed, 0 when released.
- Go_Down is set to 1 when the down arrow is pressed, 0 when released.
- Fire is set to 1 when Z is pressed, 0 when released.
- LoadPCX (Todd)
- Purpose: Loads and decodes a 320X200 PCX file
into memory and sets VGA Palette registers to those used by the image.
- Input:
- AX - Destination segment address
- DX - pointer to a null-terminated string containing filename
- Output:
- Fills destination (DestSeg:0) with image data.
- Fills VGA palette registers with image colors.
- Uses ScratchPad to hold compressed image data.
- ShowScreenBuffer (Todd)
- Purpose: Move 320X200 pixels of screen data from
ScreenBuffer to the screen. Then it clears the ScreenBuffer.
- Input: ScreenBuffer
- Output: Writes directly to the screen and clears
the ScreenBuffer.
- CheckMove_Cent (Dave)
- Purpose: To check if a centipede move is valid.
- Input: AX - head position and DX - direction
- Output: AX - 0 if not a valid move, 1 if it was
valid.
- Cent_Move (Dave)
- Purpose: To move centipede. Calls Checkmove_Cent.
Checks to see if the centipede hits the player. If so it calls DeathSound.
This procedure also animates the movement of the centipede.
- Input: head position and direction, map_array
- Output: head position and head direction, map_array.
- Checkmove_Bullet (Brett)
- Purpose: To see if the bullet can go to the next
position.
- Input: bullet_pos, map_array
- Output: AX - 0 if nothing, 1 if hit.
- Bullet_Move (Brett)
- Purpose: Animate the bullet and move its position.
Calls Checkmove_bullet
- Input: bullet_pos
- Output: bullet_pos
- Checkmove_Player (Brett)
- Purpose: To see if the player made a valid move.
The player can only move up, down, left, and right. If the player is on
the far left of the screen and presses the left arrow, the player does
nothing. Same for the right side. The player is also only allowed to move
up 50 pixels from the bottom of the screen. This is to make the game more
challenging by limiting the area that the player can move to avoid the
centipede.
- Input: map_array, DX has new player_pos
- Output: AX - 0 if not valid, 1 if valid, 2 if
hits a centipede
- Player_Move (Brett)
- Purpose: To animate and move the player across
the screen. Calls Checkmove_player.
- Input: player_pos, keyboard flags
- Output: map_array, and sends image to screenbuffer
- Bullet_Hit (Brett)
- Purpose: If a bullet hit something, this function
makes the appropriate calls to other functions to update the game. For
sound, if a mushroom is hit, it calls HitMushroomSound. If a centipede
is hit, it calls HitCentipedeSound.
- Input: bullet_pos, map_array
- Output: map_array
- FireSound (Adapted by Todd from Drinking Illini
game)
- Purpose: To play the sound "shoot.raw."
It calls and also make shootenable 0
- Input:
- AX - SoundSeg
- BX - offset Soundfx
- DX - Soundlength
- SI - offset Sound
- Output: modifies shootenable, calls Playsound.
- HitMushroomSound (Adapted by Todd from Drinking
Illini Game)
- Purpose: To play the sound "hitm.raw" and
also make shootenable 1.
- Input:
- AX - SoundSeg
- BX - offset Soundfx
- DX - Soundlength
- SI - offset Sound
- Output: Modifies shootenable, calls Playsound
- HitCentipedeSound (Adapted by Todd from Drinking
Illini game)
- Purpose: To play the sound "hitc.raw"
and also make shootenable 1.
- Input:
- AX - SoundSeg
- BX - offset Soundfx
- DX - Soundlength
- SI - offset Sound
- Output: Modifies shootenable, calls Playsound
- DeathSound (Adapted by Todd from Drinking Illini
game.)
- Purpose: To play the sound when you die. Also
decrements lives. If lives = 0 then call game_over. If not, call start_level
- Input:
- AX - SoundSeg
- BX - offset Soundfx
- DX - Soundlength
- SI - offset Sound
- Output: Modifies lives, calls Playsound.
- IntroMusic (Todd)
- Purpose: To load in the midifile into the midiseg
and initialize registers to start the play of the xmi music.
- Input:
- AX - MidiSeg
- DI - offset Midi
- CX - Midilength
- DX - offset Midifile1
- Output: Calls LoadSound, RegXmidi, PlayMidi.
- Menu (Cathy)
- Purpose: To control the begining of the game.
- Input: None.
- Output: None.
- Instructions (Cathy)
- Purpose: To display the instructions on the screen
and then when Esc is pressed, go back to the Menu
- Input: Keyboard.
- Output: None.
- Credits: (Cathy)
- Purpose: To show the credits of the game and call
the credit music.
- Input: None.
- Output: To screen.
- Game_Over (Cathy)
- Purpose: To control what to do when the game is
over.
- Input: None.
- Output:None.
- Update_Cent (Dave)
- Purpose: To cut the centipede into two pieces
and create new head. It also finds out which head was hit.
- Inputs: DX - Location in the array of the hit.
- Outputs: Updated array with new head and segments.
- DrawTile (Brett)
- Purpose: To draw a tile at a location on the screen.
- Inputs:
- AX- has the location on the screen to draw the tile.
- DX- has the tile you want.
- Outputs: Image placed in screen buffer
- DrawScreen (Brett)
- Purpose: To draw all of the tiles on the screen.
- Inputs: Call DrawTile.
- Outputs: Image placed in screen buffer
- Start_Bullet
- Purpose: Initializes the bullet location when
you first fire. Updates shoot_enable.
- Input: Player Position
- Output: Bullet Position
- Graphmode (Brett)
- Purpose: To change the computer to graphics mode
- Input: None
- Output: None
- Textmode (Brett)
- Purpose: To change the computer to text mode.
- Input: None
- Output: None
- DrawMushroom (Brett)
- Purpose: To draw a mushroom at a location on the
screen with black transparent pixels.
- Inputs:
- AX- has the location on the screen to draw the tile.
- DX- has the tile you want.
- Outputs: Image placed in screen buffer
- NewLevel (Brett)
- Purpose: To reset centi_pos, dir, valid, player_pos,
set shootenable=1, increment level.
- LoadSound (Taken from the Drinking Illini game)
- Purpose: This procedure loads either midi or raw
files into the correct part of memory.
- Inputs:
- DX - offset of the file to be opened for read only
- DI - offset of the sound segment
- CX - Length of the file
- AX - The sound segment
- RegXMidi (Todd)
- Purpose: To register the xmi midi file using midpak's
704h function.
- Input: None.
- Output: None.
- PlayMidi (Todd)
- Purpose: To play the currently registered xmi
file using midpak.
- Inputs:
- ES - segment address of MidiSeg
- SI - offset of the xmi file to be used.
- Outputs: Sound to speakers.
- StopMidi (Todd)
- Purpose: To stop the currently playing xmi song.
- Inputs: None.
- Outputs: None.
- PrepareSound (Todd)
- Purpose: Loads the raw sound files into their
offsets in memory
- Inputs: None.
- Outputs: Puts the data into their offsets in memory
- PlaySound (Taken from the Drinking Illini)
- Purpose: Plays a digitized sound.
- Inputs:
- ax - Sound segment where sound data is stored.
- bx - Offset to selected sound data
- dx - Length of the sound data to be played.
- si - Offset of SOUND structure used by Digpak.
Map_Array: (640 position in array)
0 - Where you can go
H - head1
I - head2
J - head3
K - head4
L - head5
1, 2, 3, 4, or 5 - Segments of centipede
P - Player
M - big mushroom
N - medium mushroom
O - Smallest mushroom
Points Awarded For Game Play:
1 - for mushroom hit
5 - for body hit
10 - for head hit
Programmer's Notes:
For the digitized sound, the only thing that we could get to work in
the lab was the digpak with the help of the code from the Drinking Illini
game. Any other way of programming sound did not work at all. At best with
other code we got the speakers to pop when the sound was called. So we
figured to at least get the sound to work to go ahead and use digpak even
though Prof said not to use it. It was our last resort and we had to use
it.
We had an original song for our game that was composed by Todd and
put to midi by Todd but for some reason midiform wouldn't convert it to
an xmi file format correctly. When it was converted no sound was heard
when the computer was instructed to play the file. This caused many frustrations
since so much time was spent writing a song and it couldn't even be used.
So we ended up using one of the demo xmi files that came with midpak since
midiform didn't seem to want to convert midi files correctly. Todd tried
on many different computers to get it to work, but the only thing that
worked was the demo files. You may listen to the original song if you like.
Todd's Song