; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί SEGA/Legal/Titlepage/Options					   Ί
; ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ
; Ί Entry: n/a								   Ί
; Ί  Exit: n/a								   Ί
; Ί  Used: n/a								   Ί
; ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ
; Ί All SHELL stuff happens here ...					   Ί
; Ί 									   Ί
; Ί 	SEGA LOGO Display						   Ί
; Ί 	LEGAL SCREEN Display						   Ί
; Ί 	DISNEY LOGO Display						   Ί
; Ί 	TITLE SCREEN Logic						   Ί
; Ί 	OPTIONS SCREEN Logic						   Ί
; Ί 	LOSE MAN/RESTART Logic						   Ί
; Ί 	GAME OVER/CONTINUE Logic					   Ί
; Ί 	GAME WIN Logic							   Ί
; Ί 	CREDITS Logic							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

StartupSequence		if	logos_yn
			moveq	#SegaFLUFF,d1
			bsr	FluffSequence
			moveq	#DisneyFLUFF,d1
			bra	FluffSequence
			endif
			
StartupSequence2	if	titles_yn
			moveq	#TitlepageFLUFF,d1
			bsr	FluffSequence
			cmp.w	#Level11,levnum
			bne.s	.o1
			moveq	#IntroFLUFF,d1
			bra	FluffSequence
			endif
.o1			rts


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί INTRO/BETWEEN LEVELS/STORY Sequences				   Ί
; ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ
; Ί Entry: n/a								   Ί
; Ί  Exit: n/a								   Ί
; Ί  Used: n/a								   Ί
; ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ
; Ί All FLUFF stuff happens here ...					   Ί
; Ί 									   Ί
; Ί INTRODUCTION Sequence						   Ί
; Ί STORY Sequences							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

BeginLevelSequence	cmp.w	#Level11,levnum
			bne.s	.o1
			moveq	#BeginL1FLUFF,d1
			bra	FluffSequence
.o1			cmp.w	#Level21,levnum
			bne.s	.o2
			moveq	#BeginL2FLUFF,d1
			bra	FluffSequence
.o2			cmp.w	#Level31,levnum
			bne.s	.o3
			moveq	#BeginL3FLUFF,d1
			bra	FluffSequence
.o3			cmp.w	#Level51,levnum
			bne.s	.o4
			moveq	#BeginL5FLUFF,d1
			bra	FluffSequence
.o4			cmp.w	#Level71,levnum
			bne.s	.o5
			moveq	#BeginL7FLUFF,d1
			bra	FluffSequence
.o5			rts


IntroFLUFF		equ	0
BeginL1FLUFF		equ	1
BeginL2FLUFF		equ	2
EndL2FLUFF		equ	3
BeginL3FLUFF		equ	4
BeginL5FLUFF		equ	5
BeginL7FLUFF		equ	6
MiddleL7FLUFF		equ	7
EndL7FLUFF		equ	8
CreditsFLUFF		equ	9
SegaFLUFF		equ	11
DisneyFLUFF		equ	12
TitlepageFLUFF		equ	13
OptionsLUFF		equ	14
ContinueFLUFF		equ	15
GameOverFLUFF		equ	16
JoelHelloFLUFF		equ	17


FluffSequence		if	fluff_yn	
			asl.w	#2,d1
			jmp	FluffJumpTAB(pc,d1.w)
			else	
			cmp.w	#TitlepageFLUFF,d1
			bne.s	.x
 			asl.w	#2,d1
			jmp	FluffJumpTAB(pc,d1.w)
.x			rts
			endif

FluffJumpTAB		bra	IntroFluff			;0
			bra	BeginL1Fluff			;1
			bra	BeginL2Fluff			;2
			bra	EndL2Fluff			;3
			bra	BeginL3Fluff			;4
			bra	BeginL5Fluff			;5
			bra	BeginL7Fluff			;6
			bra	MiddleL7Fluff			;7
			bra	EndL7Fluff			;8
			bra	CreditsFluff			;9
			bra	NullFluff			;10
			bra	SegaFluff			;11
			bra	DisneyFluff			;12
			bra	TitlepageFluff			;13
			bra	OptionsFluff			;14
			bra	ContinueFluff			;15
			bra	GameOverFluff			;16
			bra	JoelHelloFluff			;17
			

SetupFluffSequence	move.w	#$2700,sr
			jsr	GetDATA2
			bsr	SetMapLines				;map line table
			bsr	SetupCharsetA				;setup charset A
			bsr	Clean_DeComRam
			jsr	SetupScrlB
			jmp	SetupScrlA
			

SetupShell		move.w	#$2700,sr
			st.b	working
			clr.b	service
			jsr	InitVRamAlloc
			bsr	SetMapLines				;map line table
			bsr	Clean_DeComRam
			jsr	InitOBJECTS
			move.l	#TheDmaStack,DMA_Stack
			move.w	#ShellVBLANK,VBLANKPhase
			move.w	#reg12+%10000001,vctrl			;12 40 coloumn, shadow off, interlace off
			move.w	#HorWholScroll!VerWholScroll,d0
			bsr	SetScroll
			st.b	FullScroll_Hor
			st.b	FullScroll_Ver
			bsr	ClrScrlA	  SetupVDP
			bra	ClrScrlB
	

			
; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί GAME INTRO								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

itxt1			dc.w	cp4
			dc.b	pfA,19,10,"      994 A.D.",0

itxt2a			dc.w	cp4
			dc.b	pfA,19,08,"  VIKING SORCERERS",0
itxt2b			dc.w	cp4
			dc.b	pfA,19,10,"  HAVE CREATED AN",0
itxt2c			dc.w	cp4
			dc.b	pfA,19,12,"  ARTIFACT OF",0
itxt2d			dc.w	cp4
			dc.b	pfA,19,14,"  INCREDIBLE POWER",0
itxt2e			dc.w	cp4
			dc.b	pfA,19,16,"  AND EVIL ...",0

itxt3a			dc.w	cp4
			dc.b	pfA,19,09,"     THE  EYE",0
itxt3b			dc.w	cp4
			dc.b	pfA,19,11,"        OF",0
itxt3c			dc.w	cp4
			dc.b	pfA,19,13,"       ODIN",0
			even

IntroFluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	IntroDATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_StoryScreen
			move.l	#0,PixX_Copy
			move.l	#0,PixY_Copy
			lea	ClrIntroText,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade
			
			lea	itxt1,a1
			move.w	#1*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrIntroText,a1
			bsr	ClrTextArea

			lea	itxt2a,a1
			bsr	PrintString
			lea	itxt2b,a1
			bsr	PrintString
			lea	itxt2c,a1
			bsr	PrintString
			lea	itxt2d,a1
			bsr	PrintString
			lea	itxt2e,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrIntroText,a1
			bsr	ClrTextArea
			
			lea	itxt3a,a1
			bsr	PrintString
			lea	itxt3b,a1
			bsr	PrintString
			lea	itxt3c,a1
			bsr	PrintString
			bsr	FadeTextUp
			
			move.w	#2*hz5060,d1
			jsr	frame_delay		
			bpl.s	.1
			bsr	HandleDemoMode
.1			bsr	dark_fader
			bra	wait_fade


DoTextThang		bsr	PrintString
			bsr	FadeTextUp
			move.w	TempX,d1
			jsr	frame_delay		
			bpl.s	.1
			bsr	HandleDemoMode
.1			bra	FadeTextDown

HandleDemoMode		tst.b	demo_mode
			beq.s	.1
			bsr	dark_fader
			bsr	wait_fade
			move.b	s_button_a,button_a
			move.b	s_button_b,button_b
			move.b	s_button_c,button_c
			move.b	s_difficulty,difficulty
			bra	ColdResetTheGame
.1			rts

			
FadeTextUp		jsr	WaitFrm
			jsr	WaitFrm
			jsr	WaitFrm
			cmp.w	#$666,Pal4+30
			beq.s	.2
			add.w	#$222,Pal4+30
.2			cmp.w	#$eee,Pal4+28
			beq.s	.fin
			add.w	#$222,Pal4+28
			bra	FadeTextUp
.fin			rts
	
FadeTextDown		jsr	WaitFrm
			jsr	WaitFrm
			jsr	WaitFrm
			cmp.w	#$000,Pal4+30
			beq.s	.2
			sub.w	#$222,Pal4+30
.2			cmp.w	#$000,Pal4+28
			beq.s	.fin
			sub.w	#$222,Pal4+28
			bra	FadeTextDown
.fin			rts


ClrIntroText		dc.w	19,0,20,24,0,cp4
ClrBL1Text		dc.w	15,0,24,14,0,cp4
ClrBL2Text		dc.w	0,0,20,26,0,cp4
ClrEL2Text		dc.w	0,0,18,12,0,cp4
ClrBL5Text		dc.w	17,0,22,24,0,cp4
ClrBL7Text		dc.w	14,0,22,14,0,cp4
ClrML7Text		dc.w	0,0,21,20,0,cp4
ClrEL7Text		dc.w	21,12,17,20,0,cp4
				
ClrTextArea		move.w	0(a1),d1		;x
			move.w	2(a1),d2		;y
			move.w	d1,TempX
			move.w	d2,TempY
			move.l	#ScrlA_Base,d6
			bsr	GetScreenAddrs
	
			move.w	8(a1),d5		;fill chr
			add.w	10(a1),d5		;add in color palette
			move.w	6(a1),d4		;y	
.l1			move.w	4(a1),d3		;x
.l2			move.w	d5,vdata
			dbra	d3,.l2	
			move.w	TempX,d1
			addq.w	#1,TempY
			move.w	TempY,d2
			move.l	#ScrlA_Base,d6
			bsr	GetScreenAddrs
			dbra	d4,.l1
			rts


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί BEGIN LEVEL1							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

bl1txt1a		dc.w	cp4
			dc.b	pfA,19,08,"MAD WITH POWER,",0
bl1txt1b		dc.w	cp4
			dc.b	pfA,17,10,"VIKING INVADERS",0
bl1txt1c		dc.w	cp4
       			dc.b	pfA,15,12,"OVERRAN CASTLE WYVERN.",0

bl1txt2a		dc.w	cp4
       			dc.b	pfA,20,9, "  LEVEL  1",0
