ORG level_start

lvl_offset EQU 8


IF output_files
	write "bin/level8.lvl"
ENDIF

;*******************
;*	LEVEL 8 DATA   *	
;*******************
 START	DEFB 0
 SYNCHRO	DEFW 0000
;
START1	DEFB 0 ;sync_tst_pos
START2	DEFB 255
START3	DEFB 255
;
SYNCHRO1	DEFW SYNC1 ;sync_tst ;SYNC1
SYNCHRO2	DEFW SYNC2
SYNCHRO3	DEFW SYNC3
;
TSPRADD		DEFW 0
TADD		DEFW 0
SEQTABLE	DEFW SQTABLE
SPEVENT1	DEFW SPEV1
SPEVENT2	DEFW SPEV2

.lvl_pal
	db 0,26,11,6,3,20,10,2,1,25,16,18,9,15,13,0
	db 0
	db 0,20,2,3,0,10,1,1,0,12,3,9,0,3,1,0
	db 0
	db 0,11,1,3,0,1,0,1,0,3,0,9,0,3,0,0
	db 0
	db 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	db 0

.lvl_floating_color
	db 14
.lvl_music
	db 7
.lvl_skip
	dw 0	;music to skip on music restart
.lvl_init
	dw	0	;called after loading
.lvl_reinit
	dw	l8_reinit	;called each time player dies
	
.l8_reinit
	xor A
	ld (FX8_LastBossLife),A
	ret

;****************************************
;*	LEVEL 8 - ATTACK WAVES
;****************************************
;	1ST BYTE = TILENO
;	2ND BYTE
;		BITS 0-2 = TILESCROLL
;		BITS 3-4 = TILEPOS
;		BITS 5-7 = 
;	3RD BYTE = SEQUENCE NUMBER
;	4TH BYTE = INITIAL X POSITION
;	5TH BYTE = INITIAL Y POSITION
;	(TILESCROLL = FRAME OR BITPOS)
;****************************************
 SYNC1	
	DEFB 8-lvl_offset,1,99,4,0
	DEFB 8-lvl_offset,1,6,200,200
	DEFB 10-lvl_offset,0,1,31,4
	DEFB 10-lvl_offset,23,2,31,13

 	DEFB 15-lvl_offset,1,99,3,20
 	DEFB 15-lvl_offset,1,19,18,15
	DEFB 16-lvl_offset,15,99,3,20
	DEFB 16-lvl_offset,15,20,12,2

 	DEFB 16-lvl_offset,16,3,28,254
 	DEFB 22-lvl_offset,0,4,31,10
 	DEFB 25-lvl_offset,8,5,31,4
	
.sync_tst
.sync_tst_pos	EQU 28-lvl_offset

	LVL_Music	30-lvl_offset,0,8


	DEFB 32-lvl_offset,8,99,3,28
	DEFB 32-lvl_offset,8,48,200,200
	DEFB 32-lvl_offset,8,6,200,200
	
 	;DEFB 32-lvl_offset,8,99,1,0

