scene.org File Archive

File download

<root>­/­mirrors­/­amigascne­/­Scrollers­/­C-Groupstext­/­Complex/Complex-SportMad.txt

File size:
42 256 bytes (41.27K)
File date:
2011-10-02 23:03:03
Download count:
all-time: 298

Preview

  drfff                       COMPLEX PRESENTS ANOTHER DEMO CALLED  r5d3'SPORTMAD'    pppc THIS IS PROPABLY THE FIRST DEMO FEATURING ACTUAL SOURCE CODE OF THE DEMO ITSELF ! re52 USE CURSOR KEYS TO SCROLL AROUND  SOURCE AND PRESS HELP TO r0afGET SOMEz EFFECTS... TRY ALSO YOUR MOUSE, RIGHT ONE FOR DEFAULT MOVEMENT.  THIS IS A NEW VERSION OF THE OVERLOAD'S MOONLIGHTNING DEMO, zRELEASED AT MARCH 1988,BEFORE THE INFAMOUS LAHTI-PARTY. r999PARTYGREETINGS GO TO ALL COMPLEX MEMBERS,rec0 MEXICAN BOYS  JA SIINAHAN NE SITTEN TARKEIMMAT OLIKIN . z      SIGNED ARNOLD , WE ARE HUNGRY !      




************************************
****          SportMad		****
*				   *
*	   Demo by Complex	   *		
* 				   *
* Code  : Arska			   *	
* Music : Walkman		   *	
* Graf  : Rubberbrain		   *	
*	  Cockatrice		   *
*				   *	
* Released at Scoopex & Byterapers *
* party at Iisalmi 10-13.08.1990   *	
*				   *
****   use cursor keys to move	****
************************************

>extern"font",f1
>extern"sportmad.s",stext
>extern"runner",runner

>extern"newmoon.bmap",moon
>extern"newfont",newfont
>extern"mod.trash-collector",mt_data


OpenLibrary=	-552
allocmem=	-198
freemem=	-210
disable=	-120
enable=		-126	

sclines=15


*****************************************
*					*
* Demo start				*
*					*
*****************************************


OpenLibs:
	move.l	4.w,a6
	jsr	disable(a6)	;multitasking off

	jsr	mt_init

	bsr	doline
	bsr	dotausta
	
	move.l	#75000,d0	;amount for planes
	move.l	#$10002,d1	;chip & clear
	jsr	allocmem(a6)
	move.l	d0,display
	beq	memexit

	move.l	#14200,d0	;scroll display
	move.l	#$10002,d1
	jsr	allocmem(a6)
	move.l	d0,newdisp
	beq	newmemexit

	clr.l	d0		;get old copperpos
	lea	GfxLibName,a1		
	jsr	OpenLibrary(a6)
	move.l	d0,a0
	move.l	$26(a0),oldcop
	move.l	#copperlist,$dff080
	
	bsr	initplanes
	bsr	initwater
	bsr	donewsini
	bsr	initmoon

	bsr	dosky
	bsr	initsprite

	move.l	newdisp(pc),a0
	lea	2408(a0),a0
	move.l	a0,scdisplay

	jsr	tmakefonts
	bsr	tinitpointers
	bsr	initlist

	move.l	#text,textpointer
	
	move.l	display(pc),a0
	add.l	#59996,a0
	move.l	a0,start
	lea	1152(a0),a0
	move.l	a0,textstart

	move.b	$dff00a,old
	move.b	$dff00b,xold

	move.w	#$8400,$dff096
	
	move.w	#-1,startfade

ffe:	cmp.b	#$80,$dff006
	bne.s	ffe


*****************************************
*					*
* Main loop				*
*					*
*****************************************


WaitMouseButton:

	move.w	#$ef,d0

f:	;move.w	#$f00,$dff180
	cmp.b	$dff006,d0
	bcc	f

	bsr	hscroll
	bsr	vmutka
	bsr	print
	bsr	stars
	bsr	mouse

	bsr	putmad
	bsr	keys
	bsr	tprint
	bsr	effects
	bsr	fade
	
	jsr	mt_music


	btst	#6,$bfe001
	bne.s	WaitMouseButton


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


Exit:
	move.l	oldcop(pc),$dff080

	move.l	4.w,a6
	move.l	#14200,d0
	move.l	newdisp,a1
	jsr	freemem(a6)

newmemexit:
	move.l	4.w,a6	
	move.l	#75000,d0
	move.l	display,a1
	jsr	freemem(a6)

memexit:
	move.w	#$8020,$dff096

	jsr	mt_end

	move.l	4.w,a6
	jsr	enable(a6)

	moveq	#0,d0	
	rts		;return to cli
	
			;dont worry,

	;-)		;be happy...


*****************************************
*					*
* Fade sinus colors			*
*					*
*****************************************


fade:	
	tst.w	startfade
	bne.s	monster
	rts
monster:
	moveq	#15,d0
	moveq	#15,d1
	and.w	cend(pc),d0
	and.w	cstart(pc),d1
	sub.w	d1,d0

	muls	cn(pc),d0
	divs	cf(pc),d0
	moveq	#15,d1
	and.w	cstart(pc),d1
	add.w	d1,d0		;b
	move.w	d0,b


	move.w	#$f0,d0	
	move.w	d0,d1
	and.w	cend(pc),d0
	and.w	cstart(pc),d1
	lsr.w	#4,d0
	lsr.w	#4,d1
	sub.w	d1,d0

	muls	cn(pc),d0
	divs	cf(pc),d0
	lsl.w	#4,d0
	move.w	#$f0,d1
	and.w	cstart(pc),d1
	add.w	d1,d0		;g
	move.w	d0,g

	move.w	#$f00,d0	
	move.w	d0,d1
	and.w	cend(pc),d0
	and.w	cstart(pc),d1
	lsr.w	#8,d0
	lsr.w	#8,d1
	sub.w	d1,d0

	muls	cn(pc),d0
	divs	cf(pc),d0
	lsl.w	#8,d0
	move.w	#$f00,d1
	and.w	cstart(pc),d1
	add.w	d1,d0		;r
	move.w	d0,r
;
	move.w	r(pc),d0
	or.w	g(pc),d0
	or.w	b(pc),d0
	move.w	d0,cnow
;
	move.w	cf(pc),d0
	cmp.w	cn(pc),d0
	bne.s	eehh
	clr.w	cn		
	clr.w	startfade
eehh:
	addq.w	#1,cn
;
	move.w	cnow(pc),d1	
	lea	fcolor+2(pc),a1
	move.w	d1,(a1)
	move.w	d1,4(a1)
	move.w	d1,8(a1)
	move.w	d1,12(a1)
	move.w	d1,16(a1)
	move.w	d1,20(a1)
	move.w	d1,24(a1)
	move.w	d1,28(a1)

	move.w	d1,32(a1)
	move.w	d1,36(a1)

	rts

cn:	dc.w	0
cf:	dc.w	30

r:	dc.w	0
g:	dc.w	0
b:	dc.w	0

cnow:	dc.w	0
cstart:	dc.w	$f00
cend:	dc.w	$00f


*****************************************
*					*
* Set source colors			*
*					*
*****************************************


effects:
	move.w	helpmode(pc),d0
	beq.s	nohell

	move.w	#$5000,scplane
	
	subq.w	#1,d0
	beq.s	col2
	

sourcecol=$ff

col1:
	lea	scol,a0
	move.w	#sourcecol,(a0)
	move.w	#$fff,4(a0)
	move.w	#$333,8(a0)
	move.w	#$555,12(a0)
	move.w	#$777,16(a0)
	move.w	#$aaa,20(a0)
	move.w	#$ccc,24(a0)
	move.w	#$fff,28(a0)

	rts

col2:	
	lea	scol,a0
	move.w	#sourcecol,(a0)
	move.w	#sourcecol,4(a0)
	move.w	#sourcecol,8(a0)
	move.w	#sourcecol,12(a0)
	move.w	#sourcecol,16(a0)
	move.w	#sourcecol,20(a0)
	move.w	#sourcecol,24(a0)
	move.w	#sourcecol,28(a0)

	rts

nohell:	move.w	#-1,pressed

	lea	scol,a0
	move.w	#$f,(a0)
	move.w	#$fff,4(a0)
	move.w	#$333,8(a0)
	move.w	#$555,12(a0)
	move.w	#$777,16(a0)
	move.w	#$aaa,20(a0)
	move.w	#$ccc,24(a0)
	move.w	#$fff,28(a0)

	move.w	#$4000,scplane
	rts

pressed:dc.w	0	


*****************************************
*					*
* Blit runner to screen			*
*					*
*****************************************


putmad:
	tst.w	waitrunner
	beq.s	doit
	rts
	
doit:
	lea	runner,a0
	move.l	display(pc),a1
	lea	5496(a1),a1	
	
	addq.w	#2,rx
	cmp.w	#400,rx
	bne.s	no400
	clr.w	rx
	move.w	#-1,waitrunner
no400:

	move.w	rx(pc),d0
	lsr.w	#3,d0
	add.w	d0,a1

	move.w	rx(pc),d0
	lsr.w	#3,d0
	and.w	#7,d0
	mulu	#486,d0
	add.w	d0,a0

	
	moveq	#$f,d0
	and.w	rx(pc),d0
	ror.w	#4,d0
	or.w	#$09f0,d0


	lea	$dff000,a6
	bsr	waitblit
	bsr	waitblit

	
	move.l	a0,$50(a6)	;A
	move.l	a1,$54(a6)	;D
	move.w	d0,$40(a6)	;bltcon 0
	move.w	#00,$42(a6)	;       1
	move.w	#00,$64(a6)	;A mod
	move.w	#44,$66(a6)	;D mod
	move.l	#-1,$44(a6)	;F,L Mask
	move.w	#27*64+3,$58(a6);start
	
	lea	14200(a1),a1
	bsr	waitblit
	bsr	waitblit

	move.l	a1,$54(a6)	;D
	move.w	#27*64+3,$58(a6);start

	lea	14200(a1),a1
	bsr	waitblit
	bsr	waitblit

	move.l	a1,$54(a6)	;D
	move.w	#27*64+3,$58(a6);start

	rts


waitblit:
	btst	#14,$dff002
	bne.s	waitblit
	rts


newdisp:	dc.l	0
scdisplay:	dc.l	0

old:		dc.w	0
xold:		dc.w	0
holdx:		dc.w	$48
holdy:		dc.w	$ffb0
rx:		dc.w	0
waitrunner:	dc.w	-1


*****************************************
*					*
* Read mouse, vittu se on rotta !	*
*					*
*****************************************


mouse:
	move.b	old(pc),d0
	move.b	$dff00a,d1
	move.b	d1,old
	sub.b	d0,d1
	ext.w	d1
	add.w	d1,holdx
	
	move.w	holdx(pc),d0
	asr.w	#3,d0
	ext.l	d0
	move.l	d0,tspeed


	move.b	xold(pc),d0
	move.b	$dff00b,d1
	move.b	d1,xold
	sub.b	d0,d1
	ext.w	d1
	add.w	d1,holdy
	
	move.w	holdy(pc),d0
	asr.w	#3,d0
	ext.l	d0
	move.l	d0,qspeed


	btst	#10,$dff016
	bne.s	normp

	move.w	#$48,holdx
	move.w	#$ffb4,holdy
	move.l	#9,tspeed
	move.l	#-10,qspeed

normp:
	rts


*****************************************
*					*
* Initialization			*
*					*
*****************************************


initmoon:
	lea	moon(pc),a0
	move.l	display(pc),a1
	lea	380(a1),a1	

	moveq	#2,d0
ml1:	move.l	a1,a2
	moveq	#98,d1
ml2:	moveq	#13,d2
ml3:	move.b	(a0)+,(a2)+
	dbf	d2,ml3
	lea	36(a2),a2
	dbf	d1,ml2
	lea	14200(a1),a1
	dbf	d0,ml1
	
	rts



initwater:
	lea	sini(pc),a0
	lea	water(pc),a1

	move.w	#255,d7
iloop:	move.b	(a0)+,d0
	ext.w	d0
	asr.w	#3,d0
	muls	#50,d0
	addq.w	#4,d0
	move.w	d0,(a1)+
	dbf	d7,iloop
	rts



donewsini:
	lea	sini(pc),a0
	lea	newsini(pc),a1

	move.l	#255,d7
siloop:	move.b	(a0)+,d0
	ext.w	d0
	asr.w	#2,d0
	muls	#50,d0
	sub.w	#11000,d0
	move.w	d0,(a1)+
	dbf	d7,siloop
	rts


*****************************************
*					*
* Water effect				*
*					*
*****************************************


;;
vmutka:
	lea	eka+6(pc),a3

	move.l	qspeed(pc),d0
	add.l	d0,alku
	move.l	alku(pc),d4
	move.l	tspeed(pc),d3
	lea	water(pc),a0
	add.w	d3,d3
	
	move.l	#16,a4
	
	move.w	#$1fe,d6;mask
	moveq	#0,d2	;last
	moveq	#96,d7

	moveq	#64,d5
doloop:	
	add.w	d3,d4
	move.w	d4,d0
	and.w	d6,d0	;mask
	move.w	(a0,d0.w),d0
	move.w	d0,d1	
	sub.w	d2,d0
	move.w	d0,(a3)	;modulo
	move.w	d0,4(a3);modulo
	add.l	a4,a3	;next copperl pos
	add.w	d7,d1	;next row

	add.w	d3,d4
	move.w	d4,d0
	and.w	d6,d0	;mask
	move.w	(a0,d0.w),d0
	move.w	d0,d2	
	sub.w	d1,d0
	move.w	d0,(a3)	;modulo
	move.w	d0,4(a3);modulo
	add.l	a4,a3	;next copperl pos
	add.w	d7,d2	;next row

	dbf	d5,doloop

	add.w	d3,d4	;131. time
	move.w	d4,d0
	and.w	d6,d0	;mask
	move.w	(a0,d0.w),d0
	move.w	d0,d1
	sub.w	d2,d0
	move.w	d0,(a3)	;modulo
	move.w	d0,4(a3);modulo

	rts	

water:	blk.w	256,0

alku:	dc.l	0
temp:	dc.l	0
qspeed:	dc.l	-10
tspeed:	dc.l	9


*****************************************
*					*
* Initialization			*
*					*
*****************************************


doline:
	lea	eka(pc),a0
	move.b	#$af,d1
	moveq	#79,d0
late:	move.b	d1,(a0)
	addq.b	#1,d1
	lea	16(a0),a0
	dbf	d0,late
	rts	


dotausta:
	lea	tausta(pc),a0
	move.b	#$9b,d7
	moveq	#19,d0
adjl:	move.b	d7,(a0)
	addq.b	#1,d7
	lea	8(a0),a0
	dbf	d0,adjl

	lea	colors(pc),a0
	lea	tausta+6(pc),a1
	moveq	#19,d0
adj2:	move.w	(a0)+,(a1)
	lea	8(a1),a1
	dbf	d0,adj2

	lea	eka+14,a1
	move.w	#130,d0
adj3:	move.w	(a0)+,(a1)
	lea	16(a1),a1
	dbf	d0,adj3

	move.w	#$3000,planes

	rts


*****************************************
*					*
* Sinus scroller			*
*					*
*****************************************


;;
next:	MACRO
	subq.b	#1,d3
	move.w	d3,d0
	add.w	d0,d0
	move.w	(a2,d0.w),d0
	lea	(a0,d0.w),a1
	ENDM	

blit0:	MACRO
	subq.b	#1,d3
	move.w	d3,d0
	add.w	d0,d0
	move.w	(a2,d0.w),d0
	lea	(a0,d0.w),a1
	move.l	a0,d0
	sub.l	d4,d0
	sub.l	d4,a1

	move.l	d0,(a4)		;A
	move.l	a1,(a5)		;D	
	move.w	#$09f0,-$10(a4)	;$40 bltcon 0
	move.w	#$c000,-$c(a4)	;$44 fmask
	move.w	#43*64+1,(a3)	;start
	ENDM	

blit1:	MACRO
	move.l	a0,(a4)		;A
	move.l	a1,(a6)		;B
	move.l	a1,(a5)		;D	
	move.w	d2,-$10(a4)	;$40 d=a or b
	move.w	#$3000,-$c(a4)	;$44 fmask
	move.w	d6,(a3)		;start
	ENDM	

blit2:	MACRO
	move.l	a0,(a4)		;A
	move.l	a1,(a6)		;B
	move.l	a1,(a5)		;D	
	move.w	#?1,-$c(a4)	;$44 fmask
	move.w	d6,(a3)		;start
	ENDM	

;;
hscroll:			;sinus scroll
	lea	$dff000,a6
	move.w	#-1,$46(a6)	;lmask
	move.l	#$300030,$64(a6);A&D mod
	move.w	#$30,$62(a6)	;B mod
	move.w	#$0dfc,d2	;d=a or b
	move.l	#600,d4		;cls area
	move.w	#0,$dff042	;bltcon 1

	addq.b	#2,st
	move.b	st(pc),sin
	move.b	sin(pc),d3
	and.w	#$ff,d3

	lea	newsini(pc),a2
	lea	$58(a6),a3	;blt size&start
	lea	$50(a6),a4	;a prt
	lea	$54(a6),a5	;d prt
	lea	$4c(a6),a6	;b prt

	move.l	start(pc),a0	;start
	lea	-46(a0),a0
	move.w	#24*64+1,d6	;size

	moveq	#22,d5

hloop:	blit0

	next
	blit1

	next	
	blit2 $0c00

	next	
	blit2 $0300

	next	
	blit2 $00c0

	next	
	blit2 $0030

	next	
	blit2 $000c

	next	
	blit2 $0003

	addq.l	#2,a0

	dbf	d5,hloop
	rts


st:	dc.l	0
hstart:	dc.l	0
sin:	dc.l	0
startfade: dc.w	0

*****************************************
*					*
* Scroller from 1988			*
*					*
*****************************************


print:
	tst.b	textpause
	beq.s	tcont	
	subq.b	#1,textpause
	tst.b	textpause
	bne.s	tcont2

	move.l	textpointer(pc),a0
	cmp.b	#'p',(a0)
	beq.s	tcont2
	move.l	lastspeed(pc),d0
	move.l	d0,textspeed
tcont2:
	rts

tcont:
	move.l	textpointer(pc),a0
	cmp.b	#'p',(a0)
	bne.s	jmcont1
	move.b	#50,textpause
	clr.l	textspeed
	addq.l	#1,textpointer
	rts	
jmcont1:
	cmp.b	#'r',(a0)
	bne	jmcont2

	moveq	#0,d0
	moveq	#0,d1
	move.b	1(a0),d0
	cmp.b	#'9',d0
	bhi.s	hex
	sub.b	#'0',d0
	bra.s	nohex
hex:	sub.b	#87,d0
nohex:	move.b	d0,d1
	lsl.l	#8,d1

	moveq	#0,d0
	move.b	2(a0),d0
	cmp.b	#'9',d0
	bhi.s	hex2
	sub.b	#'0',d0
	bra.s	nohex2
hex2:	sub.b	#87,d0
nohex2:	lsl.l	#4,d0
	or.b	d0,d1
	
	clr.l	d0
	move.b	3(a0),d0
	cmp.b	#'9',d0
	bhi.s	hex3
	sub.b	#'0',d0
	bra.s	nohex3
hex3:	sub.b	#87,d0
nohex3:	or.b	d0,d1

	move.w	cend(pc),cstart
	move.w	d1,cend		;color end
	move.w	#-1,startfade

	addq.l	#4,textpointer
	bra	print
jmcont2:
	cmp.b	#'a',(a0)
	bne.s	jmconta
	move.l	#1,textspeed
	move.l	#1,lastspeed
	addq.l	#1,textpointer
	bra	print
jmconta:
	cmp.b	#'b',(a0)
	bne.s	jmcontb
	move.l	#2,textspeed
	move.l	#2,lastspeed
	addq.l	#1,textpointer
	bra	print
jmcontb:
	cmp.b	#'c',(a0)
	bne.s	jmcontc
	move.l	#3,textspeed
	move.l	#3,lastspeed
	addq.l	#1,textpointer
	bra	print
jmcontc:
	cmp.b	#'d',(a0)
	bne.s	jmcontd
	move.l	#4,textspeed
	move.l	#4,lastspeed
	addq.l	#1,textpointer
	bra	print
jmcontd:
	cmp.b	#'e',(a0)
	bne.s	jmconte
	move.l	#6,textspeed
	move.l	#6,lastspeed
	addq.l	#1,textpointer
	bra	print
jmconte:
	cmp.b	#'f',(a0)
	bne.s	jmcontf
	move.l	#12,textspeed
	move.l	#12,lastspeed
	addq.l	#1,textpointer
	bra	print
jmcontf:
	cmp.b	#'z',(a0)
	bne.s	jmcontz
	clr.w	waitrunner
	addq.l	#1,textpointer
	bra	print
jmcontz:
	move.l	textspeed(pc),d0
	add.l	d0,textcount
	cmp.l	#23,textcount
	bls	pexit
	clr.l	textcount

	cmp.b	#$ff,(a0)
	bne.s	noend

	lea	text(pc),a0
	move.l	a0,textpointer
noend:
	moveq	#0,d0
	move.b	(a0),d0
	addq.l	#1,textpointer
	
	lea	newfont(pc),a2
	sub.w	#32,d0
	bgt.s	tcont22
	moveq	#0,d0
tcont22:
	mulu	#96,d0
	add.l	d0,a2
	
	move.l	start(pc),a0

	lea	$dff000,a1
wb1:	btst	#14,2(a1)
	bne.s	wb1

	move.l	a2,$50(a1)	;A
	move.l	a0,$54(a1)	;D
	move.w	#$09f0,$40(a1)	;bltcon 0
	move.w	#00,$42(a1)	;       1
	move.w	#00,$64(a1)	;A mod
	move.w	#46,$66(a1)	;D mod
	move.l	#-1,$44(a1)	;F,L Mask
	move.w	#24*64+2,$58(a1);start

pexit:
	move.l	textspeed(pc),d0
	ror.w	#4,d0
	or.w	#$09f0,d0

	move.l	textstart(pc),a0
	lea	$dff000,a1
wb2:	btst	#14,2(a1)
	bne.s	wb2

	move.l	a0,$50(a1)	;A
	move.l	a0,$54(a1)	;D
	move.w	d0,$40(a1)	;bltcon 0
	move.w	#2,$42(a1)	;       1
	move.l	#0,$64(a1)	;A,D mod
	move.l	#$fff00fff,$44(a1);F,L Mask
	move.w	#24*64+25,$58(a1) ;start
	rts


start:		dc.l	0
textstart:	dc.l	0
textpointer:	dc.l	0
textpause:	dc.l	0
textspeed:	dc.l	2
lastspeed:	dc.l	2
textcount:	dc.l	0

;--------------------------------------

text:

DC.B "  drfff                      "
DC.B " COMPLEX PRESENTS ANOTHER DEMO "
DC.B "CALLED  r5d3'SPORTMAD'    pppc "
DC.B "THIS IS PROPABLY THE FIRST DEMO "
DC.B "FEATURING ACTUAL SOURCE CODE OF "
DC.B "THE DEMO ITSELF ! re52 "
DC.B "USE CURSOR KEYS TO SCROLL AROUND "
DC.B " SOURCE AND PRESS HELP TO r0afGET "
DC.B "SOMEz EFFECTS... TRY ALSO YOUR "
DC.B "MOUSE, RIGHT ONE FOR DEFAULT "
DC.B "MOVEMENT.  THIS IS A NEW VERSION "
DC.B "OF THE OVERLOAD'S MOONLIGHTNING "
DC.B "DEMO, zRELEASED AT MARCH 1988,"
DC.B "BEFORE THE INFAMOUS LAHTI-PARTY. r999"
DC.B "PARTYGREETINGS GO TO ALL COMPLEX "
DC.B "MEMBERS,rec0 MEXICAN BOYS "
DC.B " JA SIINAHAN NE SITTEN"
DC.B " TARKEIMMAT OLIKIN . z"
DC.B "      SIGNED ARNOLD , WE ARE HUNGRY !      "
DC.B	$ff


*****************************************
*					*
* Pure sinus data!			*
*					*
*****************************************


even
sini:

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

even


*****************************************
*					*
* Initialize copperlist			*
*					*
*****************************************


initplanes:
	lea	hi1+2(pc),a0		;clist
	move.l	display(pc),d7		
	move.w	d7,4(a0)			
	swap	d7
	move.w	d7,(a0)
	swap	d7
	add.l	#14200,d7
	move.w	d7,12(a0)			
	swap	d7
	move.w	d7,8(a0)
	swap	d7
	add.l	#14200,d7
	move.w	d7,20(a0)			
	swap	d7
	move.w	d7,16(a0)
	swap	d7
	add.l	#14200,d7
	move.w	d7,28(a0)
	swap	d7
	move.w	d7,24(a0)

	move.l	newdisp(pc),d7
	add.l	#2004,d7	
	move.w	d7,36(a0)
	swap	d7
	move.w	d7,32(a0)
	
	rts	


*****************************************
*					*
* Copperlist				*
*					*
*****************************************


l:	MACRO		;copperlist macro
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0

dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
dc.w $4001,$ff00,$108,4,$10a,4,$180,0
	ENDM	

c:	MACRO		;copperlist macro
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0

dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
dc.w $4001,$ff00,$180,$f0
	ENDM


;	   R S M M M
; 	   5 4 3 2 1
;          | | | | |
; 00 $180  0 0 0 0 0	M
; 01 $182  0 0 0 0 1	M
; 02 $184  0 0 0 1 0	M
; 03 $186  0 0 0 1 1	M
; 04 $188  0 0 1 0 0	M
; 05 $18a  0 0 1 0 1	M
; 06 $18c  0 0 1 1 0 	M
; 07 $18e  0 0 1 1 1	M

; 	   5 4 3 2 1
;          | | | | |
; 08 $190  0 1 0 0 0
; 09 $192  0 1 0 0 1 
; 10 $194  0 1 0 1 0
; 11 $196  0 1 0 1 1
; 12 $198  0 1 1 0 0 
; 13 $19a  0 1 1 0 1
; 14 $19c  0 1 1 1 0
; 15 $19e  0 1 1 1 1

; 	   5 4 3 2 1
;          | | | | |
; 16 $1a0  1 0 0 0 0
; 17 $1a2  1 0 0 0 1
; 18 $1a4  1 0 0 1 0
; 19 $1a6  1 0 0 1 1
; 20 $1a8  1 0 1 0 0
; 21 $1aa  1 0 1 0 1
; 22 $1ac  1 0 1 1 0 
; 23 $1ae  1 0 1 1 1

; 	   5 4 3 2 1
;          | | | | |
; 24 $1b0  1 1 0 0 0
; 25 $1b2  1 1 0 0 1 
; 26 $1b4  1 1 0 1 0
; 27 $1b6  1 1 0 1 1
; 28 $1b8  1 1 1 0 0 
; 29 $1ba  1 1 1 0 1
; 30 $1bc  1 1 1 1 0
; 31 $1be  1 1 1 1 1


copperlist:
hi1:	dc.w	$e0,0,$e2,0,$e4,0,$e6,0
	dc.w	$e8,0,$ea,0,$ec,0,$ee,0
	dc.w	$f0,0,$f2,0		
	
				;bitplane
				;pointers


shi0:	dc.w	$120,0,$122,0,$124,0,$126,0
	dc.w	$128,0,$12a,0,$12c,0,$12e,0
	dc.w	$130,0,$132,0,$134,0,$136,0
	dc.w	$138,0,$13a,0,$13c,0,$13e,0
					
				;sprite pointers



	dc.w	$008e,$1c81	;diwstart
	dc.w	$0090,$37e1	;diwstop

	dc.w	$0092,$0028	;dffstart
	dc.w	$0094,$00e2	;dffstop

	dc.w	$0108,$0004	;modulos
	dc.w	$010a,$0004

	dc.w	$0100	
scplane:dc.w	$5000		;bitplanes
	dc.w	$0104,$0000

	dc.w	$0180,$0000	;colors
	dc.w	$0182,$0111
	dc.w	$0184,$0333
	dc.w	$0186,$0555
	dc.w	$0188,$0777
	dc.w	$018a,$0aaa
	dc.w	$018c,$0ccc
	dc.w	$018e,$0fff

	dc.w	$01a0,
scol:	dc.w	$0004		;teksti	
	dc.w	$01a2,$0fff	;stars
	dc.w	$01a4,$0333
	dc.w	$01a6,$0555
	dc.w	$01a8,$0777
	dc.w	$01aa,$0aaa
	dc.w	$01ac,$0ccc
	dc.w	$01ae,$0fff
	
	dc.w	$01b0,$0000
	dc.w	$01b2,$0111
	dc.w	$01b4,$0333
	dc.w	$01b6,$0555
	dc.w	$01b8,$0777
	dc.w	$01ba,$0aaa
	dc.w	$01bc,$0ccc
	dc.w	$01be,$0fff

	dc.w	$2401,$ff00
	dc.w	$01a0,$22
	dc.w	$2501,$ff00
	dc.w	$01a0,$44
	dc.w	$2601,$ff00
	dc.w	$01a0,$66
	dc.w	$2701,$ff00
	dc.w	$01a0,$88
	dc.w	$2801,$ff00
	dc.w	$01a0,$aa
	dc.w	$2901,$ff00
	dc.w	$01a0,$cc
	dc.w	$2a01,$ff00
	dc.w	$01a0,$ee

fcolor:	dc.w	$0190,$0ff0	;yla
	dc.w	$0192,$0ff0	;main		
	dc.w	$0194,$0ff0
	dc.w	$0196,$0ff0
	dc.w	$0198,$0ff0	
	dc.w	$019a,$0ff0
	dc.w	$019c,$0ff0	
	dc.w	$019e,$0ff0
	dc.w	$01b0,$0ff0
	dc.w	$01b2,$0ff0	
			;reserved till here!
			;awful grammar Arnie!  - RB


	dc.w	$9601,$ff00
	dc.w	$01a0,$cc
	dc.w	$9701,$ff00
	dc.w	$01a0,$aa
	dc.w	$9801,$ff00
	dc.w	$01a0,$88
	dc.w	$9901,$ff00
	dc.w	$01a0,$66
	dc.w	$9a01,$ff00
	dc.w	$01a0,$44
	dc.w	$9b01,$ff00
	dc.w	$01a0,$22
	dc.w	$9c01,$ff00
	dc.w	$01a0,$00
	

	dc.w	$9b01,$ff00


tausta:
	c
	c

	dc.w	$0100,$4000	;4 bitplanes
	
	
eka:	l
	l
	l
	l

	l
	l
	l
	l

dc.w	$ff01,$ff00,$108,4,$10a,4,$180,0

dc.w	$ffdd,$fffe,$108,4,$10a,4,$0100
planes:	dc.w	4


dc.w	$0101,$ff00,$108,4,$10a,4,$180,0
dc.w	$0201,$ff00,$108,4,$10a,4,$180,0
dc.w	$0301,$ff00,$108,4,$10a,4,$180,0
dc.w	$0401,$ff00,$108,4,$10a,4,$180,0
dc.w	$0501,$ff00,$108,4,$10a,4,$180,0
dc.w	$0601,$ff00,$108,4,$10a,4,$180,0
dc.w	$0701,$ff00,$108,4,$10a,4,$180,0
dc.w	$0801,$ff00,$108,4,$10a,4,$180,0
dc.w	$0901,$ff00,$108,4,$10a,4,$180,0
dc.w	$0a01,$ff00,$108,4,$10a,4,$180,0
dc.w	$0b01,$ff00,$108,4,$10a,4,$180,0
dc.w	$0c01,$ff00,$108,4,$10a,4,$180,0
dc.w	$0d01,$ff00,$108,4,$10a,4,$180,0
dc.w	$0e01,$ff00,$108,4,$10a,4,$180,0
dc.w	$0f01,$ff00,$108,4,$10a,4,$180,0


dc.w	$1001,$ff00,$108,4,$10a,4,$180,0
dc.w	$1101,$ff00,$108,4,$10a,4,$180,0
dc.w	$1201,$ff00,$108,4,$10a,4,$180,0
dc.w	$1301,$ff00,$108,4,$10a,4,$180,0
dc.w	$1401,$ff00,$108,4,$10a,4,$180,0
dc.w	$1501,$ff00,$108,4,$10a,4,$180,0
dc.w	$1601,$ff00,$108,4,$10a,4,$180,0
dc.w	$1701,$ff00,$108,4,$10a,4,$180,0
dc.w	$1801,$ff00,$108,4,$10a,4,$180,0
dc.w	$1901,$ff00,$108,4,$10a,4,$180,0
dc.w	$1a01,$ff00,$108,4,$10a,4,$180,0
dc.w	$1b01,$ff00,$108,4,$10a,4,$180,0
dc.w	$1c01,$ff00,$108,4,$10a,4,$180,0
dc.w	$1d01,$ff00,$108,4,$10a,4,$180,0
dc.w	$1e01,$ff00,$108,4,$10a,4,$180,0
dc.w	$1f01,$ff00,$108,4,$10a,4,$180,0

dc.w	$2001,$ff00,$108,4,$10a,4,$180,0
dc.w	$2101,$ff00,$108,4,$10a,4,$180,0
dc.w	$2201,$ff00,$108,4,$10a,4,$180,0
dc.w	$2301,$ff00,$108,4,$10a,4,$180,0
dc.w	$2401,$ff00,$108,4,$10a,4,$180,0
dc.w	$2501,$ff00,$108,4,$10a,4,$180,0
dc.w	$2601,$ff00,$108,4,$10a,4,$180,0
dc.w	$2701,$ff00,$108,4,$10a,4,$180,0
dc.w	$2801,$ff00,$108,4,$10a,4,$180,0
dc.w	$2901,$ff00,$108,4,$10a,4,$180,0
dc.w	$2a01,$ff00,$108,4,$10a,4,$180,0
dc.w	$2b01,$ff00,$108,4,$10a,4,$180,0
dc.w	$2c01,$ff00,$108,4,$10a,4,$180,0
dc.w	$2d01,$ff00,$108,4,$10a,4,$180,0
dc.w	$2e01,$ff00,$108,4,$10a,4,$180,0
dc.w	$2f01,$ff00,$108,4,$10a,4,$180,0
dc.w	$3001,$ff00,$108,4,$10a,4,$180,0

dc.w	$3101,$ff00,$108,4,$10a,4,$180,0

dc.w	$0180,$f

dc.w	$ffff,$fffe		;end clist


*****************************************
*					*
* Variables and constants		*
*					*
*****************************************


GfxLibName:
	dc.b	'graphics.library',0
	
	even
oldcop:		dc.l	0
display:	dc.l	0

colors:
	;blk.w	60,0		;upper part (sky)
	
	blk.w   02,$0000	;lower part (horizon)
	blk.w	1,$0101
	blk.w	1,$0100
	blk.w   03,$0101
	blk.w	1,$0102
	blk.w	1,$0101
	blk.w   04,$0102
	blk.w	1,$0103
	blk.w	1,$0102
	blk.w   05,$0103
	blk.w	1,$0104
	blk.w	1,$0103
	blk.w   06,$0104
	blk.w	1,$0105
	blk.w	1,$0104
	blk.w   07,$0105
	blk.w	1,$0106
	blk.w	1,$0105
	blk.w   08,$0106
	blk.w	1,$0007
	blk.w	1,$0106
	blk.w   09,$0007
	blk.w	1,$0008
	blk.w	1,$0007
	blk.w   10,$0008
	blk.w	1,$0009
	blk.w	1,$0008
	blk.w   11,$0009
	blk.w	1,$000a
	blk.w	1,$0009
	blk.w   12,$000a
	blk.w	1,$000b
	blk.w	1,$000a
	blk.w   13,$000b
	blk.w	1,$000c
	blk.w	1,$000b
	blk.w   14,$000c
	blk.w	1,$000d
	blk.w	1,$000c
	blk.w   15,$000d
	blk.w	1,$000e
	blk.w	1,$000d
	blk.w   16,$000e
	blk.w	1,$000f
	blk.w	1,$000e
	blk.w	17,$000f

	blk.w	30,$f		;end of colors
	
newfont:	blk.b	5800,0
moon:		blk.b	4158,0	
newsini:	blk.w	256,1


*****************************************
*					*
* Starfield				*
*					*
*****************************************


stars:
	lea	sprite0+1(pc),a0

	subq.b	#1,(a0)
	subq.b	#2,8(a0)
	subq.b	#3,16(a0)
	subq.b	#1,24(a0)
	subq.b	#2,32(a0)
	subq.b	#3,40(a0)
	subq.b	#1,48(a0)
	subq.b	#2,56(a0)
	subq.b	#3,64(a0)
	subq.b	#1,72(a0)
	subq.b	#2,80(a0)
	subq.b	#3,88(a0)
	subq.b	#1,96(a0)
	subq.b	#2,104(a0)
	subq.b	#3,112(a0)
	subq.b	#1,120(a0)
	subq.b	#2,128(a0)
	subq.b	#3,136(a0)
	subq.b	#1,144(a0)
	subq.b	#2,152(a0)
	subq.b	#3,160(a0)
	subq.b	#1,168(a0)
	subq.b	#2,176(a0)
	subq.b	#3,184(a0)
	subq.b	#1,192(a0)

	subq.b	#2,200(a0)
	subq.b	#3,208(a0)
	subq.b	#1,216(a0)
	subq.b	#2,224(a0)
	subq.b	#3,232(a0)
	subq.b	#1,240(a0)
	subq.b	#2,248(a0)
	subq.b	#3,256(a0)
	subq.b	#1,264(a0)
	subq.b	#2,272(a0)
	subq.b	#3,280(a0)
	subq.b	#1,288(a0)
	subq.b	#2,296(a0)
	subq.b	#3,304(a0)
	subq.b	#1,312(a0)
	subq.b	#2,320(a0)
	subq.b	#3,328(a0)
	subq.b	#1,336(a0)
	subq.b	#2,344(a0)
	subq.b	#3,352(a0)
	subq.b	#1,360(a0)
	subq.b	#2,368(a0)
	subq.b	#3,376(a0)
	subq.b	#1,384(a0)
	subq.b	#2,392(a0)

	rts


*****************************************
*					*
* Sprite initialization			*
*					*
*****************************************


dosky:
	lea	sprite0(pc),a0

	moveq	#0,d2
	moveq	#$36,d0		;start y
	moveq	#49,d1		;stars
dsl:	
	add.b	$dff006,d2
	addq.b	#3,lask
	add.b	lask(pc),d2
	move.b	d0,(a0)+
	move.b	d2,(a0)+
	addq.b	#1,d0
	move.b	d0,(a0)+
	addq.b	#1,d0
	move.b	#$01,(a0)+

	move.w	#1,(a0)+
	move.w	#0,(a0)+
			
	dbf	d1,dsl

	move.l	#0,(a0)+
	
	rts

lask:	dc.w	0

;---------------------------------------------

sprite0:
	blk.b	400,-1
	dc.l	0		;end data


;---------------------------------------------

initsprite:
	move.w	#$8020,$dff096	;sprite dma on

	lea	shi0+2(pc),a0

	move.l	#sprite0,d7
	move.w	d7,4(a0)
	swap 	d7
	move.w	d7,(a0)
	addq.l	#8,a0

	move.l	#dummy,d7
	moveq	#6,d0
spil:	move.w	d7,4(a0)
	swap	d7
	move.w	d7,(a0)
	swap	d7
	addq.l	#8,a0
	dbf	d0,spil	

	rts

dummy:	dc.l	0


*****************************************
*					*
* Routines to print source		*
*					*
*****************************************


x:	dc.w	0
y:	dc.w	0
prevy:	dc.w	0
line:	dc.w	0
dir:	dc.w	0

yla:	dc.l	0
ala:	dc.l	0


tinitpointers:
	lea	stext(pc),a0
	move.l	a0,yla

	moveq	#sclines-2,d0
ipl:	cmp.b	#$0a,(a0)+
	bne.s	ipl
	dbf	d0,ipl

	move.l	a0,ala
	rts


*****************************************
*					*
* Read keyboard				*
*					*
*****************************************


repdelay=20

keys:
	clr.w	dir	

	btst 	#3,$dff01f
	beq.L 	nopress
	
	tst.w	keydown
	beq.s	nodd
	move.w	#repdelay,repeat
	
nodd:	
	moveq	#0,d0
	move.b 	$bfed01,d0
	move.b 	$bfec01,d0
	
	move.b 	#$d0,$bfee01
	moveq	#100,d1
kbp:	dbf	d1,kbp
	move.b 	#$90,$bfee01

	move.w 	#$08,$dff09c
	move.b	d0,prevkey
	bsr	testkey

	rts

nopress:
	clr.w	keyhit

	tst.w	keydown
	beq.s	nojee	
	
	tst.w	repeat
	beq.s	nojeah
	subq.w	#1,repeat
	rts

nojeah:				;begin repeating
	move.w	#-1,repon
	move.b	prevkey(pc),d0
	bsr	testkey
	clr.w	repon
nojee:
	rts

repon:	dc.w	0
prevkey:dc.w	0
repeat:	dc.w	0
keydown:dc.w	0
keyhit:	dc.w	0	
helpmode:dc.w	2

testkey:
	clr.w	keydown
	btst	#0,d0
	beq.s	kkk
	move.w	#1,keydown


kkk:	btst	#0,d0
	beq	nokey

	not.b	d0
	lsr.b	#1,d0

;--------------------------

	cmp.b	#$4c,d0
	bne.s	no_up		;up
	move.w	#1,dir

no_up:	cmp.b	#$4d,d0		;down
	bne.s	no_down
	move.w	#-1,dir
no_down:

;--------------------------
	
	tst.w	repon
	bne.s	nohelp		;no repeat
	cmp.b	#$5f,d0
	bne.s	nohelp		;help
	
	addq.w	#1,helpmode
	cmp.w	#3,helpmode
	bne.s	nohelp
	clr.w	helpmode

nohelp:	
;--------------------------
	move.w	#-1,keyhit

nokey:	
	rts



*****************************************
*					*
* Scroll source 			*
*					*
*****************************************


tprint:
	lea	$dff000,a6
	move.w	#$8400,$96(a6)

	move.w	dir(pc),d0
	bne.s	siirto
	rts

siirto:	tst.w	d0
	bmi	dwn

	cmp.w	#$9c5,line
	blt.s	mov_up
	rts

mov_up:	
	move.l	scdisplay(pc),a0
wbl:	btst	#14,2(a6)
	bne.s	wbl
	

scok:	move.l	a0,$54(a6)	;d
	lea	400(a0),a0
	move.l	a0,$50(a6)	;a
	move.w	#$9f0,$40(a6)
	move.w	#0,$42(a6)
	move.l	#-1,$44(a6)	;masks
	move.l	#$a000a,$64(a6)	;ad mod
	move.w	#sclines+1*8*64+20,$58(a6);go
	
	addq.w	#1,line

	move.l	yla(pc),a0
l1:	cmp.b	#$0a,(a0)+
	bne.s	l1
	move.l	a0,yla

	move.l	ala(pc),a0
lff:	cmp.b	#$0a,(a0)+
	bne.s	lff
	move.l	a0,ala
	

	move.l	scdisplay(pc),a1
	lea	sclines*400(a1),a1

	bsr	cls

	move.w	#0,x
	move.w	#sclines-1,y
	bsr	prtline

	rts
	

dwn:	move.l	scdisplay(pc),a0
	lea	sclines-1*400(a0),a0
	lea	-12(a0),a0

wbl2:	btst	#14,2(a6)
	bne.s	wbl2

	tst.w	line
	bne.s	dok
	rts

dok:	move.l	a0,$50(a6)	;d
	lea	400(a0),a0
	move.l	a0,$54(a6)	;a
	move.w	#$9f0,$40(a6)
	move.w	#2,$42(a6)	;pakki
	move.l	#-1,$44(a6)	;masks
	move.l	#$a000a,$64(a6)	;ad mod
	move.w	#sclines*8*64+20,$58(a6);go

	subq.w	#1,line

	move.l	ala(pc),a0
	subq.l	#1,a0
l2:	cmp.b	#$0a,-(a0)
	bne.s	l2
	addq.l	#1,a0
	move.l	a0,ala
	
	move.l	yla(pc),a0
	subq.l	#1,a0
l3:	cmp.b	#$0a,-(a0)
	bne.s	l3
	addq.l	#1,a0
	move.l	a0,yla

	move.l	scdisplay(pc),a1
	lea	400(a1),a1

	bsr	cls

	moveq	#0,d0
	move.w	d0,x
	move.w	d0,y
	bsr	prtline

	rts


;----------------------------------------

cls:			;clear print area
	moveq	#0,d0
	move.l	d0,d1
	move.l	d0,d2
	move.l	d0,d3
	move.l	d0,d4
	move.l	d0,d5
	move.l	d0,d6
	move.l	d0,d7

	move.l	d0,a2
	move.l	d0,a3
	move.l	d0,a4
	move.l	d0,a5

	
waitb:	btst	#14,2(a6)
	bne.s	waitb
	
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	movem.l	d0-d7/a2-a5,-(a1)
	
	movem.l	d0-d3,-(a1)
	
	rts


;---------------------------------------------

initlist:	;print first listing to screen

	clr.w	x
	clr.w	y

	lea	stext(pc),a0
	
	moveq	#sclines-1,d7
pll:	bsr	prtline
	dbf	d7,pll
	
	rts


*****************************************
*					*
*  This prints one line source code	*
*					*
*****************************************


tempsc:	dc.l	0

prtline:
	move.l	scdisplay(pc),a2
	move.w	#8*50,d1
	mulu	y(pc),d1
	add.l	d1,a2
	move.l	a2,tempsc	;line address


printline:
	moveq	#0,d0
	move.b	(a0)+,d0	;get char
	cmp.b	#$0a,d0		;enter ?
	bne.s	noent
	move.w	#0,x
	addq.w	#1,y	
	rts

noent:	cmp.b	#$09,d0		;tab ?
	bne.s	notab

	move.w	x(pc),d1
	addq.w	#8,d1
	and.w	#$fff8,d1
	move.w	d1,x
	bra.s	printline

notab:	sub.w	#32,d0
	lsl.w	#3,d0		;d0*8	

	move.l	tempsc(pc),a2

	move.w	x(pc),d2
	addq.w	#1,x
	move.w	d2,d1
	add.w	d2,d2
	add.w	add_table(pc,d2.w),a2

	and.w	#3,d1
	beq	dozero
	subq.w	#1,d1
	beq	do_one	
	subq.w	#1,d1
	beq	do_two

do_three:	
	lea	f6(pc),a1
	add.w	d0,a1
	bsr	do_or

	bra	printline


add_table:
dc.w 00,00,01,02,03,03,04,05,06,06
dc.w 07,08,09,09,10,11,12,12,13,14
dc.w 15,15,16,17,18,18,19,20,21,21
dc.w 22,23,24,24,25,26,27,27,28,29
dc.w 30,30,31,32,33,33,34,35,36,36
dc.w 37,38,39,39,40,41,42,42,43,44
dc.w 45,45,46,47,48,48,49,50,51,51
dc.w 52,53,54,54,55,56,57,57,58,59


do_two:
	lea	f4(pc),a1
	add.w	d0,a1
	bsr	do_or
	
	lea	f5(pc),a1
	add.w	d0,a1
	addq.l	#1,a2
	bsr	do_move

	bra	printline

do_one:
	lea	f2(pc),a1
	add.w	d0,a1
	bsr	do_or
	
	lea	f3(pc),a1
	add.w	d0,a1
	addq.l	#1,a2
	bsr	do_move
		
	bra	printline

	
dozero:
	lea	f1(pc),a1
	add.w	d0,a1
	bsr	do_move

	bra	printline


do_move:		;put font to screen
	move.b	(a1)+,(a2)
	move.b	(a1)+,50(a2)
	move.b	(a1)+,100(a2)
	move.b	(a1)+,150(a2)
	move.b	(a1)+,200(a2)
	move.b	(a1)+,250(a2)
	move.b	(a1)+,300(a2)
	move.b	(a1)+,350(a2)

	rts


do_or:	move.b	(a1)+,d1;put font to screen
	or.b	d1,(a2)
	move.b	(a1)+,d1
	or.b	d1,50(a2)
	move.b	(a1)+,d1
	or.b	d1,100(a2)
	move.b	(a1)+,d1
	or.b	d1,150(a2)
	move.b	(a1)+,d1
	or.b	d1,200(a2)
	move.b	(a1)+,d1
	or.b	d1,250(a2)
	move.b	(a1)+,d1
	or.b	d1,300(a2)
	move.b	(a1)+,d1
	or.b	d1,350(a2)
	
	rts


;------------------------------------------------

f1:	blk.b	960,0
f2:	blk.b	960,0
f3:	blk.b	960,0
f4:	blk.b	960,0
f5:	blk.b	960,0
f6:	blk.b	960,0

;00000000 11111111 00000000	bytes
;11111100 00001111 11000000	fonts
;|     |  |   |    | |
;1     2  3   4    5 6		f123456
 

*****************************************
*					*
* Shif 5 new fonts			*
*					*
*****************************************


tmakefonts:	

	lea	f1(pc),a0	;make font 6
	lea	f6(pc),a1	
	move.w	#959,d7
mf6:	move.b	(a0)+,d0
	lsr.b	#2,d0
	move.b	d0,(a1)+
	dbf	d7,mf6

	lea	f1(pc),a0	;make font 5
	lea	f5(pc),a1	
	move.w	#959,d7
mf5:	move.b	(a0)+,d0
	lsl.b	#4,d0
	move.b	d0,(a1)+
	dbf	d7,mf5

	lea	f1(pc),a0	;make font 4
	lea	f4(pc),a1	
	move.w	#959,d7
mf4:	move.b	(a0)+,d0
	lsr.b	#4,d0
	move.b	d0,(a1)+
	dbf	d7,mf4

	lea	f1(pc),a0	;make font 3
	lea	f3(pc),a1	
	move.w	#959,d7
mf3:	move.b	(a0)+,d0
	lsl.b	#2,d0
	move.b	d0,(a1)+
	dbf	d7,mf3

	lea	f1(pc),a0	;make font 2
	lea	f2(pc),a1	
	move.w	#959,d7
mf2:	move.b	(a0)+,d0
	lsr.b	#6,d0
	move.b	d0,(a1)+
	dbf	d7,mf2

	rts


	dc.w	$0a0a
stext:	blk.b	39200,$0a
even

runner:	blk.b	3888,$00


mt_init:lea	mt_data,a0
	move.l	a0,a1
	add.l	#$3b8,a1
	moveq	#$7f,d0
	moveq	#0,d1
mt_loop:move.l	d1,d2
	subq.w	#1,d0
mt_lop2:move.b	(a1)+,d1
	cmp.b	d2,d1
	bgt.s	mt_loop
	dbf	d0,mt_lop2
	addq.b	#1,d2

	lea	mt_samplestarts(pc),a1
	asl.l	#8,d2
	asl.l	#2,d2
	add.l	#$43c,d2
	add.l	a0,d2
	move.l	d2,a2
	moveq	#$1e,d0
mt_lop3:clr.l	(a2)
	move.l	a2,(a1)+
	moveq	#0,d1
	move.w	42(a0),d1
	asl.l	#1,d1
	add.l	d1,a2
	add.l	#$1e,a0
	dbf	d0,mt_lop3

	or.b	#$2,$bfe001
	move.b	#$6,mt_speed
	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	clr.b	mt_songpos
	clr.b	mt_counter
	clr.w	mt_pattpos
	rts

mt_end:	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	move.w	#$f,$dff096
	rts

mt_music:
	movem.l	d0-d4/a0-a3/a5-a6,-(a7)
	lea	mt_data,a0
	addq.b	#$1,mt_counter
	move.b	mt_counter,D0
	cmp.b	mt_speed,D0
	blt.s	mt_nonew
	clr.b	mt_counter
	bra	mt_getnew

mt_nonew:
	lea	mt_voice1(pc),a6
	lea	$dff0a0,a5
	bsr	mt_checkcom
	lea	mt_voice2(pc),a6
	lea	$dff0b0,a5
	bsr	mt_checkcom
	lea	mt_voice3(pc),a6
	lea	$dff0c0,a5
	bsr	mt_checkcom
	lea	mt_voice4(pc),a6
	lea	$dff0d0,a5
	bsr	mt_checkcom
	bra	mt_endr

mt_arpeggio:
	moveq	#0,d0
	move.b	mt_counter,d0
	divs	#$3,d0
	swap	d0
	cmp.w	#$0,d0
	beq.s	mt_arp2
	cmp.w	#$2,d0
	beq.s	mt_arp1

	moveq	#0,d0
	move.b	$3(a6),d0
	lsr.b	#4,d0
	bra.s	mt_arp3
mt_arp1:moveq	#0,d0
	move.b	$3(a6),d0
	and.b	#$f,d0
	bra.s	mt_arp3
mt_arp2:move.w	$10(a6),d2
	bra.s	mt_arp4
mt_arp3:asl.w	#1,d0
	moveq	#0,d1
	move.w	$10(a6),d1
	lea	mt_periods(pc),a0
	moveq	#$24,d7
mt_arploop:
	move.w	(a0,d0.w),d2
	cmp.w	(a0),d1
	bge.s	mt_arp4
	addq.l	#2,a0
	dbf	d7,mt_arploop
	rts
mt_arp4:move.w	d2,$6(a5)
	rts

mt_getnew:
	lea	mt_data,a0
	move.l	a0,a3
	move.l	a0,a2
	add.l	#$c,a3
	add.l	#$3b8,a2
	add.l	#$43c,a0

	moveq	#0,d0
	move.l	d0,d1
	move.b	mt_songpos,d0
	move.b	(a2,d0.w),d1
	asl.l	#8,d1
	asl.l	#2,d1
	add.w	mt_pattpos,d1
	clr.w	mt_dmacon

	lea	$dff0a0,a5
	lea	mt_voice1(pc),a6
	bsr.s	mt_playvoice
	lea	$dff0b0,a5
	lea	mt_voice2(pc),a6
	bsr.s	mt_playvoice
	lea	$dff0c0,a5
	lea	mt_voice3(pc),a6
	bsr.s	mt_playvoice
	lea	$dff0d0,a5
	lea	mt_voice4(pc),a6
	bsr.s	mt_playvoice
	bra	mt_setdma

mt_playvoice:
	move.l	(a0,d1.l),(a6)
	addq.l	#4,d1
	moveq	#0,d2
	move.b	$2(a6),d2
	and.b	#$f0,d2
	lsr.b	#4,d2
	move.b	(a6),d0
	and.b	#$f0,d0
	or.b	d0,d2
	tst.b	d2
	beq.s	mt_setregs
	moveq	#0,d3
	lea	mt_samplestarts(pc),a1
	move.l	d2,d4
	subq.l	#$1,d2
	asl.l	#2,d2
	mulu	#$1e,d4
	move.l	(a1,d2.l),$4(a6)
	move.w	(a3,d4.l),$8(a6)
	move.w	$2(a3,d4.l),$12(a6)
	move.w	$4(a3,d4.l),d3
	tst.w	d3
	beq.s	mt_noloop
	move.l	$4(a6),d2
	asl.w	#1,d3
	add.l	d3,d2
	move.l	d2,$a(a6)
	move.w	$4(a3,d4.l),d0
	add.w	$6(a3,d4.l),d0
	move.w	d0,8(a6)
	move.w	$6(a3,d4.l),$e(a6)
	move.w	$12(a6),$8(a5)
	bra.s	mt_setregs
mt_noloop:
	move.l	$4(a6),d2
	add.l	d3,d2
	move.l	d2,$a(a6)
	move.w	$6(a3,d4.l),$e(a6)
	move.w	$12(a6),$8(a5)
mt_setregs:
	move.w	(a6),d0
	and.w	#$fff,d0
	beq	mt_checkcom2
	move.b	$2(a6),d0
	and.b	#$F,d0
	cmp.b	#$3,d0
	bne.s	mt_setperiod
	bsr	mt_setmyport
	bra	mt_checkcom2
mt_setperiod:
	move.w	(a6),$10(a6)
	and.w	#$fff,$10(a6)
	move.w	$14(a6),d0
	move.w	d0,$dff096
	clr.b	$1b(a6)

	move.l	$4(a6),(a5)
	move.w	$8(a6),$4(a5)
	move.w	$10(a6),d0
	and.w	#$fff,d0
	move.w	d0,$6(a5)
	move.w	$14(a6),d0
	or.w	d0,mt_dmacon
	bra	mt_checkcom2

mt_setdma:
	move.w	#$12c,d0
