Attribute VB_Name = "modDef"
'-------------------------------------------------------------------------------------
'
'  Project: Shooter
'  Date:    24/04/03
'  File:    modDef
'
'  Description
'   The Definitions and public constants go in here
'-------------------------------------------------------------------------------------
Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long

Public Const SCREEN_WIDTH As Long = 800
Public Const SCREEN_HEIGHT As Long = 600
Public Const SCREEN_BITDEPTH As Long = 16
Public Const COLOUR_KEY As Long = 0    'The transparent colour

Public nCounter As Long
Public nCalled As Long

Public nScreen  As Long
Public Const SCREEN_GAME As Long = 0
Public Const SCREEN_MENU As Long = 1
Public Const SCREEN_HIGH As Long = 2

'The Main DirectX Object
Public dxMain As New DirectX7

'Checks to See if The Main Loop should stop or not
Public Running As Boolean

'The Main Direct Draw Object
Public ddMain As DirectDraw7
Public bRestore As Boolean

'This is the primary buffer and its description
Public PrimBuf As DirectDrawSurface7
Public PrimBufDesc As DDSURFACEDESC2
Public VideoMode As Long
Public Clipper As DirectDrawClipper

'This is for the sprite drawing routine
Public Const DX_BLIT As Long = 0
Public Const DX_BLITTRANS As Long = 1
Public Const DX_BLITCLIPTRANS As Long = 2

'This is the back buffer and its description
Public BackBuf As DirectDrawSurface7
Public BackBufDesc As DDSURFACEDESC2
'This is used in the creation of the back buffer
Public Caps As DDSCAPS2

'The is the Surface we put the background picture in
Public BGSurf As DirectDrawSurface7
'This is used for the blitting process
Public rBGSurf As RECT

'The is the Surface we put the title picture in
Public TitleSurf As DirectDrawSurface7
'This is used for the blitting process
Public rTitleSurf As RECT

'The is the Surface we put the text in
Public TextSurf As DirectDrawSurface7
'This is used for the blitting process
Public rTextSurf As RECT

'The is the Surface we put the 4x4 sprites picture in
Public Sprite4Surf As DirectDrawSurface7
'This is used for the blitting process
Public rSprite4Surf As RECT

'The is the Surface we put the 8x8 sprites picture in
Public Sprite8Surf As DirectDrawSurface7
'This is used for the blitting process
Public rSprite8Surf As RECT

'The is the Surface we put the 16x16 sprites picture in
Public Sprite16Surf As DirectDrawSurface7
'This is used for the blitting process
Public rSprite16Surf As RECT

'The is the Surface we put the 32x32 sprites picture in
Public Sprite32Surf As DirectDrawSurface7
'This is used for the blitting process
Public rSprite32Surf As RECT
'The is the Surface we put the 32x32 sprites picture in
Public Sprite32SurfFlash As DirectDrawSurface7
'This is used for the blitting process
Public rSprite32SurfFlash As RECT

'The is the Surface we put the 64x64 sprites picture in
Public Sprite64Surf As DirectDrawSurface7
'This is used for the blitting process
Public rSprite64Surf As RECT
'The is the Surface we put the 64x64 sprites picture in
Public Sprite64SurfFlash As DirectDrawSurface7
'This is used for the blitting process
Public rSprite64SurfFlash As RECT

'The is the Surface we put the 128x128 sprites picture in
Public Sprite128Surf As DirectDrawSurface7
'This is used for the blitting process
Public rSprite128Surf As RECT
Public Sprite128SurfFlash As DirectDrawSurface7
'This is used for the blitting process
Public rSprite128SurfFlash As RECT
Public Const SPRITE127HEIGHT As Long = 2000

'The is the Surface we put the Map Tiles in
Public TileSurf As DirectDrawSurface7
'This is used for the blitting process
Public rTileSurf As RECT

'The is the Surface we put the Explosions in
Public ExpSurf As DirectDrawSurface7
'This is used for the blitting process
Public rExpSurf As RECT

Public Const LOCK_16X16 As Long = 1
Public Const LOCK_16X32 As Long = 2
Public Const LOCK_16X64 As Long = 3
Public Const LOCK_16X128 As Long = 4
Public Const LOCK_16XTILE As Long = 5
Public Const LOCK_32X16 As Long = 6
Public Const LOCK_32X32 As Long = 7
Public Const LOCK_32X64 As Long = 8
Public Const LOCK_32X128 As Long = 9
Public Const LOCK_32XTILE As Long = 10
Public Const LOCK_64X16 As Long = 11
Public Const LOCK_64X32 As Long = 12
Public Const LOCK_64X64 As Long = 13
Public Const LOCK_64X128 As Long = 14
Public Const LOCK_64XTILE As Long = 15
Public Const LOCK_128X16 As Long = 16
Public Const LOCK_128X32 As Long = 17
Public Const LOCK_128X64 As Long = 18
Public Const LOCK_128X128 As Long = 19
Public Const LOCK_128XTILE As Long = 20
Public Const LOCK_TILEX16 As Long = 21
Public Const LOCK_TILEX32 As Long = 22
Public Const LOCK_TILEX64 As Long = 23
Public Const LOCK_TILEX128 As Long = 24
Public Const LOCK_TILEXTILE As Long = 25


'This is the surface used by the collision routine to lock things...
Public ddsdBlank As DDSURFACEDESC2

'COLOUR CREATION STUFF - used by initialisation to set mask colours
Public PixelFormat As DDPIXELFORMAT
Public RedShiftLeft As Long
Public RedShiftRight As Long
Public GreenShiftLeft As Long
Public GreenShiftRight As Long
Public BlueShiftLeft As Long
Public BlueShiftRight As Long

Public ddInput As DirectInput
Public Keyboard As DirectInputDevice
Public Mouse As DirectInputDevice
Public KeyboardState As DIKEYBOARDSTATE
Public MouseState As DIMOUSESTATE
Public MousePosX As Long
Public MousePosY As Long
Public MouseBut As Boolean
Public Const KEY_DELAY As Long = 12
Public kbFirePressed As Long
Public kbBigGun As Long
Public kbChangePower As Long

Public Const TXTRED As Long = vbRed
Public Const TXTWHITE As Long = vbWhite

'The Main Direct Sound Object
Public dsMain As DirectSound

'This is the sounds buffer object
Public DBuffer As DirectSoundBuffer
Public DSoundLaser As DirectSoundBuffer
Public DSoundExplode As DirectSoundBuffer
Public DSoundBigExplode As DirectSoundBuffer
Public DSoundPower As DirectSoundBuffer
Public DSoundGem As DirectSoundBuffer
'This is the Description of the sounds buffer object
Public DBufferDesc As DSBUFFERDESC
Public Const SND_LASER As Long = 1
Public Const SND_GEM As Long = 2
Public Const SND_POWER As Long = 3
Public Const SND_EXPLODE As Long = 4
Public Const SND_BEXPLODE As Long = 5

'This defines the format of waveform-audio data
Public WavFormat As WAVEFORMATEX

'Frames Per Second Variables
Public fpsTimer     As Long
Public fpsCount     As Long
Public fpscounter   As Long
Public Const ONESECOND As Long = 60

'Gamma Control
Public GammaControl     As DirectDrawGammaControl   'The object that gets/sets gamma ramps
Public GammaRamp        As DDGAMMARAMP              'The gamma ramp to alter the screen state
Public OriginalRamp     As DDGAMMARAMP              'The gamma ramp to store the original screen state
Public nGammaRed        As Integer                  'Store red value w.r.t. original
Public nGammaGreen      As Integer                  'Store green value w.r.t. original
Public nGammaBlue       As Integer                  'Store blue value w.r.t. original

Public nGammaMode       As Long
Public nGammaCurrent    As Long
Public Const GAMMA_NORMAL As Long = 0
Public Const GAMMA_RED As Long = 1
Public Const GAMMA_WHITE As Long = 2

'-------------------------------------------------------------------------------------
'Debuging stuff...
Public Pdebug(12)   As Long
Public Bdebug(5, 4) As Long     'Used to draw boxes on the screen
                                'if 0 = 9 then screen pauses
                                '1=x, 2=y, 3=width, 4=height
'-------------------------------------------------------------------------------------
'Pause the game
Public bInit                    As Boolean       ' Does the screen need init
Public bPause                   As Boolean       'Flag showing if the game is paused
Public yTextPos                 As Long          'The scrolling text bar...
Public yTextDir                 As Long          'Which direction does it go
'-------------------------------------------------------------------------------------
'High Score table
Public nHighScore(10)           As Long
Public sHighScore(10)           As String
'Menu Counter
Public nMenu                    As Long
Public Const MENU_DELAY         As Long = 600
Public nMenuPos                 As Long
'-------------------------------------------------------------------------------------
'The Level Map
Public Const MAXMAP As Long = 200
Public Map(11, MAXMAP / 2)      As Byte             'The Map of a level (1st layer)
Public Map2(11, MAXMAP)         As Byte             'The map of a level (2nd layer)
Public MapFlags(100)            As Byte             'Used as local map variables
Public MapPointer               As Long             'Used to point into the map file
Public MapScroll                As Long          'Used for the small offset of the scroll
Public ShakeX                   As Long          'Map shake x offset (+-3)
Public ShakeY                   As Long          'Map shake y offset (+-1)
Public Const SCROLLSPEED As Long = 2    'Dont set to 0
Public bMapScroll               As Boolean          'Is the map being scrolled at the moe
Public bDontDrawTop             As Boolean          'Do we draw the top layer
Public bDontDrawBottom          As Boolean          'Do we draw the bottom layer

