'notes 'bg 0 = ui 'bg 1 = dragged piece 'bg 2 = picker 'bg 3 = board 'rom 3 = pieces blocks visuals 'rom 4 = pieces shapes db 'state 0~1 = clear (board pattern) 'state 2 = ok (green) 'state 3 = ko (red) 'state 4 = block (block) 'state 5 = clearable (highlighted block) 'state 6 = clearing (flashing block) 'sprite 0 = logo 'sprite 0~12 = gauges 'sprites 20~101 = clear particles 'rules global gridareasize global numgridareas global gridsize global cellsize global piecedbsize global boardcellx global boardcelly global pieceoffsetx global pieceoffsety dim global pickerslot(2) dim global clearslot(2) dim global targetslot(2) global pickedslotindex global boardx global boardy global pickerposy global buttonsposy global canplay global danger global chain global score dim global scorethresholds(6) global clearfxindexoffset global fxindex gridareasize = 3 numgridareas = 3 gridsize = gridareasize * numgridareas cellsize = 2 piecedbsize = 4 boardcellx = -1 boardcelly = -1 pieceoffsetx = cellsize * 8 * 2 pieceoffsety = cellsize * 8 * 4 pickedslotindex = -1 boardx = floor((shown.w - (cellsize * gridsize * 8)) / 2) boardy = min(floor((shown.h - (cellsize * gridsize * 8)) / 2) - 16, shown.h - 260) pickerposy = boardy + (gridsize * cellsize * 8) + 8 buttonsposy = pickerposy + (piecedbsize * cellsize * 8) + 8 danger = -1 chain = 0 score = 0 clearslot(0) = 0 clearslot(1) = 0 clearslot(2) = 0 targetslot(0) = 3 targetslot(1) = 3 targetslot(2) = 4 clearfxindexoffset = 20 fxindex = 0 'thise need gridsize init first dim global boardstate(gridsize * gridsize) 'end of init sub drawscore bg 0 hudline = 3 text 1, hudline, "score" number 7, hudline, score, 3 text (shown.w/8)-7, hudline, "hi" hi = peek($E000) number (shown.w/8)-4, hudline, hi, 3 end sub sub drawhelpbutton(helpbtnx,helpbtny,helpbtnw,helpbtnh) bg 0 bg source rom(3) bg copy 0,11,helpbtnw,helpbtnh to helpbtnx,helpbtny end sub sub drawui cls 0 call drawscore end sub sub drawtitle screencentercellx = (shown.w / 2 / 8) screencentercelly = (shown.h / 2 / 8) - 4 'center cell y - 10 for program icon screencentery = screencentercelly * 8 cls 0 call drawscore bg 0 'logo bg source rom(3) bg copy 0, 4, 10, 3 to screencentercellx - (10 / 2), screencentercelly - 5 'subtitle text screencentercellx - (16 / 2), screencentercelly, "Fair series #001" 'fair sprite 0, 40, screencentery - 50, $50 sprite 0 size 3 end sub sub drawhelppage trace "help" stepx = 2 centerx = floor(shown.w / 16) steponey = 6 steptwoy = 23 steptriy = 32 stepw = floor(shown.w / 8) - (stepx * 2) steph = 4 'step1 window stepx, steponey, stepw, steph, 0 print "pick pieces and make lines, columns or squares on the board" bg source rom(5) bg 0 'pieces bg copy 12, 0, 3, 3 to centerx - 9, steponey + 7 bg copy 9, 0, 3, 3 to centerx - 6, steponey + 9 bg copy 15, 0, 3, 3 to centerx - 5, steponey + 12 'arrow bg copy 6, 9, 2, 2 to centerx - 3, steponey + 6 'board bg copy 0, 0, 9, 9 to centerx, steponey + 5 'step2 window stepx, steptwoy, stepw, steph, 0 print "cleared blocs charge magic button" 'btn bg copy 0, 9, 6, 2 to centerx - 10, steptwoy + 4 bg copy 0, 11, 6, 2 to centerx - 3, steptwoy + 4 bg copy 0, 13, 6, 2 to centerx + 4, steptwoy + 4 'step3 window stepx, steptriy, stepw, steph, 0 print "change unwanted pieces with magic button" 'crap bg copy 9, 3, 3, 3 to centerx - 6, steptriy + 4 'btn bg copy 0, 13, 6, 2 to centerx - 3, steptriy + 8 bg tint centerx - 3, steptriy + 10 to centerx + 3, steptriy + 12 pal 2 'dot bg copy 12, 3, 3, 3 to centerx + 2, steptriy + 4 'arrow sprite 1, (centerx * 8) - 8, (steptriy * 8) + 40, $29 sprite 1 size 2 sprite 1 pal 0 end sub sub drawbutton(btnindex, clearvalue, cleartarget) 'get source coordinates and palette btnsrccellw = 6 btnsrccellh = 2 if clearvalue < cleartarget then state = 0 btnsrccellx = (btnindex * btnsrccellw) btnsrccelly = 7 else state = 2 btnsrccellx = 0 btnsrccelly = 9 end if 'draw bg 0 bg source rom(3) btncellx = floor((boardx / 8) + (btnindex * btnsrccellw)) btncelly = floor(buttonsposy / 8) bg copy btnsrccellx, btnsrccelly, btnsrccellw, btnsrccellh to btncellx, btncelly bg tint btncellx, btncelly to btncellx + (btnsrccellw), btncelly + btnsrccellh pal state 'gauge sprites $92 $a2 $b2 numgaugesprites = 4 gaugespritex = (btncellx + 1) * 8 gaugespritey = (btncelly + 1) * 8 clearratio = (clearvalue / cleartarget) * numgaugesprites for g = 0 to (numgaugesprites - 1) spriteid = (btnindex * numgaugesprites) + g sprite off spriteid if clearratio < numgaugesprites then sprite spriteid pal 0 size 0 if clearratio > (g + 0.3) and clearratio < (g + 0.7) then sprite spriteid, gaugespritex + (g * 8), gaugespritey, $a2 else if clearratio >= (g + 1) then sprite spriteid, gaugespritex + (g * 8), gaugespritey, $b2 end if end if next g end sub sub drawbuttons for index = 0 to 2 call drawbutton(index, clearslot(index), targetslot(index)) next index end sub sub drawtapinvite(content$, length) scroll 1, 0, 0 bg 1 text (shown.w / 2 / 8) - (length / 2), ((shown.h - safe.b) / 8) - 2, content$ end sub sub drawmessage(content$, length) bg 0 messageline = (boardy/8) - 2 'refresh text 0, messageline, " " text (shown.w/2/8) - (length/2), messageline, content$ end sub sub drawnotif(clears, bravo) bg 1 notifline = 2 if clears = 1 then inc notifline text 0, notifline, "+" + str$(clears) else if clears > 1 then inc notifline text 0, notifline, "combo +" + str$(clears) end if if chain > 1 then text 2, notifline, "chain x" + str$(chain) end if if danger > 0 then inc notifline text 0, notifline, "danger +2" end if if bravo > 0 then inc notifline text 0, notifline, "bravo +10" end if end sub sub drawfxparticles(boardindex) 'clear fx 'pal 4/5 '$54 start 'size 2 '6 frames spritechar = $54 spritex = 0 spritey = 0 fxrandpos = 1 flipx = rnd(1) flipy = rnd(1) if flipx then spritechar = spritechar + 1 end if if flipy then spritechar = spritechar + 16 end if call indextoboardcell(boardindex, spritex, spritey) spritex = (spritex * 8) + (rnd(fxrandpos * 2) - fxrandpos) spritey = (spritey * 8) + (rnd(fxrandpos * 2) - fxrandpos) spriteindex = clearfxindexoffset + fxindex sprite spriteindex, boardx + spritex, boardy + spritey, $54 sprite spriteindex pal 5 flip flipx, flipy size 1 inc fxindex end sub sub clearfxparticles for p = clearfxindexoffset to clearfxindexoffset + fxindex sprite off p next p fxindex = 0 end sub sub toboardcell(x, y) 'converts fantasy pixel to board cell coordinates x = floor((x - boardx) / (cellsize * 8)) y = floor((y - boardy) / (cellsize * 8)) end sub sub indextoboardcell(index, boardx, boardy) 'convert index to board cell coordinates boardx = (index mod gridsize) * cellsize boardy = floor(index / gridsize) * cellsize end sub sub toboardindex(x, y, index) index = x + (gridsize * y) end sub sub clearboardstate(commit) 'remove temporary states, optionally saves ok into blocks boardindex = 0 while boardindex < gridsize * gridsize if boardstate(boardindex) = 2 then if commit > 0 then boardstate(boardindex) = 4 else boardstate(boardindex) = 0 end if else if boardstate(boardindex) < 4 then boardstate(boardindex) = 0 else if boardstate(boardindex) = 5 then boardstate(boardindex) = 4 else if boardstate(boardindex) = 6 then boardstate(boardindex) = 0 end if inc boardindex wend end sub sub clearrow(y, combo, commit) for boardindex = (y * gridsize) to (y * gridsize) + gridsize - 1 if boardstate(boardindex) < 2 then exit sub end if next boardindex for boardindex = (y * gridsize) to (y * gridsize) + gridsize - 1 if boardstate(boardindex) = 4 then if commit > 0 then boardstate(boardindex) = 6 call drawfxparticles(boardindex) else boardstate(boardindex) = 5 end if end if next boardindex inc combo if commit > 0 then clearslot(0) = clearslot(0) + combo end if end sub sub clearcolumn(x, combo, commit) for i = 0 to gridsize - 1 boardindex = (i*gridsize) + x if boardstate(boardindex) < 2 then exit sub end if next i for i = 0 to gridsize - 1 boardindex = (i*gridsize) + x if boardstate(boardindex) = 4 then if commit > 0 then boardstate(boardindex) = 6 call drawfxparticles(boardindex) else boardstate(boardindex) = 5 end if end if next i inc combo if commit > 0 then clearslot(1) = clearslot(1) + combo end if end sub sub cleararea(x, y, w, h, combo, commit) for i = 0 to h - 1 for j = 0 to w - 1 boardindex = ((x + j) + (y + i) * gridsize) if boardstate(boardindex) < 2 then exit sub end if next j next i for i = 0 to h - 1 for j = 0 to w - 1 boardindex = ((x + j) + (y + i) * gridsize) if boardstate(boardindex) = 4 then if commit > 0 then boardstate(boardindex) = 6 call drawfxparticles(boardindex) else boardstate(boardindex) = 5 end if end if next j next i inc combo if commit > 0 then clearslot(2) = clearslot(2) + combo end if end sub sub clearblocks(combo, commit) 'traverse whole board in search of things to be marked as clearable 'clear in all possible ways 'reset fx if commit > 0 then call clearfxparticles end if for row = 0 to gridsize - 1 call clearrow(row, combo, commit) next row for col = 0 to gridsize - 1 call clearcolumn(col, combo, commit) next col for areay = 0 to numgridareas - 1 for areax = 0 to numgridareas - 1 call cleararea(areax * gridareasize, areay * gridareasize, gridareasize, gridareasize, combo, commit) next areax next areay end sub sub isdropable(pieceindex, numdropables) 'check board with piece in picker isok = 0 for boardcelly = -1 to gridsize - 1 for boardcellx = -1 to gridsize - 1 call ispieceok(pieceindex, boardcellx, boardcelly, isok) if isok > 0 then inc numdropables exit sub end if next boardcellx next boardcelly end sub sub checkdropables 'trace "checkdropables" numdropables = 0 numpickables = 0 numbonususables = 0 for i = 0 to 2 if pickerslot(i) >= 0 then inc numpickables call isdropable(pickerslot(i), numdropables) end if if clearslot(i) >= targetslot(i) then inc numbonususables end if next i if numdropables = 0 and numbonususables = 0 then canplay = 0 exit sub else if numdropables < numpickables then 'danger danger = 1 recover = 0 call drawmessage("danger", 6) else if danger = 1 then recover = 1 end if danger = 0 call drawmessage(" ", 0) end if end sub sub checkbravo(bravo) for index = 0 to (gridsize * gridsize) - 1 if boardstate(index) = 4 then exit sub end if next index bravo = 1 end sub sub getcellpalette(blockx, blocky, cellpalette) 'returns either clear or dark palette to draw bg pattern if (floor(blockx / 3) + floor(blocky / 3)) mod 2 = 0 then cellpalette = 1 end if end sub sub drawboardblock(blockx, blocky, blockstate) cellpalette = blockstate if blockstate < 2 then call getcellpalette(blockx, blocky, cellpalette) end if bg 3 for celly = 0 to (cellsize - 1) for cellx = 0 to (cellsize - 1) tint (blockx * cellsize) + cellx, (blocky * cellsize) + celly pal cellpalette next cellx next celly end sub sub drawboard 'init draw scroll 3, -boardx, -boardy cls 3 bg source rom(3) bg 3 boardindex = 0 for blocky = 0 to (gridsize - 1) for blockx = 0 to (gridsize - 1) cellpalette = 0 call getcellpalette(blockx, blocky, cellpalette) bg copy (cellpalette * cellsize), 0, cellsize,cellsize to blockx * cellsize, blocky * cellsize boardstate(boardindex) = 0 inc boardindex wait vbl next blockx next blocky end sub sub drawboardstate 'draw board blocks reading current state boardindex = 0 while boardindex < gridsize * gridsize blockx = boardindex mod gridsize blocky = floor(boardindex / gridsize) call drawboardblock(blockx, blocky, boardstate(boardindex)) inc boardindex wend end sub sub readpiecedb(pieceid, x, y, result) piecedatax = (pieceid mod 12) * piecedbsize piecedatay = floor(pieceid / 12) * piecedbsize bg source rom(4) result = mcell.c(piecedatax + x, piecedatay + y) end sub difficulty_data: 'tier0: 0-11 'tier1: 12-23 'tier2: 24-33 data 6 data 0, 0,11,0,11,0,11 data 10, 0,11,0,11,0,23 data 20, 0,23,0,23,12,23 data 30, 12,23,12,23,12,33 data 40, 12,33,12,33,24,33 data 50, 12,33,24,33,24,33 data 60, 24,33,24,33,24,33 width_one_data: data 3 data 0,3,16 width_two_data: data 16 data 1,2,4,5,6,7,8,9,12,13,18,19,20,21,28,29 width_three_data: data 13 data 10,11,14,15,17,22,23,24,25,26,27,32,33 width_four_data: data 2 data 30,31 sub initscorethresholds restore difficulty_data read numtiers for i = 0 to numtiers read scorethreshold scorethresholds(i) = scorethreshold skip 6 next i end sub sub getcurrenttier(tier) for i = 0 to ubound(scorethresholds) if score >= scorethresholds(i) then tier = i end if next i end sub sub selectpiece(slotindex, tier, pieceindex) 'select tier depending on score restore difficulty_data 'skip to tier skip 2 + (tier * 7) read rangestartleft read rangeendleft read rangestartmid read rangeendmid read rangestartright read rangeendright 'set ranges dim minindex(3) dim maxindex(3) minindex(0) = rangestartleft maxindex(0) = rangeendleft minindex(1) = rangestartmid maxindex(1) = rangeendmid minindex(2) = rangestartright maxindex(2) = rangeendright 'make sure it's valid isvalid = 0 while isvalid = 0 pieceindex = minindex(slotindex) + rnd(maxindex(slotindex) - minindex(slotindex)) 'narrow pieces on the center slot if slotindex = 1 then restore width_one_data read numsingles for i = 0 to numsingles read one_width_piece if pieceindex = one_width_piece then isvalid = 1 end if next i restore width_two_data read numdoubles for i = 0 to numdoubles read two_width_piece if pieceindex = two_width_piece then isvalid = 1 end if next i else isvalid = 1 end if 'avoid duplicates hasduplicate = 0 for dupslot = 0 to 2 if pickerslot(dupslot) >= 0 and pieceindex = pickerslot(dupslot) then hasduplicate = 1 end if next dupslot if hasduplicate = 1 then isvalid = 0 end if wend end sub sub selectpieces 'set current tier tier = 0 call getcurrenttier(tier) cls 2 for slot = 0 to 2 pieceindex = 0 call selectpiece(slot, tier, pieceindex) pickerslot(slot) = pieceindex next slot end sub sub getpickerpiecex(index, piecex) 'handle half cell shift of middle piece in picker piecex = (index * (piecedbsize - 1) * cellsize) if index = 1 then piecex = piecex - (cellsize / 2) end if end sub sub drawpiece(pieceid, bgindex, piecex, piecey) 'trace "drawpiece", slot, pieceid piecedbchar = 0 for blocky = 0 to piecedbsize-1 for blockx = 0 to piecedbsize-1 call readpiecedb(pieceid, blockx, blocky, piecedbchar) cellx = piecex + (blockx * cellsize) celly = piecey + (blocky * cellsize) bg source rom(3) bg bgindex if piecedbchar = $10 then bg copy 4, 0, 2, 2 to cellx, celly end if next blockx next blocky end sub sub drawpieces(pickedslotindex) cls 2 for slot = 0 to 2 if not slot = pickedslotindex then piecex = 0 call getpickerpiecex(slot, piecex) piecey = 0 call drawpiece(pickerslot(slot), 2, piecex, piecey) end if next slot pickerw = cellsize * 8 * (piecedbsize - 1) * 3 pickerx = (shown.w - pickerw) / 2 scroll 2, -pickerx, -pickerposy end sub sub pickpiece(slot) pickedslotindex = slot call drawpieces(pickedslotindex) cls 1 call drawpiece(pickerslot(pickedslotindex), 1, 0, 0) call dragpiece end sub sub ispieceok(index, boardcellx, boardcelly, isok) isok = 1 piecedbchar = 0 boardindex = 0 for blocky = 0 to piecedbsize-1 for blockx = 0 to piecedbsize-1 call readpiecedb(index, blockx, blocky, piecedbchar) if piecedbchar = $10 then if (boardcellx + blockx) >= 0 and (boardcellx + blockx) < gridsize and (boardcelly + blocky) >= 0 and (boardcelly + blocky) < gridsize then call toboardindex(boardcellx + blockx, boardcelly + blocky, boardindex) if boardstate(boardindex) = 4 then isok = 0 exit sub end if else isok = 0 exit sub end if end if next blockx next blocky end sub sub dragpiece 'piece scroll 1, pieceoffsetx - touch.x, pieceoffsety - touch.y 'board piecedbchar = 0 boardindex = 0 boardcellx = touch.x - pieceoffsetx + (cellsize * 8 / 2) boardcelly = touch.y - pieceoffsety + (cellsize * 8 / 2) call toboardcell(boardcellx, boardcelly) call clearboardstate(0) isok = 1 call ispieceok(pickerslot(pickedslotindex), boardcellx, boardcelly, isok) for blocky = 0 to piecedbsize-1 for blockx = 0 to piecedbsize-1 call readpiecedb(pickerslot(pickedslotindex), blockx, blocky, piecedbchar) if piecedbchar = $10 then if (boardcellx + blockx) >= 0 and (boardcellx + blockx) < gridsize and (boardcelly + blocky) >= 0 and (boardcelly + blocky) < gridsize then call toboardindex(boardcellx + blockx, boardcelly + blocky, boardindex) if isok = 1 then boardstate(boardindex) = 2 else if boardstate(boardindex) < 4 then boardstate(boardindex) = 3 end if end if end if end if next blockx next blocky 'clearable if isok = 1 then combo = 0 call clearblocks(combo, 0) end if 'board call drawboardstate end sub sub droppiece(clears, bravo) isok = 1 call ispieceok(pickerslot(pickedslotindex), boardcellx, boardcelly, isok) 'trace "dropped ", pickedslotindex, isok 'board call clearboardstate(isok) call drawboardstate 'dragged piece cls 1 'handle clears if isok = 1 then call clearblocks(clears, 1) 'display clearing blocks for a short while call drawboardstate if clears > 0 then inc chain call clearboardstate(0) wait 4 call drawboardstate scoreinc = (clears * chain) + (danger * 2) call checkbravo(bravo) if bravo > 0 then scoreinc = scoreinc + 10 end if score = score + scoreinc call drawscore else chain = 0 end if pickerslot(pickedslotindex) = -1 else piecex = 0 call getpickerpiecex(pickedslotindex, piecex) piecey = 0 call drawpiece(pickerslot(pickedslotindex), 2, piecex, piecey) end if 'picker drawnewpieces = 1 for i = 0 to 2 if pickerslot(i) >= 0 then drawnewpieces = 0 exit end if next i if drawnewpieces = 1 then 'trace "drawnew", drawnewpieces call selectpieces call drawpieces(-1) end if pickedslotindex = -1 call checkdropables end sub sub usebonus(touchedslotindex) 'replaces piece in pickerslot by a dot piece if clearslot(touchedslotindex) >= targetslot(touchedslotindex) then clearslot(touchedslotindex) = 0 'clearslot(touchedslotindex) = targetslot(touchedslotindex) - 1 else exit sub end if pickerslot(touchedslotindex) = 0 call drawpieces(-1) call drawbuttons call checkdropables end sub goto title title: cls sprite off call drawui call drawtitle call initscorethresholds fairpal = 0 fairblinkduration = 8 fairblinktick = 0 inviteblinkduration = 12 inviteblinktick = 0 helpbtnw = 4 helpbtnh = 2 helpbtny = 5 helpbtnx = (shown.w/8) - helpbtnw - 2 call drawhelpbutton(helpbtnx,helpbtny,helpbtnw,helpbtnh) do 'blink fair if fairblinktick = 0 then fairblinktick = fairblinkduration inc fairpal if fairpal = 8 then fairpal = 0 end if sprite 0 pal fairpal end if dec fairblinktick 'blink invite if inviteblinktick = 0 then inviteblinktick = inviteblinkduration * 2 call drawtapinvite("tap to start", 12) else if inviteblinktick = inviteblinkduration then cls 1 end if dec inviteblinktick wait vbl if tap then if touch.y < ((helpbtny+helpbtnh)*8) then if touch.x > (helpbtnx*8) and touch.x < ((helpbtnx+helpbtnw)*8) and touch.y > (helpbtny*8) then goto help end if else goto game end if end if loop help: cls sprite off inviteblinktick= 0 call drawhelppage wait 10 do if tap then goto title end if 'blink invite if inviteblinktick = 0 then inviteblinktick = inviteblinkduration * 2 call drawtapinvite("tap to start", 12) else if inviteblinktick = inviteblinkduration then cls 1 end if dec inviteblinktick wait vbl loop game: cls sprite off for slot = 0 to 2 pickerslot(slot) = -1 clearslot(slot) = 0 next slot call drawui call drawbuttons call drawboard call selectpieces call drawpieces(-1) 'call debugloadboardstate dangerblinktick = 0 dangerblinkduration = 20 notiftickduration = 60 notiftick = 0 clearfxnumframes = 6 clearfxtickduration = 30 clearfxtick = 0 canplay = 1 do if tap then notiftick = 0 'slot index touchedslotindex = 1 if touch.x < (shown.w / 2) - (cellsize * 8 * ((piecedbsize -1) / 2)) then touchedslotindex = 0 else if touch.x > (shown.w / 2) + (cellsize * 8 * (piecedbsize / 2)) then touchedslotindex = 2 end if 'piece or button if touch.y > pickerposy and touch.y < buttonsposy then call pickpiece(touchedslotindex) else if touch.y > buttonsposy and touch.y < shown.h - safe.b then call usebonus(touchedslotindex) end if end if 'pieces if touch then if touch.drag then if pickedslotindex >= 0 then call dragpiece end if end if else if not touch and pickedslotindex >= 0 then clears = 0 bravo = 0 call droppiece(clears, bravo) if clears > 0 then call drawnotif(clears, bravo) notiftick = notiftickduration clearfxtick = clearfxtickduration end if call drawbuttons end if 'ui if notiftick > 0 then notifpal = (notiftick mod 4) bg 1 bg tint 0, 0 to 10, 5 pal notifpal dec notiftick 'slide upwards notifoffset = (notiftick / 60)*2 scroll 1, scroll.x(1), scroll.y(1) + notifoffset if notiftick = 0 then cls 1 end if end if if danger > 0 then bg 0 if dangerblinktick = 0 then dangerblinktick = dangerblinkduration * 2 bg tint 0, 5 to shown.w/8, 15 pal 3 else if dangerblinktick = dangerblinkduration then bg tint 0, 5 to shown.w/8, 15 pal 0 end if dec dangerblinktick end if 'clear fx if clearfxtick > 0 then frame = (1 - (clearfxtick / clearfxtickduration)) * clearfxnumframes pchar = 84 + (floor(frame) * 2) 'pal 4 5 switch ppal = (clearfxtick mod 2) + 4 for p = clearfxindexoffset to clearfxindexoffset + fxindex - 1 sprite p,,,pchar sprite p pal ppal next p dec clearfxtick for p = clearfxindexoffset to clearfxindexoffset + fxindex - 1 if clearfxtick = 0 then sprite off p end if next p end if 'logic if canplay = 0 then goto gameover end if wait vbl loop gameover: deadcellindex = gridsize * gridsize inviteblinkduration = 30 inviteblinktick = 0 do if deadcellindex >= 0 then 'board turns red boardcellx = 0 boardcelly = 0 call indextoboardcell(deadcellindex, boardcellx, boardcelly) if (boardstate(deadcellindex) < 2) then deadpalette = 3 else if (boardstate(deadcellindex) = 4) then deadpalette = 7 end if bg 3 bg tint boardcellx, boardcelly to boardcellx + cellsize - 1, boardcelly + cellsize - 1 pal deadpalette if deadcellindex = 1 then call drawmessage("game over", 9) end if dec deadcellindex wait 1 else 'blink invite if inviteblinktick = 0 then inviteblinktick = inviteblinkduration * 2 call drawtapinvite("tap to continue", 15) else if inviteblinktick = inviteblinkduration then cls 1 end if dec inviteblinktick end if 'touch if tap and deadcellindex < ((gridsize * gridsize) * 0.7) then hi = peek($E000) if score > hi then poke $E000, score end if score = 0 goto title end if wait vbl loop '================ sub debugloadboardstate trace "debugloadboardstate" for i = 0 to (gridsize * gridsize) if i mod 4 = 0 then boardstate(i) = 0 else boardstate(i) = 4 end if next i for i = 0 to 2 clearslot(i) = targetslot(i) pickerslot(i) = 0 next i score = 100 end sub #1:MAIN PALETTES 09242522092A2B2209111812002D2C2E 001D1C1E001E1D2B0031303300060504 #2:MAIN CHARACTERS 00000000000000000000000000000000 FFFFFFFFFFFFFFFFFF80808080808080 FFFEFEFEFEFEFEFEFE01010101010101 FFFEFEFEFEFEFE80FE8181818181817F 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 007E7E7E7E7E7E00FF818181818181FF FFFFFFFFFFFFFF80808080808080807F FEFEFEFEFEFEFE0001010101010101FF 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 007F7F7F7F7F7F7EFF80808080808081 00FEFEFEFEFEFE7EFE01010101010181 007E7E7E7E7E7E7EFF81818181818181 007F7F7F7F7F7F7EFF80808080808081 00FEFEFEFEFEFE7EFF01010101010181 007F7F7F7F7F7F7EFF80808080808081 00FEFEFEFEFEFE00FF010101010101FF 007F7F7F7F7F7F7F7F80808080808080 00FEFEFEFEFEFE00FF010101010101FF 00000000000000000000000000000107 00000000000000000000180C063FFFC6 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 7E7F7F7F7F7F7F7E8180808080808081 7EFEFEFEFCFEFE7E8101010102010181 7E7E7E7E7E7E7E7E8181818181818181 7E7F7F7F7F7F7F0081808080808080FF 7EFEFEFEFEFEFE0081010101010101FF 7E7E7E7E7E7E7E7E8181818181818181 00000000000000000000000000000000 7E7F7F7F7F7F7F0081808080808080FF 00FEFEFEFEFEFE7EFE01010101010181 00000000000000001E386040C0808080 00000000000000000C18000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 7E7F7F7F7F7F7F0081808080808080FF 7EFEFEFEFEFEFE0081010101010101FE 7E7F7F7F7F7F7F0081808080808080FF 00FFFFFFFFFFFF00FF000000000000FF 00FEFEFEFEFEFE00FF010101010101FF 7E7F7F7F7F7F7F0081808080808080FF 00FEFEFEFEFEFE00FF010101010101FF 007F7F7F7F7F7F00FF808080808080FF 7EFEFEFEFEFEFE0081010101010101FE 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 0000000000060E3C000000000000020C 00000000000020700000000000000000 00000E1F19C9CF670000000E08404423 00000000000080400000000000000000 00000000020202070000000000020202 00000000000000000000000000000000 00000200000001020000000000000002 000000004040F0400000000000A040A0 00000000000000000000000000000000 0000002020F820200000000000200000 00000000000000000000000000000000 00000010381000000000000010000000 00000000000000000000000000000000 0000081C080000000000000000000000 00000000000000000000000000000000 00000400000000000000000000000000 70303E1E181C0C0C1010080608040404 786C663F393030003028200619101000 66363000000000002212100000000000 00000000000000000000000000000000 0F7F0F0702020200073F070202020000 80F880000000000000F0000000000000 078F070200000200020F020200000000 40861038100000000080001000000000 02070200000000000002000000000000 000100081C0800000000000000000000 00040E04000000000000040000000000 00000000000400000000000000000000 00000008000000000000000000000000 00000000000000000000000000000000 00000000100000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00181840004000000000000000000000 000C2C00400000000000000000000000 00104606000000000000000000000000 00280006060000000000000000000000 00100400060600000000000000000000 00040002000C0C000000000000000000 00000400021818000000000000000000 00000002003430000000000000000000 00000000626800000000000000000000 00000060600410000000000000000000 00006060002008000000000000000000 00303000400010000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 070F1F3F3F3F3F3F0000000000000000 E0F0F8FCFEFEFEFE0000000002020202 FFFFFFFFFFFFFFFF0000FFFFFF0000FF FFFFFFFF81FFFFFF0000007EFF7E0000 FFFFCBBBBBBBC8FF0000347E6666773B FFFF8DBA98BA8AFF0000727F677777BA FFFF8FB78FB7B7FF000070FCF8FCECA4 FFFFFFF7E3C180E3000000081C3E7F7F FFFFFFFFFFFFFFFE0000000000000001 FFDBF17BCF8D1FBF00240E843072F060 FFFFFFEFC78301C700000010387CFEFE 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 3F3F3F3F3F3F3F3F0000000000000000 FEFEFEFEFEFEFEFE0202020202020202 FFFF0F0F0FFFFFFF0000FFFFFF0000FF FFFFF7F7F7F7F7FF00081C1C1C1C1C08 FFF8F0F3F3FFFFFE00070F0F0E060001 FF1F0FCFCFCF0F1F00E0F0F83838F8F0 FFFFFFFFFFFFFFFF0000000000000000 E3E3E3FFFFFFFFFF1C1C1C1C000000FF FDFAF5EBE7FFFFFF02050B161C1800FF 7FFFFFFFFFFFFFFFC0800000000000FF C7C7C7FFFFFFFFFF38383838000000FF 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 3F3F3F3F3F1F0F070000000020100807 FEFEFEFEFEFCF8F002020202060C18F0 FFFF000000FFFFFF0000FFFFFF0000FF FFFFC1DDDDDDC1FF003E7F6363637F3E FEFEFFFEFEFFFFFF01010101010100FF 7F7FFF7F7FFFFFFFE0C080C0C0C000FF FFFFFFFFFFFFFFFF00000000000000FF #3:BACKGROUND 00001212010002000101020101040204 00000000000000000000000000000000 00000000000000001100120011011201 11041204000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000200021002200230024002500 26002700280000000000000000000000 00000000000000003000310032003300 34003500360037003800000000000000 00000000000000000000000040004100 42004300440045004600470048000000 00000000000000000000000000000000 9000930094009500960091009000A300 94009500960091009000B30094009500 96009100B0009200920092009200B100 B0009200920092009200B100B0009200 920092009200B1009000970098009900 9A009100000000000000000000000000 000000000000000000000000B000A700 A800A900AA00B1000000000000000000 00000000000000000000000000000000 9000A400A50091000000000000000000 00000000000000000000000000000000 00000000B000B400B500B10000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 000000000000000000000000 #4:BACKGROUND 00003232000000000000000000070000 00000000000700000000000000000000 00000000000010000000000000000000 10000000000010001000000000001000 10000000000010000000000000000000 10000000100010000000000000001000 10000000000000000000100000000000 00001000100000000000100010000000 00001000000000000000100000070000 00000000100000000000100000000000 00000000100000000000100010000000 00001000100000000000100010000000 10001000000000070007000700000000 00000000000010001000000700070000 00070000000010000000000000001000 10000000000010001000000700001000 00000007000700001000000700070000 10000000000010000000000000000000 00000007000000000000000700070007 00000000000012070000000000001207 00000007000012070000000000001207 00000000000012070007000000001207 00000000000012070000000000001207 00070000000012070007000700071207 00000000000712070000000000071207 00070007000000001000000000071000 00000000000010000000000000000000 00000000000010000000000700000000 00000000000010000000000000070000 10000000000010001000000000001000 10000000100000001000000010001000 10000007000700070000100010000000 00001000100000001000100010000000 10001000100000000000100000000007 10001000100000000000000010000000 00001000000000000000100000000000 00000000100000001000100010000000 10000000100000070000000700000000 10000007000010000000000700000000 00000000000010000000000000001000 00000007000700000000000000000007 00000000000000000000000000001000 10000007000010001000000700070000 00000007000700000007000700070007 00000000000712070000000000001207 00000000000012070000000000001207 00000007000712070000000700071207 00000000000012070000000000001207 00070007000012070000000700071207 00070000000012070007000000071207 00070007100000000007000700000007 10000007000700070000000000000000 00000000000000071000000700001000 00000007100000000000000000000000 00001000100000001000000710001000 10000007000000000000000000000000 00000007000000070000100000000000 00001000000700000000100000000000 10000000100000070007100000070007 00000000100000070000100000000000 00000000100000070000100000000000 10000000100000000000000000000000 00000000000000000000000700000000 10000007100000000000000710000000 10000000000010000000000000000000 10000007000010000000000700000000 10000007000010000000000710000000 10000007100010001000000700070000 00000007000700000000000000000007 00070007000712070007000700071207 00070007000712070000000000001207 00070007000712070000000000071207 00070007000710001000000000071207 00070007000712070007000000001207 00070000000012070000000000001207 00000000000000000000000700000000 00000007000000000007000700070007 00000007000700000000000700000000 00000007000000000000000700070000 00000007000000070007000700070007 00000000000000000007000700070007 00070007000700070000000000000007 00000000000000000000000000070007 00000000000000000007000000000007 00000000000000000000000000070007 00070000000000000000000000000007 00000000000000000007000700070007 00070007000700070007000700000000 00070007000700070000000000000000 00000007000000070007000000000000 00000007000000000007000700070000 00000007000000000007000700000000 00000000000000000000000700070007 00000000000700070007000700070007 00000000000712070000000000001207 00070000000712070007000700071207 00070007000712070007000000071207 00070007000712070007000700071207 00070007000712070007000700071207 00070000000712070007000700071207 00000000000000070007000700000000 00070007000700070007000000070007 00000000000700070007000700070007 00070007000700070000000700070007 00070007000000070007000700070007 00070007000700070007000700070007 00070007000700070000000700070000 00000007000700070007000000000007 00070007000000070007000700070007 00070007000700000007000000070007 00070007000700070007000700070007 00070007000700070007000700070007 00070007000700070007000700000007 00070007000700070007000700000000 00070007000700070007000700070007 00070007000700070007000000000007 00070007000700000007000700070007 00000007000700070007000700070007 00070007000700070007000700070007 00000000000712070007000700071207 00070007000712070007000700071207 00070007000712070007000700001207 00070007000012070007000700071207 00070007000712070007000000071207 00070007000712070007000700071207 00070007000000000007000000070007 00070007000700000000000000000000 00000000000700070007000700000007 00000007000700000000000000000007 00070007000700070000000000070000 00070000000700000007000700070007 00000000000000070000000000070007 00070000000000000000000000000000 00000000000000000000000000070007 00000000000000000000000000000000 00000000000000000000000000000000 00000000000700000000000700070007 00070007000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00070007000700070000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000007000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 000000000000000000000000 #5:BACKGROUND 00001414030003000300030103040304 03000300030000000305030500000304 00000004030400000000000003000300 03040301030403040300030403000305 03050000000003040000030400040304 00000000030003040300030103040304 03000304030400000000000003040304 00000004000400040004000003010301 03010300030403040301030403010304 00040304000000000000000000000000 00000000030103010301030003040304 03010301030100000304000000000304 00000000000000000000000003040304 03040304030003000304030403040304 00040304000000000000000000000000 00000000030403040304030103010304 03040304030400000000000000000000 00000000000000000000000003000300 03000304030403040300030003000000 00000000000000000000000000000000 00000000030403040300030403040304 03000304030000000000000000000000 00000000000000000000000090009300 940095009600910029002A0000000000 00000000000000000000000000000000 00000000B0009200920092009200B100 39003A00000000000000000000000000 00000000000000000000000090009300 94009500960091000000000000000000 00000000000000000000000000000000 00000000B000B200A20092009200B100 00000000000000000000000000000000 00000000000000000000000090029702 980299029A0291020000000000000000 00000000000000000000000000000000 00000000B002A702A802A902AA02B102 00000000000000000000000000000000 00000000000000000000000000020000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000002000200000000 00000000000000000000000000000000 00000000000000000000000000020002 00020000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000