tent_posX		equ 18
tentup_posY		equ 7
tentdn_posY		EQU tentup_posY+3
	
	
	;DEFB 32-lvl_offset,8,99,3,18	;FORCE TENTACLES 18/19
 	;DEFB 32-lvl_offset,8,43,tent_posX,tentup_posY	;
	;DEFB 32-lvl_offset,8,99,3,19	;
	;DEFB 32-lvl_offset,8,44,tent_posX,tentdn_posY	;
	
	
	
	
	
	;DEFB 32-lvl_offset,16,41,30,11	;BRING ON ALIEN BODY
	;DEFB 32-lvl_offset,16,42,30,7	;BRING ON ALIEN HEAD
	
	DEFB 32-lvl_offset,25,99,1,0	;new scroll pos
	
	DEFB 33-lvl_offset,0,99,3,18	;FORCE TENTACLES 18/19
 	DEFB 33-lvl_offset,0,43,tent_posX,tentup_posY	;
	DEFB 33-lvl_offset,0,99,3,19	;
	DEFB 33-lvl_offset,0,44,tent_posX,tentdn_posY	;
	
	
 	DEFB 33-lvl_offset,3,99,3,15		;FORCE ALIEN COMPOSITE 15
	DEFB 33-lvl_offset,3,45,25,6 ;7		;
	
	DEFB 35-lvl_offset,0,99,3,18		;FORCE TENTACLES OPEN
	DEFB 35-lvl_offset,0,46,tent_posX,tentup_posY		;19,8
	DEFB 35-lvl_offset,0,99,3,19		;
	DEFB 35-lvl_offset,0,47,tent_posX,tentdn_posY		;19,10
	
	;DEFB 35-lvl_offset,10,99,6,3

	
	DEFB 35-lvl_offset,10,99,6,sfx_L1_Boss	
 	DEFB 35-lvl_offset,10,99,3,21	;FORCE TWIRLER 2 21
	
	DEFB 35-lvl_offset,10,21,26,9	;class is 21


	DEFB 35-lvl_offset,30,99,3,21	;

	DEFB 35-lvl_offset,30,22,5,9		;
	
	DEFB 36-lvl_offset,5,99,3,18	;FORCE TENTACLES 18/19
 	DEFB 36-lvl_offset,5,43,tent_posX,tentup_posY	;
	DEFB 36-lvl_offset,5,99,3,19	;
	DEFB 36-lvl_offset,5,44,tent_posX,tentdn_posY	;
	

	

	

	
	DEFB 41-lvl_offset,14,99,3,18	;FORCE TENTACLES OPEN
	DEFB 41-lvl_offset,14,46,tent_posX,tentup_posY	;
	DEFB 41-lvl_offset,14,99,3,19	;
	DEFB 41-lvl_offset,14,47,tent_posX,tentdn_posY	;
	
 	DEFB 41-lvl_offset,24,99,6,3
	
	DEFB 41-lvl_offset,24,99,6,sfx_L1_Boss	
 	DEFB 41-lvl_offset,24,99,3,22	;FORCE TWIRLER 3 22
	DEFB 41-lvl_offset,24,23,26,9	;
	
	DEFB 42-lvl_offset,12,99,3,22	;
	DEFB 42-lvl_offset,12,24,6,11	;
	
	DEFB 42-lvl_offset,19,99,3,18		;FORCE TENTACLES 18/19
 	DEFB 42-lvl_offset,19,43,tent_posX,tentup_posY		;
	DEFB 42-lvl_offset,19,99,3,19		;
	DEFB 42-lvl_offset,19,44,tent_posX,tentdn_posY	;
	

	L8_MASTER0		EQU $+2
	L8_MASTER0_val	EQU 30
	db 46-lvl_offset,0,49,0,0			;force explosion (type 30 to ignore)


	
	DEFB 47-lvl_offset,30,99,3,18	;FORCE TENTACLES OPEN
	DEFB 47-lvl_offset,30,46,tent_posX,tentup_posY	;
	DEFB 47-lvl_offset,30,99,3,19	;
	DEFB 47-lvl_offset,30,47,tent_posX,tentdn_posY	;
	
 	DEFB 48-lvl_offset,8,99,6,sfx_L1_Boss
	DEFB 48-lvl_offset,8,99,3,23		;FORCE TWIRLER 4 23
	DEFB 48-lvl_offset,8,25,25,9		;
 	DEFB 48-lvl_offset,27,99,3,23	;
	DEFB 48-lvl_offset,27,26,6,7		;	
	
	DEFB 49-lvl_offset,0,99,3,18	;FORCE TENTACLES 18/19
 	DEFB 49-lvl_offset,0,43,tent_posX,tentup_posY	;
	DEFB 49-lvl_offset,0,99,3,19	;
	DEFB 49-lvl_offset,0,44,tent_posX,tentdn_posY	;
	

	;DEFB 56-lvl_offset,0,99,5,0		;FORCE END OF LEVEL
	db 56-lvl_offset,0,49,0,0			;force explosion
	
	
 	DEFB 66-lvl_offset,31,99,5,0
 ;
SYNCSPEC	DEFB 67,0,99,3,8
	DEFB 67,0,40,6,19
 	DEFB 67,0,28,254,5
          	DEFB 67,4,29,254,8
	DEFB 67,8,30,254,3
	DEFB 67,12,31,254,14
	DEFB 67,16,32,254,6
 	DEFB 67,20,33,254,18
	DEFB 67,24,34,254,12
	DEFB 67,28,35,254,1
 	DEFB 68,0,36,254,17
 	DEFB 68,4,37,254,9
	DEFB 68,8,38,254,11
 	DEFB 68,12,39,254,4
 	DEFB 68,16,28,254,7
 	DEFB 68,20,29,254,15
	DEFB 68,24,30,254,2
 	DEFB 68,28,31,254,13
	DEFB 69,0,32,254,10
 	DEFB 69,4,33,254,16
 ;
	DEFB 71,0,34,254,5
	DEFB 71,4,35,254,8
	DEFB 71,8,36,254,3
	DEFB 71,12,37,254,14
	DEFB 71,16,38,254,6
 	DEFB 71,20,39,254,18
	DEFB 71,24,28,254,12
	DEFB 71,28,29,254,1
 	DEFB 72,0,30,254,17
 	DEFB 72,4,31,254,9
	DEFB 72,8,32,254,11
 	DEFB 72,12,33,254,4
 	DEFB 72,16,34,254,7
 	DEFB 72,20,35,254,15
	DEFB 72,24,36,254,2
 	DEFB 72,28,37,254,13
	DEFB 73,0,38,254,10
 	DEFB 73,4,39,254,16
 	DEFB 82,0,99,5,0
