Super 8-ball Pool

 

Team Members:

Matt Rafacz (Group Leader)
Lori Haegele 
Ervin-Dawson Warner
Quinn Butler

Introduction:

This is a fun and challenging game of 8-ball pool.   The object of course is to make all seven of your balls before your opponent makes all seven of his.  The player who makes their seven balls then and only then is allowed to make the 8-ball.  If at anytime before all seven of the balls have been pocketed the 8-ball is made, the game ends and that player losses. 

This game will feature advanced graphics, .wav sound and perhaps even midi sound.  At this time all graphics will be done in 320x200x256 color graphics.  The mouse will be the main interfacing device.  For sound implementation,  The DMA controller will be programmed.  Setups for different card configurations will be selectable.

Implementation:

This game will store the following structure that will keep track of all the balls. The physics will make sure the momentum is preserved in all of the collisions to allow for a realistic play of game. Our game will have a match between two pool legions Minnesota Fatz and Fast Eddie. They will bet on each game and the game will end when they run out of money.

Structures:

All structures which be used.

SingleBall Struct
    Xvel Real4
    Yvel Real4
    Xpos Real4
    Ypos    Real4
    Xspin Real4
    Yspin Real4
SingleBall ENDS


    Cueball    SingleBall
    1Ball        SingleBall
    2Ball        SingleBall
    3Ball        SingleBall
    4Ball        SingleBall
    5Ball        SingleBall
    6Ball        SingleBall
    7Ball        SingleBall
    8Ball        SingleBall
    9Ball        SingleBall
    10Ball       SingleBall
    11Ball       SingleBall
    12Ball       SingleBall
    13Ball       SingleBall
    14Ball       SingleBall
    15Ball       SingleBall

Game Main:

The game's main loop.

Main procedure
Inputs:none
Outputs: none

Game Sequence:
1. Initialization-interrupts, graphics, sound, variables
2. Introduction screen
3. Menu choices: play game, about, exit
       A. If exit chosen: exit game
       B. If about chosen
            i. Display about to screen, play music
       C. If game chosen
            i. Prompt player for gambling choice
            ii. Enter game main loop
                1. Draws screens, playes music, sounds
                2. Shots and scores calculaed, etc
                3. Gameover sequence

Function Definitions

By Ervin Warner

Procedure: InitMouse (Ervin-Dawson Warner)
Initializes the mouse returns InitError=0 if not available
Inputs: None
Outputs:
InitError

Procedure: ShowMouse ( Ervin-Dawson Warner)
Displays the mouse on screen
Inputs: none
Outputs: none

Procedure: HideMouse (Ervin-Dawson Warner)
Removes mouse from screen to draw graphics
Inputs: none
Outputs: none

Procedure: GetMouseXY ( Ervin-Dawson Warner)
Updates the mousex and MouseY variables with the new mouse position
Inputs: none
Outputs: MouseX, MouseY, MouseMoved, AimX,

