BTF4_Bitplane_Width  = 40
BTF4_Bitplane_Height = 256
BTF4_NumPlanosImagen = 5
BTF4_Tamano_Plano = BTF4_Bitplane_Width * BTF4_Bitplane_Height

BTF4_ZonaLetras_Height = 30
BTF4_Font_Numero_Caracteres = 53
BTF4_Font_Alto = 8				;Pixels
BTF4_Font_Ancho = 1				;bytes


BTF4_PosXInicialMarti=30
BTF4_PosYInicialMarti=120

BTF4_PosXInicialDoc=79
BTF4_PosYInicialDoc=116


BTF4_ShowAnim MACRO      ;Delay_1,Posicion_1,QUEN_StoryBoard_1,Alto,Ancho-words,SemaforoFin
\@
	tst.w 	\1
	beq 	.ImprimeBob
	sub.w   #1,\1
	clear 	d0
	bra.s 	.fin

.ImprimeBob:
	move.l 	\2,a4 	
	
	jif.l     #-1,'<>',(a4),.noreset,.l
	;lea 	\3,a4
	;move.l 	a4,\2
	ifnc '\6',''
		move.w 	#1,\6
		bra .fin
	endc
	ifc '\6',''
		lea 	\3,a4
		move.l 	a4,\2
	endc


.noreset:
	move.l  (a4)+,d0     ;x
	move.l  (a4)+,d1     ;y

	move.l  (a4)+,d2     ;tiempo
	move.w  d2,\1

	moveq   #\4,d2
	moveq	#\5,d3

	move.l 	(a4)+,a0 	;a0 origen
	beq.s 	.fin
	move.l 	(a4)+,a3
	lea 	Buffer_General_2,a1
	move.l 	a4,\2

	lea 	buffer_general_1,a4 	;***
	move.l 	#BTF4_Bitplane_Width,d4
	move.l	#BTF4_NumPlanosImagen,d5
	;move.l 	#40,d4
	;move.l	#5,d5

	bsr 	gblImprimeBob
	moveq 	#1,d0

.fin:
	nop
	ENDM

BTF4_Init:

	lea BTF4_Imagen,a1
	lea Buffer_General_2,a0	
	jsr decrunch

	lea buffer_general_2,a0
	lea buffer_general_1,a1
	
	REPEAT d0,(BTF4_Bitplane_Width*BTF4_Bitplane_Height*BTF4_NumPlanosImagen)/4 TIMES	;320*256*5 planos
		move.l 	(a0)+,(a1)+
	END_REPEAT


	lea.l	Buffer_General_2,a1
	lea.l	BTF4_Copper_Bitplanes+2,a2
	move.l	a1,d1

	REPEAT 	d0,BTF4_NumPlanosImagen TIMES
		swap	d1
		move.w	d1,(a2)
		swap	d1
		move.w	d1,4(a2)
		addq.l	#8,a2
		add.l	#BTF4_Bitplane_Width,d1
	END_REPEAT

	lea.l	BTF4_CopperList,a1
	move.l	a1,Cop1Lch+CustomBase

	move.w 	(a1),BTF4_Pausa
	clr.w 	CopJmp1+CustomBase
	move.w  #0,BTF4_Contador

	rts	;
;--------------------------------------------------------------
; Invocada en cada VBG
; El pobre blitter de 1985 no puede con todo a la vez, asi que
; limitamos el numero de personajes animados a 1 en cada VBG
; y a cascarla.
;--------------------------------------------------------------
BTF4_Run:
	add.w #1,BTF4_Contador
	clear d2
	move.l 	BTF4_Puntero_Literatura,a0
	move.w 	(a0),d0
	jif.w 	BTF4_Contador,'<>',d0,.No100
	move.w 	2(a0),d2 		; Color
	move.w 	4(a0),d0 		; X
	move.w 	6(a0),d1 		; Y

	add.l 	#48,BTF4_Puntero_Literatura

	gblPrintText82 Buffer_General_2,buffer_general_1,d0,d1,8(a0),BTF_FontCbm64,BTF_CharTab,BTF_CharTabEnd,8,1,BTF4_Bitplane_Width,BTF4_NumPlanosImagen,d2

