CopperMagnify


rout			;when this is off, the routine-file will be
			;assembled, on=testing

routp			;on = publicmem part will be assembled
routc			;on = chipmem part will be assembled

			
;debug			;when this is on, colors in the background will
			;show how much time the routine needs.

;ntsctest		;when this is on, the routineplayer is in ntsc-mode

;ocs			;off=AGA,on=OCS testing not possible on OCS !

routinemode	equ	1;20+16	;the routinemode !


; VideoTracker AGA developer source 25-12-93
; 24-bits colors, Super-HiRes, HAM8, maximum burstmode (64 pixels aligned)
; wich makes low-resolution overscan a bit ugly.
; no "interactive" support anymore, it's only used by Kick 1.3 users.

; the first part of the source handles the things that are necessary to
; show the picture/copper and playing of the routine.
; the part between the "***" lines is the routine-source.
; at the bottom of the file, there are the necessary incbin-files who

; are needed to test the routine.
; these are saved with "save effect" in videotracker. they are raw
; data files which can be fonts,pictures,landscapes,vectorobjects
; etcetra.
; the incbin-files are put in the "variables" table, in the routine-
; player-handler
; the place where it's done can be found by searching for "!!!"

;	opt	a+	;devpac 3 optimize
	opt	o+

vew_wid	equ	48
vew_hgt	equ	290
win_hgt	equ	117
win_str	equ	$1a

		ifd	ocs
pic_wid		equ	4		;wide in bytes
pic_hgt		equ	6		;hoogte
pic_dpt		equ	8		;number planes
pic_ani		equ	10		;aantal effes (anim)
pic_vew		equ	12		;viewmode
pic_cycstr	equ	14		;cycle start (*4)
pic_cycend	equ	15		;cycle end (*4)
pic_cycspd	equ	16		;cycle speed (*4)
pic_cycadd	equ	17		;cycle add (*4)
pic_palnum	equ	30		;aantal kleuren
pic_pal		equ	32		;palette start
pic_palsiz	equ	256*2		;vaste palette size
pic_raw		equ	pic_pal+pic_palsiz	;palette start
		endc
		
		ifnd	ocs
pic_wid		equ	4		;wide in bytes
pic_hgt		equ	6		;hoogte
pic_dpt		equ	8		;number planes
pic_ani		equ	10		;aantal effes (anim)
pic_vew		equ	12		;viewmode
pic_cycstr	equ	14		;cycle start (*8)
pic_cycend	equ	15		;cycle end (*8)
pic_cycspd	equ	16		;cycle speed (*8)
pic_cycadd	equ	17		;cycle add (*8)
pic_widmod	equ	46		;animation-width modulo
pic_future	equ	50		;free future space
pic_palnum	equ	62		;aantal kleuren
pic_pal		equ	64		;palette start
pic_palsiz	equ	256*4		;vaste palette size (longwords)
pic_raw		equ	pic_pal+pic_palsiz	;palette start
		endc
		
var_len		equ	$300		;lengte vartabel

var__GfxBase	equ	$000		;graphics lib
var_pic1	equ	$004		;current picture
var_anispd1	equ	$008		;animspeed
var_anitel1	equ	$00c		;animcount
var_cprbck	equ	$010		;copperback
var_bck		equ	$014		;background
var_pic2	equ	$018		;current picture
var_ntsc	equ	$01c		;ntsc/pal frequence
var_lnd		equ	$020		;landscape
var_anilop1	equ	$024
var_rottrg	equ	$028		;effect trigger
var_txt1	equ	$040		;text
var_txt16	equ	15*4+var_txt1
var_vec1	equ	$080		;vectors
var_vec16	equ	15*4+var_vec1
var_fon1	equ	$0c0		;fonts
var_fon16	equ	15*4+var_fon1
var_cols1	equ	$100		;colorsets
var_cols16	equ	15*4+var_cols1
var_obj1	equ	$180		;objects
var_obj16	equ	15*4+var_obj1

	ifd	rout
	;videotracker routine-test

	incdir	"w:include/"
	include	"exec/types.i"
	include	"graphics/gfxbase.i"
	include	"lvo/graphics_lib.i"
	incdir	'videotracker:effect/'

	SECTION	1,CODE
tus
	move.l	#var,a0
	move.l	#rotsrc,curpic1		;picture !!!
	move.l	#rotsrc,curpal1		;palette !!!
;	move.l	#rotset,var_cols1(a0)	;colorset !!!

	bsr	paltabres

	move.l	($4).w,a6
	sub.l	a1,a1
	jsr	-$126(a6)		;findtask
	move.l	d0,curtsk
	move.l	d0,a0
	move.l	$b8(a0),tskpri

	lea	dosnam,a1		;doslib openen
	moveq.l	#0,d0
	move.l	(4).w,a6
	jsr	-408(a6)		;openlib
	move.l	d0,doslib

	bsr.s	label5			;videotracker opstarten
	
	move.l	curtsk,a0
	move.l	tskpri,$b8(a0)
	move.l	($4).w,a6
	jsr	-$84(a6)		;forbid

	move.l	doslib,a1
	move.l	(4).w,a6
	jsr	-414(a6)		;closelib

	moveq.l	#0,d0
	rts
	
label5
	move.l	(4).w,a6		;workbench gedoe

	move.b	530(a6),ntscmode	;50/60 hertz halen

	ifd	ntsctest
	move.b	#60,ntscmode		;60 hertz (ntsc)
	endc

	cmp.b	#50,ntscmode		;ntsc ?
	beq.s	str.ntsc
	move.l	#vew_hgt-56,hogscr	;set NTSC screen hight
str.ntsc

	lea	cprjmp,a2		;copjmp zetten !
	move.l	#cprbck-8,d0
	move.w	d0,6(a2)
	swap	d0
	move.w	d0,2(a2)

	lea	cprbck-8,a2		;copstr zetten !
	move.l	#cpr,d0
	move.w	d0,6(a2)
	swap	d0
	move.w	d0,2(a2)

	bsr	cprsprrem		;sprites legen

	lea	gfxnam,a1		;graphics lib openen
	move.l	(4).w,a6
	jsr	-408(a6)		;openlib
	move.l	d0,a6
	move.l	d0,gfxlib
	move.l	38(a6),oldcprlist

	bset	#1,$bfe001
	bsr	copbuf			;copper vullen

	bsr	sysoff

gadrun
	btst	#6,($bfe001).l
	bne	gadrun

scrend
scrend.play
	bsr	syson

	move.l	gfxlib,a1
	move.l	(4).w,a6
	jsr	-414(a6)		;closelib

scrend.qb
	moveq.l	#0,d0	
	rts
	
	;vertical blank interrupt, no blits.
	;handles counters,interlace,sprite
	;level 3

intvb
	bra.s	intvb.cnt
	dc.l	'VIDU'
	dc.l	'LOOP'
intvb.cnt
	movem.l	d0-d7/a0-a6,-(sp)
	lea	($dff000).l,a6

	move.w	$01e(a6),d0
	btst	#5,d0			;vblank ?
	bne.s	intvb.vb

	bra.s	intcop.end

intvb.vb
	bsr	grap
	bsr	palctr			;palette zetten
	bsr.s	copbuf			;copper vullen
	
intvb.end
	move.w	#$0020,$09c(a6)	;vb bit wissen
	movem.l	(sp)+,d0-d7/a0-a6	;multitask uit, shit !
	rte

intcop.end
	movem.l	(sp)+,d0-d7/a0-a6
	move.l	intvbold,-(sp)
	rts

	;transmission buffer empty routine, BLIT !
	;handles routines,animations
	
inttbe					;tbe interrupt
	movem.l	d0-d7/a0-a6,-(sp)
	lea	($dff000).l,a6

	move.w	$01e(a6),d0
	btst	#0,d0			;no tbe ?
	beq.s	intdskblk


	btst	#6,($bfe001).l		;muis ingedrukt ?
	beq.s	inttbe.cop
	btst	#2,($dff016).l
	beq.s	inttbe.cop

	ifd	debug
	move.w	#$700,$dff180
	endc
	
	bsr	rotply			;routineplayer BLIT !
	bsr.s	copbuf			;copper vullen

	ifd	debug
	move.w	#$070,$dff180
	endc
	
inttbe.cop

inttbe.end
	move.w	#$0001,$09c(a6)
	movem.l	(sp)+,d0-d7/a0-a6
	rte

intdskblk
	move.w	#$0001,$09c(a6)		;be sure for no tbe handling
	movem.l	(sp)+,d0-d7/a0-a6
	move.l	inttbeold,-(sp)
	rts


	;moves the copperbuffer to the copperlist
	;sort of double buffering
	
copbuf
	movem.l	d0-d7/a0-a6,-(sp)

	lea	($dff000).l,a6

copbuf.novb				;copperchange overslaan
	moveq.l	#0,d0
	move.b	$005(a6),d0
	lsl.w	#8,d0
	moveq.l	#0,d1
	move.b	$006(a6),d1
	add.w	d1,d0

	cmp.w	#$4,d0			;lower limit, all stations 100%
	blt	copbuf.novb

	cmp.b	#50,ntscmode
	beq.s	copbuf.pal
	cmp.w	#$133-72-8,d0		;ntsc grens
	bge	copbuf.novb
	bra.s	copbuf.cont
copbuf.pal
	cmp.w	#$133-8,d0		;pal grens
	bge	copbuf.novb
copbuf.cont

	lea	gra.s,a0		;buffer copieren
	lea	cprbuf,a1
copbuf_aga				;AGA stuff :)
	move.l	#(gra.ql)/4-1,d0
copbuf.a
	move.w	2(a0),2(a1)
	add.l	#4,a0
	add.l	#4,a1
	dbra	d0,copbuf.a

copbuf.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts

	;goes back to the workbench
	
syson
	movem.l	d0-d7/a0-a6,-(sp)

	move.w	#$0001,$dff09a		;tbeint uit
	move.l	intvbold,($6c).w
	move.l	inttbeold,($64).w

	move.l	4,a6
	jsr	-138(a6)		;permit

	move.l	gfxlib,a6
	jsr	-462(a6)		;disownblitter

	move.l	wbview,a1
	move.l	gfxlib,a6
	jsr	_LVOLoadView(a6) 	; Fix view
	jsr	_LVOWaitTOF(a6)
	jsr	_LVOWaitTOF(a6)         ; wait for LoadView()

syson.ras
	cmp.b	#$c0,$dff006		;prevent copperjump
	bne	syson.ras

	move.l	gfxlib,a6
	move.l	gb_copinit(a6),$dff080	 ; Kick it into life

	movem.l	(sp)+,d0-d7/a0-a6
	rts
	
	;goes back to the gadgetscreen
	
sysoff
	movem.l	d0-d7/a0-a6,-(sp)
 	
	move.l	gfxlib,a6
	move.l	gb_ActiView(a6),wbview	;current view
	sub.l	a1,a1			; clear a1
	jsr 	_LVOLoadView(a6) 	; Flush View to nothing
	jsr	_LVOWaitTOF(a6) 	; Wait once
	jsr	_LVOWaitTOF(a6) 	; Wait again.

	move.l	gfxlib,a6
	jsr	-456(a6)		;ownblitter

	move.l	4,a6
	jsr	-132(a6)		;forbid
		
	move.l	($6c).w,intvbold
	move.l	#intvb,($6c).w
	move.l	($64).w,inttbeold
	move.l	#inttbe,($64).w
	move.w	#$8001,$dff09a		;tbeint aan
	bsr	gracpr			;reset copper
	bsr	copbuf			;copy copper
	move.l	#cpr,$dff080

	movem.l	(sp)+,d0-d7/a0-a6
	rts
	
cprsprrem
	movem.l	d0-d7/a0-a6,-(sp)
	lea	cprspr,a0
	move.l	#sprdat,d0
	move.w	#7,d1
cprsprrem.a
	move.w	d0,3*2(a0)
	swap	d0
	move.w	d0,1*2(a0)
	swap	d0
	add.l	#8,a0
	dbra	d1,cprsprrem.a
	movem.l	(sp)+,d0-d7/a0-a6
	rts

varset					;variablen neerzetten
	movem.l	d0-d7/a0-a6,-(sp)
	move.l	#var,a0

	move.l	#cprbck,var_cprbck(a0)
	move.l	gfxlib,var__GfxBase(a0)
	move.b	ntscmode,var_ntsc(a0)

	move.l	curpic1,var_pic1(a0)	;variabel
	move.l	curpic2,var_pic2(a0)	;variabel
	move.w	anispd1,var_anispd1(a0)
	move.w	anitel1,var_anitel1(a0)
	move.b	anilop1,var_anilop1(a0)
	move.l	#rottrg,var_rottrg(a0)
	movem.l	(sp)+,d0-d7/a0-a6
	rts
	
	;this routine handles all videotracker-routines

rotply	
	movem.l	d0-d7/a0-a6,-(sp)

	moveq.l	#0,d0

	lea	currot1,a2		;routine 1
	move.w	rotinf1,d0		;routine info
	bsr.s	rotplyr

rotply.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts

	;this routine handles 1 routine, BLIT !
	
rotplyr
	movem.l	d0-d7/a1-a6,-(sp)

	move.l	#rot,(a2)		;routinestart address
	