Procedure: CheckButtonsTitle (Ervin-Dawson Warner)
Checks if a button has been pressed at the title screen
Inputs: none
Outputs: ButtonStat

  • 0 nothing pressed

    1 over start button

    2 over options button

    3 over about button

    4 over exit button

    5 pressed start button

    6 pressed Options button

    7 pressed about button

    8 pressed exit

  • Procedure: CheckButtonsGame (Ervin-Dawson Warner)
    Checks if a mouse button was clicked in a playable area on the game screen
    and updates buttonstat
    Inputs: none
    Outputs: ButtonStat=

  • 0 nothing pressed

    1 Aim Box pressed - updates AimX and AimY

    2 Power Box pressed

    3 Spin Box pressed updates CueBall.SpinX and CueBall.SpinY

    9 Exit Button Pressed

  • Procedure: InitSound ( Ervin-Dawson Warner)
    This procedure initializes midpak and loads the sound file
    Inputs: none
    Outputs:

    Procedure: PlayMidi (Ervin-Dawson Warner)
    This procedure takes in WhichSong and plays the appropriate midifile Implements a repeat playing feature
    Inputs: WhichSong
    Outputs: Sound from speakers :)

    Procedure: ScrollINR (Ervin-Dawson Warner)
    This procedure scrolls in a graphic from the right
    Inputs: AX= offset of graphic to be scrolled in
    Outputs: to screen

    Procedure: ScrollINL (Ervin-Dawosn Warner)
    Same as ScrollINL except scrolls in from the left
    Inputs: Ax= segment of the graphic
    Outputs: None:

    Procedure: ScrollPcx (Ervin-Dawson Warner)
    This procedure scrolls a grpahics down off the screen
    Inputs: ax segment of grpahic to be scrolled off
    Outputs: none

    Procedure: ShowIntro (Ervin-Dawson Warner)
    This procedure is the main procedure for the intro and title screen
    Inputs: none
    Outputs: ButtonStat (see CheckButtonsTitle

    Procedure: DrawLine ( Ervin-Dawson Warner )
    Draws a line at Y from XMin,ZMin to XMax,ZMax Color=Color
    Inputs: (Y, XMin, XMax, ZMin, ZMax, Color)
    Outputs: a line to SBSeg
    Uses: DrawPointMacro

    Procedure: CueCase (Matt Rafacz and Ervin-Dawson Warner)
    If the cueball scratches spot the cueball
    Inputs: AimX, aimY
    Outputs: CueBall.Xpos, Cueball.yPos, NewBalls, OldBalls

     

    By Lori Haegele:

    Procedure: GameOver (Lori, Matt and Ervin)
    Handles the gameover case, draws appropriate outputs to screen.
    Inputs: Winner, Money1, Money2
    Outputs: None

    Procedure: InitNewRound
    Reinitializes variables to prepare for a new round
    Inputs: SolStr,Player,FirstBall,GameStatus,turn,NewBalss,Breakcheck, Power
    Outputs: None

    Procedure: LOADGAMEGRAPH
    Loads the PCX files for the game screen

    Procedure: DoShot
    While balls are moving, updates screen
    Inputs:BallsMoving
    Outputs:None

    Procedure: Change Color
    To determine if a player is solids, stripes or if the table is still open
    Inputs: FirstBall, Player
    Outputs: SolStr

    Procedure: CheckStatus
    To determine if there was a scratch, whose turn is next, if the game is over, who the winner is.
    Inputs: Turn, FirstBall, SolStr, NewBalls, Player
    Outputs: Winner
    GameStatus= 0 if game is over

  • =1 if scratch

    =2 if another turn

  • Procedure: AdjustMoney
    Purpose: To determine each player's money after a round has been won
    Inputs: Winner
    Outputs:Money1, Money2

     

    Written by Quinn Butler:

    Procedure: BallNumber
    This macro calculates a ball's address and places it in DI
    Inputs: : Ball number
    Outputs: Places address in DI

    Procedure: ChangeXYPos
    This macro places a xyVelocity in the ball structure
    Inputs: : Ball number, XYvelocity address
    Outputs: Updates SingleBall

    Procedure: ChangeXYVel
    This macro places a xyVelocity in the ball structure
    Inputs: : Ball number, XYvelocity address
    Outputs: Updates SingleBall

    Procedure: GetDistance
    This macro returns the distance between two objects
    Inputs: : Object 1 Coor address SI, Object 2 Coor address DI
    Outputs: Places distance between objects in Real4 Distance

    Procedure: Set_Rack
    This function initializes the ball array to a standard rack formation.
    Inputs: entire Ball array
    Outputs:
    entire Ball array

    Procedure: Do_Break
    This function 'spices up' the break by adding in some additional velocities only upon the break, right now this function is disables and to get a good break, we powered up the break shot.
    Inputs: : entire Ball array
    Outputs: entire Ball array

    Procedure: Cue_Ball
    This function will determine the xy velocity that the cue ball initially has. It will be calculated from the power and aim variables, also adds in spin.
    Inputs: Ball0, power, AimX,AimY
    Outputs: Ball0

    Procedure: Ball_Collision
    This functions checks for a ball collision, and will change the xy-spin and velocities on the two balls simulating a collision. It will also cause a 'break' if it's the first shot and cueball collision of the game
    Inputs: : Entire Ball array, BreakCheck
    Outputs: Entire Ball array, BreakCheck

    Procedure: Rail_Collision
    This function takes enitre ball array, checks for rail collisions and changes its spin and velocity simulating a collision with the rail
    Inputs: Entire Ball array
    Outputs: Entire Ball array

    Procedure: Ball_Friction
    This function slows down every ball according to FrictionCoef, simulating rolling friction
    Inputs: : entire Ball array, FrictionCoeff
    Outputs: entire Ball array

    Procedure: Move_Balls
    This function changes the xy positions of every ball based on the xy velocities of each ball.
    Inputs: entire Ball array
    Outputs: entire Ball array

    Procedure: Pocket_Check
    This function checks to see if any ball landed in a pocket, removes the ball from the table, and if it's the first ball pocketed, changes firstball
    Inputs: : entire Ball array, NewBalls, FirstBall
    Outputs: NewBalls, FirstBall

    Procedure: Check_Endofturn
    This function checks to see if all the balls have stopped moving, and if so, ends the turn
    Inputs: entire Ball array, BallsMoving
    Outputs: BallsMoving

    Procedure: Cue_Set_Spin
    This function places the spin on the cue ball at beginning of shot
    Inputs: : CueBall struct, Spin
    Outputs: CueBall struct

     

    Written by Matt Rafacz:

    Procedure: DRAWPOOLTABLE
    Inputs: : none
    Draws the pcx file onto the screenbuffer

    Procedure: DrawPowerBox1
    Inputs: : none
    Draws a box that the player hits with mouse when ready to shoot

    Procedure: DrawPowerBox2
    -Inputs: - Power (0 - 1000)
    -Draws a red power meter

    Procedure: DrawPlayerBox
    -uses drawtext to draw the player's names and their money the player's name is highlighted if it's their turn.

    Procedure: GetBallOffset
    Inputs: - Balls (Jump Table) , bx is ball number
    Outputs: di to be offset on screen

    Procedure: DrawCueBall
    -Draws a cue ball and the spin location
    -Inputs:, spin

    Procedure: DrawBalls
    Inputs: - Balls (Struct), NewBalls
    Draws all of the balls onto the table

    Procedure: DrawSingleBall
    Inputs: - di is where a ball starts on the table
    - bx is the number of the ball

    Procedure: GETPOWER
    -Inputs: - buttonStats
    -Outputs:- power
    -Moves the power meter up and down while waiting for the power

    Procedure: DrawLineVerticle
    Draws a line at Y from XMin,ZMin to XMax,ZMax Color=Color
    Inputs: (Y, XMin, XMax, ZMin, ZMax, Color)
    Outputs: a line to SBSeg

    Procedure: DrawStick
    Inputs: - AimX, AimY, BallStruct
    Uses DrawLine to draw a line between cueball and Aimx,AimY

     

    Recycled Procedures:

    Procedure: DrawPoint
    Draws a point at (x,y,z) with a given color.

    Procedure: DrawText
    Draws a text string at (x,y,z) with the specified color.
    INPUTS:SI = pointer (offset) to string.

    Procedure: ModeGraph
    Switches to 320x200x256 VGA.

    Procedure: ModeText
    Switches to 80x50 text mode.

    Procedure: Procedure MyKeyHandler
    when a key is pressed checks which key sets p1/p2 direction,escape variable or space if appropriate, send acknowledgement then exits
    Inputs: none
    Outputs: escPressed, spcPressed, p1KeyDir, p2KeyDir

    Procedure: Procedure InstKey
    This procedure installs the Keyboard interrupt function
    Inputs: none
    Outputs: OldKeyV

    Procedure: Procedure DeInstKey
    This procedure deinstalls the keyboard interrupt funciton and restore the old function
    Inputs: OldKeyV
    Outputs: none

    Procedure: Procedure ErvDrawPoint
    Draws a point to screen. Modified to Output directly to the Video Segment
    Inputs: (X,Y,Z,Color)
    Outputs: Writes a color value to ScreenBuffer and a depth value to ZBuffer
    Calls XYConvert

    Procedure: XYconvert
    Takes x and y coordinates and converts to an offset in VideoMemory
    Inputs: ax=x bx=y
    Outputs: ax=offset

    Procedure: ErvDrawRect
    This procedure draws arectangle with its upper-left corner at (X,Y), depth Z, width
    W, hieght H, and color Color
    Inputs: (X,Y,Z,W,H, Color)
    Outputs: Writes points representing a single rectangle to ScreenBuffer and ZBuffer

    Procedure: ErvLoadPCX
    This Procedure Loads and decodes a 320x200 PCX file into memory adn sets VGA Palette registers Modified to outputs to any destination segment
    Inputs: AX=Segment in memory where image contenet chould be written
    DX=Offset of null-terminated string containging the filename.
    Outputs: the decoded pcx file to FontSeg

    Procedure: DrawScreen
    Draws the buffer in ax to screen
    Inputs: AX=segment of buffer to be printed
    Outputs: video to screen

    Procedure: InstTimer
    This procedure installs the timer and saves the old timer procedure
    Inputs: none
    Outputs: OldTimerV

    Procedure: DeInstTimer
    This procedure uninstalls the timer and restores the old timer value
    Inputs: OldTimerV
    Outputs: none

    Procedure: MyTimerHandler
    -increments timercount
    -calls oldtimerV every fourth time
    -sends ACK and end-of-interrupt

    Procedure: DrawScreen
    Blasts ScreenBuffer used for the pool table onto the screen.