	section crap,code_c		; Use Chip Memory
	opt	c-,o+			; No Case Sensitivity, Optimize on


 move.l #sprite0,d0
 move.w d0,sp0l
 swap d0
 move.w d0,sp0h

	lea	$dff180,a0
	move.w	#31,d0
clear:	move.w	#$0fff,(a0)+
	dbf	d0,clear

	move.l	4.w,a6			; Get Execbase
	jsr	-132(a6)		; Turn off Muli-tasking (Forbid)
	lea	gfxlib,a1		
	moveq	#0,d0
	move.l	4.w,a6
	jsr	-$228(a6)		; Open graphics library
	tst	d0
	beq	error
	move.l	d0,gfxbse
	move.l	#screen,d0		; Store Screen address in Copper list
	move.w	d0,pl0l
	swap	d0
	move.w	d0,pl0h
	move.l	#screen3,d0		; Store Screen address in Copper list
	move.w	d0,pl1l
	swap	d0
	move.w	d0,pl1h
	move.l	#screen2,d0			; Size of one Bitplane
	move.w	d0,pl2l			; Second Bitplane
	swap	d0
	move.w	d0,pl2h
	move.l	gfxbse,a6		; Set up copper list
	add.l	#$32,a6
	move.w	#$80,$dff096
	move.l	(a6),oldcpr		; Store workbench copper list
	move.l	#newcpr,(a6)		; Use our copper list
	move.w	#$8080,$dff096
	move.w	#$8010,$dff09a		; Enable level 3 interrupt
	move.l	$6c.w,old		; Store old level 3 interrupt
	move.l	#new,$6c.w		; Use our interrupt
	bset	#1,$bfe001
	jsr	mt_init

	clr.w $dff042			; nothing set in BLTCON1

	****************
	* Blit plane 2 *
	****************

	lea screen3+(14*48)+6,a2	; Destination
	lea logo+(256*40),a0		; Source
blitready4x
	btst #14,$dff002
	bne.s blitready4x

	move.l	a0,$dff050
	move.l	a2,$dff054
	move.l	#$ffffffff,$dff044
	move.w	#8,$dff066
	move.w	#0,$dff064
	move.w	#%0000100111110000,$dff040
	clr.w	$dff042
	move.w	#%100000000010100,$dff058

	*****************
	* Blit plane 1 *
	*****************

	lea screen+(14*48)+4,a2	; Destination
	lea logo,a0			; Source
blitready4y
	btst #14,$dff002
	bne.s blitready4y

	move.l	a0,$dff050
	move.l	a2,$dff054
	move.l	#$ffffffff,$dff044
	move.w	#8,$dff066
	move.w	#0,$dff064
	move.w	#%0010100111110000,$dff040
	clr.w	$dff042
	move.w	#%100000000010100,$dff058

	*****************
	* Blit plane 3 *
	*****************

	lea screen2+(14*48)+4,a2	; Destination
	lea logo+(512*40),a0			; Source
blitready4yac
	btst #14,$dff002
	bne.s blitready4yac

	move.l	a0,$dff050
	move.l	a2,$dff054
	move.l	#$ffffffff,$dff044
	move.w	#8,$dff066
	move.w	#0,$dff064
	move.w	#%0010100111110000,$dff040
	clr.w	$dff042
	move.w	#%100000000010100,$dff058

wait:	btst	#6,$bfe001		; Test for left mouse button
	bne.s	wait			; Wait if not pressed
	bclr	#1,$bfe001
	jsr	mt_end
	move.l	old,$6c.w		; Else return to workbench
	move.l	#$10,$dff09a		; Disable copper interrupt
	move.l	gfxbse,a6		; Copper list
	add.l	#$32,a6
	move.w	#$0080,$dff096
	move.l	oldcpr,(a6)
	move.w	#$8080,$dff096
	move.l	gfxbse,a1		; Close graphics library
	move.l	$4.w,a6
	jsr	-$19e(a6)
	move.l	$4.w,a6			; Execbase
	jsr	-138(a6)		; Permit - Restart multi-tasking
error:	moveq	#0,d0			; Exit routine
	rts

nsine:	move.l	wavepos,a5
	move.w	(a5)+,d5
	add.l	d5,a2
	cmp.w	#9999,(a5)
	bne	jeeez
	lea	sinew,a5
jeeez	move.l	a5,wavepos
	rts

text1:	dc.b	" # MERCENARY #     @         "
	DC.B	" PRESENT...          "
	DC.B	"$MUSIC DISK VOLUME 1$ @         "
	DC.B	"                              "
	dcb.b	5000,0

pause:	dc.w	0