;
SYNC2
SYNC3	DEFB 255,255,255,255,255	
;****************************************
 ;	1ST BYTE
 ;		BITS 0-3 = SPECIAL EVENT 1
;		BITS 0-4 = SPECIAL EVENT 2
;	2ND BYTE = HIT POINTS
;	3RD BYTE
 ;		BITS 0-3 = POINT VALUE
;		BITS 4-7 = EXPLOSION TYPE
 ;	BYTES ARE NOW PAIRED TO MAKE UP
;	ADDRESS OF SPRITE PATTERNS
 ;	WORD 0 = END OF SEQUENCE 
;****************************************
 ;PODDER 1
SQ1	DEFB 2+192,1,2+32
	DEFW SP1BB,SP1A,SP1B,SP1C
 	DEFW SP1BB,SP1A,SP1B,SP1C,0
 ;PODDER 2
SQ2	DEFB 2+224,1,2+32
	DEFW SP1B,SP1C
	DEFW SP1BB,SP1A,SP1B,SP1C
 	DEFW SP1BB,SP1A,0
 ;PODDER 3
SQ3	DEFB 2+224,1,2+32
	DEFW SP1D,SP1D,SP1D,SP1D,SP1G
 	DEFW SP1E,SP1E,SP1E,SP1E
	DEFW SP1E,SP1E,SP1E,SP1E,0
;PODDER 4
SQ4	DEFB 2+208,1,2+32
	DEFW SP1BB,SP1AA,SP1G
 	DEFW SP1E,SP1E,SP1E,SP1E
	DEFW SP1E,SP1E,SP1E,SP1E,0
;PODDER 5
SQ5	DEFB 2+176,1,2+32
	DEFW SP1BB,SP1A,SP1B,SP1C
 	DEFW SP1BB,SP1A,SP1B,SP1C,0
 ;NULL BABIES
 SQ6	DEFB 3,63,2+32
	DEFW SP2,65535
;
;BABY 1 - U/L
SQ7	DEFB 1+16,1,2+32
 	DEFW SP3,SP3,SP3,SP3,0
;
;BABY 1 - U/R
SQ8	DEFB 1+16,1,2+32
 	DEFW SP3A,SP3A,SP3A,SP3A,0
;
;BABY 1 - D/L
SQ9	DEFB 1+16,1,2+32
 	DEFW SP3B,SP3B,SP3B,SP3B,0
;
;BABY 1 - D/R
SQ10	DEFB 1+16,1,2+32
	DEFW SP3C,SP3C,SP3C,SP3C,0
;
;BABY 2 - U/L
SQ11	DEFB 1+16,1,2+32
	DEFW SP4,SP4,SP4,SP4,0
;
;BABY 2 - U/R
SQ12	DEFB 1+16,1,2+32
	DEFW SP4A,SP4A,SP4A,SP4A,0
;
;BABY 2 - D/L
SQ13	DEFB 1+16,1,2+32
	DEFW SP4B,SP4B,SP4B,SP4B,0
;
;BABY 2 - D/R
SQ14	DEFB 1+16,1,2+32
	DEFW SP4C,SP4C,SP4C,SP4C,0
;
;BABY 3 - U/L
SQ15	DEFB 1+16,1,2+32
	DEFW SP5,SP5,SP5,SP5,0
;
;BABY 3 - U/R
SQ16	DEFB 1+16,1,2+32
	DEFW SP5A,SP5A,SP5A,SP5A,0
;
;BABY 3 - D/L
SQ17	DEFB 1+16,1,2+32
	DEFW SP5B,SP5B,SP5B,SP5B,0
;
;BABY 3 - D/R
SQ18	DEFB 1+16,1,2+32
	DEFW SP5C,SP5C,SP5C,SP5C,0
;TWIRLER 1/A
 SQ19	DEFB 10,63,12+32
	DEFW SP6A,SP6A,SP6A,SP6A,SP6A
 	DEFW SP6E,SP6E,SP6C,SP6C,SP6C
 	DEFW SP6G,SP6B,SP6H,SP6H,SP6B,SP6G,SP6C
 	DEFW SP6E,SP6A,SP6F,SP6F,SP6F,SP6F,0