bl1txt2b		dc.w	cp4
       			dc.b	pfA,20,11,"EVIL AWAKENS",0
			even

BeginL1Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	BeginL1DATA,a0
			bsr	SetupFluffSequence
			move.l	#0,PixX_Copy
			move.l	#0,PixY_Copy
			lea	ClrBL1Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade
			
			lea	bl1txt1a,a1
			bsr	PrintString
			lea	bl1txt1b,a1
			bsr	PrintString
			lea	bl1txt1c,a1
			move.w	#2*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrBL1Text,a1
			bsr	ClrTextArea
			
			lea	bl1txt2a,a1
			bsr	PrintString
			lea	bl1txt2b,a1
			bsr	PrintString
			bsr	FadeTextUp
			
			move.w	#3*hz5060,d1
			jsr	frame_delay		
			bpl.s	.1
			bsr	HandleDemoMode
.1			bsr	dark_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί BEGIN LEVEL2							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

bl2txt1a		dc.w	cp4
			dc.b	pfA,1,14,"THE VIKING ARMY",0
bl2txt1b		dc.w	cp4
			dc.b	pfA,1,16,"INVADED THE ROOKERY",0
bl2txt1c		dc.w	cp4
			dc.b	pfA,1,18,"IN A SAVAGE ATTEMPT",0
bl2txt1d		dc.w	cp4
			dc.b	pfA,1,20,"TO DESTROY THE",0
bl2txt1e		dc.w	cp4
			dc.b	pfA,1,22,"GARGOYLE EGGS, AND",0
bl2txt1f		dc.w	cp4
			dc.b	pfA,1,24,"THE ENTIRE RACE.",0
bl2txt1g		dc.w	cp4
			dc.b	pfA,1,26,"FOR ALL TIME ....",0
			
bl2txt2a		dc.w	cp4
       			dc.b	pfA,1,19,"      LEVEL  2",0
bl2txt2b		dc.w	cp4
			dc.b	pfA,1,21,"SIEGE OF THE ROOKERY",0

			even

BeginL2Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	BeginL2DATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_StoryScreen
			move.w	#$40,PixY_Copy
			lea	ClrBL2Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			lea	bl2txt1a,a1
			bsr	PrintString
			lea	bl2txt1b,a1
			bsr	PrintString
			lea	bl2txt1c,a1
			bsr	PrintString
			lea	bl2txt1d,a1
			bsr	PrintString
			lea	bl2txt1e,a1
			bsr	PrintString
			lea	bl2txt1f,a1
			bsr	PrintString
			lea	bl2txt1g,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang

			lea	ClrBL2Text,a1
			bsr	ClrTextArea

			lea	bl2txt2a,a1
			bsr	PrintString
			lea	bl2txt2b,a1
			bsr	PrintString
			bsr	FadeTextUp
			
			move.w	#3*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			bsr	dark_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί END LEVEL2								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

el2txt1a		dc.w	cp4
			dc.b	pfA,1,2,"THOUGH THE VIKING",0
el2txt1b		dc.w	cp4
			dc.b	pfA,1,4,"ARMY WAS ROUTED,",0
el2txt1c		dc.w	cp4
			dc.b	pfA,1,6,"GOLIATH WAS BLAMED",0
el2txt1d		dc.w	cp4
			dc.b	pfA,1,8,"FOR CASTLE",0
el2txt1e		dc.w	cp4
			dc.b	pfA,1,10,"WYVERN'S",0
el2txt1f		dc.w	cp4
			dc.b	pfA,1,12,"DESTRUCTION.",0

el2txt2a		dc.w	cp4
			dc.b	pfA,1,2,"AS PUNISHMENT, HE",0
el2txt2b		dc.w	cp4
			dc.b	pfA,1,4,"WAS CURSED TO",0
el2txt2c		dc.w	cp4
			dc.b	pfA,1,6,"SLEEP IN STONE",0
el2txt2d		dc.w	cp4
			dc.b	pfA,1,8,"UNTIL THE CASTLE",0
el2txt2e		dc.w	cp4
			dc.b	pfA,1,10,"RESTED ABOVE THE",0
el2txt2f		dc.w	cp4
			dc.b	pfA,1,12,"CLOUDS.",0

el2txt3a		dc.w	cp4
			dc.b	pfA,2,8,"HE WAITS ...",0
			even


EndL2Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	EndL2DATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_StoryScreen
			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade
			
			lea	el2txt1a,a1
			bsr	PrintString
			lea	el2txt1b,a1
			bsr	PrintString
			lea	el2txt1c,a1
			bsr	PrintString
			lea	el2txt1d,a1
			bsr	PrintString
			lea	el2txt1e,a1
			bsr	PrintString
			lea	el2txt1f,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			
			lea	el2txt2a,a1
			bsr	PrintString
			lea	el2txt2b,a1
			bsr	PrintString
			lea	el2txt2c,a1
			bsr	PrintString
			lea	el2txt2d,a1
			bsr	PrintString
			lea	el2txt2e,a1
			bsr	PrintString
			lea	el2txt2f,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang

			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			
			lea	el2txt3a,a1
			move.w	#2*hz5060,TempX
			bsr	DoTextThang
			
			bsr	white_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί BEGIN LEVEL3							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

bl3txt1a		dc.w	cp4
			dc.b	pfA,1,2,"A THOUSAND YEARS",0
bl3txt1b		dc.w	cp4
			dc.b	pfA,1,4,"LATER, CASTLE",0
bl3txt1c		dc.w	cp4
			dc.b	pfA,1,6,"WYVERN WAS REBUILT",0
bl3txt1d		dc.w	cp4
			dc.b	pfA,1,8,"ATOP A SKYSCRAPER",0
bl3txt1e		dc.w	cp4
			dc.b	pfA,1,10,"IN DOWNTOWN",0
bl3txt1f		dc.w	cp4
			dc.b	pfA,1,12,"MANHATTAN ...",0

bl3txt2a		dc.w	cp4
			dc.b	pfA,1,6,"ABOVE THE CLOUDS.",0

bl3txt3a		dc.w	cp4
			dc.b	pfA,1,6,"HE WAITS NO LONGER.",0

bl3txt4a		dc.w	cp4
			dc.b	pfA,2,6,"    LEVEL 3       ",0
bl3txt4b		dc.w	cp4
			dc.b	pfA,2,8,"STONE AND STEEL",0
			even


BeginL3Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	BeginL3DATA,a0
			jsr	GetDATA2
			bsr	SetMapLines				;map line table
			bsr	SetupCharsetA				;setup charset A
			bsr	Clean_DeComRam
			jsr	SetupScrlB
			jsr	SetupScrlA
			move	#$2000,sr				;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			bsr	whitelite_fader
			jsr	wait_fade

			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			
			lea	bl3txt1a,a1
			bsr	PrintString
			lea	bl3txt1b,a1
			bsr	PrintString
			lea	bl3txt1c,a1
			bsr	PrintString
			lea	bl3txt1d,a1
			bsr	PrintString
			lea	bl3txt1e,a1
			bsr	PrintString
			lea	bl3txt1f,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			
			lea	bl3txt2a,a1
			move.w	#1*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			
			lea	bl3txt3a,a1
			move.w	#1*hz5060,TempX
			bsr	DoTextThang
			
			lea	ClrEL2Text,a1
			bsr	ClrTextArea
			
			lea	bl3txt4a,a1
			bsr	PrintString
			lea	bl3txt4b,a1
			bsr	PrintString
			bsr	FadeTextUp

			move.w	#3*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			bsr	dark_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί BEGIN LEVEL5							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

bl5txt1a		dc.w	cp4
			dc.b	pfA,17,7,"THE CURSE WAS LIFTED,",0
bl5txt1b		dc.w	cp4
			dc.b	pfA,17,9,"BUT AN ANCIENT EVIL",0
bl5txt1c		dc.w	cp4
			dc.b	pfA,17,11,"STILL HAUNTS GOLIATH.",0

bl5txt2a		dc.w	cp4
			dc.b	pfA,18,7,"THE EYE OF ODIN HAS",0
bl5txt2b		dc.w	cp4
			dc.b	pfA,18,9,"SURVIVED TO BECOME",0
bl5txt2c		dc.w	cp4
			dc.b	pfA,18,11,"A WEAPON FOR A NEW",0
bl5txt2d		dc.w	cp4
			dc.b	pfA,18,13,"KIND OF ARMY.",0
			
bl5txt3a		dc.w	cp4
			dc.b	pfA,18,9, "      LEVEL 4      ",0
bl5txt3b		dc.w	cp4
			dc.b	pfA,18,11,"SUBTERRANEAN TERROR",0
			even

BeginL5Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	BeginL5DATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_StoryScreen
			move.w	#$10,PixY_Copy+2
			lea	ClrBL5Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade
			
			lea	bl5txt1a,a1
			bsr	PrintString
			lea	bl5txt1b,a1
			bsr	PrintString
			lea	bl5txt1c,a1
			move.w	#2*hz5060,TempX
			bsr	DoTextThang

			lea	ClrBL5Text,a1
			bsr	ClrTextArea

			lea	bl5txt2a,a1
			bsr	PrintString
			lea	bl5txt2b,a1
			bsr	PrintString
			lea	bl5txt2c,a1
			bsr	PrintString
			lea	bl5txt2d,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang

			lea	ClrBL5Text,a1
			bsr	ClrTextArea

			lea	bl5txt3a,a1
			bsr	PrintString
			lea	bl5txt3b,a1
			bsr	PrintString
			bsr	FadeTextUp
			
			move.w	#3*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			bsr	dark_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί BEGIN LEVEL7							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

bl7txt1a		dc.w	cp4
			dc.b	pfA,14,4,"THE PATH TO THE EYE OF",0
bl7txt1b		dc.w	cp4
			dc.b	pfA,15,6,"ODIN LEADS GOLIATH TO",0
bl7txt1c		dc.w	cp4
			dc.b	pfA,16,8,"THE BIRTHPLACE OF THE",0
bl7txt1d		dc.w	cp4
			dc.b	pfA,17,10,"LETHAL ROBOTS THAT",0