;	move.b	#50,ntscmode		;ntsc/pal hz
	clr.l	curpic2			;background picture
	move.w	#1,anispd1		;animationspeed
	clr.w	anitel1			;animation position

	lea	var,a0			;communication-table

	move.b	#0,anilop1		;animloop off/on !!!
	move.w	#32,anispd1		;animdelay !!!
	move.l	#routinemode,d0		;routinemode !!!

	sub.l	a0,a0			;picture info legen

	tst.l	(a2)			;is er een routine ?
	beq	rotplyr.end		;interlace handling

	move.l	intdel,d2		;delay
	move.l	inttel,d1		;teller
	cmp.w	d2,d1
	blt	rotplyr.end
	clr.l	inttel
				
	bsr	varset			;variabelen updaten

	move.l	(a2),a1			;routine halen
	move.l	#var,a0			;variablen tabel

	movem.l	d3-d7/a1-a6,-(sp)

	move.l	#rotchp,a2		;chip-data
	
	moveq.l	#0,d1			;vars wissen
	moveq.l	#0,d2
	moveq.l	#0,d3
	moveq.l	#0,d4
	moveq.l	#0,d5
	moveq.l	#0,d6
	moveq.l	#0,d7
	sub.l	a3,a3
	sub.l	a4,a4
	sub.l	a5,a5
	sub.l	a6,a6

	jsr	4(a1)			;routine afwerken
	movem.l	(sp)+,d3-d7/a1-a6

	;Routine:
	;
	;Input:
	;a0=variabelentabel
	;d0=routinemode
	;
	;Output:
	;a0=picture
	;d1=copperlist
	;d2=interruptdelay		(NOT used till now)
	
	move.w	#$0020,$dff09a		;vb off !

	move.l	d2,intdel		;delay

	lea	cprjmp,a3
	move.l	#cprbck-8,d0

	cmp.l	(a2),a1			;routine ondertussen gewipt ?
	bne.s	rotplyr.nocop
	tst.l	d1			;copperlist ?
	beq.s	rotplyr.nocop
	move.l	d1,d0
rotplyr.nocop
	move.w	d0,6(a3)
	swap	d0
	move.w	d0,2(a3)

	cmp.l	#0,a0			;picture ?
	beq.s	rotplyr.endvb

	move.l	a0,curpic1		;current picture (cycle)
	move.l	a0,curpal1		;current palette

	tst.b	rotdpl			;plane is geleverd
	beq.s	rotplyr.set
	clr.b	rotdpl
	clr.l	cycdel1			;cycle info wissen
	clr.l	4+cycdel1
	clr.l	curfrm1			;curfrm1, altijd planes zetten
rotplyr.set
	clr.b	dplctr
	bsr.s	grap
	bsr	grac			;colorset
rotplyr.endvb
	move.w	#$8020,$dff09a
rotplyr.end
	movem.l	(sp)+,d0-d7/a1-a6
	rts

	;removes possible routine-coppers
	
gracpr
	movem.l	d0-d7/a0-a6,-(sp)
	lea	cprjmp,a3
	move.l	#cprbck-8,d0		;copperlist resetten
	move.w	d0,6(a3)
	swap	d0
	move.w	d0,2(a3)
	movem.l	(sp)+,d0-d7/a0-a6
	rts

grap					;d7=anim
	movem.l	d0-d7/a0-a6,-(sp)

	clr.l	d7

	tst.l	curpic1			;current picture ?
	beq	grap.end

	move.l	curpic1,a2		;normal pic halen

	lea	gracprscr,a1		;window neerzetten
	move.l	hogscr,d1

	move.w	pic_hgt(a2),d3		;pic hoogte
	move.w	pic_vew(a2),d5
	btst	#2,d5			;interlace ?
	beq.s	grap.nohi4
	lsr.w	#1,d3			;/2
grap.nohi4
	cmp.w	d3,d1
	bge.s	grap.hog
	move.w	d1,d3
grap.hog
	sub.w	d3,d1
	lsr.w	#1,d1
	add.w	#win_str,d1
	move.w	d1,d2
	add.w	d3,d2

	move.b	d1,2(a1)		;y start
	move.b	d2,6(a1)		;y end

	move.w	pic_wid(a2),d4		;pic breedte in bytes
	lsl.l	#3,d4

	move.l	#vew_wid*8,d0
	move.l	#0,d1
	move.l	#$61,d6

	cmp.w	#40,pic_wid(a2)		;overscan ?
	ble.s	grap.noov1
	move.l	#$41,d6
grap.noov1

	move.w	pic_vew(a2),d5
	btst	#15,d5			;hires ?
	beq.s	grap.nohi2

	move.l	#(vew_wid)*8*2,d0
	move.l	#1,d1
	move.l	#$61,d6

	cmp.w	#80,pic_wid(a2)		;overscan ?
	ble.s	grap.nohi2
	move.l	#(vew_wid)*8*2,d0
	move.l	#$51,d6

	bra.s	grap.noshi2
grap.nohi2	
	btst	#6,d5			;super hires ?
	beq.s	grap.noshi2

	move.l	#(vew_wid)*8*4,d0
	move.l	#2,d1
	move.l	#$61,d6

	cmp.w	#80*2,pic_wid(a2)	;overscan ?
	ble.s	grap.noshi2
	move.l	#(vew_wid)*8*4,d0
	move.l	#$51,d6

grap.noshi2	

	clr.w	d5
	cmp.w	d0,d4			;breeder dan scherm ?
	ble.s	grap.c
	move.w	d4,d5
	move.w	d0,d4
	sub.w	d0,d5			;modulo
	lsr.w	#3,d5			;/8
grap.c
	lsr.w	d1,d0
	lsr.w	d1,d4

	move.w	d0,d2
	sub.w	d4,d2
	lsr.w	#1,d2			;/2

	add.w	d6,d2
	move.b	d2,3(a1)		;x start
	move.w	d2,d3			;d3 bewaren !

	add.w	d4,d2			;d4 bewaren !
	move.b	d2,7(a1)		;x end
	
	move.w	pic_vew(a2),d6
	btst	#15,d6			;hires ?
	beq.s	grap.nohi5	
	add.l	d4,d4			;*2
	bra.s	grap.noshi5
grap.nohi5
	btst	#6,d6			;super hires ?
	beq.s	grap.noshi5	
	add.l	d4,d4			;*4
	add.l	d4,d4
grap.noshi5

	move.l	d7,-(sp)
	move.w	pic_vew(a2),d6
	move.l	#17,d0
	move.l	#4,d1			;ecs 1
	move.l	#3,d7

	btst	#15,d6			;hires ?
	beq.s	grap.nohi3	
	move.l	#17,d0			;ecs 9
	move.l	#4,d1			;ecs 2
	move.l	#2,d7
	bra.s	grap.noshi3
grap.nohi3
	btst	#6,d6			;super hires ?
	beq.s	grap.noshi3	
	move.l	#17,d0			;ecs 9
	move.l	#4,d1			;ecs 2
	move.l	#1,d7
grap.noshi3
	sub.w	d0,d3
	lsr.w	#1,d3
	move.w	d3,10(a1)		;ddfstrt
	
	move.w	d4,d2			;pic breedte in pixels
	lsr.w	#4,d2			;/16
	sub.w	d1,d2			;-1

	lsl.w	d7,d2			;*8
	add.w	d2,d3
	move.w	d3,14(a1)		;ddfstop
	move.l	(sp)+,d7
	
	lea	pic_raw(a2),a0

	moveq.l	#0,d2
	move.w	pic_dpt(a2),d2
	sub.l	#1,d2
	muls	pic_wid(a2),d2
	add.w	d2,d5

	move.w	pic_vew(a2),d2		;viewmode add
	btst	#2,d2
	beq.s	grap.nolace4

	moveq.l	#0,d2
	move.w	pic_dpt(a2),d2
	muls	pic_wid(a2),d2
	add.w	d2,d5			;interlace gedoe
grap.nolace4

	lea	gracprbpl,a4		;iffpln neerzetten
	lea	gracprpln,a0		;iffpln neerzetten
	moveq.l	#0,d2
	move.w	pic_dpt(a2),d2		;plnnummer 1 halen
	move.l	#8,d6			;copper step !

	tst.l	curpic2			;2de picture ?
	bne.s	grap.pic2
grap.nopic2
	move.w	d5,34(a1)		;modulo oneven zetten
	bra	grap.nodpl
grap.pic2
	move.l	curpic2,a3		;oneven plane
	move.l	curpic2+4,a6		;oneven plane
	move.l	currot2,a5		;oneven plane
	clr.l	curpic2			;mischien niet goed
	clr.l	curpic2+4		;mischien niet goed
	clr.l	curpal2			;mischien niet goed
	clr.l	currot2			;mischien niet goed

	cmp.l	curpic1,a3		;picture hetzelfde ?
	beq.s	grap.nopic2
	
	cmp.l	#0,currot1		;routine ?	
	beq.s	grap.norot
	cmp.l	currot1,a5		;routine hetzelfde ?
	beq.s	grap.nopic2
grap.norot
	cmp.b	#4,d2			;> 16 kleuren ? (AGA)
	bgt	grap.nopic2

	move.w	pic_dpt(a3),d3		;plnnummer 2 halen
	cmp.b	d2,d3			;gelijke plnummers ?
	bne.s	grap.nopic2
	move.w	pic_vew(a2),d1
	cmp.w	pic_vew(a3),d1		;view gelijk ?
	bne.s	grap.nopic2

	move.w	pic_vew(a2),d1		;groter dan view test
	btst	#6,d1			;super hires ?
	beq.s	grap.nohi2a
	move.l	#vew_wid*4,d1
	bra.s	grap.nohi2b
grap.nohi2a
	btst	#15,d1			;hires ?
	beq.s	grap.noshi2a
	move.l	#vew_wid*2,d1
	bra.s	grap.nohi2b
grap.noshi2a
	move.l	#vew_wid,d1
grap.nohi2b
	cmp.w	pic_wid(a2),d1		;breder dan view ?
	bgt.s	grap.small
	cmp.w	pic_wid(a3),d1		;breder dan view ?
	bgt.s	grap.small

	move.w	pic_vew(a2),d1
	btst	#2,d1
	beq.s	grap.nolace8a
	move.l	hogscr,d1
	add.l	d1,d1
	bra.s	grap.nolace8b
grap.nolace8a
	move.l	hogscr,d1
grap.nolace8b
	cmp.w	pic_hgt(a2),d1		;hoger dan view ?
	bgt.s	grap.small
	cmp.w	pic_hgt(a3),d1		;hoger dan view ?
	bgt.s	grap.small
	bra.s	grap.big

grap.small
	move.w	pic_hgt(a2),d1		;wid+hgt<vew
	cmp.w	pic_hgt(a3),d1		;hoogte gelijk ?
	bne	grap.nopic2
	move.w	pic_wid(a2),d1
	cmp.w	pic_wid(a3),d1		;breedte gelijk ?
	bne	grap.nopic2

grap.big
	move.l	a3,curpic2		;toch wel goed !
	move.l	a6,curpic2+4
	move.l	a3,curpal2
	move.l	a5,currot2

	tst.b	dplctr			;dual playfield al gezet ?
	beq	grap.nocop

	move.w	30(a1),34(a1)		;modulo copieren

	move.w	2(a4),d1		;bplcon0
	btst	#10,d1			;al dual playfield ?
	beq.s	grap.ta

	move.w	2(a0),10(a0)		;plane 0>1 copieren
	move.w	6(a0),14(a0)

	move.w	18(a0),26(a0)		;plane 2>3 copieren
	move.w	22(a0),30(a0)

	move.w	34(a0),42(a0)		;plane 4>5 copieren
	move.w	38(a0),46(a0)

	move.w	50(a0),58(a0)		;plane 6>7 copieren
	move.w	54(a0),62(a0)

	bra.s	grap.tb
grap.ta
	move.w	24(a0),58(a0)		;plane 3>7 copieren
	move.w	28(a0),62(a0)

	move.w	18(a0),42(a0)		;plane 2>5 copieren
	move.w	22(a0),46(a0)

	move.w	10(a0),26(a0)		;plane 1>3 copieren
	move.w	14(a0),30(a0)

	move.w	2(a0),10(a0)		;plane 0>1 copieren
	move.w	6(a0),14(a0)

grap.tb
	move.l	#palette,a3		;palette copieren

	move.w	#16-1,d1
grap.pal
	move.l	(a3)+,60(a3)
	dbra	d1,grap.pal

grap.nocop
	add.w	d3,d2			;aantal bitplanes
	cmp.w	#8,d2			;8 bitplanes ?
	blt	grap.no8planes2
	move.w	#%10000,d2		;only bit 4
	bra	grap.8planes2
grap.no8planes2
	lsl.w	#8,d2
	lsl.w	#4,d2
grap.8planes2
	or.w	#$400,d2		;dual playfield aan
	move.w	d2,2(a4)		;bplcon0

	movem.l	d0-d7/a0-a6,-(sp)

	move.l	curpic,a2		;animpic ?
	move.l	curfrm,d7
	cmp.l	#0,a2
	bne.s	grap.noanipic

	move.l	curpic2,a2		;normal pic ?
	move.l	curfrm2,d7
	cmp.l	#0,a2
	beq.s	grap.nodplpic

grap.noanipic
	add.l	d6,a0
	add.w	d6,d6
	bsr.s	grappln			;a2,d6,d7,d0
grap.nodplpic
	movem.l	(sp)+,d0-d7/a0-a6
	add.w	d6,d6
	bra.s	grap.nodpla


grap.nodpl				;geen dual playfield
	cmp.w	#8,d2			;8 bitplanes ?
	blt	grap.no8planes
	move.w	#%10000,d2		;only bit 4
	bra	grap.8planes
grap.no8planes
	lsl.w	#8,d2
	lsl.w	#4,d2
grap.8planes
	move.w	d2,2(a4)		;bplcon0