speed:	dc.w	%0010000000000000

sine1p:	dc.l	sine1
sine1:	dc.b	0,0,0,0,1,1,1,2,2,2,3,3,4,4,5,6,7,8,8,9,10,11,12,13
	dc.b	15,16,17,19,20,22,24,26,28,30,32,33,35,36,37
	dc.b	39,40,41,42,43,44,44,45,46,47,48,48,49,49
	dc.b	50,50,50,51,51,51,52,52
	dc.b	52,52,51,51,51,50,50,50
	dc.b	49,49,48,48,47,46,45,44,44,43,42,41,40,39
	dc.b	37,36,35,33,32,30,28,26,24,22,20,19,17,16,15
	dc.b	13,12,11,10,9,8,8,7,6,5,4,4,3,3,2,2,2,1,1,1,99

;boby:	dc.l	0

new:	movem.l	d0-d7/a0-a6,-(sp)	; Save all registers
	and.w	#$10,$dff01e		; Check if it is copper interrupt
	beq	out			; If not, skip this code
	move.w	#$10,$dff09c

;	**********************************************************
;	***          This is where the code goes!!!!           ***
;	**********************************************************

	jsr	mt_music
	jsr blitclear		; Start the blitter clearing!

;	clr.l	d1
;	move.l	sine1p,a0
;	move.b	(a0)+,d1
;	cmp.b	#99,(a0)
;	bne	ok1
;	lea	sine1,a0
;ok1	move.l	a0,sine1p
;	jsr bob

;	jsr	switchscreen

;	move.l	current,d0		; Store Screen address in Copper list
;	move.w	d0,pl0l
;	swap	d0
;	move.w	d0,pl0h

	lea screen3+250*48,a2		; Destination
	lea scroll,a0		; Source
blitready4
	btst #14,$dff002
	bne.s blitready4

	move.l	a0,$dff050
	move.l	a2,$dff054
	move.l	#$ffffffff,$dff044
	move.w	#0,$dff066
	move.w	#0,$dff064
	move.w	#%0000100111110000,d2
	move.w	shift,d0
	cmp.w	#0,shift
	bne	subit
	move.w	#%1110000000000000,d0
	bra	putit
subit:	move.w	speed,d1
	sub.w	d1,d0
putit:	move.w	d0,shift
	add.w	d0,d2
	move.w	d2,$dff040
	move.w	#%01111011000,$dff058

	move.w	pause,d0	
	cmp.w	#0,d0
	beq	b
	subq.w	#1,d0
	move.w	d0,pause
	bra	nomove

b	move.w	shift,d0
	cmp.w	#%0000000000000000,d0
	bne	noscroll
	lea scroll,a2		; Destination
	lea scroll+2,a0		; Source
blitready3
	btst #14,$dff002
	bne.s blitready3

	move.l	a0,$dff050
	move.l	a2,$dff054
	move.w	#0,$dff066
	move.w	#0,$dff064
	move.w	#%0000100111110000,$dff040
	move.w	#%01111011001,$dff058
noshit:	move.l	tpoi1,a0
	clr.l	d0
	move.b	(a0)+,d0
	cmp.b	#"@",d0
	bne	no
	move.w	#251,pause
	move.l	a0,tpoi1
	move.w	#%0000000000000000,speed
	bra	nomove
no	cmp.b	#0,d0
	bne	find
	lea	text1,a0
	move.b	(a0),d0
find:	move.l	a0,tpoi1
	sub.b	#$20,d0
	lea	chars,a0
loopy:	cmp.l	#19,d0
	ble	smch
	sub.b	#20,d0
	add.l	#40*16,a0
	bra.s	loopy
smch	add.l	d0,a0
	add.l	d0,a0
	move.l	a0,char1

noscroll:
	lea scroll+46,a2	; Destination
	move.l	char1,a0
blitready3a
	btst #14,$dff002
	bne.s blitready3a

	move.l	a0,$dff050
	move.l	a2,$dff054
	move.w	#46,$dff066
	move.w	#38,$dff064
	move.w	#%0000100111110000,$dff040
	move.w	#%01111000001,$dff058

nomove:	move.w	pause,d0
	cmp.w	#1,d0
	bne	tch
	move.w	#%0010000000000000,speed
tch:
	jsr equalizer2		; Equalizers pleeeeeez!

	BTST	#10,$DFF016
	BNE.S	OUT

	move.w	#$00f0,$dff180

out:	movem.l	(sp)+,d0-d7/a0-a6	; Restore registers

	dc.w	$4ef9			; JSR instruction

old:	dc.l	0
oldcpr:	dc.l	0			; Workbench copper list

