bobs:	equ	34	;howmany bobs ?

;  All routines made by ATOM of North Star.
;  The routines have been made to be as simple
;  and easy to understand as possible, thats
;  why some of my old(very old) routines
;  have been used and not the new ones.
; 
;  But when you understand the principles
;  you should have no problems improving
;  them, and that's the point RIGHT ????
;
;  All routines might be used as you want
;  but the grafix and music is NS property.
;  
;  And it would be rather lame-looking if
;  you used the same font and music.....
;
;  Sorry for the late delivery date, but I had to
;  visit some American software houses for a few
;  weeks, but better late then never - Right Shredder ?!?

************************************************************
*
*              hardware references
*
************************************************************

custom:     equ        $dff000
bltddat:    equ        $000
dmaconr:    equ        $002
vposr:      equ        $004
vhposr:     equ        $006
dskdatr:    equ        $008
joy0dat:    equ        $00a
joy1dat:    equ        $00c
clxdat:     equ        $00e
adkconr:    equ        $010
pot0dat:    equ        $012
pot1dat:    equ        $014
potgor:     equ        $016
serdatr:    equ        $018
dskbytr:    equ        $01a
intenar:    equ        $01c
intreqr:    equ        $01e
dskpth:     equ        $020
dskptl:     equ        $022
dsklen:     equ        $024
dskdat:     equ        $026
refptr:     equ        $028
vposw:      equ        $02a
vhposw:     equ        $02c
copcon:     equ        $02e
serdat:     equ        $030
serper:     equ        $032
potgo:      equ        $034
joytest:    equ        $036
strequ:     equ        $038
strvbl:     equ        $03a
strhor:     equ        $03c
strlong:    equ        $03e
bltcon0:    equ        $040
bltcon1:    equ        $042
bltafwm:    equ        $044
bltalwm:    equ        $046
bltcpth:    equ        $048
bltcptl:    equ        $04a
bltbpth:    equ        $04c
bltbptl:    equ        $04e
bltapth:    equ        $050
bltaptl:    equ        $052
bltdpth:    equ        $054
bltdptl:    equ        $056
bltsize:    equ        $058
bltcmod:    equ        $060
bltbmod:    equ        $062
bltamod:    equ        $064
bltdmod:    equ        $066
bltcdat:    equ        $070
bltbdat:    equ        $072
bltadat:    equ        $074
dsksync:    equ        $07e
cop1lch:    equ        $080
cop1lcl:    equ        $082
cop2lch:    equ        $084
cop2lcl:    equ        $086
copjmp1:    equ        $088
copjmp2:    equ        $08a
copins:     equ        $08c
diwstrt:    equ        $08e
diwstop:    equ        $090
ddfstrt:    equ        $092
ddfstop:    equ        $094
dmacon:     equ        $096
clxcon:     equ        $098
intena:     equ        $09a
intreq:     equ        $09c
adkcon:     equ        $09e
aud0lch:    equ        $0a0
aud0lcl:    equ        $0a2
aud0len:    equ        $0a4
aud0per:    equ        $0a6
aud0vol:    equ        $0a8
aud0dat:    equ        $0aa
aud1lch:    equ        $0b0
aud1lcl:    equ        $0b2
aud1len:    equ        $0b4
aud1per:    equ        $0b6
aud1vol:    equ        $0b8
aud1dat:    equ        $0ba
aud2lch:    equ        $0c0
aud2lcl:    equ        $0c2
aud2len:    equ        $0c4
aud2per:    equ        $0c6
aud2vol:    equ        $0c8
aud2dat:    equ        $0ca
aud3lch:    equ        $0d0
aud3lcl:    equ        $0d2
aud3len:    equ        $0d4
aud3per:    equ        $0d6
aud3vol:    equ        $0d8
aud3dat:    equ        $0da
bpl1pth:    equ        $0e0
bpl1ptl:    equ        $0e2
bpl2pth:    equ        $0e4
bpl2ptl:    equ        $0e6
bpl3pth:    equ        $0e8
bpl3ptl:    equ        $0ea
bpl4pth:    equ        $0ec
bpl4ptl:    equ        $0ee
bpl5pth:    equ        $0f0
bpl5ptl:    equ        $0f2
bpl6pth:    equ        $0f4
bpl6ptl:    equ        $0f6
bplcon0:    equ        $100
bplcon1:    equ        $102
bplcon2:    equ        $104
bpl1mod:    equ        $108
bpl2mod:    equ        $10a
bpl1dat:    equ        $110
bpl2dat:    equ        $112
bpl3dat:    equ        $114
bpl4dat:    equ        $116
bpl5dat:    equ        $118
bpl6dat:    equ        $11a
spr0pth:    equ        $120
spr0ptl:    equ        $122
spr1pth:    equ        $124
spr1ptl:    equ        $126
spr2pth:    equ        $128
spr2ptl:    equ        $12a
spr3pth:    equ        $12c
spr3ptl:    equ        $12e
spr4pth:    equ        $130
spr4ptl:    equ        $132
spr5pth:    equ        $134
spr5ptl:    equ        $136
spr6pth:    equ        $138
spr6ptl:    equ        $13a
spr7pth:    equ        $13c
spr7ptl:    equ        $13e
spr0pos:    equ        $140
spr0ctl:    equ        $142
spr0data:   equ        $144
spr0datb:   equ        $146
spr1pos:    equ        $148
spr1ctl:    equ        $14a
spr1data:   equ        $14c
spr1datb:   equ        $14e
spr2pos:    equ        $150
spr2ctl:    equ        $152
spr2data:   equ        $154
spr2datb:   equ        $156
spr3pos:    equ        $158
spr3ctl:    equ        $15a
spr3data:   equ        $15c
spr3datb:   equ        $15e
spr4pos:    equ        $160
spr4ctl:    equ        $162
spr4data:   equ        $164
spr4datb:   equ        $166
spr5pos:    equ        $168
spr5ctl:    equ        $16a
spr5data:   equ        $16c
spr5datb:   equ        $16e
spr6pos:    equ        $170
spr6ctl:    equ        $172
spr6data:   equ        $174
spr6datb:   equ        $176
spr7pos:    equ        $178
spr7ctl:    equ        $17a
spr7data:   equ        $17c
spr7datb:   equ        $17e
color00:    equ        $180
color01:    equ        $182
color02:    equ        $184
color03:    equ        $186
color04:    equ        $188
color05:    equ        $18a
color06:    equ        $18c
color07:    equ        $18e
color08:    equ        $190
color09:    equ        $192
color10:    equ        $194
color11:    equ        $196
color12:    equ        $198
color13:    equ        $19a
color14:    equ        $19c
color15:    equ        $19e
color16:    equ        $1a0
color17:    equ        $1a2
color18:    equ        $1a4
color19:    equ        $1a6
color20:    equ        $1a8
color21:    equ        $1aa
color22:    equ        $1ac
color23:    equ        $1ae
color24:    equ        $1b0
color25:    equ        $1b2
color26:    equ        $1b4
color27:    equ        $1b6
color28:    equ        $1b8
color29:    equ        $1ba
color30:    equ        $1bc
color31:    equ        $1be


************************************************************
*
*              clist.lib.offsets
*
************************************************************


initclpool:     equ            -30
allocclist:     equ            -36
freeclist:      equ            -42
flushclist:     equ            -48
sizeclist:      equ            -54
putclchar:      equ            -60
getclchar:      equ            -66
ungetclchar:    equ            -72
unputlcchar:    equ            -78
putclword:      equ            -84
getclword:      equ            -90
ungetclword:    equ            -96
unputclword:    equ            -102
putclbuf:       equ            -108
getclbuf:       equ            -114
markclist:      equ            -120
incrclmark:     equ            -126
peekclmark:     equ            -132
splitclist:     equ            -138
copyclist:      equ            -144
subclist:       equ            -150
concatclist:    equ            -156


************************************************************
*
*              console.lib.offsets
*
************************************************************


cdinputhandler: equ            -42
rawkeyconvert:  equ            -48


************************************************************
*
*              diskfont.lib.offsets
*
************************************************************


opendiskfont:   equ            -30
availfonts:     equ            -36


************************************************************
*
*              dos.lib/offsets
*
***********************************************************


open:           equ            -30
close:          equ            -36
read:           equ            -42
write:          equ            -48
input:          equ            -54
output:         equ            -60


************************************************************
*
*              exec.lib.offsets
*
************************************************************


absexecbase:    equ            4
allocmem:       equ            -198
freemem:        equ            -210
getmsg:         equ            -372
replymsg:       equ            -378
waitport:       equ            -384
closelibrary:   equ            -414
opendevice:     equ            -444
closedevice:    equ            -450
doio:           equ            -456
openlibrary:    equ            -552


************************************************************
*
*              intuition.lib.offsets
*
************************************************************


clearmenustrip: equ            -54
closescreen:    equ            -66
closewindow:    equ            -72
openscreen:     equ            -198
openwindow:     equ            -204
printitext:     equ            -216
setmenustrip:   equ            -264
showtitle:      equ            -282
viewportaddress: equ           -300
windowtoback:   equ            -306
windowtofront:  equ            -312


************************************************************
*
*              graphics.lib.offsets
*
************************************************************


loadrgb4:       equ            -192
setrgb4:        equ            -288
aa	bsr	go
bb	rts
	
go:	move.l	4.w,a6
	jsr	-132(a6)

	move.l	#frimem,d0
	move.l	d0,bobmem1
	add.l	#16000,d0
	move.l	d0,bobmem2	;bob bpl mem
	add.l	#16000,d0
	move.l	d0,megaspr	;memory for sprite data
	add.l	#2000,d0	
	move.l	d0,scrmem1
	add.l	#4224,d0
	move.l	d0,scrmem2
	add.l	#4224,d0
	move.l	d0,scrmem3
	add.l	#4224+8000,d0
	move.l	d0,copmem

	bsr	flipp

	lea	$dff000,a0
	move.w	#$4000,intena(a0)
	move.w	dmaconr(a0),d0
	or.w	#$8000,d0
	move.w	d0,dmasaf

	move.w	#$7fff,dmacon(a0)
	move.w	#%1000011111101111,dmacon(a0)

	bsr	makecop

	move.l	copmem,a1
	move.l	a1,cop1lch(a0)
	clr.w	copjmp1(a0)

	bsr	makespr

	move.l	#scrtext,scrpoint
	bsr	fixbobsin

	bsr	calcbob


********* Main Program **********

main:	lea	$dff000,a0
	and.w	#$20,intreqr(a0)
	beq.s	main
	move.w	#$20,intreq(a0)	

	bsr	stars

	bsr	calclogo

	bsr	clrbobs			;clear bobs
	bsr	putbobs			;blit bobs
	bsr	flipp			;change bob pictures

crick:	cmp.b	#180,$dff000+vhposr	;timing
	blt.s	crick

	bsr	scroll		;move scroll and put new chr
	bsr	setlogo		;and scroll copper pointers
	bsr	calcbob		;calc new bob pos

	btst	#6,$bfe001
	bne.s	main

*********** Exit *************

	move.w	#$7fff,dmacon+$dff000
	move.l	4.w,a6
	jsr	-138(a6)
	lea	grlib(pc),a1
	jsr	-408(a6)
	move.l	d0,a0
	move.l	38(a0),$dff080
	move.w	#0,copjmp1+$dff000
	move.w	dmasaf,d0
	move.w	d0,dmacon+$dff000


	move.w	#$c000,$df000+intena
	moveq	#0,d0
error:	rts

********** Sub Routines ************
;  This routine sets the grade value for the bobs
;
fixbobsin:
	move.w	#bobs,d0
	lea	bobsin,a1
	lea	bobcos,a2
	clr.w	d1
	clr.w	d2
bobsin1:move.w	d1,(a1)+
	move.w	d2,(a2)+
	add.w	#8,d1		;add value to next grade (try to chg)
	add.w	#12,d2
	dbf	d0,bobsin1
	rts

***********************************
;  This routine calls the sine and cosine routines
;  to calculate new positions for the bobs, normally
;  when you run the same track again and again you
;  make the sin/cos calcs before and puts them in
;  memory so you just have to fetch them.

calcbob:move.w	#bobs,d7
	lea	bobsin,a1	;pointers to grade
	lea	bobcos,a2
	lea	boby,a3		;pointers to positions
	lea	bobx,a4
	clr.l	d0
cbob1:	move.w	(a1),d0		;get y grade
	addq.w	#4,d0		;add a value (try to change it!)
	cmp.w	#360,d0		;check not exciding 360
	blt.s	cbob2
	sub.w	#360,d0
cbob2:	move.w	d0,(a1)+	;grade y
	move.l	#100,d2		;origo y
	move.w	#80,d1		;radius y
	bsr	getsin
	move.w	d3,(a3)+	;set y pos
	
	move.w	(a2),d0		;this is the same as the sin
	addq.w	#2,d0		;just handling cos instead.
	cmp.w	#360,d0
	blt.s	cbob3
	sub.w	#360,d0
cbob3:	move.w	d0,(a2)+	;grade x
	move.w	#160-8,d2	;origo x
	move.w	#120,d1		;radius x
	bsr	getcos
	move.w	d3,(a4)+	;set x pos
	dbf	d7,cbob1
	rts

************************************
;This flipps the screen so the pict just finished is
;shown and the other one will be worked with.

;
flipp:	move.l	bobmem1,d0
	cmp.l	bobshow,d0
	beq.s	flipp2
	move.l	bobmem1,bobshow
	move.l	bobmem2,bobwork
	move.l	#clear2,clearp
	rts

flipp2:	move.l	bobmem2,bobshow
	move.l	bobmem1,bobwork
	move.l	#clear1,clearp
	rts



************************************
; This is the bob routine, with buffering,
; that is that every frame you work with
; the bobsmem not shown and you show the other

; Buffering is used so that you can blit the bobs
; during the whole frame without flickering. 

; This is used in every serious game. But it takes
; the double amount of memory....

; The new way to blit multiple bitplanes is NOT
; used, that might would have been too hard to
; understand....

clrbobs:move.l	clearp,a4
	move.l	bobwork,d1
	lea	$dff000,a0
	move.w	#36,bltdmod(a0)
	move.w	#$100,bltcon0(a0); use only destination
clr1:	move.l	(a4)+,d0	;fetch clr add
	tst.l	d0
	beq	error
	add.l	d1,d0
clr2:	btst	#6,dmaconr(a0)	;blt nasty doesn't work with only
	bne.s	clr2		;destination.....
	move.l	d0,bltdpth(a0)
	move.w	#$3c2,bltsize(a0)
	add.l	#8000,d0	;clear next bitpl
clr3:	btst	#6,dmaconr(a0)
	bne.s	clr3
	move.l	d0,bltdpth(a0)
	move.w	#$3c2,bltsize(a0)
clr4:	btst	#6,dmaconr(a0)
	bne.s	clr4
	bra.s	clr1


putbobs:
	move.w	#bobs,d0
	lea	boby,a1		;ypos in a1
	lea	bobx,a2		;xpos in a2
	lea	$dff000,a0
	move.l	#$ffff0000,bltafwm(a0)	;mask off the 16 last bits
	move.w	#36,bltdmod(a0)		;40-4=36
	move.w	#-2,bltamod(a0)		;This is done becourse you have to
	move.w	#-2,bltbmod(a0)		;blit one word more to rotate bob.
	move.w	#36,bltcmod(a0)

;A is mask
;B is gfx data
;C is screen
;D is screen

putbob1:
	move.l	bobwork,a3	;destination in a3
	move.w	(a1)+,d1	;ypos in d1
	move.w	(a2)+,d2	;xpos in d2
	mulu	#40,d1		;mulu with screen width
	move.w	d2,d3
	and.w	#15,d3		;get scroll value in d3
	lsr.w	#3,d2		;divide with 8 to get byte
	add.w	d2,d1
	move.l	clearp,a4	;save the addr for clearing of bob
	move.l	d1,(a4)+
	move.l	a4,clearp
	add.l	d1,a3		;a3 now points to right dest.
	ror.w	#4,d3		;get scr val in high bits
	move.w	d3,bltcon1(a0)	;scr value for grfx
	or.w	#$fca,d3	;use ABCD

; C and A, C or B -> D
;
;
	move.w	d3,bltcon0(a0)	;scr value for mask

	move.l	#bobraw,bltbpth(a0)
	move.l	#bobmaskraw,bltapth(a0)
	move.l	a3,bltdpth(a0)
	move.l	a3,bltcpth(a0)

	move.w	#$3c2,bltsize(a0)
waitb1:	btst	#6,dmaconr(a0)
	bne.s	waitb1

	add.l	#8000,a3	;next bpl
	move.l	#bobraw+30,bltbpth(a0)
	move.l	#bobmaskraw,bltapth(a0)
	move.l	a3,bltdpth(a0)
	move.l	a3,bltcpth(a0)
	move.w	#$3c2,bltsize(a0)

waitb2:	btst	#6,dmaconr(a0)
	bne.s	waitb2

	dbf	d0,putbob1
	move.l	clearp,a4	;make a zero last in the list
	clr.l	(a4)
	rts

************************************
;This calcs the bumping logo
;
;
;

calclogo:
	tst.w	wait1	;check if wait
	beq.s	ok1
	subq.w	#1,wait1
	rts
ok1:	addq.w	#2,logograd
	cmp.w	#180,logograd
	blt.s	slipp1
	clr.w	logograd
slipp1:	cmp.w	#90,logograd	;make a pause when 90 reached
	bne.s	ok2
	move.w	#200,wait1	;wait 200 frames
ok2:	clr.l	d0
	move.w	logograd,d0	;grade
	add.w	#180,d0
	move.l	#100,d1		;radius
	move.l	#104,d2		;origo
	bsr	getsin
	move.w	d3,logoy	;put new y pos
	rts	

************************************
;The actual scroll routine
;
;
scroll:	tst.w	pause		;pause ?
	beq	scroll99
	subq.w	#1,pause
	rts
scroll99:move.w	speed,d0
	add.w	d0,scrcount	;add speed (pixels)
	move.w	scrcount,d0
	lsr.w	#3,d0		;pix/8
	move.w	d0,scradd
	move.w	scrcount,d0
	and.w	#31,d0
	bne	error		;new char to put out ?
scroll1:move.l	scrpoint,a1	;Yep !
	clr.l	d0
scroll6:move.b	(a1)+,d0	;get ascII in d0
	cmp.w	#'^',d0		;end of scroll ?
	bne.s	scroll2
	move.l	#scrtext,scrpoint
	bra.s	scroll1
scroll2:cmp.w	#31,d0
	bgt.s	scroll5
	move.w	d0,speed
	bra.s	scroll6
scroll5:cmp.w	#'#',d0		;check if pause
	bne.s	scroll7
	move.w	#50,pause
	bra.s	scroll6
scroll7:move.l	a1,scrpoint
	lea	fontraw,a5	;Some math to calc char pos in bitmap
	sub.w	#32,d0		;space=0
	move.w	d0,d1
	divu	#10,d0		;divide by number of chars per row
	move.w	d0,d2
	mulu	#1280,d0	;multiply with one row 32*40=1280
	add.l	d0,a5		;now we point to the right row
	mulu	#10,d2
	sub.w	d2,d1
	lsl.w	#2,d1		;multiply with one char width 4bytes
	add.w	d1,a5		;a5 points to char in bitmap. GREAT !!

	move.l	scrmem1,a4	;pointer to start of screen
	add.l	#40,a4		;put char on right side of screen
	clr.l	d7
	move.w	scradd,d7
	add.l	d7,a4		;add the scradd.

	lea	$dff000,a0	;lets BLITT !!
	move.l	#$ffffffff,bltafwm(a0)	;no mask
	move.w	#40,bltdmod(a0)	;44-4=40
	move.w	#36,bltamod(a0)	;40-4=36
	move.w	#$9f0,bltcon0(a0); D=A minterm
	clr.w	bltcon1(a0)

	move.l	a4,bltdpth(a0)
	move.l	a5,bltapth(a0)	;bpl 1
	move.w	#$802,bltsize(a0)
waitb4:	btst	#6,dmaconr(a0)
	bne.s	waitb4

	add.l	#4224,a4
	add.l	#7680,a5	;bpl 2
	move.l	a4,bltdpth(a0)
	move.l	a5,bltapth(a0)
	move.w	#$802,bltsize(a0)
waitb5:	btst	#6,dmaconr(a0)
	bne.s	waitb5

	add.l	#4224,a4
	add.l	#7680,a5	;bpl 3
	move.l	a4,bltdpth(a0)
	move.l	a5,bltapth(a0)
	move.w	#$802,bltsize(a0)
waitb6:	btst	#6,dmaconr(a0)
	bne.s	waitb6
	rts
	
	

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


** this moves the stars to the right **
; you can speed this routine up to half
; the raster time if you change the cmp.l 
; to cmp.w , but then you have to change
; data struct in makespr aswell.
; (You have to do something yourself!!)
stars:	move.l	megaspr,a1	
	bsr	plupp
	move.l	megaspr,a1
	add.l	#1000,a1	
plupp:	cmp.w	#0,(a1)
	beq	error
	move.w	(a1),d0
	cmp.l	#$00010001,4(a1)	;dark color ? ($555)
	beq.s	slow
	cmp.l	#$00000001,4(a1)	;normal grey ?($aaa)
	beq.s	medel
	addi.b	#1,d0			;bright stars ? move 3 steps
medel:	addi.b	#1,d0	;change these to sub to move left.
slow:	addi.b	#1,d0
	move.b	d0,1(a1)
	add.l	#8,a1
	bra	plupp
blill:	clr.w	(a2)+
	rts

;This routine doesn't work on sprites below 255.
;But it's not hard to change it or re-write it 
;these stars routines was written a year ago....

makespr:lea	$fc0000,a3	;creates a long random x sprite
	move.l	megaspr,a2	;at address a2
	bsr	espr		;starty in d5
	move.l	megaspr,a2
	add.l	#1000,a2
espr:	move.l	#44,d5
	move.w	#1,d4
klick:	move.w	d5,d1
	add.w	#2,d5
	rol.w	#8,d1
	move.w	d1,d3
	move.w	(a3)+,d2
	move.w	50(a3),d4
	eor.w	d4,d2
	and.l	#$ff,d2
	or.w	d2,d1
	move.w	d1,(a2)+
	and.l	#$ff00,d3
	add.w	#$100,d3
	move.w	d3,(a2)+
	move.w	(a3)+,d1
	eor.w	d4,d1
	and.w	#3,d1
	cmp.w	#1,d1
	bne.s	bop1
	move.w	#1,d6
	move.w	#0,d7
bop1:	cmp.w	#2,d1
	bne.s	bop2
	move.w	#0,d6
	move.w	#1,d7
bop2:	cmp.w	#3,d1
	bne.s	bop3
	move.w	#1,d6
	move.w	#1,d7
bop3:	move.w	d6,(a2)+
	move.w	d7,(a2)+
	cmp.w	#244,d5		;200 lines done ?
	beq	blill		;exit ?
	bra	klick




***********************************
;This is the routine wich creates the whole
;copper list, most programmes write there copper list
;in a table.. But I find this way easier when you create
;complex copper lists with lot of colors and changeses.
;

makecop:move.l	copmem,a2		;get copper addr in a2
	move.w	#bpl2mod,(a2)+
	clr.w	(a2)+
	move.w	#bplcon0,(a2)+
	move.w	#$5400,(a2)+		;3 bitpl logo & 2 bitpl bobs
	move.w	#color00,(a2)+
	clr.w	(a2)+

	move.w	#$106,(a2)+		;bplcon4
	move.w	#0,(a2)+		;clear it

	move.w	#$1fc,(a2)+		;fetch mode
	move.w	#0,(a2)+		;clear it

	move.w	#bplcon2,(a2)+		;plf 1 first, plf 2 after
	move.w	#0,(a2)+		;spr last
	move.w	#bplcon1,(a2)+		;correct scr value
	move.w	#0,(a2)+
	move.w	#ddfstrt,(a2)+		;setup screen
	move.w	#$0038,(a2)+		;200*40
	move.w	#ddfstop,(a2)+
	move.w	#$00d0,(a2)+
	move.w	#diwstrt,(a2)+
	move.w	#$2c81,(a2)+
	move.w	#diwstop,(a2)+
	move.w	#$f4c1,(a2)+
	move.l	#nslogoraw,d1		;set bitplane pointers
	move.w	#bpl1pth,d0
	bsr	setbpl
	add.l	#2480,d1	;logo y*40
	move.w	#bpl3pth,d0
	bsr	setbpl
	add.l	#2480,d1	;logo y*40
	move.w	#bpl5pth,d0
	bsr	setbpl
	move.w	#spr0pth,d0		;set sprite pointers
	move.l	megaspr,d1
	bsr	setbpl
	move.w	#spr1pth,d0
	add.l	#1000,d1
	bsr	setbpl
	move.w	#spr2pth,d0		;rest of the spr to dummy
	move.l	#tom,d1			;address.
	bsr	setbpl
	move.w	#spr3pth,d0
	move.l	#tom,d1
	bsr	setbpl
	move.w	#spr4pth,d0
	move.l	#tom,d1
	bsr	setbpl
	move.w	#spr5pth,d0
	move.l	#tom,d1
	bsr	setbpl
	move.w	#spr6pth,d0
	move.l	#tom,d1
	bsr	setbpl
	move.w	#spr7pth,d0
	move.l	#tom,d1
	bsr	setbpl
					;Set colors
	lea	nslogoraw+7440,a1	;point to colors
	move.w	#7,d1			;set 8 colors
	move.w	#color00,d0
	bsr	setcol
	lea	sprcol,a1
	move.w	#3,d1
	move.w	#color16,d0
	bsr	setcol

	lea	bobraw+60,a1
	move.w	#3,d1
	move.w	#color08,d0
	bsr	setcol

	move.w	#bpl1mod,(a2)+	;logo off
	move.w	#-40,(a2)+
	pea	next1
	move.l	a2,agg1

** jump to this every vb to move logo to logoy **
;  Make sure that the logo doesn't reach the scroll !!!
;  This also shifts the bob screens

setlogo:move.l	agg1,a2
	move.l	bobshow,d1	;show picture not working with
	move.w	#bpl2pth,d0
	bsr	setbpl
	add.l	#8000,d1
	move.w	#bpl4pth,d0
	bsr	setbpl

	move.w	logoy,d0
	add.w	#44,d0		;add vb length
	lsl.w	#8,d0		;ypos in highbyte
	or.w	#1,d0		;set bit 0
	move.w	d0,(a2)+	;wait logoy
	move.w	#$ff00,(a2)+
	move.w	#bpl1mod,(a2)+
	clr.w	(a2)+		;clr bplmod1, show logo

	move.w	d0,d2		;set the colbar in the logo
	move.w	logoby,d1	;at poss logoby
	lsl.w	#8,d1
	add.w	d1,d2
	lea	colbar3,a1
	move.w	#31,d3
intact:	move.w	d2,(a2)+
	move.w	#$ff00,(a2)+
	move.w	#color07,(a2)+
	move.w	(a1)+,(a2)+
	add.w	#$0100,d2
	dbf	d3,intact


	add.w	#$3d00,d0	;show 61 lines of logo
	move.w	d0,(a2)+	;wait untill last line
	move.w	#$ff00,(a2)+
	move.w	#bpl1mod,(a2)+
	move.w	#-40,(a2)+	;turn logo off again.
	move.w	#bpl1pth,d0
	move.l	#tom,d1
	bsr	setbpl	
	move.w	#bpl3pth,d0
	move.l	#tom,d1
	bsr	setbpl	
	move.w	#bpl5pth,d0
	move.l	#tom,d1
	bsr	setbpl	

	lea	fontraw+23040,a1	;set scroll color
	move.w	#color00,d0
	move.w	#7,d1
	bsr	setcol

** this will set the bplpth's and bplcon1 for the scroll **

	move.w	#$d401,(a2)+	;put scr at line 212
	move.w	#$ff00,(a2)+
	move.w	#ddfstrt,(a2)+	;new screen width 42
	move.w	#$0032,(a2)+
	move.w	#bpl2mod,(a2)+	;correct for plf 2
	move.w	#-2,(a2)+
	move.w	#bpl1mod,(a2)+
	move.w	#2,(a2)+	;module 2, sceen 44 bytes
	move.w	scrcount,d0
	and.w	#15,d0
	not.w	d0
	move.w	#bplcon1,(a2)+	;plf 2=$f
	move.w	d0,(a2)+
	clr.l	d7
	move.w	scrcount,d7
	lsr.w	#3,d7
	move.w	#bpl1pth,d0
	move.l	scrmem1,d1
	add.l	d7,d1
	bsr	setbpl
	move.w	#bpl3pth,d0
	move.l	scrmem2,d1
	add.l	d7,d1
	bsr	setbpl
	move.w	#bpl5pth,d0
	move.l	scrmem3,d1
	add.l	d7,d1
	bsr	setbpl
	rts

next1:	move.w	#$d40b,d0	;legendary Ns Red Bars (C) NS
	move.w	#31,d1
	lea	colbar1,a1
next2:	move.w	d0,(a2)+
	move.w	#$fffe,(a2)+
	add.w	#$0100,d0
	move.w	#color00,(a2)+
	move.w	(a1)+,(a2)+
	lea	colbar2,a3	;Lets make some horizontal bars !!
	move.w	#42,d2
next3:	move.w	#color01,(a2)+
	move.w	(a3)+,(a2)+
	dbf	d2,next3

	dbf	d1,next2

leave:	move.l	#$fffffffe,(a2)	;end of copper list !!!!
	rts

*** color poiner in a1..coloraddr in d0..howmany in d1

setcol:	move.w	d0,(a2)+
	move.w	(a1)+,(a2)+
	addq.w	#2,d0
	dbf	d1,setcol
	rts

*** mem in d1....bpl in d0****

setbpl:	move.w	d0,(a2)+
	swap	d1
	move.w	d1,(a2)+
	swap	d1
	addq.w	#2,d0
	move.w	d0,(a2)+
	move.w	d1,(a2)+
	rts

*****************************************
;
;	d0-grad    d1-rad   d2-origo
;=>	d3-pos

getsin:	cmp.w	#360,d0		;test if spinn.
	ble.s	getsin2
	sub.w	#360,d0
	bra.s	getsin
getsin2:lea	sine,a0
	lsl.w	#1,d0
	move.w	(a0,d0),d3
	muls	d1,d3
	lsr.l	#7,d3
	add.l	d2,d3
	and.l	#$fff,d3
	rts

getcos:	cmp.w	#360,d0		;test if spinn.
	ble.s	getcos2
	sub.w	#360,d0
	bra.s	getcos
getcos2:lea	sine+180,a0
	lsl.w	#1,d0
	move.w	(a0,d0),d3
	muls	d1,d3
	lsr.l	#7,d3
	add.l	d2,d3
	and.l	#$fff,d3
	rts



********* Variables *************
; Data addresses
;
copmem:		dc.l	0
dmasaf:		dc.w	0
grlib:		dc.b	'graphics.library',0
		even
bobmem1:	dc.l	0
bobmem2:	dc.l	0	;memory for bobs
		dc.l	0
logoy:		dc.w	0	;logo y poss
		dc.l	0
agg1:		dc.l	0 	;memory pointer for copper
megaspr:	dc.l	0
sprcol:		dc.w	0,$fff,$aaa,$555	;color for stars
tom:		ds.w	40		;empty trash memory

** This is the scroll text, only use capital letters **
; use a "^" to start the scroll from the beginning.
; use one bit numbers below 31 to change speed ex 2,4,8,16 etc
; use "#" to make a pause.

scrtext:	dc.b	8,'NORTH STAR#'
		dc.b	16,'    AND   #'
		dc.b	8,'  SILENTS! #'
		dc.b	4,' PRESENTS A NEW '
		dc.b	'DEMO MADE FOR THE READERS OF EXCELLER 8'
		dc.b	' HOW TO MAKE AN AVERAGE DEMO.. FOR SOURCE '
		dc.b	'WITH COMMENTS PLUS ALL TOOLS USED SEND 10 MAXELL '
		dc.b	'MF2 DD DISKS IN AN UNOPENED PACKAGE TO'
		dc.b	' EXCELLER 8 '
		dc.b	'PROGRAMMING, '
		dc.b	2,'JULIG.7, 252 52 HELSINGBORG, SWEDEN... '
		dc.b	4,'THEN WE WILL SEND BACK ONE OF THE DISKS WITH '
		dc.b	'THE SOURCE !!!!        '
		dc.b	8,' H U R R Y   U P !!!!!!!    '
		dc.b	4,'IMPORTANT MESSAGE: MAHONEY,KAKTUS AND LORD VEGA IS '
		dc.b	'STILL NORTH STAR MEMBERS IN FACT MAHONEY AND KAKTUS '
		dc.b	'ARE THE NEW PROGRAMMING LEADERS SO IF YOU WANT TO '
		dc.b	'JOIN CONTACT THEM INSTEAD OF ATOM !!!        CALL OUR '
		dc.b	'BBS IN THE USA: '
		dc.b	2,'214 422 7378                   ^'
		even

scrmem1:	dc.l	0	;scroll memories
scrmem2:	dc.l	0
scrmem3:	dc.l	0
scradd:		dc.w	0
scrcount:	dc.w	0
scrpoint:	dc.l	scrtext
speed:		dc.w	1	;current scr speed
pause:		dc.w	0	;scr pause if not zero

colbar1:	dcb.w	4,0		; 3 red color bars
		dc.w	$555,$aaa,$fff,$aaa,$555
		dcb.w	5,0	
		dc.w	$555,$aaa,$fff,$aaa,$555
		dcb.w	5,0	
		dc.w	$555,$aaa,$fff,$aaa,$555,0,0,0,0,0

colbar2:	;horizontal grey scale
		dc.w	$000,$111,$222,$333
		dc.w	$444,$555,$666,$777
		dc.w	$888,$999,$aaa,$bbb
		dc.w	$ccc,$ddd,$eee,$fff
		dc.w	$eee,$ddd,$ccc,$bbb
		dc.w	$aaa,$999,$888,$777
		dc.w	$666,$555,$444,$333
		dc.w	$222,$111,$000,0,0

logograd:	dc.w	90	;grade for logo sin
wait1:		dc.w	300	;wait untill logo bumb
logoby:		dc.w	0	;ypos for colbar in logo

colbar3:	dc.w	$eee,$ddd,$ccc,$bbb	;colbar in logo
		dc.w	$aaa,$999,$888,$777
		dc.w	$666,$555,$444,$333
		dc.w	$222,$111,$000,0,0
		dc.w	$000,$111,$222,$333
		dc.w	$444,$555,$666,$777
		dc.w	$888,$999,$aaa,$bbb
		dc.w	$ccc,$ddd,$eee,$fff

bobshow:	ds.l	1		;pointer to bobmem to show in screen
bobwork:	ds.l	1		;work memory
clear1:		ds.l	50		;max bobs
clear2:		ds.l	50
clearp:		ds.l	1
boby:		ds.w	50		;vertical poss for bobs
bobx:		ds.w	50		;horizontal poss for bobs
bobsin:		ds.w	50
bobcos:		ds.w	50
frimem:		ds.b	60000*2

sat:		incbin	'coding:projects/source/oldnorthstardemo/sat'
nslogoraw:	equ	sat		;7456
bobraw:		equ	sat+7456	;68
bobmaskraw:	equ	sat+7524	;34
fontraw:	equ	sat+7558	;23056
sine:		equ	sat+30614	;900
slut:		equ	sat+31514

