;=============================================================================
; Parallex Mountains Demo
; ----------------------------------------------------------------------------
; AGA Fixes:	AGA Copper fix
;		Blit waits added (there where none at all, doh!)
;		Absolute address access to Interrupts without VBR base
;=============================================================================

		section andy,code_c
		incdir	scene1:coding/asm/demos_parallexmountains/

startlist1	equ	38
startlist2	equ	50

plnw		equ	40
plnh		equ	128
plnsize		equ	plnw*plnh
plnnum		equ	3
plndata		equ	plnsize*plnnum
buggerbuffer	equ	$ce4+80

Start2:		bsr	GetVBR			;get vectorbase for interrupts

		move.l	4,a6
		move.l	#$10002,d1
		move.l	#plndata,d0
		jsr	-198(a6)		;allocate screen memory 1
		move.l	d0,plnbase
		beq	error

		move.l	#$10002,d1
		move.l	#buggerbuffer,d0
		jsr	-198(a6)		;allocate screen memory 2
		move.l	d0,scrlbase
		beq	error

		move.w	#$0080,$dff096
		move.w	$dff01c,sysint
		or.w	#$c000,sysint		;save system intena
		move.w	#$7fff,$dff09a

		move.l	_VBR(pc),a0
		move.l	$6c(a0),int3save	;and level 6 irq
		move.l	#isr,$6c(a0)

		move.l	#newcopper,$dff080	;install our copperlist
		move.w	#$0200,$dff100

	move.l	#spec0,d0
	move.l	d0,stor
	move.w	stor,sp0+2
	move.w	stor+2,sp0+6
	move.l	#spec1,d0
	move.l	d0,stor
	move.w	stor,sp1+2
	move.w	stor+2,sp1+6
	move.l	#spec2,d0
	move.l	d0,stor
	move.w	stor,sp2+2
	move.w	stor+2,sp2+6
	move.l	#spec3,d0
	move.l	d0,stor
	move.w	stor,sp3+2
	move.w	stor+2,sp3+6

	move.l	plnbase,a1	;mount range
	move.l	#plnsize,d0
	move.l	a1,stor
	move.l	stor,pln1
	move.w	stor,bp4+2
	move.w	stor+2,bp4+6
	add.l	d0,stor
	move.l	stor,pln2
	move.w	stor,bp5+2
	move.w	stor+2,bp5+6
	add.l	d0,stor
	move.l	stor,pln3
	move.w	stor,bp6+2
	move.w	stor+2,bp6+6

	move.l	#logo,d0	;top of logo	
	sub.l	#2,d0
	move.w	d0,bp11+6
	swap	d0
	move.w	d0,bp11+2
	swap	d0
	add.l	#3840,d0
	move.w	d0,bp12+6
	swap	d0
	move.w	d0,bp12+2
	swap	d0
	add.l	#3840,d0
	move.w	d0,bp13+6
	swap	d0
	move.w	d0,bp13+2
	swap	d0
	add.l	#3840,d0
	move.l	d0,a0
	add.l	#2,a0
	move.l	#cols+2,a1
	moveq.l	#7,d0
.lp4:	move.w	(a0)+,(a1)+
	add.l	#2,a1
	dbra	d0,.lp4

	move.l	#logo+2000,d0	;bot of logo
	sub.l	#2,d0
	move.w	d0,bp1+6
	swap	d0
	move.w	d0,bp1+2
	swap	d0
	add.l	#3840,d0
	move.w	d0,bp2+6
	swap	d0
	move.w	d0,bp2+2
	swap	d0
	add.l	#3840,d0
	move.w	d0,bp3+6
	swap	d0
	move.w	d0,bp3+2
	swap	d0

	move.l	#plndat,stor
	move.w	stor,bpln1+2
	move.w	stor+2,bpln1+6

	move.l	#20479,d0
	lea	plndat,a0
	lea	plndat2,a1
.lp:	move.l	(a0)+,(a1)
	eor.l	#-1,(a1)+
	dbra	d0,.lp

	move.l	#0,d0
	move.l	#0,d1
	lea	plnaddr,a0
	move.l	#plndat,d2
.lp2:	move.l	(a0,d1),a1
	move.w	d2,6(a1)
	swap	d2
	move.w	d2,2(a1)
	swap	d2
	add.l	#40,d2
	add.l	#4,d1
	add.l	#1,d0
	cmp.l	#128,d0
	bne	.lp2

	move.l	#0,d0
	move.l	#0,d1
	move.l	#0,d2
	
	lea	ref,a0
.lp3:	move.l	pln1,d3
	add.l	#77*42,d3
	move.l	d0,d1
	mulu	#84,d1
	sub.l	d1,d3
	move.l	d3,d4
	add.l	#plnsize,d4
	move.l	d4,d5
	add.l	#plnsize,d5

	move.w	d3,6(a0)
	swap	d3
	move.w	d3,2(a0)

	move.w	d4,14(a0)
	swap	d4
	move.w	d4,10(a0)

	move.w	d5,22(a0)
	swap	d5
	move.w	d5,18(a0)

	add.l	#1,d0
	add.l	#36,a0
	cmp.l	#39,d0
	bne	.lp3

	move.l	#blnk,d3	;blank under mount ref down to top of scrl

.lp5:	move.w	d3,6(a0)
	move.w	d3,14(a0)
	move.w	d3,22(a0)
	swap	d3
	move.w	d3,2(a0)
	move.w	d3,10(a0)
	move.w	d3,18(a0)
	swap	d3

	add.l	#1,d0
	add.l	#36,a0
	cmp.l	#59,d0
	bne	.lp5

	lea	ref3,a0
	move.l	#59,d0
	move.l	scrlbase,d3	;scrl
	move.l	d3,d4
	add.l	#$44c,d4
	move.l	d4,d5
	add.l	#$44c,d5

.lp8:	move.w	d3,6(a0)
	move.w	d4,14(a0)
	move.w	d5,22(a0)
	swap	d3
	swap	d4
	swap	d5
	move.w	d3,2(a0)
	move.w	d4,10(a0)
	move.w	d5,18(a0)
	swap	d3
	swap	d4
	swap	d5

	add.l	#44,d3
	add.l	#44,d4
	add.l	#44,d5
	add.l	#1,d0
	add.l	#36,a0
	cmp.l	#78,d0
	bne	.lp8


.lp9:	move.w	d3,6(a0)
	move.w	d4,14(a0)
	move.w	d5,22(a0)
	swap	d3
	swap	d4
	swap	d5
	move.w	d3,2(a0)
	move.w	d4,10(a0)
	move.w	d5,18(a0)
	swap	d3
	swap	d4
	swap	d5

	add.l	#44,d3
	add.l	#44,d4
	add.l	#44,d5
	add.l	#1,d0
	add.l	#36,a0
	cmp.l	#84,d0
	bne	.lp9

	lea	ref4,a0		;blank from 0 down
	move.l	#$2a,d0

	move.l	#blnk,d3