current:dc.l	screen

source:
	dc.l	screen3+250*48
dest:
	dc.l	screen+(70*48)+2

;source1:
;	dc.l	screen+(300*48)+2
dest1:
	dc.l	screen+(70*48)+2
dest1a:
	dc.l	screen+(70*48)+2

;source2:
;	dc.l	screen2+(300*48)+2
dest2:
	dc.l	screen2+(70*48)+2
dest2a:
	dc.l	screen2+(70*48)+2

;ch:	dcb.l	256,$ffffffff

;a0store:
;	dc.l	0
;a2store:
;	dc.l	0
;

tpoi1:	dc.l	text1

char1:	dc.l	chars

apoi:	dc.l	0
;pos1:	dc.l	sine2
;pos2:	dc.l	sine
posit:	dc.w	0
shift:	dc.w	%1110000000000000
shift2:	dc.w	%1110000000000000
newcpr:	dc.w	$100,%0011001000000000,$102,14
	dc.w	$92,$20,$94,$d8,$8e,$1a64,$90,$39d1,$e0
pl0h:	dc.w	0,$e2
pl0l:	dc.w	0,$e4
pl1h:	dc.w	0,$e6
pl1l:	dc.w	0,$e8
pl2h:	dc.w	0,$ea
pl2l:	dc.w	0,$120
SP0H DC.W 0,$122
SP0L DC.W 0,$180
	dc.w	0
	dc.w	$9c,$8010		; Call copper interrupt

	dc.w	$0182,$0fff
	dc.w	$0184,$0888
	dc.w	$0186,$000f
	dc.w	$0188,$004f
	dc.w	$018a,$008f
	dc.w	$018c,$00cf
	dc.w	$018e,$00ff

	dc.w	$4c01,$fffe,$182,$220
	dc.w	$4d01,$fffe,$182,$440
	dc.w	$4e01,$fffe,$182,$660
	dc.w	$4f01,$fffe,$182,$880
	dc.w	$5001,$fffe,$182,$aa0
	dc.w	$5101,$fffe,$182,$cc0
	dc.w	$5201,$fffe,$182,$ff0
	dc.w	$5301,$fffe,$182,$ff0
	dc.w	$5401,$fffe,$182,$cc0
	dc.w	$5501,$fffe,$182,$aa0
	dc.w	$5601,$fffe,$182,$880
	dc.w	$5701,$fffe,$182,$660
	dc.w	$5801,$fffe,$182,$440
	dc.w	$5901,$fffe,$182,$220
	dc.w	$188,0

	DC.W	$6001,$FFFE,$182,$010,$604F,$FFFE,$182,$101,$60C1,$FFFE,$182,$011
	DC.W	$6101,$FFFE,$182,$020,$614F,$FFFE,$182,$202,$61C1,$FFFE,$182,$022
	DC.W	$6201,$FFFE,$182,$030,$624F,$FFFE,$182,$303,$62C1,$FFFE,$182,$033
	DC.W	$6301,$FFFE,$182,$040,$634F,$FFFE,$182,$404,$63C1,$FFFE,$182,$044
	DC.W	$6401,$FFFE,$182,$050,$644F,$FFFE,$182,$505,$64C1,$FFFE,$182,$055
	DC.W	$6501,$FFFE,$182,$060,$654F,$FFFE,$182,$606,$65C1,$FFFE,$182,$066
	DC.W	$6601,$FFFE,$182,$070,$664F,$FFFE,$182,$707,$66C1,$FFFE,$182,$077
	DC.W	$6701,$FFFE,$182,$080,$674F,$FFFE,$182,$808,$67C1,$FFFE,$182,$088
	DC.W	$6801,$FFFE,$182,$090,$684F,$FFFE,$182,$909,$68C1,$FFFE,$182,$099
	DC.W	$6901,$FFFE,$182,$0A0,$694F,$FFFE,$182,$A0A,$69C1,$FFFE,$182,$0AA
	DC.W	$6A01,$FFFE,$182,$0B0,$6A4F,$FFFE,$182,$B0B,$6AC1,$FFFE,$182,$0BB
	DC.W	$6B01,$FFFE,$182,$0C0,$6B4F,$FFFE,$182,$C0C,$6BC1,$FFFE,$182,$0CC
	DC.W	$6C01,$FFFE,$182,$0D0,$6C4F,$FFFE,$182,$D0D,$6CC1,$FFFE,$182,$0DD
	DC.W	$6D01,$FFFE,$182,$0E0,$6D4F,$FFFE,$182,$E0E,$6DC1,$FFFE,$182,$0EE
	DC.W	$6E01,$FFFE,$182,$0F0,$6E4F,$FFFE,$182,$F0F,$6EC1,$FFFE,$182,$0FF
	DC.W	$6F01,$FFFE,$182,$0F0,$6F4F,$FFFE,$182,$F0F,$6FC1,$FFFE,$182,$0FF
	DC.W	$7001,$FFFE,$182,$0F0,$704F,$FFFE,$182,$F0F,$70C1,$FFFE,$182,$0FF
	DC.W	$7101,$FFFE,$182,$0F0,$714F,$FFFE,$182,$F0F,$71C1,$FFFE,$182,$0FF
	DC.W	$7201,$FFFE,$182,$0F0,$724F,$FFFE,$182,$F0F,$72C1,$FFFE,$182,$0FF

	DC.W	$7301,$FFFE,$182,$010,$734F,$FFFE,$182,$101,$73C1,$FFFE,$182,$011
	DC.W	$7401,$FFFE,$182,$020,$744F,$FFFE,$182,$202,$74C1,$FFFE,$182,$022
	DC.W	$7501,$FFFE,$182,$030,$754F,$FFFE,$182,$303,$75C1,$FFFE,$182,$033
	DC.W	$7601,$FFFE,$182,$040,$764F,$FFFE,$182,$404,$76C1,$FFFE,$182,$044
	DC.W	$7701,$FFFE,$182,$050,$774F,$FFFE,$182,$505,$77C1,$FFFE,$182,$055
	DC.W	$7801,$FFFE,$182,$060,$784F,$FFFE,$182,$606,$78C1,$FFFE,$182,$066
	DC.W	$7901,$FFFE,$182,$070,$794F,$FFFE,$182,$707,$79C1,$FFFE,$182,$077
	DC.W	$7A01,$FFFE,$182,$080,$7A4F,$FFFE,$182,$808,$7AC1,$FFFE,$182,$088
	DC.W	$7B01,$FFFE,$182,$090,$7B4F,$FFFE,$182,$909,$7BC1,$FFFE,$182,$099
	DC.W	$7C01,$FFFE,$182,$0A0,$7C4F,$FFFE,$182,$A0A,$7CC1,$FFFE,$182,$0AA
	DC.W	$7D01,$FFFE,$182,$0B0,$7D4F,$FFFE,$182,$B0B,$7DC1,$FFFE,$182,$0BB
	DC.W	$7E01,$FFFE,$182,$0C0,$7E4F,$FFFE,$182,$C0C,$7EC1,$FFFE,$182,$0CC
	DC.W	$7F01,$FFFE,$182,$0D0,$7F4F,$FFFE,$182,$D0D,$7FC1,$FFFE,$182,$0DD
	DC.W	$8001,$FFFE,$182,$0E0,$804F,$FFFE,$182,$E0E,$80C1,$FFFE,$182,$0EE
	DC.W	$8101,$FFFE,$182,$0F0,$814F,$FFFE,$182,$F0F,$81C1,$FFFE,$182,$0FF
	DC.W	$8201,$FFFE,$182,$0F0,$824F,$FFFE,$182,$F0F,$82C1,$FFFE,$182,$0FF
	DC.W	$8301,$FFFE,$182,$0F0,$834F,$FFFE,$182,$F0F,$83C1,$FFFE,$182,$0FF
	DC.W	$8401,$FFFE,$182,$0F0,$844F,$FFFE,$182,$F0F,$84C1,$FFFE,$182,$0FF
	DC.W	$8501,$FFFE,$182,$0F0,$854F,$FFFE,$182,$F0F,$85C1,$FFFE,$182,$0FF

	dc.w	$ffe1,$fffe,$0001,$fffe,$184,$0fff


	dc.w	$186,$fff,$18c,$fff
	dc.w	$102,%0000000001001111

	dc.w	$0301,$fffe,$188,$f0f,$18a,$f0f
	dc.w	$0601,$fffe,$188,$f0e,$18a,$f0e
	dc.w	$0701,$fffe,$188,$f0d,$18a,$f0d
	dc.w	$0801,$fffe,$188,$f0c,$18a,$f0c
	dc.w	$0901,$fffe,$188,$f0b,$18a,$f0b
	dc.w	$0a01,$fffe,$188,$f0a,$18a,$f0a
	dc.w	$0b01,$fffe,$188,$f09,$18a,$f09
	dc.w	$0c01,$fffe,$188,$f08,$18a,$f08
	dc.w	$0d01,$fffe,$188,$f07,$18a,$f07
	dc.w	$0e01,$fffe,$188,$f06,$18a,$f06
	dc.w	$0f01,$fffe,$188,$f05,$18a,$f05
	dc.w	$1001,$fffe,$188,$f04,$18a,$f04
	dc.w	$1101,$fffe,$188,$f03,$18a,$f03
	dc.w	$1201,$fffe,$188,$f02,$18a,$f02
	dc.w	$1301,$fffe,$188,$f01,$18a,$f01
	dc.w	$1401,$fffe,$188,$f00,$184,$f0f,$18c,$f00
	dc.w	$102,%0000000001001111
	dc.w	$1501,$fffe,$188,$f10,$184,$f1f,$18c,$f1f
	dc.w	$1601,$fffe,$188,$f20,$184,$f2f,$18c,$f2f
	dc.w	$1701,$fffe,$188,$f30,$184,$f3f,$18c,$f3f
	dc.w	$1801,$fffe,$188,$f40,$184,$f4f,$18c,$f4f
	dc.w	$1901,$fffe,$188,$f50,$184,$f5f,$18c,$f5f
	dc.w	$1a01,$fffe,$188,$f60,$184,$f6f,$18c,$f6f
	dc.w	$1b01,$fffe,$188,$f70,$184,$f7f,$18c,$f7f
	dc.w	$1c01,$fffe,$188,$f80,$184,$f8f,$18c,$f8f
	dc.w	$1d01,$fffe,$188,$f90,$184,$f9f,$18c,$f9f
	dc.w	$1e01,$fffe,$188,$fa0,$184,$faf,$18c,$faf
	dc.w	$1f01,$fffe,$188,$fb0,$184,$fbf,$18c,$fbf
	dc.w	$2001,$fffe,$188,$fc0,$184,$fcf,$18c,$fcf
	dc.w	$2101,$fffe,$188,$fd0,$184,$fdf,$18c,$fdf
	dc.w	$2201,$fffe,$188,$fe0,$184,$fef,$18c,$fef
	dc.w	$2301,$fffe,$188,$ff0,$184,$fff,$18c,$fff
	dc.w	$2401,$fffe,$188,$ff1
	dc.w	$2501,$fffe,$188,$ff2
	dc.w	$2601,$fffe,$188,$ff3
	dc.w	$2701,$fffe,$188,$ff4
	dc.w	$2801,$fffe,$188,$ff5
	dc.w	$2901,$fffe,$188,$ff6

	dc.w	$ffff,$fffe		; End copper