.No100:

	BTF4_ShowAnim Delay_11,Posicion_11,QUEN_StoryBoard_11,54,4,BTF4_FinMarty
	jif.b  #0,'<>',D0,BTF4_AnimacionesSprites
	BTF4_ShowAnim Delay_21,Posicion_21,BTF4_Doc_StoryBoard_1,58,4
	jif.b  #0,'<>',D0,BTF4_AnimacionesSprites

BTF4_AnimacionesSprites:

	jif.w    #$ffff,'<>',BTF4_Pausa,.PausaNormal

	move.b #1,BTF4_Fin
	rts

.PausaNormal:
	sub.w 	#1,BTF4_Pausa
	rts


BTF4_Literatura:
	;COntador,Color,X,Y

	dc.w 	200,10,0,12
	dc.b 	"HOLA DOC! DE QUE VA TU ULTIMO INVENTO? ",0
	dc.w 	290,10,0,12
	dc.b 	"                                       ",0	
	dc.w 	300,15,0,12
	dc.b 	"HE INVENTADO LA MAQUINA DEL TIEMPO     ",0
	dc.w 	400,10,0,12
	dc.b 	"VENGA YA!!                             ",0
	dc.w 	500,15,0,12
	dc.b 	"EN AMIGAWAVE ESTAN HABLANDO DE PHASE5 ,",0
	dc.w 	600,15,0,12
	dc.b 	"Y QUIERO SABER COMO ACABA TODO...      ",0
	dc.w 	700,15,0,12
	dc.b 	"Y LUEGO VIAJARE A 2018 PARA TRAERME..  ",0
	dc.w 	900,15,0,12
	dc.b 	"       !!! UNA VAMPIRE 1200 !!!        ",0
	dc.w 	990,15,0,12
	dc.b 	"                                       ",0	
	dc.w 	1000,15,20,12
	dc.b 	"VENGA GUNNAR",1,"SACA LA FPU ",1,"DE UNA FUCKING TIME   ",0
	dc.w 	2000,10,20,12
	dc.b 	"            ",1,"            ",1,"                      ",0

	dc.w 	-1

; --------------------------------------------------------------------------------------------------
; Animacion de Marty McFly
; --------------------------------------------------------------------------------------------------
Delay_11: dc.w 0
Posicion_11: dc.l QUEN_StoryBoard_11


QUEN_StoryBoard_11: ; X,Y,Tiempo de visualizacion,bob,mascara
	dc.l 	BTF4_PosXInicialMarti,BTF4_PosYInicialMarti,200,BTF4_Personaje1f1,BTF4_Personaje1f1Mask

	REPT  	25
	dc.l 	BTF4_PosXInicialMarti,BTF4_PosYInicialMarti,16,BTF4_Personaje1f2,BTF4_Personaje1f2Mask
	dc.l 	BTF4_PosXInicialMarti,BTF4_PosYInicialMarti,17,BTF4_Personaje1f1,BTF4_Personaje1f1Mask

	ENDR

	dc.l 	BTF4_PosXInicialMarti,BTF4_PosYInicialMarti,005,BTF4_Personaje1f1,BTF4_Personaje1f1Mask	
	dc.l 	-1

	even

; --------------------------------------------------------------------------------------------------
; FIN - Animacion de Marty McFly
; --------------------------------------------------------------------------------------------------

; --------------------------------------------------------------------------------------------------
; Animacion de Doc
; --------------------------------------------------------------------------------------------------
Delay_21: dc.w 0
Posicion_21: dc.l BTF4_Doc_StoryBoard_1

BTF4_Doc_StoryBoard_1:
	REPT  	25
	dc.l 	BTF4_PosXInicialDoc,BTF4_PosYInicialDoc,15,BTF4_Personaje_Doc1_Bob,BTF4_Personaje_Doc1_Mask
	dc.l 	BTF4_PosXInicialDoc,BTF4_PosYInicialDoc,15,BTF4_Personaje_Doc2_Bob,BTF4_Personaje_Doc2_Mask
	ENDR
	dc.l 	-1

	even
; --------------------------------------------------------------------------------------------------
; FIN - Animacion de Doc
; --------------------------------------------------------------------------------------------------

BTF4_Pausa:
	dc.w 	0
BTF4_Fin:
	dc.b    0
	even
BTF4_Contador: dc.w 0

BTF4_Puntero_Literatura: dc.l BTF4_Literatura

BTF4_FinMarty:dc.w 0

	even