.lp6:	move.w	d3,6(a0)
	move.w	d3,14(a0)
	move.w	d3,22(a0)
	swap	d3
	move.w	d3,2(a0)
	move.w	d3,10(a0)
	move.w	d3,18(a0)
	swap	d3

	add.l	#36,a0
	dbra	d0,.lp6

	lea	ref2,a0		;line between scrl & ref
	move.w	d3,6(a0)
	move.w	d3,14(a0)
	move.w	d3,22(a0)
	swap	d3
	move.w	d3,2(a0)
	move.w	d3,10(a0)
	move.w	d3,18(a0)
	swap	d3

	move.w	d3,bp1a+6
	move.w	d3,bp1b+6
	move.w	d3,bp1c+6
	move.w	d3,bp2a+6
	move.w	d3,bp2b+6
	move.w	d3,bp2c+6
	move.w	d3,bp3a+6
	move.w	d3,bp3b+6
	move.w	d3,bp3c+6
	swap	d3
	move.w	d3,bp1a+2
	move.w	d3,bp1b+2
	move.w	d3,bp1c+2
	move.w	d3,bp2a+2
	move.w	d3,bp2b+2
	move.w	d3,bp2c+2
	move.w	d3,bp3a+2
	move.w	d3,bp3b+2
	move.w	d3,bp3c+2

	lea	ref4,a0		;scrl ref
	move.l	scrlbase,d3
	add.l	#24*44,d3
	move.l	d3,d4
	add.l	#$44c,d4
	move.l	d4,d5
	add.l	#$44c,d5

	move.l	#12,d0
.lpa:	move.w	d3,6(a0)
	move.w	d4,14(a0)
	move.w	d5,22(a0)
	swap	d3
	swap	d4
	swap	d5
	move.w	d3,2(a0)
	move.w	d4,10(a0)
	move.w	d5,18(a0)
	swap	d3
	swap	d4
	swap	d5

	sub.l	#88,d3
	sub.l	#88,d4
	sub.l	#88,d5

	add.l	#36,a0
	dbra	d0,.lpa

	move.w	#$8480,$dff096	
	
	jsr	start

	move.b	#2,$bfe001

wait:	jsr	task			;jmp to our sub.
	btst	#6,$bfe001		;wait for mouse.
	bne	wait
	move.l	4,a6
	move.l	#gfxname,a1
	moveq.l	#0,d0
	jsr	-552(a6)
	move.l	d0,a4
	move.l	startlist1(a4),$dff080
	move.l	startlist2(a4),$dff084
	clr.w	$dff088	

	move.l	_VBR(pc),a0
	move.l	int3save,$6c(a0)

	move.w	sysint,$dff09a
	move.w	#$8080,$dff096
	move.w	#$0400,$dff096
	move.l	4,a6
	move.l	plnbase,a1
	move.l	#plndata,d0
	jsr	-210(a6)
	move.l	4,a6
	move.l	scrlbase,a1
	move.l	#buggerbuffer,d0
	jsr	-210(a6)
	jsr	stop
	clr.l	d0
error:	move.w	#$0fff,$dff180
	rts				;exit.

_LVOSupervisor	=	-$1E
AttnFlags	=	$128

GetVBR:		move.l	4.w,a6			* get execbase
		suba.l	a4,a4			* no vbr is default..
		move.w	AttnFlags(a6),d0	* get cpu flags
		and.w	#15,d0			* are we on M68000
		beq.s	.skip			* if so skip
		lea	.getvbr(pc),a5		* else try to get VBR
		jsr	_LVOSupervisor(a6)	* force exception..
		bra.s	.skip			* skip past it..
.getvbr		movec	vbr,d0			* put vbr into d0
		move.l	d0,a4			* now return in a0 please
		rte				* return from exception
.skip		move.l	a4,_VBR
		rts

_VBR:		dc.l	0

newcopper:					
	dc.w	$01fc,$0000,$0106,$0000,$0104,$0000,$010c,$0000
	DC.W	$0100,$3200
	DC.W	$0102,$0000
	dc.w	$0104,%0000000001010100
bp11:	DC.W	$00e0,$0000,$00e2,$0000
bp12:	DC.W	$00e4,$0000,$00e6,$0000
bp13:	DC.W	$00e8,$0000,$00ea,$0000
bp5:	DC.W	$00ec,$0000,$00ee,$0000
bp3:	DC.W	$00f0,$0000,$00f2,$0000
bp6:	DC.W	$00f4,$0000,$00f6,$0000
	DC.W	$008E,$2c81,$0090,$2cc1                                 
	DC.W	$0092,$0030,$0094,$00d0
mod:	DC.W	$0108,-2,$010a,-2
cols:	dc.w	$0180,$0000
	dc.w	$0182,$0000
	dc.w	$0184,$0000
	dc.w	$0186,$0000
	dc.w	$0188,$0000
	dc.w	$018a,$0000
	dc.w	$018c,$0000
	dc.w	$018e,$0000

	dc.w	$0198,$0b74
	dc.w	$019a,$0962
	dc.w	$019c,$0851
	dc.w	$019e,$0740
	dc.w	$0192,$0fca
	dc.w	$0194,$0ea8
	dc.w	$0196,$0c85
	dc.w	$01a2,$0f00
	dc.w	$01a4,$0800
	dc.w	$01a6,$0c00
	dc.w	$01aa,$00f0
	dc.w	$01ac,$0080
	dc.w	$01ae,$00c0
sp0:	dc.w	$0120,$0000,$0122,$0000	
sp1:	dc.w	$0124,$0000,$0126,$0000	
sp2:	dc.w	$0128,$0000,$012a,$0000	
sp3:	dc.w	$012c,$0000,$012e,$0000	
sp4:	dc.w	$0130,$0000,$0132,$0000	
sp5:	dc.w	$0134,$0000,$0136,$0000	
sp6:	dc.w	$0138,$0000,$013a,$0000	
sp7:	dc.w	$013c,$0000,$013e,$0000	

	dc.w	$5e01,$fffe
	DC.W	$0100,$6600
	dc.w	$010a,0,$0104,%0000000001000100
bp1:	DC.W	$00e0,$0000,$00e2,$0000
bp4:	DC.W	$00e4,$0000,$00e6,$0000
bp2:	DC.W	$00e8,$0000,$00ea,$0000
	


	dc.w	$8c01,$fffe
bp1a:	DC.W	$00e0,$0000,$00e2,$0000
bp2a:	DC.W	$00e8,$0000,$00ea,$0000
bp3a:	DC.W	$00f0,$0000,$00f2,$0000
	dc.w	$8d01,$fffe
