	opt c- o+
NumStars	equ	30
vbl_vec:	equ	$70
key_vec:	equ	$118
hbl_vec:	equ	$120
bpwidth:	equ	320
bpheight:	equ	200
start:
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
        move.l  D0,savesup
	dc.w	$a00a

	bsr	setuptracker

loop:
	bra	loop



save_ints:				*save interrupts
	move.b	$fffffa07.w,mfpa07
	move.b	$fffffa09.w,mfpa09
	move.b	$fffffa13.w,mfpa13
	move.b	$fffffa15.w,mfpa15
	move.b	$fffffa19.w,mfpa19
	move.b	$fffffa1f.w,mfpa1f
	move.l	$134.w,old134
	move.l	$70.w,oldvbl
	rts
init_ints:				*init. interrupts
	clr.b	$fffffa09.w
	clr.b	$fffffa15.w
	move.w	module+$90,d0
	lea	mfp_freqs(pc),a0
	move.b	(a0,d0.w),$fffffa1f.w
	move.b	#2,$fffffa19.w
	move.b	#32,$fffffa07.w
	move.b	#32,$fffffa13.w
	bclr	#3,$fffffa17.w
	move.l	#replay_rot+$88ca,$134.w
	move.l	#vbi,$70.w
	rts
mfp_freqs:				*10 and 8.3 khz
	dc.b	24
	dc.b	29
ret_ints:				*restore interrupts
	move.b	mfpa07,$fffffa07.w
	move.b	mfpa09,$fffffa09.w
	move.b	mfpa13,$fffffa13.w
	move.b	mfpa15,$fffffa15.w
	move.b	mfpa19,$fffffa19.w
	move.b	mfpa1f,$fffffa1f.w
	move.l	old134,$134.w
	move.l	oldvbl,$70.w
	rts	
mfpa07:	dc.b	0			*the vars for saving interrupts
mfpa09:	dc.b	0
mfpa13:	dc.b	0
mfpa15:	dc.b	0
mfpa19:	dc.b	0
mfpa1f:	dc.b	0
old134:	dc.l	0
oldvbl:	dc.l	0

init_ste:
	move.w	#0,$ffff8900.w		*init. STE
	lea	setsam_dat(pc),a0
	move.w	#3,d0
mwwrite:
	move.w	#$7ff,$ffff8924.w
mwwrite2:
	cmp.w	#$07ff,$ffff8924.w
	bne.s	mwwrite2
	move.w	(a0)+,$ffff8922.w
	dbra	d0,mwwrite

	move.l	#$486,temp			
	move.b	temp+1(pc),$ffff8903.w
	move.b	temp+2(pc),$ffff8905.w
	move.b	temp+3(pc),$ffff8907.w

	move.l	#$488,temp
	move.b	temp+1(pc),$ffff890f.w
	move.b	temp+2(pc),$ffff8911.w
	move.b	temp+3(pc),$ffff8913.w

	move.w	#%0000000000000001,$ffff8920.w
	move.w	#3,$ffff8900.w
	rts
setuptracker:
	jsr	init_ste(pc)		*init. ste
	lea	module,a0		*a0=module start
	jsr	replay_rot+$20(pc)	*init. replay routine
	jsr	save_ints(pc)		*save interrupts
	jsr	init_ints(pc)		*init. interrupts
	clr.w	wfnc
	rts

vbi:
	movem.l	d0-d5/a0-a1,-(sp)	*save regs.
	bsr	replay_rot+$24		*jump to music rout
	movem.l	(sp)+,d0-d5/a0-a1	*pop regs.
	rte
temp:
	dc.l	0
setsam_dat:
	dc.w	%0000000011010100  	*mastervol
	dc.w	%0000010010000110  	*treble
	dc.w	%0000010001000110  	*bass
	dc.w	%0000000000000001  	*mixer



******************************************
*               RETURN TO GEM
gem:
	jsr	ret_ints		*restore interrupts

	move.l  savesup,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP

	clr.w	-(sp)
	trap	#1

rvsave:	dc.l	0
resave:	dc.l	0
	even
savesup:	dc.l	0
ressave:	dc.w	0
filename:	dc.l	0
save_usp:
	dc.l	0
wfnc:
	dc.w	0
save_stk:
	dc.l	0
pointer:	dc.l	0
flip:	dc.w	0
flip2:	dc.w	0
seen:	dc.l	0
hiden:	dc.l	0
clrbuffseen:	dc.l	0
clrbuffhiden:	dc.l	0
screen:	dc.l	0
	ds.w	16
*	section	bss
number:	ds.w	1
palsave:
	ds.w	16
vblslot:	ds.l	1
d7emulator:	ds.w	1
pauseimg:
	 dc.w	$7BC7,$1CFB,$C73C,$03E7,$00F1,$C89E,$F800,$8228
	 dc.w	$A282,$28A2,$0088,$808A,$28A0,$8000,$73CF,$A0F3
	 dc.w	$CFBC,$0088,$80F3,$E89C,$F000,$0A08,$A282,$28A4
	 dc.w	$0088,$8082,$2882,$8000,$F208,$9CFB,$E8A2,$0087
	 dc.w	$0082,$273C,$F800


replay_rot:				*the replay routine
	incbin	e:\demo\trackere.rot
	even
module:					*the module
	incbin 	d:\mytdm2.mod
	even
