0,]']>S}Wup8d%qy)6o;]AsVl3>??????? PQ0S@U`XpZp\p^p_pPPPPPPPPPPPPPPPPPPPPP 0000p0p0p000000000000000000000000 `@@ @ @@@ @ @@@@@@@@@@@@@@@@@@@@@@@ 037<??000000000000000000000000 $ bbbbbbbbbbBv+*v+   v+*v+t)v+*v+v+pP0*v+v+t)pPbbHbbbbbBJ Jj JJ * JjJ Jj JJ * JjJ Jj JJ *jjjjJJJ JJfF&v)*6)c c cc c cccc c cc c cccc c cc c cccc c cc c cccT)T(`@  [(``{/`@ bBi*`@ v)*6)0y+`@`@,z+     v,`@ t,v,v,`@ t,`t,`y,`{,`@ ~,t,{,`@ y,`y,{,`       v, y,nnnn       c ccccccc c ccc  c ccccccc c ccc v,ggg gv,gg ggv,   v,   v,    c ccccccc c ccc  c ccccccc c ccc bbbb6'6' 8'8'   9'9'  ccc cc c  c cc c c  c c cCc c c ccccc cc c  c cc c c  c c cCc c c c ccccv, kK+='g?'g?'g['g='g?'g?'g['g]'gM'gQ0fF&  0$4$@@R@R@@@@XXXXX\Xxx@x#x x@xxhT4dĴtT4dĴt? " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " """"""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""" " " " " " " " " " " " " " " " """"""""""""""""""""""""""""""""""""""""""""""""" " " " " " " " " " " " " " " " """"""""""""""""""""""""""""""""""""""""""""""""" " " " " " " " " " " " " " " " """"""""""""""""""""""""""""""""""""""""""""""""" " " " " " " " " " " " " " " " """""""""""""""""""""""""""""""""nn""""""""""""fefe""""nV\nV\ " " " " " " " " " " " "nWunWu " " " "vgvg""""""""""""nn""""_U""""""""""""UU""""""""UUnn""""""""""""UUfe""""fe""""_UnV\oV\ " " " " " " " " " RU% "UnWu " " " "oWu " " " "UUU_vgvg""""""""""UU"n""""n""""UU"""""""""""RU""""""""""""nn""""""""""""^Ufe""""""""fe""""_UnV\oV\ " " " " " " " " "UUU" "^UnWu " " " " " " " "oWu " " " "UUUvgvg"""""""""UUU"n""""""""n""""UUUUUU""""""""UUU^fUU%"""""""^U_UUn""""""""VU"""""""fe^oV\ " " " " " " " "^%" " " " " " " "oWu^fffvg""""""""UUU""""""""n^U"""""""""U"""""""nnn""""""""""""fefe""""fenV\nV\oV\ " " " " " " " " " " " "nWunWu " " " "oWuvgvgvg""""""""UUU""""nn""""n^UUUU"""""""U%^UUUU""""""""""_UU^UUUUnn"""""""RUUUUU""fe""""fe""""_UUnV\oV\ " " " " " " RUU " " " "nWu " " " "oWu " " " "_UUvgvg"""""""RUU""""n""""n""""U"""""""U%""""""""""""_UU^U_Unn"""""""RUUUUUUU""fe""""""""fe_UUUUUUUnV\oV\ " " " " " " "U%UUUUU " "nWu " " " " " " " "oWuP^^U^U_Uvgvg""""""""UUU""""n""""""""nUUUUU^U"""""""""""RUU%UU"UU""""""""""""""""""""""""""""""""_UU_UUU"""""""""""RUU""UU%"""""""""""""""""""""""""""""""UUUU " " " " " " " " " " "PUU"%" "UU%" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "PUU_UUU""""""""""RURUU%"RU""""""""""""""""""""""""""""""""UUUUU ^UUUU^UUUU^UU^U^^^UUUUUUUU^UUUUU^U-- title: Multiple Maze -- author: verysoftwares -- desc: room-shifting puzzle-platformer. -- script: lua t=0; at=0; start_t=0 x=7*8+1 y=0*8+2 dx=0 dy=0 onladder=0 sx=110-20-20-50; sy=62-12-12-26 debug=false if debug then sx=sx+40; sy=sy+24 end if debug then sx=170-50; sy=98-26 end if debug then sx=120; sy=60; x=x+8*8 end if debug then sx=100; sy=0; y=y+8 end --if debug then sx=140; sy=85; x=x+6*8 end gemcombo=0 gemcombo_t=0 gems=0 gem_get={} deaths=0 save_sx=sx; save_sy=sy save_x=x; save_y=y enemies={} music(2) function update() if t==0 and not debug then alert({'Welcome to the maze!','Arrow keys or D-pad to move.'},function() for i=0,3 do if btnp(i) then return true end end end) end if t==0 then -- spawn enemies for mx=0,159 do for my=0,71 do if mget(mx,my)==40 then mset(mx,my,0) table.insert(enemies,{type='bat',x=mx*8+2,y=my*8+2,dx=-0.5,stx=mx*8+2,sty=my*8+2}) end end end end if TIC==update and (not banner_msg or (banner_t2 and banner_t2>0)) then if (btn(0) or btn(4)) and onground and (not jump) and onladder==0 and mget(sx+x//8,sy+y//8)~=33 then if dy>0 then dy=0 end; dy=dy-2.8; jump=0; onladder=0 end if onladder==1 and btn(0) then if dy>0 then dy=0; climb_t=t end; dy=dy-0.2 end if onladder==1 and btn(1) then if dy<0 then dy=0; climb_t=t end; dy=dy+0.2 end --if btn(1) then y=y+1 end if btn(2) then if dx>0 then dx=0; plr_t=t end; if btnp(2) then plr_t=t end dx=dx-0.2; lastflip=1 end if btn(3) then if dx<0 then dx=0; plr_t=t end; if btnp(3) then plr_t=t end dx=dx+0.2; lastflip=0 end if math.abs(dx)<0.02 then plr_t=nil; dx=0 end if btnp(5) and (gem_msg or debug) and not (banner_msg and banner_msg[1]=='Ouch!') then TIC=mapscr end end detect_gamepad() --spr(1+t%60//30*2,x,y,14,3,0,0,2,2) --print("HELLO WORLD!",84,84) --print(jump) --print(onladder,0,8) cls(0) --print(control) rect(240/2-80,136/2-48,80*2,48*2,14) rect(240/2-80-8-160,136/2-48,80*2,48*2,14) rect(240/2-80+8+160,136/2-48,80*2,48*2,14) rect(240/2-80,136/2-48-8-96,80*2,48*2,14) rect(240/2-80,136/2-48+8+96,80*2,48*2,14) drawmap(0,0,0,0,0) drawmap(0,-1,0,0,0) drawmap(0,1,0,0,0) drawmap(-1,0,0,0,0) drawmap(1,0,0,0,0) update_goo() rect(0,136/2-48-8,240,8,0) rect(240/2-80-8,0,8,136,0) rect(0,136/2+48,240,8,0) rect(240/2+80,0,8,136,0) --map(sx,sy-12,20,12,240/2-80,136/2-48-8-96,1) --spr(48,x+240/2-80,y+136/2-48,1) clip(240/2-80,136/2-48,160,96) --rect(x+240/2-80,y+136/2-48,6,6,0) --local sp if not plr_t then sp=304 end if onladder==1 then if dy<=0 and btn(0) then if (at-climb_t)%18<=17 then sp=355 end if (at-climb_t)%18<=17-6 then sp=356 end if (at-climb_t)%18<=17-6-6 then sp=354 end elseif dy>=0 and btn(1) then if (at-climb_t)%18<=17 then sp=354 end if (at-climb_t)%18<=17-6 then sp=356 end if (at-climb_t)%18<=17-6-6 then sp=355 end end elseif jump then sp=352+jump//4; if jump>=16 then sp=304 end elseif squash then if squash>3 then sp=352 else sp=353 end; squash=squash-1 if squash==0 then squash=nil end elseif plr_t then if (at-plr_t)%24<=23 then sp=288+32+3 end if (at-plr_t)%24<=23-6 then sp=288+32+2 end if (at-plr_t)%24<=23-6-6 then sp=288+32+1 end if (at-plr_t)%24<=23-6-6-6 then sp=288+32+0 end end flip=0 if dx<0 then flip=1 end if dx==0 then flip=lastflip end if not end_msg then spr(sp,x+240/2-80-1,y+136/2-48-2,1,1,flip) --spr(273,x+240/2-80-1,y+136/2-48-2,1) clip(240/2-80,96+8+136/2-48,160,96) --rect(x+240/2-80,(y-96)+96+8+136/2-48,6,6,0) spr(sp,x+240/2-80-1,(y-96)+96+8+136/2-48-2,1,1,flip) clip(240/2-80,-96-8+136/2-48,160,96) --rect(x+240/2-80,(y+96)-96-8+136/2-48,6,6,0) spr(sp,x+240/2-80-1,(y+96)-96-8+136/2-48-2,1,1,flip) clip(240/2-80-160-8,136/2-48,160,96) --rect((x-160-16)+160+8+240/2-80,y+136/2-48,6,6,0) spr(sp,(x-160-16)+160+8+240/2-80-1,y+136/2-48-2,1,1,flip) clip(240/2-80+160+8,136/2-48,160,96) --rect((x+160+16)-160-8+240/2-80,y+136/2-48,6,6,0) spr(sp,(x+160+16)-160-8+240/2-80-1,y+136/2-48-2,1,1,flip) end clip() if TIC==idle then goto skipcoll end if onladder<1 then dy=dy+0.2 end for i,e in ipairs(enemies) do e.x=e.x+e.dx for mx=e.x//8-1,e.x//8+1 do for my=e.y//8-1,e.y//8+1 do local m=mget(mx,my) if fget(m,2) and AABB(e.x,e.y,4,4,mx*8,my*8,8,8) then if mx*8e.x then e.x=mx*8-4 end e.dx=-e.dx end end end end y=y+dy for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do if (mget(sx+mx,sy+my)==39 and AABB(x,y,6,6,mx*8,my*8+4,8,4)) or (mget(sx+mx,sy+my)==41 and AABB(x,y,6,6,mx*8,my*8,8,4)) then die() goto skipcoll end end end for i,e in ipairs(enemies) do if e.type=='bat' then if AABB(sx*8+x,sy*8+y,6,6,e.x,e.y,4,4) then die() goto skipcoll end end end if onground then onground=onground-1; if onground==0 then onground=nil end end for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do if mget(sx+mx,sy+my)==70 and AABB(x,y,6,6,mx*8,my*8+4,8,4) then if btnp(1) then toggle(sx+mx,sy+my) end if not switch_msg then alert({'Press down to flip switches.'},function() return btn(1) end); switch_msg=true end elseif mget(sx+mx,sy+my)==71 and AABB(x,y,6,6,mx*8,my*8+4,8,4) then if btnp(1) then toggle(sx+mx,sy+my) end if not switch_msg then alert({'Press down to flip switches.'},function() return btn(1) end); switch_msg=true end end end end for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do local m=mget(sx+mx,sy+my) if dy>0 and y<=(my+1)*8 and onladder<1 and fget(m,1) and mget(sx+mx,sy+my+1)==33 and AABB(x,y,6,6,mx*8+1,(my+1)*8,6,8) then onground=5; if dy>0.2 then squash=5; splatter(dy); if not (sy==60) then save_sx=sx; save_sy=sy; save_x=x; save_y=(my+1)*8-6; gem_get={} end end; if dx~=0 then gootrail() end; y=(my+1)*8-6; dy=0; jump=false; onladder=0; if btn(1) then onladder=1; climb_t=t; y=y+0.2; goto skipy end end local m=mget(sx+mx,sy+my) if fget(m,2) and AABB(x,y,6,6,mx*8,my*8,8,8) then --print('yooo'); y=y-dy; goto skipy if my*8y then local function hiddenobjects() for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do local m=mget(sx+mx,sy+my) if AABB(x,y,6,6,mx*8,my*8,8,8) and (m==73 or m==75 or m==102) then return true end end end end onground=5; if dy>0.2 then squash=5; splatter(dy); if not (sy==60) and not hiddenobjects() then save_sx=sx; save_sy=sy; save_x=x; save_y=my*8-6; gem_get={} end else if dx~=0 then gootrail() end end; y=my*8-6; dy=0; jump=false; onladder=0; if (btn(0)) then goto skipy else goto skipy2 end end end end end for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do if mget(sx+mx,sy+my)==34 and AABB(x,y,6,6,mx*8+1,my*8+1,6,6) then mset(sx+mx,sy+my,35); table.insert(gem_get,{sx+mx,sy+my}); gems=gems+1; collect=15; sfx(1,12*3+9+gemcombo,16,2); gemcombo=gemcombo+1; gemcombo_t=30; if not gemroom(sx,sy) and mx<20 and mx>=0 and my<12 and my>=0 then sfx(4,'F-6',50,2) end end end end ::skipy:: for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do if mget(sx+mx,sy+my)==33 and (btn(0) or btn(1)) and AABB(x,y,6,6,mx*8+1,my*8,6,8) then if onladder==0 then dy=0; climb_t=t end; x=mx*8+1; onladder=1; jump=false; goto skipx end end end ::skipy2:: x=x+dx for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do local m=mget(sx+mx,sy+my) if fget(m,2) and AABB(x,y,6,6,mx*8,my*8,8,8) then --print('yooo'); x=x-dx; goto skipx if mx*8x then x=mx*8-6; dx=0; goto skipx end end end end for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do if mget(sx+mx,sy+my)==34 and AABB(x,y,6,6,mx*8+1,my*8+1,6,6) then mset(sx+mx,sy+my,35); table.insert(gem_get,{sx+mx,sy+my}); gems=gems+1; collect=15; sfx(1,12*3+9+gemcombo,16,2); gemcombo=gemcombo+1; gemcombo_t=30; if not gemroom(sx,sy) and mx<20 and mx>=0 and my<12 and my>=0 then sfx(4,'F-6',50,2) end end end end ::skipx:: if y>=96 then TIC=cooltrans; tr={dx=0, dy=4, t=t} end--sy=sy+12; y=y-96 end if y<-6 then TIC=cooltrans; tr={dx=0, dy=-4,t=t} end--sy=sy-12; y=y+96 end if x>=160 then TIC=cooltrans; tr={dx=4, dy=0, t=t} end--sy=sy+12; y=y-96 end if x<=-6 then TIC=cooltrans; tr={dx=-4,dy=0, t=t} end--sy=sy-12; y=y+96 end if onladder==1 and ((mget(sx+x//8,sy+y//8)~=33 and mget(sx+x//8,sy+y//8+1)~=33) or (mget(sx+x//8,sy+y//8)~=33 and mget(sx+x//8,sy+y//8+1)==33 and not AABB(x,y,6,6,x//8*8+1,y//8*8+8,6,8))) then onladder=0.5 end dx=dx*0.84 dy=dy*0.95 if onladder==1 then dy=dy*0.88 end ::skipcoll:: --if math.abs(dx)>0 then splatter(0.5) end if sx==20 and sy==12 and not gemroom(sx,sy) and not gem_msg then local keymsg='Press X to activate.' if control=='gamepad' then keymsg='Press % to activate.' end alert({'Brought together, the gems','resonate with ancient power...',keymsg},function() return btnp(5) end,function() TIC=mapscr; local keymsg='Use Z and arrows to shift rooms'; if control=='gamepad' then keymsg='Use $ and D-pad to shift rooms' end alert({'This is a map of the maze.',keymsg,'with no gems in them.'},anykey) end) TIC=idle gem_msg=true end --if sy>=62-12-12+2*12+2*12+12 and not end_msg and not debug then if not end_msg then for mx=x//8-1,x//8+1 do for my=y//8-1,y//8+1 do local m=mget(sx+mx,sy+my) if (m==104 or m==105) and AABB(mx*8,my*8,8,8,x,y,6,6) then if mget(sx+mx,sy+my+1)==98 then sfx(13,'A-6',40,2) TIC=warp plr_t=at else if not tele_msg then alert({'A teleporter.','It\'s offline.'},function() return btnp(4) or btnp(5) end) tele_msg=true end end end end end end if TIC==update then local tm=time()-start_t if math.floor(tm/(1000*60*60))==0 then local tw=print(string.format('%.2d:%.2d',math.floor(tm/(1000*60))%60,math.floor(tm/1000)%60),0,-6,12,true) print(string.format('%.2d:%.2d',math.floor(tm/(1000*60))%60,math.floor(tm/1000)%60),240/2-tw/2,8*2-2,11,true) else local tw=print(string.format('%.2d:%.2d:%.2d',math.floor(tm/(1000*60*60)),math.floor(tm/(1000*60))%60,math.floor(tm/1000)%60),0,-6,12,true) print(string.format('%.2d:%.2d:%.2d',math.floor(tm/(1000*60*60)),math.floor(tm/(1000*60))%60,math.floor(tm/1000)%60),240/2-tw/2,8*2-2,11,true) end local tw=print(string.format('Gems: %.3d',gems),0,-6,12,true) print(string.format('Gems: %.3d',gems),240/2-tw/2,8*3+8*12-2,11,true) end for mx=0,20-1 do for my=0,12-1 do local m= mget(sx+mx,sy+my) if m==70 or m==71 or m==104 or m==105 then spr(m,240/2-80+mx*8,136/2-48+my*8,1) end end end if t%3==0 then maintain_toggle() end draw_banner() if collect then if collect>0 then collect=collect-1; poke(0x3FF8,7-collect//5) else collect=nil; poke(0x3FF8,0) end end if not gemroom(sx,sy) and not emptyroom(sx,sy) then poke(0x3FF8,5) end if gemcombo_t>0 then gemcombo_t=gemcombo_t-1 if gemcombo_t==0 then gemcombo=0 end end --[[for fx=0,240-1 do for fy=0,136-1 do if pix(fx,fy)==0 then local c=4+math.cos(fx*(1+math.sin(t*0.01))+t*0.2)+math.sin(fx*0.2+fy*0.2+t*0.1)*4 if math.floor(c)==3 then c=2 end pix(fx,fy,c) end end end]] --local anim --if at%24<=11+5+7 then anim=1 end --if at%24<=11+5 then anim=0 end --if at%24<=11 then anim=2 end --spr(288+anim,8*6,8*6,1) if jump and jump<20 then jump=jump+1 end poke(ADDR+3*11+0,0x73) poke(ADDR+3*11+1,0xEF) poke(ADDR+3*11+2,0xF7) poke(ADDR+3+3+3+0,0xEF) poke(ADDR+3+3+3+1,0x7D) poke(ADDR+3+3+3+2,0x57) palette=0 if TIC==update then at=at+1 end t=t+1 end function warp() drawmap(0,0,0,0,0) drawmap(0,-1,0,0,0) drawmap(0,1,0,0,0) drawmap(-1,0,0,0,0) drawmap(1,0,0,0,0) update_goo() pal(5,12); pal(6,12); pal(15,12); pal(14,12) if (at-plr_t)%30<=29 then sp=355 end if (at-plr_t)%30<=29-6 then sp=356 end if (at-plr_t)%30<=29-6-6 then sp=354 end if (at-plr_t)%30<=29-6-6-6 then sp=353 end if (at-plr_t)%30<=29-6-6-6-6 then sp=352 end flip=0 if dx<0 then flip=1 end if dx==0 then flip=lastflip end spr(sp,12*8+240/2-80,7*8+136/2-48,1,1,flip) pal() for mx=0,20-1 do for my=0,12-1 do local m= mget(sx+mx,sy+my) if m==70 or m==71 or m==104 or m==105 then spr(m,240/2-80+mx*8,136/2-48+my*8,1) end end end if at-plr_t==29 and not end_msg then local tm=time()-start_t local tmsg if math.floor(tm/(1000*60*60))==0 then tmsg=string.format('Time taken: %.2d:%.2d.%.3d',math.floor(tm/(1000*60))%60,math.floor(tm/1000)%60,math.floor(tm%1000)) else tmsg=string.format('Time taken: %.2d:%.2d:%.2d.%.3d',math.floor(tm/(1000*60*60)),math.floor(tm/(1000*60))%60,math.floor(tm/1000)%60,math.floor(tm%1000)) end alert({'You\'ve escaped the maze!','Thanks for playing!',string.format('Gems collected: %.3d',gems),string.format('Deaths: %d',deaths),tmsg},function() end) TIC=idle end_msg=true end at=at+1 t=t+1 end function idle() update() end --for mx=50,209 do for my=26,97 do -- mset(mx-50,my-26,mget(mx,my)) -- mset(mx,my,0) --end end --sync(4,0,true) function credits() map(0,102,30,17,0,0) local tw tw=print('Game by: verysoftwares',0,-6,11) print('Game by: verysoftwares',10*8+5*8-tw/2,8*5-2,11) tw=print('Speedrunners:',5*8,-6,11) print('Speedrunners:',10*8-8-tw/2,8*5-2+8+8,11) tw=print('* Jayrude',7*8-1,-6,11) print('* Jayrude',10*8-8-tw/2,8*6-2+8+8,11) tw=print('* Ten',7*8-1,-6,11) print('* Ten',10*8-8-tw/2,8*6-2+8+8+8,11) tw=print('Key testers:',5*8+6,-6,11) print('Key testers:',10*8+10*8-tw/2,8*8-2+8+8-8-8-8,11) for i,v in ipairs({'Mark Brown','shiona','Stefan','Ten * Typhin','Yuho'}) do tw=print('* '..v,7*8-1,-6,11) print('* '..v,10*8+10*8-tw/2,8*10-2+8-8-8-8-8+8+(i-1)*8,11) end tw=print('Code helpers:',0,-6,11) print('Code helpers:',10*8-8-tw/2,8*7-2+8+8+8+8,11) tw=print('* BORB',0,-6,11) print('* BORB',10*8-8-tw/2,8*8-2+8+8+8+8,11) poke(ADDR+3*11+0,0x73) poke(ADDR+3*11+1,0xEF) poke(ADDR+3*11+2,0xF7) palette=0 if anykey() then TIC=titlescr end end cycle={i=1,update,options,credits} function titlescr() if dist==0 then if btnp(0) or btnp(2) then cycle.i=cycle.i-1 end if btnp(1) or btnp(3) then cycle.i=cycle.i+1 end if cycle.i<1 then cycle.i=#cycle end if cycle.i>#cycle then cycle.i=1 end end if btnp(4) and not banner_msg and dist==0 then TIC_pend=cycle[cycle.i] if TIC_pend==update then TIC_tpend=true start_t=time() end if TIC_pend==nil then alert({'Not yet implemented!'},function() if banner_t<180-1 then return anykey() end end) TIC_pend=titlescr end end if btnp(4) then dist=0 end cls(3) dist= dist or 3*99 if dist>0 then dist=dist-3 end for mx=0,0+29-1 do for my=119,119+7-1 do local m=mget(mx,my) if (m>0 and m<32) or fget(m,2) then --rect(-dist+4+(mx-30)*8+1,4+(my-1)*8+1,8,8,0) for ix=0,7 do for iy=0,7 do if sprpix(m,ix,iy)~=1 then pix(-dist+4+(mx-0)*8+ix+1,4+(my-119)*8+iy+1,0) end end end end end end for mx=0,0+17-1 do for my=119+10,119+10+5-1 do local m=mget(mx,my) if (m>0 and m<32) or fget(m,2) then rect(240/2-60+dist-4+(mx-0)*8+1,8*7+(my-119-10)*8+1,8,8,0) end end end map(0,119,29,7,-dist+4,4,1) map(0,119+10,17,5,240/2-60+dist-4,8*7,1) if dist==0 then print('Version 2c',-dist+240/2+20,8*12+2,15) local tw for i,v in ipairs({'New game','Options','Credits'}) do local msg=v if i==cycle.i then if t%21<7 then msg='[ '..msg..' ]' elseif t%21<14 then msg='[[ '..msg..' ]]' else msg='[ '..msg..' ]' end end tw=print(msg,240/2-80+(i-1)*80,-6,12,false,1,true) print(msg,240/2-80+(i-1)*80-tw/2,136-8*2-8*2+(i-1)*8+2,12,false,1,true) end end draw_banner() poke(ADDR+3+3+3+0,0xEF) poke(ADDR+3+3+3+1,0x7D) poke(ADDR+3+3+3+2,0x57) palette=0 t=t+1 end TIC=update TIC=titlescr function gameover() poke(0x3FF8,2) poke(ADDR+3+3+3+0,0xEF) poke(ADDR+3+3+3+1,0x7D) poke(ADDR+3+3+3+2,0x57) palette=0 if keyp(19) or btnp(7) then sx=save_sx; sy=save_sy x=save_x; y=save_y dx=0; dy=0 goo={} for i,e in ipairs(enemies) do e.x=e.stx; e.y=e.sty; e.dx=-0.5 end TIC=update poke(0x3FF8,0) for i,v in ipairs(gem_get) do mset(v[1],v[2],34) end gems=gems-#gem_get gem_get={} if not gemroom(sx,sy) and not emptyroom(sx,sy) then poke(0x3FF8,5) end end clip(240/2-80,136/2-48,160,96) cls(14) drawmap(0,0,0,0,0) drawmap(-1,0,0,0,0) drawmap(1,0,0,0,0) drawmap(0,-1,0,0,0) drawmap(0,1,0,0,0) update_goo() clip() draw_banner() t=t+1 end function die() TIC=gameover splatter(6) local keymsg='Press S to reset.' if control=='gamepad' then keymsg='Press & to reset.' end if #gem_get>0 then if #gem_get==1 then alert({'Ouch!','1 gem lost.',keymsg},function() return keyp(19) or btnp(7) end) else alert({'Ouch!',string.format('%d gems lost.',#gem_get),keymsg},function() return keyp(19) or btnp(7) end) end else alert({'Ouch!',keymsg},function() return keyp(19) or btnp(7) end) end sfx(11,'B-5',20,2) deaths=deaths+1 end function cooltrans() cls(0) poke(0x3FF8,0) dist=dist or 0 rect(240/2-80-tr.dx*(t-tr.t),136/2-48-tr.dy*(t-tr.t),80*2,48*2,14) local xdist=0 local ydist=0 if tr.dx~=0 then ydist=dist end if tr.dy~=0 then xdist=dist end rect(240/2-80-8-160-tr.dx*(t-tr.t)-xdist,136/2-48-tr.dy*(t-tr.t),80*2,48*2,14) rect(240/2-80+8+160-tr.dx*(t-tr.t)+xdist,136/2-48-tr.dy*(t-tr.t),80*2,48*2,14) rect(240/2-80-tr.dx*(t-tr.t),136/2-48-8-96-tr.dy*(t-tr.t)-ydist,80*2,48*2,14) rect(240/2-80-tr.dx*(t-tr.t),136/2-48+8+96-tr.dy*(t-tr.t)+ydist,80*2,48*2,14) if tr.dx<0 then rect(240/2-80-8*2-160*2-tr.dx*(t-tr.t),136/2-48-tr.dy*(t-tr.t),80*2,48*2,14) end if tr.dx>0 then rect(240/2-80+8*2+160*2-tr.dx*(t-tr.t),136/2-48-tr.dy*(t-tr.t),80*2,48*2,14) end if tr.dy<0 then rect(240/2-80-tr.dx*(t-tr.t),136/2-48-8*2-96*2-tr.dy*(t-tr.t),80*2,48*2,14) end if tr.dy>0 then rect(240/2-80-tr.dx*(t-tr.t),136/2-48+8*2+96*2-tr.dy*(t-tr.t),80*2,48*2,14) end drawmap(0,0,tr.dx,tr.dy,t-tr.t) drawmap(0,-1,tr.dx,tr.dy,t-tr.t,0,-ydist) drawmap(0,1,tr.dx,tr.dy,t-tr.t,0,ydist) drawmap(-1,0,tr.dx,tr.dy,t-tr.t,-xdist,0) drawmap(1,0,tr.dx,tr.dy,t-tr.t,xdist,0) if tr.dx<0 then drawmap(-2,0,tr.dx,tr.dy,t-tr.t); drawmap(-1,-1,tr.dx,tr.dy,t-tr.t,0,-(240/4-(16*2)/2-4)+dist); drawmap(-1,1,tr.dx,tr.dy,t-tr.t,0,(240/4-(16*2)/2-4)-dist) end if tr.dx>0 then drawmap(2,0,tr.dx,tr.dy,t-tr.t); drawmap(1,-1,tr.dx,tr.dy,t-tr.t,0,-(240/4-(16*2)/2-4)+dist); drawmap(1,1,tr.dx,tr.dy,t-tr.t,0,(240/4-(16*2)/2-4)-dist) end if tr.dy<0 then drawmap(0,-2,tr.dx,tr.dy,t-tr.t); drawmap(-1,-1,tr.dx,tr.dy,t-tr.t,-(136/4-16/2)+dist); drawmap(1,-1,tr.dx,tr.dy,t-tr.t,(136/4-16/2)-dist) end if tr.dy>0 then drawmap(0,2,tr.dx,tr.dy,t-tr.t); drawmap(-1,1,tr.dx,tr.dy,t-tr.t,-(136/4-16/2)+dist); drawmap(1,1,tr.dx,tr.dy,t-tr.t,(136/4-16/2)-dist) end rect(0-tr.dx*(t-tr.t),136/2-48-8-tr.dy*(t-tr.t),240,8,0) rect(240/2-80-8-tr.dx*(t-tr.t),0-tr.dy*(t-tr.t),8,136,0) rect(0-tr.dx*(t-tr.t),136/2+48-tr.dy*(t-tr.t),240,8,0) rect(240/2+80-tr.dx*(t-tr.t),0-tr.dy*(t-tr.t),8,136,0) rect(0-tr.dx*(t-tr.t)+tr.dx*(160+8)*0.5,136/2-48-8-tr.dy*(t-tr.t)+tr.dy*(96+8)*0.5,240,8,0) rect(240/2-80-8-tr.dx*(t-tr.t)+tr.dx*(160+8)*0.5,0-tr.dy*(t-tr.t)+tr.dy*(96+8)*0.5,8,136,0) rect(0-tr.dx*(t-tr.t)+tr.dx*(160+8)*0.5,136/2+48-tr.dy*(t-tr.t)+tr.dy*(96+8)*0.5,240,8,0) rect(240/2+80-tr.dx*(t-tr.t)+tr.dx*(160+8)*0.5,0-tr.dy*(t-tr.t)+tr.dy*(96+8)*0.5,8,136,0) --map(sx,sy-12,20,12,240/2-80,136/2-48-8-96,1) --spr(48,x+240/2-80,y+136/2-48,1) clip(240/2-80-tr.dx*(t-tr.t),136/2-48-tr.dy*(t-tr.t),160,96) spr(sp,x+240/2-80-tr.dx*(t-tr.t)-1,y+136/2-48-tr.dy*(t-tr.t)-2,1,1,flip) clip(240/2-80-tr.dx*(t-tr.t),96+8+136/2-48-tr.dy*(t-tr.t),160,96) spr(sp,x+240/2-80-tr.dx*(t-tr.t)-1,(y-96)+96+8+136/2-48-tr.dy*(t-tr.t)-2,1,1,flip) clip(240/2-80-tr.dx*(t-tr.t),-96-8+136/2-48-tr.dy*(t-tr.t),160,96) spr(sp,x+240/2-80-tr.dx*(t-tr.t)-1,(y+96)-96-8+136/2-48-tr.dy*(t-tr.t)-2,1,1,flip) clip(240/2-80-160-8-tr.dx*(t-tr.t),136/2-48-tr.dy*(t-tr.t),160,96) spr(sp,(x-160-16)+160+8+240/2-80-tr.dx*(t-tr.t)-1,y+136/2-48-tr.dy*(t-tr.t)-2,1,1,flip) clip(240/2-80+160+8-tr.dx*(t-tr.t),136/2-48-tr.dy*(t-tr.t),160,96) spr(sp,(x+160+16)-160-8+240/2-80-tr.dx*(t-tr.t)-1,y+136/2-48-tr.dy*(t-tr.t)-2,1,1,flip) clip() dist=dist+1 local nx,ny=sx+tr.dx*0.25*20,sy+tr.dy*0.25*12 if (nx==60 and ny==36 and peek(0x13FFC)~=4) or (nx==60 and ny==36-12 and peek(0x13FFC)~=3) or (nx==120 and ny==72 and peek(0x13FFC)~=5) or (nx==120 and ny==72-12 and peek(0x13FFC)~=4) then for ch=0,3 do if ch~=2 then local vol if tr.dy~=0 then vol=(1-(t-tr.t)/(136/4-16/2))*15 end if tr.dx~=0 then vol=(1-(t-tr.t)/(240/4-(16*2)/2-4))*15 end setvol(ch,math.floor(vol)) end end end if (tr.dy~=0 and t-tr.t>=136/4-16/2) or (tr.dx~=0 and t-tr.t>=240/4-(16*2)/2-4) then TIC=update if nx==60 and ny==36 and peek(0x13FFC)~=4 then music(4) end if nx==60 and ny==36-12 and peek(0x13FFC)~=3 then music(3) end if nx==120 and ny==72 and peek(0x13FFC)~=5 then music(5) end if nx==120 and ny==72-12 and peek(0x13FFC)~=4 then music(4) end x=x-tr.dx*160*0.25 y=y-tr.dy*96*0.25 sx=sx+tr.dx*0.25*20 if sx>=240 then sx=10 end if sx<0 then sx=240-20-10 end sy=sy+tr.dy*0.25*12 if sy>=136 then sy=2 end if sy<=0 then sy=136-12-2 end dist=nil --goo={} end t=t+1 end ADDR = 0x3FC0 palette = 0 function addLight(scnline) --for j=0, 2 do --poke(ADDR+3+j, palette+5+math.sin(scnline+t*0.1)*5) --end if TIC~=titlescr then poke(ADDR+3+3+3, palette+5+math.sin(scnline+t*0.1)*5) poke(ADDR+3+3+3+1, palette+5+math.sin(scnline+t*0.1)*5) poke(ADDR+3+3+3+2, palette+40+5+math.sin(scnline+t*0.1)*5) else poke(ADDR+3+3+3, palette+60+math.sin(scnline+t*0.1)*5) poke(ADDR+3+3+3+1, palette+15+math.sin(scnline+t*0.1)*5) poke(ADDR+3+3+3+2, palette+15+math.sin(scnline+t*0.1)*5) end palette = palette + 5 end function addLight2(scnline) poke(ADDR+3*11, palette2+30) poke(ADDR+3*11+1, palette2+30) poke(ADDR+3*11+2, palette2+5) palette2 = palette2+12 end function SCN(scnline) if (scnline) % 8 == 0 and TIC~=gameover and TIC~=update then addLight(scnline) end if TIC_pend and scnline==135 then TIC=TIC_pend; TIC_pend=nil end if TIC_tpend then t=0; dist=nil; music(3); TIC_tpend=nil end if scnline%8==0 then palette2=50 end addLight2(scnline) end mapstate=nil function mapscr() cx=cx or sx; cy=cy or sy if not banner_msg or (banner_t2 and banner_t2>0) then if btnp(0) then cy=cy-12 end if btnp(1) then cy=cy+12 end if btnp(2) then cx=cx-20 end if btnp(3) then cx=cx+20 end if cysy+12 then cy=sy+12 end if cxsx+20 then cx=sx+20 end end if btnp(5) and mapstate~='copy' and (not banner_msg or #banner_msg==2) then TIC_pend=update; cx=nil; cy=nil; mapdata=nil; mapstate=nil; header_msg=nil; header_t=nil end detect_gamepad() cls(1+1+1) poke(ADDR+3+0,0x5D) poke(ADDR+3+1,0x27) poke(ADDR+3+2,0x5D) poke(ADDR+3+3+3+0,0xEF) poke(ADDR+3+3+3+1,0x7D) poke(ADDR+3+3+3+2,0x57) palette=0 old_left=left old_right=right mox,moy,left,_,right=mouse() if not leftclick then leftclick=left and not old_left else leftclick=false end if not rightclick then rightclick=right and not old_right else rightclick=false end if rightclick then mapstate=nil mapdata=nil end --if leftclick then -- trace('wee',2) --end local tw=3*20 local th=3*12 for tx=0,3-1 do for ty=0,3-1 do --rect(240/2-90+tx*60,136/2-60+ty*40,60,40,14) local c=12 if mapstate=='1click' and sx-20+tx*20==mapdata.x and sy-12+ty*12==mapdata.y then c=4+t*0.4%4 end if (sx-20+tx*20==cx and sy-12+ty*12==cy) then--or AABB(mox,moy,1,1,240/2-tw-tw/2+tx*tw-2+tx*2,136/2-th-th/2+ty*th-2+ty*2,tw+2,th+2) then if c==12 then c=t*0.4%16 end if btnp(4) and (not banner_msg or (banner_t2 and banner_t2>0)) then if not mapstate then if not gemroom(sx-20+tx*20,sy-12+ty*12) then if not emptyroom(sx-20+tx*20,sy-12+ty*12) then local adj=adjacent(sx-20+tx*20,sy-12+ty*12) if #adj==1 then if not AABB(adj[1].x*8,adj[1].y*8,20*8,12*8,sx*8+x,sy*8+y,6,6) and not AABB((sx+20)*8,(sy)*8,8,12*8,sx*8+x,sy*8+y,6,6) and not AABB((sx-1)*8,(sy)*8,8,12*8,sx*8+x,sy*8+y,6,6) and not AABB((sx)*8,(sy-1)*8,20*8,8,sx*8+x,sy*8+y,6,6) and not AABB((sx)*8,(sy+12)*8,20*8,8,sx*8+x,sy*8+y,6,6) then local function enemy_in_path() for i,e in ipairs(enemies) do if e.x//8>=adj[1].x and e.x//8=adj[1].y and e.y//81 then mapstate='1click' mapdata={x=sx-20+tx*20,y=sy-12+ty*12,adjacent=adj} complain('where to?') elseif #adj==0 then complain('room is surrounded') end else complain('room is empty') end else complain('gems in room') end elseif mapstate=='1click' then local findadj=function() for i,v in ipairs(mapdata.adjacent) do if v.x==sx-20+tx*20 and v.y==sy-12+ty*12 then return true end end end if findadj() then if not AABB((sx-20+tx*20)*8,(sy-12+ty*12)*8,20*8,12*8,sx*8+x,sy*8+y,6,6) and not AABB((sx+20)*8,(sy)*8,8,12*8,sx*8+x,sy*8+y,6,6) and not AABB((sx-1)*8,(sy)*8,8,12*8,sx*8+x,sy*8+y,6,6) and not AABB((sx)*8,(sy-1)*8,20*8,8,sx*8+x,sy*8+y,6,6) and not AABB((sx)*8,(sy+12)*8,20*8,8,sx*8+x,sy*8+y,6,6) then local function enemy_in_path() for i,e in ipairs(enemies) do if e.x//8>=sx-20+tx*20 and e.x//8=sy-12+ty*12 and e.y//8=32 then spr(m+16, 240/2-tw-tw/2+tx*tw-2+tx*2+1+mx*3, 136/2-th-th/2+ty*th-2+ty*2+1+my*3, 1 ) end if sx-20+tx*20+mx==sx+x//8 and sy-12+ty*12+my==sy+y//8 and (t*0.06)%2>=1 then spr(58, 240/2-tw-tw/2+tx*tw-2+tx*2+1+mx*3, 136/2-th-th/2+ty*th-2+ty*2+1+my*3, 1 ) end for i,e in ipairs(enemies) do if e.type=='bat' then if sx-20+tx*20+mx==e.x//8 and sy-12+ty*12+my==e.y//8 then local flash=0 if (t*0.06)%2>=1 then flash=1 end spr(56+flash*16, 240/2-tw-tw/2+tx*tw-2+tx*2+1+mx*3, 136/2-th-th/2+ty*th-2+ty*2+1+my*3, 1 ) end end end end end --if sx-20+tx*20==sx and sy-12+ty*12==sy then spr(257,240/2-tw-tw/2+tx*tw-2+tx*2+tw/2-4,136/2-th-th/2+ty*th-2+ty*2+th/2-4,1) end --[[ old and ugly method textri(240/2-tw-tw/2+tx*tw-2+tx*2+1, 136/2-th-th/2+ty*th-2+ty*2+1, 240/2-tw-tw/2+tx*tw+tw-2+tx*2+1,136/2-th-th/2+ty*th-2+ty*2+1, 240/2-tw-tw/2+tx*tw-2+tx*2+1, 136/2-th-th/2+ty*th+th-2+ty*2+1, (sx-20+tx*20)*8, (sy-12+ty*12)*8, (sx-20+tx*20+20)*8,(sy-12+ty*12)*8, (sx-20+tx*20)*8, (sy-12+ty*12+12)*8, true,1) textri(240/2-tw-tw/2+tx*tw+tw-2+tx*2+1,136/2-th-th/2+ty*th-2+ty*2+1, 240/2-tw-tw/2+tx*tw+tw-2+tx*2+1,136/2-th-th/2+ty*th+th-2+ty*2+1, 240/2-tw-tw/2+tx*tw-2+tx*2+1, 136/2-th-th/2+ty*th+th-2+ty*2+1, (sx-20+tx*20+20)*8,(sy-12+ty*12)*8, (sx-20+tx*20+20)*8,(sy-12+ty*12+12)*8, (sx-20+tx*20)*8, (sy-12+ty*12+12)*8, true,1) ]] end end local nx,ny if mapdata and (mapdata.dx or mapdata.dy) then nx,ny=mapdata.x+mapdata.dx,mapdata.y+mapdata.dy end if mapstate=='copy' then sfx(5,'E-3',2,2) if sx==mapdata.x and sy==mapdata.y and ((nx==60 and ny==36 and peek(0x13FFC)~=4) or (nx==60 and ny==36-12 and peek(0x13FFC)~=3) or (nx==120 and ny==72 and peek(0x13FFC)~=5) or (nx==120 and ny==72-12 and peek(0x13FFC)~=4)) then for ch=0,3 do if ch~=2 then local vol if mapdata.dy~=0 then vol=(1-(mapdata.prog)/math.abs(mapdata.dy))*15 end if mapdata.dx~=0 then vol=(1-(mapdata.prog)/math.abs(mapdata.dx))*15 end setvol(ch,math.floor(vol)) end end end end if mapstate=='copy' and t%3==0 then if mapdata.dx~=0 then if mapdata.dx>0 then for mx=20-1,0,-1 do for my=0,12-1 do mset(mapdata.x+mapdata.prog+mx+1,mapdata.y+my,mget(mapdata.x+mapdata.prog+mx,mapdata.y+my)) mset(mapdata.x+mapdata.prog+mx,mapdata.y+my,0) end end if sx+x//8>=mapdata.x+mapdata.prog and sx+x//8=mapdata.y and sy+y//8=mapdata.x+mapdata.prog and e.x//8=mapdata.y and e.y//8=mapdata.x+mapdata.prog and e.stx//8=mapdata.y and e.sty//8=mapdata.x-mapdata.prog and sx+x//8=mapdata.y and sy+y//8=mapdata.x-mapdata.prog and e.x//8=mapdata.y and e.y//8=mapdata.x-mapdata.prog and e.stx//8=mapdata.y and e.sty//80 then for mx=0,20-1 do for my=12-1,0,-1 do mset(mapdata.x+mx,mapdata.y+mapdata.prog+my+1,mget(mapdata.x+mx,mapdata.y+mapdata.prog+my)) mset(mapdata.x+mx,mapdata.y+mapdata.prog+my,0) end end if sx+x//8>=mapdata.x and sx+x//8=mapdata.y+mapdata.prog and sy+y//8=mapdata.x and e.x//8=mapdata.y+mapdata.prog and e.y//8=mapdata.x and e.stx//8=mapdata.y+mapdata.prog and e.sty//8=mapdata.x and sx+x//8=mapdata.y-mapdata.prog and sy+y//8=mapdata.x and e.x//8=mapdata.y-mapdata.prog and e.y//8=mapdata.x and e.stx//8=mapdata.y-mapdata.prog and e.sty//8=mapdata.x*8 and g.x=mapdata.y*8 and g.y=mapdata.x and g[1]=mapdata.y and g[2]0 then collect=collect-1; poke(0x3FF8,7-collect//5) else collect=nil; poke(0x3FF8,0) end else poke(0x3FF8,0) end t=t+1 end function ymod(pos) if pos<0 then return pos+132 end if pos>=132 then return pos-132 end return pos end function drawmap(dx,dy,trdx,trdy,trt,xdist,ydist) xdist=xdist or 0 ydist=ydist or 0 clip(240/2-80+dx*(160+8)-trdx*trt+xdist,136/2-48+dy*(96+8)-trdy*trt+ydist,20*8,12*8) cls(14) -- drop shadows for tiles for mx=0,20-1 do for my=0,12-1 do local m=mget(sx+dx*20+mx,sy+dy*12+my) if fget(m,2) and m~=103 then rect(240/2-80+dx*(160+8)+mx*8+1-trdx*trt+xdist,136/2-48+dy*(96+8)+my*8+1-trdy*trt+ydist,8,8,15) end end end for mx=0,20-1 do for my=0,12-1 do local m=mget(sx+dx*20+mx,sy+dy*12+my) if m==104 or m==105 and mget(sx+dx*20+mx,sy+dy*12+my+1)==98 then mset(sx+dx*20+mx,sy+dy*12+my,104+(t*0.4)%2) end end end map(sx+dx*20,sy+dy*12,20,12,240/2-80+dx*(160+8)-trdx*trt+xdist,136/2-48+dy*(96+8)-trdy*trt+ydist,1) for mx=0,20-1 do for my=0,12-1 do for i,e in ipairs(enemies) do if sx+dx*20+mx==e.x//8 and sy+dy*12+my==e.y//8 then if e.type=='bat' then local anim if at%24<=11+5+7 then anim=1 end if at%24<=11+5 then anim=0 end if at%24<=11 then anim=2 end local flip=0 if e.dx>0 then flip=1 end spr(288+anim,240/2-80+e.x-(sx)*8+dx*8-2-trdx*trt+xdist,136/2-48+e.y-(sy)*8+dy*8-2-trdy*trt+ydist,1,1,flip) end end end end end draw_goo(dx,dy,trdx,trdy,trt,xdist,ydist) clip() end function emptyroom(ssx,ssy) for mx=0,20-1 do for my=0,12-1 do if mget(ssx+mx,ssy+my)>0 then return false end end end return true end function gemroom(ssx,ssy) for mx=0,20-1 do for my=0,12-1 do if mget(ssx+mx,ssy+my)==34 then return true end end end return false end function adjacent(rx,ry) local out={} for i,v in ipairs({{-20,0},{20,0},{0,-12},{0,12}}) do if rx+v[1]>=sx-20 and rx+v[1]<=sx+20 and ry+v[2]>=sy-12 and ry+v[2]<=sy+12 and emptyroom(rx+v[1],ry+v[2]) then table.insert(out,{x=rx+v[1],y=ry+v[2]}) end end return out end checked_on={} checked_off={} function toggle(mx,my) if mget(mx,my)==70 then mset(mx,my,71) sfx(12,'D-5',6,2) if mget(mx,my-1)>=44 and mget(mx,my-1)<=69 and fget(mget(mx,my-1),6) then table.insert(checked_on,{mx,my-1}) end if mget(mx,my+1)>=44 and mget(mx,my+1)<=69 and fget(mget(mx,my+1),4) then table.insert(checked_on,{mx,my+1}) end if mget(mx-1,my)>=44 and mget(mx-1,my)<=69 and fget(mget(mx-1,my),7) then table.insert(checked_on,{mx-1,my}) end if mget(mx+1,my)>=44 and mget(mx+1,my)<=69 and fget(mget(mx+1,my),5) then table.insert(checked_on,{mx+1,my}) end elseif mget(mx,my)==71 then mset(mx,my,70) sfx(12,'D-5',6,2) if mget(mx,my-1)>=76 and mget(mx,my-1)<=101 and fget(mget(mx,my-1),6) then table.insert(checked_off,{mx,my-1}) end if mget(mx,my+1)>=76 and mget(mx,my+1)<=101 and fget(mget(mx,my+1),4) then table.insert(checked_off,{mx,my+1}) end if mget(mx-1,my)>=76 and mget(mx-1,my)<=101 and fget(mget(mx-1,my),7) then table.insert(checked_off,{mx-1,my}) end if mget(mx+1,my)>=76 and mget(mx+1,my)<=101 and fget(mget(mx+1,my),5) then table.insert(checked_off,{mx+1,my}) end end end function maintain_toggle() local len=#checked_on local new=false local rem={} for i=1,len do local v=checked_on[i] if not v[3] then local m=mget(v[1],v[2]) mset(v[1],v[2],m+32) local mx,my=v[1],v[2] if fget(m,4) and fget(mget(mx,my-1),6) and mget(mx,my-1)>=44 and mget(mx,my-1)<=69 and not findv2(checked_on,{mx,my-1,true}) then table.insert(checked_on,{mx,my-1,prev=v}) end if fget(m,6) and fget(mget(mx,my+1),4) and mget(mx,my+1)>=44 and mget(mx,my+1)<=69 and not findv2(checked_on,{mx,my+1,true}) then table.insert(checked_on,{mx,my+1,prev=v}) end if fget(m,5) and fget(mget(mx-1,my),7) and mget(mx-1,my)>=44 and mget(mx-1,my)<=69 and not findv2(checked_on,{mx-1,my,true}) then table.insert(checked_on,{mx-1,my,prev=v}) end if fget(m,7) and fget(mget(mx+1,my),5) and mget(mx+1,my)>=44 and mget(mx+1,my)<=69 and not findv2(checked_on,{mx+1,my,true}) then table.insert(checked_on,{mx+1,my,prev=v}) end if fget(m,4) and mget(mx,my-1)==39 or mget(mx,my-1)==41 then mset(mx,my-1,mget(mx,my-1)+(73-39)) end if fget(m,6) and mget(mx,my+1)==39 or mget(mx,my+1)==41 then mset(mx,my+1,mget(mx,my+1)+(73-39)) end if fget(m,5) and mget(mx-1,my)==39 or mget(mx-1,my)==41 then mset(mx-1,my,mget(mx-1,my)+(73-39)) end if fget(m,7) and mget(mx+1,my)==39 or mget(mx+1,my)==41 then mset(mx+1,my,mget(mx+1,my)+(73-39)) end if fget(m,4) and mget(mx,my-1)==102 then mset(mx,my-1,103); if AABB(x,y,6,6,(mx-sx)*8,(my-1-sy)*8,8,8) then die() end end if fget(m,6) and mget(mx,my+1)==102 then mset(mx,my+1,103); if AABB(x,y,6,6,(mx-sx)*8,(my+1-sy)*8,8,8) then die() end end if fget(m,5) and mget(mx-1,my)==102 then mset(mx-1,my,103); if AABB(x,y,6,6,(mx-1-sx)*8,(my-sy)*8,8,8) then die() end end if fget(m,7) and mget(mx+1,my)==102 then mset(mx+1,my,103); if AABB(x,y,6,6,(mx+1-sx)*8,(my-sy)*8,8,8) then die() end end v[3]=true if v.prev and v.prev.prev and find(checked_on,v.prev.prev) then table.insert(rem,find(checked_on,v.prev.prev)) end new=true end end for i=#rem,1,-1 do table.remove(checked_on,rem[i]) end for i=#checked_on,1,-1 do local v=checked_on[i] if v[3] and (v.prev and not find(checked_on,v.prev.prev)) or not v.prev then table.remove(checked_on,i) end end if not new then checked_on={} end len=#checked_off new=false rem={} for i=1,len do local v=checked_off[i] if not v[3] then local m=mget(v[1],v[2]) mset(v[1],v[2],m-32) local mx,my=v[1],v[2] if fget(m,4) and fget(mget(mx,my-1),6) and mget(mx,my-1)>=76 and mget(mx,my-1)<=101 and not findv2(checked_off,{mx,my-1,true}) then table.insert(checked_off,{mx,my-1,prev=v}) end if fget(m,6) and fget(mget(mx,my+1),4) and mget(mx,my+1)>=76 and mget(mx,my+1)<=101 and not findv2(checked_off,{mx,my+1,true}) then table.insert(checked_off,{mx,my+1,prev=v}) end if fget(m,5) and fget(mget(mx-1,my),7) and mget(mx-1,my)>=76 and mget(mx-1,my)<=101 and not findv2(checked_off,{mx-1,my,true}) then table.insert(checked_off,{mx-1,my,prev=v}) end if fget(m,7) and fget(mget(mx+1,my),5) and mget(mx+1,my)>=76 and mget(mx+1,my)<=101 and not findv2(checked_off,{mx+1,my,true}) then table.insert(checked_off,{mx+1,my,prev=v}) end if fget(m,4) and mget(mx,my-1)==73 or mget(mx,my-1)==75 then mset(mx,my-1,mget(mx,my-1)-(73-39)) end if fget(m,6) and mget(mx,my+1)==73 or mget(mx,my+1)==75 then mset(mx,my+1,mget(mx,my+1)-(73-39)) end if fget(m,5) and mget(mx-1,my)==73 or mget(mx-1,my)==75 then mset(mx-1,my,mget(mx-1,my)-(73-39)) end if fget(m,7) and mget(mx+1,my)==73 or mget(mx+1,my)==75 then mset(mx+1,my,mget(mx+1,my)-(73-39)) end if fget(m,4) and mget(mx,my-1)==103 then mset(mx,my-1,102) end if fget(m,6) and mget(mx,my+1)==103 then mset(mx,my+1,102) end if fget(m,5) and mget(mx-1,my)==103 then mset(mx-1,my,102) end if fget(m,7) and mget(mx+1,my)==103 then mset(mx+1,my,102) end v[3]=true if v.prev and v.prev.prev and find(checked_off,v.prev.prev) then table.insert(rem,find(checked_off,v.prev.prev)) end new=true end end for i=#rem,1,-1 do table.remove(checked_off,rem[i]) end for i=#checked_off,1,-1 do local v=checked_off[i] if v[3] and (v.prev and not find(checked_off,v.prev.prev)) or not v.prev then table.remove(checked_off,i) end end if not new then checked_off={} end end function reconnect() local out_on={} local out_off={} for i,v in ipairs(checked_on) do if v[1]>=mapdata.x and v[1]<=mapdata.x+19 and v[2]>=mapdata.y and v[2]<=mapdata.y+11 then v[1]=v[1]+mapdata.dx v[2]=v[2]+mapdata.dy end end for i,v in ipairs(checked_off) do if v[1]>=mapdata.x and v[1]<=mapdata.x+19 and v[2]>=mapdata.y and v[2]<=mapdata.y+11 then v[1]=v[1]+mapdata.dx v[2]=v[2]+mapdata.dy end end for mx=mapdata.tgtx-1,mapdata.tgtx+20-1+1 do for my=mapdata.tgty+0-1,mapdata.tgty+12-1+1 do local mxx=mx-mapdata.tgtx local myy=my-mapdata.tgty if (not (((mxx==11 or mxx==12) and myy==-1) or ((mxx==19 or mxx==-1) and (myy<=0 or myy>=11)) or mxx==9 or (myy==11-4) or (myy==12 and mxx<=0))) and (mxx<=0 or mxx>=19 or myy<=0 or myy>=11) then local m=mget(mx,my) if ((myy==0 or myy==12) and fget(m,4)) or ((myy==-1 or myy==11) and fget(m,6)) or ((mxx==0 or mxx==20) and fget(m,5)) or ((mxx==-1 or mxx==19) and fget(m,7)) then if m>=44 and m<=69 and not findv2(checked_off,{mx,my}) then out_off={{mx,my}} local connected=false for i,v in ipairs(out_off) do local m=mget(v[1],v[2]) local nx,ny=v[1],v[2] if #out_off>30 then connected=false; break end if fget(m,4) and mget(nx,ny-1)==71 then connected=true; break end if fget(m,6) and mget(nx,ny+1)==71 then connected=true; break end if fget(m,5) and mget(nx-1,ny)==71 then connected=true; break end if fget(m,7) and mget(nx+1,ny)==71 then connected=true; break end if fget(m,4) and fget(mget(nx,ny-1),6) and not findv2(checked_on,{nx,ny-1}) and not findv2(out_off,{nx,ny-1}) then table.insert(out_off,{nx,ny-1}) end if fget(m,6) and fget(mget(nx,ny+1),4) and not findv2(checked_on,{nx,ny+1}) and not findv2(out_off,{nx,ny+1}) then table.insert(out_off,{nx,ny+1}) end if fget(m,5) and fget(mget(nx-1,ny),7) and not findv2(checked_on,{nx-1,ny}) and not findv2(out_off,{nx-1,ny}) then table.insert(out_off,{nx-1,ny}) end if fget(m,7) and fget(mget(nx+1,ny),5) and not findv2(checked_on,{nx+1,ny}) and not findv2(out_off,{nx+1,ny}) then table.insert(out_off,{nx+1,ny}) end end if connected then table.insert(checked_on,out_off[1]) end elseif m>=76 and m<=101 and not findv2(checked_off,{mx,my}) then out_on={{mx,my}} local connected=false for i,v in ipairs(out_on) do local m=mget(v[1],v[2]) local nx,ny=v[1],v[2] if fget(m,4) and mget(nx,ny-1)==71 then connected=true; break end if fget(m,6) and mget(nx,ny+1)==71 then connected=true; break end if fget(m,5) and mget(nx-1,ny)==71 then connected=true; break end if fget(m,7) and mget(nx+1,ny)==71 then connected=true; break end if fget(m,4) and fget(mget(nx,ny-1),6) and not findv2(checked_off,{nx,ny-1}) and not findv2(out_on,{nx,ny-1}) then table.insert(out_on,{nx,ny-1}) end if fget(m,6) and fget(mget(nx,ny+1),4) and not findv2(checked_off,{nx,ny+1}) and not findv2(out_on,{nx,ny+1}) then table.insert(out_on,{nx,ny+1}) end if fget(m,5) and fget(mget(nx-1,ny),7) and not findv2(checked_off,{nx-1,ny}) and not findv2(out_on,{nx-1,ny}) then table.insert(out_on,{nx-1,ny}) end if fget(m,7) and fget(mget(nx+1,ny),5) and not findv2(checked_off,{nx+1,ny}) and not findv2(out_on,{nx+1,ny}) then table.insert(out_on,{nx+1,ny}) end end if not connected then table.insert(checked_off,out_on[1]) end end end end end end for mx=mapdata.x-1,mapdata.x+20-1+1 do for my=mapdata.y+0-1,mapdata.y+12-1+1 do local mxx=mx-mapdata.x local myy=my-mapdata.y if (not (((mxx==11 or mxx==12) and myy==-1) or ((mxx==19 or mxx==-1) and (myy<=0 or myy>=11)) or mxx==9 or (myy==11-4) or (myy==12 and mxx<=0))) and (mxx<=0 or mxx>=19 or myy<=0 or myy>=11) then local m=mget(mx,my) if ((myy==0 or myy==12) and fget(m,4)) or ((myy==-1 or myy==11) and fget(m,6)) or ((mxx==0 or mxx==20) and fget(m,5)) or ((mxx==-1 or mxx==19) and fget(m,7)) then if m>=44 and m<=69 and not findv2(checked_on,{mx,my}) then out_off={{mx,my}} local connected=false for i,v in ipairs(out_off) do local m=mget(v[1],v[2]) local nx,ny=v[1],v[2] if #out_off>30 then connected=false; break end if fget(m,4) and mget(nx,ny-1)==71 then connected=true; break end if fget(m,6) and mget(nx,ny+1)==71 then connected=true; break end if fget(m,5) and mget(nx-1,ny)==71 then connected=true; break end if fget(m,7) and mget(nx+1,ny)==71 then connected=true; break end if fget(m,4) and fget(mget(nx,ny-1),6) and not findv2(checked_on,{nx,ny-1}) and not findv2(out_off,{nx,ny-1}) then table.insert(out_off,{nx,ny-1}) end if fget(m,6) and fget(mget(nx,ny+1),4) and not findv2(checked_on,{nx,ny+1}) and not findv2(out_off,{nx,ny+1}) then table.insert(out_off,{nx,ny+1}) end if fget(m,5) and fget(mget(nx-1,ny),7) and not findv2(checked_on,{nx-1,ny}) and not findv2(out_off,{nx-1,ny}) then table.insert(out_off,{nx-1,ny}) end if fget(m,7) and fget(mget(nx+1,ny),5) and not findv2(checked_on,{nx+1,ny}) and not findv2(out_off,{nx+1,ny}) then table.insert(out_off,{nx+1,ny}) end end if connected then table.insert(checked_on,out_off[1]) end elseif m>=76 and m<=101 and not findv2(checked_off,{mx,my}) then out_on={{mx,my}} local connected=false for i,v in ipairs(out_on) do local m=mget(v[1],v[2]) local nx,ny=v[1],v[2] if fget(m,4) and mget(nx,ny-1)==71 then connected=true; break end if fget(m,6) and mget(nx,ny+1)==71 then connected=true; break end if fget(m,5) and mget(nx-1,ny)==71 then connected=true; break end if fget(m,7) and mget(nx+1,ny)==71 then connected=true; break end if fget(m,4) and fget(mget(nx,ny-1),6) and not findv2(checked_off,{nx,ny-1}) and not findv2(out_on,{nx,ny-1}) then table.insert(out_on,{nx,ny-1}) end if fget(m,6) and fget(mget(nx,ny+1),4) and not findv2(checked_off,{nx,ny+1}) and not findv2(out_on,{nx,ny+1}) then table.insert(out_on,{nx,ny+1}) end if fget(m,5) and fget(mget(nx-1,ny),7) and not findv2(checked_off,{nx-1,ny}) and not findv2(out_on,{nx-1,ny}) then table.insert(out_on,{nx-1,ny}) end if fget(m,7) and fget(mget(nx+1,ny),5) and not findv2(checked_off,{nx+1,ny}) and not findv2(out_on,{nx+1,ny}) then table.insert(out_on,{nx+1,ny}) end end if not connected then table.insert(checked_off,out_on[1]) end end end end end end end function alert(msg,manual,ending) banner_msg=msg banner_t=180 banner_t2=0 banner_manual=manual banner_end=ending end function draw_banner() if banner_msg then local bw=240 for i,bmsg in ipairs(banner_msg) do if banner_t2>0 then bw=math.max(0,240-(banner_t2-(i-1)*8)*16) end rect(math.max(0,240-(180-(i-1)*8-banner_t)*16),136/2-4-(#banner_msg-1)*6+(i-1)*12,bw,8,13) clip(math.max(0,240-(180-(i-1)*8-banner_t)*16),0,bw,136) for c=1,#bmsg do local char=string.sub(bmsg,c,c) if char=='$' then spr(5,-2+240/2-#bmsg/2*6+(c-1)*6,-1+136/2-3-(#banner_msg-1)*6+(i-1)*12,0) elseif char=='%' then spr(6,-2+240/2-#bmsg/2*6+(c-1)*6,-1+136/2-3-(#banner_msg-1)*6+(i-1)*12,0) elseif char=='&' then spr(22,-2+240/2-#bmsg/2*6+(c-1)*6,-1+136/2-3-(#banner_msg-1)*6+(i-1)*12,0) else print(char,240/2-#bmsg/2*6+(c-1)*6+math.cos(t*0.12+c*7)*1+1,136/2-3-(#banner_msg-1)*6+(i-1)*12+math.sin(t*0.12+c*9)*1+1,15,false,1,true) print(char,240/2-#bmsg/2*6+(c-1)*6+math.cos(t*0.12+c*7)*1,136/2-3-(#banner_msg-1)*6+(i-1)*12+math.sin(t*0.12+c*9)*1,4,false,1,true) end end clip() end if banner_t2>0 then banner_t2=banner_t2+1 if bw==0 then banner_msg=nil; banner_t=nil; banner_t2=nil if banner_end then banner_end(); banner_end=nil end end end if banner_t and banner_t>0 then banner_t=banner_t-1 if banner_t==0 and not banner_manual and not (banner_t2>0) then banner_t2=1 end end if banner_manual and banner_manual() then banner_t2=1 banner_manual=nil end end end goo={} function splatter(force) --trace(force) for i=0,6+(force-1)*8-1 do local a=math.random(180-20,360+20)*math.pi/180 table.insert(goo,{x=sx*8+x+3,y=sy*8+y+3,dx=math.cos(a)*(1+force-1.6)/2,dy=math.sin(a)*(1+force-1.6),r=math.random(1,2),t=t}) end end function gootrail() table.insert(goo,{x=sx*8+x+3,y=sy*8+y+6,dx=0,dy=0,r=1}) end function update_goo() for i=#goo,1,-1 do local s=goo[i] if TIC==update or TIC==gameover then s.x=s.x+s.dx; s.y=s.y+s.dy end local m=mget(s.x//8,s.y//8) if fget(m,2) then s.dx=0; s.dy=0 end if TIC==update or TIC==gameover then s.dy=s.dy+0.2; s.dy=s.dy*0.95 end if s.y>=sy*8+2*12*8+s.r then table.remove(goo,i) end end end function draw_goo(dx,dy,trdx,trdy,trt,xdist,ydist) xdist=xdist or 0 ydist=ydist or 0 --local cx=240/2-80+dx*(160+8)-trdx*trt+xdist --local cy=136/2-48+dy*(96+8)-trdy*trt+ydist --clip(cx,cy,160,96) for i=#goo,1,-1 do local s=goo[i] --if s.x-(240/2-80)>=cx and s.x-(240/2-80)=cy and s.y-(136/2-48) x2 and y1 < y2 + h2 and y1 + h1 > y2) end -- from 1THRUSTR.EXE function sprpix(sprno,px,py) local byte= peek(0x4000 + 32*sprno + py*4 + px/2) if px%2==1 then byte=(byte&0xf0)>>4 else byte=byte&0x0f end return byte end -- palette swapping by BORB function pal(c0,c1) if(c0==nil and c1==nil) then for i=0,15 do poke4(0x3FF0*2+i,i) end else poke4(0x3FF0*2+c0,c1) end end -- from Sunray Valley function setvol(ch,vol)--ch 0-3,vol 0-15 local val=peek(0xFF9C+18*ch+1) poke(0xFF9C+18*ch+1,val&(0x0f|vol<<4)) end