local _ENV = require 'std.strict' (_G)

local class = require 'middleclass'
local playerObj = class('playerObj')
local enemyObj = class('enemyObj')
local obstacleObj = class('obstacleObj')
local bulletObj = class('bulletObj')

function playerObj:initialize(x, y)
    self.x = x
    self.y = y
    self.carsprite = 2 --spr1, 2x2 car sprite 
    self.isHit = false
    self.jump = false
    self.upBulletList = {}
    self.fwdBulletList = {}
    self.lives = 3
    self.score = 0
end

function bulletObj:initialize(flag, x, y)
    self.x = x
    self.y = y
    self.flag = flag
    self.move = true
end

function playerObj:fireHorizontalBullet()
    if #self.fwdBulletList < 4 then
        local newBullet = bulletObj:new(0, self.x, self.y -10)
        table.insert(self.fwdBulletList, newBullet)
        sfx(1,12,14,0, 4)
    end
end

function playerObj:fireUpwardBullet()
    if #self.upBulletList < 4 then
        local newBullet = bulletObj:new(1, self.x, self.y-16)
        table.insert(self.upBulletList, newBullet)
        sfx(1,12,14,0, 4)
    end
end


-- Updating bullet positions
function playerObj:updateBullets(enemyList)
    for i, bullet in ipairs(self.upBulletList) do

        bullet.y = bullet.y - 3  -- Move upwards
        spr(4, bullet.x, bullet.y, 0, 1, 1, 0)  -- 2 is the sprite ID for the bullet

        -- Remove bullets that are out of bounds
        if bullet.y < -10 then
            self.upBulletList = removeFromTable(self.upBulletList, i)
            -- print('bullet gone', 40, 80)
        end


        for id, enemy in pairs(enemyList) do
            if hit(bullet, enemy) then
                enemy.isHit = true
                sfx(2,36,20,0, 3)
                self.score = self.score + enemy.points
                enemyList = removeFromTable(enemyList, enemy) 
                self.upBulletList = removeFromTable(self.upBulletList, i)
            end
        end
    end

    for i, bullet in ipairs(self.fwdBulletList) do

        bullet.x = bullet.x + 3  -- Move horizontally
        spr(20, bullet.x, bullet.y, 0, 1, 0, 0)  -- 18 is the sprite ID for the bullet
    

        -- Remove bullets that are out of bounds
        if bullet.x > 240 then
            self.fwdBulletList = removeFromTable(self.fwdBulletList, i)
            -- print('bullet gone', 40, 80)
        end

        for id, enemy in pairs(enemyList) do
            if hit(bullet, enemy) and enemy.type == 3 then 
                enemy.isHit = true
                sfx(2,36,20,0, 3)
                enemy.y = enemy.y + 30
                self.score = self.score + enemy.points
                enemyList = removeFromTable(enemyList, enemy) 
                self.fwdBulletList = removeFromTable(self.fwdBulletList, i)
            end
        end
    end
end

function playerObj:printLives()
    for i = 1, (self.lives) do
        spr(13, i * 10, 5)
    end
end



-- flying enemy is one of 3 types
function enemyObj:initialize(type, t)
    self.x = 239
    self.time = t
    self.isHit = false
    self.bulletList = {}
    self.points = math.random(200,300)
    self.type = type

    if type <= 2 then
        if type == 1 then
            self.y = math.random(15,50)
            self.sprite = 5
        elseif type == 2 then
            self.y = math.random(15,50)
            self.sprite = 21
        end
    else
        self.y = lands[self.x - 4].y - 4
        self.sprite = 12
    end


end

function enemyObj:fireEnemyBullet()
    local newBullet = bulletObj:new(1, self.x, self.y)
    table.insert(self.bulletList, newBullet)
    sfx(0,36,10,0, 4)
end

-- draws a bullet sprite directly below enemy. Increments each frame, until it hits the player
function enemyObj:updateEnemyBullet(bullet, player)
    if bullet.flag <= 1 then
        spr(7, bullet.x, bullet.y, 0)
        if not (hit(bullet, player)) then
            bullet.y = bullet.y + 1
        else
            self.bulletList = removeFromTable(self.bulletList, bullet)
            player.isHit = true
        end
    end

    if bullet.y > 100 or bullet.x < -8 then
        self.bulletList = removeFromTable(self.bulletList, bullet)
    end