gfxlib:	dc.b	"graphics.library",0
	even
gfxbse:	dc.l	0

screen:	dcb.b	52*262,0
screen2:dcb.b	52*262,0
screen3:dcb.b	52*262,0
screen4:dcb.b	52*25,0

chars:	incbin	"chars"
	dcb.w	52*8,0
scroll:	dcb.w	52*32,0

dir:	dc.w	0

switchscreen:
	move.l	current,a0
	cmp.l	#screen,a0
	bne	sc2
	move.l	#screen2,a0
	move.l	a0,current
	move.l	dest2,a0
	move.l	a0,dest
	rts

sc2:	move.l	#screen,a0
	move.l	a0,current
	move.l	dest1,a0
	move.l	a0,dest
	rts

i=1440
sinew:	dc.w	0000,0000,0000,0000,0000,0048,0048,0048,0048,0096,0096,0096,0144,0144
	dc.w	0192,0192,0240,0288,0288,0336,0384,0432,0432

	dc.w	0480,0528,0576,0624,0672,0720,0768,0816,0864,0912
	dc.w	0960,1008,1056,1104,1152,1200,1248,1296,1344,1392
	dc.w	1440,1488,1536,1584,1632,1680,1728,1776,1824,1872
	dc.w	1920,1968,2016,2064,2112,2160,2208,2256,2304,2352

	dc.w	2400,2448,2496,2544,2592,2640,2688,2736,2784,2832
	dc.w	2880,2928,2976,3024,3072,3120,3168,3216,3264,3312
	dc.w	3360,3408,3456,3504,3552,3600,3648,3696,3744,3792

	dc.w	2400+i,2400+i,2448+i,2496+i,2544+i,2544+i,2592+i,2640+i,2640+i,2688+i,2688+i,2736+i,2736+i
	dc.w	2736+i,2784+i,2784+i,2784+i,2784+i,2832+i,2832+i,2832+i,2832+i,2832+i,2784+i,2784+i,2784+i
	dc.w	2784+i,2736+i,2736+i,2736+i,2688+i,2688+i,2640+i,2640+i,2592+i,2544+i,2544+i,2496+i
	dc.w	2448+i,2400+i,2400+i

	dc.w	3792,3744,3696,3648,3600,3552,3504,3456,3408,3360
	dc.w	3312,3264,3216,3168,3120,3072,3024,2976,2928,2880
	dc.w	2832,2784,2736,2688,2640,2592,2544,2496,2448,2400

	dc.w	2352,2304,2256,2208,2160,2112,2064,2016,1968,1920
	dc.w	1872,1824,1776,1728,1680,1632,1584,1536,1488,1440
	dc.w	1392,1344,1296,1248,1200,1152,1104,1056,1008,0960
	dc.w	0912,0864,0816,0768,0720,0672,0624,0576,0528,0480

	dc.w	0432,0432,0384,0336,0288
	dc.w	0288,0240,0192,0192,0144,0144,0096,0096,0096,0048,0048,0048,0048