bl7txt1e		dc.w	cp4
			dc.b	pfA,18,12,"SWARM THE CITY.",0
		
bl7txt2a		dc.w	cp4
			dc.b	pfA,21,8," LEVEL 5",0
bl7txt2b		dc.w	cp4
			dc.b	pfA,21,10,"THE FORGE",0
			even

BeginL7Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	BeginL7DATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_StoryScreen
			lea	ClrBL7Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade
			
			lea	bl7txt1a,a1
			bsr	PrintString
			lea	bl7txt1b,a1
			bsr	PrintString
			lea	bl7txt1c,a1
			bsr	PrintString
			lea	bl7txt1d,a1
			bsr	PrintString
			lea	bl7txt1e,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang

			lea	ClrBL7Text,a1
			bsr	ClrTextArea
	
			lea	bl7txt2a,a1
			bsr	PrintString
			lea	bl7txt2b,a1
			bsr	PrintString
			bsr	FadeTextUp
			
			move.w	#3*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			bsr	dark_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί MIDDLE LEVEL7							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

ml7txt1a		dc.w	cp4
			dc.b	pfA,2,6,"THE FORCE BEHIND",0
ml7txt1b		dc.w	cp4
			dc.b	pfA,2,8,"THE EVIL ONSLAUGHT",0
ml7txt1c		dc.w	cp4
			dc.b	pfA,2,10,"IS REVEALED :",0
ml7txt1d		dc.w	cp4
			dc.b	pfA,2,14,"DEMONA.",0

ml7txt2a		dc.w	cp4
			dc.b	pfA,2,6,"WITH THE EYE OF",0
ml7txt2b		dc.w	cp4
			dc.b	pfA,2,8,"ODIN IN HER CONTROL",0
ml7txt2c		dc.w	cp4
			dc.b	pfA,2,10,"DEMONA IS NEARLY",0
ml7txt2d		dc.w	cp4
			dc.b	pfA,2,12,"INVINCIBLE.",0

ml7txt3a		dc.w	cp4
			dc.b	pfA,2,6,"BUT GOLIATH KNOWS",0
ml7txt3b		dc.w	cp4
			dc.b	pfA,2,8,"HE MUST STOP HER.",0
ml7txt3c		dc.w	cp4
			dc.b	pfA,2,12,"SOMEHOW.",0
			even
			
MiddleL7Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	MidL7DATA,a0
			bsr	SetupFluffSequence
			jsr	gemsstopall
			MUSIC	_MUS_StoryScreen
			lea	ClrML7Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			lea	ml7txt1a,a1
			bsr	PrintString
			lea	ml7txt1b,a1
			bsr	PrintString
			lea	ml7txt1c,a1
			bsr	PrintString
			lea	ml7txt1d,a1
			bsr	PrintString
			move.w	#4*hz5060,d1
			jsr	frame_delay		

			lea	ClrML7Text,a1
			bsr	ClrTextArea

			lea	ml7txt2a,a1
			bsr	PrintString
			lea	ml7txt2b,a1
			bsr	PrintString
			lea	ml7txt2c,a1
			bsr	PrintString
			lea	ml7txt2d,a1
			bsr	PrintString
			move.w	#4*hz5060,d1
			jsr	frame_delay		

			lea	ClrML7Text,a1
			bsr	ClrTextArea

			lea	ml7txt3a,a1
			bsr	PrintString
			lea	ml7txt3b,a1
			bsr	PrintString
			lea	ml7txt3c,a1
			bsr	PrintString

			move.w	#5*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			bsr	dark_fader
			bra	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί END LEVEL7								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

el7txt1a		dc.w	cp4
			dc.b	pfA,21,13,"DEMONA AND THE",0
el7txt1b		dc.w	cp4
			dc.b	pfA,21,15,"EYE OF ODIN HAVE",0
el7txt1c		dc.w	cp4
			dc.b	pfA,21,17,"BEEN DEFEATED.",0
el7txt1d		dc.w	cp4
			dc.b	pfA,21,19,"EVIL HAS BEEN",0
el7txt1e		dc.w	cp4
			dc.b	pfA,21,21,"VANQUISHED.",0

el7txt2a		dc.w	cp4
			dc.b	pfA,21,13,"AND AN ANCIENT",0
el7txt2b		dc.w	cp4
			dc.b	pfA,21,15,"SENTINEL HAS",0
el7txt2c		dc.w	cp4
			dc.b	pfA,21,17,"BECOME A NEW HERO.",0
			even

EndL7Fluff		bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	EndL7DATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_StoryScreen
			lea	ClrEL7Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			lea	el7txt1a,a1
			bsr	PrintString
			lea	el7txt1b,a1
			bsr	PrintString
			lea	el7txt1c,a1
			bsr	PrintString
			lea	el7txt1d,a1
			bsr	PrintString
			lea	el7txt1e,a1
			move.w	#3*hz5060,TempX
			bsr	DoTextThang
	
			lea	ClrEL7Text,a1
			bsr	ClrTextArea

			lea	el7txt2a,a1
			bsr	PrintString
			lea	el7txt2b,a1
			bsr	PrintString
			lea	el7txt2c,a1
			bsr	PrintString
			bsr	FadeTextUp

			move.w	#4*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			bra	CreditsFluff


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί CREDITS								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

CreditScript		dc.l	ctt1a	
			dc.l	ctt1b	
			dc.l	0	
			dc.l	0
			dc.l	0
			dc.l	ctt2a	
			dc.l	ctt2b	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt3a	
			dc.l	ctt3b	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt4a	
			dc.l	ctt4b	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt5a	
			dc.l	ctt5b	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt6a	
			dc.l	ctt6b	
			dc.l	ctt6c	
			dc.l	ctt6d	
			dc.l	ctt6e	
			dc.l	ctt6f	
			dc.l	ctt6g	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt7a	
			dc.l	ctt7b	
			dc.l	ctt7c	
			dc.l	ctt7d	
			dc.l	ctt7e	
			dc.l	ctt7f	
			dc.l	ctt7g	
			dc.l	ctt7h	
			dc.l	ctt7i	
			dc.l	ctt7j	
			dc.l	ctt7k	
			dc.l	ctt7l	
			dc.l	ctt7m	
			dc.l	ctt7n	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt8a	
			dc.l	ctt8b	
			dc.l	ctt8c	
			dc.l	ctt8d	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt9a	
			dc.l	ctt9b	
			dc.l	ctt9c	
			dc.l	ctt9d	
			dc.l	ctt9e	
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt10a
			dc.l	ctt10b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt10a
			dc.l	ctt11b
			dc.l	ctt11c
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt12a
			dc.l	ctt12b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt13a
			dc.l	ctt13b
			dc.l	ctt13c
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt14a
			dc.l	ctt14b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt15a
			dc.l	ctt15b
			dc.l	0
			dc.l	0
			dc.l	ctt16a
			dc.l	ctt16b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt17c
			dc.l	ctt17d
			dc.l	ctt17e
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt18a
			dc.l	ctt18b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt19a
			dc.l	ctt19b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt20a
			dc.l	ctt20b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt21a
			dc.l	ctt21b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt22a
			dc.l	ctt22b
			dc.l	ctt22c
			dc.l	ctt22d
			dc.l	ctt22e
			dc.l	ctt22f
			dc.l	ctt22g
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt23a
			dc.l	ctt23b
			dc.l	ctt23c
			dc.l	ctt23d
			dc.l	ctt23e
			dc.l	ctt23f
			dc.l	ctt23g
			dc.l	ctt23h
			dc.l	ctt23i
			dc.l	ctt23j
			dc.l	ctt23k
			dc.l	0
			dc.l	0
			dc.l	0   
			dc.l	ctt24a
			dc.l	ctt24b
			dc.l	ctt24c
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt25a
			dc.l	ctt25b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt26a
			dc.l	ctt26b
			dc.l	ctt26c
			dc.l	ctt26d
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt27a
			dc.l	ctt27b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt28a
			dc.l	ctt28b
			dc.l	ctt28c
			dc.l	ctt28d
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt29a
			dc.l	0
			dc.l	0   
			dc.l	ctt30a
			dc.l	ctt30b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt31a
			dc.l	ctt31b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt32a
			dc.l	ctt32b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt33a
			dc.l	ctt33b
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt34a
			dc.l	ctt34b
			dc.l	ctt34c
			dc.l	ctt34d
			dc.l	ctt34e
			dc.l	ctt34f
			dc.l	ctt34g
			dc.l	ctt34h
			dc.l	ctt34i
			dc.l	ctt34j
			dc.l	ctt34k
			dc.l	ctt34l
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt35a
			dc.l	ctt35b
			dc.l	ctt35c
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt36a
			dc.l	ctt36b
			dc.l	ctt36c
			dc.l	ctt36d
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	ctt37a
			dc.l	ctt37b
			dc.l	ctt37c
			dc.l	ctt37d
			dc.l	ctt37e
			dc.l	ctt37f
			dc.l	ctt37g
			dc.l	ctt37h
			dc.l	ctt37i
			dc.l	ctt37j
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	0
			dc.l	-1


ScreenWidth		equ	26

CreditsFluff		bsr	dark_fader
			bsr	wait_fade
			
			bsr	SetupShell
    			st.b	working
    			clr.b	service
			
			lea	Font8x8CHR,a0		;compressed chr data
			move.w	#Alpha_VRAM,d6		;DMA Char data
			bsr	BlitCharset_nv
			
			lea	IntroDATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_Titlepage
			clr.l	PixX_Copy
			clr.l	PixY_Copy
			MUSIC	_MUS_Titlepage
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade
			
			move.w	#$aaa,Pal3+28
			move.w	#$444,Pal3+30
			move.w	#$eee,Pal4+28
			move.w	#$666,Pal4+30
			
			move.w	#30,TempY
			clr.w	CreditDex

.credit_loop		jsr	WaitFrm
			jsr	WaitFrm
			jsr	WaitFrm
			jsr	WaitFrm

			addq.w	#1,PixY_Copy
			move.w	PixY_Copy,d1
			and.w	#7,d1
			bne.s	.credit_loop

			moveq	#0,d1				;zero denotes a blank line so lets clr it
			moveq	#0,d2
			move.w	TempY,d3			;y pos		
			asl.w	#1,d3
			lea	yybase,a1    			;screen line table
			move.w	0(a1,d3.w),d6
			jsr	GetScreenAddrs			;get screen vram address
			moveq	#39,d1				;clr 40 chars