;TWIRLER 1/B
 SQ20	DEFB 10,63,12+32
	DEFW SP6D,SP6H,SP6B,SP6G,SP6G,SP6G
	DEFW SP6B,SP6H,SP6D,SP6F,SP6A,SP6E
	DEFW SP6E,SP6E,SP6A,SP6F,65535
;
;TWIRLER 2/A
 SQ21	DEFB 10,63,12+32
	DEFW SP6CC,SP6CC,SP6CC,SP6CC,SP6CC,0
;TWIRLER 2/B
 SQ22	DEFB 10,63,12+32
	DEFW SP6C,SP6E,SP6A,SP6F
	DEFW SP6D,SP6H,SP6B,SP6G,65535
;
;TWIRLER 3/A
 SQ23	DEFB 10,63,12+32 
 	DEFW SP6C,SP6CC,SP6CC,SP6CC,SP6CC,SP6G,0
;TWIRLER 3/B
 SQ24	DEFB 10,63,12+32
	DEFW SP6B,SP6H,SP6D,SP6F,SP6F,SP6F,SP6F
 	DEFW SP6A,SP6E,SP6C,SP6G,SP6G,SP6G,SP6G,65535
 ;
;TWIRLER 4/A
 SQ25	DEFB 10,63,12+32
	DEFW SP6CC,SP6CC,SP6CC,SP6CC,SP6E,SP6AA,0
 ;TWIRLER 4/B
 SQ26	DEFB 10,63,12+32
	DEFW SP6F,SP6F,SP6D,SP6D,SP6H
 	DEFW SP6H,SP6B,SP6B,SP6G,SP6G
 	DEFW SP6C,SP6C,SP6E,SP6E,SP6A,SP6A,65535
;HOMING TWIRLER
SQ27	DEFB 4,63,12+32
 	DEFW SP6I,SP6I,65535
;R TYPE 1 red
SQ28	DEFB 5+32,63,12+32
	DEFW SP7A,SP7A,SP7A,SP7A,SP7A,SP7A,SP7A,SP7A,SP7A,0
 ;R TYPE 2 red
SQ29	DEFB 5+32,63,12+32
	DEFW SP7B,SP7B,SP7B,SP7B,SP7B,SP7B,SP7B,SP7B,SP7B,0
 ;R TYPE 1 magenta
SQ30	DEFB 0,0,0
		dw sp30_null
		dw 0
sp30_null
		db 7,128
;R TYPE 2 magenta
SQ31	DEFB 11+32,63,12+32
		DEFW #1D00+29
;R TYPE 1 green
SQ32	DEFB 12+32,63,12+32
		DEFW #1C00+28
;R TYPE 2 green
SQ33	DEFB 12+32,63,12+32
		DEFW #1D00+29
;R TYPE 1 cyan
 SQ34	DEFB 13+32,63,12+32
		DEFW #1C00+28
;R TYPE 2 cyan
 SQ35	DEFB 13+32,63,12+32
		DEFW #1D00+29
;R TYPE 1 yellow
 SQ36	DEFB 14+32,63,12+32
		DEFW #1C00+28
;R TYPE 2 yellow
 SQ37	DEFB 14+32,63,12+32
		DEFW #1D00+29
;R TYPE 1 white
SQ38	DEFB 15+32,63,12+32
		DEFW #1C00+28
;R TYPE 2 white
SQ39	DEFB 15+32,63,12+32
		DEFW #1D00+29
;LETTERS
SQ40	DEFB 6+32,63,12+32
	DEFW SP8,SP8,SP8,SP8,SP8,SP8,SP8,SP8,SP8,SP8,SP8,0
;BRING ON BIG ALIEN BODY
 SQ41	DEFB 1+16,63,12+32
	DEFW SP9,0
;BRING ON BIG ALIEN HEAD
 SQ42	DEFB 1+16,63,12+32
	DEFW SP10,0
 ;TENTACLES TOP
 SQ43	DEFB 7+16,63,12+32
	DEFW SP11,65535
 ;TENTACLES BOTTOM
SQ44	DEFB 7+16,63,12+32
	DEFW SP12,65535
 ;BIG ALIEN COMPOSITE
 SQ45	DEFB 8+48,62,0 ;+32
	DEFW SP13,SP13A,SP13,SP13,SP13,SP13A
	DEFW SP13,SP13,SP13,SP13A,SP13,SP13,SP13,SP13,0
 ;TENTACLES TOP OPEN
SQ46	DEFB 7+16,63,12+32
	DEFW SP11A,0
;TENTACLES BOTTOM OPEN
 SQ47	DEFB 7+16,63,12+32
	DEFW SP12A,0
;DUMMY END LEVEL CHECK
 SQ48	DEFB 9,62,12+32
 	DEFW SP2,65535
	