;	dc.w	0000,0000,0000,0000,0000,0048,0048,0048,0048,0096,0096,0096,0144,0144
;	dc.w	0192,0192,0240,0288,0288,0336,0384,0432,0432

;	dc.w	0480,0528,0576,0624,0672,0720,0768,0816,0864,0912
;	dc.w	0960,1008,1056,1104,1152,1200,1248,1296,1344,1392
;	dc.w	1440,1488,1536,1584,1632,1680,1728,1776,1824,1872
;	dc.w	1920,1968,2016,2064,2112,2160,2208,2256,2304,2352

;	dc.w	2400,2400,2448,2496,2544,2544,2592,2640,2640,2688,2688,2736,2736
;	dc.w	2736,2784,2784,2784,2784,2832,2832,2832,2832,2832,2784,2784,2784
;	dc.w	2784,2736,2736,2736,2688,2688,2640,2640,2592,2544,2544,2496
;	dc.w	2448,2400,2400

;	dc.w	2352,2304,2256,2208,2160,2112,2064,2016,1968,1920
;	dc.w	1872,1824,1776,1728,1680,1632,1584,1536,1488,1440
;	dc.w	1392,1344,1296,1248,1200,1152,1104,1056,1008,0960
;	dc.w	0912,0864,0816,0768,0720,0672,0624,0576,0528,0480