bp1b:	DC.W	$00e0,$0000,$00e2,$0000
bp2b:	DC.W	$00e8,$0000,$00ea,$0000
bp3b:	DC.W	$00f0,$0000,$00f2,$0000
	dc.w	$8e01,$fffe
bp1c:	DC.W	$00e0,$0000,$00e2,$0000
bp2c:	DC.W	$00e8,$0000,$00ea,$0000
bp3c:	DC.W	$00f0,$0000,$00f2,$0000


	dc.w	$ab01,$fffe

	dc.w	$0190,$0777
	dc.w	$0192,$0fff
	dc.w	$0194,$0eee
	dc.w	$0196,$0ddd	
	dc.w	$0198,$0ccc
	dc.w	$019a,$0bbb
	dc.w	$019c,$0aaa
	dc.w	$019e,$0999
	dc.w	$0180,$0003	;poo
	dc.w	$0186,$008a
	dc.w	$0188,$0059
	dc.w	$018a,$0038
	dc.w	$018c,$0016
	dc.w	$018e,$0004
	dc.w	$0182,$00ff
	dc.w	$0184,$00bd

	dc.w	$ac01,$fffe
	DC.W	$0100,$4200
ref:	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ad01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ae01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$af01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln8:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln9:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bplna:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bplnb:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bplnc:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bplnd:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$b901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bplne:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ba01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bplnf:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$bb01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln10:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$bc01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln11:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$bd01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln12:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$be01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln13:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$bf01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln14:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln15:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln16:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln17:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln18:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln19:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$c901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ca01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln1f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$cb01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln20:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$cc01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln21:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$cd01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln22:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ce01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln23:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$cf01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln24:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln25:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln26:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln27:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln28:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln29:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$d901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$da01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln2f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$db01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln30:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$dc01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln31:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$dd01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln32:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$de01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln33:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$df01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln34:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln35:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln36:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln37:	DC.W	$00ec,$0000,$00ee,$0000


	dc.w	$e301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln38:	DC.W	$00ec,$0000,$00ee,$0000


	dc.w	$e401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln39:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0182,$0fff
	dc.w	$0184,$0e0e 
	dc.w	$0186,$0c0c 
	dc.w	$0188,$0a0a 
	dc.w	$018a,$0909 
	dc.w	$018c,$0707 
	dc.w	$018e,$0fa0
	dc.w	$0192,$0fff
	dc.w	$0194,$0e0e
	dc.w	$0196,$0c0c
	dc.w	$0198,$0a0a
	dc.w	$019a,$0909
	dc.w	$019c,$0707
	dc.w	$019e,$0fa0


	dc.w	$e701,$fffe
ref3:	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$e901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ea01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln3f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$eb01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln40:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ec01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln41:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ed01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln42:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ee01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln43:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ef01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln44:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln45:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln46:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln47:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln48:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln49:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$f901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$fa01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln4f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$fb01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln50:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$fc01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln51:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$fd01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln52:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$fe01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln53:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ff01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln54:	DC.W	$00ec,$0000,$00ee,$0000
	dc.w	$ffdf,$fffe	

	dc.w	$0001,$fffe
ref2:	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln55:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0182,$0888		;black
	dc.w	$0184,$0607 
	dc.w	$0186,$0506 
	dc.w	$0188,$0405 
	dc.w	$018a,$0304 
	dc.w	$018c,$0203 
	dc.w	$018e,$0840

	dc.w	$0192,$0fff
	dc.w	$0194,$0eae 
	dc.w	$0196,$0c9c 
	dc.w	$0198,$0a8a 
	dc.w	$019a,$0979 
	dc.w	$019c,$0767 
	dc.w	$019e,$0fa4

	dc.w	$0101,$fffe
ref4:	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln56:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln57:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln58:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln59:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0a01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln5f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0b01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln60:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0c01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln61:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0d01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln62:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0e01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln63:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$0f01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln64:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln65:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln66:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln67:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln68:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln69:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1a01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln6f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1b01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln70:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1c01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln71:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1d01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln72:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1e01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln73:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$1f01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln74:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2001,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln75:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2101,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln76:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2201,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln77:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2301,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln78:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2401,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln79:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2501,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7a:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2601,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7b:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2701,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7c:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2801,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7d:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2901,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7e:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2a01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln7f:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2b01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln80:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2c01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln81:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$2d01,$fffe
	DC.W	$00e0,$0000,$00e2,$0000
	DC.W	$00e4,$0000,$00e6,$0000
	DC.W	$00e8,$0000,$00ea,$0000
bpln82:	DC.W	$00ec,$0000,$00ee,$0000

	dc.w	$ffff,$fffe
	

gfxname:
	DC.B	'graphics.library',0
	EVEN
gfxbase:
	DC.L	0

stor:	dc.l	0
pln1:	dc.l	0
pln2:	dc.l	0
pln3:	dc.l	0
pln4:	dc.l	0
pln5:	dc.l	0
pln6:	dc.l	0
sysint:	dc.w	0
int3save:
	dc.l	0
plnbase:dc.l	0
scrlbase:
	dc.l	0

isr:	movem.l	d0/d7-a0/a6,-(sp)
	move.w	#$0020,$dff09c
	movem.l	(sp)+,d0/d7-a0/a6
	rte

task:	move.w	$dff006,d0
	and.w	#$ff00,d0
	cmp.w	#$d500,d0
	bne	task
	;move.w	#$00f0,$dff180
	jsr	updtspec
	jsr	blitmnt1
	jsr	blitmnt2
	jsr	make_scape
	jsr	getcirc
	jsr	replay
	jsr	scrl
	;move.w	#$0000,$dff180
	rts


	************************
	*Update frame according to frame
	*Obvious or what?
	************************

Make_scape:
.lp5:	move.l	xvec,d0
	add.l	d0,frame
	move.l	frame,frame2
	and.l	#15,frame
	tst.l	xvec
	beq	.lp4
	
	bpl	.lp7
	tst.l	frame2
	bpl	.lp4
	bra	.lp6

.lp7:	tst.l	frame
	beq	.lp6
.lp8:	move.l	frame2,d1
	cmp.l	#15,d1
	ble	.lp4

.lp6:	move.l	startoff,d0
	move.l	startoff+4,startoff
	move.l	d0,startoff+4

.lp4:	lea	squdata,a2
	lea	squpos,a3
	move.l	#0,d6
	move.l	startoff,d4
	move.l	startoff+4,d5
	move.l	frame,d2
	mulu	#5120,d2
	move.l	#0,d0
	lea	plnaddr,a0
	move.w	(a3)+,d6
	move.w	(a2,d6),d6
	