grap.nodpla
	move.w	d5,30(a1)		;modulo even

	moveq.l	#0,d3
	add.w	pic_vew(a2),d3		;viewmode add
	moveq.l	#0,d2
	move.w	2(a4),d2
	or.l	d3,d2

	ifd	gui
	tst.b	genlck
	bne	grap.genset
	endc

	or.l	#$100,d2		;genlock off ($302)

	ifd	gui
	bra	grap.gencont
grap.genset
	or.l	#$102,d2		;genlock on ($302)
grap.gencont
	endc
	
	move.w	d2,2(a4)
	
	bsr.s	grappln			;a2,d6,d7,d0

grap.end
	
	movem.l	(sp)+,d0-d7/a0-a6
	rts
		

	;sets on of the 2 possible pictures to the copper
	;handles interlace

	;d7=framenummer
	;d6=copperliststap
	;d0=raw planes positie
	;a2=current picture
grappln					;planes invullen 
	movem.l	d0-d7/a0-a6,-(sp)

	lea	pic_raw(a2),a1
	move.l	a1,d0			;raw planes
	
	moveq.l	#0,d2			;x*y
	move.w	pic_wid(a2),d2
	lsr.l	#1,d2			;/2
	moveq.l	#0,d3
	move.w	pic_hgt(a2),d3
	muls	d3,d2
	
	move.l	d2,d4
	add.l	d2,d2

	move.w	pic_dpt(a2),d3
	muls	d3,d4			;hele picture size
	muls	d7,d4			;frame*size d7 !!!

	add.l	d4,d4

	add.l	d4,d0

	move.l	#vew_wid,d5		;max x view
	move.l	hogscr,d4		;max y view
	move.w	pic_vew(a2),d1		;viewmode add
	btst	#2,d1
	beq.s	grappln.nolace
	add.l	d4,d4			;max y view
grappln.nolace
	btst	#15,d1			;hires ?
	beq.s	grappln.nohi
	move.l	#vew_wid*2,d5		;max x view
	bra.s	grappln.noshi
grappln.nohi
	btst	#6,d1			;super hires ?
	beq.s	grappln.noshi
	move.l	#vew_wid*4,d5		;max x view
grappln.noshi

	moveq.l	#0,d3			;scherm centreren
	move.w	pic_wid(a2),d3		;pic breedte in bytes
	cmp.w	d5,d3			;breder dan scherm ?
	ble.s	grappln.qa
	sub.w	d5,d3			;-scherm breedte
	lsr.w	#2,d3			;/4

	add.l	d3,d3

	add.l	d3,d0
grappln.qa
	move.w	pic_hgt(a2),d3		;pic hoogte in bytes
	cmp.w	d4,d3			;hoger dan scherm ?
	ble.s	grappln.qb
	sub.w	d4,d3			;-scherm breedte
	lsr.w	#1,d3			;/2
	moveq.l	#0,d5
	move.w	pic_wid(a2),d5		;pic breedte in bytes
	muls	pic_dpt(a2),d5
	muls	d5,d3
	add.l	d3,d0
grappln.qb
	moveq.l	#0,d2
	move.w	pic_wid(a2),d2

	move.w	pic_vew(a2),d5		;interlace flipping ?
	btst	#2,d5
	beq.s	grappln.nolac7b

	move.w	$04(a6),d5		;even/oneven ?
	btst	#15,d5
	beq.s	grappln.nolac7b
	
	moveq.l	#0,d3
	move.w	pic_wid(a2),d3
	muls	pic_dpt(a2),d3
	add.l	d3,d0
grappln.nolac7b

	move.w	pic_dpt(a2),d1		;plnnummer 1 halen
	tst.w	d1			;0 planes ?
	beq	grappln.end
	sub.w	#1,d1
grappln.a
	move.w	d0,3*2(a0)
	swap	d0
	move.w	d0,1*2(a0)
	swap	d0
	add.l	d6,a0			;d6=copper step !
	add.l	d2,d0
	dbra	d1,grappln.a

	cmp.w	#8,pic_dpt(a2)		;8 planes ?
	bne	grappln.noham8
	btst	#3,pic_vew(a2)		;ham ?
	beq	grappln.noham8

	move.w	-14(a0),d0		;get 6
	move.w	-10(a0),d1
	move.w	-6(a0),d2		;get 7
	move.w	-2(a0),d3
	move.w	-18(a0),-2(a0)		;5>7
	move.w	-22(a0),-6(a0)		;5>7
	move.w	-26(a0),-10(a0)		;4>6
	move.w	-30(a0),-14(a0)		;4>6
	move.w	-34(a0),-18(a0)		;3>5
	move.w	-38(a0),-22(a0)		;3>5
	move.w	-42(a0),-26(a0)		;2>4
	move.w	-46(a0),-30(a0)		;2>4
	move.w	-50(a0),-34(a0)		;1>3
	move.w	-54(a0),-38(a0)		;1>3
	move.w	-58(a0),-42(a0)		;0>2
	move.w	-62(a0),-46(a0)		;0>2
	move.w	d0,-62(a0)		;6>0
	move.w	d1,-58(a0)		;6>0
	move.w	d2,-54(a0)		;7>1
	move.w	d3,-50(a0)		;7>1
grappln.noham8

grappln.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts

	;sets palettes to palette-buffer
	
grac
	movem.l	d0-d7/a0-a6,-(sp)

	lea	curpal1,a3		;palette 1
	move.l	#palette,a1
	bsr.s	gracfrm

	lea	curpal2,a3		;palette 2 (dpl)
	move.l	#16*4+palette,a1
	bsr.s	gracfrm
	
	bsr	palctr			;palette-buffer to copper
grac.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts
		
	;moves palette from picture to palette-buffer

gracfrm
	movem.l	d0-d7/a0-a6,-(sp)
	tst.l	(a3)			;palette aanwezig ?
	beq.s	gracfrm.end

	move.l	(a3),a2			;current palette
	
	cmp.l	#'PALE',(a2)		;palette ?
	bne.s	gracfrm.pict
	lea	6(a2),a0		;palette
	move.w	4(a2),d0		;aantal kleuren
	bra.s	gracfrm.col
gracfrm.pict
	cmp.l	#'ANIM',(a2)		;animatie ?
	bne.s	gracfrm.noanim

	moveq.l	#0,d1
	move.w	pic_ani(a2),d1
	bclr	#7,d1			;behandelbit weghalen

	moveq.l	#0,d3
	move.w	pic_wid(a2),d3
	lsr.w	#1,d3			;/2
	muls	pic_hgt(a2),d3
	muls	pic_dpt(a2),d3

	add.l	d3,d3

	add.l	#pic_raw,d3
	move.l	d3,d5

	btst	#0,d1
	bne.s	gracfrm.buf2
	moveq.l	#0,d5
gracfrm.buf2
	add.l	d5,a2
gracfrm.noanim
	lea	pic_pal(a2),a0		;palette
	move.w	pic_palnum(a2),d0

	tst.w	d0			;0 planes ?
	beq.s	gracfrm.end
gracfrm.col
gracfrm.fa
	move.l	(a0)+,(a1)+
	dbra	d0,gracfrm.fa
gracfrm.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts
	
	;handles colorcycling in the palette-buffer

palcycctr
	movem.l	d0-d7/a0-a6,-(sp)

	move.l	curpic1,a2		;current raw
	cmp.l	#0,a2
	beq.s	palcycctr.qb
	lea	cycdel1,a3		;cycle delays
	move.l	#paltab,a4
	bsr	palcyc
palcycctr.qb
	move.l	curpic2,a2		;current raw
	cmp.l	#0,a2
	beq.s	palcycctr.c
	lea	cycdel2,a3		;cycle delays
	move.l	#16*2+paltab,a4
	bsr	palcyc
palcycctr.c
	movem.l	(sp)+,d0-d7/a0-a6
	rts
	
	;copies palette-buffer to copper

palctr
	movem.l	d0-d7/a0-a6,-(sp)

	lea	gracprcol,a1		;AGA
	move.l	#palette,a0
	move.l	#paltab,a2
	move.w	#8-1,d6
palctr.e
	move.w	#32-1,d7
palctr.d
	move.w	(a2)+,d0			;get cycle-position
	move.w	(a0,d0),6(a1)			;high RGB bits
	move.w	2(a0,d0),((32+1)*4)+6(a1)	;low RGB bits
	add.l	#4,a1
	dbra	d7,palctr.d
	add.l	#((32+2)*4),a1
	dbra	d6,palctr.e
palctr.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts

	;reset palette tabel, for proper color cycling

paltabres
	movem.l	d0-d7/a0-a6,-(sp)
	lea	paltab,a0
	clr.l	d0
	move.w	#256-1,d1
paltabres.a
	move.w	d0,(a0)+
	add.w	#4,d0			;aga color words, high RGB + low RGB
	dbra	d1,paltabres.a
paltabres.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts

	;colorcyclinghandling of a palette

palcyc
	movem.l	d0-d7/a0-a6,-(sp)
	move.w	#4-1,d7			;4 cycles
palcyc.d
	tst.w	(a3)+			;delay klaar ?
	bne.s	palcyc.c
	
	moveq.l	#0,d1
	move.b	pic_cycstr(a2),d1	;start color
	lsl.b	#1,d1		;*2

	moveq.l	#0,d2
	move.b	pic_cycend(a2),d2	;end color
	lsl.b	#1,d2		;*2

	moveq.l	#0,d3
	move.b	pic_cycadd(a2),d3	;richting

	move.l	a4,a0			;palette pointer
	move.l	a0,a1
	add.l	d1,a0			;startcolor
	add.l	d2,a1			;endcolor
	
	cmp.b	#1,d3			;omhoog
	beq.s	palcyc.up	
	cmp.b	#3,d3			;omlaag
	beq.s	palcyc.down
	bra.s	palcyc.i

palcyc.up				;kleuren copieren
	move.w	(a1),d4			;laatst color bewaren
palcyc.f				;kleuren copieren
	cmp.l	a0,a1
	beq.s	palcyc.fa
	move.w	-(a1),2(a1)
	bra.s	palcyc.f
palcyc.fa
	move.w	d4,(a1)
	bra.s	palcyc.g	
	
palcyc.down
	move.w	(a0),d4			;laatst color bewaren
palcyc.h				;kleuren copieren
	cmp.l	a0,a1
	beq.s	palcyc.ha
	move.w	2(a0),(a0)+
	bra.s	palcyc.h
palcyc.ha
	move.w	d4,(a1)

palcyc.g
	move.b	pic_cycspd(a2),-1(a3)	;delay zetten
	bra.s	palcyc.i
palcyc.c
	sub.w	#1,-2(a3)		;cycle delay aftellen
palcyc.i
	add.l	#4,a2			;next cycle info
	dbra	d7,palcyc.d

palcyc.qb
	movem.l	(sp)+,d0-d7/a0-a6
	rts


	SECTION	2,DATA

	cnop	0,2
curtsk		dc.l	0
tskpri		dc.l	0
duplok		dc.l	0
inttel		dc.l	0
intdel		dc.l	0

form		dc.l	0
ifffil		dc.l	0
intvbold	dc.l	0
inttbeold	dc.l	0
patpos		dc.l	0
gfxlib		dc.l	0
doslib		dc.l	0
wbview  	dc.l	0
mt_data		dc.l	0
memvid		dc.l	0
oldcprlist	dc.l	0
hogscr		dc.l	vew_hgt

inspos		dc.l	-1
anispd1		dc.w	1	;nooit op 0 !
anispd2		dc.w	1

		cnop	0,2
varclr.s			;start wissen
oldrot		dc.l	0
curpic		dc.l	0
curfrm		dc.l	0
cycdel1		ds.w	4
cycdel2		ds.w	4

rotinf1		dc.w	0
rotinf2		dc.w	0

effspd		dc.w	0
efflop		dc.b	0
anilop1		dc.b	0
anilop2		dc.b	0
anipal1		dc.b	0
anipal2		dc.b	0
rotdpl		dc.b	1
rottrg		dc.b	0
dplctr		dc.b	0
		cnop	0,2

insdat		ds.l	4
inspri		dc.l	0
instel		dc.w	0

cureff		dc.l	0
efftel		dc.w	0

curpal1		dc.l	0
curpal2		dc.l	0
currot1		dc.l	0
currot2		dc.l	0
curpic1		dc.l	0
curpic2		dc.l	0
anitel1		dc.w	0
anitel2		dc.w	0
curfrm1		dc.l	0
curfrm2		dc.l	0
oldfrm1		dc.l	0
oldfrm2		dc.l	0

varclr.e
		dc.l	0			;wisruimte
	
varclr.ql	equ	varclr.e-varclr.s	;wislengte
	
ntscmode	dc.b	0
end		dc.b	0

pronam	dc.b	'VideoTracker',0
	cnop	0,2
dosnam	dc.b	'dos.library',0
	cnop	0,4
gfxnam	dc.b	'graphics.library',0
	cnop	0,4
	
	cnop	0,4
gra.s			;copperlist edit buffer
gracprscr
	dc.w	$8e,$3381,$90,$81c1,$92,$003c,$94,$00d0
gracprbpl
	dc.w	$100,$0000,$102,$0000,$104,$0020
	dc.w	$108,$0000,$10a,$0000,$1fc,$0003
gracprpln
	dc.w	$e0,$0000,$e2,$0000	;1
	dc.w	$e4,$0000,$e6,$0000	;2
	dc.w	$e8,$0000,$ea,$0000	;3
	dc.w	$ec,$0000,$ee,$0000	;4
	dc.w	$f0,$0000,$f2,$0000	;5
	dc.w	$f4,$0000,$f6,$0000	;6
	dc.w	$f8,$0000,$fa,$0000	;7
	dc.w	$fc,$0000,$fe,$0000	;8
