ùúùúÿ×|Ïÿ×|Ïÿ×|Ïÿ×|Ïÿ×|Ïÿ×|Ïÿ×|Ïÿ×|Ïÿ×|Ï**************************************************************************
**************************************************************************
***************   INTRO  by  ALE  of  PARALAX SYSTEMS   ******************
****************             and ENATOR                *******************
******************   in the year of the lord  1991    ********************
*******************************          *********************************
**************************************************************************
**************************************************************************

org $30000
load $30000

o:
BRA.L	START_INTRO

*********************************************************
**  Amiga FUTURE COMPOSER  »» V1.4 ««  Replay routine  **
*********************************************************

;Doesn't work with V1.0 - V1.3 modules !!




END_MUSIC:
	clr.w	onoff
	clr.l	$dff0a6
	clr.l	$dff0b6
	clr.l	$dff0c6
	clr.l	$dff0d6
	move.w	#$000f,$dff096
	bclr	#1,$bfe001
rts

INIT_MUSIC:
	move.w	#1,onoff
	bset	#1,$bfe001
	lea	MODULE,a0
	lea	180(a0),a1
	move.l	a1,SEQpoint
	move.l	a0,a1
	add.l	8(a0),a1
	move.l	a1,PATpoint
	move.l	a0,a1
	add.l	16(a0),a1
	move.l	a1,FRQpoint
	move.l	a0,a1
	add.l	24(a0),a1
	move.l	a1,VOLpoint
	move.l	4(a0),d0
	divu	#13,d0

	lea 40(a0),a1
	lea SOUNDINFO+4(pc),a2
	moveq #10-1,d1
initloop:
	move.w (a1)+,(a2)+
	move.l (a1)+,(a2)+
	adda.w #10,a2
	dbf d1,initloop
	move.l a0,d1
	add.l 32(a0),d1
	lea SOUNDINFO(pc),a3
	move.l d1,(a3)+
	moveq #9-1,d3
	moveq #0,d2
initloop1:
	move.w (a3),d2
	add.l d2,d1
	add.l d2,d1
	addq.l #2,d1
	adda.w #12,a3
	move.l d1,(a3)+
	dbf d3,initloop1

	lea 100(a0),a1
	lea SOUNDINFO+[10*16](pc),a2
	move.l a0,a3
	add.l 36(a0),a3

	moveq #80-1,d1
	moveq #0,d2
initloop2:
	move.l a3,(a2)+
	move.b (a1)+,d2
	move.w d2,(a2)+
	clr.w (a2)+
	move.w d2,(a2)+
	addq.w #6,a2
	add.w d2,a3
	add.w d2,a3
	dbf d1,initloop2

	move.l SEQpoint(pc),a0
	moveq #0,d2
	move.b 12(a0),d2		;Get replay speed
	bne.s speedok
	move.b #3,d2			;Set default speed
speedok:
	move.w d2,respcnt		;Init repspeed counter
	move.w d2,repspd
INIT2:
	clr.w audtemp
	move.w #$000f,$dff096		;Disable audio DMA
	move.w #$0780,$dff09a		;Disable audio IRQ
	moveq #0,d7
	mulu #13,d0
	moveq #4-1,d6			;Number of soundchannels-1
	lea V1data(pc),a0		;Point to 1st voice data area
	lea silent(pc),a1
	lea Chandata(pc),a2
initloop3:
	move.l a1,10(a0)
	move.l a1,18(a0)
	clr.w 4(a0)
	move.w #$000d,6(a0)
	clr.w 8(a0)
	clr.l 14(a0)
	move.b #$01,23(a0)
	move.b #$01,24(a0)
	clr.b 25(a0)
	clr.l 26(a0)
	clr.w 30(a0)
	clr.l 38(a0)
	clr.w 42(a0)	
	clr.l 44(a0)
	clr.l 48(a0)
	clr.w 56(a0)
	moveq #$00,d3
	move.w (a2)+,d1
	move.w (a2),d3
	divu #$0003,d3
	moveq #0,d4
	bset d3,d4
	move.w d4,32(a0)
	move.w (a2)+,d3
	andi.l #$00ff,d3
	andi.l #$00ff,d1
	lea $dff0a0,a6
	add.w d1,a6
	move.l #$0000,(a6)
	move.w #$0100,4(a6)
	move.w #$0000,6(a6)
	move.w #$0000,8(a6)
	move.l a6,60(a0)
	move.l SEQpoint(pc),(a0)
	move.l SEQpoint(pc),52(a0)
	add.l d0,52(a0)
	add.l d3,52(a0)
	add.l d7,(a0)
	add.l d3,(a0)
	move.l (a0),a3
	move.b (a3),d1
	andi.l #$00ff,d1
	lsl.w #6,d1
	move.l PATpoint(pc),a4
	adda.w d1,a4
	move.l a4,34(a0)
	move.b 1(a3),44(a0)
	move.b 2(a3),22(a0)
	lea $4a(a0),a0		;Point to next voice's data area
	dbf d6,initloop3
rts


PLAY:
	lea audtemp(pc),a5
	tst.w 8(a5)
	bne.s music_on
rts
music_on:
	subq.w #1,4(a5)			;Decrease replayspeed counter
	bne.s nonewnote
	move.w 6(a5),4(a5)		;Restore replayspeed counter
	moveq #0,d5	
	moveq #6,d6
	lea V1data(pc),a0		;Point to voice1 data area
	bsr.L new_note
	lea V2data(pc),a0		;Point to voice2 data area
	bsr.L new_note
	lea V3data(pc),a0		;Point to voice3 data area
	bsr.L new_note
	lea V4data(pc),a0		;Point to voice4 data area
	bsr.L new_note