;timer ending
.SQ49	
		db 11,63,0
		dw SP49,#FFFF
.SP49	db 1,128
;****************************************
SQTABLE		DEFW SQ1,SQ2,SQ3,SQ4,SQ5,SQ6,SQ7,SQ8,SQ9,SQ10
			DEFW SQ11,SQ12,SQ13,SQ14,SQ15,SQ16,SQ17,SQ18,SQ19,SQ20
			DEFW SQ21,SQ22,SQ23,SQ24,SQ25,SQ26,SQ27,SQ28,SQ29,SQ30
			DEFW SQ31,SQ32,SQ33,SQ34,SQ35,SQ36,SQ37,SQ38,SQ39,SQ40
			DEFW SQ41,SQ42,SQ43,SQ44,SQ45,SQ46,SQ47,SQ48,SQ49
;****************************************
;	1ST BYTE = SPRITE NUMBER
;
;	2ND BYTE =
;		BITS 0-1 = ORIENTATION
;		BIT 2 = UP
;		BIT 3 = DOWN
;		BIT 4 = LEFT
;		BIT 5 = RIGHT
;		BIT 6 = 
;		BIT 7 = END OF PATTERN
;****************************************	
;PODDERFS
SP1A	DEFB 7,24,7,24			;FLY D/L 6
 SP1AA	DEFB 7,24,7,24,7,24,7,24+128	;FLY D/L 4 
 SP1B	DEFB 7,16,7,16			;FLY L 4
 SP1BB	DEFB 7,16,7,16+128		;FLY L 2
 SP1C	DEFB 7,20,7,20			;FLY U/L 6
 SP1CC	DEFB 7,20,7,20,7,20,7,20+128	;FLY U/L 4
SP1D	DEFB 7,8			;DROP 4
SP1DD	DEFB 7,8			;DROP 3
 SP1DDD	DEFB 7,8			;DROP 2
SP1DDDD	DEFB 7,8+128			;DROP 1
 SP1E	DEFB 5,16,3,16,5,16,4,16+128	;WALK L
SP1G	DEFB 6,0,6,0+128			;LAND IMPACT L
 ;BABIES NULL ENTRY
 SP2	DEFB 24,128
;BABY 1
SP3	DEFB 10,21,11,21,10,21,11,21+128			;U/L
SP3A	DEFB 10,36,11,36,10,36,11,36+128			;U/R
 SP3B	DEFB 28,25,29,25,28,25,29,25+128			;D/L
 SP3C	DEFB 28,40,29,40,28,40,29,40+128			;D/R
 ;BABY 2
SP4	DEFB 12,21,13,21,12,21,13,21+128			;U/L
SP4A	DEFB 12,36,13,36,12,36,13,36+128			;U/R
 SP4B	DEFB 30,25,31,25,30,25,31,25+128			;D/L
 SP4C	DEFB 30,40,31,40,30,40,31,40+128			;D/R
 ;BABY 3
SP5	DEFB 15,17,14,21,15,17,14,21
 	DEFB 15,17,14,21,15,17,14,21+128			;U/L
 SP5A	DEFB 15,32,14,36,15,32,14,36
	DEFB 15,32,14,36,15,32,14,36+128			;U/R
 SP5B	DEFB 15,19,14,27,15,19,14,27
	DEFB 15,19,14,27,15,19,14,27+128			;D/L
 SP5C	DEFB 15,34,14,42,15,34,14,42
	DEFB 15,34,14,42,15,34,14,42+128			;D/R
 ;TWIRLERS
SP6A	DEFB 8,4
SP6AA	DEFB 8,5+128		;U
 SP6B	DEFB 8,8,8,9+128		;D

 SP6CC	DEFB 8,16,8,17
 SP6C	DEFB 8,16,8,17+128	;

 SP6CCC	DEFB 8,16,8,17,8,16,8,17+128

 SP6D	DEFB 8,32,8,33+128	;R
 SP6E	DEFB 8,20,8,21+128	;U/L
 SP6F	DEFB 8,36,8,37+128	;U/R
 SP6G	DEFB 8,24,8,25+128	;D/L
 SP6H	DEFB 8,40,8,41+128	;D/R
 SP6I	DEFB 8,0,8,1+128
;
;R TYPES !
 SP7A	DEFB 17,0,18,0,19,0,20,0,21,0,22,0,23,0,16,32
 	DEFB 17,0,18,0,19,0,20,0,21,0,22,0,23,0,16,32
 	DEFB 17,0,18,0,19,0,20,0,21,0,22,0,23,0,16,32
 	DEFB 17,0,18,0,19,0,20,0,21,0,22,0,23,0,16,32+128
 SP7B	DEFB 18,0,20,0,22,0,16,32,18,0,20,0,22,0,16,32
	DEFB 18,0,20,0,22,0,16,32,18,0,20,0,22,0,16,32+128