gracprcol
	dc.w	$106,$0000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$0200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$2000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$2200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$4000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$4200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$6000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$6200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$8000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$8200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$a000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$a200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$c000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$c200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$e000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$e200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$1000

cprjmp
	dc.w	$080,0,$082,0
gra.e
gra.ql	equ	gra.e-gra.s		;block lengte


	SECTION	3,DATA_C

	cnop	0,8
cpr					;real copperlist
	dc.w	$0001,$fffe
	dc.w	$09c,$8001		;tbeint
cprspr
	dc.w	$120,$0000,$122,$0000
	dc.w	$124,$0000,$126,$0000
	dc.w	$128,$0000,$12a,$0000
	dc.w	$12c,$0000,$12e,$0000
	dc.w	$130,$0000,$132,$0000
	dc.w	$134,$0000,$136,$0000
	dc.w	$138,$0000,$13a,$0000
	dc.w	$13c,$0000,$13e,$0000

cprbuf
	dc.w	$8e,$3381,$90,$81c1,$92,$003c,$94,$00d0
	dc.w	$100,$9000,$102,$0000,$104,$0020
	dc.w	$108,$0000,$10a,$0000,$1fc,$0003

	dc.w	$e0,$0000,$e2,$0000	;0
	dc.w	$e4,$0000,$e6,$0000	;1
	dc.w	$e8,$0000,$ea,$0000	;2
	dc.w	$ec,$0000,$ee,$0000	;3
	dc.w	$f0,$0000,$f2,$0000	;4
	dc.w	$f4,$0000,$f6,$0000	;5
	dc.w	$f8,$0000,$fa,$0000	;6
	dc.w	$fc,$0000,$fe,$0000	;7

	dc.w	$106,$0000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$0200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$2000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$2200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$4000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$4200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$6000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$6200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$8000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$8200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
 	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$a000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$a200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$c000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$c200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$e000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$e200
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	$106,$1000

	dc.w	$080,0,$082,0
cprbuf.e

	dc.w	$088,$0000		;copjmp2
	dc.w	$080,0,$082,0		;moet achter cprbck blijven !
cprbck
sprdat
	dc.w	$ffff,$fffe

	SECTION	4,BSS

palette		ds.l	256		;palette 24-bits, far out !
paltab		ds.w	256		;palette cycle-tabel

	cnop	0,2
var	ds.b	$300	;variabelen voor routines

	
		endc

; this is the routine-source
;**********************************************************************

;vew_wid	equ	48
;vew_hgt	equ	290
;win_hgt	equ	117
;win_str	equ	$20

;bit8		;full 8 bit copper
;bit4		;48*48 4 bit copper

bitaga
;bit4aga		;88*72 4 bit copper
bit3aga		;117*96 3 bit copper

;calc		;on=calculate tunnel-data,off=play tunnel

rottun_wid	equ	256
rottun_hgt	equ	256

		ifd	calc
		ifd	bit4aga
rotpic_wid	equ	11
rotpic_hgt	equ	72
rotpic_dpt	equ	1
		endc
		ifd	bit3aga
rotpic_wid	equ	15
rotpic_hgt	equ	96
rotpic_dpt	equ	1
		endc
		endc
		
		ifnd	calc
;rotpic_wid	equ	40
;rotpic_hgt	equ	256
;rotpic_dpt	equ	1
;rotcop_hgt	equ	113
;rotcop_dpt	equ	5
		endc
		
		ifd	bit3aga
rotpic_y	equ	288
rotpic_yp	equ	96
rotpic_x	equ	117
		endc
		ifd	bit4aga
rotpic_y	equ	288
rotpic_yp	equ	72
rotpic_x	equ	88
		endc
		ifd	bit4
rotpic_y	equ	192
rotpic_yp	equ	48
rotpic_x	equ	48
		endc
		ifd	bit8
rotpic_y	equ	288
rotpic_yp	equ	36
rotpic_x	equ	48
		endc

;	Input:
;	a0=variabelen tabel
;	d0=routinfo

;	Output:
;	a0=picture
;	d1=copperlist

	ifd	routp

	SECTION	5,CODE

	cnop	0,8
rot
rotp
	ifnd	ocs
	dc.l	'ROTA'			;new chip/public format
	endc
	ifd	ocs
	dc.l	'ROTO'			;new chip/public format
	endc

	movem.l	d2-d7/a1-a6,-(sp)

	lea	($dff000).l,a6		;hardware
	lea	rot(pc),a5		;prog base
	move.l	a2,rotchppos-rot(a5)	;chipmem data
		
	ifd	bit8
	sub.l	a1,a1
	clr.l	d1
	tst.w	d0
	beq	rot.c
	move.l	rotchppos-rot(a5),a1
	add.l	#rotpicemp-rotchp,a1
rot.c	
	move.l	a1,rotpicvew-rot(a5)
	endc
	
	move.l	#64,d2
	bsr	getd7

;rot.ea	
;	move.l	#4,d2			;routine
;	bsr	getd7
;	muls	#1380,d7
;	move.l	d7,variabele1-rot(a5)
;	move.l	#1,d2			;breedte
;	bsr	getd7
;	muls	#6,d7
;	move.l	d7,variabele7-rot(a5)

rot.end
	ifd	calc
	tst.b	rotcalcmode
	bne	rot.calcready
	endc
	bsr	rotint			;eventueel init
	ifd	calc
	bsr	rotcal
	endc
rot.calcready

	move.l	var_cprbck(a0),d1
	sub.l	#8,d1
	move.l	rotchppos-rot(a5),a1
	add.l	#rotcop1-rotchp,a1	;copperjump adres zetten
	move.l	rotbuf-rot(a5),d2	;double buffer
	add.l	d2,a1
	move.w	d1,6(a1)
	swap	d1
	move.w	d1,2(a1)

	ifd	bit8
	move.l	a1,a2
	add.l	#rotcprbck1ntsc,a2
	move.l	a1,a3
	add.l	#rotcprend1ntsc,a3
	move.l	a1,a4
	add.l	#rotcprbck1,a4

;rotcprbck1		equ	(rotcoptus_l*(rotpic_y-124))+8
;rotcprbck1ntsc		equ	(rotcoptus_l*(rotpic_y-180))+8
;rotcprend1ntsc		equ	(rotcoptus_l*(rotpic_y-60))+8

cop_str			equ	$18
rotcprbck1_v		equ	(cop_str+rotpic_y-124)*$1000000+$29fffe
rotcprbck1ntsc_v	equ	(cop_str+rotpic_y-180)*$1000000+$29fffe
rotcprend1ntsc_v	equ	(cop_str+rotpic_y-60)*$1000000+$29fffe

	cmp.b	#50,var_ntsc(a0)	;ntsc/pal frequence
	bne	rot.ntsc
	move.l	#rotcprbck1ntsc_v,(a2)	;reset ntsc split (cprbck1ntsc)
	move.l	#rotcprend1ntsc_v,(a3)	;reset ntsc end (cprend1ntsc)
	add.l	#rotcprbck1,a1
	move.l	#rotcprbck1_v,d3	;pal split (cprbck1)
	bra	rot.split
rot.ntsc
	move.l	#rotcprbck1_v,(a4)	;reset pal split (cprbck1)
	move.l	#$00880000,(a3)		;set ntsc end (cprend1ntsc)
	add.l	#rotcprbck1ntsc,a1
	move.l	#rotcprbck1ntsc_v,d3	;(cprbck1ntsc)
rot.split
	move.l	#$00880000,(a1)		;set break
	move.l	var_cprbck(a0),a2
	cmp.b	#$ff,(a2)		;menu uit ?
	bne	rot.a
	move.l	d3,(a1)
rot.a
	endc

	ifd	bit3aga
	move.l	a1,a2
	add.l	#rotcprbck1ntsc,a2
	move.l	a1,a3
	add.l	#rotcprend1ntsc,a3
	move.l	a1,a4
	add.l	#rotcprbck1,a4

cop_str			equ	$17;$24
rotcprbck1_v		equ	(cop_str+rotpic_y-124)*$1000000+$01fffe
rotcprbck1ntsc_v	equ	(cop_str+rotpic_y-172)*$1000000+$01fffe
rotcprend1ntsc_v	equ	(cop_str+rotpic_y-60)*$1000000+$01fffe

rotcprbck1_vn		equ	(cop_str-2+rotpic_y-124)*$1000000+$01fffe
rotcprbck1ntsc_vn	equ	(cop_str-2+rotpic_y-172)*$1000000+$01fffe

;	cmp.b	#50,var_ntsc(a0)	;ntsc/pal frequence
;	bne	rot.ntsc
;	move.l	#rotcprbck1ntsc_v,(a2)	;reset ntsc split (cprbck1ntsc)
;	move.l	#rotcprend1ntsc_v,(a3)	;reset ntsc end (cprend1ntsc)
;	add.l	#rotcprbck1,a1
;	move.l	#rotcprbck1_v,d3	;pal split (cprbck1)
;	bra	rot.split
;rot.ntsc
;	move.l	#rotcprbck1_vn,(a4)	;reset pal split (cprbck1)
;	move.l	#$00880000,(a3)		;set ntsc end (cprend1ntsc)
;	add.l	#rotcprbck1ntsc,a1
;	move.l	#rotcprbck1ntsc_vn,d3	;(cprbck1ntsc)
;rot.split
;	move.l	#$00880000,(a1)		;set break
;	move.l	var_cprbck(a0),a2
;	cmp.b	#$ff,(a2)		;menu uit ?
;	bne	rot.a
;	move.l	d3,(a1)
;rot.a
	endc

	ifd	bit4aga
	move.l	a1,a2
	add.l	#rotcprbck1ntsc,a2
	move.l	a1,a3
	add.l	#rotcprend1ntsc,a3
	move.l	a1,a4
	add.l	#rotcprbck1,a4

cop_str			equ	$17
rotcprbck1_v		equ	(cop_str+rotpic_y-124)*$1000000+$01fffe
rotcprbck1ntsc_v	equ	(cop_str+rotpic_y-172)*$1000000+$01fffe
rotcprend1ntsc_v	equ	(cop_str+rotpic_y-60)*$1000000+$01fffe

rotcprbck1_vn		equ	(cop_str-2+rotpic_y-124)*$1000000+$01fffe
rotcprbck1ntsc_vn	equ	(cop_str-2+rotpic_y-172)*$1000000+$01fffe

	cmp.b	#50,var_ntsc(a0)	;ntsc/pal frequence
	bne	rot.ntsc
	move.l	#rotcprbck1ntsc_v,(a2)	;reset ntsc split (cprbck1ntsc)
	move.l	#rotcprend1ntsc_v,(a3)	;reset ntsc end (cprend1ntsc)
	add.l	#rotcprbck1,a1
	move.l	#rotcprbck1_v,d3	;pal split (cprbck1)
	bra	rot.split
rot.ntsc
	move.l	#rotcprbck1_vn,(a4)	;reset pal split (cprbck1)
	move.l	#$00880000,(a3)		;set ntsc end (cprend1ntsc)
	add.l	#rotcprbck1ntsc,a1
	move.l	#rotcprbck1ntsc_vn,d3	;(cprbck1ntsc)
rot.split
	move.l	#$00880000,(a1)		;set break
	move.l	var_cprbck(a0),a2
	cmp.b	#$ff,(a2)		;menu uit ?
	bne	rot.a
	move.l	d3,(a1)
rot.a
	endc

	ifd	bit4

;rotcprbck1		equ	(rotcoptus_l*(rotpic_y-78))+8
;rotcprbck1ntsc		equ	(rotcoptus_l*(rotpic_y-106))+8

cop_str			equ	$4a
rotcprbck1_v		equ	(cop_str+rotpic_y-78)*$1000000+$c9fffe
rotcprbck1ntsc_v	equ	(cop_str+rotpic_y-106)*$1000000+$c9fffe
rotcprbck1_vn		equ	(cop_str-28+rotpic_y-78)*$1000000+$c9fffe
rotcprbck1ntsc_vn	equ	(cop_str-28+rotpic_y-106)*$1000000+$c9fffe


	move.l	a1,a2
	add.l	#rotcprbck1ntsc,a2
	move.l	a1,a4
	add.l	#rotcprbck1,a4

	cmp.b	#50,var_ntsc(a0)	;ntsc/pal frequence
	bne	rot.ntsc
	move.l	#rotcprbck1ntsc_v,(a2)	;reset ntsc split (cprbck1ntsc)
	add.l	#rotcprbck1,a1
	move.l	#rotcprbck1_v,d3	;pal split (cprbck1)
	bra	rot.split
rot.ntsc
	move.l	#rotcprbck1_vn,(a4)	;reset pal split (cprbck1)
	add.l	#rotcprbck1ntsc,a1
	move.l	#rotcprbck1ntsc_vn,d3	;(cprbck1ntsc)
rot.split
	move.l	#$00880000,(a1)		;set break
	move.l	var_cprbck(a0),a2
	cmp.b	#$ff,(a2)		;menu uit ?
	bne	rot.a
	move.l	d3,(a1)
rot.a
	endc
	
	cmp.w	#16,d0
	bge	rot.tunnel
	bsr	rotlop			;magnify+rotate
	bra	rot.verder
rot.tunnel
	ifnd	calc
	sub.w	#16,d0
	lea	rotaddtab(pc),a0
	lsl.l	#2,d0
	move.l	(a0,d0),rotadd-rot(a5)
	bsr	rotvew
	endc
