org	$30000
load	$30000

s:
;lea	$57000,a0
;lea	$59000,a1
;loesch:
;clr.l	(a0)+
;cmp.l	a0,a1
;bne	loesch

lea	$50000,a0
lea	$53000,a1
bsr	unpack
lea	$77000,a0	; Beginning of Compacted - Picture
lea	$40000,a1	; Entpackted Picture
bsr	unpack		; Entpacken
bsr	setupcol	; Farben setzen
lea	$7a606,a0
lea	$47000,a1
bsr	unpack

move.l	#$2a11fffe,d0
move.l	#$01800000,d1
move.l	#$01080078,d2
move.l	#$010a0078,d3
move.w	#160,d4
lea	coppar,a0
setcop:
move.l	d0,(a0)+
move.l	d1,(a0)+
move.l	d2,(a0)+
move.l	d3,(a0)+
add.l	#$01000000,d0
move.w	d0,$dff180
sub.w	#1,d4
bne	setcop
move.l	d0,(a0)+
move.l	#$01800f0f,(a0)+
move.l	#$01080038,(a0)+
move.l	#$010a0038,(a0)+
move.l	#$cb11fffe,(a0)+
move.l	#$018000ff,(a0)+
move.l	#$00e00005,(a0)+
move.l	#$00e29004,(a0)+
move.l	#$cc11fffe,(a0)+
move.l	#$01800ff0,(a0)+
move.l	#$00e40005,(a0)+
move.l	#$00e69094,(a0)+
move.l	#$cd11fffe,(a0)+
move.l	#$01800f00,(a0)+
move.l	#$01002200,(a0)+
move.l	#$01860aaa,(a0)+
move.l	#$ce11fffe,d1
move.l	#$01800000,d2
move.w	#100,d0
nextcop:
move.l	d1,(a0)+
move.l	d2,(a0)+
move.l	#$01820eee,(a0)+
move.l	#$01840ccc,(a0)+
add.l	#$01000000,d1
add.l	#$00000002,d2
sub.w	#$1,d0
cmp.l	#$0011fffe,d1
bne	nextcop
sub.w	#1,d0
move.l	#$ffe1fffe,(a0)+
move.l	#$01b00000,(a0)+
move.l	#$01b00000,(a0)+
move.l	#$01b00000,(a0)+
contcop:
move.l	d1,(a0)+
move.l	d2,(a0)+
move.l	#$01820eee,(a0)+
move.l	#$01840ccc,(a0)+
add.l	#$01000000,d1
add.l	#$00000002,d2
sub.w	#1,d0
bne	contcop

move.l	$04,a6
jsr	-132(a6)
lea	gfxname,a1
jsr	-408(a6)
move.l	d0,gfxbase
move.l	d0,a0
move.l	50(a0),oldclist
move.l	#newclist,50(a0)
move.l	$6c,oldirq+2
move.l	#newirq,$6c
wait:
btst	#6,$bfe001
bne.s	wait
move.l	oldirq+2,$6c
move.l	gfxbase,a0
move.l	oldclist,50(a0)
move.l	$04,a6
move.l	gfxbase,a1
jsr	-414(a6)
jsr	-138(a6)
rts

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

bsr	copyscroll
bsr	scrolldat
bsr	calcnewmod
bsr	writes1
bsr	scrollc1
bsr	turnit
bsr	check

bsr	scroll
sub.w	#1,shift
bne	notget
bsr	getchar
move.w	#16,shift
notget:

exit:
movem.l	(sp)+,d0-d7/a0-a6
oldirq:
jmp	$00000000

newclist:
dc.w	$008e,$2c81,$0090,$2cc1,$0092,$0038,$0094,$00d0
dc.w	$0102,$0000,$0104,$0000,$0108,120,$010a,120
dc.w	$0100,$4200,$0180,$0000
adresses:
dc.w	$00e0,$0004,$00e2,$0000,$00e4,$0004,$00e6,$0028
dc.w	$00e8,$0004,$00ea,$0050,$00ec,$0004,$00ee,$0078
copcol:
blk.l	16,0
dc.w	$120,0,$122,0,$124,0,$126,0,$128,$12a,$12c,0,$12e,0
dc.w	$130,0,$132,0,$134,0,$136,0,$138,$13a,$13c,0,$13e,0
coppar:
blk.w	160*8,0
blk.w	32,0
blk.w	100*8,0
dc.w	$180,0
dc.w	$ffff,$fffe