.lp1:	move.l	d2,d3
	add.l	d4,d3
	move.l	(a0)+,a1
	move.w	d3,6(a1)
	swap	d3
	move.w	d3,2(a1)

	add.l	#40,d2
	add.l	#1,d0
	cmp.l	#128,d0
	beq	.lp2
.lp9:	dbra	d6,.lp1
	move.l	#0,d6
	exg	d4,d5
	move.w	(a3)+,d6
	move.w	(a2,d6),d6
	bra	.lp1
.lp2:
	move.l	yvec,d0
	asl.l	#1,d0
	add.w	d0,squpos
	add.w	d0,squpos+2
	add.w	d0,squpos+4
	add.w	d0,squpos+6
	add.w	d0,squpos+8
	add.w	d0,squpos+10
	add.w	d0,squpos+12
	add.w	d0,squpos+14
	add.w	d0,squpos+16
	add.w	d0,squpos+18
	tst.w	squpos
	bpl	.lpa

	add.w	#20,squpos
	add.w	#20,squpos+2
	add.w	#20,squpos+4
	add.w	#20,squpos+6
	add.w	#20,squpos+8
	add.w	#20,squpos+10
	add.w	#20,squpos+12
	add.w	#20,squpos+14
	add.w	#20,squpos+16
	add.w	#20,squpos+18

	move.l	startoff,d0
	move.l	startoff+4,startoff
	move.l	d0,startoff+4
	rts
	
.lpa:	cmp.w	#20,squpos
	bge	.lp3
	rts
.lp3:	
	sub.w	#20,squpos
	sub.w	#20,squpos+2
	sub.w	#20,squpos+4
	sub.w	#20,squpos+6
	sub.w	#20,squpos+8
	sub.w	#20,squpos+10
	sub.w	#20,squpos+12
	sub.w	#20,squpos+14
	sub.w	#20,squpos+16
	sub.w	#20,squpos+18

	move.l	startoff,d0
	move.l	startoff+4,startoff
	move.l	d0,startoff+4
	rts
frame:	dc.l	0	
frame2:	dc.l	0	
count:	dc.l	0
xvec:	dc.l	0
yvec:	dc.l	1
mxpos:	dc.l	0
mxpos2:	dc.l	0
vec1:	dc.l	0
vec2:	dc.l	0
deg1:	dc.l	0
deg2:	dc.l	76
flag:	dc.l	0
	even

wb:		btst	#14,$dff002
		bne.s	wb
		rts

Blitmnt1:
	move.l	xvec,d0		;update xcoords
	add.l	d0,mxpos
	add.l	d0,mxpos2
	cmp.l	#320,mxpos
	bge	.lp4
	tst.l	mxpos
	bmi	.lp5
	bra	.lp6
.lp4:	tst.l	mxpos
	bmi	.lp5
	sub.l	#320,mxpos
	bra	.lp6
.lp5:	add.l	#320,mxpos

.lp6:	cmp.l	#640,mxpos2	;update sec xcoord
	bge	.lp7
	tst.l	mxpos2
	bmi	.lp8
	bra	.lp9
.lp7:	tst.l	mxpos2
	bmi	.lp8
	sub.l	#640,mxpos2
	bra	.lp9
.lp8:	add.l	#640,mxpos2


.lp9:	;move.w	#$0fff,$dff180
	move.l	mxpos2,d5
	lsr.l	#4,d5
	bclr	#0,d5
	sub.l	#40,d5
	move.l	mxpos2,d3
	lsr.l	#1,d3
	and.l	#$0f,d3
	asl.l	#8,d3
	asl.l	#4,d3
	and.w	#$f000,d3
	move.w	d3,d4
	or.w	#%0000100111110000,d3	

	bsr	wb
	
	move.l	#mount1-2,d0
	move.l	pln1,d1
	sub.l	d5,d0
	;add.l	#50*40,d1
	move.l	d0,$dff050	;a source IM
	move.l	d1,$dff054	;d source
	move.w	#$0026,$dff064	;a mod
	move.w	#$0000,$dff066	;d mod
	move.w	#$ffff,$dff044	;fw mask
	move.w	#$ffff,$dff046	;lw mask
	move.w	d3,$dff040	;con0
	move.w	d4,$dff042	;con1
	move.w	#%0001001110010101,$dff058	;size		
	;move.w	#$0000,$dff180
	bsr	wb

	add.l	#plnsize,d1
	add.l	#$1860,d0
	move.l	d0,$dff050	;a source IM
	move.l	d1,$dff054	;d source	
	move.w	#%0001001110010101,$dff058	;size		
	;move.w	#$0000,$dff180
	bsr	wb

	add.l	#plnsize,d1
	add.l	#$1860,d0

	move.l	d0,$dff050	;a source IM
	move.l	d1,$dff054	;d source
	move.w	#%0001001110010101,$dff058	;size		
	;move.w	#$0000,$dff180
	bsr	wb
	rts
	even

Blitmnt2:
	;move.w	#$0fff,$dff180

	move.l	mxpos,d5
	lsr.l	#3,d5
	bclr	#0,d5
	sub.l	#40,d5
	move.l	mxpos,d3
	and.l	#$0f,d3
	asl.l	#8,d3
	asl.l	#4,d3
	and.w	#$f000,d3
	move.w	d3,d4
	or.w	#%0000111110111000,d3	
	
	move.l	#mount2-2,d0
	sub.l	d5,d0
	move.l	#mask-2,d2
	sub.l	d5,d2
	move.l	pln1,d1
	add.l	#46*42,d1
	move.l	d0,$dff050	;a source IM
	move.l	d2,$dff04c	;b mask IM
	move.l	d1,$dff048	;c source
	move.l	d1,$dff054	;d source
	move.w	#$0026,$dff064	;a mod
	move.w	#$0026,$dff062	;b mod
	move.w	#$0000,$dff060	;c mod
	move.w	#$0000,$dff066	;d mod
	move.w	#$ffff,$dff044	;fw mask
	move.w	#$ffff,$dff046	;lw mask
	move.w	d3,$dff040	;con0
	move.w	d4,$dff042	;con1
	move.w	#%0000100000010101,$dff058	;size		
	bsr	wb
	;move.w	#$0000,$dff180

	* M-00001111 10111000       *

	add.l	#plnsize,d1
	add.l	#$a00,d0

	move.l	d0,$dff050	;a source IM
	move.l	d2,$dff04c	;b mask IM
	move.l	d1,$dff048	;c source
	move.l	d1,$dff054	;d source	
	move.w	#%0000100000010101,$dff058	;size		
	bsr	wb
	;move.w	#$0000,$dff180

	add.l	#plnsize,d1
	add.l	#$a00,d0

	move.l	d0,$dff050	;a source IM
	move.l	d2,$dff04c	;b mask IM
	move.l	d1,$dff048	;c source
	move.l	d1,$dff054	;d source
	move.w	#%0000100000010101,$dff058	;size		
	bsr	wb
	;move.w	#$0000,$dff180

	rts