rot.verder

	move.l	rotchppos-rot(a5),a0
	add.l	#rotcop1-rotchp,a0
	move.l	rotbuf-rot(a5),d1
	add.l	a0,d1
	eor.l	#rotcop_l,rotbuf-rot(a5)

	ifd	bit8
	move.l	rotpicvew-rot(a5),a0
	endc
	
	ifnd	bit8
	move.l	rotchppos-rot(a5),a0
	add.l	#rotpic-rotchp,a0
	endc

	ifd	calc
	lea	rotpic3,a0		;picture
	endc
	movem.l	(sp)+,d2-d7/a1-a6
	rts

getd7
	move.w	d0,d1
	divs	d2,d1
	and.l	#$ffff,d1
	move.l	d1,d7
	muls	d2,d1
	sub.w	d1,d0
	move.l	d0,d6
	add.l	#1,d7
	rts

rotint
	movem.l	d0-d7/a0-a6,-(sp)

	move.l	rotchppos-rot(a5),a2
	add.l	#rotcoptus.s-rotchp,a2

	ifnd	bit8
	move.l	rotcopstr-rot(a5),d0		;pal start
	cmp.b	#50,var_ntsc(a0)		;ntsc/pal frequence
	bne	rotint.ntsc
	move.l	#cop_str,rotcopstr-rot(a5)	;pal start
	bra	rotint.split
rotint.ntsc
	ifd	bit4
	move.l	#cop_str-28,rotcopstr-rot(a5)	;ntsc start
	endc
	ifd	bit3aga
	move.l	#cop_str-2,rotcopstr-rot(a5)	;ntsc start
	endc
	ifd	bit4aga
	move.l	#cop_str-2,rotcopstr-rot(a5)	;ntsc start
	endc
rotint.split
	cmp.l	rotcopstr-rot(a5),d0		;veranderd ?
	bne	rotint.changed
	endc

	tst.b	(a2)				;already filled ?
	bne	rotint.nocop

rotint.changed
	move.l	rotcopstr-rot(a5),d1	;copper y position
	
	ifnd	bitaga
	move.w	#rotpic_y-1,d0		;number of copperlines
	endc
	ifd	bit3aga
	move.w	#rotpic_y/3-1,d0	;number of copperlines
	endc
	ifd	bit4aga
	move.w	#rotpic_y/4-1,d0	;number of copperlines
	endc
rotint.a
	move.b	d1,(a2)

	ifnd	bitaga
	add.w	#1,d1
	endc
	ifd	bit3aga
	add.w	#2,d1
;	move.b	d1,rotcoptus_l-4(a2)
	add.w	#1,d1
	endc
	ifd	bit4aga
	add.w	#3,d1
;	move.b	d1,rotcoptus_l-4(a2)
	add.w	#1,d1
	endc

	add.l	#rotcoptus_l,a2
	dbra	d0,rotint.a
	
	move.l	rotchppos-rot(a5),a2
	add.l	#rotcop1-rotchp,a2	;copy copper1 to copper2
	move.l	a2,a1
	add.l	#rotcop_l,a1
	move.w	#rotcop_l/4-1,d0
rotint.bb
	move.l	(a2)+,(a1)+
	dbra	d0,rotint.bb

rotint.nocop
	move.l	var_pic1(a0),a1		;picture
	cmp.l	#0,a1			;empty ?
	beq	rotint.nopic

	cmp.l	rotbck-rot(a5),a1	;already on screen ?
	beq	rotint.nopic

	move.w	pic_vew(a1),d0
	btst	#11,d0			;hold and modify ?
	beq	rotint.nopic

	clr.l	d0
	move.w	pic_wid(a1),d0		;get width
	ifnd	ocs
	sub.l	pic_widmod(a1),d0	;animation-width modulo
	endc
	lsl.l	#3,d0			;*8 for pixelnumber

	cmp.w	#320,d0			;bigger than buffer ?
	bge	rotint.mod
	sub.w	#16,d0
	clr.l	rotcen-rot(a5)		;modulo wissen
	cmp.w	#rotcol_x,d0		;bigger than buffer ?
	bgt	rotint.nopic
	bra	rotint.nomod
rotint.mod
	move.l	d0,d1
	move.w	#rotcol_x,d0
	sub.w	#rotcol_x,d1
	lsr.l	#1+3,d1
	move.l	d1,rotcen-rot(a5)	;modulo
rotint.nomod

	clr.l	d1
	move.w	pic_hgt(a1),d1		;heigth
	cmp.w	#rotcol_y,d1		;bigger than buffer ?
	bgt	rotint.nopic
	muls	d1,d0			;* heigth
	lsl.l	#1,d0			;*2 for words

	cmp.l	#rotcol_l,d0		;bigger than buffer ?
	bgt	rotint.nopic

	move.l	a1,rotbck-rot(a5)

	move.l	a5,a4
	add.l	#rotcol-rot,a4		;start colorbuffer
	
	clr.l	d0
	move.w	pic_wid(a1),d0		;get width
	
	lea	pic_raw(a1),a2		;start raw planes

	clr.l	d3			;colorvalue
	clr.l	d1			;y start position
rotint.f
	add.l	rotcen-rot(a5),a2	;modulo
	clr.l	d6			;x start position
rotint.d

	move.l	#8-1,d7			;read bits of 1 byte
rotint.c
	clr.l	d4			;colorbits
	clr.l	d5			;colorinfo

	btst	d7,(a2)			;get colorbits
	beq	rotint.c0	
	bset	#0,d4
rotint.c0	
	add.l	d0,a2
	btst	d7,(a2)
	beq	rotint.c1	
	bset	#1,d4
rotint.c1	
	add.l	d0,a2
	btst	d7,(a2)
	beq	rotint.c2
	bset	#2,d4
rotint.c2
	add.l	d0,a2
	btst	d7,(a2)
	beq	rotint.c3
	bset	#3,d4
rotint.c3

	add.l	d0,a2			;get colorinfo
	btst	d7,(a2)
	beq	rotint.c4
	bset	#0,d5
rotint.c4
	add.l	d0,a2
	btst	d7,(a2)
	beq	rotint.c5
	bset	#1,d5
rotint.c5

	rept	5
	sub.l	d0,a2
	endr

	tst.b	d5			;true color ?
	bne	rotint.c00
	lea	pic_pal(a1),a3		;palette
	ifnd	ocs
	lsl.l	#2,d4
	endc
	ifd	ocs
	lsl.l	#1,d4
	endc
	move.w	(a3,d4),d3
	bra	rotint.e
rotint.c00
	cmp.b	#1,d5			;blue bits ?
	bne	rotint.c01
	and.w	#$ff0,d3		;remove old bits
	or.w	d4,d3			;set new bits
	bra	rotint.e
rotint.c01
	cmp.b	#2,d5			;red bits ?
	bne	rotint.c02
	and.w	#$0ff,d3		;remove old bits
	lsl.w	#8,d4
	or.w	d4,d3			;set new bits
	bra	rotint.e
rotint.c02
	cmp.b	#3,d5			;green bits ?
	bne	rotint.c03
	and.w	#$f0f,d3		;remove old bits
	lsl.w	#4,d4
	or.w	d4,d3			;set new bits
	bra	rotint.e
rotint.c03

rotint.e
	move.l	d1,d5			;y pos
	muls	#rotcol_x*2,d5
;	lsl.l	#8,d5			;*256 (width)
;	lsl.l	#1,d5			;make words

	move.l	d6,d4			;x byte pos	
	lsl.l	#3,d4			;make pixels
	add.l	#7,d4			;x bit pos
	sub.l	d7,d4
	lsl.l	#1,d4			;make words

rotint.g
	clr.l	d2
	move.w	pic_wid(a1),d2
	tst.l	rotcen-rot(a5)		;modulo
	bne	rotint.skip2
	sub.l	#2,d2			;dpaint ?
rotint.skip2	
	ifnd	ocs
	sub.l	pic_widmod(a1),d2	;animation-width modulo
	endc
	lsl.l	#4,d2			;make pixels and words
	
	move.l	d4,-(sp)
rotint.eb
	move.l	a4,a6
	add.l	d5,a6			;x,y start
	add.l	d4,a6			;x add
	move.w	d3,(a6)
	add.l	d2,d4
	cmp.l	#rotcol_x*2,d4		;reached border ?
	blt	rotint.eb
	move.l	(sp)+,d4

	clr.l	d2
	move.w	pic_hgt(a1),d2
	muls	#rotcol_x*2,d2
;	lsl.l	#8,d2			;* total width (256)
;	lsl.l	#1,d2			;make words

	add.l	d2,d5
	cmp.l	#rotcol_l,d5		;reached border ?
	blt	rotint.g

rotint.ge
	dbra	d7,rotint.c

	add.l	#1,a2			;next byte

	add.l	#1,d6
	clr.l	d2
	move.w	pic_wid(a1),d2
	sub.l	rotcen-rot(a5),d2
	sub.l	rotcen-rot(a5),d2
	ifnd	ocs
	sub.l	pic_widmod(a1),d2	;animation-width modulo
	endc
	tst.l	rotcen-rot(a5)		;modulo
	bne	rotint.skip3
	sub.l	#2,d2			;dpaint ?
rotint.skip3
	cmp.l	d2,d6
	bne	rotint.d

	ifnd	ocs
	add.l	pic_widmod(a1),a2	;animation-width modulo
	endc
	tst.l	rotcen-rot(a5)		;modulo
	bne	rotint.skip4
	add.l	#2,a2			;dpaint ?
rotint.skip4

	rept	5
	add.l	d0,a2
	endr

	add.l	rotcen-rot(a5),a2	;modulo

	add.l	#1,d1
	cmp.w	pic_hgt(a1),d1		;y-end reached ?
	bne	rotint.f

	move.l	a5,a0
	add.l	#rotcol-rot,a0
	move.l	a0,a1
	move.l	a0,a3
	add.l	#rotcol.e-rotcol,a1
	sub.l	#rotcol.e-rotcol,a3
	move.l	a1,a2
rotint.copy
	move.l	(a0)+,(a1)+
	move.l	-4(a0),(a3)+
	cmp.l	a0,a2
	bne	rotint.copy
	
rotint.nopic

rotint.end	
	movem.l	(sp)+,d0-d7/a0-a6
	rts

rotlop
	movem.l	d0-d7/a0-a6,-(sp)

	tst.l	rotbck-rot(a5)		;picture available ?
	beq	rotlop.end

	move.l	rotchppos-rot(a5),a1
	add.l	#rotcoptus.s-rotchp,a1	;get copperlist
	move.l	rotbuf-rot(a5),d1
	add.l	d1,a1
	
	move.l	a5,a4			;get colortable
	add.l	#rotcol-rot,a4

	move.l	#rotcol_x,d0		;x centre
	move.l	d0,d1
	move.l	rotmag-rot(a5),d4
	muls	#rotpic_x,d4
	divs	#rotcol_x,d4
	ext.l	d4
	sub.l	d4,d0
	and.b	#$fe,d0
	add.l	d0,a4			;(words)

;	move.l	#rotcol_y*2,d0		;y centre
	move.l	#rotcol_y,d0		;y centre
	sub.l	d4,d0
	lsr.l	#1,d0			;/2
	muls	d1,d0			;*width
	lsl.l	#1,d0			;words
	add.l	d0,a4			;(words)

	move.l	rotmag-rot(a5),a3	;x-magnify add
	move.l	rotrot-rot(a5),a0	;x-rotation add
	move.l	a4,a2

	clr.l	d1			;y-pos magnify
	clr.l	d0			;y-pos rotate

	move.w	#rotpic_yp-1,d7
rotlop.a
	moveq.w	#0,d3			;x-pos magnify
	moveq.w	#0,d2			;x-pos rotate

	ifd	bit3aga

	move.w	#31-1,d6
rotlop.a1
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 3 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a1

	add.l	#4,a1
	
	move.w	#32-1,d6
rotlop.a2
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 2 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a2

	add.l	#4,a1
	
	move.w	#32-1,d6
rotlop.a3
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 2 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a3

	add.l	#4,a1
	
	move.w	#22-1,d6
rotlop.a4
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 2 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a4
	endc
	
	ifd	bit4aga

	move.w	#31-1,d6
rotlop.a1
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 2 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a1

	add.l	#4,a1
	
	move.w	#32-1,d6
rotlop.a2
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 2 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a2

	add.l	#4,a1
	
	move.w	#25-1,d6
rotlop.a3
	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,14(a1)		;fill 2 copperrows
	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1
	dbra	d6,rotlop.a3
	endc
	
	ifnd	bitaga
	rept	rotpic_x		;x-repeat

	move.w	d2,d5
	clr.b	d5
	lsl.w	#1,d5
	move.w	d3,d4
	lsr.w	#8,d4			;/256
	lsl.w	#1,d4			;words
	add.w	d5,d4
	move.w	(a4,d4),d4
	move.w	d4,6(a1)		;fill 4 copperrows
	move.w	d4,rotcoptus_l+6(a1)
	move.w	d4,2*rotcoptus_l+6(a1)
	move.w	d4,3*rotcoptus_l+6(a1)

	ifd	bit8
	move.w	d4,4*rotcoptus_l+6(a1)
	move.w	d4,5*rotcoptus_l+6(a1)
	move.w	d4,6*rotcoptus_l+6(a1)
	move.w	d4,7*rotcoptus_l+6(a1)
	endc

	add.w	a0,d2			;x-rotation add
	add.w	a3,d3			;x-magnify add
	lea	4(a1),a1

	endr				;end x-repeat
	endc
	
	ifd	bit3aga