;
;END LETTERING
SP8	DEFB 32,0,32,0,32,0,32,0,32,0
	DEFB 32,0,32,0,32,0,32,0,32,4
 	DEFB 32,0,32,0,32,0,32,0,32,0
 	DEFB 32,0,32,0,32,0,32,0,32,4
 	DEFB 32,0,32,0,32,0,32,0,32,0
 	DEFB 32,0,32,0,32,0,32,0,32,4
 	DEFB 32,0,32,0,32,0,32,0,32,0
 	DEFB 32,0,32,0,32,0,32,0,32,4+128
 ;
;BIG ALIEN BODY
SP9	DEFB 41,16,41,0,41,16,41,0,41,16,41,0
	DEFB 41,16,41,0,41,16,41,0+128
;
;BIG ALIEN HEAD
SP10	DEFB 42,16,42,0,42,16,42,0,42,16,42,0
 	DEFB 42,16,42,0,42,16,42,0+128
;
;TENTACLES TOP
 SP11	;DEFB 33,64,33,0,34,0,34,0,35,0,35,0
		;DEFB 36,0,36,0,36,0,35,0,35,0,34,0,34,0,33,0+128
		;35, 32, 33, 34, 33, 32

		db 36,64,36,0,33,0,33,0,34,0,34,0,35,0,35,0,34,0,34,0,33,0,33,128
	
SP11A	;DEFB 38,64,38,0,39,0,39,0,40,0,37,0,37,0,37,0
		;DEFB 37,0,37,0,40,0,39,0,39,0,38,0,38,0+128
		DEFB 38,64,38,0,39,0,39,0,40,0,40,0,40,0,40,0
		db 40,0,40,0,40,0,40,0
		DEFB 40,0,40,0,40,0,39,0,39,0,38,0,38,0+128
 ;
;TENTACLES BOTTOM
SP12	;DEFB 33,2+64,33,2,34,2,34,2,35,2,35,2
		;DEFB 36,2,36,2,36,2,35,2,35,2,34,2,34,2,33,2+128
		db 36,64+2,36,2,33,2,33,2,34,2,34,2,35,2,35,2,34,2,34,2,33,2,33,128+2
		
SP12A	DEFB 38,2+64,38,2,39,2,39,2,40,2,40,2,40,2,40,2
		db 40,2,40,2,40,2,40,2
		DEFB 40,2,40,2,40,2,39,2,39,2,38,2,38,2+128
 ;
;COMPOSITE ALIEN
 SP13	DEFB 42,0,42,0,42,0,42,0,42,0,42,0,42,0,42,0
	DEFB 42,0,42,0,42,0,42,0,42,0,42,0,42,0,42,0
	DEFB 42,0,42,0,42,0,42,0,42,0,42,0,42,0,42,0
	DEFB 42,0,42,0,42,0,42,0,42,0,42,0,42,0,42,0+128
SP13A	DEFB 43,0,44,0,45,0,46,0,46,0,45,0,44,0,43,0+128

;****************************************
 SPEV1	DEFW FX0,FX1,FX2,FX3,FX4,FX5,FX6,FX7,FX8,FX9,FX10,FX11
	DEFW FX5,FX5,FX5,FX5,FX5
SPEV2	DEFW FXA0,FXA1,FXA2,FXA3,FXA4,FXA5
 	DEFW FXA6,FXA7,FXA8,FXA9,FXA10
	DEFW FXA11,FXA12,FXA13,FXA14,FXA15
;****************************************
 ;NO ACTION
 FX0	JP C,TV5
 FX0A	JP TV1
;
;HALF SPEED
FX1	JP C,TV5
 FX1A	LD A,(FRAME)
	AND 1
 	JP NZ,TV1
 	JP TV2
;	
 ;PODDER EXPLOSION BYPASS
 FX2	JR NC,FX1A
 	JP TV5
;BABIES
FX3	LD A,(TILENO)
	CP 54
 	JR NZ,FX3B
	LD A,(TILEPOS)
	LD L,A
	LD A,(TILESCROLL)
 	ADD L
 	AND A
 	JR Z,FX3M
 FX3B	LD A,(FRAME)
L8_MASTER2		EQU $+1
L8_MASTER2_val	EQU 15 
	AND 31 ;15
	JP NZ,TV1
 ;
	PUSH DE
 	LD DE,(SHIPX)
 	INC E
 	CALL FXA98
	AND 3
 	LD HL,FX38
	CP (HL)
 	JR NZ,FX3A
	INC A
 	AND 3
 FX3A	LD (HL),A
 	CP 3
	JR Z,FX33
 	CP 2
	JR Z,FX32
 	CP 1
	JR Z,FX31
 ;