nonewnote:
	clr.w (a5)
	lea $dff000,a6
	lea V1data(pc),a0
	bsr.L effects
	move.l d0,$a6(a6)
	lea V2data(pc),a0
	bsr.L effects
	move.l d0,$b6(a6)
	lea V3data(pc),a0
	bsr.L effects
	move.l d0,$c6(a6)
	lea V4data(pc),a0
	bsr.L effects
	move.l d0,$d6(a6)
	lea V1data(pc),a0
	move.l 68+[0*74](a0),a1		;Get samplepointer
	adda.w 64+[0*74](a0),a1		;add repeat_start
	move.l 68+[1*74](a0),a2
	adda.w 64+[1*74](a0),a2
	move.l 68+[2*74](a0),a3
	adda.w 64+[2*74](a0),a3
	move.l 68+[3*74](a0),a4
	adda.w 64+[3*74](a0),a4
	move.w 66+[0*74](a0),d1		;Get repeat_length
	move.w 66+[1*74](a0),d2
	move.w 66+[2*74](a0),d3
	move.w 66+[3*74](a0),d4
	moveq #2,d0
	moveq #0,d5
	move.w (a5),d7
	ori.w #$8000,d7			;Set/clr bit = 1
	move.w d7,$dff096		;Enable audio DMA
chan1:
	lea V1data+72(pc),a0
	move.w (a0),d7
	beq.s chan2
	subq.w #1,(a0)
	cmp.w d0,d7
	bne.s chan2
	move.w d5,(a0)
	move.l a1,$a0(a6)		;Set samplestart
	move.w d1,$a4(a6)		;Set samplelength
chan2:
	lea V2data+72(pc),a0
	move.w (a0),d7
	beq.s chan3
	subq.w #1,(a0)
	cmp.w d0,d7
	bne.s chan3
	move.w d5,(a0)
	move.l a2,$b0(a6)
	move.w d2,$b4(a6)
chan3:
	lea V3data+72(pc),a0
	move.w (a0),d7
	beq.s chan4
	subq.w #1,(a0)
	cmp.w d0,d7
	bne.s chan4
	move.w d5,(a0)
	move.l a3,$c0(a6)
	move.w d3,$c4(a6)
chan4:
	lea V4data+72(pc),a0
	move.w (a0),d7
	beq.s endplay
	subq.w #1,(a0)
	cmp.w d0,d7
	bne.s endplay
	move.w d5,(a0)
	move.l a4,$d0(a6)
	move.w d4,$d4(a6)
endplay:
rts

NEW_NOTE:
	move.l 34(a0),a1
	adda.w 40(a0),a1
	cmp.b #$49,(a1)		;Check "END" mark in pattern
	beq.s patend
	cmp.w #64,40(a0)		;Have all the notes been played?
	bne.S samepat
patend:
	move.w d5,40(a0)
	move.l (a0),a2
	adda.w 6(a0),a2		;Point to next sequence row
	cmpa.l 52(a0),a2	;Is it the end?
	bne.s notend
	move.w d5,6(a0)		;yes!
	move.l (a0),a2		;Point to first sequence
notend:
	lea spdtemp(pc),a3
	moveq #1,d1
	addq.b #1,(a3)
	cmpi.b #5,(a3)
	bne.s nonewspd
	move.b d1,(a3)
	move.b 12(a2),d1	;Get new replay speed
	beq.s nonewspd
	move.w d1,2(a3)		;store in counter
	move.w d1,4(a3)
nonewspd:
	move.b (a2)+,d1		;Pattern to play
	move.b (a2)+,44(a0)	;Transpose value
	move.b (a2)+,22(a0)	;Soundtranspose value
	lsl.w d6,d1
	move.l PATpoint(pc),a1	;Get pattern pointer
	add.w d1,a1
	move.l a1,34(a0)
	addi.w #$000d,6(a0)
samepat:
	move.b 1(a1),d1		;Get info byte
	move.b (a1)+,d0		;Get note
	bne.s ww1
	andi.w #%11000000,d1
	beq.s noport
	bra.s ww11
ww1:
	move.w d5,56(a0)
ww11:
	move.b d5,47(a0)
	btst #7,d1
	beq.s noport
	move.b 2(a1),47(a0)	
noport:
	andi.w #$007f,d0
	beq.S nextnote
	move.b d0,8(a0)
	move.b (a1),d1
	move.b d1,9(a0)
	move.w 32(a0),d3
	or.w d3,(a5)
	move.w d3,$dff096
	andi.w #$003f,d1	;Max 64 instruments
	add.b 22(a0),d1		;add Soundtranspose
	move.l VOLpoint(pc),a2
	lsl.w d6,d1
	adda.w d1,a2
	move.w d5,16(a0)
	move.b (a2),23(a0)
	move.b (a2)+,24(a0)
	moveq #0,d1
	move.b (a2)+,d1
	move.b (a2)+,27(a0)
	move.b #$40,46(a0)
	move.b (a2),28(a0)
	move.b (a2)+,29(a0)
	move.b (a2)+,30(a0)
	move.l a2,10(a0)
	move.l FRQpoint(pc),a2
	lsl.w d6,d1
	adda.w d1,a2
	move.l a2,18(a0)
	move.w d5,50(a0)
	move.b d5,25(a0)
	move.b d5,26(a0)
nextnote:
	addq.w #2,40(a0)