Getcirc:
	move.l	deg1,d0
	lea	lrgcircle,a0
	move.l	(a0,d0),d0
	move.l	d0,xvec

	add.l	#4,deg1
	add.l	deg1,a0
	cmp.l	#vec,a0
	bne	.lp
	move.l	#0,deg1
.lp:	add.l	#1,deg2
	cmp.l	#1000,deg2
	bne	.lp2
	move.l	#0,deg2
	eor.l	#-1,yvec
.lp2:	rts

updtspec:
	tst.l	spcl0
	beq	nospec0
	move.l	#spec0,a0
	move.l	spcl0,d0
	asl.l	#2,d0
	move.w	#$00ff,4(a0)
	sub.l	#1,spcl0
	move.l	#$51,d0		;80
	lea	spectab,a1
	move.l	spcl0,d1
	asl.l	#1,d1
	add.w	(a1,d1),d0
	move.b	d0,(a0)
	add.l	spcl0,d0
	move.b	d0,2(a0)
	move.l	spcl0,d0
	asl.l	#2,d0
	move.w	#0,4(a0)	
	lsr.l	#1,d0
nospec0:
	tst.w	mt_aud1temp
	beq	nov0
	move.l	#32,spcl0
	move.w	#0,mt_aud1temp
nov0:	
	tst.l	spcl1
	beq	nospec1
	move.l	#spec1,a0
	move.l	spcl1,d0
	asl.l	#2,d0
	move.w	#$00ff,4(a0)
	sub.l	#1,spcl1
	move.l	#$51,d0
	lea	spectab,a1
	move.l	spcl1,d1
	asl.l	#1,d1
	add.w	(a1,d1),d0
	move.b	d0,(a0)
	add.l	spcl1,d0
	move.b	d0,2(a0)
	move.l	spcl1,d0
	asl.l	#2,d0
	move.w	#0,4(a0)	
	lsr.l	#1,d0
nospec1:tst.w	mt_aud2temp
	beq	nov1
	move.l	#32,spcl1
	move.w	#0,mt_aud2temp
nov1:	
	tst.l	spcl2
	beq	nospec2
	move.l	#spec2,a0
	move.l	spcl2,d0
	asl.l	#2,d0
	move.w	#$00ff,4(a0)
	sub.l	#1,spcl2
	move.l	#$51,d0
	lea	spectab,a1
	move.l	spcl2,d1
	asl.l	#1,d1
	add.w	(a1,d1),d0
	move.b	d0,(a0)
	add.l	spcl2,d0
	move.b	d0,2(a0)
	move.l	spcl2,d0
	asl.l	#2,d0
	move.w	#0,4(a0)	
	lsr.l	#1,d0
nospec2:tst.w	mt_aud3temp
	beq	nov2
	move.l	#32,spcl2
	move.w	#0,mt_aud3temp
nov2:	
	tst.l	spcl3
	beq	nospec3
	move.l	#spec3,a0
	move.l	spcl3,d0
	asl.l	#2,d0
	move.l	#$00ff00ff,4(a0)
	sub.l	#1,spcl3
	move.l	#$51,d0
	lea	spectab,a1
	move.l	spcl3,d1
	asl.l	#1,d1
	add.w	(a1,d1),d0
	move.b	d0,(a0)
	add.l	spcl3,d0
	move.b	d0,2(a0)
	move.l	spcl3,d0
	asl.l	#2,d0
	move.l	#0,4(a0)	
	lsr.l	#1,d0
nospec3:tst.w	mt_aud4temp
	beq	nov3
	move.l	#32,spcl3
	move.w	#0,mt_aud4temp
nov3:	rts


; -----------------------------------------------
; ------- Soundtracker V2.4 - playroutine -------
; -----------------------------------------------

; call 'mt_init' to initialize the playroutine

start:	lea	mt_data,a0
	add.l	#$03b8,a0
	moveq	#$7f,d0
	moveq	#0,d1
mt_init1:
	move.l	d1,d2
	subq.w	#1,d0
mt_init2:
	move.b	(a0)+,d1
	cmp.b	d2,d1
	bgt.s	mt_init1
	dbf	d0,mt_init2
	addq.b	#1,d2

mt_init3:
	lea	mt_data,a0
	lea	mt_sample1(pc),a1
	asl.l	#8,d2
	asl.l	#2,d2
	add.l	#$438,d2
	add.l	a0,d2
	moveq	#$1e,d0
mt_init4:
	move.l	d2,(a1)+
	moveq	#0,d1
	move.w	42(a0),d1
	asl.l	#1,d1
	add.l	d1,d2
	add.l	#$1e,a0
	dbf	d0,mt_init4

	lea	mt_sample1(PC),a0
	moveq	#0,d0
mt_clear:
	move.l	(a0,d0.w),a1
	clr.l	(a1)
	addq.w	#4,d0
	cmp.w	#$7c,d0
	bne.s	mt_clear

	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	clr.l	mt_partnrplay
	clr.l	mt_partnote
	clr.l	mt_partpoint

	move.b	mt_data+$3b6,mt_maxpart+1
	rts

; call 'mt_end' to switch the sound off

stop:	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	move.w	#$f,$dff096
	rts

; the playroutine - call this every frame

replay:
	addq.w	#1,mt_counter
mt_cool:cmp.w	#6,mt_counter
	bne.s	mt_notsix
	clr.w	mt_counter
	bra	mt_rout2

mt_notsix:
	lea	mt_aud1temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp1
	lea	$dff0a0,a5		
	bsr.s	mt_arprout
mt_arp1:lea	mt_aud2temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp2
	lea	$dff0b0,a5
	bsr.s	mt_arprout
mt_arp2:lea	mt_aud3temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp3
	lea	$dff0c0,a5
	bsr.s	mt_arprout
mt_arp3:lea	mt_aud4temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp4
	lea	$dff0d0,a5
	bra.s	mt_arprout
mt_arp4:rts

mt_arprout:
	move.b	2(a6),d0
	and.b	#$0f,d0
	tst.b	d0
	beq	mt_arpegrt
	cmp.b	#$01,d0
	beq.s	mt_portup
	cmp.b	#$02,d0
	beq.s	mt_portdwn
	cmp.b	#$0a,d0
	beq.s	mt_volslide
	rts