.cl1			move.w	#0,vdata
			dbra	d1,.cl1
			
			lea	CreditScript,a1
			move.w	CreditDex,d1
			move.l	0(a1,d1.w),a2
			cmp.l	#0,a2
			beq	.nxt
			cmp.l	#-1,a2
			beq	.finito
			
			moveq	#0,d2				;get length of sentence
			move.l	a2,a3
.l1			tst.b	(a2)+
			beq.s	.v2
			bmi.s	.l1
			addq.b	#1,d2
			bra	.l1
.v2			move.w	#ScreenWidth,d1			;get the width of text area
			sub.w	d2,d1				;subtract the sentence length
			lsr.w	#1,d1				;devide by 2 and bingo, we get the tab to center it
			add.w	#41-ScreenWidth,d1
			moveq	#0,d2
			move.w	TempY,d3			;y pos		
			asl.w	#1,d3
			lea	yybase,a1    			;screen line table
			move.w	0(a1,d3.w),d6
			jsr	GetScreenAddrs			;get screen vram address
			
.l2			moveq	#0,d2
			move.b	(a3)+,d2
			bpl.s	.v3
   			move.w	#cp3,d3
			cmp.b	#-1,d2
			beq.s	.l2
   			move.w	#cp4,d3
			bra.s	.l2
.v3			beq.s	.nxt
			sub.w	#$1f,d2
			add.w	#Alpha_Base+$8000,d2
			add.w	d3,d2
			move.w	d2,vdata
			bra	.l2			

.nxt			addq.w	#1,TempY
			and.w	#$1f,TempY
			add.w	#4,CreditDex
			bra	.credit_loop

.finito			bsr	dark_fader
			bsr	wait_fade
			bra	ColdResetTheGame


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί NULL								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

NullFluff		rts

; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί SEGA SCREEN								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

SegaFluff		bsr	SetupShell
			
			moveq	#0,d6
			move.w	#$1068/2,d0
			lea	SegaLogoCHR,a0		;compressed chr data
			jsr	dma_data

			move.l	#ScrlB_Base,d6		;screen base address
			moveq	#12,d1			;x,y screen pos
			moveq	#10,d2
			bsr	GetScreenAddrs		;calc screen address
			lea	SegaLogoMAP,a0		;logo map
			moveq	#11,d0			;width
			moveq	#3,d1			;height
			moveq	#0,d4			;add
			bsr	windowblock		;print block to screen

			move.w	#$10,PixX_Copy+2	;position it
	
			clr.b	working
			st.b	service
			clr.b	joy1
			clr.b	d_joy1
			move	#$2000,sr		;enable irq
			
			lea	SegaLogoPAL,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			moveq	#$28,d7
SegaLogoLOOP		jsr	WaitFrm	 		;cycle the sega logo
			jsr	WaitFrm
			lea	Pal1+4,a1
			lea	SegaLogoCYCLE(pc,d7),a0
			moveq	#11-1,d0
SegaLogoCRAM		move.w	(a0)+,(a1)+
			dbra	d0,SegaLogoCRAM
			subq.w	#2,d7
			bpl.s	SegaLogoLOOP

			move.w	#3*hz5060,d1		;wait 5 secs
			jsr	frame_delay2		
			jsr	dark_fader		;fade
			jmp	wait_fade

SegaLogoCYCLE		DC.W	$EC0,$EA0,$E80,$E60,$E40,$E20,$E00,$C00
			DC.W	$A00,$800,$600,$800,$A00,$C00,$E00,$E20
			DC.W	$E40,$E60,$E80,$EA0,$EC0,$EA0,$E80,$E60
			DC.W	$E40,$E20,$E00,$C00,$A00,$800,$600
		
SegaLogoPAL		DC.W	$000,$eee
			DC.W	$ec0,$ea0,$e80,$e60,$e40,$e20,$e00,$c00
			DC.W	$a00,$800,$600,$800,$a00,$c00,$e00,$e20
			DC.W	$e40,$e60,$e80,$ea0,$ec0,$ea0,$e80,$e60
			DC.W	$e40,$e20,$e00,$c00,$a00,$800,$600
			ds.w	31

SegaLogoMAP		DC.W	1,2,3,4,5,6,7,8,9,10,11,12
			DC.W	13,14,15,16,17,18,19,20,21,22,23,24
			DC.W	25,26,27,28,29,30,31,32,33,34,35,36
			DC.W	37,38,39,40,41,42,43,44,45,46,47,48	
				       


windowblock		move.w	d0,d2			;dma a block x,y
.l1			move.w	(a0)+,d3
			add.w	d4,d3
			move.w	d3,vdata
			dbra	d2,.l1
			add.w	#128,d6
			jsr	get_address
			move.l	d7,vctrl
			dbra	d1,windowblock
			rts


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί DISNEY/BUENA VISTA SCREEN						   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

DisneyFluff		bsr	SetupShell
			
			lea	DisneyLogoCHR,a0	;compressed chr data
			bsr	BlitCharset

			lea	DisneyLogoMAP,a0	;compressed chr data
			lea	MapA_Buff,a1		;destination buffer
			jsr	DecompressSWD		;decompress data
			move.l	#ScrlB_Base,d6
			moveq	#0,d1			;print the logo to screen
			moveq	#0,d2
			bsr	GetScreenAddrs
			lea	MapA_Buff,a0
			moveq	#39,d0
			moveq	#25,d1
			moveq	#0,d4
			bsr	windowblock

			move.w	#4,PixX_Copy+2		;position it
			move.w	#-$20,PixY_Copy
			move.w	#-$20,PixY_Copy+2
			
			clr.b	working
			st.b	service
			clr.b	joy1
			clr.b	d_joy1
			move	#$2000,sr		;enable irq
			
			lea	DisneyLogoPAL,a1	;fade
			jsr	lite_fader
			jsr	wait_fade

			move.w	#3*hz5060,d1		;wait 5 secs
			jsr	frame_delay		
			jsr	dark_fader		;fade
			jmp	wait_fade


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί TITLEPAGE 								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

ttxt1			dc.w	cp4
			dc.b	pfA,5,15,"BUILD - \#_month/\#_day/\#_year AT \#_hours:\#_minutes",0
op1			dc.w	cp4
			dc.b	pfA,16,16," START",0
op2			dc.w	cp4
			dc.b	pfA,16,18,"OPTIONS",0
op1a			dc.w	cp3
			dc.b	pfA,16,16," START",0
op2a			dc.w	cp3
			dc.b	pfA,16,18,"OPTIONS",0
ctxt1			dc.w	cp4
			dc.b	pfA,3,24," (C)1995 BUENA VISTA INTERACTIVE",0
ctxt2			dc.w	cp4
			dc.b	pfA,3,25,"LICENSED BY SEGA ENTERPRISES, LTD.",0
			even

TitlepageFluff		bsr	SetupShell
			st.b	working
			clr.b	service

			lea	Font8x8CHR,a0		;compressed chr data
			move.w	#Alpha_VRAM,d6		;DMA Char data
			bsr	BlitCharset_nv
						
			lea	TitlesDATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_Titlepage
			lea	AMAP_FLAME10_START,a2
			jsr	SetupCharAnim						
			lea	AMAP_FLAME20_START,a2
			jsr	SetupCharAnim						
			move.b	#1,CH_AnCnt(a1)	
			if	diplay_build
			lea	ttxt1,a1
			bsr	PrintString
			endif
			clr.b	TitSelDex
			bsr	PrintStartOption
			lea	ctxt1,a1
			bsr	PrintString
			lea	ctxt2,a1
			bsr	PrintString
			clr.b	PulsateDLY
			clr.b	PulsateDEX1
			move.w	#10*hz5060,demo_timeout
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

Tselloop		bsr	WaitFrm
			bsr	PulsateText
			
			subq.w	#1,demo_timeout
			bne.s	Tn1
			moveq	#0,d1
			move.b	DemoIndex,d1
			addq.b	#1,DemoIndex
			asl.w	#1,d1
			move.w	DemoLev(pc,d1.w),levnum
			asl.w	#1,d1
			move.l	DemoTab(pc,d1.w),demo_data
			clr.w	record_dex
			st.b	demo_mode
			bsr	SetLives
			jsr	dark_fader				;fade
			jsr	wait_fade
			bsr	ClrScrlA
			bra	ClrScrlB

DemoLev			dc.w	Level13,Level22,Level32,Level51
DemoTab			dc.l	Demo1,Demo2,Demo3,Demo4

Tn1			btst.b	#up,d_joy1
			bne	.updown
			btst.b	#down,d_joy1
			bne	.updown
			btst.b	#start,d_joy1
			beq	Tselloop

.start			tst.b	TitSelDex
			beq.s	.stok
     			bra	OptionsFluff

.stok			move.l	#_MUS_Titlepage,d0
			jsr	StopMusic
			move.w	new_level,levnum
			move.w	levnum,d1				;convert starting level 
			lea	GF_LevnumConvTAB,a1			
			move.b	0(a1,d1.w),d1
			lea	GF_StartPosTAB,a1			;into the start index into the 
			move.w	0(a1,d1.w),GameFlowINDEX		;game flow script
			bsr	SetDifficulty
			bsr	SetController
			clr.b	demo_mode
			jsr	dark_fader				;fade
			jsr	wait_fade
			bsr	ClrScrlA
			bra	ClrScrlB
			
.updown			eor.b	#1,TitSelDex
			move.w	#10*hz5060,demo_timeout
			bsr	PrintStartOption
			bra	Tselloop


PulsateTab		dc.w	$000,$222,$444,$666,$888,$aaa,$ccc,$eee,$ccc,$aaa,$888,$666,$444,$222,-1
PulsateTab2		dc.w	$000,$000,$000,$222,$222,$222,$444,$444,$444,$222,$222,$222,$000,$000,-1

PulsateText		lea	PulsateTab,a1
			lea	PulsateTab2,a2
			
			addq.b	#1,PulsateDLY
			and.b	#3,PulsateDLY
			bne.s	.1
			addq.b	#2,PulsateDEX1
			
.1			moveq	#0,d1
			move.b	PulsateDEX1,d1
			move.w	0(a1,d1.w),d3
			move.w	0(a2,d1.w),d4
			cmp.w	#-1,d3
			bne.s	.ok1
			clr.b	PulsateDEX1
			bra	.1
.ok1			move.w	d3,Pal3+28
			move.w	d4,Pal3+30
			rts

				
WaveFire		move.w	pix_y,d1
			swap	d1
			move.w	pix_y,d1
			lsr.w	#1,d1
			bsr	serv_scrl_ab_y
			
			bra	copy_b_fxs
   				

pfA			equ	0		;playfield A
pfB			equ	1		;playfield B
pfC			equ	2		;Custom


PrintStartOption	tst.b	TitSelDex
			beq.s	.1
			lea	op1,a1
			bsr	PrintString
			lea	op2a,a1
			bra	PrintString
.1			lea	op1a,a1
			bsr	PrintString
			lea	op2,a1
			bra	PrintString
	

PrintString		move.w	(a1)+,d5
			move.b	(a1)+,d1
			bmi.s	.loop
			beq.s	.1
			cmp.b	#1,d1
			bne.s	.3
.2			move.l	#ScrlB_Base,d6
			bra	.3
.1			move.l	#ScrlA_Base,d6
.3			move.b	(a1)+,d1		;x
			move.b	(a1)+,d2		;y
			ext.w	d1
			ext.w	d2
			bsr	GetScreenAddrs

.loop			move.b	(a1)+,d1
			ext.w	d1
			beq.s	.fin
			sub.w	#$1f,d1
			add.w	#Alpha_Base+$8000,d1
			add.w	d5,d1
			move.w	d1,vdata
			bra	.loop
.fin			rts

PrintLevTxt		lea	lttab,a1
			move.w	new_level,d1
			asl.w	#2,d1
			move.l	0(a1,d1.w),a1
			bra	PrintString


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί OPTIONS SCREEN							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

lttab			dc.l	l1p1t,l1p2t,l1p3t,l1p4t
			dc.l	l2p1t,l2p2t,l2p3t,l2p4t
			dc.l	l3p1t,l3p2t,l3p3t,l3p4t
			dc.l	l4p1t,l4p2t,l4p3t,l4p4t
			dc.l	l5p1t
			dc.l	l6p1t,l6p2t,l6p3t,l6p4t
			dc.l	l7p1t,l7p2t,l7p3t,l7p4t,l7p5t,l7p6t,l7p7t

l1p1t			dc.w	cp4
			dc.b	pfA,17,22,"L1:M1 - CASTLE #1	           ",0
l1p2t			dc.w	cp4
			dc.b	pfA,17,22,"L1:M2 - CASTLE #2	           ",0
l1p3t			dc.w	cp4
			dc.b	pfA,17,22,"L1:M3 - CASTLE #3	           ",0
l1p4t			dc.w	cp4
			dc.b	pfA,17,22,"L1:M4 - CASTLE BOSS	           ",0

l2p1t			dc.w	cp4
			dc.b	pfA,17,22,"L2:M1 - ROOKERY #1               ",0
l2p2t			dc.w	cp4
			dc.b	pfA,17,22,"L2:M2 - ROOKERY #2               ",0
l2p3t			dc.w	cp4
			dc.b	pfA,17,22,"L2:M3 - ROOKERY #3               ",0
l2p4t			dc.w	cp4
			dc.b	pfA,17,22,"L2:M4 - ROOKERY BOSS             ",0

l3p1t			dc.w	cp4
			dc.b	pfA,17,22,"L3:M1 - ROOFTOPS #1              ",0
l3p2t			dc.w	cp4
			dc.b	pfA,17,22,"L3:M2 - ROOFTOPS #2              ",0
l3p3t			dc.w	cp4
			dc.b	pfA,17,22,"L3:M3 - ROOFTOPS #3              ",0
l3p4t			dc.w	cp4
			dc.b	pfA,17,22,"L3:M4 - ROOFTOPS BOSS            ",0

l4p1t			dc.w	cp4
			dc.b	pfA,17,22,"L4:M1 - NULL                    ",0
l4p2t			dc.w	cp4
			dc.b	pfA,17,22,"L4:M2 - NULL                    ",0
l4p3t			dc.w	cp4
			dc.b	pfA,17,22,"L4:M3 - NULL	                   ",0
l4p4t			dc.w	cp4
			dc.b	pfA,17,22,"L4:M4 - NULL	                   ",0

l5p1t			dc.w	cp4
			dc.b	pfA,17,22,"L5:M1 - SUBWAY                   ",0

l6p1t			dc.w	cp4
			dc.b	pfA,17,22,"L6:M1 - NULL		           ",0
l6p2t			dc.w	cp4
			dc.b	pfA,17,22,"L6:M2 - NULL		           ",0
l6p3t			dc.w	cp4
			dc.b	pfA,17,22,"L6:M3 - NULL		           ",0
l6p4t			dc.w	cp4
			dc.b	pfA,17,22,"L6:M4 - NULL	       		   ",0

l7p1t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M1 - FORGE #1                 ",0
l7p2t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M2 - FORGE #2                 ",0
l7p3t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M3 - FORGE #3                 ",0
l7p4t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M4 - FORGE #4                 ",0
l7p5t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M5 - FORGE #5                 ",0
l7p6t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M6 - NULL                     ",0
l7p7t			dc.w	cp4
			dc.b	pfA,17,22,"L7:M7 - FORGE BOSS               ",0


optxt1			dc.w	cp4
			dc.b	pfA,21,2,"OPTIONS",0

optxt2			dc.w	cp4
			dc.b	pfA,17,5,"DIFFICULTY :",0
optxt3			dc.w	cp4
			dc.b	pfA,17,7,"SOUND :",0
optxt4			dc.w	cp4
			dc.b	pfA,17,9,"MUSIC :",0
optxt5			dc.w	cp4
			dc.b	pfA,17,11,"SOUND TEST :",0
optxt6			dc.w	cp4
			dc.b	pfA,17,13,"CONTROLS :",0
optxt7			dc.w	cp4
			dc.b	pfA,17,19,"EXIT",0

optxt2a			dc.w	cp3
			dc.b	pfA,17,5,"DIFFICULTY :",0
optxt3a			dc.w	cp3
			dc.b	pfA,17,7,"SOUND :",0
optxt4a			dc.w	cp3
			dc.b	pfA,17,9,"MUSIC :",0
optxt5a			dc.w	cp3
			dc.b	pfA,17,11,"SOUND TEST :",0
optxt6a			dc.w	cp3
			dc.b	pfA,17,13,"CONTROLS :",0
optxt7a			dc.w	cp3
			dc.b	pfA,17,19,"EXIT",0

ctxt1a			dc.w	cp4
			dc.b	pfA,22,15,"A = THROW     ",0
ctxt1b			dc.w	cp4
			dc.b	pfA,22,16,"B = CLAW/SLASH",0
ctxt1c			dc.w	cp4
			dc.b	pfA,22,17,"C = JUMP/FLAP ",0
ctxt2a			dc.w	cp4
			dc.b	pfA,22,15,"A = THROW     ",0
ctxt2b			dc.w	cp4
			dc.b	pfA,22,16,"B = JUMP/FLAP ",0
ctxt2c			dc.w	cp4
			dc.b	pfA,22,17,"C = CLAW/SLASH",0
ctxt3a			dc.w	cp4
			dc.b	pfA,22,15,"A = CLAW/SLASH",0
ctxt3b			dc.w	cp4
			dc.b	pfA,22,16,"B = THROW     ",0
ctxt3c			dc.w	cp4
			dc.b	pfA,22,17,"C = JUMP/FLAP ",0
ctxt4a			dc.w	cp4
			dc.b	pfA,22,15,"A = CLAW/SLASH",0
ctxt4b			dc.w	cp4
			dc.b	pfA,22,16,"B = JUMP/FLAP ",0
ctxt4c			dc.w	cp4
			dc.b	pfA,22,17,"C = THROW     ",0
ctxt5a			dc.w	cp4
			dc.b	pfA,22,15,"A = JUMP/FLAP ",0
ctxt5b			dc.w	cp4
			dc.b	pfA,22,16,"B = THROW     ",0
ctxt5c			dc.w	cp4
			dc.b	pfA,22,17,"C = CLAW/SLASH",0
ctxt6a			dc.w	cp4
			dc.b	pfA,22,15,"A = JUMP/FLAP ",0
ctxt6b			dc.w	cp4
			dc.b	pfA,22,16,"B = CLAW/SLASH",0
ctxt6c			dc.w	cp4
			dc.b	pfA,22,17,"C = THROW     ",0


ontxt			dc.w	cp4
			dc.b	pfA,25,7,"ON ",0
offtxt			dc.w	cp4
			dc.b	pfA,25,7,"OFF",0
ontxt2			dc.w	cp4
			dc.b	pfA,25,9,"ON ",0
offtxt2			dc.w	cp4
			dc.b	pfA,25,9,"OFF",0

diftxt1			dc.w	cp4
			dc.b	pfA,30,5,"EASY  ",0
diftxt2			dc.w	cp4
			dc.b	pfA,30,5,"NORMAL",0
diftxt3			dc.w	cp4
			dc.b	pfA,30,5,"HARD  ",0

			even


OptionsFluff		bsr	dark_fader
			bsr	wait_fade
			
			bsr	SetupShell
			st.b	working
			clr.b	service
			
			move.w	#HorLineScroll!VerCellScroll,d0
			bsr	SetScroll
			clr.b	FullScroll_Hor
			clr.b	FullScroll_Ver
			
			lea	OptionsDATA,a0
			bsr	SetupFluffSequence
			lea	optxt1,a1
			jsr	PrintString
			move.b	#5,OptSelDex
			clr.w	new_level
			clr.b	SoundTestSEQ
			bsr	PrintOptionsText
			bsr	PrintOptionsSel
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

.selloop		bsr	WaitFrm
			bsr	PulsateText
		
			btst.b	#up,d_joy1
			bne	.up
			btst.b	#down,d_joy1
			bne	.down
			btst.b	#left,d_joy1
			bne	.left
			btst.b	#right,d_joy1
			bne	.right
.o2			btst.b	#start,d_joy1
			beq.s	.selloop


.start			cmp.b	#3,OptSelDex
			bne.s	.1
  			jsr	gemsstopall
			moveq	#0,d1
			move.b	SoundTestSEQ,d1
			asl.w	#2,d1
			lea	SoundTestTab,a1
			move.l	0(a1,d1.w),sfx_poll
			jsr	SetSFX
			bra	.selloop

.1			cmp.b	#5,OptSelDex
			bne	.selloop
			cmp.w	#Level41,new_level
			beq	.selloop
			cmp.w	#Level42,new_level
			beq	.selloop
			cmp.w	#Level43,new_level
			beq	.selloop
			cmp.w	#Level44,new_level
			beq	.selloop
			cmp.w	#Level61,new_level
			beq	.selloop
			cmp.w	#Level62,new_level
			beq	.selloop
			cmp.w	#Level63,new_level
			beq	.selloop
			cmp.w	#Level64,new_level
			beq	.selloop
			cmp.w	#Level76,new_level
			beq	.selloop

.s2			jsr	gemsstopall
			move.l	#-1,last_music
			bsr	SetDifficulty
			bsr	SetController
			bsr	dark_fader
			bsr	wait_fade
			bra	TitlepageFluff

.up			tst.b	OptSelDex
			bne.s	.u1
			move.b	#5,OptSelDex
			bra	.u2
.u1			subq.b	#1,OptSelDex
.u2			bsr	PrintOptionsText	
			bra	.selloop	

.down			cmp.b	#5,OptSelDex
			bne.s	.d1
			clr.b	OptSelDex
			bra	.d2
.d1			addq.b	#1,OptSelDex
.d2			bsr	PrintOptionsText	
			bra	.selloop	

.left			moveq	#0,d1
			move.b	OptSelDex,d1
			asl.w	#2,d1
			jsr	.leftjumptab(pc,d1.w)
			bra	.o1
.leftjumptab		bra	L_Difficulty
			bra	LR_Sound
			bra	LR_Music
			bra	L_SoundTest
			bra	L_Controls
			bra	L_Levels
.right			moveq	#0,d1
			move.b	OptSelDex,d1
			asl.w	#2,d1
			jsr	.rightjumptab(pc,d1.w)
			bra	.o1
.rightjumptab		bra	R_Difficulty
			bra	LR_Sound
			bra	LR_Music
			bra	R_SoundTest
			bra	R_Controls
			bra	R_Levels
.o1			bsr	PrintOptionsSel
			bra	.selloop

L_Difficulty		tst.b	difficulty
			bne.s	.1
			move.b	#2,difficulty
			rts
.1			subq.b	#1,difficulty
			rts
R_Difficulty		cmp.b	#2,difficulty
			bne.s	.1
			clr.b	difficulty
			rts
.1			addq.b	#1,difficulty
			rts

LR_Sound		eor.b	#1,SoundFLG
			rts
LR_Music		eor.b	#1,MusicFLG
			rts

R_SoundTest		cmp.b	#MaxSoundSEQ,SoundTestSEQ
			bne.s	.1
			clr.b	SoundTestSEQ
			rts
.1			addq.b	#1,SoundTestSEQ
			rts
L_SoundTest		tst.b	SoundTestSEQ
			bne.s	.1
			move.b	#MaxSoundSEQ,SoundTestSEQ
			rts
.1			subq.b	#1,SoundTestSEQ
			rts

L_Controls		tst.b	controller
			bne.s	.1
			move.b	#5,controller
			rts
.1			subq.b	#1,controller
			rts
R_Controls		cmp.b	#5,controller
			bne.s	.1
			clr.b	controller
			rts
.1			addq.b	#1,controller
			rts

R_Levels		if	level_select
			cmp.w	#MaxLevs-1,new_level
			bne.s	.1
			clr.w	new_level
			rts
.1			addq.w	#1,new_level
			rts
			else
			rts
			endif
L_Levels		if	level_select
			tst.w	new_level
			bne.s	.1
			move.w	#MaxLevs-1,new_level
			rts
.1			subq.w	#1,new_level
			rts
			else
			rts
			endif


MaxSoundSEQ		equ	10

SoundTestTab		dc.l	_MUS_Boss,_MUS_GameOver,_MUS_Hammer,_MUS_Titlepage,_MUS_Castle
			dc.l	_MUS_Rookery,_MUS_Rooftops,_MUS_Subway,_MUS_Forge,_MUS_StoryScreen,_MUS_Continue


; --------------------------------------------------------------------------

SetDifficulty		tst.b	difficulty
			beq.s	.easy
			cmp.b	#1,difficulty
			beq.s	.norm
.hard			move.b	#3,lives
			move.b	#0,continues
			rts
.norm			move.b	#5,lives
			move.b	#1,continues
			rts
.easy			move.b	#7,lives
			move.b	#3,continues
			rts

SetLives		tst.b	difficulty
			beq.s	.easy
			cmp.b	#1,difficulty
			beq.s	.norm
.hard			move.b	#3,lives
			rts
.norm			move.b	#5,lives
			rts
.easy			move.b	#7,lives
			rts

			;button_a     b     c
cdatatab		dc.b	but_c,but_b,but_a,0
			dc.b	but_b,but_c,but_a,0
			dc.b	but_c,but_a,but_b,0
			dc.b	but_b,but_a,but_c,0
			dc.b	but_a,but_c,but_b,0
			dc.b	but_a,but_b,but_c,0


SetController		moveq	#0,d1
			move.b	controller,d1
			asl.w	#2,d1
			move.b	cdatatab(pc,d1.w),button_a
			move.b	cdatatab+1(pc,d1.w),button_b
			move.b	cdatatab+2(pc,d1.w),button_c
			rts


; --------------------------------------------------------------------------
; --------------------------------------------------------------------------
						
optxttab		dc.l	optxt2,optxt3,optxt4,optxt5,optxt6,optxt7
optxttaba		dc.l	optxt2a,optxt3a,optxt4a,optxt5a,optxt6a,optxt7a

PrintOptionsText	lea	optxttab,a2
			lea	optxttaba,a3

			moveq	#6,d1
.l1			move.l	d1,-(sp)
			move.w	d1,d2
			asl.w	#2,d2
			cmp.b	OptSelDex,d1
			bne.s	.n
			move.l	0(a3,d2.w),a1
			bra	.o1
.n			move.l	0(a2,d2.w),a1
.o1			bsr	PrintString
			move.l	(sp)+,d1
			dbra	d1,.l1
			rts
	
ctxttab			dc.l	ctxt1a,ctxt1b,ctxt1c,0
			dc.l	ctxt2a,ctxt2b,ctxt2c,0
			dc.l	ctxt3a,ctxt3b,ctxt3c,0
			dc.l	ctxt4a,ctxt4b,ctxt4c,0
			dc.l	ctxt5a,ctxt5b,ctxt5c,0
			dc.l	ctxt6a,ctxt6b,ctxt6c,0

diftxttab		dc.l	diftxt1,diftxt2,diftxt3

PrintOptionsSel		moveq	#0,d1
			move.b	difficulty,d1
			asl.w	#2,d1
			move.l	diftxttab(pc,d1.w),a1
			jsr	PrintString
		
			tst.b	SoundFLG
			beq.s	.soff
			lea	ontxt,a1
			bra	.o2
.soff			lea	offtxt,a1
.o2			jsr	PrintString
			
			tst.b	MusicFLG
			beq.s	.moff
			lea	ontxt2,a1
			bra	.o1
.moff			lea	offtxt2,a1
.o1			jsr	PrintString			
			
			move.l	#ScrlA_Base+((30*2)+(11*128)),d6
			moveq	#1,d4
			move.b	SoundTestSEQ,d5
			bsr	c_byte
;			bsr	hex_print_b
			
			moveq	#0,d4
			move.b	controller,d4
			asl.w	#4,d4
			lea	ctxttab,a2
			move.l	0(a2,d4.w),a1
			jsr	PrintString
			move.l	4(a2,d4.w),a1
			jsr	PrintString
			move.l	8(a2,d4.w),a1

			if	level_select
			jsr	PrintString
			move.w	new_level,d1
			asl.w	#2,d1
			lea	lttab,a1
			move.l	0(a1,d1.w),a1
			jmp	PrintString		
			else
			jmp	PrintString
			endif


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί CONTINUE SCREEN							   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

ContinueFluff		bsr	dark_fader
			bsr	wait_fade
			
			bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	ContinueDATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_Continue
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			jsr	SetupGoliath
			st.b	NoFollowFLG
			bset.b	#ob_noclip,OB_Flag1(a0)
			bset.b	#ob_setup,OB_Flag2(a0)
			move.w	#$b0,OB_Xpos(a0)
			move.w	#0,OB_Ypos(a0)
			clr.w	OB_Var1(a0)
			clr.w	OB_Var2(a0)
			move.w	#GolContinueSTATE,OB_State(a0)
			lea	GolFallANM,a1
			bsr	SetNewAnim
			bsr	ForceNewAnim

			clr.b	GolContinueFLG
.wait			tst.b	GolContinueFLG
			beq.s	.wait
			bpl.s	.no
			bsr	SetLives
			st.b	UpdateLivesFLG
			cmp.w	#Level51,levnum				;handle subway inside\outside 
			bne.s	.oo1					;re-starting
   			clr.b	PlayingPREBOSS
			st.b	InsideFLG
.oo1			jmp	PDboss				;resurrect
.no			st.b	GameOverFLG
			bra	MainLoop


; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί GAME OVER								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

gotxt1a			dc.w	cp4
			dc.b	pfA,20,10,"GOLIATH  HAS",0
gotxt1b			dc.w	cp4
			dc.b	pfA,20,12,"    LOST    ",0
			even

GameOverFluff		bsr	dark_fader
			bsr	wait_fade
			
			bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	YouLoseDATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_Hammer
			lea	ClrBL1Text,a1
			bsr	ClrTextArea
			move	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			lea	gotxt1a,a1
			bsr	PrintString
			lea	gotxt1b,a1
			bsr	PrintString
			bsr	FadeTextUp

			move.w	#4*hz5060,d1		;wait 5 secs
			jsr	frame_delay2		
			jsr	dark_fader		;fade
			jsr	wait_fade
			bra	FlagYES



; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί JOELS HELLO								   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

jhtxt1a			dc.w	cp4
			dc.b	pfA,2,14,"JOEL SAYS HELLO TO MOLLIE GORDON,",0
jhtxt1b			dc.w	cp4
			dc.b	pfA,2,15,"MELANIE MCCOY, CHUCK GOODSELL,",0
jhtxt1c			dc.w	cp4
			dc.b	pfA,2,16,"JESSE GOODSELL, CHRIS THE GOD",0
jhtxt1d			dc.w	cp4
			dc.b	pfA,2,17,"SHRIGLEY, PATCHES THE SOUND MASTER",0
jhtxt1e			dc.w	cp4
			dc.b	pfA,2,18,"COLLINS, TOM MAGIC IS MERELY ILLUSION",0
jhtxt1f			dc.w	cp4
			dc.b	pfA,2,19,"BREEDEN, JODY NOT THE CASTLE AGAIN",0
jhtxt1g			dc.w	cp4
			dc.b	pfA,2,20,"MCMURRIAN, BRIAN THE RENDER KING",0
jhtxt1h			dc.w	cp4
			dc.b	pfA,2,21,"HORTON, THE BUG BUSTERS MARCUS AND",0
jhtxt1i			dc.w	cp4
			dc.b	pfA,2,22,"SHANE, REDBIRD AND THE CHEROKEE",0
jhtxt1j			dc.w	cp4
			dc.b	pfA,2,23,"NATION, THE USN, TORI AMOS, AND",0
jhtxt1k			dc.w	cp4
			dc.b	pfA,2,24,"THE DANGERMAN.",0


JoelHelloFluff		bsr	dark_fader
			bsr	wait_fade
			
			bsr	SetupShell
			st.b	working
			clr.b	service
			
			lea	TitlesDATA,a0
			bsr	SetupFluffSequence
			MUSIC	_MUS_Boss
			lea	jhtxt1a,a1
			bsr	PrintString
			lea	jhtxt1b,a1
			bsr	PrintString
			lea	jhtxt1c,a1
			bsr	PrintString
			lea	jhtxt1d,a1
			bsr	PrintString
			lea	jhtxt1e,a1
			bsr	PrintString
			lea	jhtxt1f,a1
			bsr	PrintString
			lea	jhtxt1g,a1
			bsr	PrintString
			lea	jhtxt1h,a1
			bsr	PrintString
			lea	jhtxt1i,a1
			bsr	PrintString
			lea	jhtxt1j,a1
			bsr	PrintString
			lea	jhtxt1k,a1
			bsr	PrintString
			
			lea	AMAP_FLAME10_START,a2
			jsr	SetupCharAnim						
			lea	AMAP_FLAME20_START,a2
			jsr	SetupCharAnim						
			
			move.w	#$2000,sr		;enable irq
			st.b	service			
			lea	GamePalette,a1		;fade
			jsr	lite_fader
			jsr	wait_fade

			move.w	#$aaa,Pal3+28
			move.w	#$444,Pal3+30
			move.w	#$eee,Pal4+28
			move.w	#$666,Pal4+30
						
.1a			jsr	WaitFrm
			cmp.b	#$f0,joy1
			bne.s	.1a
			jmp	ColdResetTheGame


; --------------------------------------------------------------------------
; --------------------------------------------------------------------------

GF_FadeOut		equ	1
GF_FadeWhite		equ	2
GF_NewLevel		equ	3
GF_Restart		equ	4
GF_FadeIn		equ	5
GF_StartLevel		equ	6
GF_Fluff		equ	7

GFS			macro 
			if	\1=GF_FadeOut
			dc.w	\1			;GF_FadeOut
			elseif	\1=GF_FadeWhite	
			dc.w	\1			;GF_FadeWhite
			elseif	\1=GF_NewLevel	
			dc.w	\1			;GF_NewLevel
			dc.w	\2			;new level #
			elseif	\1=GF_Restart
			dc.w	\1			;GF_Restart
			elseif	\1=GF_FadeIn
			dc.w	\1			;GF_FadeIn
			elseif	\1=GF_StartLevel
			dc.w	\1			;GF_StartLevel
			elseif	\1=GF_Fluff
			dc.w	\1			;GF_Fluff
			dc.w	\2			;fluff sequence #
			endif
			endm
	   
GF_LevnumConvTAB	dc.b	0			;level11
 			dc.b	2			;level12
 			dc.b	4			;level13
 			dc.b	6			;level14
 			dc.b	8			;level21
 			dc.b	10			;level22
 			dc.b	12			;level23
 			dc.b	14			;level24
 			dc.b	16			;level31
 			dc.b	18			;level32
 			dc.b	20			;level33
 			dc.b	22			;level34
 			dc.b	2			;cut
 			dc.b	2			;cut
 			dc.b	2			;cut
 			dc.b	2			;cut
 			dc.b	24			;level51
 			dc.b	2			;cut
 			dc.b	2			;cut
 			dc.b	2			;cut
 			dc.b	2			;cut
 			dc.b	26			;level71
 			dc.b	28			;level72
 			dc.b	30			;level73
 			dc.b	32			;level74
 			dc.b	34			;level75
 			dc.b	2			;level76
 			dc.b	36			;level77

GF_StartPosTAB		dc.w	GameFlowSCRIPT-GameFlowSCRIPT		;level11
			dc.w	GFS_L13-GameFlowSCRIPT			;level12
			dc.w	GFS_L14-GameFlowSCRIPT			;level13
			dc.w	GFS_L21-GameFlowSCRIPT			;level14
			dc.w	GFS_L22-GameFlowSCRIPT			;level21
			dc.w	GFS_L23-GameFlowSCRIPT			;level22
			dc.w	GFS_L24-GameFlowSCRIPT			;level23
			dc.w	GFS_L31-GameFlowSCRIPT			;level24
			dc.w	GFS_L32-GameFlowSCRIPT			;level31
			dc.w	GFS_L33-GameFlowSCRIPT			;level32
			dc.w	GFS_L34-GameFlowSCRIPT			;level33
			dc.w	GFS_L51-GameFlowSCRIPT			;level34
			dc.w	GFS_L71-GameFlowSCRIPT			;level51
			dc.w	GFS_L72-GameFlowSCRIPT			;level71
			dc.w	GFS_L73-GameFlowSCRIPT			;level72
			dc.w	GFS_L74-GameFlowSCRIPT			;level73
			dc.w	GFS_L75-GameFlowSCRIPT			;level74
			dc.w	GFS_L77-GameFlowSCRIPT			;level76
			dc.w	GFS_END-GameFlowSCRIPT			;Ending


GameFlowSCRIPT		GFS	GF_FadeOut
			GFS	GF_NewLevel,Level12
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L13			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level13
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L14			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level14
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L21			GFS	GF_FadeOut
			GFS	GF_Fluff,BeginL2FLUFF
			GFS	GF_NewLevel,Level21
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L22			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level22
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L23			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level23
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L24			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level24
			GFS	GF_FadeIn
			GFS	GF_StartLevel
		
GFS_L31			GFS	GF_FadeOut
			GFS	GF_Fluff,EndL2FLUFF
			GFS	GF_Fluff,BeginL3FLUFF
			GFS	GF_NewLevel,Level31
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L32			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level32
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L33			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level33
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L34			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level34
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L51			GFS	GF_FadeOut
			GFS	GF_Fluff,BeginL5FLUFF
			GFS	GF_NewLevel,Level51
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L71			GFS	GF_FadeOut
			GFS	GF_Fluff,BeginL7FLUFF
			GFS	GF_NewLevel,Level71
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L72			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level72
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L73			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level73
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L74			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level74
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L75			GFS	GF_FadeOut
			GFS	GF_NewLevel,Level75
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_L77			GFS	GF_FadeOut
			GFS	GF_Fluff,MiddleL7FLUFF
			GFS	GF_NewLevel,Level77
			GFS	GF_FadeIn
			GFS	GF_StartLevel
			
GFS_END			GFS	GF_FadeOut
			GFS	GF_Fluff,EndL7FLUFF
			GFS	GF_Restart
			

GetNextLevel		move.w	#NewLevelVBLANK,VBLANKPhase
			
GNL			lea	GameFlowSCRIPT,a1
			move.w	GameFlowINDEX,d1
			move.w	0(a1,d1.w),d2
			subq.w	#1,d2
			asl.w	#2,d2	
			jmp	GFSTable(pc,d2.w)

GFSTable		bra	.GF_FadeBlack
			bra	.GF_FadeWhite
			bra	.GF_NewLevel
			bra	.GF_Restart
			bra	.GF_FadeBack
			bra	.GF_StartLevel
			bra	.GF_Fluff
			
.GF_FadeBlack		jsr	dark_fader		;setup fade
			jsr	wait_fade		;wait for it to finish
			bra	.bump2

.GF_FadeWhite		moveq	#$3,d1	 		;fade to white
			move.w	#def_blackout,d2
			jsr	set_whiteout
			jsr	wait_fade		;wait for it to finish
			bra	.bump2

.GF_NewLevel		move.w	2(a1,d1.w),levnum
			move.w	#$2700,sr
			st.b	working
			clr.b	service
			cmp.w	#Level51,levnum
			bne.s	.l51no
			st.b	InsideFLG
.l51no			jsr	ClrScrlA
			jsr	ClrScrlB
			bsr	SetupLevel
			bsr	ClrMailBoxes
			bsr	KillLoopingSFX
			jsr	SetupGoliath				;player
			bsr	SetupLevelMusic
			move.w	PlrEnergy,OB_Nrg(a0)
			move.l	a0,a1
			jsr	DMA_HealthPLR
			bsr	TriggerALL
			clr.b	working
			st.b	service
			clr.b	joy1
			clr.b	d_joy1
			clr.b	NewGameFLG
			clr.b	first_pass
			clr.b	NextLevelFLG
			move.w	#GameVBLANK,VBLANKPhase
			lea	TheStack,sp		;set stack pointer
			move.w	#$2000,sr
			bra	.bump4
			