rts

EFFECTS:
	moveq #0,d7
testsustain:
	tst.b 26(a0)		;Is sustain counter = 0
	beq.s sustzero
	subq.b #1,26(a0)	;if no, decrease counter
	bra.L VOLUfx
sustzero:		;Next part of effect sequence
	move.l 18(a0),a1	;can be executed now.
	adda.w 50(a0),a1
testeffects:
	cmpi.b #$e1,(a1)	;E1 = end of FREQseq sequence
	beq.L VOLUfx
	move.b (a1),d0
	cmpi.b #$e0,d0		;E0 = loop to other part of sequence
	bne.s testnewsound
	move.b 1(a1),d1		;loop to start of sequence + 1(a1)
	andi.w #$003f,d1
	move.w d1,50(a0)
	move.l 18(a0),a1
	adda.w d1,a1
	move.b (a1),d0
testnewsound:
	cmpi.b #$e2,d0		;E2 = set waveform
	bne.s testE4
	move.w 32(a0),d1
	or.w d1,(a5)
	move.w d1,$dff096
	moveq #0,d0
	move.b 1(a1),d0
	lea SOUNDINFO(pc),a4
	lsl.w #4,d0
	adda.w d0,a4
	move.l 60(a0),a3
	move.l (a4)+,d1
	move.l d1,(a3)
	move.l d1,68(a0)
	move.w (a4)+,4(a3)
	move.l (a4),64(a0)
	move.w #$0003,72(a0)
	move.w d7,16(a0)
	move.b #$01,23(a0)
	addq.w #2,50(a0)
	bra.L transpose
testE4:
	cmpi.b #$e4,d0
	bne.s testE9
	moveq #0,d0
	move.b 1(a1),d0
	lea SOUNDINFO(pc),a4
	lsl.w #4,d0
	adda.w d0,a4
	move.l 60(a0),a3
	move.l (a4)+,d1
	move.l d1,(a3)
	move.l d1,68(a0)
	move.w (a4)+,4(a3)
	move.l (a4),64(a0)
	move.w #$0003,72(a0)
	addq.w #2,50(a0)
	bra.L transpose
testE9:
	cmpi.b #$e9,d0
	bne.S	testpatjmp
	move.w 32(a0),d1
	or.w d1,(a5)
	move.w d1,$dff096
	moveq #0,d0
	move.b 1(a1),d0
	lea SOUNDINFO(pc),a4
	lsl.w #4,d0
	adda.w d0,a4
	move.l (a4),a2
	cmpi.l #"SSMP",(a2)+
	bne.s nossmp
	lea 320(a2),a4
	moveq #0,d1
	move.b 2(a1),d1
	lsl.w #4,d1
	add.w d1,a2	
	add.l (a2),a4
	move.l 60(a0),a3
	move.l a4,(a3)
	move.l 4(a2),4(a3)
	move.l a4,68(a0)
	move.l 6(a2),64(a0)
	move.w d7,16(a0)
	move.b #1,23(a0)
	move.w #3,72(a0)
nossmp:
	addq.w #3,50(a0)
	bra.s transpose
testpatjmp:
	cmpi.b #$e7,d0
	bne.s testpitchbend
	moveq #0,d0
	move.b 1(a1),d0
	lsl.w d6,d0
	move.l FRQpoint(pc),a1
	adda.w d0,a1
	move.l a1,18(a0)
	move.w d7,50(a0)
	bra.L testeffects
testpitchbend:
	cmpi.b #$ea,d0
	bne.s testnewsustain
	move.b 1(a1),4(a0)
	move.b 2(a1),5(a0)
	addq.w #3,50(a0)
	bra.s transpose
testnewsustain:
	cmpi.b #$e8,d0
	bne.s testnewvib
	move.b 1(a1),26(a0)
	addq.w #2,50(a0)
	bra.L testsustain
testnewvib:
	cmpi.b #$e3,(a1)+
	bne.s transpose
	addq.w #3,50(a0)
	move.b (a1)+,27(a0)
	move.b (a1),28(a0)
transpose:
	move.l 18(a0),a1
	adda.w 50(a0),a1
	move.b (a1),43(a0)
	addq.w #1,50(a0)

VOLUfx:
	tst.b 25(a0)
	beq.s volsustzero
	subq.b #1,25(a0)
	bra.L calcperiod
volsustzero:
	tst.b 15(a0)
	bne.s do_VOLbend
	subq.b #1,23(a0)
	bne.s calcperiod
	move.b 24(a0),23(a0)
volu_cmd:
	move.l 10(a0),a1
	adda.w 16(a0),a1
	move.b (a1),d0
testvoluend:
	cmpi.b #$e1,d0
	beq.s calcperiod
	cmpi.b #$ea,d0
	bne.s testVOLsustain
	move.b 1(a1),14(a0)
	move.b 2(a1),15(a0)
	addq.w #3,16(a0)
	bra.s do_VOLbend
testVOLsustain:
	cmpi.b #$e8,d0
	bne.s testVOLloop
	addq.w #2,16(a0)
	move.b 1(a1),25(a0)
	bra.s calcperiod
testVOLloop:
	cmpi.b #$e0,d0
	bne.s setvolume
	move.b 1(a1),d0
	andi.w #$003f,d0
	subq.b #5,d0
	move.w d0,16(a0)
	bra.s volu_cmd