mt_portup:
	moveq	#0,d0
	move.b	3(a6),d0
	sub.w	d0,22(a6)
	cmp.w	#$71,22(a6)
	bpl.s	mt_ok1
	move.w	#$71,22(a6)
mt_ok1:	move.w	22(a6),6(a5)
	rts

mt_portdwn:
	moveq	#0,d0
	move.b	3(a6),d0
	add.w	d0,22(a6)
	cmp.w	#$538,22(a6)
	bmi.s	mt_ok2
	move.w	#$538,22(a6)
mt_ok2:	move.w	22(a6),6(a5)
	rts

mt_volslide:
	moveq	#0,d0
	move.b	3(a6),d0
	lsr.b	#4,d0
	tst.b	d0
	beq.s	mt_voldwn
	add.w	d0,18(a6)
	cmp.w	#64,18(a6)
	bmi.s	mt_ok3
	move.w	#64,18(a6)
mt_ok3:	move.w	18(a6),8(a5)
	rts
mt_voldwn:
	moveq	#0,d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	sub.w	d0,18(a6)
	bpl.s	mt_ok4
	clr.w	18(a6)
mt_ok4:	move.w	18(a6),8(a5)
	rts

mt_arpegrt:
	move.w	mt_counter(PC),d0
	cmp.w	#1,d0
	beq.s	mt_loop2
	cmp.w	#2,d0
	beq.s	mt_loop3
	cmp.w	#3,d0
	beq.s	mt_loop4
	cmp.w	#4,d0
	beq.s	mt_loop2
	cmp.w	#5,d0
	beq.s	mt_loop3
	rts

mt_loop2:
	moveq	#0,d0
	move.b	3(a6),d0
	lsr.b	#4,d0
	bra.s	mt_cont
mt_loop3:
	moveq	#$00,d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	bra.s	mt_cont
mt_loop4:
	move.w	16(a6),d2
	bra.s	mt_endpart
mt_cont:
	add.w	d0,d0
	moveq	#0,d1
	move.w	16(a6),d1
	and.w	#$fff,d1
	lea	mt_arpeggio(PC),a0
mt_loop5:
	move.w	(a0,d0),d2
	cmp.w	(a0),d1
	beq.s	mt_endpart
	addq.l	#2,a0
	bra.s	mt_loop5
mt_endpart:
	move.w	d2,6(a5)
	rts

mt_rout2:
	lea	mt_data,a0
	move.l	a0,a3
	add.l	#$0c,a3
	move.l	a0,a2
	add.l	#$3b8,a2
	add.l	#$43c,a0
	move.l	mt_partnrplay(PC),d0
	moveq	#0,d1
	move.b	(a2,d0),d1
	asl.l	#8,d1
	asl.l	#2,d1
	add.l	mt_partnote(PC),d1
	move.l	d1,mt_partpoint
	clr.w	mt_dmacon

	lea	$dff0a0,a5
	lea	mt_aud1temp(PC),a6
	bsr	mt_playit
	lea	$dff0b0,a5
	lea	mt_aud2temp(PC),a6
	bsr	mt_playit
	lea	$dff0c0,a5
	lea	mt_aud3temp(PC),a6
	bsr	mt_playit
	lea	$dff0d0,a5
	lea	mt_aud4temp(PC),a6
	bsr	mt_playit

		moveq	#3-1,d0
pp_waitdma2	move.b	$dff006,d1
pp_waitdma3	cmp.b	$dff006,d1
		dbeq	d0,pp_waitdma2		;do a few *LAME* rasters waits
		beq.b	pp_waitdma3		;for samples to finish playing!

	move.w	#$8000,d0
	or.w	mt_dmacon,d0
	move.w	d0,$dff096

	lea	mt_aud4temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice3
	move.l	10(a6),$dff0d0
	move.w	#1,$dff0d4
mt_voice3:
	lea	mt_aud3temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice2
	move.l	10(a6),$dff0c0
	move.w	#1,$dff0c4
mt_voice2:
	lea	mt_aud2temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice1
	move.l	10(a6),$dff0b0
	move.w	#1,$dff0b4
mt_voice1:
	lea	mt_aud1temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice0
	move.l	10(a6),$dff0a0
	move.w	#1,$dff0a4
mt_voice0:
	move.l	mt_partnote(PC),d0
	add.l	#$10,d0
	move.l	d0,mt_partnote
	cmp.l	#$400,d0
	bne.s	mt_stop
mt_higher:
	clr.l	mt_partnote
	addq.l	#1,mt_partnrplay
	moveq	#0,d0
	move.w	mt_maxpart(PC),d0
	move.l	mt_partnrplay(PC),d1
	cmp.l	d0,d1
	bne.s	mt_stop
	clr.l	mt_partnrplay
mt_stop:tst.w	mt_status
	beq.s	mt_stop2
	clr.w	mt_status
	bra.s	mt_higher
mt_stop2:
	rts

mt_playit:
	move.l	(a0,d1.l),(a6)
	addq.l	#4,d1
	moveq	#0,d2
	move.b	2(a6),d2
	and.b	#$f0,d2
	lsr.b	#4,d2

	move.b	(a6),d0
	and.b	#$f0,d0
	or.b	d0,d2
	tst.b	d2
	beq.s	mt_nosamplechange

	moveq	#0,d3
	lea	mt_samples(PC),a1
	move.l	d2,d4
	asl.l	#2,d2
	mulu	#$1e,d4
	move.l	(a1,d2),4(a6)
	move.w	(a3,d4.l),8(a6)
	move.w	2(a3,d4.l),18(a6)
	move.w	4(a3,d4.l),d3
	tst.w	d3
	beq.s	mt_displace
	move.l	4(a6),d2
	add.l	d3,d2
	move.l	d2,4(a6)
	move.l	d2,10(a6)
	move.w	6(a3,d4.l),8(a6)
	move.w	6(a3,d4.l),14(a6)
	move.w	18(a6),8(a5)
	bra.s	mt_nosamplechange

mt_displace:
	move.l	4(a6),d2
	add.l	d3,d2
	move.l	d2,10(a6)
	move.w	6(a3,d4.l),14(a6)
	move.w	18(a6),8(a5)
mt_nosamplechange:
	move.w	(a6),d0
	and.w	#$fff,d0
	tst.w	d0
	beq.s	mt_retrout
	move.w	(a6),16(a6)
	move.w	20(a6),$dff096
	move.l	4(a6),(a5)
	move.w	8(a6),4(a5)
	move.w	(a6),d0
	and.w	#$fff,d0
	move.w	d0,6(a5)
	move.w	20(a6),d0
	or.w	d0,mt_dmacon

mt_retrout:
	tst.w	(a6)
	beq.s	mt_nonewper
	move.w	(a6),22(a6)