;	dc.w	0432,0432,0384,0336,0288
;	dc.w	0288,0240,0192,0192,0144,0144,0096,0096,0096,0048,0048,0048,0048

j=-1920

;	dc.w	0,0,0,0,0,48,48,48,48
;	dc.w	96,96,96,144,144
;	dc.w	192,192,240,288,288,336,384,432,432

;	dc.w	2400+j,2400+j,2448+j,2496+j,2544+j,2544+j,2592+j,2640+j,2640+j,2688+j,2688+j,2736+j,2736+j
;	dc.w	2736+j,2784+j,2784+j,2784+j,2784+j,2832+j,2832+j,2832+j,2832+j,2832+j,2784+j,2784+j,2784+j
;	dc.w	2784+j,2736+j,2736+j,2736+j,2688+j,2688+j,2640+j,2640+j,2592+j,2544+j,2544+j,2496+j
;	dc.w	2448+j,2400+j,2400+j

;	dc.w	432,432,384,336,288,288,240,192,192
;	dc.w	144,144,96,96,96
;	dc.w	48,48,48,48,0,0,0,0


	dc.w	9999,9999,9999,9999,9999

wavepos:
	dc.l	sinew
wavemove:
	dc.l	sinew


sprite0:
	dc.w	0,0,0,0,0,0

pos:	dc.l	cols