do_VOLbend:
	not.b 38(a0)
	beq.s calcperiod
	subq.b #1,15(a0)
	move.b 14(a0),d1
	add.b d1,45(a0)
	bpl.s calcperiod
	moveq #0,d1
	move.b d1,15(a0)
	move.b d1,45(a0)
	bra.s calcperiod
setvolume:
	move.b (a1),45(a0)
	addq.w #1,16(a0)
calcperiod:
	move.b 43(a0),d0
	bmi.s lockednote
	add.b 8(a0),d0
	add.b 44(a0),d0
lockednote:
	moveq #$7f,d1
	and.l d1,d0
	lea PERIODS(pc),a1
	add.w d0,d0
	move.w d0,d1
	adda.w d0,a1
	move.w (a1),d0

	move.b 46(a0),d7
	tst.b 30(a0)		;Vibrato_delay = zero ?
	beq.s vibrator
	subq.b #1,30(a0)
	bra.s novibrato
vibrator:
	moveq #5,d2
	move.b d1,d5
	move.b 28(a0),d4
	add.b d4,d4
	move.b 29(a0),d1
	tst.b d7
	bpl.s vib1
	btst #0,d7
	bne.s vib4
vib1:
	btst d2,d7
	bne.s vib2
	sub.b 27(a0),d1
	bcc.s vib3
	bset d2,d7
	moveq #0,d1
	bra.s vib3
vib2:
	add.b 27(a0),d1
	cmp.b d4,d1
	bcs.s vib3
	bclr d2,d7
	move.b d4,d1
vib3:
	move.b d1,29(a0)
vib4:
	lsr.b #1,d4
	sub.b d4,d1
	bcc.s vib5
	subi.w #$0100,d1
vib5:
	addi.b #$a0,d5
	bcs.s vib7
vib6:
	add.w d1,d1
	addi.b #$18,d5
	bcc.s vib6
vib7:
	add.w d1,d0
novibrato:
	eori.b #$01,d7
	move.b d7,46(a0)

; DO THE PORTAMENTO THING
	not.b 39(a0)
	beq.s pitchbend
	moveq #0,d1
	move.b 47(a0),d1	;get portavalue
	beq.s pitchbend		;0=no portamento
	cmpi.b #$1f,d1
	bls.s portaup
portadown: 
	andi.w #$1f,d1
	neg.w d1
portaup:
	sub.w d1,56(a0)
pitchbend:
	not.b 42(a0)
	beq.s addporta
	tst.b 5(a0)
	beq.s addporta
	subq.b #1,5(a0)
	moveq #0,d1
	move.b 4(a0),d1
	bpl.s pitchup
	ext.w d1
pitchup:
	sub.w d1,56(a0)
	addporta:
	add.w 56(a0),d0
	cmpi.w #$0070,d0
	bhi.s nn1
	move.w #$0071,d0
nn1:
	cmpi.w #$0d60,d0
bls.s nn2
	move.w #$0d60,d0
nn2:
	swap d0
	move.b 45(a0),d0
rts



V1data:  blk.b 64,0	;Voice 1 data area
offset1: blk.b 02,0	;Is added to start of sound
ssize1:  blk.b 02,0	;Length of sound
start1:  blk.b 06,0	;Start of sound

V2data:  blk.b 64,0	;Voice 2 data area
offset2: blk.b 02,0
ssize2:  blk.b 02,0
start2:  blk.b 06,0

V3data:  blk.b 64,0	;Voice 3 data area
offset3: blk.b 02,0
ssize3:  blk.b 02,0
start3:  blk.b 06,0

V4data:  blk.b 64,0	;Voice 4 data area
offset4: blk.b 02,0
ssize4:  blk.b 02,0
start4:  blk.b 06,0

audtemp: dc.w 0		;DMACON
spdtemp: dc.w 0
respcnt: dc.w 0		;Replay speed counter 
repspd:  dc.w 0		;Replay speed counter temp
onoff:   dc.w 0		;Music on/off flag.

Chandata: dc.l $00000000,$00100003,$00200006,$00300009
SEQpoint: dc.l 0
PATpoint: dc.l 0
FRQpoint: dc.l 0
VOLpoint: dc.l 0


SILENT: dc.w $0100,$0000,$0000,$00e1

PERIODS:dc.w $06b0,$0650,$05f4,$05a0,$054c,$0500,$04b8,$0474
	dc.w $0434,$03f8,$03c0,$038a,$0358,$0328,$02fa,$02d0
	dc.w $02a6,$0280,$025c,$023a,$021a,$01fc,$01e0,$01c5
	dc.w $01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d
	dc.w $010d,$00fe,$00f0,$00e2,$00d6,$00ca,$00be,$00b4
	dc.w $00aa,$00a0,$0097,$008f,$0087,$007f,$0078,$0071
	dc.w $0071,$0071,$0071,$0071,$0071,$0071,$0071,$0071
	dc.w $0071,$0071,$0071,$0071,$0d60,$0ca0,$0be8,$0b40
	dc.w $0a98,$0a00,$0970,$08e8,$0868,$07f0,$0780,$0714
	dc.w $1ac0,$1940,$17d0,$1680,$1530,$1400,$12e0,$11d0
	dc.w $10d0,$0fe0,$0f00,$0e28,$06b0,$0650,$05f4,$05a0
	dc.w $054c,$0500,$04b8,$0474,$0434,$03f8,$03c0,$038a
	dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a
	dc.w $021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d,$0168
	dc.w $0153,$0140,$012e,$011d,$010d,$00fe,$00f0,$00e2
	dc.w $00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f
	dc.w $0087,$007f,$0078,$0071