;	add.l	#43*4,a1		;next 4 copperlines
	add.l	#3*4,a1			;next 4 copperlines
	endc
	ifd	bit4aga
	add.l	#10*4,a1		;next 4 copperlines
	endc
	ifd	bit4
	add.l	#rotcoptus_l*3+4,a1	;next 4 copperlines
	endc
	ifd	bit8
	add.l	#rotcoptus_l*7+4,a1	;next 8 copperlines
	endc
	
	add.l	rotrot-rot(a5),d0	;y-rotate add
	move.l	d0,d6
	lsr.l	#8,d6			;/256
	lsl.l	#1,d6			;words

	add.l	rotmag-rot(a5),d1	;y-magnify add
	move.l	d1,d5
	clr.b	d5
;	lsl.l	#2,d5
	lsl.l	#1,d5

	sub.l	d6,d5			;-rotate

	move.l	a2,a4
	add.l	d5,a4
	dbra	d7,rotlop.a

rotlop.ca
	move.l	rotmagpos-rot(a5),d0
	move.l	rotmagway-rot(a5),d1
	add.l	d1,d0
	cmp.l	#rotmagtab_l,d0
	blt	rotlop.cc
	neg.l	rotmagway-rot(a5)
	bra	rotlop.ca
rotlop.cc
	cmp.l	#0,d0
	bge	rotlop.cb
	neg.l	rotmagway-rot(a5)
	bra	rotlop.ca
rotlop.cb
	move.l	d0,rotmagpos-rot(a5)

	lea	rotmagtab(pc),a1
	move.w	(a1,d0),d0
	ext.l	d0
	move.l	d0,rotmag-rot(a5)


rotlop.ca2
	move.l	rotrotpos-rot(a5),d0
	move.l	rotrotway-rot(a5),d1
	add.l	d1,d0
	cmp.l	#rotrottab_l,d0
	blt	rotlop.cc2
	neg.l	rotrotway-rot(a5)
	bra	rotlop.ca2
rotlop.cc2
	cmp.l	#0,d0
	bge	rotlop.cb2
	neg.l	rotrotway-rot(a5)
	bra	rotlop.ca2
rotlop.cb2
	move.l	d0,rotrotpos-rot(a5)

	lea	rotrottab(pc),a1
	move.w	(a1,d0),d0
	ext.l	d0
	move.l	d0,rotrot-rot(a5)


rotlop.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts


	ifd	calc
rotcal					;calculate tunnel
	movem.l	d0-d7/a0-a6,-(sp)

	move.l	#32767-7000,d3		;size
rotcal.f
	move.l	a5,a3
	add.l	#rotcol-rot,a3
rotcal.d
	move.w	#((32767-7000)/256)/(15+2)-1,d6	;sinus pixel heigth
rotcal.c
	btst	#6,($bfe001).l
	beq	rotcal.end
	move.w	d6,$dff180

	lea	rotsin,a0
	move.l	a3,a1
	move.w	#rottun_wid-2,d0	;tunnel picture width
rotcal.a
	move.w	(a1)+,d1		;get color
	
	move.w	#4-1,d7			;sinus pixel width
rotcal.e

	clr.l	d2
	move.w	(a0)+,d2		;get sinus
	ext.l	d2
	divs.l	d3,d2
	ext.l	d2			;x

	cmp.l	#rotpic_wid*4,d2	;out of border ?
	bge	rotcal.not
	cmp.l	#-rotpic_wid*4,d2
	blt	rotcal.not
	
	move.l	a5,a4
	add.l	#rotoff-rot,a4
	move.l	d2,d5
	add.l	#rotpic_wid*4,d5
	lsl.l	#2,d5			;longwords
	add.l	d5,a4
		
	add.l	#rotpic_wid*4,d2

	lea	rotpic3+pic_raw,a2
	move.l	d2,d4
	lsr.l	#3,d4
	add.l	d4,a2
	lsl.l	#3,d4
	eor.b	#7,d2
	sub.l	d4,d2
					
	clr.l	d4
	move.w	(((rotsin_l/4)/2)*2)-2(a0),d4	;get cos
	ext.l	d4
	divs.l	d3,d4
	ext.l	d4			;y

	cmp.l	#rotpic_hgt/2,d4	;out of border ?
	bge	rotcal.not
	cmp.l	#-rotpic_hgt/2,d4
	blt	rotcal.not
	
	move.l	d4,d5
	add.l	#rotpic_hgt/2,d5
	muls	#rotpic_wid*8*4,d5	;longwords
	add.l	d5,a4

	move.l	a1,a6			;current picture position
	sub.l	a5,a6			;-rot
	sub.l	#rotcol-rot,a6		;-rotcol
	move.l	a6,(a4)			;offset table
		
	add.l	#rotpic_hgt/2,d4
	muls	#rotpic_wid*rotpic_dpt,d4
	add.l	d4,a2
	
	bset	d2,(a2)

rotcal.not
	dbra	d7,rotcal.e		;next sinus-position
	
	dbra	d0,rotcal.a		;next x-pixel

	sub.l	#1*(15+2),d3
	cmp.l	#0,d3
	ble	rotcal.end
	dbra	d6,rotcal.c		;next sinus-size

	add.l	#rottun_wid*2,a3	;next tunnelpicture y-row
	move.l	a3,d0
	sub.l	#rotcol,d0
	cmp.l	#rottun_hgt*rottun_wid*2,d0
	bne	rotcal.d
	bra	rotcal.f
rotcal.end
	move.b	#1,rotcalcmode

	lea	rotoff,a0
	move.w	#rotpic_hgt-1,d3
rotcal.fixlop
	move.l	a0,a3
rotcal.findfilled
	tst.l	(a3)+
	beq	rotcal.findfilled
	move.l	-4(a3),d0

	move.w	#rotpic_wid*8-1,d2
rotcal.fixlop2
	move.l	(a0)+,d1
	tst.l	d1
	bne	rotcal.nofix
	move.l	d0,-4(a0)
	bra	rotcal.nextfix
rotcal.nofix
	move.l	d1,d0
rotcal.nextfix
	dbra	d2,rotcal.fixlop2
	dbra	d3,rotcal.fixlop

	movem.l	(sp)+,d0-d7/a0-a6
	rts
	endc
	

rotvew					;show tunnel on screen
	movem.l	d0-d7/a0-a6,-(sp)

	move.l	rotchppos-rot(a5),a1
	add.l	#rotcoptus.s-rotchp,a1	;get copperlist
	move.l	rotbuf-rot(a5),d1
	add.l	d1,a1
	
	move.l	a5,a0
	add.l	#rotoff-rot,a0		;tunnel data
	ifd	bit3aga
	add.l	#4,a0
	endc

	move.l	a5,a6
	add.l	#rotcol.e-rot,a6	;tunnel picture

rotvew.e1
	move.l	rotpos-rot(a5),d4

	move.l	rotadd-rot(a5),d1
	add.l	d1,d4

	cmp.l	#rottun_hgt*rottun_wid*2,d4
	blt.s	rotvew.e
	sub.l	#rottun_hgt*rottun_wid*2,d4
rotvew.e	
	cmp.l	#0,d4
	bge.s	rotvew.e2
	add.l	#rottun_hgt*rottun_wid*2,d4
rotvew.e2
	move.l	d4,rotpos-rot(a5)
	sub.l	d4,a6

	move.w	#rotpic_yp-1,d6
rotvew.d

	ifd	bit3aga

	move.w	#31-1,d7
rotvew.a1
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a1

	add.l	#4,a1
	
	move.w	#32-1,d7
rotvew.a2
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a2

	add.l	#4,a1
	
	move.w	#32-1,d7
rotvew.a3
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a3

	add.l	#4,a1
	
	move.w	#22-1,d7
rotvew.a4
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a4

	add.l	#3*4,a0		;pixels overslaan
	add.l	#3*4,a1		;next 3 copperlines
	endc
	
	ifd	bit4aga

	move.w	#31-1,d7
rotvew.a1
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a1

	add.l	#4,a1
	
	move.w	#32-1,d7
rotvew.a2
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a2

	add.l	#4,a1
	
	move.w	#25-1,d7
rotvew.a3
	move.l	(a0)+,a2		;offset
	add.l	a6,a2			;rotcol
	move.w	(a2),14(a1)		;in copper
	lea	4(a1),a1
	dbra	d7,rotvew.a3

	add.l	#10*4,a1		;next 3 copperlines
	endc
	
	dbra	d6,rotvew.d
	
			
rotvew.end
	movem.l	(sp)+,d0-d7/a0-a6
	rts

rotchppos	dc.l	0
rotcen		dc.l	0
rotbuf		dc.l	0
rotbck		dc.l	0
rotpos		dc.l	0
rotadd		dc.l	0

rotpicvew	dc.l	0
rotmag		dc.l	0
rotmagpos	dc.l	0
rotmagway	dc.l	4
rotrot		dc.l	0
rotrotpos	dc.l	0
rotrotway	dc.l	18

rotcopstr	dc.l	cop_str
		


rotaddtab
	dc.l	rottun_wid*2		;erin
	dc.l	(rottun_wid*2)+2	;links erin
	dc.l	(rottun_wid*2)-2	;rechts erin
	dc.l	-(rottun_wid*2)		;eruit
	dc.l	-(rottun_wid*2)-2	;links eruit
	dc.l	-(rottun_wid*2)+2	;rechts eruit
	dc.l	(rottun_wid*2)+4	;links snel erin
	dc.l	(rottun_wid*2)-4	;rechts snel erin
	dc.l	-(rottun_wid*2)-4	;links snel eruit
	dc.l	-(rottun_wid*2)+4	;rechts snel eruit
	dc.l	0
	dc.l	rottun_wid*4		;erin
	dc.l	(rottun_wid*4)+2	;links erin
	dc.l	(rottun_wid*4)-2	;rechts erin
	dc.l	-(rottun_wid*4)		;eruit
	dc.l	-(rottun_wid*4)-2	;links eruit
	dc.l	-(rottun_wid*4)+2	;rechts eruit
	dc.l	(rottun_wid*4)+4	;links snel erin
	dc.l	(rottun_wid*4)-4	;rechts snel erin
	dc.l	-(rottun_wid*4)-4	;links snel eruit
	dc.l	-(rottun_wid*4)+4	;rechts snel eruit

	dc.l	rottun_wid*70+70	;psycho !!!

	ds.l	26

;rotoff_l	equ	rotoff.e-rotoff

;rotcol		ds.b	rottun_hgt*rottun_wid
;rotcol.e
;		ds.b	rottun_hgt*rottun_wid
;rotcol_l	equ	rotcol.e-rotcol

		cnop	0,8
		
rotmagtab
	ifd	bitaga
       dc.w       1100,1081,1062,1042,1023,1004,985,966,947,928,909,890
       dc.w       871,853,834,815,797,778,760,742,724,706,688,670
       dc.w       653,635,618,601,584,567,550,533,517,501,485,469
       dc.w       453,438,423,408,393

       dc.w	378,364,350,336,322,309,296
       dc.w       283,270,257,245,233,222,210,199,188,177,167,157
       dc.w       147,138,129,120,111,103,95,87,80,73,66,60
       dc.w       54,48,43,37,33,28,24,20,17,14,11,8
       dc.w       6,4,3,2,1,0,0
       dc.w       0,0,0,0,-1,-2,-2,-4,-5,-6,-8,-9
       dc.w       -11,-13,-16,-18,-20,-23,-26,-29,-32,-36,-39,-43
       dc.w       -46,-50,-55,-59,-63,-68,-73,-77,-82,-88,-93,-99
       dc.w       -104,-110,-116,-122,-128,-135,-141,-148,-155,-162,-169,-176
       dc.w       -183,-191,-198,-206,-214,-222,-230,-239,-247,-256,-264,-273
       dc.w       -282,-291,-300,-310,-319,-328,-338,-348,-358,-368,-378,-388
       dc.w       -398,-409,-419,-430,-441,-451
       dc.w	-462,-473,-484,-496

       dc.w	-507,-518
       dc.w       -530,-541,-553,-565,-576,-588,-600,-612,-624,-636,-649,-661
       dc.w       -673,-686,-698,-711,-723,-736,-749,-761,-774,-787,-800,-813
       dc.w       -826,-839,-852,-865,-878,-891,-905,-918,-931,-945,-958,-971
       dc.w       -985,-998,-1011,-1025,-1038,-1052,-1065,-1078,-1092
	endc
	
	ifnd	bitaga
       dc.w       1100,1081,1062,1042,1023,1004,985,966,947,928,909,890
       dc.w       871,853,834,815,797,778,760,742,724,706,688,670
       dc.w       653,635,618,601,584,567,550,533,517,501,485,469
       dc.w       453,438,423,408,393,378,364,350,336,322,309,296
       dc.w       283,270,257,245,233,222,210,199,188,177,167,157
       dc.w       147,138,129,120,111,103,95,87,80,73,66,60
       dc.w       54,48,43,37,33,28,24,20,17,14,11,8
       dc.w       6,4,3,2,1,0,0
       dc.w       0,0,0,0,-1,-2,-2,-4,-5,-6,-8,-9
       dc.w       -11,-13,-16,-18,-20,-23,-26,-29,-32,-36,-39,-43
       dc.w       -46,-50,-55,-59,-63,-68,-73,-77,-82,-88,-93,-99
       dc.w       -104,-110,-116,-122,-128,-135,-141,-148,-155,-162,-169,-176
       dc.w       -183,-191,-198,-206,-214,-222,-230,-239,-247,-256,-264,-273
       dc.w       -282,-291,-300,-310,-319,-328,-338,-348,-358,-368,-378,-388
       dc.w       -398,-409,-419,-430,-441,-451,-462,-473,-484,-496,-507,-518
       dc.w       -530,-541,-553,-565,-576,-588,-600,-612,-624,-636,-649,-661
       dc.w       -673,-686,-698,-711,-723,-736,-749,-761,-774,-787,-800,-813
       dc.w       -826,-839,-852,-865,-878,-891,-905,-918,-931,-945,-958,-971
       dc.w       -985,-998,-1011,-1025,-1038,-1052,-1065,-1078,-1092
	endc
	