'Monster Spawn (attached to map)
Public Const MAXSPAWNS As Long = MAXMAP
Private Type defSpawn
    Type    As Long
    Map     As Long     'What part of the map spawns these enemies
    Action  As Long
    Group   As Long     'If a group of enemies are spawned then nothing else does
    xPos    As Long
    yPos    As Long
    xDest   As Long
    yDest   As Long
End Type
Public Spawn(MAXSPAWNS)         As defSpawn
'-------------------------------------------------------------------------------------
'Some Missiles
Public Const MAXMISSILES As Long = 100
Private Type defMissile
    xPos    As Double
    yPos    As Double
    Thrust  As Long
    dX      As Double
    dY      As Double
    Damage  As Long
    Type    As Long
End Type
Public Missiles(MAXMISSILES)    As defMissile
Public EnemyFire(MAXMISSILES)   As defMissile
Public AutoFireSpeed            As Long
Public BigFireSpeed             As Long
'-------------------------------------------------------------------------------------
'Explosions
'  These are static and do no damage if you fly through them...
'  There are a few types...
Public Const EXPLOSIONSPEED As Long = 3     'How quickly does the frame change on an explosion
Public Const MAXEXPLOSIONS As Long = 32
Private Type defExplosion
    xPos    As Long
    yPos    As Long
    Frame   As Long
    Counter As Long
End Type
Public Explosions(MAXEXPLOSIONS)    As defExplosion
Private Type defExpDetail       'Used to describe the explosion
    OffsetX As Long
    OffsetY As Long
    StartX  As Long
    StartY  As Long
    Width   As Long          'Actually end pixel position
    Height  As Long          'Actually end pixel position (a bit of a pain)
    Next    As Long          'If zero then no next frame!
    Delay   As Long
End Type
Public ExpDetail(25) As defExpDetail
'-------------------------------------------------------------------------------------
'Player Offsets and Variables
Public POffset(20, 2)           As Long
Public PX                       As Long     'Player X position
Public PY                       As Long     'Player y position
Public PWeap                    As Long     'Player Front Weapon Strength
Public PDual                    As Long     'Dual shot modifier
Public PBack                    As Long     'Back Shooter
Public PSide                    As Long     'Side Shooters
Public PSpeed                   As Long     'Player speed
Public PThruster                As Boolean  'Player is going backwards
Public PMove                    As Long     'Player moving left and right
Public PRect                    As RECT     'The Players Rectangle
Public PHealth                  As Long     'The Players health
Public PLives                   As Long     'the number of lives left
Public PStartY                  As Long     'The start position of the player
Public PAni                     As Long     'If anything is animating on a player

'Scores...
Public nScore                   As Long
Public nDispScore               As Long

'Graphic and offset constants
Public Const P_SHIP_GRAPHIC As Long = 32

Public Const P_OFF_SHIP As Long = 2
Public Const P_OFF_WEAP1 As Long = 4
Public Const P_OFF_THRUST_LEFT As Long = 5
Public Const P_OFF_THRUST_RIGHT As Long = 6
Public Const P_OFF_WEAP2 As Long = 7

'-------------------------------------------------------------------------------------
'Enemy Offsets and Variables
Public Const ENEMYSPEED As Long = 3     'How quickly does the frame change on an explosion
Public Const MAXENEMIES As Long = 32
Public Const MAXSPRITES As Long = 200   'How many
Public Const FLASH_DELAY As Long = 5    'How long does an enemy flash for if hit
Private Type defEnemy
    Type    As Long         'What type is this enemy
    xPos    As Long
    yPos    As Long
    xDest   As Long         'Set up by the enemy movement logic
    yDest   As Long         'Set up by the enemy movement logic
    MoveCounter As Long     'Where are we in the logic
    Speed   As Long         'How fast can we move
    CanShoot    As Long     'If 0 can't shoot otherwise the type of fire
    ShootDelay  As Long     'The delay between shots
    Frame   As Long         'Current Graphic and the counter to the next one...
    Counter As Long
    Flash   As Boolean      'If true then enemy is drawn with inverse set.
    FlashCounter As Long    'How long the flash counter has left to run
    Hits    As Long
    State   As Long         'What state is this enemy in...
    Score   As Long         'How Much is it worth
    Group   As Long         'What group does it belong to
    Spawns  As Long         'If it is killed what group does it spawn
