	
	.text
	.arm
	.global	show_logo
	.type	show_logo,function
	
show_logo:

	stmfd	sp!,{r0-r12,lr}

		
	@play sound
	
	ldr	r0,=lachen_mod
	bl	init_mod		@init_mod

	@**** mach dunkel
	
	mov	r0,#0xff
	strh	r0,[r6,#0x50]
	mov	r0,#0x1f	
	strh	r0,[r6,#0x54]
	
	@**** set gfx

	mov 	r6,#0x4000000   		@
	mov	r1,#0x1400		@mode 0 bg 2/3 + sprites
	strh 	r1,[r6]			@store

	@**** init gfx

	mov 	r6,#0x4000000   		@
	ldr	r1,=0x1481		@0 tile,   +40960 (20)map / 256 c prio 0	
	strh 	r1,[r6,#0xc]	
		
	ldr	r1,=0x1508		@32k tile, +43008 (21) map / 16 c  prio 1
	strh 	r1,[r6,#0xe]
	
		
	@**** logo 2 pal (64 farben)
	
	ldr	r0,=logo2pal
	mov	r1,#0x5000000
	mov	r2,#64*2
	bl	dmacpy	
	
	@**** logo 1 pal (16 farben)
	
	ldr	r0,=logo1pal
	mov	r1,#0x5000000
	add	r1,r1,#64*2
	mov	r2,#16*2
	bl	dmacpy	
	
	@**** logo 2 gfx 
	
	ldr	r0,=logo2gfx
	mov	r1,#0x6000000
	ldr	r2,=23616
	bl	dmacpy	
	
	@**** logo 1 gfx 
	
	ldr	r0,=logo1gfx
	mov	r1,#0x6000000
	add	r1,r1,#32768
	ldr	r2,=8075
	bl	dmacpy
	
	@**** map 2
	
	ldr	r2,=logo2map
	mov	r3,#0x6000000
	add	r3,r3,#40960
	
	mov	r1,#20
map2y:	mov	r0,#30
map2x:	ldrh	r4,[r2],#2
	strh	r4,[r3],#2
	subs	r0,r0,#1
	bne	map2x
	add	r3,r3,#4
	subs	r1,r1,#1
	bne	map2y
	
	@**** map 1
	
	ldr	r2,=logo1map
	mov	r3,#0x6000000
	add	r3,r3,#43008
	
	mov	r1,#20
map1y:	mov	r0,#30
map1x:	ldrh	r4,[r2],#2
	orr	r4,r4,#0x4000		@palette 4
	strh	r4,[r3],#2
	subs	r0,r0,#1
	bne	map1x
	add	r3,r3,#4
	subs	r1,r1,#1
	bne	map1y	

	@**** mach heller

	mov	r6,#0x4000000
	mov	r0,#0x1f	
dtoh2:
	mov	r2,#160
	bl	wait
	mov	r2,#159
	bl	wait

	strh	r0,[r6,#0x54]
	subs	r0,r0,#1
	cmp	r0,#-1
	bne	dtoh2

	@**** setze transp.
	
	ldr	r1,=0x448		@bg2-3
	strh	r1,[r6,#0x50]
	ldr	r1,=0x151f
	strh	r1,[r6,#0x52]
	
	@**** schalte bg2 wieder an
	
	mov 	r6,#0x4000000   		@
	mov	r1,#0x1c00		@mode 0 bg 2/3 + sprites
	strh 	r1,[r6]			@store
	
	@**** spiele lachen
	
	
	
	@**** logo1 enttransparenten :)

	mov	r6,#0x4000000
	mov	r10,#31	
enttra:

	mov	r2,#160
	bl	wait
	mov	r2,#159
	bl	wait
	mov	r2,#158
	bl	wait
	mov	r2,#157
	bl	wait
	mov	r2,#156
	bl	wait	
	
	cmp	r10,#16
	bleq	start_mod		@start_mod
	
	mov	r1,r10,lsl #8
	orr	r1,r1,#0x1f
	strh	r1,[r6,#0x52]

	subs	r10,r10,#1
	cmp	r10,#-1
	bne	enttra	
			
	mov	r0,#0
	strh	r0,[r6,#0x50]
	strh	r0,[r6,#0x52]			
			
	@**** warte
	
	mov	r3,#120
wasteti:	
	mov	r2,#160
	bl	wait
	mov	r2,#159
	bl	wait
	
	subs	r3,r3,#1
	bne	wasteti
	
	@**** mod aus
	
	bl	stop_mod
	
	@**** mach hell
	
	mov	r0,#0xfc
	strh	r0,[r6,#0x50]
	mov	r0,#0x0
	strh	r0,[r6,#0x54]
	
	@**** mach dunkler

	mov	r6,#0x4000000
	mov	r0,#0x1f	
dtoh:
	mov	r2,#160
	bl	wait
	mov	r2,#159
	bl	wait

	rsb	r1,r0,#0x1f
	strh	r1,[r6,#0x54]
	subs	r0,r0,#1
	cmp	r0,#-1
	bne	dtoh

	
	ldmfd	sp!,{r0-r12,lr}
	bx	lr
	
	.pool
	

lachen_mod:	.include	"lachen.mmod.i"  
	
logo1gfx:	.include	"gfx/logo1.gfx.s"	@8075
logo1pal: 	.include	"gfx/logo1.pal.s"	@16*2
logo1map:	.include	"gfx/logo1.map.s"	@1200

logo2gfx:	.include	"gfx/logo2.gfx.s"	@23616
logo2pal: 	.include	"gfx/logo2.pal.s"	@64*2
logo2map:	.include	"gfx/logo2.map.s"	@1200