end



ACCEL_VALUE = 3

function respawn(player1)
    local timer = 0
    while timer < 10000 do
        print('respawning.. ', 80, 50)
        timer = timer + 1
    end
    player1.x = 20
    player1.y = 104
end

function drawCar()
    -- spr(player1.carsprite, player1.x, player1.y, -1, 1, 0, 0, 2, 2)
  player1.y = lands[player1.x - 4].y
  spr(2, player1.x-7, player1.y-16, 0, 1, 0, 0, 2, 2)
  spr(1, player1.x-8, lands[player1.x-6].y-8, 0)
  spr(1, player1.x+2, lands[player1.x+6].y-8, 0)
end

-- display lives, time, score, and zones
function update(player1, enemyList)
    -- flag 0 = touching ground pixel

    -- player movement
    local left = 2
    local right = 3
    local ax = ACCEL_VALUE
    local ay = ACCEL_VALUE

    if btn(left) and player1.x > 10 then
        player1.x = player1.x - ax
    end
    if btn(right) and player1.x < 230 then
        player1.x = player1.x + ay
    end

    -- draw moon buggy
    if player1.isHit == false then
      drawCar()
    end
    
    print('score: ', 10, 18, 12)
    print(player1.score, 70, 18, 12)

  -- player fires upward bullet
    if btnp(4) then 
        player1:fireUpwardBullet()
    end

 -- player fires horizontal bullet
    if btnp(5) then 
        player1:fireHorizontalBullet()
    end

    -- Update bullet positions
    player1:updateBullets(enemyList)

    -- Print life counter
    player1:printLives()
end


function updateEnemies(enemyList, player1)
-- goes thru a list of enemies and updates them one by one
    for id, enemy in ipairs(enemyList) do
        -- draw enemy

        if (enemyList[id].isHit == false) then
            spr(enemyList[id].sprite, enemyList[id].x, enemyList[id].y, 0, 1, 0, 0, 1, 1)
            -- how enemies randomly shoot
            if math.random(100) == 1 and enemy.type <= 2 then
                if enemyList[id].x >= 0 then
                    enemy:fireEnemyBullet()
                end
            end
        end

        if enemy.time % 1200 >= 600 then
            if enemy.type == 1 then
                if enemy.sprite == 5 then
                    enemy.sprite = 6
                elseif enemy.sprite == 6 then
                    enemy.sprite = 5
                end
            elseif enemy.type == 2 then
                if enemy.sprite == 21 then
                    enemy.sprite = 22
                elseif enemy.sprite == 22 then
                    enemy.sprite = 21
                end
            end
        end


        for i, bullet in ipairs(enemy.bulletList) do
            enemy:updateEnemyBullet(bullet, player1)
        end

        -- movement    
        if enemyList[id].type <= 2 then
            enemyList[id].x = enemyList[id].x - 2
        else
            -- is stationary
            enemyList[id].x = enemyList[id].x - 1
            hit(enemyList[id], player1)
        end


    end
end