End Type
Public Enemies(MAXENEMIES)    As defEnemy
Private Type defEnemyDetail    'Used to describe the enemy Graphics
    Surface As Long
    OffsetX As Long
    OffsetY As Long
    StartX  As Long
    StartY  As Long
    Width   As Long          'Actually end pixel position
    Height  As Long          'Actually end pixel position (a bit of a pain)
    Next    As Long          'If zero then no next frame!
    Delay   As Long
End Type
Public EnemyDetail(MAXSPRITES) As defEnemyDetail
Public Const ENEMYGRAPH_4 As Long = 0
Public Const ENEMYGRAPH_8 As Long = 0
Public Const ENEMYGRAPH_16 As Long = 0
Public Const ENEMYGRAPH_32 As Long = 0
Public Const ENEMYGRAPH_64 As Long = 81
Public Const ENEMYGRAPH_128 As Long = 104

Public Const ENEMY_SMLROCK1 As Long = 1
Public Const ENEMY_SMLROCK2 As Long = 17
Public Const ENEMY_SMLROCK3 As Long = 33
Public Const ENEMY_MIDROCK1 As Long = 81
Public Const ENEMY_MIDROCK2 As Long = 0
Public Const ENEMY_MIDROCK3 As Long = 0
Public Const ENEMY_BIGROCK1 As Long = 104
Public Const ENEMY_BIGROCK2 As Long = 129
Public Const ENEMY_BIGROCK3 As Long = 0
Public Const ENEMY_UFO As Long = 49
Public Const ENEMY_DRONE As Long = 65

Public Const MAXGROUPS  As Long = 12
Public Const MAXINGROUP  As Long = 8
Private Type defEnemyGroup
    Number  As Long         'How many in this group
    Alive   As Long         'How many are left
    Counter(MAXINGROUP) As Long
    Frame(MAXINGROUP)   As Long
    Hits(MAXINGROUP)    As Long
    State(MAXINGROUP)   As Long
    Score(MAXINGROUP)   As Long
    nType(MAXINGROUP)   As Long
    xPos(MAXINGROUP)    As Long
    yPos(MAXINGROUP)    As Long
    Bonus   As Long         'How many more points if all group killed
    Gem     As Long         'Does a gem get spawned (if so what type)
End Type
Public EnemyGroups(MAXGROUPS)   As defEnemyGroup
'-------------------------------------------------------------------------------------
'Movement Paths
Public Const MAXPATHS As Long = 10
Public Const MAXPATHLENGTH As Long = 50
Private Type defPath
    Type    As Long
    xDir    As Long
    yDir    As Long
    Count   As Long
End Type
Public Paths(MAXPATHS, MAXPATHLENGTH) As defPath
'-------------------------------------------------------------------------------------
'Gem Offsets and variables (includes weapons and the like)
Private Type defGemDetail    'Used to describe the Gem Graphics
    Surface As Long
    OffsetX As Long
    OffsetY As Long
    StartX  As Long
    StartY  As Long
    Width   As Long          'Actually end pixel position
    Height  As Long          'Actually end pixel position (a bit of a pain)
    Next    As Long          'If zero then no next frame!
    Delay   As Long
End Type
Public GemDetail(8) As defGemDetail
Private Type defGems
    Type    As Long         '1 = Can Collide, 2 = Cant
    Counter As Long
    Frame   As Long
    xPos    As Long
    yPos    As Long
    yVel    As Long         'A gem drifts up in the end then starts to fall down
    xVel    As Long         'and it can randomly go side to side as well
End Type
Public Const MAXGEMS As Long = 32
Public Gems(MAXGEMS)  As defGems
'-------------------------------------------------------------------------------------
Private Type defStars
    Active  As Boolean
    xPos    As Long
    yPos    As Long
    yVel    As Long         'A star drifts up in the end then starts to fall down
    xVel    As Long         'and it can randomly go side to side as well
End Type
Public Const MAXSTARS As Long = 80
Public Stars(MAXSTARS)  As defStars
'-------------------------------------------------------------------------------------

Private Type defPowerUps
    Active      As Boolean
    Available   As Boolean
    Type        As Long
    Collected   As Long
    Needed      As Long
    Next        As Long
    Sound       As Boolean
End Type
Public Const MAXPOWERUPS As Long = 8
Public PowerUps(MAXPOWERUPS) As defPowerUps
Public pup_frame    As Long
Public Const PUP_DELAY As Long = 6  'How long before the gem rotates
Public pup_counter  As Long
Public Const PUP_AUTOFIRE As Long = 1
Public Const PUP_POWER As Long = 2
Public Const PUP_DUALFIRE As Long = 3
Public Const PUP_SIDEFIRE As Long = 4
Public Const PUP_BACKFIRE As Long = 5
Public pup_upgrade  As Boolean      'Are we doing the power up ani?
Public pup_ani      As Long         'What frame are we on...
Public pup_ani_count    As Long     'Gem Spawnings