even
oldclist:
dc.l	0
gfxbase:
dc.l	0
gfxname:
dc.b	"graphics.library",0
even
unpack:
	add.l	#12,a0
	move.l	4(a0),d0
	add.l	d0,a0
	add.l	#8,a0
	move.l	a0,cmapchunk

iff1:	cmp.l	#$424f4459,(a0)
	beq	iff0
	add.l	#2,a0
	bra	iff1

iff0:	move.l	4(a0),d0	; Anzahl Bytes
	add.l	#1,d0
	and.l	#$fffffffe,d0

	add.l	#8,a0		; Pointer to first Byte

iff4:	clr.l	d2
	move.b	(a0)+,d2
	bmi	iff6

iff5:	move.b	(a0)+,(a1)+
	subi.l	#1,d0
	subi.b	#1,d2
	bpl	iff5
	bra	iff7
	
iff6:	neg.b	d2
	beq	iff7

iff61:	move.b	(a0),(a1)+
	subi.b	#1,d2
	bpl	iff61
	subi.l	#1,d0
	add.l	#1,a0

iff7:	subi.l	#1,d0
	bmi	iff8
	beq	iff8
	bra	iff4

iff8:	move.l	cmapchunk,a0
	move.l	cmap,a1
	add.l	#8,a0
	move.l	#16,d0

cmaploop:
	clr.l	d1
	move.b	(a0),d1
	lsl.w	#4,d1
	move.b	2(a0),d1
	lsr.b	#4,d1
	or.b	1(a0),d1
	move.w	d1,(a1)+
	add.l	#3,a0
	sub.w	#1,d0
	bne	cmaploop
	rts

cmapchunk:
	dc.l	0

cmap:	dc.l	color1

color1:	blk.w	16,0

setupcol:
lea	color1,a0
lea	copcol,a1
move.l	#$01800000,d0
move.l	#16,d1

suc1:
move.w	(a0)+,d0
move.l	d0,(a1)+
add.l	#$00020000,d0
sub.w	#1,d1
bne	suc1
rts

Turn72 = $38000

copywerte:
lea	turn72+[48*160],a0
move.l	a0,a1

copyturn:
move.b	-(a0),(a1)+
cmp.l	#turn72,a0
bne	copyturn
rts

calcnewmod:
lea	$40000,a6
lea	adresses,a5
lea	mod1table,a0	; Order of rasters
move.l	#160,d7		; 72 lines
lea	coppar,a2
move.w	#$28,d4

move.w	(a0)+,d0	; Get Line No
mulu	#40*4,d0	; multiply by 5 Bitplanes Width 80
add.l	a6,d0		; add Startadress
move.l	d0,d6		; Save Adress

move.l	d0,d1		; Copy Adress
swap	d1
move.w	d1,2(a5)	; High
move.w	d0,6(a5)	; Low
add.w	d4,d0		; Next Line

move.l	d0,d1
swap	d1
move.w	d1,10(a5)
move.w	d0,14(a5)
add.w	d4,d0

move.l	d0,d1
swap	d1
move.w	d1,18(a5)
move.w	d0,22(a5)
add.w	d4,d0

move.l	d0,d1
swap	d1
move.w	d1,26(a5)
move.w	d0,30(a5)

clr.l	d0
move.l	#160,d4

cnmloop:
move.w	(a0)+,d1	; Get next

gtnxt:
mulu	d4,d1
add.l	a6,d1
move.l	d1,d2
sub.l	#40,d1
sub.l	d6,d1
move.w	d1,14(a2)
move.w	d1,10(a2)
move.l	d2,d6

add.l	#16,a2
sub.w	#1,d7
bne	cnmloop
rts

mod1table:
dc.w	0,1,2,3,4,5,6,7,8,9
dc.w	10,11,12,13,14,15,16,17,18,19
dc.w	20,21,22,23,24,25,26,27,28,29
dc.w	30,31,32,33,34,35,36,37,38,39
dc.w	40,41,42,43,44,45,46,47,48,49
dc.w	50,51,52,53,54,55,56,57,58,59
dc.w	60,61,62,63,64,65,66,67,68,69
dc.w	70,71,72,73,74,75,76,77,78,79
dc.w	80,81,82,83,84,85,86,87,88,89
dc.w	90,91,92,93,94,95,96,97,98,99
dc.w	100,101,102,103,104,105,106,107,108,109
dc.w	110,111,112,113,114,115,116,117,118,119
dc.w	120,121,122,123,124,125,126,127,128,129
dc.w	130,131,132,133,134,135,136,137,138,139
dc.w	140,141,142,143,144,145,146,147,148,149
dc.w	150,151,152,153,154,155,156,157,158,159
dc.w	160,161,162,163,164,165,166,167,168,169
dc.w	170,171,172,173,174,175,176,177,178,179
dc.w	180,181,182,183,184,185,186,187,188,189
dc.w	190,191,192,193,194,195,196,197,198,199