mt_nonewper:
	move.b	2(a6),d0
	and.b	#$0f,d0
	cmp.b	#$0b,d0
	beq.s	mt_posjmp
	cmp.b	#$0c,d0
	beq.s	mt_setvol
	cmp.b	#$0d,d0
	beq.s	mt_break
	cmp.b	#$0e,d0
	beq.s	mt_setfil
	cmp.b	#$0f,d0
	beq.s	mt_setspeed
	rts

mt_posjmp:
	not.w	mt_status
	moveq	#0,d0
	move.b	3(a6),d0
	subq.b	#1,d0
	move.l	d0,mt_partnrplay
	rts

mt_setvol:
	move.b	3(a6),8(a5)
	rts

mt_break:
	not.w	mt_status
	rts

mt_setfil:
	moveq	#0,d0
	move.b	3(a6),d0
	and.b	#1,d0
	rol.b	#1,d0
	and.b	#$fd,$bfe001
	or.b	d0,$bfe001
	rts

mt_setspeed:
	move.b	3(a6),d0
	and.b	#$0f,d0
	beq.s	mt_back
	clr.w	mt_counter
	move.b	d0,mt_cool+3
mt_back:rts

mt_aud1temp:
	dcb.w	10,0
	dc.w	1
	dcb.w	2,0
mt_aud2temp:
	dcb.w	10,0
	dc.w	2
	dcb.w	2,0
mt_aud3temp:
	dcb.w	10,0
	dc.w	4
	dcb.w	2,0
mt_aud4temp:
	dcb.w	10,0
	dc.w	8
	dcb.w	2,0

mt_partnote:	dc.l	0
mt_partnrplay:	dc.l	0
mt_counter:	dc.w	0
mt_partpoint:	dc.l	0
mt_samples:	dc.l	0
mt_sample1:	dcb.l	31,0
mt_maxpart:	dc.w	0
mt_dmacon:	dc.w	0
mt_status:	dc.w	0

mt_arpeggio:
	dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
	dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
	dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
	dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
	dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000

lrgcircle:
	dc.l	-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8
	dc.l	-8,-8,-8,-8,-8,-8,-8,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7
	dc.l	-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-5,-5,-5,-5,-5,-5,-5,-5,-5,-4
	dc.l	-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2
	dc.l	-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,1,1,1
	dc.l	1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3
	dc.l	3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5
	dc.l	6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7
	dc.l	7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
	dc.l	7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
	dc.l	7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6
	dc.l	5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,3
	dc.l	3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,1,1,1,1,1
	dc.l	1,1,1,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2
	dc.l	-2,-2,-2,-2,-2,-3,-3,-3,-3,-3,-3,-3,-3,-4,-4,-4,-4,-4,-4,-4
	dc.l	-4,-5,-5,-5,-5,-5,-5,-5,-5,-5,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6
	dc.l	-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-8,-8,-8,-8,-8,-8,-8
	dc.l	-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8

	dc.l	-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7
	dc.l	-6,-6,-6,-6,-6,-6,-6,-6,-6,-6,-5,-5,-5,-5,-5,-5,-5,-5,-5,-4
	dc.l	-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2
	dc.l	-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0

medcircle:
	dc.l	1,1,1,1,1,1,1,1,1,1,1,1,1
	dc.l	1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
	dc.l	2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3
	dc.l	3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
	dc.l	3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
	dc.l	3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2
	dc.l	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1
	dc.l	1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
	dc.l	0,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
	dc.l	-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2
	dc.l	-2,-2,-2,-2,-2,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3
	dc.l	-3,-3,-3,-3,-3,-3,-3,-3,-3,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4
	dc.l	-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4
	dc.l	-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4
	dc.l	-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-3,-3
	dc.l	-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2
	dc.l	-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1
	dc.l	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0
	dc.l	0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1
	dc.l	1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
	dc.l	2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3
	dc.l	3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
	dc.l	3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3

	dc.l	2,2,2,2,2,2,2,2,2
	dc.l	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1
	dc.l	1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
	dc.l	0,0,0,0,0,0,0,0,0,0

	dc.l	-1,-1,-1,-1,-1,-1,-1,-2,-2,-2
	dc.l	-2,-2,-2,-2,-2,-3,-3,-3,-3,-3,-3,-3,-3,-4,-4,-4,-4,-4,-4,-4
	dc.l	-4,-5,-5,-5,-5,-5,-5,-5,-5,-5,-6,-6,-6,-6,-6,-6,-6,-6,-6,-6
	dc.l	-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-7,-8,-8,-8,-8,-8,-8,-8
	dc.l	-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8,-8

vec:	dc.l	0


Killspr:
	move.l	#deadspr,d0
	move.w	d0,sp0+6
	move.w	d0,sp1+6
	move.w	d0,sp2+6
	move.w	d0,sp3+6
	move.w	d0,sp4+6
	move.w	d0,sp5+6
	move.w	d0,sp6+6
	move.w	d0,sp7+6
	swap	d0
	move.w	d0,sp0+2
	move.w	d0,sp1+2
	move.w	d0,sp2+2
	move.w	d0,sp3+2
	move.w	d0,sp4+2
	move.w	d0,sp5+2
	move.w	d0,sp6+2
	move.w	d0,sp7+2
	rts
	even

scrl:	tst.l	pause
	beq	.lp
	sub.l	#1,pause
	rts
.lp:	jsr	scrl2
scrl2:	sub.b	#1,scrlcount
	bne	nextpix
	moveq.l	#0,d0
	lea	mess,a0
	add.l	messcount,a0
	move.b	(a0),d0
	bne	notend
	move.l	#0,messcount
	bra	nextpix
notend:	cmp.b	#$ff,d0
	bne	notpause
	move.l	#100,pause
	add.l	#1,messcount
	rts
notpause:
	add.l	#1,messcount
	sub.b	#32,d0
	lea	pixwidth,a0
	move.b	(a0,d0),scrlcount
	asl.l	#1,d0
	lea	chars,a1
	add.l	d0,a1
	move.l	scrlbase,a0
	add.l	#42,a0

	moveq.l	#2,d0

.lp:	move.w	(a1),(a0)
	move.w	118(a1),44(a0)
	move.w	236(a1),88(a0)
	move.w	354(a1),132(a0)
	move.w	472(a1),176(a0)

	move.w	590(a1),220(a0)
	move.w	708(a1),264(a0)
	move.w	826(a1),308(a0)
	move.w	944(a1),352(a0)
	move.w	1062(a1),396(a0)

	move.w	1180(a1),440(a0)
	move.w	1298(a1),484(a0)
	move.w	1416(a1),528(a0)
	move.w	1534(a1),572(a0)
	move.w	1652(a1),616(a0)

	move.w	1770(a1),660(a0)
	move.w	1888(a1),704(a0)
	move.w	2006(a1),748(a0)
	move.w	2124(a1),792(a0)
	move.w	2242(a1),836(a0)

	move.w	2360(a1),880(a0)
	move.w	2478(a1),924(a0)
	move.w	2596(a1),968(a0)
	move.w	2714(a1),1012(a0)
	move.w	2832(a1),1056(a0)

	add.l	#$44c,a0
	add.l	#$b86,a1
	dbra	d0,.lp