SOUNDINFO:
;Start.l , Length.w , Repeat start.w , Repeat-length.w , blk.b 6,0 

blk.b 10*16,0	;Reserved for samples
blk.b 80*16,0	;Reserved for waveforms



**************************************************************************
**************************************************************************
**************************************************************************


START_INTRO:


**************************************************************************

****************   Init the copperlist and sinus tables   ****************

**************************************************************************
;	lea	spointers,a0
;	move.l	screen,d1
;	moveq	#3,d0
;Iinlop:	
;	move.w	d1,4(a0)
;	swap	d1
;	move.w	d1,(a0)
;	swap	d1
;	add.l	#8,a0
;	add.l	#$17c0,d1
;	dbra	d0,Iinlop


	lea	screenpointers(pc),a0
	move.l	#$3007fffe,d1
	move.l	#logo+40,d2	
	move.l	#logo+[35*40],d3	
	moveq	#31,d0
scrptlp:
	move.l	d1,(a0)+
	swap	d2
	move.w	#$00e0,(a0)+
	move.w	d2,(a0)+
	swap	d2
	move.w	#$00e2,(a0)+
	move.w	d2,(a0)+
	swap	d3
	move.w	#$00e4,(a0)+
	move.w	d3,(a0)+
	swap	d3
	move.w	#$00e6,(a0)+
	move.w	d3,(a0)+
	add.l	#$02000000,d1
	add.l	#40,d2
	add.l	#40,d3
	dbra	d0,scrptlp

	lea	screen(pc),a0
	move.l	#$7107fffe,d1
	lea	backcol(pc),a1	
	lea	backcol2(pc),a2
	move.l	#141,d0
scrblki:
	move.l	d1,(a0)+
	move.l	#$00e20000,(a0)+
	move.l	#$01020000,(a0)+
	move.w	#$0182,(a0)+
colagn:	move.w	(a1)+,d2
	cmp.w	#$0fff,d2
	bne.S	okcol
	lea	backcol(pc),a1	
	bra.S	colagn
okcol:	move.w	d2,(a0)+

	move.w	#$0192,(a0)+
colagn2:move.w	(a2)+,d2
	cmp.w	#$0fff,d2
	bne.S	okcol2
	lea	backcol2(pc),a2	
	bra.S	colagn2
okcol2:	move.w	d2,(a0)+
	add.l	#$01000000,d1
	dbra	d0,scrblki


	lea	sindata(pc),a0
	lea	scrollsin1(pc),a1
	move.l	#34,d0
	move.l	#359,d2
mscdat7:clr.l	d1
	move.w	(a0),d1
	cmp.w	#$ffff,d1
	bne.S	okysin4
	move.l	#sindata,a0
	bra.S	mscdat7	
okysin4:add.l	#4096,d1
	mulu	d0,d1
	divu	#4096,d1	
	mulu	#48,d1
	move.w	d1,(a1)+
	add.l	#2,a0
	dbra	d2,mscdat7

	lea	sindata(pc),a0
	lea	scrollsin2(pc),a1
	move.l	#29,d0
	move.l	#359,d2
mscdat5:clr.l	d1
	move.w	(a0),d1
	cmp.w	#$ffff,d1
	bne.S	okysin5
	move.l	#sindata,a0
	bra.S	mscdat5	
okysin5:add.l	#4096,d1
	mulu	d0,d1
	divu	#4096,d1	
	addq.l	#1,d1
	mulu	#48,d1
	move.w	d1,(a1)+
	add.l	#4,a0
	dbra	d2,mscdat5



**************************************************************************

************     Start Level 3 Interupt and Kill System      *************

**************************************************************************

	move.w	$dff002,DMAbits		; Store DMA and Interupt bits
	move.w	$dff01c,Interuptbits	;

	
	move.w	#$3807,$dff09a		; set Interupt bits
	move.b	#%01111111,$bfed01	; shut off keyboard
	move.w	#$7fff,$dff096		; Clear DMA bits
	move.w	#$87ef,$dff096		; Set DMA bits
	move.w	#$8400,$dff096		; Set Blitter nasty 

;	MOVE.L  $68,OLDINTERUPT2
	MOVE.L	$6C,OLDINTERUPT3

	bsr	printback

;	MOVE.L  #DINTERUPT,$68
	MOVE.L  #INTERUPT,$6C

	bsr.L	init_music
	move.l	#text1,chrpoint1

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






	move.l	#aclogocopper,actualcopper
	
**************************************************************************

*****************      Mainloop for the INTRO         ********************

**************************************************************************

	

main:
	bsr.L	VBwait
	bsr.l	chcol
	bsr.L	swapscreen
	bsr.L	sinscroll
;	move.w	#$000f,$dff180  ;kolla rastertidkvar
	btst	#6,$bfe001	;testa musknapp
	bne.S	main



**************************************************************************

***********************   Restore system and Quit ************************

**************************************************************************

quit:
	bsr.L	end_music
	move.w	DMAbits,d0
	or.w	#$8100,d0
	move.w	d0,$dff096
	move.w	Interuptbits,d0
	or.w	#$c000,d0
	move.w	d0,$dff09a
	move.b	#%10011011,$bfed01
;	MOVE.L  OLDINTERUPT2,$68
	move.l	OLDINTERUPT3,$6C;flytta tillbaka gamla copperlistan
	clr.l	d0
rts
**************************************************************************



****************   HERE IS THE BEGINING OFF SUBROUTINES   ***************




**************************************************************************

***************  All sub routines for the AC LOGO part   *****************

**************************************************************************

