Back to Index
[Game design and data structures]
Resolution: 640 x 480 pixels
Pixels: 4 bytes (ARGB)
Map details:
Game field: 65 x 60 grids (520 x 480 pixels)
Status bar: 15 x 60 grids on the right side of the game field (120 x 480 pixels)
Grids: 8 x 8 pixels, 2 byte each
Bit 15-8 (while bit 1 = 1): index for [_P1CannonArray] or [_P2CannonArray]
Bit 15-8 (while bit 1 = 0):
Value 0: unvailable
Value 1: empty
Value 2: obstacle
Value 3: castle
Value 4: remains of destroyed cannon
Value 5: wall
Value 6: wall destroyed
Bit 7-4: reserved
Bit 3-2: Player indicator
Value 0: P1
Value 1: P2
Bit 1: cannon
Bit 0: occupied
Castle: 3 x 3 grids
Cannon: 2 x 2 grids
Cannon ball: 8 bytes
Byte 7: x coordinate of source in grid
Byte 6: y coordinate of source in grid
Byte 5: x coordinate of destination in grid
Byte 4: y coordinate of destination in grid
Bytes 3-2: x coordinate of current location in pixel
Bytes 1-0: y coordinate of current location in pixel
Effective range of damage: 1 grid
Explosion: 4 bytes
Byte 3: reserved (for possible expansion)
Byte 2: current frame to display
Byte 1: x coordinate of location in grid
Byte 0: y coordinate of location in grid
Wall piece: 1 to 5 contiguous grids out of 3 x 3 square (2 bytes)
Bits 15-9: reserved (for possible expansion)
Bits 8-0: wall piece data
Using the design shown below, we only need to rotate left low-byte by 2 bits in order to rotate a block counter-clockwise
Block design
0
7
6
1
8
5
2
3
4
Bit assignments
-
-
-
-
-
-
-
8
7
6
5
4
3
2
1
0
Game data variables:
[_P1X] - x coordinate of P1 cursor (2)
[_P1Y] - y coordinate of P1 cursor (2)
[_P1_Up_Key] - scancode of P1 'up' key (1)
[_P1_Down_Key] - scancode of P1 'down' key (1)
[_P1_Left_Key] - scancode of P1 'left' key (1)
[_P1_Right_Key] - scancode of P1 'right' key (1)
[_P1_Primary_Key] - scancode of P1 'primary' key (1)
[_P1_Secondary_Key] - scancode of P1 'secondary' key (1)
[_P1Score] - score for P1 (2)
[_P1Life] - indicates how many life P1 has (1)
[_P1CurrentBlock] - current wall piece for P1 (2)
[_NumP1Castle] - number of conquered P1 castle (1)
[_NumP1Territory] - number of conquered grid by P1 (2)
[_NumP1Cannon] - number of P1 cannons on the map (1)
[_NumP1DeployCannon] - number of P1 cannons available for deployment (1)
[_P1CastleArray] - array of castles for P1 (10 x 4)
Byte 1: x coordinate of castle (FFh if no castle)
Byte 0: y coordinate of castle (FFh if no castle)
[_P1CannonArray] - array of cannons for P1 (30 x 4)
Byte 3: reserved (for possible expansion)
Byte 2: damage count
Bytes 1-0: location of upper-left part of cannon on map in grids
[_P2X] - x coordinate of P2 cursor (2)
[_P2Y] - y coordinate of P2 cursor (2)
[_P2_Up_Key] - scancode of P2 'up' key (1)
[_P2_Down_Key] - scancode of P2 'down' key (1)
[_P2_Left_Key] - scancode of P2 'left' key (1)
[_P2_Right_Key] - scancode of P2 'right' key (1)
[_P2_Primary_Key] - scancode of P2 'primary' key (1)
[_P2_Secondary_Key] - scancode of P2 'secondary' key (1)
[_P2Score] - score for P2 (2)
[_P2Life] - indicates how many life P2 has (1)
[_P2CurrentBlock] - current wall piece for P2 (2)
[_NumP2Castle] - number of conquered P2 castle (1)
[_NumP2Territory] - number of conquered grid by P2 (2)
[_NumP2Cannon] - number of P2 cannons on the map (1)
[_NumP2DeployCannon] - number of P2 cannons available for deployment (1)
[_P2CastleArray] - array of castles for P2 (10 x 2)
Same as [_P1CastleArray]
[_P2CannonArray] - array of cannons for P2 (30 x 4)
Same as [_P1CannonArray]
[_CBallArray] - array of cannon balls currently on map (60 x 8)
Explained in Cannon ball under Map details
[_BlockArray] - array of 19 available wall pieces (19 x 2)
Explained in Wall piece under Map details
[_ExplosionArray] - array of explosion grids (30 x 4)
Explained in Explosion under Map details
[_NumTotalCastle] - number of castles available for each player (1)
[_NumRounds] - number of game rounds played (1)
[_BattleTime] - duration of battle phase (2)
[_RebuildTime] - duration of rebuild phase (2)
[_DeployTime] - duration of deploy phase (2)
Game map and buffer offset variables:
[_GameMapOff] - offset of game map buffer (65 x 60 x 1)
[_ScreenOff] - offset of screen buffer (640 x 480 x 4)
[_AuxScreenOff] - offset of secondary screen buffer (640 x 480 x 4) (for backup purposes)
[_MapScreenOff] - offset of map screen buffer (520 x 480 x 4)
[_OverlayOff] - offset of overlay buffer (520 x 480 x 4)
Image offset variables:
_StatusBarOff resd 1 ; offset of status bar image (120 x 480 x 4)
_LeadOff resd 1 ; offset of Lead image buffer (20 x 20 x 4)
_P1InitCursorOff ; offset of P1 initialize cursor (56 x 72 x 4)
_P1DeployCursorOff ; offset of P1 initialize cursor (16 x 16 x 4)
_P1BattleCursorOff ; offset of P1 battle cursor (24 x 24 x 4)
_P1TerrainOff ; offset of P1 terrain image (8 x 8 x 4)
_P1BlockOff ; offset of P1 block image (8 x 8 x 4)
_P1FlatWallOff ; offset of P1 flat wall image (8 x 8 x 4)
_P1BattleWallOff ; offset of P1 battle wall image (?)
_P1FlatCannonOff ; offset of P1 flat cannon image (16 x 16 x 4)
_P1BattleCannonOff ; offset of P1 battle cannon image (16 x 16 x 4)
_P1FlatCastleOff ; offset of P1 flat castle image (24 x 24 x 4)
_P1BattleCastleOff ; offset of P1 battle castle image (24 x 24 x 4)
_P1WinBannerOff ; offset of win banner for P1 (378 x 282 x 4)
_P2InitCursorOff ; offset of P2 initialize cursor (56 x 72 x 4)
_P2DeployCursorOff ; offset of P2 initialize cursor (16 x 16 x 4)
_P2BattleCursorOff ; offset of P2 battle cursor (24 x 24 x 4)
_P2TerrainOff ; offset of P2 terrain image (8 x 8 x 4)
_P2BlockOff ; offset of P2 block image (8 x 8 x 4)
_P2FlatWallOff ; offset of P2 flat wall image (8 x 8 x 4)
_P2BattleWallOff ; offset of P2 battle wall image (?)
_P2FlatCannonOff ; offset of P2 flat cannon image (16 x 16 x 4)
_P2BattleCannonOff ; offset of P2 battle cannon image (16 x 16 x 4)
_P2FlatCastleOff ; offset of P2 flat castle image (24 x 24 x 4)
_P2BattleCastleOff ; offset of P2 battle castle image (24 x 24 x 4)
_P2WinBannerOff ; offset of win banner for P2 (378 x 282 x 4)
_InvalidBlockOff ; offset of invalid block image (8 x 8 x 4)
_InvalidCannonOff ; offset of invalid cannon image (8 x 8 x 4)
_CannonBallOff ; offset of cannon ball image offset (240 x 20 x 4)
_ExplosionOff ; offset of explosion image offset (256 x 16 x 4)
_RubblesOff ; offset of rubbles image offset (8 x 8 x 4)
_DestroyedCannonOff ; offset of destroyed cannon image (16 x 16 x 4)
_Terrain1Off ; offset of terrain image #1 (520 x 480 x 4)
_Terrain2Off ; offset of terrain image #2 (520 x 480 x 4)
_TerrainOff ; offset of terrain image selected (520 x 480 x 4)
_BigNumFontOff ; offset of big number font image buffer (400 x 55 x 4)
_SmallNumFontOff ; offset of small number font image buffer (200 x 21 x 4)
_BlueNumFontOff ; offest of blue number font image buffer (100 x 12 x 4)
_BattleBannerOff ; offset of battle phase banner image buffer (441 x 119 x 4)
_RebuildBannerOff ; offset of rebuild phase banner image buffer (441 x 119 x 4)
_DeployBannerOff ; offset of deploy phase banner image buffer (441 x 119 x 4)
_MenuOff ; offset of menu screen
_PlayBtn0Off ; offset of play game button image buffer
_PlayBtn1Off ; offset of play game button image buffer
_InstructionBtn0Off ; offset of instruction button image buffer
_InstructionBtn1Off ; offset of instruction button image buffer
_CreditsBtn0Off ; offset of credits button image buffer
_CreditsBtn1Off ; offset of credits button image buffer
_ExitBtn0Off ; offset of exit button image buffer
_ExitBtn1Off ; offset of exit button image buffer
_InstScreen1Off ; offset of instruction screen 1
_InstScreen2Off ; offset of instruction screen 2
_InstScreen3Off ; offset of instruction screen 3
_InstScreen4Off ; offset of instruction screen 4
Sound offset variables:
_FireSndOff ; offset of cannon firing sound
_Fire2SndOff ; offset of cannon firing sound
_ExplosionSndOff ; offset of explosion sound
_BuildWallSndOff ; offset of placing wall piece sound
_BuildCannonSndOff ; offset of placing cannon sound
_InvalidSndOff ; offset of invalid move for placing object sound
_IntroBGMOff ; offset of intro background music
_BattleBGMOff ; offset of battle phase background music
_RebuildBGMOff ; offset of rebuild phase background music
_DeployBGMOff ; offset of deploy phase background music
_FireSndSize ; size of cannon firing sound
_Fire2SndSize ; size of cannon firing sound
_ExplosionSndSize ; size of explosion sound
_BuildWallSndSize ; size of placing wall piece sound
_BuildCannonSndSize ; size of placing cannon sound
_InvalidSndSize ; size of invalid move for placing object sound
_IntroBGMSize ; size of intro background music
_BattleBGMSize ; size of battle phase background music
_RebuildBGMSize ; size of rebuild phase background music
_DeployBGMSize ; size of deploy phase background music
Flags and status indicators:
[_Flags]: program flags (1)
Bit 4: right mouse button pressed down
Bit 3: left mouse button pressed down
Bit 0: exit
[_P1_InputFlags]: player 1 input flags (2)
Bit 15-8: reserved (for possible expansion)
Bit 7-6: reserved (for possible expansion)
Bit 5: 'primary' key
Bit 4: 'secondary' key
Bit 3: 'up' key
Bit 2: 'down' key
Bit 1: 'left' key
Bit 0: 'right' key
[_P2_InputFlags]: player 2 input flags (2)
Same as [_P1Flags]
[_Phase]: phase indicator(1)
Bits 7-5: current phase
Value 0: initialize phase
Value 1: deploy phase
Value 2: battle phase
Value 3: rebuild phase
Value 4: break phase
Bits 4-0 (while Bits 7-5 = 0):
Bit 4-2: reserved (for possible expansion)
Bit 1: P2 initialize phase
Bit 0: P1 initialize phase
Bits 4-0 (while Bits 7-5 = 1):
Bit 4-2: reserved (for possible expansion)
Bit 1: P2 deploy phase
Bit 0: P1 deploy phase
Bits 4-0 (while Bits 7-5 = 2): unused
Bits 4-0 (while Bits 7-5 = 3): unused
Bits 4-0 (while Bits 7-5 = 4):
Value 0: break phase before deploy
Value 1: break phase before battle
Value 2: break phase before rebuild
Other global variables:
[_GraphicsMode] - graphics mode # (2)
[_kbINT] - keyboard interrupt # (1)
[_kbIRQ] - keyboard IRQ (1)
[_kbPort] - keyboard port (2)
[_MouseSeg] - real mode segment for MouseCallback (2)
[_MouseOff] - real mode offset for MouseCallback (2)
[_MouseX] - X coordinate position of mouse on screen (2)
[_MouseY] - Y coordinate position of mouse on screen (2)
[_RoundingFactor] - rounding factor for alpha-blending (4)
[_TimeTick] - tick counter for timer (for controlling time limit in _Game)(2)
[_CBallTick] - tick counter for timer (for updating cannon ball array)(1)
[_AnimateTick] - tick counter for timer (for animation) (1)
[_BannerX] - x coordinate of banner (2)
[_BannerY] - y coordinate of banner (2)
Constants:
TIMER_INT = 1Ch ;timer int #
SCREEN_WIDTH = 640 ;width of resolution
SCREEN_HEIGHT = 480 ;height of resolution
GAME_MAP_WIDTH = 65 ;width of game map in grids
GAME_MAP_HEIGHT = 60 ;height of game map in grids
MAP_PIXEL_WIDTH = 520 ;width of game map in pixels
MAP_PIXEL_HEIGHT = 480 ;height of game map in pixels
STATUSBAR_WIDTH = 120 ;width of status bar in pixels
STATUSBAR_HEIGHT = 480 ;height of status bar in pixels
STATUSBAR_X = 520 ;x coordinate for status bar
STATUSBAR_Y = 0 ;y coordinate for status bar
WIN_BANNER_WIDTH = 50 ;width of win banner
WIN_BANNER_HEIGHT = 50 ;height of win banner
WIN_BANNER_X = 50 ;x coordinate for win banner
WIN_BANNER_Y = 50 ;y coordinate for win banner
DEPLOY_BANNER_WIDTH = 50 ;width of deploy banner
DEPLOY_BANNER_HEIGHT = 50 ;height of deploy banner
BATTLE_BANNER_WIDTH = 50 ;width of battle banner
BATTLE_BANNER_HEIGHT = 50 ;height of battle banner
REBUILD_BANNER_WIDTH = 50 ;width of rebuild banner
REBUILD_BANNER_HEIGHT = 50 ;height of rebuild banner
BANNER_INIT_X = 639 ;x coordinate for initial banner loctaion
BANNER_INIT_Y = 100 ;y coordinate for initial banner loctaion
CASTLE_WIDTH = 24 ;width of castle image buffer
CASTLE_HEIGHT = 24 ;height of castle image buffer
WALL_WIDTH = 8 ;width of wall
WALL_HEIGHT = 8 ;width of height
INIT_CURSOR_WIDTH = 56 ;width of init cursor
INIT_CURSOR_HEIGHT = 72 ;height of init cursor
BATTLE_CURSOR_WIDTH = 24 ;width of battle cursor
BATTLE_CURSOR_HEIGHT = 24 ;height of battle cursor
NUM_FRAMES_INIT_CURSOR = 8 ;number of frames for initialize cursor
NUM_FRAMES_BATTLE_CURSOR = 8 ;number of frames for battle cursor
DIM_VAL = 50 ;value for dimming buffer
MAX_CANNON = 30 ;max number of cannons allowed
NUM_HANDICAP_CANNON = 4 ;number of deploy cannons given to player who lost
NUM_INIT_TERRITORY = 63 ;amount of initial territory in grids
NUM_TOTAL_ROUNDS = 10 ;number of total game rounds
INIT_PHASE = 00000000b ;phase value for initialize
DEPLOY_PHASE = 00100000b ;phase value for deploy
BATTLE_PHASE = 01000000b ;phase value for battle
REBUILD_PHASE = 01100000b ;phase value for rebuild
BREAK_PHASE = 10000000b ;phase value for break
BREAK_DEPLOY_PHASE = 10000000b ;phase value for break before deploy
BREAK_BATTLE_PHASE = 10000001b ;phase value for break before battle
BREAK_REBUILD_PHASE = 10000010b ;phase value for break before rebuild
BREAK_TIME = 20 ;duration of break phase
OCCUPIED = 10000000b ;map bit for occupied
CANNON = 01000000b ;map bit for cannon
OBSTACLE = 0 ;map value for unavailable grid
CANNON_REMAINS = 1 ;map value for remains of destroyed cannon
WALL_HIT = 2 ;map value for wall piece hit by cannon ball
P1_REGION = 5 ;map value for P1 region
P1_WALL = 11 ;map value for P1 wall
P1_CASTLE = 12 ;map value for P1 castle
P1_INIT_PHASE = 00000001b ;bit for P1 initialize phase
P1_DEPLOY_PHASE = 00100001b ;bit for P1 deploy phase
P2_REGION = 6 ;map value for P2 region
P2_WALL = 21 ;map value for P2 wall
P2_CASTLE = 22 ;map value for P2 castle
P2_INIT_PHASE = 00000010b ;bit for P2 initialize phase
P2_DEPLOY_PHASE = 00100010b ;bit for P2 deploy phase
EXIT_FLAG = 00000001b ;exit flag
PRIMARY_FLAG = 00100000b ;'primary' input flag
SECONDARY_FLAG = 00010000b ;'secondary' input flag
UP_FLAG = 00001000b ;'up' input flag
DOWN_FLAG = 00000100b ;'down' input flag
LEFT_FLAG = 00000010b ;'left' input flag
RIGHT_FLAG = 00000001b ;'right' input flag
Preliminary grid and block design