cols:	dc.w	$f00
	dc.w	$f10,$f20,$f30,$f40,$f50,$f60,$f70,$f80
	dc.w	$f90,$fa0,$fb0,$fc0,$fd0,$fe0,$ff0
	dc.w	$ef0,$df0,$cf0,$bf0,$af0,$9f0,$8f0,$7f0
	dc.w	$6f0,$5f0,$4f0,$3f0,$2f0,$1f0,$0f0
	dc.w	$0f1,$0f2,$0f3,$0f4,$0f5,$0f6,$0f7,$0f8
	dc.w	$0f9,$0fa,$0fb,$0fc,$0fd,$0fe,$0ff
	dc.w	$0ef,$0df,$0cf,$0bf,$0af,$09f,$08f,$07f
	dc.w	$06f,$05f,$04f,$03f,$02f,$01f,$00f
	dc.w	$10f,$20f,$30f,$40f,$50f,$60f,$70f,$80f
	dc.w	$90f,$a0f,$b0f,$c0f,$d0f,$e0f,$f0f
	dc.w	$f0e,$f0d,$f0c,$f0b,$f0a,$f09,$f08,$f07
	dc.w	$f06,$f05,$f04,$f03,$f02,$f01
	dc.w	$f00
	dc.w	$f10,$f20,$f30,$f40,$f50,$f60,$f70,$f80
	dc.w	$f90,$fa0,$fb0,$fc0,$fd0,$fe0,$ff0
	dc.w	$ef0,$df0,$cf0,$bf0,$af0,$9f0,$8f0,$7f0
	dc.w	$6f0,$5f0,$4f0,$3f0,$2f0,$1f0,$0f0
	dc.w	$0f1,$0f2,$0f3,$0f4,$0f5,$0f6,$0f7,$0f8
	dc.w	$0f9,$0fa,$0fb,$0fc,$0fd,$0fe,$0ff
	dc.w	$0ef,$0df,$0cf,$0bf,$0af,$09f,$08f,$07f
	dc.w	$06f,$05f,$04f,$03f,$02f,$01f,$00f
	dc.w	$10f,$20f,$30f,$40f,$50f,$60f,$70f,$80f
	dc.w	$90f,$a0f,$b0f,$c0f,$d0f,$e0f,$f0f
	dc.w	$f0e,$f0d,$f0c,$f0b,$f0a,$f09,$f08,$f07
	dc.w	$f06,$f05,$f04,$f03,$f02,$f01

	dc.w	$ffff

b1:	dc.w	$000,$220,$440,$660,$880
	dc.w	$aa0,$cc0,$ee0,$ff0,$ee0
	dc.w	$cc0,$aa0,$880,$660,$440
	dc.w	$220

b2:	dc.w	$000,$200,$400,$600,$800
	dc.w	$a00,$c00,$e00,$f00,$e00
	dc.w	$c00,$a00,$800,$600,$400
	dc.w	$200

b3:	dc.w	$000,$020,$040,$060,$080
	dc.w	$0a0,$0c0,$0e0,$0f0,$0e0
	dc.w	$0c0,$0a0,$080,$060,$040
	dc.w	$020

b4:	dc.w	$000,$002,$004,$006,$008
	dc.w	$00a,$00c,$00e,$00f,$00e
	dc.w	$00c,$00a,$008,$006,$004
	dc.w	$002

logo:	incbin	"mercenary.bmp"

	****************************************
	* Routine to put a bob onto the screen *
	*   using co-ordinates D0=X and D1=Y   *
	****************************************

bob:	lea screen3+(160*48)+20,a2	; Destination
	mulu	#48,d1
	add.l	d1,a2
	lea	chars+6,a0	; Source
blitreadybob
	btst #14,$dff002
	bne.s blitreadybob

	move.l	a0,$dff050
	move.l	a2,$dff04c
	move.l	a2,$dff054
	move.l	#-1,$dff044
	move.w	#46,$dff066
	move.w	#46,$dff062
	move.w	#38,$dff064
	move.w	#%0000110111111100,$dff040
	clr.w	$dff042
	move.w	#%01110000001,$dff058

	rts

upbig equ 25
upsmall equ 20
upsmaller equ 15
upsmall1 equ 10
upsmall2 equ 5
downvalue equ 2
barht equ 40
winheight equ 45

	*************************************
	***   SPECTRUM ANALYZER ROUTINE   ***
	*** (80 BANDS, 40 REAL POSITIONS) ***
	*************************************

eqsub:	move.w (a0),d0
	bne.s eqsub2
	rts

eqsub2	clr.w (a0)
	lea notetable,a1
	moveq #0,d1
nomatch	move.w (a1)+,d2			; this works out the position
	cmp.w d2,d0			; along the equalizer for the
	bgt.s match			; bar by using the note table
	addq.b #1,d1			; in the music play routine
	bra.s nomatch
match	;move.w d1,testpt2
	lea eqtab(pc),a1
	add.l d1,a1
	add.l d1,a1
	addq.l	#3,a1
	add.b #upbig,(a1)
	add.b #upsmall,-1(a1)
	add.b #upsmall,1(a1)
	add.b #upsmaller,-2(a1)
	add.b #upsmaller,2(a1)
	add.b #upsmall1,-3(a1)
	add.b #upsmall1,3(a1)
	add.b #upsmall2,-4(a1)
	add.b #upsmall2,4(a1)
	
noplus	move.b (a1),d0
	cmp.b #barht,d0
	bls.s less50
	move.b #barht,(a1)
less50	move.b -1(a1),d0
	cmp.b #barht-2,d0
	bls.s less41
	move.b #barht-2,-1(a1)
less41	move.b 1(a1),d0
	cmp.b #barht-2,d0
	bls.s less42
	move.b #barht-2,1(a1)