rotmagtab.e
rotmagtab_l	equ	rotmagtab.e-rotmagtab

rotrottab
       dc.w       128,128,128,128,128,128,128,128,127,127,127,127
       dc.w       127,126,126,126,126,125,125,125,124,124,123,123
       dc.w       123,122,122,121,121,120,119,119,118,118,117,116
       dc.w       116,115,114,114,113,112,112,111,110,109,108,107
       dc.w       107,106,105,104,103,102,101,100,99,98,97,96
       dc.w       95,94,93,92,91,90,89,87,86,85,84,83
       dc.w       82,80,79,78,77,75,74,73,72,70,69,68
       dc.w       66,65,64,62,61,60,58,57,55,54,52,51
       dc.w       50,48,47,45,44,42,41,39,38,36,35,33
       dc.w       32,30,29,27,26,24,23,21,20,18,16,15
       dc.w       13,12,10,9,7,6,4,2,1,0,-2,-3
       dc.w       -5,-6,-8,-10,-11,-13,-14,-16,-17,-19,-20,-22
       dc.w       -23,-25,-27,-28,-30,-31,-33,-34,-36,-37,-39,-40
       dc.w       -42,-43,-45,-46,-47,-49,-50,-52,-53,-55,-56,-57
       dc.w       -59,-60,-62,-63,-64,-66,-67,-68,-70,-71,-72,-73
       dc.w       -75,-76,-77,-78,-80,-81,-82,-83,-84,-86,-87,-88
       dc.w       -89,-90,-91,-92,-93,-94,-96,-97,-98,-99,-100,-101
       dc.w       -101,-102,-103,-104,-105,-106,-107,-108,-109,-109,-110,-111
       dc.w       -112,-112,-113,-114,-115,-115,-116,-117,-117,-118,-118,-119
       dc.w       -119,-120,-121,-121,-122,-122,-122,-123,-123,-124,-124,-124
       dc.w       -125,-125,-125,-126,-126,-126,-126,-127,-127,-127,-127,-127
       dc.w       -127,-127,-127,-127,-127,-127

rotrottab.e
rotrottab_l	equ	rotrottab.e-rotrottab


rotcol_x	equ	256
rotcol_y	equ	256

rotoff
		ifd	calc
		ds.l	rotpic_wid*8*rotpic_hgt
		endc
		ifnd	calc
		ifd	bit4aga
		incbin	'w:binaga/tun3.bin'
		endc
		ifd	bit3aga
		incbin	'w:binaga/tun4.bin'
		endc
		cnop	0,2
		endc
rotoff.e


		ds.w	rotcol_x*rotcol_y
rotcol		ds.w	rotcol_x*rotcol_y
rotcol.e
		ds.w	rotcol_x*rotcol_y
rotcol_l	equ	rotcol.e-rotcol


		ifd	calc
rotcalcmode	dc.l	0

rotsin		;(360 graden / rottun_wid / 4) + een beetje ; no 0 value !

       dc.w       0,201,402,603,804,1005,1206,1407,1608,1809,2010,2210
       dc.w       2411,2611,2812,3012,3212,3412,3612,3812,4011,4211,4410,4609
       dc.w       4808,5007,5206,5404,5603,5801,5998,6196,6393,6590,6787,6984
       dc.w       7180,7376,7572,7767,7963,8157,8352,8546,8740,8934,9127,9320
       dc.w       9513,9705,9897,10088,10279,10470,10661,10850,11040,11229,11418,11606
       dc.w       11794,11981,12168,12355,12541,12726,12911,13096,13280,13463,13647,13829
       dc.w       14011,14193,14374,14554,14734,14913,15092,15270,15448,15625,15801,15977
       dc.w       16152,16327,16501,16674,16847,17019,17191,17362,17532,17701,17870,18039
       dc.w       18206,18373,18539,18705,18869,19033,19197,19359,19521,19682,19843,20002
       dc.w       20161,20319,20477,20633,20789,20944,21098,21252,21404,21556,21707,21858
       dc.w       22007,22155,22303,22450,22596,22741,22886,23029,23172,23313,23454,23594
       dc.w       23733,23872,24009,24145,24281,24415,24549,24682,24813,24944,25074,25203
       dc.w       25331,25458,25584,25710,25834,25957,26079,26200,26321,26440,26558,26675
       dc.w       26792,26907,27021,27134,27247,27358,27468,27577,27685,27792,27898,28003
       dc.w       28107,28210,28312,28412,28512,28611,28708,28804,28900,28994,29087,29179
       dc.w       29270,29360,29449,29536,29623,29708,29792,29876,29958,30038,30118,30197
       dc.w       30274,30351,30426,30500,30573,30645,30715,30785,30853,30920,30986,31051
       dc.w       31115,31177,31238,31298,31357,31415,31472,31527,31581,31634,31686,31737
       dc.w       31786,31834,31881,31927,31972,32015,32058,32099,32138,32177,32214,32250
       dc.w       32285,32319,32352,32383,32413,32442,32470,32496,32521,32545,32568,32589
       dc.w       32610,32629,32647,32663,32679,32693,32706,32717,32728,32737,32745,32752
       dc.w       32757,32762,32765,32766,32767,32766,32764,32761,32757,32751,32745,32737
       dc.w       32727,32717,32705,32692,32678,32662,32646,32628,32609,32588,32567,32544
       dc.w       32520,32495,32468,32440,32411,32381,32350,32317,32284,32249,32212,32175
       dc.w       32136,32096,32055,32013,31969,31925,31879,31832,31783,31734,31683,31631
       dc.w       31578,31524,31469,31412,31354,31295,31235,31174,31111,31047,30983,30916
       dc.w       30849,30781,30711,30641,30569,30496,30422,30347,30270,30193,30114,30034
       dc.w       29953,29871,29788,29703,29618,29531,29444,29355,29265,29174,29082,28989
       dc.w       28894,28799,28703,28605,28506,28407,28306,28204,28101,27997,27892,27786
       dc.w       27679,27571,27462,27352,27241,27128,27015,26901,26785,26669,26552,26433
       dc.w       26314,26194,26072,25950,25827,25703,25577,25451,25324,25196,25067,24937
       dc.w       24806,24674,24542,24408,24273,24138,24001,23864,23726,23587,23447,23306
       dc.w       23164,23021,22878,22733,22588,22442,22295,22147,21999,21849,21699,21548
       dc.w       21396,21243,21090,20936,20781,20625,20468,20311,20153,19994,19834,19673
       dc.w       19512,19350,19188,19024,18860,18696,18530,18364,18197,18029,17861,17692
       dc.w       17523,17353,17182,17010,16838,16665,16492,16318,16143,15968,15792,15615
       dc.w       15438,15261,15082,14904,14724,14544,14364,14183,14001,13819,13637,13454
       dc.w       13270,13086,12901,12716,12531,12345,12158,11971,11784,11596,11408,11219
       dc.w       11030,10840,10650,10460,10269,10078,9887,9695,9503,9310,9117,8924
       dc.w       8730,8536,8342,8147,7952,7757,7562,7366,7170,6973,6777,6580
       dc.w       6383,6185,5988,5790,5592,5394,5195,4997,4798,4599,4400,4200
       dc.w       4001,3801,3602,3402,3202,3001,2801,2601,2400,2200,1999,1798
       dc.w       1597,1397,1196,995,794,593,392,191,-10,-211,-412,-613
       dc.w       -814,-1015,-1216,-1417,-1618,-1819,-2019,-2220,-2421,-2621,-2822,-3022
       dc.w       -3222,-3422,-3622,-3822,-4021,-4221,-4420,-4619,-4818,-5017,-5216,-5414
       dc.w       -5612,-5810,-6008,-6206,-6403,-6600,-6797,-6993,-7190,-7386,-7581,-7777
       dc.w       -7972,-8167,-8362,-8556,-8750,-8943,-9137,-9330,-9522,-9714,-9906,-10098
       dc.w       -10289,-10479,-10670,-10860,-11049,-11238,-11427,-11615,-11803,-11990,-12177,-12364
       dc.w       -12550,-12735,-12920,-13105,-13289,-13472,-13655,-13838,-14020,-14201,-14382,-14563
       dc.w       -14742,-14922,-15101,-15279,-15456,-15633,-15810,-15985,-16161,-16335,-16509,-16683
       dc.w       -16855,-17028,-17199,-17370,-17540,-17710,-17878,-18047,-18214,-18381,-18547,-18712
       dc.w       -18877,-19041,-19204,-19367,-19529,-19690,-19850,-20010,-20169,-20327,-20484,-20641
       dc.w       -20796,-20951,-21105,-21259,-21412,-21563,-21714,-21864,-22014,-22162,-22310,-22457
       dc.w       -22603,-22748,-22892,-23036,-23178,-23320,-23461,-23601,-23740,-23878,-24015,-24151
       dc.w       -24287,-24421,-24555,-24688,-24819,-24950,-25080,-25209,-25337,-25464,-25590,-25715
       dc.w       -25839,-25962,-26085,-26206,-26326,-26445,-26563,-26681,-26797,-26912,-27026,-27139
       dc.w       -27252,-27363,-27473,-27582,-27690,-27797,-27903,-28008,-28112,-28214,-28316,-28417
       dc.w       -28516,-28615,-28712,-28809,-28904,-28998,-29091,-29183,-29274,-29364,-29452,-29540
       dc.w       -29626,-29712,-29796,-29879,-29961,-30042,-30122,-30200,-30278,-30354,-30429,-30503
       dc.w       -30576,-30648,-30718,-30788,-30856,-30923,-30989,-31054,-31117,-31180,-31241,-31301
       dc.w       -31360,-31417,-31474,-31529,-31583,-31636,-31688,-31739,-31788,-31836,-31883,-31929
       dc.w       -31973,-32017,-32059,-32100,-32140,-32178,-32216,-32252,-32287,-32320,-32353,-32384
       dc.w       -32414,-32443,-32470,-32497,-32522,-32546,-32568,-32590,-32610,-32629,-32647,-32663
       dc.w       -32679,-32693,-32706,-32717,-32728,-32737,-32745,-32752,-32757,-32761,-32764,-32766
       dc.w       -32766,-32766,-32764,-32761,-32756,-32751,-32744,-32736,-32726,-32716,-32704,-32691
       dc.w       -32677,-32661,-32644,-32626,-32607,-32587,-32565,-32542,-32518,-32493,-32466,-32439
       dc.w       -32410,-32379,-32348,-32315,-32281,-32246,-32210,-32173,-32134,-32094,-32053,-32010
       dc.w       -31967,-31922,-31876,-31829,-31781,-31731,-31680,-31628,-31575,-31521,-31466,-31409
       dc.w       -31351,-31292,-31232,-31170,-31108,-31044,-30979,-30913,-30846,-30777,-30708,-30637
       dc.w       -30565,-30492,-30418,-30343,-30266,-30188,-30110,-30030,-29949,-29867,-29783,-29699
       dc.w       -29614,-29527,-29439,-29350,-29260,-29169,-29077,-28984,-28890,-28794,-28698,-28600
       dc.w       -28502,-28402,-28301,-28199,-28096,-27992,-27887,-27781,-27674,-27566,-27457,-27346
       dc.w       -27235,-27123,-27009,-26895,-26780,-26663,-26546,-26428,-26308,-26188,-26066,-25944
       dc.w       -25821,-25697,-25571,-25445,-25318,-25190,-25061,-24931,-24800,-24668,-24535,-24401
       dc.w       -24267,-24131,-23995,-23857,-23719,-23580,-23440,-23299,-23157,-23014,-22871,-22726
       dc.w       -22581,-22435,-22288,-22140,-21992,-21842,-21692,-21541,-21389,-21236,-21083,-20928
       dc.w       -20773,-20617,-20461,-20303,-20145,-19986,-19826,-19666,-19505,-19343,-19180,-19017
       dc.w       -18853,-18688,-18522,-18356,-18189,-18022,-17853,-17684,-17515,-17344,-17174,-17002
       dc.w       -16830,-16657,-16483,-16309,-16135,-15959,-15783,-15607,-15430,-15252,-15074,-14895
       dc.w       -14716,-14536,-14355,-14174,-13993,-13811,-13628,-13445,-13261,-13077,-12893,-12708
       dc.w       -12522,-12336,-12149,-11962,-11775,-11587,-11399,-11210,-11021,-10831,-10641,-10451
       dc.w       -10260,-10069,-9878,-9686,-9493,-9301,-9108,-8915,-8721,-8527,-8333,-8138
       dc.w       -7943,-7748,-7552,-7357,-7160,-6964,-6767,-6571,-6374,-6176,-5979,-5781
       dc.w       -5583,-5384,-5186,-4987,-4789,-4590,-4390,-4191,-3992,-3792,-3592,-3392
       dc.w       -3192,-2992,-2792,-2591,-2391,-2190,-1990,-1789,-1588,-1387,-1186,-985
       dc.w       -784,-583,-382,-181
