Movement constants

Sound constants

Element state variables

Temp variables

Variables Used for the introduction1, Menu_screen_intro, and game_over functions:

Sound variables

Functions:

Introduction1 and Menu_intro:

purpose: This will implement cool graphics with animation and incredible sound files. After the user passes through the initial intro he or she will then be prompted to select the level of play and the difficulty that they desire. This will involve input from the keyboard with specific hot keys. The menus will be pop up menus that will highlight as the user presses the level numbe them. The intro exits when the enter key is pressed. Sound effects will accompany each selection.

Inputs: Keyboard selection.

Calls: show_screen_buffer, intro_key, instkey(bx=0), load_pcx

Outputs: Level and Difficulty updated.

Game_over:

Purpose: This function will prompt the user to play again or quit. It updates the appropriate variables and then exits the game or goes to the main menu.

inputs: keyboard selection

outputs: updates gameover or replay variables

calls: Show_screen_buffer, instkey (bx=2), load_pcx, menu_screen_intro(if replay set)

CheckMove:

Purpose: Keeps track of the paddle position and the state of the ball (position and velocity vectors). Checks to see if the ball hits a wall, a brick, or the paddle, and then updates the position and velocity of the ball and the state of the brick array. The magnitude of the ball velocity should be such that it moves approximately 1 pixel per frame.

Inputs: Left, Right, BallX_F, BallY_F, Xvelocity, Yvelocity, PaddleX

Ouptuts: Modifies PaddleX, BallX, BallX_F, BallY,BallY_F, Xvelocity, Yvelocity, PaddleX.

Notes:

Calls : Brick_Value and Bounce

Brick_Value:

purpose: Determines which type of brick is at the specified board location. If no brick is in that position then the brick value returned will be zero. Besides letting CheckMove know if there is a brick there, it updates the brick array appropriately by either decrementing it to the next degraded state for that brick or, when it's finally destroyed, changing the brick value to the first crumble state and leaving it for the Crumble routine. Also the player's score is increased. Finally, it calls the Random function, to randomly decide it will drop a spike from this brick, if there isn't already a spike in play.   

inputs: ax = x pixel coordinate, bx = y pixel coordinate

Outputs: cl = brick value, updates brick value in bricks array.

Notes:    calls Random

Bounce:

purpose: We want our paddle to be curved at the edges so you can get the ball to move at different angles. We will approximate this by associatting an angle with each pixel along the top edge of the paddle (0 degrees for the pixels in the middle of the paddle and incrementally increasing angles for each pixel as you get closer to the edge). All angles choosen will be integers in radians so that they can be easily passed in to the procedure in a register. This function uses the FPU to calculate the new values of x_velocity and y_velocity when the ball hits one of the segments of the paddle that is at a non-zero angle with respect to the positve X axis.

Inputs: ax = angle of plane, x_velocity, y_velocity

Outputs: updated x_velocity and y_velocity

Notes: the new velocities will be calculated with the formula :

Random:
            (Eric Keller)

Purpose: generates a random 16 bit number

Inputs: randval

Outputs: AX = random 16 bit number

Delay:
            (Eric Keller)

Purpose: Burns CPU cycles to waste time

Inputs: DelayC

Outputs: time

Crumble:
            (Eric Keller)
Purpose:  Implements the animated crumbling effect when a brick is destroyed. Does this by traversing the bricks array and checking if the bricks are in one of the crumble states. If they are then it degrades those bricks to the next crumble state. This proccess  is repeated every frame until the brick is gone. Also implements a check to see if the board has been cleared so you know when to go to the next level.

Inputs:  the bricks array

Outputs:   updated brick array and board clear flag

Blast:
            (Eric Keller)

Purpose: Keeps track of position of the laser, checks for brick hits,and how many laser shots the player has left.

Inputs: Ammo, laserX

Outputs: Ammo, laserX, laserY

Notes: calls BrickValue

Spike:
           (Eric Keller)

Purpose: Keeps track of position of a falling spike and checks for a paddle hit.

Inputs: FallX, xfall_temp, yfall_temp

Outputs: FallX, FallY

Load_PCX:

(Chi Luong and Jon Spychalski

Inputs: PCX file

Outputs: Uploaded PCX file into the specified segment

Purpose: Takes a PCX file and stores it into memory for later runtime use.

Show_Screen_Buffer:

(Chi Luong and Jon Spychalski)

Inputs: ScreenBuffer

Outputs: Writes directly to the screen and clears the ScreenBuffer

Purpose: Move 320x200 pixels of screen data from ScreenBuffer to the svreen. Then it clears the ScreenBuffer.

Notes: Uses string opcode to transfer the data. Uses 32-bit register for optimal efficiency.

Update_ScreenBuf:

(Chi Luong)

Purpose: Move 320x200 pixels of screen with the updated postions for the paddle and ball, the number and positions of the remaining blocks, the number of lives remaining,and the new score to the ScreenBuffer. It calls DrawPic and DrawBrick with the correct X and Y position to display the correct picture. The break pattern will be loaded depending on the initial pattern map that we want. There will be a laser displayed depending on whether the fire button (Control key) was pressed.

Inputs: Level, blockarray, ball_x, ball_y, paddle_x, score, balls_left, and bgseg.

Outputs:  ScreenBuffer

Notes: Use string opcode to transfer the data. Use 32-bit register for optimal efficiency. Use jump-tables to find the beginning offset of where to find the pictures and numbers to be drawn.

Calls: Show_Screen_Buffer, DrawPic, DrawBrick

DrawPic:

(Chi Luong)

DrawpPic: Draws the appropriate picture to the screen given its X and Y position. It is used to draw the crumbling of the bricks when destroyed, the ball, and the paddle. This is needed because we need to do some pixel masking to reveal only the picture that we want and not the picture background. We set the pixel to be masked as pixel value 255, so if the pixel has this value we do not display it.

Inputs: The X and Y position of the paddle,ball, and the offset of the brick to crumble. The BlockArray[] value, a BlockArray[] value of 0 will not draw the break, a BlockArray[] value other than 0 will draw its corresponding brick texture.

Outputs: ScreenBuffer

Notes: The paddle, ball, and crumbling picture sequence are stored in a pcx file linked with our program.

Calls: None

Install_Keyboard:

Purpose: Installs a new keyboard handler into DOS.

Inputs: bx = index for new keyboard handler

Outputs: new Key board handler

My_Key_Int:

Purpose: This is the actual keyboard handler function. It changes the status of the movement variables as well as the exit flag.

Deinstall_Keyboard:

Purpose: This removes our keyboard handler and reinstalls the old DOS handler.

inputs: Old_Key

Setup_Game:

(Chi Luong)

Purpose: Initialize ball and paddle position. Set up brick pattern from choice that we have depending on which map was selected during the menu selection screen. Indicate which level and how many lives are left.

Inputs: Whichlevel db - indicates which include file contains the map data wanted

Outputs: The selected brick pattern is moved to blockarray[].

Notes: Get images from the included pcx files.
 
 

DSP_INIT:

purpose: Enable the speakers so that sound can propogate, use macro DSP_WRITE. Initializes DSP; Installs a new or irq setting.

inputs: old irq settings

outputs: new dsp irq setting

DSP_DEINST:

purpose: return DSP to its original state (This removes our IRQ setting and reinstalls the old IRQ).

inputs: new irq settings

outputs: old irq settings

LOAD_XMI:

purpose: Put an extended midi file into a segment of memory called xmi_seg. Open the correct file, then read it into memory and close it again. set ExitFlag to a 1 if an error occured while opening or closing a .xmi file, hence, this will cause the game to quit.

inputs: xmi_num

outputs: A filled memory segment (xmi_seg)

XMI_PLAY:

purpose: Determine the length of the xmi based on the xmi_num. Play midi file for background, during game play. Needs to call xmi_load. use dspwrite macro to write to dsp.

inputs: xmi_num

outputs: sound protrudes from speakers

WAV_LOAD:

purpose: Load wave file into memory segment called wav_seg based upon the value of wav_num. obtain wav_lngth from tables too. open, read into memory and close wave files, setting exitflag to 1 if an error occured.

inputs: Wav_num

outputs: wav_lngth, a filled memory segment (wav_seg)

WAV_PLAY:

purpose: play a wave file. call dma_set, wav_load and macro DSPWRITE, use an 8 bit register to send to macro al is preffered. (which writes to dsp).

inputs: wav_lngth (from wav_load)

outputs: wav_lngth, a filled memory segment (wav_seg)

DMA_SET:

purpose: based on the segment value of wav_seg, and the offset of fg_music, calculate the page and pageoffset. set up dma so that transfer of data can take place (do the following to set up): maskoff channel so that it isn't disrupted, set up write mode to mode, write page, move offset of page (bits, 0 through 7, first) (8 through 15, second). addjust count register to wavelength minus one. again, (bits 0 through 7, first) (8 through 15, second). reenable channel 1 to enable sound card.

inputs: none

outputs: dma is propperly set up.

CheckSong:

purpose: check if .xmid is done. If so, then play the next song. Loop back to the first song when the last song is done playing.

inputs: wav_num

outputs: Updated wav_num, if need be the case.

DSPWRITE macro x:

purpose: write x to dsp, where x is an eight bit number.

inputs: x, (al is used to transfer the data between macro and functions)

outputs: write to dsp (port = sb_addr + STATUS)

WAV_IRQ:

purpose: sends to signal end of DMA trasfer and acknowledge service routine

inputs: none

outputs: DMA transfer stops, service routine is acknowledged

DSP_RESET:

purpose: Reset the dsp so that sound transfer can take place. send a one the reset register. give 3us time span so the reset CAN occur. wait another 100us to make sure that tbe reset HAS occured. test to see that it properly read in, finally read from the port. (have to acknowledge the card so that a file can be played).

inputs: none

outputs: dsp is reset