Browse Source

cleaning up tabs/spaces, palette function rewrite

Mike Hoskins 3 years ago
parent
commit
3afd2bc870
1 changed files with 881 additions and 0 deletions
  1. 881 0
      alter-ego-by-kyuchumimo.lua

+ 881 - 0
alter-ego-by-kyuchumimo.lua

@@ -0,0 +1,881 @@
+-- title:   Alter Ego (WIP)
+-- author: ORIGINAL ZX SPECTRUM GAME BY DENIS GRACHEV
+--          NES CONVERSION BY SHIRU
+--          NES MUSIC BY RICHARD "KULOR" ARMIJO
+--										TIC-80 CONVERSION BY KYUCHUMIMO
+-- desc:    My first TIC-80 program
+
+--WARNING: Saved on TIC-80 0.80.xxxx beta. Music doesn't work on previous versions.
+
+--CHANGELOG:
+--200621 - Some SPR and basic learning
+--200622 - Added title music, letters tileset, timming
+--200623 - Added mget command for collision proposes and poke() functions for change palette and create fade effect alike NES
+--200624 - Added Horizontal and Vertical Alter ego sprite mirroring, SFX and 8x8 movement
+--200625 - Added more tilesets, level HELLO WORLD and future levels rearranged based on ZX spectrum version
+--200626 - Added Levels 2 to 9 and Remap function for animate tiles
+--200627 - Added new formulas for X maps and stairs and blocks collision
+--200630 - Added new formulas for Y maps, fall instrucction and sfx, animation and movement speed accurancy
+--200701 - Added more level properties, climb movements and arrangement of debug data
+--200702 - Added cover art for testing
+--200703 - Added a definitive and noiseless cover art
+--200804 - Added mset command for switch tiles (e.g. Bridges)
+--200807 - Added music more accurated from source, instruments and music loops. Number of patern tables reduced to most minimum (7 saved).
+--200808 - Added Sync command to restore tilemap. More variables for control, timing accurancy and small optimizations on code. Game over screen and music. Keyp command
+--200820 - Added death proerties, sfx, level 3 music and music loop accurancy with formulas. Music command correction.
+--200921 - Added both Pixel and phantom pixel collision, animation and sfx. Improved slide SFX and functional Game Over screen
+--200923 - Palette values and address changed to hexadecimal. Code optimization and fixes on collisions and fall conditions (Size from 19618 bytes to 17506 bytes), bridge falling animation (fix later: overlay on frame)
+--200924 - Bridge sprite set colorkey for alpha transparency, small fixes. Functional swap abillity for horizontal mirror added (With some unexpected bugs)
+--200925 - Some transitions and timming added
+--200928 - Vertical mirroring swap abillity added, more transitions and timming, some small changes or fixes.
+--201101 - Added 6 levels more. Now you can press either A or B to swap between Alter Ego and Hero
+--201105 - Added an unused music, there will be no more music due to limitations in the RAM size of music patterns on TIC-80. Minor additions
+--201106 - Cover art updated to a better version. Now you will no longer be able to exchange places with Alter Ego if it is positioned on a block or platform. Added sound effects related to swapping
+--201108 - Now each pixel has its own animation set and pixel animation timming accurancy
+--201110 - 14 of 16 colors in the color palette updated to Sweetie 16 by GrafxKid palette for more consistency with TIC-80. Debug text thinner. Status are now displayed by tiles instead of sprites. Level clear message added at the end of every level
+--201111 - Added pause function, new music respawn method. More additions. Bug fix: Freeze at swapping action bug fixed.
+--201112 - Bug fix: Hero was not displayed when he was moving and the game was paused.
+--201116 - Some transitions and Jxx command used as a loop for music
+--INFO:
+--https://tic80.com/play?cart=1420
+--https://www.youtube.com/watch?v=O3uOHAvlsN8
+
+-- script:  lua
+
+--VARIABLES
+--climb
+c=0
+--sprite flip
+f=0
+--lives
+l=5
+--LEVEL (DEFAULT=0)
+m=0
+--pixels (KEEP AWAY FROM 0)
+px=0
+aepx=0
+--swap
+s=0
+--EVENT TIMER
+et=nil
+--GLOBAL TIMER
+t=0
+--bridge animation trigger
+btrig=0
+--FALL TRIGGER
+ftrig=0
+--PAUSE TRIGGER
+ptrig=0
+--SWAP TRIGGER
+strig=0
+--ALTER EGO mirroring (0=H,1=V)
+aeo=0
+
+--HERO animation ticks
+anix=0
+aniy=0
+--HERO X position
+animx=0
+--HERO Y position
+animy=0
+--ALTER EGO X position
+aex=0
+--ALTER EGO Y position
+aey=0
+--palette RGB value
+v=0
+
+cls()
+map()
+
+--PALETTE VARIABLES
+local basepalette = {
+    0x1a1c2c, 0x29366f, 0x3b5dc9, 0x493c2b, 0x5d275d, 0x38b764, 0xb13e53, 0x333c57, 0x41a6f6, 0xef7d57, 0x94b0c2, 0xa7f070, 0xe06f8b, 0x73eff7, 0xffcd75, 0xf4f4f4
+}
+function pal(v)
+    for i = 1, #basepalette do
+        local offset, color = i-1, basepalette[i]
+        poke(0x3fc0+(offset*3), ((color//65536) * v))
+        poke(0x3fc1+(offset*3), ((color//256)%256) * v)
+        poke(0x3fc2+(offset*3), (color%256) * v)
+    end
+end
+
+function fade_out(et)
+	if t==(et+(2.1*60)) then
+		if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)==6 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==151 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==152 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==153 then music() end
+		return pal(1)
+	end
+	if t==(et+(2.2*60)) then return pal(0.75) end
+	if t==(et+(2.3*60)) then return pal(0.5) end
+	if t==(et+(2.4*60)) then return pal(0.25) end
+	if t==(et+(2.5*60)) then return pal(0) end
+end
+
+function fade_in(et)
+	if t==(et+(0*60)+1) then return pal(0) end
+	if t==(et+(0.1*60)) then return pal(0.25) end
+	if t==(et+(0.2*60)) then return pal(0.5) end
+	if t==(et+(0.3*60)) then return pal(0.75) end
+	if t==(et+(0.4*60)) then return pal(1) end
+end
+
+--(shx: Xpos, shy: Ypos, shf: flip, sht: timer) CHECK THIS
+function skullh(shx,shy,shf,sht)
+	--local shx
+	--local shy
+	--local sht
+	--local shf
+	if mget((30*m%240)+((shx-8)//8),(17*(m//8))+((shy+8)//8))==0 or mget((30*m%240)+((shx+8)//8),(17*(m//8))+((shy+8)//8))==0 then
+		if shf==0 then shf=1 else shf=0 end
+		--sht=0
+		spr(288+t%16//4,(shx*8)+(sht//8),(shy*8),0,1,shf,0,1,2)
+	else
+		--sht=sht+1
+		spr(288+t%16//4,(shx*8)-(sht//8),(shy*8),0,1,shf,0,1,2)
+	end
+	
+	if (animx*8+(anix//10))==shx*8 and ((animy*8+(aniy//10))+8)==(shy*8)+8 then
+		ftrig=0
+		l=l-1
+		sfx(56,45,-2,0)
+		t=0
+		level(m)	
+	end
+ 
+--SCREEN SKULL SPR POSITION DEBUG
+	--print(shx*8,22,24)
+	--print((shy*8)+8,22,30)
+
+end	
+	
+--LEVEL PROPERTIES (ANIMX/Y LIMITS(1-28,1-14))
+function level(m)
+	
+	sync(0,0,false)
+
+	c=0
+	f=0
+	px=nil
+	aepx=nil
+	anix=0
+	aniy=0
+	et=-255
+	strig=0
+	ftrig=0
+	
+	--HELLO WORLD
+	if m==2 then
+		t=0
+		s=2
+		px=3
+		aepx=0
+		aeo=0
+		animx=21
+		animy=3
+	end
+	
+	--PROMENADE
+	if m==3 then
+		s=2
+		px=8
+		aepx=0
+		aeo=0
+		animx=5
+		animy=3
+	end
+
+	--BROKEN BRIDGE
+	if m==4 then
+		s=0
+		px=8
+		aepx=0
+		aeo=0
+		animx=11
+		animy=8
+	end
+	
+	--PHANTOM PIXELS
+	if m==5 then
+		s=3
+		px=2
+		aepx=4
+		aeo=0
+		animx=14
+		animy=3
+	end	
+
+	--ANOTHER PHANTOM
+	if m==6 then
+		s=4
+		px=13
+		aepx=0
+		aeo=1
+		animx=3
+		animy=10
+	end
+
+	--SKULLS LAIR
+	if m==7 then
+		s=2
+		px=14
+		aepx=0
+		aeo=0
+		animx=17
+		animy=13
+	end
+	
+	--ABRACADABRA
+	if m==8 then
+		s=2
+		px=6
+		aepx=6
+		aeo=0
+		animx=9
+		animy=10
+	end
+					
+	--VERTICAL ILLUTIONS
+	if m==9 then
+		s=8
+		px=10
+		aepx=0
+		aeo=1
+		animx=4
+		animy=9
+	end
+
+	--MIRRORS
+	if m==10 then
+		s=2
+		px=4
+		aepx=3
+		aeo=0
+		animx=26
+		animy=11
+	end
+
+	--16 PIXELS
+	if m==11 then
+		s=4
+		px=16
+		aepx=0
+		aeo=0
+		animx=5
+		animy=9
+	end
+
+	--PERFECT REFLECT
+	if m==12 then
+		t=0
+		s=1
+		px=16
+		aepx=0
+		aeo=0
+		animx=15
+		animy=10
+	end
+
+	--ICELANDS
+	if m==13 then
+		s=3
+		px=5
+		aepx=3
+		aeo=0
+		animx=15
+		animy=9
+	end
+
+	--MIDNIGHT
+	if m==14 then
+		s=2
+		px=5
+		aepx=0
+		aeo=0
+		animx=23
+		animy=12
+	end
+	
+	--ALONE SKULL
+	if m==15 then
+		s=3
+		px=3
+		aepx=2
+		aeo=0
+		animx=15
+		animy=2
+	end
+
+	--MADE IN HEAVEN
+	if m==16 then
+		s=5
+		px=9
+		aepx=6
+		aeo=1
+		animx=4
+		animy=4
+	end
+
+	--UNDERWATER
+	if m==17 then
+		s=2
+		px=3
+		aepx=5
+		aeo=0
+		animx=2
+		animy=9
+	end
+
+	--ZUPAPIXELS
+	if m==18 then
+		s=9
+		px=8
+		aepx=1
+		aeo=0
+		animx=3
+		animy=2
+	end
+	
+	--SKULLOPEDIA
+	if m==19 then
+		s=4
+		px=12
+		aepx=0
+		aeo=0
+		animx=7
+		animy=12
+	end
+
+	--AFTER THE WAR
+	if m==20 then
+		s=3
+		px=8
+		aepx=0
+		aeo=1
+		animx=3
+		animy=2
+	end
+
+	--VIRUS KVARTIRUS
+	if m==21 then
+		s=6
+		px=11
+		aepx=0
+		aeo=0
+		animx=24
+		animy=13
+	end
+	
+	--END
+	if m==22 then
+		t=0
+		l=143
+		s=143
+		px=-255
+		aepx=-255
+		aeo=0
+		animx=-1
+		animy=-2
+		mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8),1)
+		mset(((30*m%240)+(animx*8+(anix//10))//8)-1,(17*(m//8))+((animy*8+(aniy//10))//8)+1,1)
+		mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,1)
+		mset(((30*m%240)+(animx*8+(anix//10))//8)+1,(17*(m//8))+((animy*8+(aniy//10))//8)+1,1)	
+	end
+end
+
+level(m)
+
+function TIC()
+
+--MUSIC (For loop use t%(spd*rows*#patterns used)==0)
+	--TITLE SCREEN
+	if m==1 and t==0 then music(0,-1,-1,false) end
+	--LEVELS 1-10
+	if m>=2 and m<=11 and t==0 then	music(1,-1,-1,false) end
+	--LEVELS 11-21
+	if m>=12 and m<=21 and t==0 then music(2,-1,-1,false) end
+	--LEVELS 21-???
+	if m>=22 and t==0 then music(3) end
+
+--TIMER
+	if ptrig==0 then t=t+1 end
+
+--CREDITS
+	if m==0 then
+	 --if t==(-0.3*60)+1 then return cls(10) end
+	 --if t==(-0.2*60) then return cls() end
+		--if t==(-0.1*60) then return cls(10) end
+  --if t<(0*60) then return end
+		map(0,0,30,17)
+		print(t,0,0,15,true,1,true)
+		print(et,0,6,15,true,1,true)
+		fade_in(0)
+	 if t==(3*60) or keyp(50) then et=t end
+		if t>(et+(3*60)) and et>=0 then 
+			m=m+1
+			t=0
+			et=-255
+		else 
+			fade_out(et)
+			return
+		end
+	end
+	
+--TITLE SCREEN
+	if m==1 then
+		l=5
+		--REMAP
+		cls()
+		map(30*m%270,17*((m-1)//8),30,17,0,0,0,1,
+
+		function(tile)
+		if tile>=80 and tile<=111 and et==-255 then
+			return tile*(t%38//19)
+		end
+		if tile>=80 and tile<=111 and et~=-255 then
+			return tile*(t%10//5)
+		end
+		return tile
+		end)
+
+		fade_in(0)
+		
+		if t<0.4*60 then return end 
+			print("DEBUG: Press X/A and Y/S to switch levels",8,131)
+			print(et,0,0,15,true,1,true)
+		if keyp(50) and et<=0 then
+			music()
+			sfx(51,43,-1,0,15)
+			et=t
+		end
+		if t>(et+(3*60)) and et>=0 then 
+			m=m+1
+			level(m)
+		else 
+			fade_out(et)
+			return
+		end
+	end
+
+--LEVEL DISPLAY
+	if m>1 then
+		fade_in(0)
+		--REMAP
+		cls()
+		map(30*m%240,17*(m//8),30,17,0,0,0,1,
+
+		function(tile)
+		if tile>=80 and tile<=111 and anix==0 and aniy==0 and px==0 and aepx==0 then
+			return tile*(t%38//19)
+		end
+		if tile==6 or tile==22 or tile==38 or tile==54 or tile==8 or tile==24 then
+			return tile+(t%38//19)
+		else
+			if tile~=6 and tile~=22 and tile~=38 and tile~=54 and tile~=8 and tile~=24 and not (tile>=64 and tile<=79) then return tile end
+		end
+		end)
+
+  --PIXELS	DISPLAY
+		map(30*m%240,17*(m//8),30,17,0,0,0,1,
+		function(tile)
+		if tile==64 or tile==72 then
+			return tile+(t%20//2.5)
+		end
+		if tile==65 or tile==73 then
+			return tile+(((t+2.5)%20//2.5)-1)
+		end
+		if tile==66 or tile==74 then
+			return tile+(((t+5)%20//2.5)-2)
+		end
+		if tile==67 or tile==75 then
+			return tile+(((t+7.5)%20//2.5)-3)
+		end
+		if tile==68 or tile==76 then
+			return tile+(((t+10)%20//2.5)-4)
+		end
+		if tile==69 or tile==77 then
+			return tile+(((t+12.5)%20//2.5)-5)
+		end
+		if tile==70 or tile==78 then
+			return tile+(((t+15)%20//2.5)-6)
+		end
+		if tile==71 or tile==79 then
+			return tile+(((t+17.5)%20//2.5)-7)
+		end
+		end)
+
+--SKULLH LIMITS(1-28,1-14)
+	--skullh(12,10,0,0)
+ --if btn(5) then	skullh(25,3,0,0) end
+	--skullh(20,6,0,0)
+	
+--LEVEL CLEAR
+	if px==0 and aepx==0 and anix==0 and aniy==0 then
+		if et<0 then
+		 sfx(52,36,90,0)
+			for i=0,29 do
+				mset((30*m%240)+i,(17*(m//8)),0)
+			end
+			mset((30*m%240)+10,(17*(m//8)),91)
+			mset((30*m%240)+11,(17*(m//8)),84)
+			mset((30*m%240)+12,(17*(m//8)),101)
+			mset((30*m%240)+13,(17*(m//8)),84)
+			mset((30*m%240)+14,(17*(m//8)),91)
+			mset((30*m%240)+16,(17*(m//8)),82)
+			mset((30*m%240)+17,(17*(m//8)),91)
+			mset((30*m%240)+18,(17*(m//8)),84)
+			mset((30*m%240)+19,(17*(m//8)),80)
+			mset((30*m%240)+20,(17*(m//8)),97)
+			et=t
+		end
+		if et>0 then
+			spr(257+(f*3),animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
+			spr(265,aex,aey,0,1,0,0,1,2)
+			fade_out(et)
+		end
+		if t<et+(3*60) then
+		return end
+	 m=m+1
+		t=1
+		level(m)
+	end
+
+	--STATUS DISPLAY
+	mset((30*m%240)+3,(17*(m//8)),112+l)
+	mset((30*m%240)+7,(17*(m//8)),112+s)
+	end
+
+--GAME OVER
+	if l==0 then
+		map(210,119,30,17)
+		sfx(-1,-1,-1,0)
+		sfx(-1,-1,-1,1)
+		sfx(-1,-1,-1,2)
+		sfx(-1,-1,-1,3)
+		if t==1 then
+			music(6,-1,-1,false)
+		end
+		fade_in(0)
+		if t<8*60 then
+			return
+		end
+		m=1
+		level()
+		t=0
+	end
+
+	--DEATH
+	if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)==6 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==151 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==152 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==153 then
+		if et<0 then
+			sfx(56,45,-2,0)
+			sfx(60,45,-2,1)
+			et=t
+		end
+		if et>0 then
+			spr(331+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
+			spr(329+t%8//4,aex,aey,0,1,0,0,1,2)
+			fade_out(et)
+		end
+		if t<et+(3*60) then
+		return end
+		ftrig=0
+		l=l-1
+		t=0
+		level(m)
+	end
+	
+ --FALL
+	if not ((mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==1 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==2 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==17 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==18 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==10 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==11 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==26 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==27 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==37 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==48 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==49 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==16 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==32 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==37) and anix==0 and aniy==0 and strig==0 then
+		if ftrig==0 and l>0 then sfx(57,82,-1,0) end
+		ftrig=1
+		animy=animy+1
+		aniy=-80
+		spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
+	end
+	--NOTHING
+	if anix==0 and aniy==0 and t>(2*60) then
+		if ftrig==1 and strig==0 then sfx(58,24,-1,0) end
+		if strig==0 then
+			spr(256+c,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
+		else
+			spr(301+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
+		end
+		ftrig=0
+		btrig=0
+	end
+
+	if t<(2*60) then
+		spr((256+c)+((t%20//10)*15),animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
+	end
+		
+	if m>1 then
+		--CONTROLS, COLLISION and SFX
+		--UP(0),DOWN(1),LEFT(2),RIGHT(3)
+		if strig==0 and t>(2*60) and ptrig==0 then
+			if btn(0) and (mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8)==5 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8)==37) and anix==0 and aniy==0 then
+				ftrig=0
+				sfx(63,84,-1,3)
+				animy=animy-1
+				aniy=80
+			end
+
+			if btn(1) and (mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==0 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==5 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==37) and anix==0 and aniy==0 then
+				ftrig=0
+				sfx(63,84,-1,3)
+				animy=animy+1
+				aniy=-80
+			end
+
+		if btn(2) and anix==0 and aniy==0 and not ((mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==1 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==2 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==17 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==18 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==10 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==11 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==26 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==27) then
+			ftrig=0
+			--BRIDGE
+			if	mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==48 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==49 then
+				sfx(61,0,-1,3)
+				mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
+				btrig=1
+			else
+				sfx(62,0,-1,3)
+			end
+			animx=animx-1
+			anix=80
+		end
+
+		if btn(3) and anix==0 and aniy==0 and not ((mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==1 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==2 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==17 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==18 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==10 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==11 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==26 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==27) then
+			ftrig=0
+			--BRIDGE
+			ifmget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==48 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==49 then
+				sfx(61,0,-1,3)
+				mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
+				btrig=1
+			else
+				sfx(62,0,-1,3)
+			end
+			animx=animx+1
+			anix=-80
+		end
+
+		--A/Z(4),B/X(5),X/A(6),Y/S(7)	
+		if (btnp(4) or btnp(5)) and m>=2 then
+			if s>0 and not (mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==1 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==2 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==16 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==17 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==18 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==10 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==11 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==26 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==27) then
+				sfx(53,72,-1,3)
+				s=s-1
+				strig=1
+			else
+				if s==0 then
+					sfx(55,31,-1,2)
+				else
+					sfx(59,60,-1,3)
+				end
+			end
+		end
+		if btnp(6) and m<=21 then
+			m=m+1
+			level(m)
+		end
+		if btnp(7) and m>=3 and m<=21 then
+			m=m-1
+			level(m)
+			end
+		end
+
+		if t>=2*60 then
+			if keyp(50) then
+				if ptrig==0 then
+					sfx(51,43,-1,0,15)
+					ptrig=1
+					pal(0.5)
+					must=peek(0x13ffc)
+					musf=peek(0x13ffd)
+					musr=peek(0x13ffe)
+					musl=peek(0x13fff)
+					music()
+				else
+					sfx(51,43,-1,0,15)
+					ptrig=0
+					pal(1)
+					music(must,musf,musr,musl)
+				end
+			end
+		end
+
+		--MOVEMENT PROPERTIES
+		if strig==1 and anix==0 and aniy==0 then
+			if aeo==0 then strig=(aex)-(animx*8+(anix//10)) end
+			if aeo==1 then strig=(aey)-(animy*8+(aniy//10)) end
+		end
+		if strig~=1 then
+		if strig<0 and ptrig==0 then
+			if aeo==0 then animx=animx-0.5 end
+			if aeo==1 then animy=animy-0.5 end
+			strig=strig+4
+		end
+		if strig>0 and ptrig==0 then
+			if aeo==0 then animx=animx+0.5 end
+			if aeo==1 then animy=animy+0.5 end
+			strig=strig-4
+		end
+	end
+
+	if anix>0 then
+		if	btrig==1 then	
+			if m<=11 then spr(48,(animx*8)+8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
+			if m>=12 then spr(49,(animx*8)+8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
+		end
+		c=0
+		f=0
+		if ptrig==0 then anix=anix-8 end
+			spr(257+t%8//2,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
+		end
+		if anix<0 then
+			if btrig==1 then	
+				if m<=11 then spr(48,(animx*8)-8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
+				if m>=12 then spr(49,(animx*8)-8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end			
+			end
+			c=0
+			f=1
+			if ptrig==0 then anix=anix+8 end
+				spr(257+t%8//2,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
+			end 
+		if aniy>0 then
+			c=5
+			if ptrig==0 then aniy=aniy-8 end
+			spr(261+t%6//3,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
+		end
+		if aniy<0 then
+			c=5
+			if ptrig==0 then aniy=aniy+8 end
+			if not ((mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==1 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==2 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==17 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==18 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==10 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==11 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==26 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==27 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==37 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==48 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==49 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==16 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==32) then
+				spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
+			else
+				if ftrig==1 then c=0 end
+				spr(261+t%14//7,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
+			end
+		end
+
+	--PIXEL COLLISION
+	if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)>=64 and mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)<=71 and strig==0 then
+		px=px-1
+		sfx(54,72,-1,0)
+		mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+1,0)
+	end
+
+	--PHANTOM PIXEL COLLISION
+	if mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))>=72 and mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))<=79 and strig==0 then
+		aepx=aepx-1
+		sfx(54,69,-1,0)
+		mset((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8),0)
+	end
+	
+	--HERO DISPLAY
+	
+	--ALTER EGO DISPLAY
+	if aeo==0 then
+		--120=ZX spectrum Mirrored, 116=NES Mirrored
+		aex=120-((animx*8+(anix//10))-120)
+		aey=animy*8+(aniy//10)
+	end
+	if aeo==1 then
+		aex=animx*8+(anix//10)
+		aey=64-((animy*8+(aniy//10))-64)
+	end
+ 
+	if t>(2*60) then	
+		if strig==0 then
+			spr(265+t%8//2,aex,aey,0,1,0,0,1,2)
+		else
+			spr(297+t%16//4,aex,aey,0,1,0,0,1,2)
+		end
+	else
+		spr(265+((t%20//10)*6),aex,aey,0,1,0,0,1,2)
+	end
+	
+	end
+
+	--DEBUG DISPLAY
+	print("DEBUG",0,0,15,true,1,true)
+	--TIMER DEBUG
+	print(t,0,6,15,true,1,true)
+	--SWAP ACTION INPUT DEBUG
+	if btn(4)==true or btn(5)==true then
+		print("true",0,12,15,true,1,true)
+	else
+		print("false",0,12,15,true,1,true)
+	end
+	--MAP SCREEN DEBUG
+	print(m,0,18,15,true,1,true)
+
+	--SWAP TRIGGER DEBUG	
+	print(strig,22,18,15,true,1,true)
+	
+	--SCREEN HERO SPR POSITION DEBUG
+	print((animx*8+(anix//10)),0,24,15,true,1,true)
+	print((animy*8+(aniy//10))+8,0,30,15,true,1,true)
+	
+	--SCREEN ALTER EGO SPR POSITION DEBUG
+	print(aex,22,24,15,true,1,true)
+	print(aey+8,22,30,15,true,1,true)
+
+	--MAP HERO SPR POSITION DEBUG
+	print((30*m%240)+(animx*8+(anix//10))//8,0,42,15,true,1,true)
+	print((17*(m//8))+((animy*8+(aniy//10))//8)+1,0,48,15,true,1,true)
+	
+	--MAP ALTER EGO SPR POSITION DEBUG
+	print((30*m%240)+aex//8,22,42,15,true,1,true)
+	print((17*(m//8))+((aey+8)//8),22,48,15,true,1,true)
+	
+	--MOVEMENT DEBUG
+	print(anix//10,0,60,15,true,1,true)
+	print(aniy//10,0,66,15,true,1,true)
+	
+	--PIXEL AND PHANTOM PIXEL DEBUG
+	print(px,22,60,15,true,1,true)
+	print(aepx,22,66,15,true,1,true)	
+
+	--MGET DEBUG
+	print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8),22,78,15,true,1,true)	
+	print(mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8),0,84,15,true,1,true)
+	print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8),22,84,15,true,1,true)
+	print(mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8),44,84,15,true,1,true)
+	print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8),22,90,15,true,1,true)
+ 
+	--MUSIC SPEED DEBUG (0-7)
+	--print(peek(0x13e96),0,102)
+	--print(peek(0x13ec9),22,102)
+	--print(peek(0x13efc),0,108)
+	--print(peek(0x13f2f),22,108)
+	--print(peek(0x13f62),0,114)
+	--print(peek(0x13f95),22,114)
+	--print(peek(0x13fc8),0,120)
+	--print(peek(0x13ffb),22,120)
+
+	--MUSIC POSITION DEBUG
+	print("track:",44,102,15,true,1,true)
+	print(peek(0x13ffc),88,102,15,true,1,true)
+	print("frame:",44,108,15,true,1,true)
+	print(peek(0x13ffd),88,108,15,true,1,true)
+	print("row  :",44,114,15,true,1,true)
+	print(peek(0x13ffe),88,114,15,true,1,true)
+	print("loop :",44,120,15,true,1,true)
+	print(peek(0x13fff),88,120,15,true,1,true)
+	
+	--wait: Time event (2 sec)
+	--if t<2*60 then return end
+	--stuff to do
+		
+	--spr command: spr(id+t%nf//f,x,y,z,s,f,r,w,h)
+	--id=sprite id
+	--t=timer
+	--f=frames to wait for switch sprites
+	--n=number of sprites to switch
+	--Compare between f and n variables for speed
+	--x=x position
+	--y=y position
+	--z=colorkey id to set alpha
+	--s=scale
+	--f=flip(Hflip(1),Vflip(2),HVflip(3))
+	--r=rotate(90 deg(1),180 deg(2),270 deg(3))
+	--w=width of composite sprite
+	--h=height of composite sprite
+
+	--end of function TIC()
+end