| CS306 |
Processing Systems and Structures |
Lockwood, Spring 2002 |
Final Project:
Dynamic Fish Bowl
Project Summary
Create a 2D underwater world consisting of various types of fish and plants. In this world fish will interact with each other, by eating other fish, traveling together, etc. The dynamics of the fish will be programmable through a collection of assembly functions and partially customizable via a configuration file. Finally the state of the world will be savable to disk for later reference and restoration. Areas of expertise include graphic design and the use of the graphics mode for moving sprites about the screen. File IO knowledge will also be needed for saving of states, etc. Expertise in good programming practices for creating efficient algorithms to create the dynamic nature of the world would be useful as well.
Implementation
The graphical view of the fishbowl will be created using the 640x480x256 graphics environment. Objects in the environment are to be represented by sprites, while the background will be represented using repeating tiles of vegitation and static aquatic life.
The underlying actions of the fish will be handle by a single function call for each fish that updates its current position with a new position. This function may utilize any number of other algorithms and function calls for creating semi-intelligent movement. For each object in the environment, a set number of bytes in an array will be allocated, as well as a second array for storing current & future locations.
Group Members
- Greg Hackmann
- Kyle Woerner
- John Zook
Procedures
- ReadFile
- Purpose: Reads an input file describing the fish in the environment.
- Inputs: Reads data from disk
- Outputs: Updates _FishInfo, _FishCurrent, _FishUpdate array with new values
- Uses: None
- Registers: Preserves any that are modified
- Description:
Reads from a binary file the description of the environment into the _Fish array. Should also correctly set any other global variables that would be influenced.
- Status:
Nearly complete, should correctly read the files, but untested.
- Programmer: Kyle Woerner
- WriteFile
- Purpose: Saves a file describing the fish in the environment to be read by ReadFile
- Inputs: None
- Outputs: Writes data to disk
- Uses: None
- Registers: Preserves any that are modified
- Description:
Takes the current state of the environment and writes it to the disk.
- Status:
Complete. Correctly writes data file.
- Programmer: Kyle Woerner
- RunSplash
- Purpose: Draws each of the initial splash screens
- Inputs: None
- Uses: DisplayFile
- Registers: Preserves any that are modified
- Description:
Runs through each of the splash screens in succession at fixed or variable intervals.
- Status:
Incomplete, instead of looping through all splash screens only calls DisplayScreen and has it write a blanked splash.
- Programmer: Kyle Woerner
- DisplayFile
- Purpose: Reads a image file from disk and displays on the screen.
- Inputs: [FileHandle]: Handle of opened filed to read
- Outputs: Displays to screen
- Uses: None
- Registers: Preserves any that are modified
- Description:
Diplays a single full-size image to the screen. Used in the original splash screen creation.
- Status:
Incomplete, large chunck of almost complete code exists with a comment in the code describing the issue. Was redone quickly to display several full colored screens.
- Programmer: Kyle Woerner
- ReadImageFiles
- Purpose: Reads in all image files
- Inputs: None
- Uses: _FishInfo
- Registers: Preserves any that are modified
- Description:
Moves the data from image files for the fish into the corresponding _FishImage array location.
- Status:
Incomplete, fails to parse the pcx files.
- Programmer: Kyle Woerner
- MoveFish
- Purpose: Calculates the new position for a fish.
- Inputs: BX: Index of the fish to move
- Reads Variables:
- [_FishUpdate+offset]
- [_FishCurrent+offset]
- [_FishInfo+offset]
- Uses: KillFish, EatFish, RestoreFish
- Registers: Preserves any that are modified
- Description:
Taking the fishes current position and utilizing any information available about the surrounding fish this routine determines where the fish will move next.
- Status:
Not as complete as one would like, no logic exists. The fish do move as the function is supposed to do though.
- Programmer: John Zook
- ClosestFish
- Purpose: Calculates the closest fish and distance
- Inputs: BX: Index of the fish to compare to
- Reads Variables:
- [_FishCurrent+offset]
- [_FishInfo+offset]
- Registers: Returns CX as fish found and SI as distance
- Description:
Returns the distance to the closest fish and determines which fish that is.
- Status:
Unable to completely test the code. Should return correctly the distance, without taking square-root. Therefore it is limited to a distance of 255. This function was added for the intelligence of the fish, but remains unused.
- Programmer: John Zook
- RestoreFish
- Purpose: Brings a dead fish back to life somewhere on the screen (play God).
- Inputs: BX: Index of the fish to restore
- Uses: None
- Affects Variables:
- Registers: Preserves any that are modified
- Description:
After a fish has been dead for a reasonable amount of time, this function is called to restore the fish to life.
- Status:
Effectively brings a fish back to life on the side of the screen. Only limited by the fact that fish can overlap because ClosestFish doesn't work correctly.
- Programmer: John Zook
- KillFish
- Purpose: Kills a fish that is being / has been eaten or died from natural causes.
- Inputs: BX: Index of the fish to restore
- Uses: None
- Affects Variables:
- Registers: Preserves any that are modified
- Description:
This function shall convert a living fish into a dead state and alter all corresponding variables.
- Status:
Incomplete, due to time constraints. Does correctly modify the flags though, but would like to have it change the sprite for a dead fish.
- Programmer: John Zook
- EatFish
- Purpose: Kills a fish that is being / has been eaten or died from natural causes.
- Inputs:
- AX: Index of the fish eatting
- BX: Index of the fish to be eaten
- Uses: None
- Affects Variables:
- Registers: Preserves any that are modified
- Description:
This function shall convert a living fish into a dead state and alter all corresponding variables for a correctly eaten fish.
- Status:
Passed on implementing function to get rest of the code to work. Incomplete.
- Programmer: John Zook
- UpdateEnvironment
- Purpose: Updates the _Fish arrays with new positions.
- Inputs: None
- Uses: MoveFish, UpdateGREnvironment
- Registers: Preserves any that are modified
- Description:
Takes the current state of the environment and makes sure each fish updates its position. The order in which each fish is updated is arbitrary and upon conclusion the graphical environment must be updated.
- Status:
Complete, functions as expected.
- Programmer: John Zook
- UpdatePositions
- Purpose: Updates the _FishCurrent array with _FishUpdate array
- Inputs: None
- Uses: None
- Registers: Preserves any that are modified
- Description:
Moves everything in _FishUpdate to _FishCurrent
- Status:
Complete, works as functions. Was added to satisfy the need for the function.
- Programmer: John Zook
- RunFishBowl
- Purpose: Continuously updates the graphical environment
- Inputs: None
- Uses: UpdateEnvironment, UpdateGREnvironment, CheckInput
- Registers: Preserves any that are modified
- Description:
Loops until interupted by keyboard input. Will update the display on each loop. Also inserts any needed delay for smooth flow. This routine handles the overall flow of the program.
- Status:
Incomplete, simplified to only loop through a fixed number of times. Mostly runs test case instead of a complete program.
- Programmer: John Zook
- NewEnvironment
- Purpose: Creates a brand new environment
- Inputs: None
- Uses: None
- Registers: Preserves any that are modified
- Description:
Creates a new environment, completely rewriting the _FishInfo array.
- Status:
Complete, works as functions. Was added to satisfy the need for the function.
- Programmer: John Zook
- TestCase
- Purpose: Sets up a test case
- Inputs: None
- Uses: None
- Registers: Preserves any that are modified
- Description:
Used for testing.
- Status:
Complete, but shouldn't be needed and is.
- Programmer: John Zook
- DrawFish
- Purpose: Draws a single fish on the screen and updates background.
- Inputs
- BX: Index of this fish in the fish array.
- Reads Variables:
- [_FishUpdate+offset]
- [_FishCurrent+offset]
- [_FishInfo+offset]
- Outputs: Writes to screen
- Registers: Preserves any that are modified
- Description:
This routine draws a given fish on the screen. All information needed for the position, color, image, and state should be read from the three _Fish... arrays.
- Status:
Complete, works as described.
- Programmer: Greg Hackmann
- ClipSprite
- DrawSprite
- Purpose: Draws a single sprite to the scren
- Inputs: None
- Reads/Writes Variables:
- [_FishClipping+offset]
- [_FishUpdate+offset]
- Registers: Preserves any that are modified
- Description:
Draws the actual sprite.
- Status:
Complete, works as described.
- Programmer: Greg Hackmann
- UpdateGREnvironment
- Purpose: Updates the graphical view of the environment by calling each DrawFish.
- Inputs: None
- Uses: DrawFish
- Registers: Preserves any that are modified
- Description:
Takes the current state of the environment and makes sure each fish updates its position on the display. This function must handle the order in which fish are drawn, dead fish, followed by eaten fish, followed by eating fish, etc.
- Status:
Complete, works as described.
- Programmer: Greg Hackmann
- InitGraphics
- Purpose: Initializes the 640x480 display
- Inputs: None
- Outputs: None
- Registers: Preserves any that are modified
- Description:
Initializes graphical display for 640x480 display mode.
- Status:
Complete, works as described.
- Programmer: Greg Hackmann
- CheckInput
- Purpose: Checks the keyboard for any input.
- Inputs: None
- Outputs: AL: 0 if no key pressed 1 if key pressed
BX: Key pressed if key has been pressed, otherwise unmodified.
- Registers: Preserves any that are modified
- Description:
This function is used to handle interupting via the keyboard and switching states from a fixed interval update to user input (saving, quiting, pausing, etc)
- Status:
Incomplete.
- Programmer: Kyle Woerner
Other Notes
- If two fish collide, the large fish wins and the smaller fish gets eaten.
- Eatting fish are completely enveloped. Flag if being eatten.
- Splash screen designed for use in 320x200 graphics mode Mode 13h
- Actual program runs in 640x480 graphics mode
Indivdual Comments
Greg Hackmann's Comments
Kyle Woerner's Comments
John Zook's Comments
SVGA using VESA 1.2 Manual