function removeFromTable(oldTable, id) -- if table item should be removed, copies existing enemy table minus removed item and returns new table 
    local newTable = {}
    for i = 1, #oldTable do
        if i ~= id then
            newTable[#newTable + 1] = oldTable[i]
        end
    end
    return newTable
end

function addToTable(oldTable, item)
    oldTable.newObject = item
    return oldTable
end

function hit(obj1, obj2)
    local cellSize = 8
    -- Calculate the grid cell coordinates for the centers of the objects
    local obj1CellX = (obj1.x + 8 / 2) // cellSize
    local obj1CellY = (obj1.y + 8 / 2) // cellSize
    local obj2CellX = (obj2.x + 8 / 2) // cellSize
    local obj2CellY = (obj2.y + 8 / 2) // cellSize

    -- Check for overlap in grid cells
    return obj1CellX == obj2CellX and obj1CellY == obj2CellY
end

function createLand(lands, yland)
    -- Creates the initial land table and populates it with 240 elements.
    for i = 1, 240 do
      yland = yland + math.random(-1, 1)
      yland = math.max(yland, 90)
      yland = math.min(yland, 120)
      local land = {y = yland, x = i}
      table.insert(lands, land)
    end
  end

  function createbgLand(lands, yland)
    -- Creates the initial land table and populates it with 240 elements.
    for i = 1, 240 do
      yland = yland + math.random(-1, 1)
      yland = math.max(yland, 80)
      yland = math.min(yland, 100)
      local land = {y = yland, x = i}
      table.insert(lands, land)
    end
  end
  
  function generateLand(lands)
    -- Extends the land table by adding points beyond x = 240.
    local yland = lands[#lands].y + math.random(-1, 1)
    yland = math.max(yland, 90)
    yland = math.min(yland, 120)
    local cont = {x = 240, y = yland}
    table.insert(lands, cont)
  end

  function generatebgLand(lands)
    -- Extends the land table by adding points beyond x = 240.
    local yland = lands[#lands].y + math.random(-1, 1)
    yland = math.max(yland, 80)
    yland = math.min(yland, 100)
    local cont = {x = 240, y = yland}
    table.insert(lands, cont)
  end
  
  function drawLands(lands)
    -- Draws the land using data stored in the table.
    local lineclr = 14
    local color = 13
    for id = #lands, 1, -1 do
      local l = lands[id]
      l.x = l.x - 1
      if l.x < 0 then
        table.remove(lands, id)
      end
      line(l.x, 240, l.x, l.y, lineclr)
      pix(l.x, l.y, color)
    end
  end

  function drawbgLands(lands)
    -- Draws the land using data stored in the table.
    local lineclr = 1
    local color = 1
    for id = #lands, 1, -1 do
      local l = lands[id]
      l.x = l.x - 1
      if l.x < 0 then
        table.remove(lands, id)
      end
      line(l.x, 240, l.x, l.y, lineclr)
      pix(l.x, l.y, color)
    end
  end
  

function generateStars()
    local stars = {}
    for i = 1, 50 do
        local x = math.random(0, 240)
        local y = math.random(0, 120)
        table.insert(stars, {x = x, y = y, active = true})
    end
    return stars
end

function drawStars(stars)
    for _, star in ipairs(stars) do
        pix(star.x, star.y, 13)
    end
end




local GAME_STATE_TITLE = 1
local GAME_STATE_PLAY = 2
local GAME_STATE_GAME_OVER = 3

-- Initialize the current game state
local gameState = GAME_STATE_TITLE

-- entity stuff
player1 = playerObj:new(20, 104)
enemyList = {}
obstacleList = {}
t = 0
spawnVal = 0

-- ground stuff
yland = 0
lands= {}
createLand(lands, yland)

--background stuff
yland2 = 0
lands2= {}
createbgLand(lands2, yland2)

stars = generateStars()
function TIC()
    cls(0)

    -- Draw background
    map()
    drawStars(stars)
    generatebgLand(lands2, yland2)
    drawbgLands(lands2)

    -- Update and draw the land elements
    generateLand(lands, yland) -- Extend the land table
    drawLands(lands)

    if gameState == GAME_STATE_TITLE then
        t = t + 1
        rect(0, 0, 300, 300, 0)
        spr(320, 10, 30, -1, 2, 0, 0, 16, 6)
        if t%60>=30 then
            print("A to Start", 89, 109,12)
        end
        if btnp(4) then
            -- sfx
            t = 0 
            spawnVal = 0
            player1.lives = 3
            --maybe add a start screen with controls
            gameState = GAME_STATE_PLAY
        end

    elseif gameState == GAME_STATE_PLAY then
        t = t + 1
        if #enemyList >= 30 or player1.isHit == true then
            enemyList = {}  -- Clear the enemyList if it exceeds 30 items
            obstacleList = {}
            if spawnVal < 800 then
                if spawnVal ~= 600 then
                    spawnVal = spawnVal + 100
                end
            end
        end

        local rand = math.random(900 - spawnVal)        
        if rand < 12 then
            if rand % 2 == 0 then
                local enemy = enemyObj:new(1, t)
                table.insert(enemyList, enemy)
            else 
                local enemy2 = enemyObj:new(2, t)
                table.insert(enemyList, enemy2)
                local enemy3 = enemyObj:new(3, t)
                table.insert(enemyList, enemy3)
            end
        sfx(3,1,-1,0, 1)
        end

        -- when player is hit
        if player1.isHit == true then
            -- deathAnimation()
            if player1.lives > 1 then
                respawn(player1)
                player1.lives = player1.lives - 1
                player1.isHit = false
            else
                gameState = GAME_STATE_GAME_OVER
            end
        end


        -- all update stuff
        update(player1, enemyList)
        updateEnemies(enemyList, player1)

    
    elseif gameState == GAME_STATE_GAME_OVER then
        cls()
        local string="Game over!"
        local width=print(string,0,-6)
        print(string,(240-width)//2,(106-6)//2, 13)

        local string2="Final score: "
        local width2=print(string2,0,-6)
        print(string2,(240-width2)//2,(136-6)//2, 13)

        local string3=player1.score
        local width3=print(string3,0,-6)
        print(string3,(240-width3)//2,(162-6)//2, 13)

        if btnp(4) then 
            gameState = GAME_STATE_TITLE
        end
    end
end














-- <TILES>
-- 001:0000000000000000000ff00000fedf0000fdef00000ff0000000000000000000
-- 002:0000000000000000000033000001331000013310000033000000330200113311
-- 003:0000000000000000000000000000000002222200222aba0022aaaba02aaaaaa0
-- 004:000ee00000edde0000edde0000edde0000edde000ff44ff00034430002222220
-- 005:0000000000baab0000aaaa00034aa43034444443344334432020020200000000
-- 006:0000000000baab0000aaaa00034aa43034444443344334432020020220200202
-- 007:002cc200002cc200002cc200002cc200002cc200002cc200002cc200002cc200
-- 011:0000000000000000000000000008000000998000089998000899898008999980
-- 012:0008880000999800089998000998998009999980998999888999988889998898
-- 013:0000000000000000030222000322aab0022222200fd00df00000000000000000
-- 018:0221111222221122222222220222222200222222000000000000000000000000
-- 019:22aaaa2022222220222222202222220022222000000000000000000000000000
-- 020:0000000020f0000023feeee0244dddde244dddde23feeee020f0000000000000
-- 021:0000000000baab0000aaaa00065aa56065555556655665567070070700000000
-- 022:0000000000baab0000aaaa00065aa56065555556655665567070070770700707
-- 023:000000000000000022222222cccccccccccccccc222222220000000000000000
-- 138:0000000000000000000000000000000000000000000000010000011f00111fee
-- 139:0000000000000000000000000000000000011111111ffff1ffffffffeeeeeeee
-- 140:000000000000000000000000000000001111100011111111fff11111effffff1
-- 141:0000000000000000000000000000000000000000100000001111100011111100
-- 153:000000000000000f000000ff00000eee000ffeee000eeefe00eeefed0feefede
-- 154:11ffeeeeffeeefeeeeeeeeeeeedeeeeeeededddeeeefeddeeeeefeddefedddde
-- 155:eeeeeeeeeeeeeeeeeeeffeeeeeeeeedeeeee1eefddeedeffeddfdfefee1deedd
-- 156:eeffffffeeef1ff1eeeffee1eeee1ff1eeeee1ffeeeeee1ff1e1f11fff1111e1
-- 157:f1111110fff111111fff1111f11ef111f111f1111f1fff11f1ffeff1ffff1ff1
-- 158:0000000010000000110000001110000011110000111110001111110011111110
-- 168:0000000000000000000000010000000100000011000000110000011100000111
-- 169:1fefeeee111edfee1eeefe11fe1111f1ef1111e1e1111edfeee1eeee1e1e1edd
-- 170:fdedeeddeeddeeedeeddeeededeeee1deeeeeeedeeddeeed1dddeddc1edededd
-- 171:efffddddedfedddeeddddddfefdeddffeeddffffdfeeddffdcddffffdefffeff
-- 172:dfff11e1df11f1ff1ff1f1fe1e11ffffed1ff1fdfff1deedfef1fdefff111fde
-- 173:ff1f1ff1fffeff11efff1111e1ff1111eeffffe1eef1ff11effff111e1efff11
-- 174:1111111011111111111111111111111111111111111111111111f111fe1f1111
-- 175:0000000000000000100000001000000011000000110000001100000011100000
-- 184:0000011e0000111f0000111f0000111e00001e1e00001e1f000011e10000f111
-- 185:1ee1dddde1e1dddddeeeeddd1feeedde1feeedde1feeddde1dfddcdedfddddce
-- 186:deeedd1feefed11fdddee11fdddee11deeeee1dddcddeedcddeededdeededded
-- 187:fffffeffffffeeffffeeffffffffffffdddfffffeeeeeeefeeeccfefddddfffe
-- 188:ffffffff1111fffeffffffffffffffeeffdeeeedffdeddddeefeddd1effefdd1
-- 189:eedd1effeddddde1eddddde1dddddee1effe1111fff11111fff1111111f11111
-- 190:11ef1111eee11111eff111111e11111111111111111111111111111111111111
-- 191:1110000011100000111000001111000011110000111100001111000011110000
-- 200:0000ee110000ee110000ee110000eefe0000edee00001eed00001edd000001ed
-- 201:ddddffdd1eeeedfd1efed1df111111fdfedde111ddde1111ddd11f11dee11111
-- 202:dddddeedddeeddfcdeeeedcddeefedcd11d11ddfff1ffffd11111fff1111f111
-- 203:dccdfffffffefffefeefecfeceeeecfedeeeeedfeeeeefefeeeeeffffeefcff1
-- 204:fffd1111efff1111dfff1111deff1111efff1111fffe1111ffff111e111fdedd
-- 205:111ff111111f1111111f1111111fff11e1111111d11f1ff1cde11111eed111f1
-- 206:1111111f11111111111df11111ee1111111ef1ef111eee111111e111111eff1f
-- 207:1111000011110000111100001111000011110000111000001110000011100000
-- 216:00000eee000001ee000000e10000001e0000001e000000010000000000000000
-- 217:eddc11fee1f1ee11ee1111e1ee1e1111ee11111fde111111ee11e11f1dee11e1
-- 218:eefd1de1e111f11f111d111d1ddd11f11fdfdef111eeed1e1e1e1fd1ee111111
-- 219:dffeee111dd11e111f111f1f11111eef11ff1111cdef11efe1fed1de11dde11d
-- 220:111efedf11111111111111f11111111fe1f11111eee111dededfefde111111ee
-- 221:edfe11f1fe1fe1fffeddeeefeedffeef1111efefeee1eefeedddeedd1eeeedee
-- 222:efffe1f1eeffeff1dfde1ff1dedeef11ededee11eeeee111eeeef111deef1110
-- 223:1110000011000000110000001000000010000000000000000000000000000000
-- 233:0ede111e00ee111e001ddee10001de1100001dee000001ee0000001f00000000
-- 234:11de111e1111111eee11111111ee1111e1ee1111eee11e1fddd1d1e11edee111
-- 235:1dde111e1111df11e1eef1ed11ee1e1e1e1111feeef1edee11ee1eddeefeedde
-- 236:edf1ee1feee1edeefede11ededededdededdddeedeeeededdedeeeedeeeeedee
-- 237:1eeeddffdfdddeefddedefe1ddddeeffddddeeeedeedeeeedeeeeeefeeeeeef1
-- 238:f11111101111110011111000ff110000f1f00000ff0000001000000000000000
-- 240:fffffffffefffffffeffffffffeffffffffffefffffffeffffffffefffffffff
-- 250:00feeeee000ffeef000000fe0000000000000000000000000000000000000000
-- 251:eeeffeeeeeeefefefeedeefe0ffeeeee00000000000000000000000000000000
-- 252:effffeeefeffeeeeeeefffffefeefff000000000000000000000000000000000
-- 253:eeefff00eeef0000ff0000000000000000000000000000000000000000000000
-- </TILES>

-- <SPRITES>
-- 066:0000000000000000000000000000000000000000000000000000000000333333
-- 067:0000000000000000000000000000000000000000000000000000000033333333
-- 068:0000000000000000000000000000000000000000000000000000000030000000
-- 076:0000000000000000000000000000000000000000000000000000000300000003
-- 077:0000000000000000000000000000000000000000000000003333000033300000
-- 080:0000000003333330333333303330033033003333000033330003333300033333
-- 081:0000000000033333000333330033333003333330033333303330330033303300
-- 082:0033333330333333000000000000000000000000000000000000000000333333
-- 083:3333333333333333000000030000000000000000000000000000000000033333
-- 084:3333333333333333333333330000000000000000000000000000000030000333
-- 085:3333333333333333333333330000000000000000000000000000000333333003
-- 086:3333333333333333333333333333000033330000333000003330000033333333
-- 087:3333330033333300333333000333300003333000333300003330000033000003
-- 088:0000000000000000000000000000000000000000000000030000000333300003
-- 089:0000000003300000333300003333000033330000333300003333330033333300
-- 090:0000000000000000000000000000000000000000000000000003300000033333
-- 091:0000000000000000000000000000000000000000000000000003333300333333
-- 092:0000000300000003000000330000003300000333000003333000033333000333
-- 093:3300000033000000330000003000000030000000300000003000000000000000
-- 096:0003303303333033033300033333000033300000333000003300000033000000
-- 097:3300330033003330300033300000033000000333000003330000003300000033
-- 098:0333333303300003033000030330000303300003333000033333333330333333
-- 099:3033333330330000303300003033000030330000303300003033333303303333
-- 100:3300033333003330330033003300330033033300330330003333300030333000
-- 101:3333300300330033003300330333033303300333333003333330333333003333
-- 102:3333333333333333330000003300000030000000300000003000000000000000
-- 103:0000033300000333000033000003300000000000000333330033003300300033
-- 104:3330000300330033003300330330003303300333330003333300033333300333
-- 105:3300000030000000300000000000033030003330300333303333330033333000
-- 106:0033333300333333003300000333000003330000333000003330000033000000
-- 107:0033000033330000333300000033000000330000003300000033333300033333
-- 108:3300333333003333330033333300333003003330030033333300333330003333
-- 109:0000000000000000000000000000000000000000000000003333333333333333
-- 110:0000000000000000000000000000000000000000000000003333333333333333
-- 111:0000000000000000000000000000000000000000000000003333333333333333
-- 119:0003333300000000000000000000000000000000000000000000000000000000
-- 120:3300000000000000000000000000000000000000000000000000000000000000
-- 124:0000000300000000000000000000000000000000000000000000000000000000
-- 125:3333333300000000000000000000000000000000000000000000000000000000
-- 126:3333333300000000000000000000000000000000000000000000000000000000
-- 127:3333333300000000000000000000000000000000000000000000000000000000
-- </SPRITES>

-- <MAP>
-- 004:000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 005:000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 006:0000000000000000001212120000000000000000778797a7b7c7d7e7f700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 007:0000000000000000000000000000000000000000788898a8b8c8d8e8f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 008:0000000000000000000000000000000000000000798999a9b9c9d9e9f900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 009:00000000000000000000000000000000000000007a8a9aaabacadaeafa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 010:00000000000000000000000000000000000000007b8b9babbbcbdbebfb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 011:00000000000000000000000000000000000000007c8c9cacbcccdcecfc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 012:13233343531323334313233343533313233343537d8d9dadbdcdddedfd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 013:13233343531323334314243444543414243444547e8e9eaebecedeeefe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 014:14243444541424344415253545553513233343537f8f9fafbfcfdfefff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 015:152535455515253545162636465636142434132333435313233313233300530000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 016:162636465616263646561626364656152535142434445414243414243444540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 017:000000000000000000000000000000162636152535455515253515253545550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 018:000000000000000000000000000000000000162636465616263616263646560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- </MAP>

-- <WAVES>
-- 000:00000000ffffffff00000000ffffffff
-- 001:0123456789abcdeffedcba9876543210
-- 002:0123456789abcdef0123456789abcdef
-- 004:0023456899abcdef1412341235713570
-- </WAVES>

-- <SFX>
-- 000:9270829092a0a2a0a2a0a2a0a280927092708280a290c2a0c2a0b290a26092419260a270a28192819280b280b28fb20fc20fc20fd20fe200e201f201330000000000
-- 001:0010001000202030404060507070708070a060b060d060f070e070d080b090b0a0a0a090c080d070d070d050e040e030e020e020e020e010e000e000220000000000
-- 002:0000000000000000005000500050005000900090009000900090009000900090009000900090009000900090f080f000f000f000f000f000f000f000300000000000
-- 003:bf00bf10bf10bf20bf30bf30bf40bf40bf40bf50bf50bf50bf60bf60bf60bf70bf70bf70bf70bf70bf70bf70bf70bf70bf70bf70bf70bf70bf70bf7000000000fd00
-- </SFX>

-- <TRACKS>
-- 000:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- </TRACKS>

-- <FLAGS>
-- 000:00000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- </FLAGS>

-- <PALETTE>
-- 000:1a1c2c29366fb13e53ef7d57ffcd75a7f07038b7642571796d380cb2610041a6f673eff7f4f4f494b0c2566c86333c57
-- </PALETTE>