ti_adr:	dc.l	turn72
ti_mo:	dc.w	0
ti_no:	dc.w	0

turnit:
lea	mod1table,a0
move.l	ti_adr,a1
clr.l	d0
move.l	#159,d6
move.w	ti_mo,d5
bmi	tunit

turnit2:
move.b	(a1)+,d0
move.w	d0,(a0)+
dbf	d6,turnit2
add.w	#1,ti_no
cmp.w	#48,ti_no
bne	turnit3
sub.l	#160,a1
move.w	#$ffff,ti_mo

turnit3:
move.l	a1,ti_adr
move.w	#1,d0
rts

tunit:

tunit2:
move.b	(a1)+,d0
move.w	d0,(a0)+
dbf	d6,tunit2
sub.l	#160*2,a1
sub.w	#1,ti_no
bne	tunit3
add.l	#160,a1
move.w	#1,ti_mo
move.l	a1,ti_adr
add.w	#1,ti_count
cmp.w	#3,ti_count
bne	tunit3
clr.l	d0
rts

tunit3:
move.l	a1,ti_adr
move.w	#1,d0
rts

ti_count:	dc.w	0

check:
move.l	adrzeiger,a0
jump:
move.b	(a0)+,d0
cmp.b	#1,d0
bne	check2
move.l	#$40000,calcnewmod+2
check2:
cmp.b	#2,d0
bne	checkff
move.l	#$47000,calcnewmod+2
checkff:
cmp.b	#$ff,d0
bne	exitcheck
lea	adrd,a0
bra	jump
exitcheck:
move.l	a0,adrzeiger
rts
adrd:
blk.b	48,1
blk.b	48,2
blk.b	48,2
blk.b	48,1
dc.b	$ff
even
adrzeiger:	dc.l	adrd
scroll:
bsr	bltwait
move.l	#$dff000,a4
move.l	#$57182,$50(a4)
move.l	#$57180,$54(a4)
move.w	#0,$64(a4)
move.w	#0,$66(a4)
move.w	#$ffff,$44(a4)
move.w	#0,$46(a4)
move.l	#$e9f00000,$40(a4)
move.w	#$1818,$58(a4)
wartemal:
btst	#6,$dff002
bne	wartemal
rts
getchar:
move.l	textzeiger,a0
move.b	(a0)+,d0
bne	contchar
lea	text,a0
move.b	(a0)+,d0
contchar:
move.l	a0,textzeiger
lea	ascii,a0
move.l	a0,a1
notrchar:
cmp.b	(a0)+,d0
bne	notrchar
sub.l	#1,a0
sub.l	a1,a0
clr.l	d1
move.l	a0,d1
cmp.l	#10,d1
bcs	mi10
cmp.l	#20,d1
bcs	mi20
cmp.l	#30,d1
bcs	mi30
cmp.l	#40,d1
bcs	mi40
cmp.l	#50,d1
bcs	mi50
bra	return
mi50:
sub.l	#40,d1
add.l	#$a00,d1
bra	mi10
mi40:
sub.l	#30,d1
add.l	#$780,d1
bra	mi10
mi30:
sub.l	#20,d1
add.l	#$500,d1
bra	mi10
mi20:
sub.l	#10,d1
add.l	#$280,d1
mi10:
mulu	#4,d1
move.l	#$53000,d2
add.l	d1,d2

move.l	d2,$dff050
move.l	#$57180+$2c,$dff054
move.w	#36,$dff064
move.w	#44,$dff066
move.l	#$ffffffff,$dff044
move.l	#$09f00000,$dff040
move.w	#$1002,$dff058
ratemal:
btst	#6,$dff002
bne	ratemal
return:
rts
shift:	dc.w	16
ascii:;  123456789012345678901234567890123456789
dc.b	"abcdefghijklmnopqrstuvwxyz0123456789.:,^*!? "
text:
dc.b	"sargon is proud to present you our megademo...   "
dc.b	"this part was done by btc with help from danny   "
dc.b	"megademo spreaded by wow copy party in aachen ...    "
dc.b	"do you think this scroll is very lame ??? mark said to me "
dc.b	"that i shouldn*t make this scroller faster ...   "
dc.b	0
even
textzeiger:
dc.l	text

