>EXTERN "ICE-T_POWER.DATA",$60000
***********************************************************
*          Short Sinus Intro V2.1
*    Coded by Ice-T of Thrust in 1989
* 
* This Intro was originally coded for Supreme , but
* as noone used it I sold to the group ''ICE-T Power''
*       Yes , they are my fan-club !
*
* Instructions :
*
* How to edit the Scroll and its functions ( at line 182 ):
* 
* - A 's' ( not a capital 'S' !! ) makes the scrollmachine
*   to hold for a while .
* - The numbers from '1' to '8' direct the scrollspeed of the 
*   sinus wave ( 1 = very slow  ... 8 = very fast )   
* - As I am a real lazy guy I did not implent an extra driver
*   for the extra symbols !
*   Well , its now up to you to discover them .....
*   Example : a 'n' summits the cauldron
*             a '[' produces a '!'     etc.
*   Feel free to implent the extra symbol selector on your own !!!
* 
* How to make it run :
* 
*
* - Use 'ri' to load the file 'raw!' to $60000
* - Use 'ri' to load a song  to $40000
* - Now assemble the whole crap and type 'g $5b000'
*
* How to pack this small bunch of bytes :
*
* - Assemble this Source 
* - type wi and enter the filename then type , when the comp. is
*   up to ask for the Begin : $5b000 <RETURN> ( HARR HARR )
*   The End-Address is 'Program_end' .... ( That means , that when
*   the End-Address is requested you have to enter 'Program_end !! )
* - Now load Tetrapack and link the code !!
* - load 'raw!' to $60000 with the option 'o' for 'plain'
* - load the code you have saved with the Seka to $5b000  with
*   option 'o' , too.
* - load 'song' to $40000 with .......
* - When Jump Address is requested type '$5b000' !!!
*
* If there are any questions call my BBS 049-412-330 
* PS: If there's not enough Disk-Space just don't load the song
* and delete Line 98,138,143 and the lines from 891 to 'program_end' !
* But DO NOT (!) remove the label 'PROGRAM_END' !!!!!!!!
*     ======        
*
      
org $5b000
load $5b000

dmacon   = $dff096    
dmaconr  = $dff002
cop1lch  = $dff080    
copjmp1  = $dff088    

intreq   = $dff09c    
intreqr  = $dff01e     
intena   = $dff09a    


bltapth  = $dff050
bltbpth  = $dff04c
bltcpth  = $dff048
bltdpth  = $dff054
bltamod  = $dff064
bltbmod  = $dff062
bltcmod  = $dff060
bltdmod  = $dff066
bltafwm  = $dff044
bltalwm  = $dff046
bltcon0  = $dff040
bltcon1  = $dff042
bltsize  = $dff058

go:
movem.l	d0-d7/a0-a6,-(a7)
move.l	#quantum,$80
trap	0
moveq	#$0000,d0
movem.l	(a7)+,d0-d7/a0-a6
rts
counter:
dc.w 0
quantum:
move.w	#$2700,sr
move.w	#$0020,$dff096
move.w	#$8400,$dff096
bsr	clear
bsr	maker
bsr	start_muzak
bsr	create_cop1
bsr	create_cop2
move.l	#newclist,$dff080
main:
cmp.b	#$4f,$dff006
bne.s	main
move.w  #$8660,bit
move.w  #$9178,bit2
move.l  #$757a8,test3
move.l  #$757a8,tentakel2
add.w   #1,counter
cmp.w   #2,counter
bne     double_buffer
clr.w   counter
move.w  #$3660,bit
move.w  #$4178,bit2
move.l  #$7a7a8,test3
move.l  #$7a7a8,tentakel2
double_buffer:
bsr	sort
movem.l	d0-d7/a0-a6,-(a7)
bsr.l	loesch           
movem.l	(a7)+,d0-d7/a0-a6

bsr	sinus

bsr	blit2
cmp.w   #1,stop2
bne     okay
add.w   #1,counter2
cmp.w   #280,counter2
bne     out
clr.w   counter2
clr.w   stop2
out:
bra	nix
okay:
bsr	scrolltext
nix:
bsr	replay_muzak
irqend:
btst	#$6,$bfe001
bne.L	main
bsr	oldcopper
bsr	stop_muzak
move.w	#$8020,$dff096
move.w	#$0400,$dff096
move.w	#$2000,sr
rte
stop2:
dc.w 0
counter2:
dc.w 0
puffer:	blk.b	64*4,0
save_stack:	blk.l	1,0
tentakel2:
dc.l 0

loesch:
move.l	a7,save_stack	
lea	puffer(pc),a7
movem.l	(a7)+,d0-d7/a0-a6
move.l	save_stack,a7
move.l	tentakel2(pc),a6
add.l	#40*40,a6
move.w	#194,d7
loelo2:
movem.l	a0-a5/d0-d6,-(a6)
subq.w #1,d7
bne loelo2
rts
oldcopper:
move.l	$4,a6
lea	gfxname,a1		
jsr	-408(a6)		
move.l	d0,a1			
move.l	38(a1),$dff080		
jsr	-414(a6)		
rts
letters2:                  ;
dc.b "3 HI THERE ALL YOU SHIThHEADS ["
dc.b "     pnp ICEhT pnp   s"
dc.b " IS BACK WITH ANOTHER SHORT INTRO [[[ " 
end222:
even

clear:
lea $6b000,a0
lea $7fffe,a1
loop7:
clr.l (a0)+
cmp.l a1,a0
blt	loop7
rts


next_letter:
move.l	#$69340,a1	
move.l	letter_pointer,a2
move.b	(a2),d0
cmp.b   #$49,d0
beq	setting
cmp.b   #94,d0
beq	setting2
cmp.b   #$31,d0
beq	setting3
cmp.b   #$32,d0
beq	setting4
cmp.b   #$33,d0
beq	setting5
cmp.b   #$34,d0
beq	setting6
cmp.b   #$35,d0
beq	setting7
cmp.b   #$36,d0
beq	setting8
cmp.b   #$37,d0
beq	setting8
cmp.b   #$38,d0
beq	setting10
cmp.b   #$73,d0
beq	setting11
move.w  #$8,compare
tu:
cmp.b	#$41,d0
bmi	special_font
add.l	#1,letter_pointer
sub.b	#$41,d0
lcont:	
mulu	#$2,d0
add.l	d0,a1
cmp.l   #end222,a2
beq     ender
bra.L	blit
special_font:
lea     $6a000,a1
add.l	#1,letter_pointer
bra.s	lcont
ender:
clr.l   letter_pointer
move.l	reset,letter_pointer
bra.L	next_letter		
rts

setting:
move.w #$4,compare
bra	tu
rts

setting2:
move.w #$4,compare
bra	tu
rts

setting3:
move.l #8,sortfac
bra	special_font
rts

setting4:
move.l #12,sortfac
bra	special_font
rts

setting5:
move.l #16,sortfac
bra	special_font
rts

setting6:
move.l #20,sortfac
bra	special_font
rts

setting7:
move.l #24,sortfac
bra	special_font
rts

setting8:
move.l #28,sortfac
bra	special_font
rts

setting9:
move.l #32,sortfac
bra	special_font
rts

setting10:
move.l #36,sortfac
bra	special_font
rts

setting11:
move.w #$1,stop2
bra	special_font
rts



blit:		
move.w	#94,bltamod
move.w	#40,bltdmod
move.l  a1,bltapth
move.l	#$72042,bltdpth;$8a4
move.w	#%1111111111111111,bltafwm
move.w	#%1111111111111111,bltalwm
move.w	#%0000100111110000,bltcon0
move.w  #%0000000000000000,bltcon1
move.w	#%0000111100000001,bltsize
clr.w	blitcounter
blw1:	
btst	#6,dmaconr
bne.s	blw1	
rts

blit2:		
move.w	#%1111111111111111,bltafwm
move.w	#%1111111111111111,bltalwm
rts
sortex:
rts

sort:
cmp.l #sinustabend,multi2
blt   more
;move.l #multi,multi2
sub.l  #1258,multi2
more:
move.l sortfac,d7
add.l d7,multi2
rts
sortfac:
dc.l 20
multi2:
dc.l multi
test3:
dc.l 0
test:
dc.l 0

maker:
lea multi,a0
lea abs_end,a1
looping:
move.w (a0),d5
mulu   #40,d5
move.w d5,(a0)+
cmp.l a0,a1
bne	looping
rts

sinus:		
;move.w  #$0f00,$dff180
move.w	#40,bltamod
move.w	#38,bltbmod
move.w	#38,bltdmod
move.l	#$727d0,test;$727d0
move.w	#19,d4
move.l	multi2,a6

move.w	#%0000110111111100,bltcon0
move.w  #%0000000000000010,bltcon1
looper:
move.w  #$8000,d7
moveq  #16,d6
move.l  test3,test2

loop:
move.l  test3,d5
sub.l	(a6),d5
addq.l  #2,a6
move.l  test,bltapth
move.l	d5,bltbpth
move.l	d5,bltdpth;$8a4
move.w	d7,bltafwm
move.w	#%0000001110000001,bltsize
lsr.w   #1,d7
subq    #1,d6
bne     loop
addq.l	#2,test
addq.l	#2,test3

dbra	d4,looper
move.w  #$0000,$dff180

rts


scrolltext:
addq	#1,blitcounter
clr.w   bltamod
clr.w   bltdmod
move.l	#$7281e,bltapth
move.l	#$7281e,bltdpth
move.w	#%0010100111110000,bltcon0
move.w	#%0000010000010101,bltsize
blw2:	
btst	#6,dmaconr
bne.s	blw2
move.w  compare,d0
cmp.w	blitcounter,d0
bne.s	bcont
bsr	next_letter
bcont:
rts

compare:
dc.w 5


create_cop1:
lea waittab1,a0
lea coleurs,a1
move.w #34,d0
move.w #$5109,d1
loop4:
move.w d1,(a0)+
move.w #$fffe,(a0)+
move.w #$01a0,(a0)+
move.w (a1),(a0)+
move.w #$01a2,(a0)+
move.w (a1),(a0)+
move.w #$01a4,(a0)+
move.w (a1),(a0)+
move.w #$01a6,(a0)+
move.w (a1),(a0)+
move.w #$01a8,(a0)+
move.w (a1),(a0)+
move.w #$01aa,(a0)+
move.w (a1),(a0)+
move.w #$01ac,(a0)+
move.w (a1),(a0)+
move.w #$01ae,(a0)+
move.w (a1),(a0)+
move.w #$01b0,(a0)+
move.w (a1),(a0)+
move.w #$01b2,(a0)+
move.w (a1),(a0)+
move.w #$01b4,(a0)+
move.w (a1),(a0)+
move.w #$01b6,(a0)+
move.w (a1),(a0)+
move.w #$01b8,(a0)+
move.w (a1),(a0)+
move.w #$01ba,(a0)+
move.w (a1),(a0)+
move.w #$01bc,(a0)+
move.w (a1),(a0)+
move.w #$01be,(a0)+
move.w (a1)+,(a0)+
add.w  #$0200,d1
dbra	d0,loop4
rts

create_cop2:
lea waittab2,a0
lea coleurs2,a1
move.w #$9709,d1
move.w #51,d0
loop5:
move.w d1,(a0)+
move.w #$fffe,(a0)+
move.w #$0182,(a0)+
move.w (a1)+,(a0)+
add.w  #$0200,d1
dbra   d0,loop5
move.w #$ffd9,(a0)+
move.w #$fffe,(a0)+
move.w #$0182,(a0)+
move.w (a1)+,(a0)+

move.w #$00e9,d1
move.w #51,d0
lea    cox,a2
lea    mir,a3
loop6:
move.w d1,(a0)+
move.w #$fffe,(a0)+
move.w #$0108,(a0)+
move.w (a3)+,(a0)+
move.w #$0180,(a0)+
move.w (a2)+,(a0)+
move.w #$0182,(a0)+
move.w (a1)+,(a0)+
add.w  #$0200,d1
dbra   d0,loop6
rts
cox:
dc.w $100,$200,$300,$400,$500,$600,$700,$800
dc.w $900,$a00,$b00,$c00,$d00,$e00,$f00,$004
dc.w $1,$3,$5,$7,$9,$b,$d,$f,$1f,$3f,$5f,$7f
dc.w $9f,$bf,$df,$ff
dc.w 5,5,5,5,5,5,5,5,5,5
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
dc.w 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4

mir:
dc.w 0,0
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-120,-120
dc.w -120,-120,-120,-120,-120,-120,-120,-120,-80,0,0
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


newclist:
dc.w	$008e,$2821,$0090,$44c1,$0092,$0038,$0094,$00d0
dc.w    $0108,0,$010a,0
dc.w	$0102,$0000,$0104,$0000
dc.w	$0182,$0fff
dc.w	$0100,$4200;,$0180,$0000
dc.w    $00e0,$0005,$00e2,$fffe
dc.w    $00e4,$0006,$00e6,$1f3e
dc.w    $00e8,$0006,$00ea,$3e7e
dc.w    $00ec,$0006,$00ee,$5dbe
dc.w    $0180,$0000,$0182,$0ff0
dc.w    $0184,$0fe0,$0186,$0fd0
dc.w    $0188,$0fb0,$018a,$0fa0
dc.w    $018c,$0f90,$018e,$0f80
dc.w    $0190,$0d60,$0192,$0b50
dc.w    $0194,$0a40,$0196,$0840
dc.w    $0198,$0630,$019a,$0520
dc.w    $019c,$0310,$019e,$0100
dc.w    $5009,$fffe,$0100,$5200
dc.w	$0100,$5200,$0180,$0000
dc.w    $00f0,$0007,$00f2
bit:
dc.w	$3660

;dc.w    $01a6,$0fff
waittab1:
blk.w   1190,0  
dc.w    $9709,$fffe
dc.w    $0100,$1200
dc.w    $00e0,$0007,$00e2
bit2:
dc.w	$4178
dc.w    $0182,$08f0
waittab2:
blk.w   1440,0
  
dc.w	$ffff,$fffe
;scrollm:
dc.b " AND AGAIN SOME STUNNING FX FROM THE GRANDMASTER ICE-T !"
end:
even
;zeiger:
dc.l	0
oldclist:
dc.l	0
gfxbase:
dc.l	0
gfxname:
dc.b	"graphics.library",0
even
blitcounter:
dc.w	0

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

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


letter_pointer:
dc.l	letters2

reset:
dc.l	letters2




even

; mover ! 



test2:
dc.l $637f8



sinfac:
dc.l	0

factor:
dc.l	40

multi:
sydat:
dc.l	$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000001,$00010001,$00010001,$00010002,$00020002,
dc.l	$00020003,$00030003,$00030004,$00040004,$00050005,$00050006,
dc.l	$00060006,$00070007,$00070008,$00080009,$00090009,$000A000A,
dc.l	$000B000B,$000C000C,$000D000D,$000E000E,$000F000F,$00100010,
dc.l	$00110012,$00120013,$00130014,$00150015,$00160016,$00170018,
dc.l	$00180019,$001A001A,$001B001C,$001C001D,$001E001F,$001F0020,
dc.l	$00210022,$00220023,$00240025,$00250026,$00270028,$00290029,
dc.l	$002A002B,$002C002D,$002D002E,$002F0030,$00310032,$00330033,
dc.l	$00340035,$00360037,$00380039,$003A003B,$003C003C,$003D003E,
dc.l	$003F0040,$00410042,$00430044,$00450046,$00470048,$0049004A,
dc.l	$004B004C,$004D004E,$004F0050,$00510052,$00530053,$00540055,
dc.l	$00560057,$00580059,$005A005B,$005C005D,$005E005F,$00600061,
dc.l	$00620063,$00640065,$00660067,$00680069,$006A006B,$006C006D,
dc.l	$006E006F,$00700071,$00720073,$00740075,$00760077,$00780079,
dc.l	$007A007B,$007C007D,$007E007F,$00800081,$00820083,$00840085,
dc.l	$00860087,$00880089,$0089008A,$008B008C,$008D008E,$008F0090,
dc.l	$00910092,$00920093,$00940095,$00960097,$00980099,$0099009A,
dc.l	$009B009C,$009D009E,$009E009F,$00A000A1,$00A200A2,$00A300A4,
dc.l	$00A500A5,$00A600A7,$00A800A8,$00A900AA,$00AA00AB,$00AC00AD,
dc.l	$00AD00AE,$00AF00AF,$00B000B1,$00B100B2,$00B200B3,$00B400B4,
dc.l	$00B500B5,$00B600B7,$00B700B8,$00B800B9,$00B900BA,$00BA00BB,
dc.l	$00BB00BC,$00BC00BD,$00BD00BD,$00BE00BE,$00BF00BF,$00C000C0,
dc.l	$00C000C1,$00C100C1,$00C200C2,$00C200C3,$00C300C3,$00C400C4,
dc.l	$00C400C4,$00C500C5,$00C500C5,$00C500C6,$00C600C6,$00C600C6,
dc.l	$00C600C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C6,$00C600C6,$00C600C6,$00C600C5,
dc.l	$00C500C5,$00C500C4,$00C400C4,$00C400C3,$00C300C3,$00C200C2,
dc.l	$00C200C1,$00C100C1,$00C000C0,$00C000BF,$00BF00BE,$00BE00BE,
dc.l	$00BD00BD,$00BC00BC,$00BB00BB,$00BA00BA,$00B900B9,$00B800B8,
dc.l	$00B700B7,$00B600B6,$00B500B4,$00B400B3,$00B300B2,$00B100B1,
dc.l	$00B000AF,$00AF00AE,$00AD00AD,$00AC00AB,$00AB00AA,$00A900A9,
dc.l	$00A800A7,$00A600A6,$00A500A4,$00A300A3,$00A200A1,$00A0009F,
dc.l	$009F009E,$009D009C,$009B009B,$009A0099,$00980097,$00960095,
dc.l	$00950094,$00930092,$00910090,$008F008E,$008D008C,$008C008B,
dc.l	$008A0089,$00880087,$00860085,$00840083,$00820081,$0080007F,
dc.l	$007E007D,$007C007C,$007B007A,$00790078,$00770076,$00750074,
dc.l	$00730072,$00710070,$006F006E,$006D006C,$006B006A,$00690068,
dc.l	$00670066,$00650064,$00630062,$00610060,$005F005E,$005D005C,
dc.l	$005B005A,$00590058,$00570056,$00550054,$00530052,$00510050,
dc.l	$004F004E,$004D004C,$004B004A,$00490048,$00470046,$00450044,
dc.l	$00430042,$00410040,$0040003F,$003E003D,$003C003B,$003A0039,
dc.l	$00380037,$00360036,$00350034,$00330032,$00310030,$002F002F,
dc.l	$002E002D,$002C002B,$002A002A,$00290028,$00270026,$00260025,
dc.l	$00240023,$00220022,$00210020,$0020001F,$001E001D,$001D001C,
dc.l	$001B001B,$001A0019,$00190018,$00170017,$00160015,$00150014,
dc.l	$00130013,$00120012,$00110011,$0010000F,$000F000E,$000E000D,
dc.l	$000D000C,$000C000B,$000B000A,$000A000A,$00090009,$00080008,
dc.l	$00080007,$00070006,$00060006,$00050005,$00050004,$00040004,
dc.l	$00030003,$00030003,$00020002,$00020002,$00020001,$00010001,
dc.l	$00010001,$00010000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000000
dc.w	$0000
dc.l	$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000001,$00010001,$00010001,$00010002,$00020002,
dc.l	$00020003,$00030003,$00030004,$00040004,$00050005,$00050006,
dc.l	$00060006,$00070007,$00070008,$00080009,$00090009,$000A000A,
dc.l	$000B000B,$000C000C,$000D000D,$000E000E,$000F000F,$00100010,
dc.l	$00110012,$00120013,$00130014,$00150015,$00160016,$00170018,
dc.l	$00180019,$001A001A,$001B001C,$001C001D,$001E001F,$001F0020,
dc.l	$00210022,$00220023,$00240025,$00250026,$00270028,$00290029,
dc.l	$002A002B,$002C002D,$002D002E,$002F0030,$00310032,$00330033,
dc.l	$00340035,$00360037,$00380039,$003A003B,$003C003C,$003D003E,
dc.l	$003F0040,$00410042,$00430044,$00450046,$00470048,$0049004A,
dc.l	$004B004C,$004D004E,$004F0050,$00510052,$00530053,$00540055,
dc.l	$00560057,$00580059,$005A005B,$005C005D,$005E005F,$00600061,
dc.l	$00620063,$00640065,$00660067,$00680069,$006A006B,$006C006D,
dc.l	$006E006F,$00700071,$00720073,$00740075,$00760077,$00780079,
dc.l	$007A007B,$007C007D,$007E007F,$00800081,$00820083,$00840085,
dc.l	$00860087,$00880089,$0089008A,$008B008C,$008D008E,$008F0090,
dc.l	$00910092,$00920093,$00940095,$00960097,$00980099,$0099009A,
dc.l	$009B009C,$009D009E,$009E009F,$00A000A1,$00A200A2,$00A300A4,
dc.l	$00A500A5,$00A600A7,$00A800A8,$00A900AA,$00AA00AB,$00AC00AD,
dc.l	$00AD00AE,$00AF00AF,$00B000B1,$00B100B2,$00B200B3,$00B400B4,
dc.l	$00B500B5,$00B600B7,$00B700B8,$00B800B9,$00B900BA,$00BA00BB,
dc.l	$00BB00BC,$00BC00BD,$00BD00BD,$00BE00BE,$00BF00BF,$00C000C0,
dc.l	$00C000C1,$00C100C1,$00C200C2,$00C200C3,$00C300C3,$00C400C4,
dc.l	$00C400C4,$00C500C5,$00C500C5,$00C500C6,$00C600C6,$00C600C6,
dc.l	$00C600C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C6,$00C600C6,$00C600C6,$00C600C5,
dc.l	$00C500C5,$00C500C4,$00C400C4,$00C400C3,$00C300C3,$00C200C2,
dc.l	$00C200C1,$00C100C1,$00C000C0,$00C000BF,$00BF00BE,$00BE00BE,
dc.l	$00BD00BD,$00BC00BC,$00BB00BB,$00BA00BA,$00B900B9,$00B800B8,
dc.l	$00B700B7,$00B600B6,$00B500B4,$00B400B3,$00B300B2,$00B100B1,
dc.l	$00B000AF,$00AF00AE,$00AD00AD,$00AC00AB,$00AB00AA,$00A900A9,
dc.l	$00A800A7,$00A600A6,$00A500A4,$00A300A3,$00A200A1,$00A0009F,
dc.l	$009F009E,$009D009C,$009B009B,$009A0099,$00980097,$00960095,
dc.l	$00950094,$00930092,$00910090,$008F008E,$008D008C,$008C008B,
dc.l	$008A0089,$00880087,$00860085,$00840083,$00820081,$0080007F,
dc.l	$007E007D,$007C007C,$007B007A,$00790078,$00770076,$00750074,
dc.l	$00730072,$00710070,$006F006E,$006D006C,$006B006A,$00690068,
dc.l	$00670066,$00650064,$00630062,$00610060,$005F005E,$005D005C,
dc.l	$005B005A,$00590058,$00570056,$00550054,$00530052,$00510050,
dc.l	$004F004E,$004D004C,$004B004A,$00490048,$00470046,$00450044,
dc.l	$00430042,$00410040,$0040003F,$003E003D,$003C003B,$003A0039,
dc.l	$00380037,$00360036,$00350034,$00330032,$00310030,$002F002F,
dc.l	$002E002D,$002C002B,$002A002A,$00290028,$00270026,$00260025,
dc.l	$00240023,$00220022,$00210020,$0020001F,$001E001D,$001D001C,
dc.l	$001B001B,$001A0019,$00190018,$00170017,$00160015,$00150014,
dc.l	$00130013,$00120012,$00110011,$0010000F,$000F000E,$000E000D,
dc.l	$000D000C,$000C000B,$000B000A,$000A000A,$00090009,$00080008,
dc.l	$00080007,$00070006,$00060006,$00050005,$00050004,$00040004,
dc.l	$00030003,$00030003,$00020002,$00020002,$00020001,$00010001,
dc.l	$00010001,$00010000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000000
dc.w	$0000
syend:	
dc.l	$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000001,$00010001,$00010001,$00010002,$00020002,
dc.l	$00020003,$00030003,$00030004,$00040004,$00050005,$00050006,
dc.l	$00060006,$00070007,$00070008,$00080009,$00090009,$000A000A,
dc.l	$000B000B,$000C000C,$000D000D,$000E000E,$000F000F,$00100010,
dc.l	$00110012,$00120013,$00130014,$00150015,$00160016,$00170018,
dc.l	$00180019,$001A001A,$001B001C,$001C001D,$001E001F,$001F0020,
dc.l	$00210022,$00220023,$00240025,$00250026,$00270028,$00290029,
dc.l	$002A002B,$002C002D,$002D002E,$002F0030,$00310032,$00330033,
dc.l	$00340035,$00360037,$00380039,$003A003B,$003C003C,$003D003E,
dc.l	$003F0040,$00410042,$00430044,$00450046,$00470048,$0049004A,
dc.l	$004B004C,$004D004E,$004F0050,$00510052,$00530053,$00540055,
dc.l	$00560057,$00580059,$005A005B,$005C005D,$005E005F,$00600061,
dc.l	$00620063,$00640065,$00660067,$00680069,$006A006B,$006C006D,
dc.l	$006E006F,$00700071,$00720073,$00740075,$00760077,$00780079,
dc.l	$007A007B,$007C007D,$007E007F,$00800081,$00820083,$00840085,
dc.l	$00860087,$00880089,$0089008A,$008B008C,$008D008E,$008F0090,
dc.l	$00910092,$00920093,$00940095,$00960097,$00980099,$0099009A,
dc.l	$009B009C,$009D009E,$009E009F,$00A000A1,$00A200A2,$00A300A4,
dc.l	$00A500A5,$00A600A7,$00A800A8,$00A900AA,$00AA00AB,$00AC00AD,
dc.l	$00AD00AE,$00AF00AF,$00B000B1,$00B100B2,$00B200B3,$00B400B4,
dc.l	$00B500B5,$00B600B7,$00B700B8,$00B800B9,$00B900BA,$00BA00BB,
dc.l	$00BB00BC,$00BC00BD,$00BD00BD,$00BE00BE,$00BF00BF,$00C000C0,
dc.l	$00C000C1,$00C100C1,$00C200C2,$00C200C3,$00C300C3,$00C400C4,
dc.l	$00C400C4,$00C500C5,$00C500C5,$00C500C6,$00C600C6,$00C600C6,
dc.l	$00C600C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C6,$00C600C6,$00C600C6,$00C600C5,
dc.l	$00C500C5,$00C500C4,$00C400C4,$00C400C3,$00C300C3,$00C200C2,
dc.l	$00C200C1,$00C100C1,$00C000C0,$00C000BF,$00BF00BE,$00BE00BE,
dc.l	$00BD00BD,$00BC00BC,$00BB00BB,$00BA00BA,$00B900B9,$00B800B8,
dc.l	$00B700B7,$00B600B6,$00B500B4,$00B400B3,$00B300B2,$00B100B1,
dc.l	$00B000AF,$00AF00AE,$00AD00AD,$00AC00AB,$00AB00AA,$00A900A9,
dc.l	$00A800A7,$00A600A6,$00A500A4,$00A300A3,$00A200A1,$00A0009F,
dc.l	$009F009E,$009D009C,$009B009B,$009A0099,$00980097,$00960095,
dc.l	$00950094,$00930092,$00910090,$008F008E,$008D008C,$008C008B,
dc.l	$008A0089,$00880087,$00860085,$00840083,$00820081,$0080007F,
dc.l	$007E007D,$007C007C,$007B007A,$00790078,$00770076,$00750074,
dc.l	$00730072,$00710070,$006F006E,$006D006C,$006B006A,$00690068,
dc.l	$00670066,$00650064,$00630062,$00610060,$005F005E,$005D005C,
dc.l	$005B005A,$00590058,$00570056,$00550054,$00530052,$00510050,
dc.l	$004F004E,$004D004C,$004B004A,$00490048,$00470046,$00450044,
dc.l	$00430042,$00410040,$0040003F,$003E003D,$003C003B,$003A0039,
dc.l	$00380037,$00360036,$00350034,$00330032,$00310030,$002F002F,
dc.l	$002E002D,$002C002B,$002A002A,$00290028,$00270026,$00260025,
dc.l	$00240023,$00220022,$00210020,$0020001F,$001E001D,$001D001C,
dc.l	$001B001B,$001A0019,$00190018,$00170017,$00160015,$00150014,
dc.l	$00130013,$00120012,$00110011,$0010000F,$000F000E,$000E000D,
dc.l	$000D000C,$000C000B,$000B000A,$000A000A,$00090009,$00080008,
dc.l	$00080007,$00070006,$00060006,$00050005,$00050004,$00040004,
dc.l	$00030003,$00030003,$00020002,$00020002,$00020001,$00010001,
dc.l	$00010001,$00010000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000000
dc.w	$0000

sinustabend:
dc.l	$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000001,$00010001,$00010001,$00010002,$00020002,
dc.l	$00020003,$00030003,$00030004,$00040004,$00050005,$00050006,
dc.l	$00060006,$00070007,$00070008,$00080009,$00090009,$000A000A,
dc.l	$000B000B,$000C000C,$000D000D,$000E000E,$000F000F,$00100010,
dc.l	$00110012,$00120013,$00130014,$00150015,$00160016,$00170018,
dc.l	$00180019,$001A001A,$001B001C,$001C001D,$001E001F,$001F0020,
dc.l	$00210022,$00220023,$00240025,$00250026,$00270028,$00290029,
dc.l	$002A002B,$002C002D,$002D002E,$002F0030,$00310032,$00330033,
dc.l	$00340035,$00360037,$00380039,$003A003B,$003C003C,$003D003E,
dc.l	$003F0040,$00410042,$00430044,$00450046,$00470048,$0049004A,
dc.l	$004B004C,$004D004E,$004F0050,$00510052,$00530053,$00540055,
dc.l	$00560057,$00580059,$005A005B,$005C005D,$005E005F,$00600061,
dc.l	$00620063,$00640065,$00660067,$00680069,$006A006B,$006C006D,
dc.l	$006E006F,$00700071,$00720073,$00740075,$00760077,$00780079,
dc.l	$007A007B,$007C007D,$007E007F,$00800081,$00820083,$00840085,
dc.l	$00860087,$00880089,$0089008A,$008B008C,$008D008E,$008F0090,
dc.l	$00910092,$00920093,$00940095,$00960097,$00980099,$0099009A,
dc.l	$009B009C,$009D009E,$009E009F,$00A000A1,$00A200A2,$00A300A4,
dc.l	$00A500A5,$00A600A7,$00A800A8,$00A900AA,$00AA00AB,$00AC00AD,
dc.l	$00AD00AE,$00AF00AF,$00B000B1,$00B100B2,$00B200B3,$00B400B4,
dc.l	$00B500B5,$00B600B7,$00B700B8,$00B800B9,$00B900BA,$00BA00BB,
dc.l	$00BB00BC,$00BC00BD,$00BD00BD,$00BE00BE,$00BF00BF,$00C000C0,
dc.l	$00C000C1,$00C100C1,$00C200C2,$00C200C3,$00C300C3,$00C400C4,
dc.l	$00C400C4,$00C500C5,$00C500C5,$00C500C6,$00C600C6,$00C600C6,
dc.l	$00C600C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C6,$00C600C6,$00C600C6,$00C600C5,
dc.l	$00C500C5,$00C500C4,$00C400C4,$00C400C3,$00C300C3,$00C200C2,
dc.l	$00C200C1,$00C100C1,$00C000C0,$00C000BF,$00BF00BE,$00BE00BE,
dc.l	$00BD00BD,$00BC00BC,$00BB00BB,$00BA00BA,$00B900B9,$00B800B8,
dc.l	$00B700B7,$00B600B6,$00B500B4,$00B400B3,$00B300B2,$00B100B1,
dc.l	$00B000AF,$00AF00AE,$00AD00AD,$00AC00AB,$00AB00AA,$00A900A9,
dc.l	$00A800A7,$00A600A6,$00A500A4,$00A300A3,$00A200A1,$00A0009F,
dc.l	$009F009E,$009D009C,$009B009B,$009A0099,$00980097,$00960095,
dc.l	$00950094,$00930092,$00910090,$008F008E,$008D008C,$008C008B,
dc.l	$008A0089,$00880087,$00860085,$00840083,$00820081,$0080007F,
dc.l	$007E007D,$007C007C,$007B007A,$00790078,$00770076,$00750074,
dc.l	$00730072,$00710070,$006F006E,$006D006C,$006B006A,$00690068,
dc.l	$00670066,$00650064,$00630062,$00610060,$005F005E,$005D005C,
dc.l	$005B005A,$00590058,$00570056,$00550054,$00530052,$00510050,
dc.l	$004F004E,$004D004C,$004B004A,$00490048,$00470046,$00450044,
dc.l	$00430042,$00410040,$0040003F,$003E003D,$003C003B,$003A0039,
dc.l	$00380037,$00360036,$00350034,$00330032,$00310030,$002F002F,
dc.l	$002E002D,$002C002B,$002A002A,$00290028,$00270026,$00260025,
dc.l	$00240023,$00220022,$00210020,$0020001F,$001E001D,$001D001C,
dc.l	$001B001B,$001A0019,$00190018,$00170017,$00160015,$00150014,
dc.l	$00130013,$00120012,$00110011,$0010000F,$000F000E,$000E000D,
dc.l	$000D000C,$000C000B,$000B000A,$000A000A,$00090009,$00080008,
dc.l	$00080007,$00070006,$00060006,$00050005,$00050004,$00040004,
dc.l	$00030003,$00030003,$00020002,$00020002,$00020001,$00010001,
dc.l	$00010001,$00010000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000000
dc.w	$0000

dc.l	$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000001,$00010001,$00010001,$00010002,$00020002,
dc.l	$00020003,$00030003,$00030004,$00040004,$00050005,$00050006,
dc.l	$00060006,$00070007,$00070008,$00080009,$00090009,$000A000A,
dc.l	$000B000B,$000C000C,$000D000D,$000E000E,$000F000F,$00100010,
dc.l	$00110012,$00120013,$00130014,$00150015,$00160016,$00170018,
dc.l	$00180019,$001A001A,$001B001C,$001C001D,$001E001F,$001F0020,
dc.l	$00210022,$00220023,$00240025,$00250026,$00270028,$00290029,
dc.l	$002A002B,$002C002D,$002D002E,$002F0030,$00310032,$00330033,
dc.l	$00340035,$00360037,$00380039,$003A003B,$003C003C,$003D003E,
dc.l	$003F0040,$00410042,$00430044,$00450046,$00470048,$0049004A,
dc.l	$004B004C,$004D004E,$004F0050,$00510052,$00530053,$00540055,
dc.l	$00560057,$00580059,$005A005B,$005C005D,$005E005F,$00600061,
dc.l	$00620063,$00640065,$00660067,$00680069,$006A006B,$006C006D,
dc.l	$006E006F,$00700071,$00720073,$00740075,$00760077,$00780079,
dc.l	$007A007B,$007C007D,$007E007F,$00800081,$00820083,$00840085,
dc.l	$00860087,$00880089,$0089008A,$008B008C,$008D008E,$008F0090,
dc.l	$00910092,$00920093,$00940095,$00960097,$00980099,$0099009A,
dc.l	$009B009C,$009D009E,$009E009F,$00A000A1,$00A200A2,$00A300A4,
dc.l	$00A500A5,$00A600A7,$00A800A8,$00A900AA,$00AA00AB,$00AC00AD,
dc.l	$00AD00AE,$00AF00AF,$00B000B1,$00B100B2,$00B200B3,$00B400B4,
dc.l	$00B500B5,$00B600B7,$00B700B8,$00B800B9,$00B900BA,$00BA00BB,
dc.l	$00BB00BC,$00BC00BD,$00BD00BD,$00BE00BE,$00BF00BF,$00C000C0,
dc.l	$00C000C1,$00C100C1,$00C200C2,$00C200C3,$00C300C3,$00C400C4,
dc.l	$00C400C4,$00C500C5,$00C500C5,$00C500C6,$00C600C6,$00C600C6,
dc.l	$00C600C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,$00C700C7,
dc.l	$00C700C7,$00C700C7,$00C700C6,$00C600C6,$00C600C6,$00C600C5,
dc.l	$00C500C5,$00C500C4,$00C400C4,$00C400C3,$00C300C3,$00C200C2,
dc.l	$00C200C1,$00C100C1,$00C000C0,$00C000BF,$00BF00BE,$00BE00BE,
dc.l	$00BD00BD,$00BC00BC,$00BB00BB,$00BA00BA,$00B900B9,$00B800B8,
dc.l	$00B700B7,$00B600B6,$00B500B4,$00B400B3,$00B300B2,$00B100B1,
dc.l	$00B000AF,$00AF00AE,$00AD00AD,$00AC00AB,$00AB00AA,$00A900A9,
dc.l	$00A800A7,$00A600A6,$00A500A4,$00A300A3,$00A200A1,$00A0009F,
dc.l	$009F009E,$009D009C,$009B009B,$009A0099,$00980097,$00960095,
dc.l	$00950094,$00930092,$00910090,$008F008E,$008D008C,$008C008B,
dc.l	$008A0089,$00880087,$00860085,$00840083,$00820081,$0080007F,
dc.l	$007E007D,$007C007C,$007B007A,$00790078,$00770076,$00750074,
dc.l	$00730072,$00710070,$006F006E,$006D006C,$006B006A,$00690068,
dc.l	$00670066,$00650064,$00630062,$00610060,$005F005E,$005D005C,
dc.l	$005B005A,$00590058,$00570056,$00550054,$00530052,$00510050,
dc.l	$004F004E,$004D004C,$004B004A,$00490048,$00470046,$00450044,
dc.l	$00430042,$00410040,$0040003F,$003E003D,$003C003B,$003A0039,
dc.l	$00380037,$00360036,$00350034,$00330032,$00310030,$002F002F,
dc.l	$002E002D,$002C002B,$002A002A,$00290028,$00270026,$00260025,
dc.l	$00240023,$00220022,$00210020,$0020001F,$001E001D,$001D001C,
dc.l	$001B001B,$001A0019,$00190018,$00170017,$00160015,$00150014,
dc.l	$00130013,$00120012,$00110011,$0010000F,$000F000E,$000E000D,
dc.l	$000D000C,$000C000B,$000B000A,$000A000A,$00090009,$00080008,
dc.l	$00080007,$00070006,$00060006,$00050005,$00050004,$00040004,
dc.l	$00030003,$00030003,$00020002,$00020002,$00020001,$00010001,
dc.l	$00010001,$00010000,$00000000,$00000000,$00000000,$00000000,
dc.l	$00000000,$00000000
dc.w	$0000
abs_end:
even

start_muzak:
	move.l	#data,muzakoffset	;** get offset

init0:	move.l	muzakoffset,a0		;** get highest used pattern
	add.l	#472,a0
	move.l	#$80,d0
	clr.l	d1
init1:	move.l	d1,d2
	subq.w	#1,d0
init2:	move.b	(a0)+,d1
	cmp.b	d2,d1
	bgt.s	init1
	dbf	d0,init2
	addq.b	#1,d2

init3:	move.l	muzakoffset,a0		;** calc samplepointers
	lea	pointers(pc),a1
	lsl.l	#8,d2
	lsl.l	#2,d2
	add.l	#600,d2
	add.l	a0,d2
	moveq	#14,d0
init4:	move.l	d2,(a1)+
	clr.l	d1
	move.w	42(a0),d1
	lsl.l	#1,d1
	add.l	d1,d2
	add.l	#30,a0
	dbf	d0,init4

init5:	clr.w	$dff0a8			;** clear used values
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	clr.w	timpos
	clr.l	trkpos
	clr.l	patpos

init6:	move.l	muzakoffset,a0		;** initialize timer irq
	move.b	470(a0),numpat+1	;number of patterns
;	move.l	$6c.w,lev3save+2
;	move.l	#lev3interrupt,$6c.w
	rts

stop_muzak:
;	move.l	lev3save+2,$6c.w
	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	move.w	#$f,$dff096
	rts

replay_muzak:
	movem.l	d0-d7/a0-a6,-(a7)
	addq.w	#1,timpos
speed:	cmp.w	#6,timpos
	beq.L	replaystep

chaneleffects:				;** seek effects
	lea	datach0(pc),a6
	tst.b	3(a6)
	beq.s	ceff1
	lea	$dff0a0,a5
	bsr.s	ceff5
ceff1:	lea	datach1(pc),a6
	tst.b	3(a6)
	beq.s	ceff2
	lea	$dff0b0,a5
	bsr.s	ceff5
ceff2:	lea	datach2(pc),a6
	tst.b	3(a6)
	beq.s	ceff3
	lea	$dff0c0,a5
	bsr.s	ceff5
ceff3:	lea	datach3(pc),a6
	tst.b	3(a6)
	beq.s	ceff4
	lea	$dff0d0,a5
	bsr.s	ceff5
ceff4:	movem.l	(a7)+,d0-d7/a0-a6
	rts

ceff5:	move.b	2(a6),d0		;room for some more
	and.b	#$f,d0			;implementations below
	tst.b	d0
	beq.s	arpreggiato
	cmp.b	#1,d0
	beq.L	pitchup
	cmp.b	#2,d0
	beq.L	pitchdown
	cmp.b	#12,d0
	beq.L	setvol
	cmp.b	#14,d0
	beq.L	setfilt
	cmp.b	#15,d0
	beq.L	setspeed
	rts

arpreggiato:				;** spread by time
	cmp.w	#1,timpos
	beq.s	arp1
	cmp.w	#2,timpos
	beq.s	arp2
	cmp.w	#3,timpos
	beq.s	arp3
	cmp.w	#4,timpos
	beq.s	arp1
	cmp.w	#5,timpos
	beq.s	arp2
	rts

arp1:	clr.l	d0			;** get higher note-values
	move.b	3(a6),d0		;   or play original
	lsr.b	#4,d0
	bra.s	arp4
arp2:	clr.l	d0
	move.b	3(a6),d0
	and.b	#$f,d0
	bra.s	arp4
arp3:	move.w	16(a6),d2
	bra.s	arp6
arp4:	lsl.w	#1,d0
	clr.l	d1
	move.w	16(a6),d1
	lea	notetable,a0
arp5:	move.w	(a0,d0.w),d2
	cmp.w	(a0),d1
	beq.s	arp6
	addq.l	#2,a0
	bra.s	arp5
arp6:	move.w	d2,6(a5)
	rts

pitchdown:
	bsr.s	newrou
	clr.l	d0
	move.b	3(a6),d0
	and.b	#$f,d0
	add.w	d0,(a4)
	cmp.w	#$358,(a4)
	bmi.s	ok1
	move.w	#$358,(a4)
ok1:	move.w	(a4),6(a5)
	rts

pitchup:bsr.s	newrou
	clr.l	d0
	move.b	3(a6),d0
	and.b	#$f,d0
	sub.w	d0,(a4)
	cmp.w	#$71,(a4)
	bpl.s	ok2
	move.w	#$71,(a4)
ok2:	move.w	(a4),6(a5)
	rts

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

setfilt:move.b	3(a6),d0
	and.b	#1,d0
	lsl.b	#1,d0
	and.b	#$fd,$bfe001
	or.b	d0,$bfe001
	rts

setspeed:
	clr.l	d0
	move.b	3(a6),d0
	and.b	#$f,d0
	move.w	d0,speed+2
	rts

newrou:	cmp.l	#datach0,a6
	bne.s	next1
	lea	voi1(pc),a4
	rts
next1:	cmp.l	#datach1,a6
	bne.s	next2
	lea	voi2(pc),a4
	rts
next2:	cmp.l	#datach2,a6
	bne.s	next3
	lea	voi3(pc),a4
	rts
next3:	lea	voi4(pc),a4
	rts

replaystep:				;** work next pattern-step
	clr.w	timpos
	move.l	muzakoffset,a0
	move.l	a0,a3
	add.l	#12,a3			;ptr to soundprefs
	move.l	a0,a2
	add.l	#472,a2			;ptr to pattern-table
	add.l	#600,a0			;ptr to first pattern
	clr.l	d1
	move.l	trkpos,d0		;get ptr to current pattern
	move.b	(a2,d0),d1
	lsl.l	#8,d1
	lsl.l	#2,d1
	add.l	patpos,d1		;get ptr to current step
	clr.w	enbits
	lea	$dff0a0,a5		;chanel 0
	lea	datach0(pc),a6
	bsr.L	chanelhandler
	lea	$dff0b0,a5		;chanel 1
	lea	datach1(pc),a6
	bsr.L	chanelhandler
	lea	$dff0c0,a5		;chanel 2
	lea	datach2(pc),a6
	bsr.L	chanelhandler
	lea	$dff0d0,a5		;chanel 3
	lea	datach3(pc),a6
	bsr.L	chanelhandler
	move.w	#400,d0			;** wait a while and set len
rep1:	dbf	d0,rep1			;   of oneshot to 1 word
	move.w	#$8000,d0
	or.w	enbits,d0
	move.w	d0,$dff096
	cmp.w	#1,datach0+14
	bne.s	rep2
	clr.w	datach0+14
	move.w	#1,$dff0a4
rep2:	cmp.w	#1,datach1+14
	bne.s	rep3
	clr.w	datach1+14
	move.w	#1,$dff0b4
rep3:	cmp.w	#1,datach2+14
	bne.s	rep4
	clr.w	datach2+14
	move.w	#1,$dff0c4
rep4:	cmp.w	#1,datach3+14
	bne.s	rep5
	clr.w	datach3+14
	move.w	#1,$dff0d4

rep5:	add.l	#16,patpos		;next step
	cmp.l	#64*16,patpos		;pattern finished ?
	bne.s	rep6
	clr.l	patpos
	addq.l	#1,trkpos		;next pattern in table
	clr.l	d0
	move.w	numpat,d0
	cmp.l	trkpos,d0		;song finished ?
	bne.s	rep6
	clr.l	trkpos
rep6:	movem.l	(a7)+,d0-d7/a0-a6
	rts

chanelhandler:
	move.l	(a0,d1.l),(a6)		;get period & action-word
	addq.l	#4,d1			;point to next chanel
	clr.l	d2
	move.b	2(a6),d2		;get nibble for soundnumber
	lsr.b	#4,d2
	beq.s	chan2			;no soundchange !
	move.l	d2,d4			;** calc ptr to sample
	lsl.l	#2,d2
	mulu	#30,d4
	lea	pointers-4(pc),a1
	move.l	(a1,d2.l),4(a6)		;store sample-address
	move.w	(a3,d4.l),8(a6)		;store sample-len in words
	move.w	2(a3,d4.l),18(a6)	;store sample-volume

	move.l	d0,-(a7)
	move.b	2(a6),d0
	and.b	#$f,d0
	cmp.b	#$c,d0
	bne.s	ok3
	move.b	3(a6),8(a5)
	bra.s	ok4
ok3:	move.w	2(a3,d4.l),8(a5)	;change chanel-volume
ok4:	move.l	(a7)+,d0

	clr.l	d3
	move.w	4(a3,d4),d3		;** calc repeatstart
	add.l	4(a6),d3
	move.l	d3,10(a6)		;store repeatstart
	move.w	6(a3,d4),14(a6)		;store repeatlength
	cmp.w	#1,14(a6)
	beq.s	chan2			;no sustainsound !
	move.l	10(a6),4(a6)		;repstart  = sndstart
	move.w	6(a3,d4),8(a6)		;replength = sndlength
chan2:	tst.w	(a6)
	beq.s	chan4			;no new note set !
	move.w	22(a6),$dff096		;clear dma
	tst.w	14(a6)
	bne.s	chan3			;no oneshot-sample
	move.w	#1,14(a6)		;allow resume (later)
chan3:	bsr.L	newrou
	move.w	(a6),(a4)
	move.w	(a6),16(a6)		;save note for effect
	move.l	4(a6),0(a5)		;set samplestart
	move.w	8(a6),4(a5)		;set samplelength
	move.w	(a6),6(a5)		;set period
	move.w	22(a6),d0
	or.w	d0,enbits		;store dma-bit
	move.w	18(a6),20(a6)		;volume trigger
chan4:	rts

datach0:	blk.w	11,0
		dc.w	1
datach1:	blk.w	11,0
		dc.w	2
datach2:	blk.w	11,0
		dc.w	4
datach3:	blk.w	11,0
		dc.w	8
voi1:		dc.w	0
voi2:		dc.w	0
voi3:		dc.w	0
voi4:		dc.w	0
pointers:	blk.l	15,0
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
muzakoffset:	dc.l	0
trkpos:		dc.l	0
patpos:		dc.l	0
numpat:		dc.w	0
enbits:		dc.w	0
timpos:		dc.w	0
data=$40000
Program_end:

