שתשת                                        *****************************************************************************
*				MOOOOOOOOO!!!				    *
*****************************************************************************
*									    *
*  This is the source code, but you won`t find the text here. It`s kept in  *
* the file called "Text.txt" found elsewhere.				    *
*  I hope you`re using Devpac...					    *
*									    *
*****************************************************************************
*                                                                           *
* A quick note from Tango:-                                                 *
*                                                                           *
* After 30 mins on the phone to our coder, between us, we finally managed   *
* to get the code working on an A1200 ok! Any problems then ring me on      *
* +44 [0]704 576915 or leave me mail on 13th Hour                           *
*                                                                           *
*****************************************************************************

 SECTION LOWMEM,CODE_C
; OPT C-

pages	equ	5	;Set this to the number of pages you`re using
			;If you set it too high then you waste bytes
			;If you set it too low then expect the unexpected...

*****************************************************************************
* EXECUTE SEQUENCE				    			    *
*****************************************************************************

	MOVEM.L A0-A6/D0-D7,-(A7)
	MOVE.L  A7,Stackpoint
	JSR 	Kill_OS
	JSR 	SetUp
	JSR	Rdcinitsines
	JSR	Randinit
	JSR	FormatText
	LEA	$dff000,a6
	MOVEQ	#1,d0
;	MOVEQ	#0,d1
	JSR	Tune
	MOVEQ	#1,d0
	JSR	Tune+2
	JSR 	Main
	JSR	Tune+10
	JSR 	Help_OS
	MOVE.L  Stackpoint,A7
	MOVEM.L (A7)+,A0-A6/D0-D7
	RTS


Perspex	Equ	400
Strech	Equ	6

*****************************************************************************
* KILL OS				            			    *
*****************************************************************************

Kill_OS	MOVE.L	 $4,A6
	CLR.L    D0
	LEA	 GFXlib(PC),A1
	JSR	 -552(A6)
	MOVE.L   D0,GFXBase    
	JSR	 -132(A6)
	MOVE.W	 $DFF002,DMAsave	
	MOVE.W	 $DFF01C,INTensave		
	MOVE.W   $DFF01E,INTrqsave		
;Wt	BTST	 #0,$DFF004			
;	BNE.S	 Wt
;Wtt	CMPI.B	 #55,$DFF006			
;	BNE.S	 Wtt				
	MOVE.W   #$7FFF,$DFF09A   	     	
	MOVE.W   #$7FFF,$DFF096   		
	MOVE.L   #Copperlist,$DFF080		
;	MOVE.W   $DFF088,D0			
	MOVE.W   #%1000001111000000,$DFF096	
	RTS 

*****************************************************************************
* SET UP ROUTINES							    *
*****************************************************************************

SetUp
	MOVE.L	#Planes,A0
	MOVE.L  curframe,D0
	MOVE.L	#1,D1
PlLp	MOVE.W  D0,6(A0)
	SWAP    D0
	MOVE.W  D0,2(A0)
	SWAP    D0
	ADD.L   #(384*44),D0
	ADD.L   #16,A0
	DBRA  D1,PlLp

	move.l	#Shadowplane,d0
	MOVE.W  D0,6(A0)
	SWAP    D0
	MOVE.W  D0,2(A0)
	SWAP    D0

	MOVE.L	#Planes+8,A0
	MOVE.L  #Mainscreen+2,D0
	MOVE.L	#1,D1
PlLp2	MOVE.W  D0,6(A0)
	SWAP    D0
	MOVE.W  D0,2(A0)
	SWAP    D0
	ADD.L   #44,D0
	ADD.L   #16,A0
	DBRA  D1,PlLp2
	RTS

*****************************************************************************
* MAIN					    				    *
*****************************************************************************
Main
	CMPI.B	#200,$DFF006
	BNE.S	Main
	jsr	Music
	jsr	framebuffering
	tst.w	vexon
	beq.s	vexoff
	jsr	vectors
vexoff
	tst.w	texton
	beq.s	txtoff
	jsr	textplot
txtoff
	tst.w	thing
	beq.s	thoff
	jsr	thingies
	bra.s	Main
thoff
	BTST   	#6,$BFE001
	BNE.S  	Main
	move.w	#3,thing
	move.l	#1,Fadeout
Fader
	CMPI.B	#200,$DFF006
	BNE.S	Fader
Fader2
	CMPI.B	#201,$DFF006
	BNE.S	Fader2
	jsr	Music
******************************
	jsr	framebuffering
	tst.w	vexon
	beq.s	vexoff2
	jsr	vectors
vexoff2
	tst.w	texton
	beq.s	txtoff2
	jsr	textplot
txtoff2
	tst.w	thing
	beq.s	thoff2
	jsr	thingies
	bra.s	Fader
thoff2
******************************
	subq.w	#1,fadetimer
	blt.s	Finishedfade
	subq.w	#1,fadeswitch
	bgt.s	Fader
	move.w	#2,fadeswitch
	lea	Black,a0
	lea	Col,a1
	subq	#8,fademus
	bsr.b	ffade
	bra.s	Fader
Finishedfade
 	RTS	 
fadetimer	dc.w	100
fadeswitch	dc.w	2
texton	dc.w	0
thing	dc.w	1
vexon	dc.w	0
************************************************
Music
	move.w	fademus,d0
;	move.l	Fadeout,d1
	jsr	Tune+6
	rts
fademus	dc.w	64
Fadeout	dc.l	0
************************************************
ffade
	move.l	fnumcol,d6
flop2
	move.w	(a0),d0
	move.w	2(a1),d1
	and.w	#$f00,d0
	and.w	#$f00,d1
	move.w	#$100,d2
	bsr.b	fdofade
	move.w	(a0),d0
	move.w	2(a1),d1
	and.w	#$0f0,d0
	and.w	#$0f0,d1
	move.w	#$010,d2
	bsr.b	fdofade
	move.w	(a0),d0
	move.w	2(a1),d1
	and.w	#$00f,d0
	and.w	#$00f,d1
	move.w	#$001,d2
	bsr.b	fdofade
	addq.l	#2,a0
	add.l	fmodulo,a1
	dbra	d6,flop2
	rts

fdofade	cmp.w	d0,d1
	beq.s	fnext
	bgt.s	fadd
	add.w	d2,2(a1)
	bra.s	fnext
fadd	sub.w	d2,2(a1)
fnext	rts

fnumcol			dc.l	15
fmodulo			dc.l	4
black			dcb.w	16,0
************************************************
framebuffering
	bsr.w	SetUp
	move.l	curframe,d0
	cmp.l	#picturea,d0
	beq.b	setb
	move.l	#picturea,curframe
	rts
setb	move.l	#pictureb,curframe
	rts
************************************************
vectors
	jsr	clear
	jsr	calcvex
	jsr	plotvex
	cmp.l	#128*44,vexpos
	bge.s	Veconscreen
	add.l	#44,vexpos
	rts
Veconscreen
	add.l	#2,SWP
	cmp.l	#Endswing,SWP
	blt.s	Notendswing
	move.l	#Swinglist,SWP
Notendswing
	tst.l	vecspd
	bne.s	Notcrossing
	cmp.l	#-44,vecdir
	bne.s	Vecdown
	bsr.w	Randgen
	lea	Priorities1,a0
	move.w	#5,d1
Priloop1
	lsr.w	d0
	bcc.s	Prioff1
	move.w	#0,6(a0)
	bra.s	Prion1
Prioff1
	move.w	#$40,6(a0)
Prion1
	lea	8(a0),a0
	dbf	d1,Priloop1
	bra.s	Notcrossing
Vecdown
	bsr.w	Randgen
	lea	Priorities2,a0
	move.w	#4,d1
Priloop2
	lsr.w	d0
	bcc.s	Prioff2
	move.w	#0,6(a0)
	bra.s	Prion2
Prioff2
	move.w	#$40,6(a0)
Prion2
	lea	8(a0),a0
	dbf	d1,Priloop2
	lsr.w	d0
	bcc.s	Prioff3
	move.w	#0,10(a0)
	bra.s	Prion3
Prioff3
	move.w	#$40,10(a0)
Prion3
Notcrossing
	move.l	vecpos2,d0
	sub.l	vecspd,d0
	move.l	d0,vecpos2
	lsr.l	#6,d0
	move.l	d0,d1
	divu	#44,d1
	swap	d1
	ext.l	d1
	sub.l	d1,d0
	move.l	d0,vexpos
	move.l	vecdir,d0
	add.l	d0,vecspd
	cmpi.l	#-4000,vecspd
	bgt.s	Notminspeed
	move.l	#44,vecdir
Notminspeed
	cmpi.l	#4000,vecspd
	blt.s	Notmaxspeed
	move.l	#-44,vecdir
Notmaxspeed
	rts
vecpos2	dc.l	128*44*64
vecdir	dc.l	-44
vecspd	dc.l	0
************************************************
Randseed	dc.l	0
Randgen
	lea	Randseed,a0
	move.l	(a0),d0
	add.l	d0,d0
	bhi.s	Overflow
	eori.l	#$8149c3a7,d0
Overflow
	move.l	d0,(a0)
	and.l	#$ffff,d0
	divu	#64,d0
	swap	d0
	rts
Randinit
	lea	Randseed,a0
;	move.b	$bfe801,d1
;	and.l	#$ff,d1
;	move.b	$bfe901,d2
;	lsl.w	#8,d2
;	or.w	d2,d1
;	move.b	$bfea01,d2
;	and.l	#$ff,d2
;	swap	d2
;	or.l	d2,d1
;	move.b	$dff00a,d2
;	lsl.w	#8,d2
;	swap	d2 
;	and.w	#0,d2
;	or.l	d2,d1
	move.l	#$aaa66616,d1
	move.l	d1,(a0)
	rts
************************************************
clear
	btst	#14,$Dff002
	bne.b	clear
	move.l	#$9000000,$dff040
	move.l	#0,$dff064
	move.l	#$ffffffff,$dff044
	move.l	#picture2,d4
	move.l	d4,$dff054
	move.l	d4,$dff050
	move.w	#20+(128*64*2),$dff058
	rts
************************************************
textplot
	cmp.w	#2,texton
	beq.w	Textwait
	cmp.w	#3,texton
	beq.w	Textrem
	move.l	tpoint,a0
	move.b	(a0),d0
	bne.s	Notendtext
	move.l	#text,tpoint
	move.b	text,d0
Notendtext
	andi.l	#$ff,d0
	sub.l	#32,d0
	divu	#20,d0
	move.l	#36*40,d1
	mulu	d0,d1
	swap	d0
	add.w	d0,d0
	add.w	d0,d1
	add.l	#Fonty,d1	;d1 is position in font
	move.l	Screenpointer,d0

bt123	btst	#14,$dff002
	bne.s	bt123

	cmp.w	#1,side
	beq.s	Leftg
	move.l	#$69f00000,$dff040
	bra.s	Rightg
Leftg
	move.l	#$9f00000,$dff040
Rightg

	move.l	#$ffffffff,$dff044
	move.l	d1,$dff050
	move.l	d0,$dff054
	move.l	#$26002a,$dff064
	move.w	#(1+36*64),$dff058


	move.l	Screenpointer,d0
bt456	btst	#14,$dff002
	bne.s	bt456

	move.l	#$ffffffff,$dff044

	cmp.w	#1,side
	beq.s	Leftgoing
	move.l	d0,$dff050
	move.l	d0,$dff054
	addq.l	#2,d0
	move.l	#$a9f00000,$dff040
	cmp.l	#2918+Fonty,d1
	bne.s	Rightgoing
	move.l	#$59f00000,$dff040
	bra.s	Rightgoing
Leftgoing
	subi.l	#42,d0
	move.l	d0,$dff054
	addq.l	#2,d0
	move.l	d0,$dff050
	move.l	#$69f00000,$dff040
	cmp.l	#2918+Fonty,d1
	bne.s	Rightgoing
	move.l	#$b9f00000,$dff040
Rightgoing
	move.l	#$20002,$dff064
	move.w	#(21+36*64),$dff058


btshad1	btst	#14,$dff002
	bne.s	btshad1
	move.w	#$30,$dff060
	move.l	#$300004,$dff064
	move.l	#$4b500000,$dff040
	move.l	#$fffffff0,$dff044
	subi.l	#308,d0
	move.l	d0,$dff050
	addi.l	#44*8,d0
	move.l	d0,$dff048
	subi.l	#Mainscreen+2+44,d0
	lsr.l	#1,d0
	addi.l	#Shadowplane,d0
	move.l	d0,$dff054
	move.w	#20+(22*64),$dff058	;Shadow is displayed


	move.w	side,d0
	ext.l	d0
	add.l	d0,tpoint
	addq.w	#1,txcount
	cmp.w	#32,txcount
	blt.w	Notendofrow
	move.w	#0,txcount
	addq.w	#1,tycount
	cmp.w	#12,tycount
	blt.s	Notendofscreen
	move.w	#2,texton
	move.w	#1,vexon
	move.w	#0,tycount
	move.l	#Mainscreen+42+(36*44),Screenpointer
	addi.l	#33,tpoint
	rts
Notendofscreen
	addi.l	#36*44,Screenpointer
	neg.w	side
	cmp.w	#1,side
	bne.s	Gotoleft
	addi.l	#33,tpoint
	addi.l	#42,Screenpointer
	bra.s	Notendofrow
Gotoleft
	subi.l	#42,Screenpointer
	addi.l	#31,tpoint
Notendofrow
	rts
Textwait
	subq.w	#1,txtime
	bgt.s	Notendofrow
	move.w	#500,txtime
	move.w	#3,texton
	rts
Textrem

	move.l	Screenpointer,d0
bt789	btst	#14,$dff002
	bne.s	bt789
	move.l	#$ffff0000,$dff044
	cmp.w	#1,side
	beq.s	Leftgoing2
	addq.l	#2,d0
	move.l	d0,$dff050
	move.l	d0,$dff054
	move.l	#$a9f00000,$dff040
	bra.s	Rightgoing2
Leftgoing2
	subi.l	#40,d0
	move.l	d0,$dff054
	addq.l	#2,d0
	move.l	d0,$dff050
	subq.l	#2,d0
	move.l	#$69f00000,$dff040
Rightgoing2
	move.l	#$20002,$dff064
	move.w	#(21+36*64),$dff058


btshad2	btst	#14,$dff002
	bne.s	btshad2
	move.w	#$30,$dff060
	move.l	#$300004,$dff064
	move.l	#$4b500000,$dff040
	move.l	#$fffffff0,$dff044
	subi.l	#394,d0
	move.l	d0,$dff050
	addi.l	#44*8,d0
	move.l	d0,$dff048
	subi.l	#Mainscreen+2,d0
	lsr.l	#1,d0
	addi.l	#Shadowplane,d0
	move.l	d0,$dff054
	move.w	#20+(22*64),$dff058	;Shadow is displayed


	addq.w	#1,txcount
	cmp.w	#32,txcount
	blt.s	Notendofrow1
	move.w	#0,txcount
	addq.w	#1,tycount
	cmp.w	#12,tycount
	blt.s	Notendofscreen1
	move.w	#0,tycount
	move.w	#1,texton
	move.l	#Mainscreen+42+(36*44),Screenpointer
	rts
Notendofscreen1
	addi.l	#36*44,Screenpointer
	neg.w	side
	cmp.w	#1,side
	bne.s	Gotoleft1
	addi.l	#42,Screenpointer
	bra.s	Notendofrow1
Gotoleft1
	subi.l	#42,Screenpointer
Notendofrow1
	rts
txtime	dc.w	500
tpoint	dc.l	text
txcount	dc.w	0
tycount	dc.w	0
side	dc.w	1		;1 for right, -1 for left
Screenpointer	dc.l	Mainscreen+42+(36*44)
************************************************
thingies
	lea	thinglist,a0
	move.w	thing,d5
	add.w	d5,d5
	add.w	d5,d5
	move.l	(a0,d5.w),a1
	move.l	#$9f000000,d0
	move.w	Pos,d1
	move.w	d1,d2
	andi.w	#$f,d2
	or.w	d2,d0
	ror.l	#4,d0
	lea	twidths,a0
	move.l	(a0,d5.w),d2
	lsr.w	#4,d1
	move.w	d1,d3
	addi.w	#(26*64)+2,d1		;d1=Bltsize
	add.w	d3,d3
	suba.w	d3,a1
	sub.w	d3,d2
	subi.w	#40,d3
	neg.w	d3
bt1111
	btst	#14,$dff002
	bne.s	bt1111
	move.w	d3,$dff066
	move.w	d2,$dff064
	move.l	d0,$dff040
	move.l	#$ffff0000,$dff044
	move.l	a1,$dff050
	move.l	#Mainscreen,$dff054
	move.w	d1,$dff058		;Thing is displayed

	move.w	thingdir,d6
	add.w	d6,Pos
	cmp.w	#4,d5
	beq.s	Meloncontrol
	cmp.w	#8,d5
	beq.w	Whoopscontrol
	cmp.w	#-1,Pos
	bgt.s	Logonotoff
	clr.w	thing
	bra.w	Returnfromthing
Logonotoff
	cmp.w	#49,Pos
	blt.w	Returnfromthing
	move.w	#1,texton
	clr.w	thing
	move.w	#-1,thingdir
	bra.w	Returnfromthing
Meloncontrol
	tst.w	Pos
	beq.s	Melonoff
	cmp.w	#32,Pos
	blt.s	Returnfromthing
	move.w	#32,Pos
	subq.w	#1,thingtimer
	bne.s	Returnfromthing
	move.w	#50,thingtimer
	move.w	#-1,thingdir
	bra.s	Returnfromthing
Melonoff
	move.w	#1,thingdir
	move.w	#2,thing
	bra.s	Returnfromthing
Whoopscontrol
	tst.w	Pos
	beq.s	Whoopsoff
	cmp.w	#64,Pos
	blt.s	Returnfromthing
	move.w	#64,Pos
	subq.w	#1,thingtimer
	bne.s	Returnfromthing
	move.w	#-1,thingdir
	bra.s	Returnfromthing
Whoopsoff
	move.w	#1,thingdir
	move.w	#3,thing
Returnfromthing
	btst	#14,$dff002
	bne.s	Returnfromthing
	move.w	#$4e,$dff060
	move.l	#$4e0022,$dff064
	move.l	#$4b500000,$dff040
	move.l	#$ffff,$dff044
	move.l	#Mainscreen+44+352,$dff048
	move.l	#Mainscreen+44,$dff050
	move.l	#Shadowplane+(44*4)-2,$dff054
	move.w	#5+(13*64),$dff058	;Shadow is displayed
	rts

thingdir
	dc.w	1
Pos	dc.w	0
twidths	dc.l	0,0,4,2
thingtimer
	dc.w	150
thinglist
	dc.l	0
	dc.l	Melon+2
	dc.l	Whoops+6
	dc.l	Defekt+4
************************************************
calcvex
;rotation goes here
	move.w	rotatorx,d0
	addq.w	#2,d0
	cmp.w	#360,d0
	blt.s	smodlyheb1
	sub.w	#360,d0
smodlyheb1
	move.w	d0,rotatorx

	move.w	rotatory,d0
	addq.w	#1,d0
	cmp.w	#360,d0
	blt.s	smodlyheb2
	sub.w	#360,d0
smodlyheb2
	move.w	d0,rotatory

	move.w	rotatorz,d0
	addq.w	#3,d0
	cmp.w	#360,d0
	blt.s	smodlyheb3
	sub.w	#360,d0
smodlyheb3
	move.w	d0,rotatorz

	lea	poly2,a2
	lea	points,a6
	move.l	SWP,a5
fnerg
skegness
	move.w	(a2)+,d4
	move.w	d4,(a6)+
	cmp.w	#$7fff,d4
	beq.w	endrotatevex
	move.w	(a2)+,d5
	move.w	(a2)+,d6
	move.w	rotatorx,d1
	jsr	rdcsincos
	move.w	d2,d0
	asr.w	#6,d0
	jsr	yrotationvex
	move.w	rotatory,d1
	jsr	rdcsincos
	move.w	d2,d0
	asr.w	#6,d0
	add.w	#50,d0
	jsr	xrotationvex
	move.w	rotatorz,d1
	jsr	rdcsincos
	move.w	d2,d0
	asr.w	#7,d0
	jsr	zrotationvex
	add.w	#perspex,d6
	asl.w	#strech,d4
	asl.w	#strech,d5
	ext.l	d4
	ext.l	d5
	asr.w	#1,d6
	divs	d6,d4
	divs	d6,d5
	add.w	#160,d4
	add.w	(a5),d4
	add.w	#64,d5


	move.w	d4,-2(a6)
	move.w	d5,(a6)+
	bra.b	skegness
***************************************
yrotationvex 
	move.l	d3,d7
	muls	d6,d7
	move.l	d2,d0
	muls	d4,d0
	sub.l	d0,d7
	asr.l	#8,d7
	asr.l	#6,d7
	move.l	d3,d0
	muls	d4,d0
	muls	d6,d2
	add.l	d2,d0
	asr.l	#8,d0
	asr.l	#6,d0
	move.w	d0,d4
	move.w	d7,d6
	rts
xrotationvex
	move.l	d3,d7
	muls	d6,d7
	move.l	d2,d0
	muls	d5,d0
	add.l	d0,d7
	asr.l	#8,d7
	asr.l	#6,d7
	move.l	d3,d0
	muls	d5,d0
	muls	d6,d2
	sub.l	d2,d0
	asr.l	#8,d0
	asr.l	#6,d0
	move.w	d0,d5
	move.w	d7,d6
	rts
zrotationvex
	move.l	d3,d7
	muls	d4,d7
	move.l	d2,d0
	muls	d5,d0
	sub.l	d0,d7
	asr.l	#8,d7
	asr.l	#6,d7
	move.l	d3,d0
	muls	d5,d0
	muls	d4,d2
	add.l	d2,d0
	asr.l	#8,d0
	asr.l	#6,d0
	move.w	d0,d5
	move.w	d7,d4
	rts




;;;
endrotatevex
	lea	poly,a2
	lea	points,a3
	lea	Lightsourcetable,a6
beginvex
	move.w	(a2)+,d6
	cmp.w	#$7fff,d6
	beq.w	endrout
	move.w	d6,d7
	move.w	(a2)+,d2
	move.w	2(a3,d2.w),d3
	move.w	0(a3,d2.w),d2
;Calculate 3rd point
	move.w	2(a2),d0
	move.w	2(a3,d0.w),d1
	move.w	0(a3,d0.w),d0
	move.w	d0,vex3rdx
	move.w	d1,vex3rdy
	move.w	#1,a5
;;
	move.w	d2,xvexstore
	move.w	d3,yvexstore
;
vauxhal
;	move.w	#$f00,$dff180
	move.w	xvexstore,d0
	move.w	yvexstore,d1
	move.w	(a2)+,d2
	cmp.w	#$7fff,d2
	beq.b	beginvex
	move.w	2(a3,d2.w),d3
	move.w	0(a3,d2.w),d2
	move.w	d0,xvexstore1
	move.w	d1,yvexstore1
	move.w	d2,xvexstore
	move.w	d3,yvexstore
	cmp.w	#1,a5
	bne.b	noconvextest

;	move.w	#$f0,$dff180
	move.w	vex3rdx,d4
	move.w	vex3rdy,d5

	sub.w	d2,d0		;x2-x1=dx2
	sub.w	d4,d2		;x3-x2=dx1
	sub.w	d3,d1		;y2-y1=dy2
	sub.w	d5,d3		;y3-y2=dy1
	ext.l	d2
	ext.l	d3
	muls	d0,d3
	muls	d1,d2
	sub.w	d3,d2
	bgt.b	drawconvex

findnextpoly
	move.w	(a2)+,d0
	cmp.w	#$7fff,d0
	bne.b	findnextpoly
	bra.w	beginvex

drawconvex
	tst.l	Fadeout
	beq.s	Dolightsource
	tst.w	thing
	beq.s	Nolightsource
Dolightsource
	lea	Col+34,a4
	add.w	d7,d7
	add.w	d7,d7
	lea	(a4,d7.w),a4
	lsr.w	#2,d7
	lsr.w	#8,d2
	andi.w	#-2,d2
	move.w	(a6,d2.w),(a4)
	move.w	(a6,d2.w),16(a4)
Nolightsource
	move.w	#0,a5
	move.w	xvexstore1,d0
	move.w	yvexstore1,d1
	move.w	xvexstore,d2
	move.w	yvexstore,d3
noconvextest
	lea	picture2,a0
	lsr.w	d6
	bcc.b	notbp1vex
	jsr	linedraw
	move.w	xvexstore1,d0
	move.w	yvexstore1,d1
	move.w	xvexstore,d2
	move.w	yvexstore,d3
notbp1vex
	lea	picture2+(128*40),a0
	lsr.w	d6
	bcc.b	notbp2vex
	jsr	linedraw
notbp2vex
	move.w	d7,d6
	bra.w	vauxhal
endrout
	rts
Lightsourcetable
	dc.w	$822
	dc.w	$833
	dc.w	$944
	dc.w	$944
	dc.w	$a55
	dc.w	$a66
	dc.w	$b66
	dc.w	$b77
	dc.w	$c88
	dc.w	$c88
	dc.w	$d99
	dc.w	$daa
	dc.w	$eaa
	dc.w	$ebb
	dc.w	$fcc
	dc.w	$fcc

************************************************
plotvex
	jsr	polyfila
	rts

***********************
**** Blitterlinien ****
***********************

linedraw:
	cmp.w	d1,d3
	beq.w	eline
	bgt.b	noswapys
	exg.l	d1,d3
	exg.l	d0,d2
noswapys
	addq.w	#1,d1
	cmp.w	d1,d3
;	beq	drawadot
backfromdrawadot
	cmp.w	d0,d2
	bne.b	li_weiter
	cmp.w	d1,d3
	beq.w	li_end
li_weiter:
	cmp.w	#0,d0
	blt.w	li_end
	cmp.w	#0,d1
	blt.w	li_end
	cmp.w	#0,d2
	blt.w	li_end
	cmp.w	#0,d3
	blt.w	li_end
	lea	$dff000,a5
	moveq.l	#40,d4
	muls	d1,d4
	move.w	#$fff0,d5
	and.w	d0,d5
	lsr.w	#3,d5
	add.w	d5,d4
	add.l	a0,d4
	moveq	#0,d5
	sub.w	d1,d3
	roxl.b	#1,d5
	tst.w	d3
	bge.s	li_y2gy1
	neg.w	d3
li_y2gy1:
	sub.w	d0,d2
	roxl.b	#1,d5
	tst.w	d2
	bge.s	li_x2gx1
	neg.w	d2
li_x2gx1:
	move.w	d3,d1
	sub.w	d2,d1
	bge.s	li_dygdx
	exg	d2,d3
li_dygdx:
	roxl.b	#1,d5
	move.b	li_okttable(pc,d5),d5
	add.w	d2,d2
	and.w	#$f,d0
	ror.w	#4,d0
	or.w	d0,d5
	or.w	#$0b4a,d0
li_wait:
	btst	#14,2(a5)
	bne.s	li_wait	
	move.w	d2,$62(a5)
	sub.w	d3,d2
	bge.s	li_signnl
	or.b	#$40,d5
li_signnl:

	move.w	d2,$52(a5)
	sub.w	d3,d2
	move.w	d2,$64(a5)
	move.w	#$8000,$74(a5)
	move.w	#$ffff,$72(a5)
	move.w	#$ffff,$44(a5)

	movem.w	d0/d5,$40(a5)
	move.l	d4,$48(a5)
	move.l	d4,$54(a5)
	move.l	d4,$4c(a5)
	move.w	#40,$60(a5)
	move.w	#40,$66(a5)
	addq.w	#1,d3
	lsl.w	#6,d3
	addq.w	#2,d3
	move.w	d3,$58(a5)

li_end:			
eline	rts
li_okttable:
	dc.b	0*4+3
	dc.b	4*4+3
	dc.b	2*4+3
	dc.b	5*4+3
	dc.b	1*4+3
	dc.b	6*4+3
	dc.b	3*4+3
	dc.b	7*4+3

drawadot
	movem.w	d2-d3/a0,-(sp)
	muls	#40,d3
	move.w	#$fff7,d5
	sub.w	d2,d5
	and.w	#7,d5
	asr.w	#3,d2
	lea	0(a0,d3.w),a0
	bchg	d5,0(a0,d2.w)
	movem.w	(sp)+,d2-d3/a0
	bra.w	backfromdrawadot

polyfila
	move.l	SWP,a0
	move.w	(a0),d7
	asr.w	#3,d7
	andi.l	#$fffe,d7
	subi.w	#10,d7
	ext.l	d7
bt11	btst	#14,$Dff002
	bne.b	bt11
	move.l	#$9f00012,$dff040
	move.l	#$140018,$dff064
	move.l	#$ffffffff,$dff044
	move.l	curframe,d1
	add.l	#(44*384*2)-4,d1
	add.l	d7,d1
	subq.l	#2,d1
	sub.l	vexpos,d1
	move.l	d1,$dff054
	move.l	#picture2+(40*128*2)-2,d1
	add.l	d7,d1
	move.l	d1,$dff050
	move.w	#10+(128*64),$dff058
bt22	btst	#14,$Dff002
	bne.b	bt22
	move.l	#$9f00012,$dff040
	move.l	#$140018,$dff064
	move.l	#$ffffffff,$dff044
	move.l	curframe,d1
	add.l	#(44*384)-4,d1
	add.l	d7,d1
	subq.l	#2,d1
	sub.l	vexpos,d1
	move.l	d1,$dff054
	move.l	#picture2+(40*128)-2,d1
	add.l	d7,d1
	move.l	d1,$dff050
	move.w	#10+(128*64),$dff058
	rts
vexpos	dc.l	0
*****************************************************************************
* Text formatter			    				    *
*****************************************************************************
FormatText
	lea	text,a0
	lea	texttoformat,a1
	moveq	#0,d4
Formatloop
	not.w	d4		;unset="[" at beginning
	lea	(a1),a2
	moveq	#-1,d1		;d1 is letter count
Readlineloop
	addq.w	#1,d1
	move.b	(a2)+,d0
	cmpi.b	#$a,d0
	bne.s	Readlineloop
	tst.w	d1
	bne.s	Existingtext1
	moveq	#31,d3
	bra.s	Addspacesloopeven2
Existingtext1
	btst	#0,d1
	bne.s	Oddnumberofletters
	moveq	#32,d2
	sub.w	d1,d2
	beq.s	Writelineloop
	lsr.w	#1,d2
	move.w	d2,d3
	subq.w	#1,d3
Addspacesloopeven1
	move.b	#" ",(a0)+
	dbf	d3,Addspacesloopeven1
Writelineloop
	move.b	(a1)+,(a0)+
	cmpi.b	#$a,(a1)
	bne.s	Writelineloop
	move.w	d2,d3
	beq.s	Nospaces
	subq.w	#1,d3
Addspacesloopeven2
	move.b	#" ",(a0)+
	dbf	d3,Addspacesloopeven2
Nospaces
	lea	1(a1),a1
	cmpi.b	#"]",(a1)
	bne.b	Formatloop
	clr.b	(a0)+
	rts
Oddnumberofletters
	moveq	#31,d2
	sub.w	d1,d2
	bne.s	Spacesintext
	tst.w	d4
	bne.s	Writelineloop2
	move.b	#"[",(a0)+
	bra.s	Writelineloop2
Spacesintext
	lsr.w	#1,d2
	move.w	d2,d3
	subq.w	#1,d3
	tst.w	d4
	bne.s	Addspacesloopodd1
	move.b	#"[",(a0)+
Addspacesloopodd1
	move.b	#" ",(a0)+
	dbf	d3,Addspacesloopodd1
Writelineloop2
	move.b	(a1)+,(a0)+
	cmpi.b	#$a,(a1)
	bne.s	Writelineloop2
	move.w	d2,d3
	beq.s	Nospaces2
	subq.w	#1,d3
Addspacesloopodd2
	move.b	#" ",(a0)+
	dbf	d3,Addspacesloopodd2
Nospaces2
	tst.w	d4
	beq.s	Notatend
	move.b	#"[",(a0)+
Notatend
	lea	1(a1),a1
	cmpi.b	#"]",(a1)
	bne.w	Formatloop
	clr.b	(a0)+
	rts
*****************************************************************************
* RESTORE OS				    				    *
*****************************************************************************

Help_OS	MOVE.W  INTensave,D7
	BSET    #$F,D7				
	MOVE.W  D7,$DFF09A			
	MOVE.W  INTrqsave,D7
	BSET    #$F,D7
	MOVE.W  D7,$DFF09C			
	MOVE.W  DMAsave,D7
	BSET    #$F,D7
	MOVE.W  D7,$DFF096	  		
	MOVE.L  GFXbase,A0
	MOVE.L  $26(A0),$DFF080			
	MOVE.L  $4,A6
	JSR     -138(A6)			
	RTS 
 
*****************************************************************************
*			        COPPER				    	    *
*****************************************************************************

Copperlist
	DC.L $01080004,$010A0030,$01005600,$01020000
	DC.L $00920038,$009400d0,$008E2c64,$00902cD1
Planes	DC.L $00E00000,$00E20000,$00E40000,$00E60000
	DC.L $00E80000,$00EA0000,$00EC0000,$00EE0000
	dc.l $00f00000,$00f20000
Col
	dc.w $0190,$0966,$0192,$0dbb,$0194,$0000,$0196,$0fff
	DC.L $01980000,$019A0000,$019C0000,$019E0000
	DC.L $01800966,$01820000,$01840000,$01860000
	DC.L $01880744,$018A0000,$018C0000,$018E0000
	DC.L $01040000
Priorities1
	dc.l $3e01ff00,$01040000
	dc.l $5001ff00,$01040000
	dc.l $6201ff00,$01040000
	dc.l $7401ff00,$01040000
	dc.l $8601ff00,$01040000
	dc.l $9801ff00,$01040000
Priorities2
	dc.l $aa01ff00,$01040000
	dc.l $bc01ff00,$01040000
	dc.l $ce01ff00,$01040000
	dc.l $e001ff00,$01040000
	dc.l $f201ff00,$01040000
	dc.l $ffe1fffe
	dc.l $0401ff00,$01040000
	DC.L $FFFFFFFE

*****************************************************************************
* LABELS,INCLUDES							    *
*****************************************************************************

GFXlib			DC.B "graphics.library"
Stackpoint		DC.L 0
GFXbase			DC.L 0
INTrqsave		DC.W 0
INTensave		DC.W 0
DMAsave			DC.W 0
xvexstore	dc.w	0
yvexstore	dc.w	0
xvexstore1	dc.w	0
yvexstore1	dc.w	0
counter		dc.w	0
vex3rdx		dc.w	0
vex3rdy		dc.w	0
tempvexstore	dc.w	0
tempcossin	dc.l	0
rotatorx	dc.w	0
rotatory	dc.w	0
rotatorz	dc.w	0
transformx	dc.w	0
transformy	dc.w	0
transformz	dc.w	0
curframe	dc.l	picturea
poly
	dc.w	%10
	dc.w	0,4,8,12,0
	dc.w	$7fff
	dc.w	%1
	dc.w	0,16,20,4,0
	dc.w	$7fff
	dc.w	%11
	dc.w	0,12,28,16,0
	dc.w	$7fff
	dc.w	%10
	dc.w	16,28,24,20,16
	dc.w	$7fff
	dc.w	%1
	dc.w	12,8,24,28,12
	dc.w	$7fff
	dc.w	%11
	dc.w	4,20,24,8,4
	dc.w	$7fff
	dc.w	$7fff
points
	dcb.w	200
poly2
	dc.w	-100,-100,-100	;0
	dc.w	100,-100,-100	;4
	dc.w	100,-100,100	;8
	dc.w	-100,-100,100	;12
	dc.w	-100,100,-100	;16
	dc.w	100,100,-100	;20
	dc.w	100,100,100	;24
	dc.w	-100,100,100	;28
	dc.w	$7fff
	dc.w	$7fff

rdcinitsines
	lea	rdcsines,a0
	lea	rdccosines,a1
	moveq	#0,d4
	move.w	#359,d7
rdcangslop
	move.w	d4,d1
	bsr.b	rdcpresincos
	move.w	d2,(a0)+
	move.w	d3,(a1)+
	addq.w	#1,d4
	dbra	d7,rdcangslop
	rts
rdcsincos
	lea	rdcsines,a0
	lea	rdccosines,a1
	add.w	d1,d1
	move.w	0(a0,d1.w),d2
	move.w	0(a1,d1.w),d3
	rts

rdcpresincos
	lea	rdcsintable,a5
	cmp	#360,d1
	bmi.s	rdcless360
	sub	#360,d1
rdcless360
	cmp	#270,d1
	bmi.s	rdcless270
	bsr.b	rdcover270
	rts