FX30	LD A,E
	SUB D
 	LD E,A
	INC E
 	INC E
 	LD D,2
	LD A,10
 	JR FX35
 ;
FX31	LD A,E
	ADD D
 	LD E,A
	DEC E
 	DEC E
 	DEC E
 	DEC E
 	LD D,2
	LD A,9
	JR FX35
 ;
FX32	LD A,E
	SUB D
 	LD E,A
	INC E
 	LD D,18
 	LD A,8
	JR FX35
 ;
FX33	LD A,E
	ADD D
 	LD E,A
	DEC E
 	DEC E
 	LD D,18
 	LD A,7
	JR FX35
 ;
FX35	LD HL,FX39
	LD (HL),A
 	INC HL
	LD (HL),E
 	INC HL
	LD (HL),D
 	;CALL RND
	ld A,R
	AND 3
 	CP 3
	JR NZ,FX36
	LD A,1
FX36	ADD A
 	ADD A
 	LD HL,FX39
	ADD (HL)
	LD (HL),A
 	CALL FORCESYNC
	POP DE
	JP TV1
;
FX38	DEFB 0
FX39	DEFB 0,0,0
;
;HOMING TWIRLERS SWITCH
FX3M	PUSH DE : PUSH BC
	LD IX,SEQBUFF+171 ;(19*9)
	LD B,4
FX3N	LD (IX+0),0
 	LD HL,FX3O+1
	LD A,(IX+3)
 	LD (HL),A
 	INC HL
	LD A,(IX+4)
	LD (HL),A
	LD HL,FX3O
	PUSH IX : POP BC
	CALL FORCESYNC
	POP BC : POP IX
 	LD DE,9
 	ADD IX,DE
 	DJNZ FX3N
 	POP BC : POP DE
 	JP FX3B
 ;
FX3O	DEFB 27,0,0
 ;
;HOMING TWIRLERS
 FX4	
	ld (IY+0),62	
	SetMaster NeutralMaster+1 ;very special master , not solid except with player
	
	LD A,(SHIPY)
 	CP B
	JR Z,FX4B
 	JR C,FX4C
 	INC B
 	JR FX4B
 FX4C	DEC B
 FX4B	LD A,(SHIPX)
	CP C
	JR Z,FX4D
 	JR C,FX4E
 	INC C
 	JR FX4D
 FX4E	DEC C
 FX4D	JP TV1
;
;COLOURED R TYPE'S
 FX5	LD A,(IY+5)
	AND 15
	CP 5
	JR NZ,FX5A
	LD A,10
 FX5A	SUB 8
 	OR 64
 	;LD (CADD+1),A
 	JP TV1
;
;COLOURED END TEXT
 FX6	LD A,(IY+8)
	CP 2
	JR NZ,FX6B
	INC (IY+8)
	;CALL STAROFF
	;LD HL,31*256+FULL+1
	;CALL BEEP
	;LD HL,32*256+HALF+1
	;CALL BEEP
	;LD HL,33*256+FULL+1
	;CALL BEEP
 FX6B	LD A,(FRAME)
	AND 7
 	CP 2
	JR NC,FX6A
	AND 1
 	ADD 6
 FX6A	ADD 64
	;LD (CADD+1),A
 	JP TV1
;
;TENTACLES
 FX7	;LD A,(TILENO)
	;CP 33-lvl_offset
 	;JP NZ,FX1A
	;LD A,(TILEPOS)
	;CP 1
	;JP NZ,FX1A
	;LD A,(TILESCROLL)
 	;CP 1
	;JP NZ,FX1A
	ld A,(DE)
	bit 6,A
	jp z,FX1A
;
	;LD HL,2*256+5
 	;CALL CHOP
 	;JP FX1A
	
	ex AF,AF'
 	PUSH AF : PUSH BC : PUSH DE
 	CALL TSPGADD
	CALL REND_EraseZone
 	POP DE : POP BC : POP AF
	ex AF,AF'
	JP FX1A
	
 ;
;COMPOSITE ALIEN
FX8	;JR C,FX8C
	;JR Z,FX8A
 	;JR FX8B
	jr nc,FX8_NotDead
	
	ld A,(FX8_LastBossLife)
	inc A
	ld (FX8_LastBossLife),A
	
	cp 5
	jr c,FX8_Reload	
	
	;give 15K in 2 times
	ld A,14-1	;10
	call SCORE_Add
	ld A,12-1
	call SCORE_Add
	
	call BIG_EXPLO_Start
	
	jp TV5