.GF_FadeBack		jsr	BlackPalette
			clr.b	PalLightCNT
			lea	GamePalette,a1
			bsr	lite_fader
			bsr	wait_fade		;wait for it to finish
			bra	.bump2

.GF_StartLevel		addq.w	#2,GameFlowINDEX
			bra	MainLoop		;lets start this level

.GF_Restart		jmp	ColdResetTheGame		;reset the game

.GF_Fluff		move.w	2(a1,d1.w),d1		;pull fluff sequence #
			bsr	FluffSequence		;do the fluff
			jmp	.bump4

.bump2			addq.w	#2,GameFlowINDEX
			bra	GNL
.bump4			addq.w	#4,GameFlowINDEX
			bra	GNL



			if	1=0

; - COLOUR DEBUG for Artists -----------------------------------------------

; ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»
; Ί COLOUR DEBUG ROUTINE						   Ί
; ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ
; Ί Entry: n/a								   Ί
; Ί  Exit: n/a								   Ί
; Ί  Used: n/a								   Ί
; ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ
; Ί Allows the Artist/Programmer to manipulate the Genesis		   Ί
; Ί colour palettes. Displays raw RGB values for the SEGA		   Ί
; Ί (NOTE: these values should be multiplied by 2 for real SEGA		   Ί
; Ί colours). Displays DPAINT RGB values.				   Ί
; Ί 									   Ί
; Ί This routine is functional but extremely Cheesey.			   Ί
; ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ

CDtext1			dc.b	pfC,1,25,"PAL=0  : SEGA - R=0 G=0 B=0 : RGB=000",0
CDtext2			dc.b	pfC,1,26,"COL=00 : DPAINT - R=00 G=00 B=00",0
ct1			dc.b	pfC,5,26,"01",0
ct2			dc.b	pfC,5,26,"02",0
ct3			dc.b	pfC,5,26,"03",0
ct4			dc.b	pfC,5,26,"04",0
ct5			dc.b	pfC,5,26,"05",0
ct6			dc.b	pfC,5,26,"06",0
ct7			dc.b	pfC,5,26,"07",0
ct8			dc.b	pfC,5,26,"08",0
ct9			dc.b	pfC,5,26,"09",0
ct10			dc.b	pfC,5,26,"10",0
ct11			dc.b	pfC,5,26,"11",0
ct12			dc.b	pfC,5,26,"12",0
ct13			dc.b	pfC,5,26,"13",0
ct14			dc.b	pfC,5,26,"14",0
ct15			dc.b	pfC,5,26,"15",0
ct16			dc.b	pfC,5,26,"16",0
rgb0			dc.b	-1,"00",0
rgb1			dc.b	-1,"14",0
rgb2			dc.b	-1,"27",0
rgb3			dc.b	-1,"39",0
rgb4			dc.b	-1,"52",0
rgb5			dc.b	-1,"64",0
rgb6			dc.b	-1,"77",0
rgb7			dc.b	-1,"89",0
			even

cttab			dc.l	ct1,ct2,ct3,ct4,ct5,ct6,ct7,ct8,ct9,ct10,ct11,ct12,ct13,ct14,ct15,ct16
rgbtab			dc.l	rgb0,rgb1,rgb2,rgb3,rgb4,rgb5,rgb6,rgb7
paltab			dc.l	Pal1,Pal2,Pal3,Pal4

			bsr	DoColorDebug

DoColorDebug		cmp.b	#$84,joy1
			beq.s	ColorDebug
.1			rts

ColorDebug		move.w	#DebugVBLANK,VBLANKPhase

			move.w	#reg17,vctrl
			move.w	#reg18+$80+25,vctrl
			move.w	#reg3+($d000>>10),vctrl

			move.l	#$d000,d6
			lea	CDtext1,a1
			bsr	PrintString
			move.l	#$d000,d6
			lea	CDtext2,a1
			bsr	PrintString
			
			clr.b	CD_Pal
			clr.b	CD_Col
			
.selloop		bsr	WaitFrm
			btst.b	#start,d_joy1
			bne	.exit

			bsr	PrintDebugBits
	
			btst.b	#up,d_joy1
			bne.s	.palinc
			btst.b	#down,d_joy1
			bne.s	.paldec
			btst.b	#left,d_joy1
			bne.s	.coldec
			btst.b	#right,d_joy1
			bne.s	.colinc
			
			bra	.selloop

.palinc			bsr	TestButABC
			tst	d5
			bmi	.selloop
			addq.b	#1,CD_Pal
			cmp.b	#4,CD_Pal
			bne	.selloop
			clr.b	CD_Pal
			bra	.selloop
.paldec			bsr	TestButABC
			tst	d5
			bmi	.selloop
			subq.b	#1,CD_Pal
			bpl	.selloop
			move.b	#3,CD_Pal
			bra	.selloop

.colinc			addq.b	#1,CD_Col
			cmp.b	#16,CD_Col
			bne	.selloop
			clr.b	CD_Col
			bra	.selloop
.coldec			subq.b	#1,CD_Col
			bpl	.selloop
			move.b	#15,CD_Col
			bra	.selloop

.exit			move.w	#GameVBLANK,VBLANKPhase
			move.w	#reg17,vctrl
			move.w	#reg18,vctrl
			move.w	#reg3,vctrl
			clr.l	joy1
			clr.l	joy2
			rts

TestButABC		lea	paltab,a2			;pull color from palette
			move.b	CD_Pal,d7
			ext.w	d7
			asl.w	#2,d7
			move.l	0(a2,d7.w),a2
			move.b	CD_Col,d7			;print RGB values
			ext.w	d7
			asl.w	#1,d7
			
			moveq	#0,d5
			btst.b	#but_a,joy1
			beq.s	.a
			bsr	.red
			moveq	#-1,d5
.a			btst.b	#but_b,joy1
			beq.s	.b
			bsr	.green
			moveq	#-1,d5
.b			btst.b	#but_c,joy1
			beq.s	.c
			bsr	.blue
			moveq	#-1,d5
.c			rts

.red			move.w	0(a2,d7.w),d1			;get col
			move.w	d1,d2
			and.w	#$0ff0,d2
			btst.b	#down,joy1
			bne.s	.rd
.ra			add.w	#$0002,d1
			bra	.r1
.rd			sub.w	#$0002,d1
.r1			and.w	#$000f,d1
			bra	.xx

.green			move.w	0(a2,d7.w),d1			;get col
			move.w	d1,d2
			and.w	#$0f0f,d2
			btst.b	#down,joy1
			bne.s	.gd
.ga			add.w	#$0020,d1
			bra	.g1
.gd			sub.w	#$0020,d1
.g1			and.w	#$00f0,d1
			bra	.xx

.blue			move.w	0(a2,d7.w),d1			;get col
			move.w	d1,d2
			and.w	#$00ff,d2
			btst.b	#down,joy1
			bne.s	.bd
.ba			add.w	#$0200,d1
			bra	.b1
.bd			sub.w	#$0200,d1
.b1			and.w	#$0f00,d1
.xx			or.w	d2,d1
			move.w	d1,0(a2,d7.w)
			rts
			
			

PrintDebugBits		move.l	#$d000,d6			;print palette #
			moveq	#5,d1
			moveq	#25,d2
			bsr	GetScreenAddrs
			move.b	CD_Pal,d1
			ext.w	d1
			addq.w	#1,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata

			lea	cttab,a1			;print colour #
			move.b	CD_Col,d7
			asl.b	#2,d7
			ext.w	d7
			move.l	0(a1,d7.w),a1
			move.l	#$d000,d6
			bsr	PrintString

			lea	paltab,a2			;pull color from palette
			move.b	CD_Pal,d7
			ext.w	d7
			asl.w	#2,d7
			move.l	0(a2,d7.w),a2
			move.b	CD_Col,d7			;print RGB values
			ext.w	d7
			asl.w	#1,d7
			move.w	0(a2,d7.w),d1
			move.w	d1,-(sp)
			and.w	#$000f,d1			;d4=red
			lsr.w	#1,d1
			move.w	d1,red
			move.w	(sp)+,d1
			move.w	d1,-(sp)
			and.w	#$00f0,d1			;d4=green
			lsr.w	#5,d1
			move.w	d1,green
			move.w	(sp)+,d1
			and.w	#$0f00,d1			;d4=blue
			lsr.w	#8,d1
			lsr.w	#1,d1
			move.w	d1,blue

			move.l	#$d000,d6
			moveq	#19,d1
			moveq	#25,d2
			bsr	GetScreenAddrs
			move.w	red,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata
			move.l	#$d000,d6
			moveq	#23,d1
			moveq	#25,d2
			bsr	GetScreenAddrs
			move.w	green,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata
			move.l	#$d000,d6
			moveq	#27,d1
			moveq	#25,d2
			bsr	GetScreenAddrs
			move.w	blue,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata

			move.l	#$d000,d6
			moveq	#35,d1
			moveq	#25,d2
			bsr	GetScreenAddrs
			move.w	red,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata
			move.w	green,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata
			move.w	blue,d1
			add.w	#("0"-$1f)+Alpha_Base+$8000,d1
			move.w	d1,vdata
			
			move.l	#$d000,d6
			moveq	#21,d1
			moveq	#26,d2
			bsr	GetScreenAddrs
			lea	rgbtab,a2
			move.w	red,d1
			asl.w	#2,d1
			move.l	0(a2,d1.w),a1
			bsr	PrintString
			move.l	#$d000,d6
			moveq	#26,d1
			moveq	#26,d2
			bsr	GetScreenAddrs
			lea	rgbtab,a2
			move.w	green,d1
			asl.w	#2,d1
			move.l	0(a2,d1.w),a1
			bsr	PrintString
			move.l	#$d000,d6
			moveq	#31,d1
			moveq	#26,d2
			bsr	GetScreenAddrs
			lea	rgbtab,a2
			move.w	blue,d1
			asl.w	#2,d1
			move.l	0(a2,d1.w),a1
			bsr	PrintString
			
			rts

			endif