rotsin.e


       dc.w       0,201,402,603,804,1005,1206,1407,1608,1809,2010,2210
       dc.w       2411,2611,2812,3012,3212,3412,3612,3812,4011,4211,4410,4609
       dc.w       4808,5007,5206,5404,5603,5801,5998,6196,6393,6590,6787,6984
       dc.w       7180,7376,7572,7767,7963,8157,8352,8546,8740,8934,9127,9320
       dc.w       9513,9705,9897,10088,10279,10470,10661,10850,11040,11229,11418,11606
       dc.w       11794,11981,12168,12355,12541,12726,12911,13096,13280,13463,13647,13829
       dc.w       14011,14193,14374,14554,14734,14913,15092,15270,15448,15625,15801,15977
       dc.w       16152,16327,16501,16674,16847,17019,17191,17362,17532,17701,17870,18039
       dc.w       18206,18373,18539,18705,18869,19033,19197,19359,19521,19682,19843,20002
       dc.w       20161,20319,20477,20633,20789,20944,21098,21252,21404,21556,21707,21858
       dc.w       22007,22155,22303,22450,22596,22741,22886,23029,23172,23313,23454,23594
       dc.w       23733,23872,24009,24145,24281,24415,24549,24682,24813,24944,25074,25203
       dc.w       25331,25458,25584,25710,25834,25957,26079,26200,26321,26440,26558,26675
       dc.w       26792,26907,27021,27134,27247,27358,27468,27577,27685,27792,27898,28003
       dc.w       28107,28210,28312,28412,28512,28611,28708,28804,28900,28994,29087,29179
       dc.w       29270,29360,29449,29536,29623,29708,29792,29876,29958,30038,30118,30197
       dc.w       30274,30351,30426,30500,30573,30645,30715,30785,30853,30920,30986,31051
       dc.w       31115,31177,31238,31298,31357,31415,31472,31527,31581,31634,31686,31737
       dc.w       31786,31834,31881,31927,31972,32015,32058,32099,32138,32177,32214,32250
       dc.w       32285,32319,32352,32383,32413,32442,32470,32496,32521,32545,32568,32589
       dc.w       32610,32629,32647,32663,32679,32693,32706,32717,32728,32737,32745,32752
       dc.w       32757,32762,32765,32766,32767,32766,32764,32761,32757,32751,32745,32737
       dc.w       32727,32717,32705,32692,32678,32662,32646,32628,32609,32588,32567,32544
       dc.w       32520,32495,32468,32440,32411,32381,32350,32317,32284,32249,32212,32175
       dc.w       32136,32096,32055,32013,31969,31925,31879,31832,31783,31734,31683,31631
       dc.w       31578,31524,31469,31412,31354,31295,31235,31174,31111,31047,30983,30916


rotsin_l	equ	rotsin.e-rotsin
	
		endc	;calc

rotp.e

	endc	;routp

	ifd	routc

	SECTION	6,CODE_C

	cnop	0,8
rotc
rotchp
	ifnd	ocs
	dc.l	'ROTA'			;new chip/public format
	endc
	ifd	ocs
	dc.l	'ROTO'			;new chip/public format
	endc
	rts
	
	cnop	0,8
	
		ifd	calc
		cnop	0,8
rotpic3
		ifnd	ocs
		dc.l	'PICT'
		dc.w	rotpic_wid,rotpic_hgt,rotpic_dpt,1,0
		ds.b	8*4
		ds.b	16
		dc.w	32-1
		dc.w	$000,0,$00f,0,$0f0,0,$0ff,0,$f00,0,$f0f,0,$ff0,0,$fff,0
		dc.w	$000,0,$00f,0,$0f0,0,$0ff,0,$f00,0,$f0f,0,$ff0,0,$fff,0
		dc.w	$000,0,$00f,0,$0f0,0,$0ff,0,$f00,0,$f0f,0,$ff0,0,$fff,0
		dc.w	$000,0,$00f,0,$0f0,0,$0ff,0,$f00,0,$f0f,0,$ff0,0,$fff,0
		ds.l	256-32
		ds.b	rotpic_wid*rotpic_hgt*rotpic_dpt
		endc	
		ifd	ocs
		dc.l	'PICT'
		dc.w	rotpic_wid,rotpic_hgt,rotpic_dpt,1,0
		ds.b	4*4
		dc.w	32-1
		dc.w	$000,$00f,$0f0,$0ff,$f00,$f0f,$ff0,$fff
		dc.w	$000,$00f,$0f0,$0ff,$f00,$f0f,$ff0,$fff
		dc.w	$000,$00f,$0f0,$0ff,$f00,$f0f,$ff0,$fff
		dc.w	$000,$00f,$0f0,$0ff,$f00,$f0f,$ff0,$fff
		ds.w	256-32
		ds.b	rotpic_wid*rotpic_hgt*rotpic_dpt
		endc
		endc

	ifd	bit8
	ifnd	ocs
rotpicemp
	dc.l	'PICT'
	dc.w	16,16,1,1,0
	ds.b	8*4
	dc.l	0
	ds.b	12
	dc.w	0
	ds.l	256
	ds.b	16*16*1
	endc
	ifd	ocs
rotpicemp
	dc.l	'PICT'
	dc.w	16,16,1,1,0
	ds.b	4*4
	dc.w	0
	ds.w	256
	ds.b	16*16*1
	endc
	endc
	

	cnop	0,8
rotpic
	ifd	bit3aga
;	incbin	'w:binaga/copmag2.pic'
;	incbin	'w:binaga/copmag3.pic'
	incbin	'w:binaga/copmag4.pic'
	endc
	ifd	bit4aga
;	incbin	'w:binaga/copmag2.pic'
	incbin	'w:binaga/copmag3.pic'
;	incbin	'w:binaga/copmag4.pic'
	endc

	ifd	bit4
	ifd	ocs
	incbin	'w:bin/copmag.bin'
	endc
	ifnd	ocs
	incbin	'w:binaga/copmag.pic'
	endc
	endc

cop_xstr	equ	$01

	cnop	0,2
rotcop1
rotcprjmp
	dc.w	$80,0,$82,0
	ifd	bit4aga
	dc.w	$008e,$1b41,$0090,$3bc1,$0092,$0018,$0094,$00b8	;384*288
	dc.w	$0108,-$30,$010a,-$30
	endc	
	ifd	bit3aga
	dc.w	$008e,$1b41,$0090,$3bc1,$0092,$0018,$0094,$00b8	;384*288
	dc.w	$0108,-$30,$010a,-$30
;	dc.w	$008e,$2481,$0090,$31c1,$0092,$0038,$0094,$00b8	;320*256
;	dc.w	$0108,-$28,$010a,-$28
	endc
rotcoptus.s
	ifd	bit3aga
	dc.w	cop_xstr,$fffe
	dc.w	$10c,$0000
	dc.w	$106,$8000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;31
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$a000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;32
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$c000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;32
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$e000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;22
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0
;	dc.w	$1ac,0,$1ae,0
;	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	endc

	ifd	bit4aga
	dc.w	cop_xstr,$fffe
	dc.w	$10c,$0000
	dc.w	$106,$8000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;31
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$a000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;32
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$c000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;17
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0
	dc.w	$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0,$1b0,0
	dc.w	$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
;	dc.w	$00c9,$fffe
	endc

	ifd	bit4
	dc.w	$00c9,$fffe
	dc.w	$1be,$000,$1bc,$000,$1ba,$000,$1b8,$000
	dc.w	$1b6,$000,$1b4,$000,$1b2,$000,$1b0,$000
	dc.w	$1ae,$000,$1ac,$000,$1aa,$000,$1a8,$000
	dc.w	$1a6,$000,$1a4,$000,$1a2,$000,$1a0,$000
	dc.w	$19e,$000,$19c,$000,$19a,$000,$198,$000
	dc.w	$196,$000,$194,$000,$192,$000,$190,$000
	dc.w	$18e,$000,$18c,$000,$18a,$000,$188,$000
	dc.w	$186,$000,$184,$000,$182,$000
	dc.w	$1be,$000,$1bc,$000,$1ba,$000,$1b8,$000
	dc.w	$1b6,$000,$1b4,$000,$1b2,$000,$1b0,$000
	dc.w	$1ae,$000,$1ac,$000,$1aa,$000,$1a8,$000
	dc.w	$1a6,$000,$1a4,$000,$1a2,$000,$1a0,$000
	dc.w	$19e,$000
	endc

	ifd	bit8
	dc.w	$0029,$fffe
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000
	endc

rotcoptus.e

	ifd	bit3aga

	dc.w	cop_xstr,$fffe
	dc.w	$10c,$8000
	dc.w	$106,$0000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$2000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$4000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$6000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;22
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0
;	dc.w	$1ac,0,$1ae,0
;	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	rept	rotpic_y/6-1
	dc.w	cop_xstr,$fffe
	dc.w	$10c,$0000
	dc.w	$106,$8000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$a000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$c000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$e000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;22
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0
;	dc.w	$1ac,0,$1ae,0
;	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	dc.w	cop_xstr,$fffe
	dc.w	$10c,$8000
	dc.w	$106,$0000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$2000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$4000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$6000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0	;22
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0
;	dc.w	$1ac,0,$1ae,0
;	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0

	endr
	endc

	ifd	bit4aga

	dc.w	cop_xstr,$fffe
	dc.w	$10c,$8000
	dc.w	$106,$0000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$2000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$4000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0
	dc.w	$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0,$1b0,0
	dc.w	$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
;	dc.w	$00c9,$fffe

	rept	rotpic_y/8-1
	dc.w	cop_xstr,$fffe
	dc.w	$10c,$0000
	dc.w	$106,$8000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$a000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$c000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0
	dc.w	$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0,$1b0,0
	dc.w	$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
;	dc.w	$00c9,$fffe

	dc.w	cop_xstr,$fffe
	dc.w	$10c,$8000
	dc.w	$106,$0000
	dc.w	$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$2000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0,$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0
	dc.w	$1b0,0,$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
	dc.w	$106,$4000
	dc.w	$180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
	dc.w	$190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
	dc.w	$1a0,0
	dc.w	$1a2,0,$1a4,0,$1a6,0,$1a8,0,$1aa,0,$1ac,0,$1ae,0,$1b0,0
	dc.w	$1b2,0,$1b4,0,$1b6,0,$1b8,0,$1ba,0,$1bc,0,$1be,0
;	dc.w	$00c9,$fffe

	endr
	endc

	ifd	bit4
	rept	rotpic_y-1
	dc.w	$00c9,$fffe
	dc.w	$1be,$000,$1bc,$000,$1ba,$000,$1b8,$000
	dc.w	$1b6,$000,$1b4,$000,$1b2,$000,$1b0,$000
	dc.w	$1ae,$000,$1ac,$000,$1aa,$000,$1a8,$000
	dc.w	$1a6,$000,$1a4,$000,$1a2,$000,$1a0,$000
	dc.w	$19e,$000,$19c,$000,$19a,$000,$198,$000
	dc.w	$196,$000,$194,$000,$192,$000,$190,$000
	dc.w	$18e,$000,$18c,$000,$18a,$000,$188,$000
	dc.w	$186,$000,$184,$000,$182,$000
	dc.w	$1be,$000,$1bc,$000,$1ba,$000,$1b8,$000
	dc.w	$1b6,$000,$1b4,$000,$1b2,$000,$1b0,$000
	dc.w	$1ae,$000,$1ac,$000,$1aa,$000,$1a8,$000
	dc.w	$1a6,$000,$1a4,$000,$1a2,$000,$1a0,$000
	dc.w	$19e,$000
	endr
	endc

	ifd	bit8
	rept	rotpic_y-1
	dc.w	$0029,$fffe
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000,$180,$000,$180,$000,$180,$000
	dc.w	$180,$000
	endr
	endc

	dc.w	$180,$000,$88,0

rotcoptus_l	equ	rotcoptus.e-rotcoptus.s

	ifd	bit3aga
rotcprbck1		equ	(rotcoptus_l*((rotpic_y-124)/4))+8
rotcprbck1ntsc		equ	(rotcoptus_l*((rotpic_y-172)/4))+8
rotcprend1ntsc		equ	(rotcoptus_l*((rotpic_y-60)/4))+8
	endc
	
	ifd	bit4aga
rotcprbck1		equ	(rotcoptus_l*((rotpic_y-124)/4))+8
rotcprbck1ntsc		equ	(rotcoptus_l*((rotpic_y-172)/4))+8
rotcprend1ntsc		equ	(rotcoptus_l*((rotpic_y-60)/4))+8
	endc
	
	ifd	bit8
rotcprbck1		equ	(rotcoptus_l*(rotpic_y-124))+8
rotcprbck1ntsc		equ	(rotcoptus_l*(rotpic_y-180))+8
rotcprend1ntsc		equ	(rotcoptus_l*(rotpic_y-60))+8
	endc
	
	ifd	bit4
rotcprbck1		equ	(rotcoptus_l*(rotpic_y-78))+8
rotcprbck1ntsc		equ	(rotcoptus_l*(rotpic_y-106))+8
	endc

rotcop2
	ds.b	rotcop2-rotcop1
rotcop2.e

rotcop_l	equ	rotcop2-rotcop1

rotc.e

rot.e
;**********************************************************************

	ifd	rout
	cnop	0,8
rotsrc
	ifnd	ocs
;	incbin	'w:effectaga/.parrot_ham.bru'
;	incbin	'w:effectaga/borisgirl_ham.bru'
	incbin	'w:effectaga/diamondrgb_ham.bru'
	endc
	ifd	ocs
	incbin	'w:effect/diamondrgb_ham.bru'
	endc
	endc


	endc