less42	move.b 2(a1),d0
	cmp.b #barht-2,d0
	bls.s less43
	move.b #barht-3,2(a1)
less43	move.b 3(a1),d0
	cmp.b #barht-2,d0
	bls.s less44
	move.b #barht-2,3(a1)
less44	move.b 4(a1),d0
	cmp.b #barht-2,d0
	bls.s less45
	move.b #barht-2,4(a1)
less45	move.b -2(a1),d0
	cmp.b #barht-2,d0
	bls.s less46
	move.b #barht-2,-2(a1)
less46	move.b -3(a1),d0
	cmp.b #barht-2,d0
	bls.s less47
	move.b #barht-2,-3(a1)
less47	move.b -4(a1),d0
	cmp.b #barht-2,d0
	bls.s less48
	move.b #barht-2,-4(a1)
less48	
	rts




equalizer2:
	lea eq1p,a0
	bsr eqsub
	lea eq2p,a0
	bsr eqsub
	lea eq3p,a0
	bsr eqsub
	lea eq4p,a0
	bsr eqsub
blitfin2:
;	btst #14,$dff002		
;	bne.s blitfin2		; wait till blitter ready

	moveq #79,d0		; 80 segments	
	move.b	#%00001110,d5
	
	lea eqtab(pc),a1 	; table
	lea screen2+48*247+4,a2	; picture
mainlp	moveq #0,d1
	move.b (a1),d1		; get byte
	move.l d1,d4		;
	neg.w d1
	add.w #barht/2+6,d1		; subtract from bar height
	mulu #48,d1			; multiply by 48 (MODULO)

	ror.b	#4,d5

	cmp.w	#0,d4
	beq.s	nobar

	cmp.w	#barht,d4
	ble.s	fillbar
	move.w	#40,d4
	
fillbar	
	or.b d5,0(a2,d1)	; splat on equalizer
	add.w #48,d1
	dbra d4,fillbar

nobar:
	move.b (a1),d3
	subq.b #downvalue,(a1)
	bpl.s izok		; hasn't gone below zero
	move.b #0,(a1)
izok	move.b	oo,d3
	cmp.w	#0,oo
	beq.s	noadd
	move.b	#0,oo
	addq.l #1,a2
	bra.s	yesadd
noadd:	move.b	#1,oo
yesadd:	addq.l #1,a1
	dbf d0,mainlp
	rts

oo:	dc.w	0

blitclear:
	lea screen2+48*230,a0		; visible bitplane
blitfin:
;	btst #14,$dff002		
;	bne.s blitfin			; wait till blitter ready

	*** Q. Who fucking cares if the blitter is ready? ***
	*** A. Not me, matey! And that`s for fucking sure ***

	move.l a0,$dff054		; source address
	move.l a0,$dff050		; destination address
	clr.l $dff044			; no FWM/LWM
	clr.l $dff064			; no MODULO

	move.w #%100000000,$dff040 	; Enable DMA channel D, nothing
					; else, no minterms active. 
	clr.w $dff042			; nothing set in BLTCON1
	move.w #24+64*winheight,$dff058	



	rts
	
eq1 dc.b 0
eq2 dc.b 0
eq3 dc.b 0
eq4 dc.b 0
eq1p dc.w 381
eq2p dc.w 381
eq3p dc.w 381
eq4p dc.w 381
eqtab dcb.w 80



mt_init: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

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

; the playroutine - call this every frame

mt_music:
	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
	move.w	#$01f4,d0
mt_rls:	dbf	d0,mt_rls

	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.b #$1c,eq4
	move.w (a6),eq4p

	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.b #$1c,eq3
	move.w (a6),eq3p

	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.b #$1c,eq2
	move.w (a6),eq2p

	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.b #$1c,eq1
	move.w (a6),eq1p

	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
;	st	Pflag
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


notetable:	dc.w	856,808,762,720,678,640,604,570
		dc.w	538,508,480,453,428,404,381,360
		dc.w	339,320,302,285,269,254,240,226  
		dc.w	214,202,190,180,170,160,151,143
		dc.w	135,127,120,113,000
	dc.w	856,808,762,720,678,640,604,570
		dc.w	538,508,480,453,428,404,381,360
		dc.w	339,320,302,285,269,254,240,226  
		dc.w	214,202,190,180,170,160,151,143
		dc.w	135,127,120,113,000
	dc.w	856,808,762,720,678,640,604,570
		dc.w	538,508,480,453,428,404,381,360
		dc.w	339,320,302,285,269,254,240,226  
		dc.w	214,202,190,180,170,160,151,143
		dc.w	135,127,120,113,000

mt_data:	incbin	"mod.ingame"