mt_wait:dbf	d0,mt_wait
	move.w	mt_dmacon,d0
	or.w	#$8000,d0
	move.w	d0,$dff096
	move.w	#$12c,d0
mt_wai2:dbf	d0,mt_wai2
	lea	$dff000,a5
	lea	mt_voice4(pc),a6
	move.l	$a(a6),$d0(a5)
	move.w	$e(a6),$d4(a5)
	lea	mt_voice3(pc),a6
	move.l	$a(a6),$c0(a5)
	move.w	$e(a6),$c4(a5)
	lea	mt_voice2(pc),a6
	move.l	$a(a6),$b0(a5)
	move.w	$e(a6),$b4(a5)
	lea	mt_voice1(pc),a6
	move.l	$a(a6),$a0(a5)
	move.w	$e(a6),$a4(a5)

	add.w	#$10,mt_pattpos
	cmp.w	#$400,mt_pattpos
	bne.s	mt_endr
mt_nex:	clr.w	mt_pattpos
	clr.b	mt_break
	addq.b	#1,mt_songpos
	and.b	#$7f,mt_songpos
	move.b	mt_songpos,d1
	cmp.b	mt_data+$3b6,d1
	bne.s	mt_endr
	move.b	mt_data+$3b7,mt_songpos
mt_endr:tst.b	mt_break
	bne.s	mt_nex
	movem.l	(a7)+,d0-d4/a0-a3/a5-a6
	rts

mt_setmyport:
	move.w	(a6),d2
	and.w	#$fff,d2
	move.w	d2,$18(a6)
	move.w	$10(a6),d0
	clr.b	$16(a6)
	cmp.w	d0,d2
	beq.s	mt_clrport
	bge.s	mt_rt
	move.b	#$1,$16(a6)
	rts
mt_clrport:
	clr.w	$18(a6)
mt_rt:	rts

mt_myport:
	move.b	$3(a6),d0
	beq.s	mt_myslide
	move.b	d0,$17(a6)
	clr.b	$3(a6)
mt_myslide:
	tst.w	$18(a6)
	beq.s	mt_rt
	moveq	#0,d0
	move.b	$17(a6),d0
	tst.b	$16(a6)
	bne.s	mt_mysub
	add.w	d0,$10(a6)
	move.w	$18(a6),d0
	cmp.w	$10(a6),d0
	bgt.s	mt_myok
	move.w	$18(a6),$10(a6)
	clr.w	$18(a6)
mt_myok:move.w	$10(a6),$6(a5)
	rts
mt_mysub:
	sub.w	d0,$10(a6)
	move.w	$18(a6),d0
	cmp.w	$10(a6),d0
	blt.s	mt_myok
	move.w	$18(a6),$10(a6)
	clr.w	$18(a6)
	move.w	$10(a6),$6(a5)
	rts

mt_vib:	move.b	$3(a6),d0
	beq.s	mt_vi
	move.b	d0,$1a(a6)

mt_vi:	move.b	$1b(a6),d0
	lea	mt_sin(pc),a4
	lsr.w	#$2,d0
	and.w	#$1f,d0
	moveq	#0,d2
	move.b	(a4,d0.w),d2
	move.b	$1a(a6),d0
	and.w	#$f,d0
	mulu	d0,d2
	lsr.w	#$6,d2
	move.w	$10(a6),d0
	tst.b	$1b(a6)
	bmi.s	mt_vibmin
	add.w	d2,d0
	bra.s	mt_vib2
mt_vibmin:
	sub.w	d2,d0
mt_vib2:move.w	d0,$6(a5)
	move.b	$1a(a6),d0
	lsr.w	#$2,d0
	and.w	#$3c,d0
	add.b	d0,$1b(a6)
	rts

mt_nop:	move.w	$10(a6),$6(a5)
	rts

mt_checkcom:
	move.w	$2(a6),d0
	and.w	#$fff,d0
	beq.s	mt_nop
	move.b	$2(a6),d0
	and.b	#$f,d0
	tst.b	d0
	beq	mt_arpeggio
	cmp.b	#$1,d0
	beq.s	mt_portup
	cmp.b	#$2,d0
	beq	mt_portdown
	cmp.b	#$3,d0
	beq	mt_myport
	cmp.b	#$4,d0
	beq	mt_vib
	move.w	$10(a6),$6(a5)
	cmp.b	#$a,d0
	beq.s	mt_volslide
	rts

mt_volslide:
	moveq	#0,d0
	move.b	$3(a6),d0
	lsr.b	#4,d0
	tst.b	d0
	beq.s	mt_voldown
	add.w	d0,$12(a6)
	cmp.w	#$40,$12(a6)
	bmi.s	mt_vol2
	move.w	#$40,$12(a6)
mt_vol2:move.w	$12(a6),$8(a5)
	rts

mt_voldown:
	moveq	#0,d0
	move.b	$3(a6),d0
	and.b	#$f,d0
	sub.w	d0,$12(a6)
	bpl.s	mt_vol3
	clr.w	$12(a6)
mt_vol3:move.w	$12(a6),$8(a5)
	rts

mt_portup:
	moveq	#0,d0
	move.b	$3(a6),d0
	sub.w	d0,$10(a6)
	move.w	$10(a6),d0
	and.w	#$fff,d0
	cmp.w	#$71,d0
	bpl.s	mt_por2
	and.w	#$f000,$10(a6)
	or.w	#$71,$10(a6)
mt_por2:move.w	$10(a6),d0
	and.w	#$fff,d0
	move.w	d0,$6(a5)
	rts

mt_portdown:
	clr.w	d0
	move.b	$3(a6),d0
	add.w	d0,$10(a6)
	move.w	$10(a6),d0
	and.w	#$fff,d0
	cmp.w	#$358,d0
	bmi.s	mt_por3
	and.w	#$f000,$10(a6)
	or.w	#$358,$10(a6)
mt_por3:move.w	$10(a6),d0
	and.w	#$fff,d0
	move.w	d0,$6(a5)
	rts

mt_checkcom2:
	move.b	$2(a6),d0
	and.b	#$f,d0
	cmp.b	#$e,d0
	beq.s	mt_setfilt
	cmp.b	#$d,d0
	beq.s	mt_pattbreak
	cmp.b	#$b,d0
	beq.s	mt_posjmp
	cmp.b	#$c,d0
	beq.s	mt_setvol
	cmp.b	#$f,d0
	beq.s	mt_setspeed
	rts

mt_setfilt:
	move.b	$3(a6),d0
	and.b	#$1,d0
	asl.b	#$1,d0
	and.b	#$fd,$bfe001
	or.b	d0,$bfe001
	rts
mt_pattbreak:
	not.b	mt_break
	rts
mt_posjmp:
	move.b	$3(a6),d0
	subq.b	#$1,d0
	move.b	d0,mt_songpos
	not.b	mt_break
	rts
mt_setvol:
	cmp.b	#$40,$3(a6)
	ble.s	mt_vol4
	move.b	#$40,$3(a6)
mt_vol4:move.b	$3(a6),$8(a5)
	rts
mt_setspeed:
	cmp.b	#$1f,$3(a6)
	ble.s	mt_sets
	move.b	#$1f,$3(a6)
mt_sets:move.b	$3(a6),d0
	beq.s	mt_rts2
	move.b	d0,mt_speed
	clr.b	mt_counter
mt_rts2:rts

mt_sin:
dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18

mt_periods:
dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a,$01fc,$01e0
dc.w $01c5,$01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d,$010d,$00fe
dc.w $00f0,$00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f,$0087
dc.w $007f,$0078,$0071,$0000,$0000

mt_speed:	dc.b	$6
mt_songpos:	dc.b	$0
mt_pattpos:	dc.w	$0
mt_counter:	dc.b	$0

mt_break:	dc.b	$0
mt_dmacon:	dc.w	$0
mt_samplestarts:blk.l	$1f,0
mt_voice1:	blk.w	10,0
		dc.w	$1
		blk.w	3,0
mt_voice2:	blk.w	10,0
		dc.w	$2
		blk.w	3,0
mt_voice3:	blk.w	10,0
		dc.w	$4
		blk.w	3,0
mt_voice4:	blk.w	10,0
		dc.w	$8
		blk.w	3,0

mt_data:
		blk.b	88308,0

************************* end