nextpix:move.l	scrlbase,d0
	move.l	d0,d1
	add.l	#2,d0
	move.l	d0,$dff050	;a source IM
	move.l	d1,$dff054	;d source
	move.w	#$0000,$dff064	;a mod
	move.w	#$0000,$dff066	;d mod
	move.w	#$7fff,$dff044	;fw mask
	move.w	#$ffff,$dff046	;lw mask
	move.w	#%1111100111110000,$dff040	;con0
	move.w	#%1111000000000000,$dff042	;con1
	move.w	#%0000011001010110,$dff058	;size		
	bsr	wb
	;move.w	#$0000,$dff180


	add.l	#$44c,d1
	add.l	#$44c,d0
	
	move.l	d0,$dff050	;a source IM
	move.l	d1,$dff054	;d source
	move.w	#%0000011001010110,$dff058	;size		
	bsr	wb

	add.l	#$44c,d1
	add.l	#$44c,d0
	
	move.l	d0,$dff050	;a source IM
	move.l	d1,$dff054	;d source
	move.w	#%0000011001010110,$dff058	;size		
	bsr	wb

	rts

messcount:
	dc.l	0
pause:	dc.l	0
scrlcount:
	dc.b	2
	even

pixwidth:                 
	dc.b	10,6,14,16,16,16,16,7,11,11,16,16,7,16,7,16,16,7
	dc.b	16,16,16,16,16,16,16,16,6,7
	dc.b	16,16,16,16,16,16,16,16,16,16,16,16,16,6
	dc.b	16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
	dc.b	16,16,16


mess:	
	DC.B 	"                POO             ",255
	dc.b	"                      ",0
	
	even
	
plnaddr:
	dc.l	bpln1,bpln2,bpln3,bpln4,bpln5,bpln6,bpln7,bpln8
	dc.l	bpln9,bplna,bplnb,bplnc,bplnd,bplne,bplnf,bpln10
	dc.l	bpln11,bpln12,bpln13,bpln14,bpln15,bpln16,bpln17,bpln18
	dc.l	bpln19,bpln1a,bpln1b,bpln1c,bpln1d,bpln1e,bpln1f,bpln20
	dc.l	bpln21,bpln22,bpln23,bpln24,bpln25,bpln26,bpln27,bpln28
	dc.l	bpln29,bpln2a,bpln2b,bpln2c,bpln2d,bpln2e,bpln2f,bpln30
	dc.l	bpln31,bpln32,bpln33,bpln34,bpln35,bpln36,bpln37,bpln38
	dc.l	bpln39,bpln3a,bpln3b,bpln3c,bpln3d,bpln3e,bpln3f,bpln40
	dc.l	bpln41,bpln42,bpln43,bpln44,bpln45,bpln46,bpln47,bpln48
	dc.l	bpln49,bpln4a,bpln4b,bpln4c,bpln4d,bpln4e,bpln4f,bpln50
	dc.l	bpln51,bpln52,bpln53,bpln54,bpln55,bpln56,bpln57,bpln58
	dc.l	bpln59,bpln5a,bpln5b,bpln5c,bpln5d,bpln5e,bpln5f,bpln60
	dc.l	bpln61,bpln62,bpln63,bpln64,bpln65,bpln66,bpln67,bpln68
	dc.l	bpln69,bpln6a,bpln6b,bpln6c,bpln6d,bpln6e,bpln6f,bpln70
	dc.l	bpln71,bpln72,bpln73,bpln74,bpln75,bpln76,bpln77,bpln78
	dc.l	bpln79,bpln7a,bpln7b,bpln7c,bpln7d,bpln7e,bpln7f,bpln80

squdata:
	dc.w	0,0,0,0,0,1,1
	dc.w	1,1,2,2,2,3,3,4,4,5
	dc.w	5,6,6,7,7,8,9,9,10,11
	dc.w	12,13,13,14,15,16,17,18,19,20
	dc.w	21,22,23,24,25,26,28,29,30,31
	dc.w	33,34,35,37,38,39,41,42,44,45
	dc.w	47,48,50,52,53,55,57,58,60,62
	dc.w	64,65,67,69,71,73,75,77,79,81
	dc.w	83,85,87,89,91,93,96,98,100,102
	dc.w	105,107,109,112,114,117,119,121,124,127

squpos:	dc.w	0,20,40,60,80,100,120,140,160,180		;actual word offsets (+2)'s
startoff:
	dc.l	plndat-2
	dc.l	plndat2-2

plndat:
	incbin	bpln1
	incbin	bpln2
	incbin	bpln3
	incbin	bpln4
	incbin	bpln5
	incbin	bpln6
	incbin	bpln7
	incbin	bpln8
	incbin	bpln9
	incbin	bpln10
	incbin	bpln11
	incbin	bpln12
	incbin	bpln13
	incbin	bpln14
	incbin	bpln15
	incbin	bpln16

plndat2:
	ds.b	5120*16
blnk:	ds.b	40

deadspr:dc.l	0,0,0,0

mount1:	incbin	'mount1bit'
	even
mount2:	incbin	'mount2bit'
	even
mask:	incbin	'range2mask'
	even
logo:	incbin	'logobit'
	even
chars:	incbin	texyraw
	even

spcl0:	dc.l	32
spcl1:	dc.l	32
spcl2:	dc.l	32
spcl3:	dc.l	32
save1:	dc.l	0
save2:	dc.l	0
save3:	dc.l	0
save4:	dc.l	0
spectab:
	dc.w	32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17
	dc.w	16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,1
spec0:
	dc.w	$8041,$a000
	dc.w	$00ff,$0000
	dc.w	$00ff,$0000
	dc.w	$00fe,$0001
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$0000,$0000

spec1:
	dc.w	$8049,$a000
	dc.w	$00ff,$0000
	dc.w	$00ff,$0000
	dc.w	$00fe,$0001
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$0000,$0000

spec2:
	dc.w	$80cc,$a000
	dc.w	$00ff,$0000
	dc.w	$00ff,$0000
	dc.w	$00fe,$0001
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$0000,$0000

spec3:
	dc.w	$80d4,$a000
	dc.w	$00ff,$0000
	dc.w	$00ff,$0000
	dc.w	$00fe,$0001
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$00fc,$003f
	dc.w	$0000,$0000

mt_data:	incbin	'work:protracker/modules/mod.zadd_!'