rdcless270
	cmp	#180,d1
	bmi.s	rdcless180
	bsr.b	rdcover180
	rts
rdcless180
	cmp	#90,d1
	bmi.s	rdcless90
	bsr.b	rdcover90
	rts
rdcless90
	add	d1,d1
	move.w	0(a5,d1.w),d2
	subi	#180,d1
	neg	d1
	move.w	0(a5,d1.w),d3
	rts
rdcover270
	subi	#360,d1
	neg	d1
	add	d1,d1
	move.w	0(a5,d1.w),d2
	neg	d2
	subi	#180,d1
	neg	d1
	move.w	0(a5,d1.w),d3
	rts
rdcover180
	subi	#180,d1
	add	d1,d1
	move.w	0(a5,d1.w),d2
	neg	d2
	subi	#180,d1
	neg	d1
	move.w	0(a5,d1.w),d3
	neg.w	d3
	rts
rdcover90
	subi	#180,d1
	neg	d1
	add	d1,d1
	move.w	0(a5,d1.w),d2
	subi	#180,d1
	neg	d1
	move.w	0(a5,d1.w),d3
	neg	d3
	rts


rdcsintable
	dc.w	0,286,572,857,1143,1428,1713,1997,2280,2563,2845,3126
	dc.w	3406,3686,3964,4240,4516,4790,5063,5334,5604,5872,6138
	dc.w	6402,6664,6924,7182,7438,7692,7943,8192,8438,8682,8923
	dc.w	9162,9397,9630,9860,10087,10311,10531,10749,10963,11174
	dc.w	11381,11585,11786,11982,12176,12365,12551,12733,12911
	dc.w	13085,13255,13421,13583,13741,13894,14044,14189,14330
	dc.w	14466,14598,14726,14849,14968,15082,15191,15296,15396
	dc.w	15491,15582,15668,15749,15826,15897,15964,16026,16083
	dc.w	16135,16182,16225,16262,16294,16322,16344,16362,16374
	dc.w	16382,16384

rdcsines	dcb.w	360
rdccosines	dcb.w	360

 SECTION  LOWMEM2,DATA_C	

Mainscreen		dcb.b	(256*44)*2
Shadowplane		dcb.b	(256*44)
Picturea		DCB.B	(384*44)*2
pictureb		dcb.b	(384*44)*2
picture2		dcb.b	(128*40)*2
Fonty			incbin	dh0:work/krak/Font2.blt
Melon			incbin	dh0:work/krak/Melon.blt
			dcb.b	2*4*4
Whoops			incbin	dh0:work/krak/Whoops.blt
			dcb.b	2*8*4
Defekt			incbin	dh0:work/krak/Defekt.blt
Tune			incbin	dh0:mods/pro.equ
SWP	dc.l	Swinglist+148
Swinglist
	dc.w	80,80,80,80,80,80,79,79
	dc.w	79,79,78,78,77,77,77,76
	dc.w	76,75,74,74,73,72,72,71
	dc.w	70,69,68,68,67,66,65,64
	dc.w	63,62,61,59,58,57,56,55
	dc.w	54,52,51,50,48,47,46,44
	dc.w	43,41,40,39,37,36,34,33
	dc.w	31,29,28,26,25,23,22,20
	dc.w	18,17,15,13,12,10,8,7
	dc.w	5,3,2,0,-1,-2,-4,-6
	dc.w	-7,-9,-11,-12,-14,-16,-17,-19
	dc.w	-21,-22,-24,-25,-27,-28,-30,-32
	dc.w	-33,-35,-36,-38,-39,-40,-42,-43
	dc.w	-45,-46,-47,-49,-50,-51,-53,-54
	dc.w	-55,-56,-57,-58,-60,-61,-62,-63
	dc.w	-64,-65,-66,-67,-67,-68,-69,-70
	dc.w	-71,-71,-72,-73,-73,-74,-75,-75
	dc.w	-76,-76,-76,-77,-77,-78,-78,-78
	dc.w	-78,-79,-79,-79,-79,-79,-79,-79
	dc.w	-79,-79,-79,-79,-78,-78,-78,-78
	dc.w	-77,-77,-76,-76,-76,-75,-75,-74
	dc.w	-73,-73,-72,-71,-71,-70,-69,-68
	dc.w	-67,-67,-66,-65,-64,-63,-62,-61
	dc.w	-60,-58,-57,-56,-55,-54,-53,-51
	dc.w	-50,-49,-47,-46,-45,-43,-42,-40
	dc.w	-39,-38,-36,-35,-33,-32,-30,-28
	dc.w	-27,-25,-24,-22,-21,-19,-17,-16
	dc.w	-14,-12,-11,-9,-7,-6,-4,-2
	dc.w	-1,0,2,3,5,7,8,10
	dc.w	12,13,15,17,18,20,22,23
	dc.w	25,26,28,29,31,33,34,36
	dc.w	37,39,40,41,43,44,46,47
	dc.w	48,50,51,52,54,55,56,57
	dc.w	58,59,61,62,63,64,65,66
	dc.w	67,68,68,69,70,71,72,72
	dc.w	73,74,74,75,76,76,77,77
	dc.w	77,78,78,79,79,79,79,80
	dc.w	80,80,80,80
Endswing
text	dcb.b	32*12*(pages)," "

	even
texttoformat
	incbin	dh0:download/Text.txt
	even