chcol:	
	lea	screen(pc),a0
	move.w	18(a0),d5
	move.l	#45,d0
collp:	move.w	38(a0),18(a0)
	add.l	#20,a0
	dbra	d0,collp
	move.w	d5,18(a0)
rts	




printback:

;       --------- Clear Screen Area ----------

	move.w	#00,$dff066
 	move.l	#$ffffffff,$dff044
	move.l	#SCREEN02,$dff054
	move.l  #$09000000,$dff040 ;cntl word
	move.w	#$2398,$dff058	;starta blittern


	move.l	#backtext,chrpoint1
	move.l	#screen02+[3*42]+2,printpos

doaprin:	
	moveq	#0,d1
	move.l	chrpoint1,a1
	move.b	(a1),d1
	cmp.b	#0,d1 
	bne.s	norestart4
	add.l	#590,printpos
	addq.l	#1,chrpoint1
	bra.s	doaprin
norestart4:
	cmp.b	#1,d1 
	bne.s	norestart5
	rts
norestart5:
	move.l	#-1,d2
	lea	convertiontable1(pc),a0
findch3:move.b	(a0)+,d0
	addq.l	#1,d2
	cmp.b	d0,d1
	bne.s	findch3
	MULU	#26,d2

	add.l	#font,d2
	move.w	#40,$dff066
 	move.l	#$ffffffff,$dff044
	move.w	#00,$dff064
	move.l	#$09f00000,$dff040
	move.l	d2,$dff050
	move.l	printpos,$dff054
	move.w	#$0341,$dff058

	addq.l	#1,chrpoint1
	addq.l	#2,printpos
bra doaprin	


swapscreen:

	bchg	#1,iscflag
	btst	#1,iscflag
	bne.S	ci2
	move.l	#screen00,usescreen
	move.l	#screen01,d1
	bra.S	doxsin
ci2:
	move.l	#screen01,usescreen
	move.l	#screen00,d1
doxsin:
	addq.l	#6,d1		
      	lea	screen(pc),a0
	lea	scrollsin(pc),a1
	move.l	#140,d0
xsinlop:moveq	#0,d6
	moveq	#0,d5
	move.w	(a1)+,d6
	addq.l	#2,a1
	divu	#48,d6		;dela med 48 eftersom tabellen e sån
	ror.l	#5,d6				
	move.w	d6,d5
	rol.l	#1,d5
	and.l	#$f0000000,d6
	rol.l	#4,d6
	move.w	d6,10(a0)	;lagg in shift value
	neg	d5
	add.l	d1,d5
	move.w	d5,6(a0)	;lagg in screensta	
	add.l	#20,a0
	add.l	#48,d1
	dbra	d0,xsinlop
rts	


sinscroll:
	move.l	#$ffffffff,$dff044
	move.w	#00,$dff064

	subq.w	#1,pos
	tst.w	pos
	bne.L	sliding
	move.b	#0,stopflag
	addq.l	#1,chrpoint1
	move.w	#8,pos	
	moveq	#0,d1
wrs:	move.l	chrpoint1,a1
	move.b	(a1),d1
	cmp.b	#0,d1 
	bne.s	norestart2
	move.l	#text1,chrpoint1
	bra.S	wrs
norestart2:
	cmp.b	#1,d1 
	bne.s	norestart3
	move.b	#1,stopflag	
	bra.S	sliding
norestart3:
	move.l	#-1,d2
	lea	convertiontable1(pc),a0
findch2:move.b	(a0)+,d0
	addq.l	#1,d2
	cmp.b	d0,d1
	bne.s	findch2
	MULU	#26,d2

	add.l	#font,d2
	move.w	#48,$dff066
 	move.l	#$09f00000,$dff040
	move.l	d2,$dff050
	move.l	#scrollplane+48,$dff054
	move.w	#$0341,$dff058

sliding:
	move.w	#00,$dff066	;blitter dest.modulo

	tst.b	stopflag
	bne.S	dontslide

;	-------- Slide the Scrollplane -------- 
 	move.l	#$e9f00000,$dff040
	move.l	#scrollplane+2,$dff050	;blitter source a
	move.l	#scrollplane,$dff054	;blitter destination
	move.w	#$0359,$dff058	;starta blittern

dontslide:
;       --------- Clear Screen Area ----------

	move.l	usescreen,$dff054
	move.l  #$09000000,$dff040 ;cntl word
	move.w	#$2398,$dff058	;starta blittern

;       --------- Start do the sinus ----------

	lea	scrollsin,a0
	lea	scrollplane,a1
	move.l	usescreen,d4
	move.w  #46,$dff062
	move.w  #48,$dff064
	move.w  #46,$dff066
	lea	$dff054,a3
	lea	$dff04c,a4
	lea	$dff050,a5
	lea	$dff058,a6	
	lea	$dff044,a2
	move.l  #$0dfc0000,$dff040
	moveq	#23,d5
	move.l  #$c000c000,d7
blloop:	moveq	#7,d6
bllop2:	move.l  d7,(a2)
	move.l  d4,d3
	clr.l	d0
	move.w	(a0)+,d0
	add.l	d0,d3
	move.l  d3,(a3)
	move.l  d3,(a4)
	move.l  a1,(a5)  
	move.w  #$0341,(a6)	

	ror.l	#2,d7
	dbra	d6,bllop2
	addq.l	#2,d4
	addq.l	#2,a1
	dbra	d5,blloop

	lea	scrollsin1,a0
	move.l  (a0),d5
	move.l	#178,d0