adres:	dc.l	$59182
copyscroll:
move.l	#$ffffffff,$dff044
;move.w	#$2e,$dff066
;move.w	#$2e,$dff064
;move.w	#$2e,$dff062
move.w	#$2e,d0
move.w	d0,$dff066
move.w	d0,$dff064
move.w	d0,$dff062

move.l	adres,a0
move.l	#$57184,a1
lea	sinusdat,a3
move.w	(a3),d0
add.w	d0,adres+2
moveq	#19,d1
move.w	#$1001,d4
move.w	#$180,d3
move.l	#$dff000,a4

cloop2:
sub.w	d3,a0
sub.w	d3,a1
bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.w	#$f000,$44(a4)
move.l	#$09f00000,$40(a4)
move.w	#$1401,$58(a4)
add.w	d3,a0
add.w	d3,a1
add.w	(a3)+,a0

bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.l	a0,$4c(a4)
move.w	#$0f00,$44(a4)
move.l	#$0dfc0000,$40(a4)
move.w	d4,$58(a4)
add.w	(a3)+,a0

bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.l	a0,$4c(a4)
move.w	#$00f0,$44(a4)
move.w	d4,$58(a4)
add.w	(a3)+,a0

bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.l	a0,$4c(a4)
move.w	#$000f,$44(a4)
move.w	d4,$58(a4)
add.w	(a3)+,a0

add.w	#2,a0
add.w	#2,a1
dbf	d1,cloop2
rts

bltwait:
btst	#6,$dff002
bne	bltwait
rts

sinusdat:
blk.w	4,0
dc.w	96,0,0,96,0,0,96,0,96,0,96,0,96,0,96,96,0,96,96,0,96,96,96
dc.w	0,96,96,96,96,96,0,96,96,96,96,96,96,96,96,96,96,96
dc.w	96,0,96,96,96,96,96,96,96,96,96,96,96,0,96,96,96,96
dc.w	96,0,96,96,96,0,96,96,0,96,96,0,96,0,96,0,96,0,96,0,0
dc.w	96,0,0,96,0,0,0,0,0,0,0,0,96,-96
dc.w	0,0,0,0,0,0,0,0,-96,0,0,-96,0,0,-96,0,-96,0,-96,0,-96
dc.w	0,-96,-96,0,-96,-96,0,-96,-96,-96,0,-96,-96,-96,-96,-96,0
dc.w	-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,0,-96
dc.w	-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,0,-96,-96
dc.w	-96,-96,-96,0,-96,-96,-96,0,-96,-96,0,-96,-96,0,-96
dc.w	0,-96,0,-96,0,-96,0,0,-96,0,0,-96
blk.w	4,0
lsinus:

scrolldat:
lea	sinusdat,a0
lea	lsinus-2,a1
move.w	(a0),d0
scrollweiter:
move.w	2(a0),(a0)
addq.l	#2,a0
cmp.l	a0,a1
bne.s	scrollweiter
move.w	d0,(a1)
rts

writes1:
;add.l	#10*16*16,a0
moveq	#13,d4
lea	c1,a1
lea	coppar+[10*16*16],a0
not14:
moveq	#8,d0
contc1:
move.w	(a1)+,6(a0)
add.l	#16,a0
subq.w	#1,d0
bne	contc1
sub.l	#14,a1
subq.w	#1,d4
bne	not14
rts
c1:
dc.w	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,10
dc.w	9,8,7,6,5,4,3,2,1
dc.w	0,0,0,0,0,0,0,0,0,0
dc.w	$100,$200,$300,$400,$500,$600,$700,$800,$900,$a00
dc.w	$b00,$c00,$d00,$e00,$f00,$e00,$d00,$c00,$b00,$a00,$900
dc.w	$800,$700,$600,$500,$400,$300,$200,$100
dc.w	0,0,0,0,0,0,0,0,0
lc1:
dc.w	0

blk.w	10,0

scrollc1:
lea	c1,a0
lea	lc1,a1
move.w	(a0),d0
scrollagain1:
move.w	2(a0),(a0)
addq.l	#2,a0
cmp.l	a0,a1
bne	scrollagain1
move.w	d0,(a1)
rts