.FX8_LastBossLife
	db 0
.FX8_Reload
	ld (IY+0),62
.FX8_NotDead	
	ld A,0
	jr z,FX8C
	
	SetNullMaster
	ld A,sfx_touchboss
	call SND_SfxPlay
	
	;ld A,(FRAME)
	;and 1
	;add A
	;ld A,2
	;ld L,A
	;add A
	;add A
	;add L
	ld A,10
FX8C	
	ld (FX8_key),A
	;LD A,62
 	;LD (IY+0),A
 	;LD A,(FXBYTE1)
	;INC A
 	;LD (FXBYTE1),A
FX8B	
	;LD A,(FRAME)
	;AND 1
 	;JR NZ,FX8A
	;LD A,68
 	;LD (CADD+1),A
 FX8A	
	EX AF,AF'
 	PUSH AF : PUSH BC : PUSH DE
 	;LD A,B
	;ADD 6 ;4
 	;LD B,A
	;LD A,41
FX8_key	EQU $+1
	add 0
	CALL TSPGADD
	push AF
	push BC
	push DE
	push HL
	call REND_EraseZone
	pop HL : pop DE : pop BC : pop AF
 	
	;CALL SPNS_Static
	;call REND_EraseZone
	call SPNS_BG
 	POP DE : POP BC : POP AF
	EX AF,AF'
 	;JP FX1A
	jp TV5
 ;
;END OF LEVEL FINDER
 FX9	LD A,(FXBYTE1)
 	CP 10
 	JP NZ,FXA1
	;CALL BIGBANG99
	LD HL,SYNCSPEC
	LD (SYNCHOLD),HL
	LD A,61
 	LD (TILENO),A
 	LD HL,SEQBUFF
 	LD BC,28*9
	CALL FILL0
	LD DE,1*256+5
 	;CALL ATS
	;LD DE,5*256+4
 	;CALL ATS
	JP TV5
.FILL0
	
.FILL0_loop
	ld (HL),0
	inc HL
	;djnz FILL0_loop
	dec BC
	ld A,C
	or B
	jr nz,FILL0_loop
	ret
;
;TWIRLER HIT POINT PATCH
.FX10	
	SetMaster NeutralMaster+1 ;very special master , not solid except with player
	LD (IY+0),62
	JP TV1
;force ending	
.FX11	
	call BIG_EXPLO_Start
	jp TV5
	
;****************************************
 ;NO ACTION
 FXA0	JP TV3
;
;HALF SPEED
FXA1	LD A,(FRAME)
	AND 1
 	JP NZ,TV3
 	JP TV4
;SWITCH OF COLOURED R TYPE'S
 FXA2	XOR A
 	;LD (CADD+1),A
 	JP TV3
;
FXA3	XOR A
 	;LD (CADD+1),A
 	JR FXA1
 ;
FXA4
 ;
FXA5
 ;
FXA6
 ;
;PODDER TOP PILL
 FXA7	LD L,8
	JR FXA15A
 ;
;PODDER BOTTOM PILL
FXA8	LD L,9
	JR FXA15A
 ;
;PODDER BULLETS (1)
;FXA9	LD L,1
 ;	JR FXA15A
;
;PODDER MINI LASER (2)
 ;FXA10	LD L,2
;	JR FXA15A
;
;PODDER LASER (3)
FXA10
FXA11	LD L,3
 	JR FXA15A
 ;
;PODDER BLOB (3)
 FXA9
 FXA12	LD L,4
 	JR FXA15A
 ;
;PODDER CIRCLE (3)
 FXA13	LD L,5
 	JR FXA15A
 ;
;PODDER BONUS
FXA14	LD L,6
 	JR FXA15A
 ;
;PODDER MISSLIE
FXA15	LD L,7
 FXA15A	CALL FXA99
	LD A,(JEW1)
 	AND A
 	JR NZ,FXA15B
;
	LD (JEW1X),BC
 	LD A,L
	LD (JEW1),A
 	LD A,(FRAME)
	DEC A
 	AND 7
 	LD (JEW1P),A
	JP FXA1
 ;
FXA15B	LD (JEW2X),BC
 	LD A,L
	LD (JEW2),A
 	LD A,(FRAME)
	DEC A
 	AND 7
 	LD (JEW2P),A
	JP FXA1
;****************************************
 FXA98	LD HL,(SEED)
 	INC HL
	LD (SEED),HL
	LD A,(HL)
 	RET
;****************************************
 FXA99	LD A,(IY+0)
	AND A
 	JR NZ,FXA99A
	RET
 FXA99A	POP HL
	JP FXA1
;****************************************

read "l8_master_data.asm"