sinsllp1:move.l	4(a0),(a0)+
	dbra	d0,sinsllp1
	move.l	d5,(a0)

	lea	scrollsin2+716,a0
	move.l  (a0),d5
	move.l	#178,d0
sinsllp2:move.l	-4(a0),(a0)
	sub.l	#4,a0
	dbra	d0,sinsllp2
	move.l	d5,(a0)


	lea	scrollsin1,a0
	lea	scrollsin2,a1
	lea	scrollsin,a2
	move.l	#359,d0
sinalop:move.w	(a0)+,d1
	add.w	(a1)+,d1
	move.w	d1,(a2)+
	dbra	d0,sinalop

rts



vbwait:	move.b	$dff006,d0;vantar
	cmp.b	#$ff,d0
	bne.S	vbwait
rts


INTERUPT:	
	MOVEM.L	D0-D7/A0-A6,-(SP)
	MOVE.W	$DFF01E,D0
	BTST	#5,D0
	BNE.s	DOCOPPER
	MOVE.W	D0,$DFF09C
	MOVEM.L	(SP)+,D0-D7/A0-A6
RTE

DOCOPPER:
	BSR.L	PLAY
	MOVE.W	#$0020,$DFF09c	
	MOVE.L	ACTUALCOPPER,$DFF084
	MOVEM.L	(SP)+,D0-D7/A0-A6
RTE



**************************************************************************

************************    Copper Listor     ****************************

**************************************************************************

aclogocopper:
	dc.w  $120,0,$122,0
aclogocmap:
	dc.w  $0180,$0000,$0182,$0c0c,$0184,$0808,$0186,$0505
	dc.w  $0100,$2200
	dc.w  $0104,$0000
	dc.w  $0102,$0000
	dc.w  $008e,$3081,$0090,$30c1	;display
 	dc.w  $0092,$0038,$0094,$00d0	;data fetch,stop
	dc.w  $0108,-40,$010a,-40	;modulos

screenpointers:	blk 10*2*32		;bitplane pointers
	

	
	dc.w $7007,$fffe
		
	dc.w	$0180,$000f,$0182,$0fff,$0190,$0000,$0192,$0509
	dc.w  $0100,$2600
	dc.w  $0104,$0000
	dc.w  $0102,$0000
	dc.w  $008e,$7181,$0090,$ffc1	;display
 	dc.w  $0092,$0030,$0094,$00d0	;data fetch,stop
	dc.w  $0108,8,$010a,0	;modulos
	dc.w  $00e0,$5
	dc.w  $00e4,$5
	dc.w  $00e6,$4000

	dc.w $7107,$fffe
	dc.w $0180,$0000

screen:	blk 2840,0


	dc.w $ff07,$fffe
	dc.w $0180,$000f
	dc.w $ffe1,$fffe
	dc.w $0007,$fffe
	dc.w $0180,$0000

dc.w $ffff,$fffe




**************************************************************************

******************  DATA AREA and VARIABLE DECLARATION  ******************

**************************************************************************


sindata:	;  SIN VALUES $ff00 $0100  step .5 degres
	DC.W	$0000,$0047,$008F,$00D6,$011E,$0165,$01AC,$01F3,$023A,$0281,$02C7,$030E
	DC.W	$0354,$0399,$03DF,$0424,$0469,$04AE,$04F2,$0536,$0579,$05BC,$05FE,$0640
	DC.W	$0682,$06C3,$0704,$0744,$0783,$07C2,$0800,$083E,$087B,$08B7,$08F2,$092D
	DC.W	$0968,$09A1,$09DA,$0A12,$0A49,$0A7F,$0AB5,$0AE9,$0B1D,$0B50,$0B82,$0BB4
	DC.W	$0BE4,$0C13,$0C42,$0C6F,$0C9C,$0CC7,$0CF2,$0D1B,$0D44,$0D6B,$0D92,$0DB7
	DC.W	$0DDB,$0DFE,$0E21,$0E42,$0E61,$0E80,$0E9E,$0EBA,$0ED6,$0EF0,$0F09,$0F21
	DC.W	$0F38,$0F4D,$0F61,$0F74,$0F86,$0F97,$0FA6,$0FB5,$0FC2,$0FCE,$0FD8,$0FE1
	DC.W	$0FEA,$0FF0,$0FF6,$0FFA,$0FFE,$0FFF,$1000,$0FFF,$0FFE,$0FFA,$0FF6,$0FF0
	DC.W	$0FEA,$0FE1,$0FD8,$0FCE,$0FC2,$0FB5,$0FA6,$0F97,$0F86,$0F74,$0F61,$0F4D
	DC.W	$0F38,$0F21,$0F09,$0EF0,$0ED6,$0EBA,$0E9E,$0E80,$0E61,$0E42,$0E21,$0DFE
	DC.W	$0DDB,$0DB7,$0D92,$0D6B,$0D44,$0D1B,$0CF2,$0CC7,$0C9C,$0C6F,$0C42,$0C13
	DC.W	$0BE4,$0BB4,$0B82,$0B50,$0B1D,$0AE9,$0AB5,$0A7F,$0A49,$0A12,$09DA,$09A1
	DC.W	$0968,$092D,$08F2,$08B7,$087B,$083E,$0800,$07C2,$0783,$0744,$0704,$06C3
	DC.W	$0682,$0640,$05FE,$05BC,$0579,$0536,$04F2,$04AE,$0469,$0424,$03DF,$0399
	DC.W	$0354,$030E,$02C7,$0281,$023A,$01F3,$01AC,$0165,$011E,$00D6,$008F,$0048
	DC.W	$0000,$FFB9,$FF71,$FF2A,$FEE2,$FE9B,$FE54,$FE0D,$FDC6,$FD7F,$FD39,$FCF2
	DC.W	$FCAC,$FC67,$FC21,$FBDC,$FB97,$FB52,$FB0E,$FACA,$FA87,$FA44,$FA02,$F9C0
	DC.W	$F97E,$F93D,$F8FC,$F8BC,$F87D,$F83E,$F800,$F7C2,$F785,$F749,$F70E,$F6D3
	DC.W	$F698,$F65F,$F626,$F5EE,$F5B7,$F581,$F54B,$F517,$F4E3,$F4B0,$F47E,$F44C
	DC.W	$F41C,$F3ED,$F3BE,$F391,$F364,$F339,$F30E,$F2E5,$F2BC,$F295,$F26E,$F249
	DC.W	$F225,$F202,$F1DF,$F1BE,$F19F,$F180,$F162,$F146,$F12A,$F110,$F0F7,$F0DF
	DC.W	$F0C8,$F0B3,$F09F,$F08C,$F07A,$F069,$F05A,$F04B,$F03E,$F032,$F028,$F01F
	DC.W	$F016,$F010,$F00A,$F006,$F002,$F001,$F000,$F001,$F002,$F006,$F00A,$F010
	DC.W	$F016,$F01F,$F028,$F032,$F03E,$F04B,$F059,$F069,$F07A,$F08C,$F09F,$F0B3
	DC.W	$F0C8,$F0DF,$F0F7,$F110,$F12A,$F146,$F162,$F180,$F19F,$F1BE,$F1DF,$F202
	DC.W	$F225,$F249,$F26E,$F295,$F2BC,$F2E5,$F30E,$F339,$F364,$F391,$F3BE,$F3ED
	DC.W	$F41C,$F44C,$F47E,$F4B0,$F4E3,$F516,$F54B,$F581,$F5B7,$F5EE,$F626,$F65F
	DC.W	$F698,$F6D3,$F70D,$F749,$F785,$F7C2,$F800,$F83E,$F87D,$F8BC,$F8FC,$F93D
	DC.W	$F97E,$F9BF,$FA02,$FA44,$FA87,$FACA,$FB0E,$FB52,$FB97,$FBDC,$FC21,$FC67
	DC.W	$FCAC,$FCF2,$FD39,$FD7F,$FDC6,$FE0D,$FE54,$FE9B,$FEE2,$FF2A,$FF71,$FFB8
	dc.w	$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff
backcol: 
	dc.w $a00,$a10,$a20,$a30,$a40,$a50,$a60,$a70,$a80,$a90,$aa0,$ab0,$ac0,$ad0
	dc.w $ac0,$ab0,$aa0,$a90,$a80,$a70,$a60,$a50,$a40,$a30,$a20,$a10,$fff

backcol2: 
	dc.w $a08,$a18,$a28,$a38,$a48,$a58,$a68,$a78,$a88,$a98,$aa8,$ab8,$ac8,$ad0
	dc.w $ac8,$ab8,$aa8,$a98,$a88,$a78,$a68,$a58,$a48,$a38,$a28,$a18,$fff

convertiontable1: 	;for introfont
	dc.b 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!():*?/-& '


**************    SCROLL TEXT IS TO BE PLACED HERE    ***************

*****  PLEASE NOTE 1. ALWAYS PUT A SPACE IN THE BEGINNING OF THE TEXT
*****              2. END THE SCROLLER WITH A 0
*****              3. USE THE NUMBER 1 TO STOP THE SCROLLER FOR 1 CHR

*********************************************************************
Text1:
DC.B ' THIS IS A TEST   ',1,1,1,1,1,1,1,1,1,1,1
DC.B '      OF  THIS FUCKIN SCROLLER  (HOPE YOU LIKE IT) !         '
DC.B ' ALE / PARALAX SYSTEMS           ',0


******** TEXT BAKOM SCROLLER (MÅSTE HA DENNA STORLEK!) *******

********  ETT EXEMPEL *******
Backtext:
dc.b	'      PRESENTS      ',0
dc.b	'     A CRACK BY     ',0
DC.B	'       SPOLIX       ',0
DC.B	'                    ',0
DC.B    '********************',0
DC.B	'*   STORMBRINGER   *',0
DC.B	'*       FROM       *',0
DC.B	'*     ILLUSION     *',0
DC.B	'********************',1
even 

OLDINTERUPT2: 	dc.l $0
OLDINTERUPT3: 	dc.l $0
ACTUALCOPPER:	dc.l $0
DMABITS:	dc.w $0
INTERUPTbits:	dc.w $0
chrpoint1:	dc.l $0
usescreen:	dc.l $0
printpos:	dc.l $0
pos:		dc.w $8
fadeflag:	dc.w $0	
iscflag:	dc.b $0
noscroll:	dc.b $0
stopflag:	dc.b $0
even
scrollsin:	blk  720,0
scrollsin1:	blk  720,0
scrollsin2:	blk  720,0

scrollplane:	blk  660,0
font:		equ  $60000 
logo:		equ  $61000
module:		equ  $65000
screen00:	equ  $50000	
screen01:	equ  $52000
screen02:	equ  $54000
maxmem:		equ  $7f000

>extern "asmdisk2:font/abvfont",font
>extern "asmdisk2:logo/abstract",logo
>extern "asmdisk2:module/mod.astaroth.1",module				

