Back to Index
[Graphics Functions]
void _DrawStatusBar(dword *DestOff, word X, word Y)
- Author: Ki Chung
- Inputs:
- DestOff - offset of destination buffer
- X - x coordinate of the status bar (use this as reference)
- Y - y coordinate of the status bar (use this as reference)
- _StatusBarOff - offset of status bar image
- _BigNumFontOff - offset of big number font image
- _SmallNumFontOff - offset of small number font image
- _BlueNumFontOff - offset of blue number font image
- [_NumP1Castle] - number of conquered P1 castle
- [_NumP2Castle] - number of conquered P2 castle
- [_TimeTick] - tick counter for displaying time left
- [_AnimateTick] - tick counter for animation
- Outputs: DestOff - status bar drawn to the destination buffer pointed to by DestOff
- Returns: -
- Calls: _CopyBuffer, _DrawImage
- Draws status bar which shows game info (remaining time time, number of castles conquered by each player, amount of territory conquered by each player, and number of cannons deployed by each player) to the destination buffer pointed to by DestOff
void _DrawMap(dword *DestOff, dword *MapOff)
- Author: Ki Chung, Seunghoon Kim
- Inputs:
- DestOff - offset of destination buffer
- MapOff - offset of map buffer
- [_TerrainOff] - offset of terrain image
- [_FlatCastleOff] - offset of flat castle image
- [_BattleCastleOff] - offset of battle phase castle image
- [_FlatCannonOff] - offset of flat cannon image
- [_BattleCannonOff] - offset of battle phase cannon image
- [_FlatWallOff] - offset of flat wall image
- [_BattleWallOff] - offset of battle phase wall image
- [_DestroyedCannonOff] - offset of destroyed cannon image
- [_RubblesOff] - offset of rubbles image
- [_OverlayOff] - offset of overlay buffer
- [_Phase] - current phase
- [_AnimateTick] - tick counter for animation
- Outputs: DestOff - map data drawn to the destination buffer pointed to by DestOff
- Returns: -
- Calls: _ClearBuffer, _CopyBuffer, _ComposeBuffer
- Draws map data to the destination buffer pointed to by DestOff; First colors P1 and P2 regions accordingly, then draws castles, cannons, and walls with the data provided by the game map buffer
void _DrawImage(dword *DestOff, word DestWidth, word DestHeight, dword *ImageOff, word ImageWidth, word ImageHeight, word X, word Y, word NumFrames, word FrameCount, dword AlphaBlend)
- Author: Ki Chung
- Inputs:
- DestOff - offset of destination buffer
- DestWidth - width of destination buffer
- DestHeight - height of destination buffer
- ImageOff - offset of image to draw
- ImageWidth - width of image buffer
- ImageHeight - height of image buffer
- X - x coordinate of cursor in grids
- Y - y coordinate of cursor in grids
- NumFrames - number of frames for image
- FrameCount - counter to be used to determine which frame to be drawn
- AlphaBlend - if 1, alpha-blend image to destination buffer
- [_OverlayOff] - offset of overlay buffer
- Outputs: image drawn on the destination buffer at (X, Y)
- Returns: -
- Calls: _ClearBuffer, _CopyBuffer, _ComposeBuffer, _PointInBox
- Draws image at (X, Y) on the destination buffer pointed to by DestOff and alpha-blends if indicated to do so. This function is a very general function which is used by many other graphics function in the game. It first checks to see if the pixel it's trying to draw is outside the boundary given by DestWidth and DestHeight. This is done by calling _PointInBox. Then it calculates the frame to draw from NumFrames and FrameCount. This calculation is done by dividing FrameCount by NumFrames. The remainder of the division is the frame to draw. So if the calling function wants to draw a particular frame in the image, it just needs to pass that frame number along with the width and height of the frame. If the calling function passes some sort of counting variable for the FrameCount, the end result is an animated object drawn on screen. If AlphaBlend is 1, it draws into overlay buffer instead of DestOff so that it can alpha composed.
void _DrawDeployCursor(dword *DestOff, word X, word Y, dword *CursorImageOff)
- Author: Ki Chung, Seunghoon Kim
- Inputs:
- DestOff - offset of destination buffer
- X - x coordinate of cursor in grids
- Y - y coordinate of cursor in grids
- CursorImageOff - offset of deploy cursor image
- [_InvalidCannonOff] - offset of invalid cannon image
- [_OverlayOff] - offset of overlay buffer
- [_AnimateTick] - tick count that determines which sprite to draw
- Outputs: deploy cursor drawn on the destination buffer at (X, Y)
- Returns: -
- Calls: _BoundaryInRegion, _ClearBuffer, _CopyBuffer, _ComposeBuffer
- Draws deploy cursor at (X, Y) on the destination buffer pointed to by DestOff, if the cannon lies over where it cannot be placed, it's drawn with invalid cannon image
void _DrawBlock(dword *DestOff, word X, word Y, word Block, dword *BlockImageOff)
- Author: Seunghoon Kim
- Inputs:
- DestOff - offset of destination buffer
- X - x coordinate of block in grids
- Y - y coordinate of block in grids
- Block - block to draw
- BlockImageOff - offset of block image
- [_InvalidBlockOff] - offset of invalid block image
- [_OverlayOff] - offset of overlay buffer
- [_AnimateTick] - tick count that determines which sprite to draw
- Outputs: block drawn on the destination buffer at (X, Y)
- Returns: -
- Calls: _BlockInRegion, _ClearBuffer, _CopyBuffer, _ComposeBuffer
- Draws the random blocks created at various positions, respect to the rotations made by the player. The function makes a call to BlockInRegion, to check if the block is in the free region, and in respect to the output returned by BlockInRegion, it will print out the picture on each grid, specified by the block numbers. The block numbers used here are randomly generated from the block array, which holds the bit assignment to each grid in 3x3 image.(The bit will be 1, if a block exists in that grid.) I have written separate function subroutines for each of the nine grids, since each grid holds different coordinate values, and each makes a different function calls.
void _DrawExplosion(dword *DestOff, dword *MapOff, dword *ExplosionArray, dword *ExplosionImage)
- Author: Ki Chung
- Inputs:
- DestOff - offset of destination buffer
- MapOff - offset of map buffer
- ExplosionArray - array of explosions to draw
- ExplosionImage - offset of explosion image
- [_AnimateTick] - tick count for animation (updates ExplosionArray)
- Outputs: explosions drawn to the buffer pointed to by DestOff
- Returns: -
- Calls: _CopyBuffer
- Draws explosions on the destination buffer pointed to by DestOff
void _DrawCannonBall(dword *DestOff, dword *CannonBallArray, dword *CannonBallImage)
- Author: Ki Chung
- Inputs:
- DestOff - offset of destination buffer
- CannonBallArray - array of cannon balls to draw
- CannonBallImage - offset of cannon ball image
- Outputs: cannon balls drawn to the buffer pointed to by DestOff
- Returns: -
- Calls: _CopyBuffer
- Draws cannon balls on the destination buffer pointed to by DestOff
void _DimBuffer(dword *DestOff, word DestWidth, word DestHeight, word DimVal)
- Author: Gihyun Ko
- Inputs:
- DestOff - offset of image buffer in memory
- DestWidth - width of the buffer
- DestHeight - height of the buffer
- DimVal - color to clear with
- Outputs: color copied to buffer
- Returns: -
- Calls: -
- Takes input DimVal and dims the buffer by that constant. Each pixel contains ARGB bytes and each bytes are unpacked into a mmx register and subracted by the DimVal using saturation to prevent the colors going bright again when it goes below 0. Then the mmx register is packed again to dword size and changed for each pixel in the DestOff with width DestWidth and height DestHeight.