;*******************************************************
;*
;*	WAVE-INTRO by HAEGAR / THRUST
;*
;*	startdate: 07/19/88		>ri
;*					>datshortcr
;*	enddate:   07/19/88		>crunch
;*
;*	SUNSETGLOW  1988 THRUST
;*
;*******************************************************

fontram = $6d000
copperram = $7eb00
pic = $7a000
picr =	pic+1600
scrollfield = pic - 5000
scrollfieldend = scrollfield+4224
haus = $73000
trap:
	move.l #start,$80
	trap #0
	rts

start:
	move.w #$2700,sr
	movem.l d0-d7/a0-a6,-(sp)

;-------floppystop-------

	ori.b #$80,$bfd100
	ori.b #$8,$bfd100
	andi.b #$f7,$bfd100
	ori.b #$10,$bfd100
	andi.b #$ef,$bfd100

	jsr	s
	move.l	#sintab,a0
	move.l	#sintab_end,a1
	sub.l	a0,a1
	move.l	a1,d0
	move.w	d0,sintab_save
;------init haus
	move.l	#copperram,a0
	move.l	#newcopper,a1
	move.l	#bitplanes1,a2
	sub.l	a1,a2
	add.l	a2,a0
	move.l	a0,haus_copper_ram
	move.l	#copperram,a0
	move.l	#newcopper,a1
	move.l	#bitplanes,a2
	sub.l	a1,a2
	add.l	a2,a0
	move.l	a0,bitplanes_ram
	bsr copy_copper
	bsr	init_copperlist

move.l	#$73000+18,d0
move.w	#3,d1
move.l	haus_copper_ram,a0
loop_f:
swap	d0
	move.w	d0,2(a0)
swap	d0
	move.w	d0,6(a0)
add.l	#40,d0
add.l	#8,a0
dbra	d1,loop_f
	
	move.l	#copperram,a0
	move.l	#newcopper,a1
	move.l	#bitscroll,a2
	sub.l	a1,a2
	add.l	a2,a0
	move.l	a0,scroll_copper_ram

move.l	#scrollfield,d0
move.w	#2,d1
move.l	scroll_copper_ram,a0
loop_e:
swap	d0
	move.w	d0,2(a0)
swap	d0
	move.w	d0,6(a0)
add.l	#44,d0
add.l	#8,a0
dbra	d1,loop_e
	
	move.w #$80,$dff096
	move.l #copperram,$dff080
	clr.w $dff088
	move.w #$8080,$dff096


wait:
	cmp.b #$30,$dff006
	bne wait
	btst	#10,$dff016
	beq	mouse
	bsr	scroll_rout
mouse:
	bsr	write_line
	bsr	asr_init
	
	btst #6,$bfe001
	bne wait

end:
	move.w #15,$dff096	;sound aus
copperinit:
	move.l	4,a6
	move.l	#gfxname,a1
	jsr	-408(a6)
	move.l	d0,a1
	move.w #$80,$dff096
	move.l	38(a1),$dff080
	clr.w $dff088
	move.w #$8080,$dff096
	
	jsr	-414(a6)

	move.w #$8020,$dff096	;mouse an
	movem.l (a7)+,d0-d7/a0-a6
	move.w #$2000,sr
	rte

gfxname:	dc.b	"graphics.library",0
even
;********************************************************
;* waverout
;********************************************************

write_line:
	move.l	bitplanes_ram,a0
	move.l	#sintab,a1	;sintabelle
	add.w	#4,sintab_pointer	;erhoehe pointer
	move.w	sintab_save,d1
	move.w	sintab_pointer,d2	
	cmp.w	d1,d2
	ble	sintab_weiter
	move.w	#0,sintab_pointer
sintab_weiter:
	move.w	sintab_pointer,d0	;zeiger auf sintab
	
	move.l	#pic,d1		;bildadd
	move.w	#80,d4		;schleifen_zaehler
write_loop:
	moveq	#0,d2
	move.w	0(a1,d0.w),d2	;sin_nach d2
	tst.w	asr_
	bne	no_0
	moveq	#0,d2
no_0:
	move.w	#100,d6
	muls	asr_,d6
	add.w	#1000,d6
	divs	d6,d2
	mulu	#160,d2		;= zeile
	move.l	d1,d3	
	add.l	d2,d3		;zeile
	and.l	#$fffff,d3
	add.l	#4,a0		;offset copperlist to adresse bplpoin
move.w	#3,d7		;little_loop
l_loop:
	swap	d3
	move.w	d3,2(a0)
	swap	d3
	move.w	d3,6(a0)
	add.l	#40,d3
	add.l	#8,a0
	dbra	d7,l_loop
	add.w	#6,d0
	sub.l	a3,a3
	move.w	d0,a3
	add.l	#sintab,a3
	move.l	#sintab_end,a4
	cmp.l	a3,a4
	bge	weiter_d0
	moveq	#0,d0
	weiter_d0:

	add.l	#160,d1
	dbra	d4,write_loop
rts

;------copy_copper---------------------
clear_copper:
move.l #copperram,a0
clr_loop:
clr.l	(a0)+
cmp.l	#$7fff0,a0
ble	clr_loop
rts
copy_copper:
move.l #copperram,a0
move.l #newcopper,a1
move.l #copper_end,a2
copper_schleife:
move.l (a1)+,(a0)+
cmp.l a1,a2
bge copper_schleife
rts




;**************************************************
;*	asr_
;**************************************************

asr_init:
sub.w	#1,asr_time
tst.w	asr_time
beq	asr_weiter
rts
asr_weiter:
move.w	asr_time_save,asr_time
move.l	#asr_data,a0
add.l	asr_pointer,a0
move.w	(a0),asr_
add.l	#2,asr_pointer
move.l	#asr_dataend,d1
move.l	#asr_data,d0
add.l	asr_pointer,d0
cmp.l	d0,d1
ble	gleich
rts
gleich:
clr.l	asr_pointer
rts

;**************************************************
;*	init copperliste
;**************************************************

init_copperlist:
move.w	#80,d0		;schleifenzaehler
move.l	bitplanes_ram,a0
move.w	#$00e0,d1	;first bitplane
move.l	#pic,d3		;picadd
move.w	#$5307,d2	;wait_copper
init_copper_list:
	move.w	d1,d4		;save bitplaneadressedesti	

	move.w	d2,(a0)+	;write waitline
	move.w	#$fffe,(a0)+	;write waitmask
	move.w	d4,(a0)+	;first bitplane hi add
swap	d3
	move.w	d3,(a0)+	;and write high
add.w	#2,d4			;next adresse for bitplane
	move.w	d4,(a0)+	;and write
swap	d3
	move.w	d3,(a0)+	;write low

add.l	#40,d3			;next bitplane

add.w	#2,d4

	move.w	d4,(a0)+	;first bitplane hi add
swap	d3
	move.w	d3,(a0)+	;and write high
add.w	#2,d4			;next adresse for bitplane
	move.w	d4,(a0)+	;and write
swap	d3
	move.w	d3,(a0)+	;write low

add.l	#40,d3			;next bitplane

add.w	#2,d4

	move.w	d4,(a0)+	;first bitplane hi add
swap	d3
	move.w	d3,(a0)+	;and write high
add.w	#2,d4			;next adresse for bitplane
	move.w	d4,(a0)+	;and write
swap	d3
	move.w	d3,(a0)+	;write low

add.l	#40,d3			;next bitplane

add.w	#2,d4

	move.w	d4,(a0)+	;first bitplane hi add
swap	d3
	move.w	d3,(a0)+	;and write high
add.w	#2,d4			;next adresse for bitplane
	move.w	d4,(a0)+	;and write
swap	d3
	move.w	d3,(a0)+	;write low

add.l	#40,d3			;next bitplane

add.w	#2,d4


add.w	#$100,d2
dbra	d0,init_copper_list
rts

;18 words

newcopper:
dc.l	$0101fffe
dc.l	$008e2c81
dc.l	$009031d1
dc.l	$00920038
dc.l	$009400d0
dc.l	$00960020
dc.l	$01020000
dc.l	$01040000
dc.l	$0108005c
dc.l	$010a005c
	dc.l	$01800000,$01820620,$01840731,$01860952
	dc.l	$01880a73,$018a0c95,$018c0db7,$018e0fca
bitscroll:
	dc.l	$00e00000
	dc.l	$00e20000
	dc.l	$00e40000
	dc.l	$00e60000
	dc.l	$00e80000
	dc.l	$00ea0000
dc.l	$01003200

dc.l	$5007fffe
dc.l	$01000200
dc.l	$0180000f
dc.l	$5207fffe
dc.l	$01000200
dc.l	$01004200
	dc.l	$01800006,$0182034a,$0184045a,$0186056b
	dc.l	$0188067b,$018a078c,$018c078c,$018e078c
	dc.l	$0190088d,$0192099d,$01940abf,$01960cce
	dc.l	$01980ddf,$019a0fff,$019c0aaf,$019e0102
bitplanes:
blk.w	1458,0	
bpldma: 
dc.l	$01004200
dc.l	$a407fffe
dc.l	$01000200
dc.l	$0180000f
dc.l	$a607fffe
	dc.l	$01800000,$01820d00,$01840d20,$01860e51
	dc.l	$01880e71,$018a0ea1,$018c0fc2,$018e0ff2
	dc.l	$01900000,$0192094a,$0194094c,$01960566
	dc.l	$01980167,$019a0322,$019c0666,$019e0444
dc.l	$01080078
dc.l	$010a0078
dc.l	$01000200
bitplanes1:
	dc.l	$00e00000
	dc.l	$00e20000
	dc.l	$00e40000
	dc.l	$00e60000
	dc.l	$00e80000
	dc.l	$00ea0000
	dc.l	$00ec0000
	dc.l	$00ee0000
	dc.l	$00f00000
	dc.l	$00f20000
	dc.l	$01004200
dc.l	$fffffffe
copper_end:

sintab:	;86
	dc.l	$7fff7f80
	dc.l	$7ec17d34
	dc.l	$7b0b7848
	dc.l	$74ef7104
	dc.l	$6c8d678e
	dc.l	$620e5c13
	dc.l	$55a64ece
	dc.l	$47944000
	dc.l	$381d2ff3
	dc.l	$278e1ef7
	dc.l	$163a0d61
	dc.l	$0478023c
	dc.l	$04780d61
	dc.l	$163a1ef7
	dc.l	$278e2ff3
	dc.l	$381d4000
	dc.l	$47944ece
	dc.l	$55a65c13
	dc.l	$620e678e
	dc.l	$6c8d7104
	dc.l	$74ef7848
	dc.l	$7b0b7d34
	dc.l	$7ec17f80

sintab_end:
	dc.w	$7fff7fff
;*************************************
;*	data
;*************************************

sintab_save:	dc.w	0
data:
bitplanes_ram:	dc.l	0
;	hier ein paar werte reinschreiben von 1 bis 200
;	0 = stehen
asr_data:

dc.w	0,0,400,350,300,280,260,230,200,175,150,130,110,100,90,80
dc.w	70,65,60,55,50,45,40,37,34,31,28,25,22,20,18,16,14,12,10,8
dc.w	7,6,5,4,3,2,1,1,2,3,4,5,6,7,8,10,12,14,16,18,20,22,25,28
dc.w	31,34,37,40,45,50,55,60,65,70,80,90,100,110,130,150,175,200
dc.w	230,260,280,300,350,400
asr_dataend:	
asr_:	dc.w	0
asr_pointer:	dc.l	0
asr_time:	dc.w	10
asr_time_save:	dc.w	20	;wie lange schwabbeln
sintab_pointer:	dc.w	0
haus_copper_ram:	dc.l	0
scroll_copper_ram:	dc.l	0

scroll_rout:

;-------time_scroll---------
tst.w scroll_time
beq scroll_sign_l
move.w scroll_time,d0
sub.w #1,d0
move.w d0,scroll_time
cmp.w #0,d0
bne ende
scroll_sign_l:
move.l #fontram,zeichensatz
bsr blit
sub.b	#$01,pixel
bne.L	ende
bsr blitpixel_scroll
move.b	#$4,pixel
get_sign:
move.l #scrolltext,a0
add.l zeiger,a0
clr.l d0
move.b (a0),d0
tst.b d0
bne weiter_o
add.l #1,a0
move.b (a0),d5
ext.w d5
move.w d5,scroll_time

add.l #2,zeiger
bra get_sign
weiter_o:
cmp.b #$40,d0
ble weiter_i
move.l zeichensatz,d7
add.l #12094+252,d7
move.l d7,zeichensatz
weiter_i:
sub.b #$20,d0
asl #2,d0
add.l zeichensatz,d0
move.l d0,sign_scroll
addq.l	#$01,zeiger
cmp.l	#endtext-1,a0
blt.L	ende
move.l	#0,zeiger
ende:
rts
sign_blit: dc.l 0
sign_ziel: dc.l 0
zeichensatz:	dc.l	0
blit:

move.l 		#scrollfield,$dff050	;A 
move.l		#scrollfield-2,$dff054 ;D
move.w 		#$0,$dff064	;modulus
move.w 		#$0,$dff066
move.w 		#$0,$dff042
move.l		#$ffffffff,$dff044
move.w		#$89f0,$dff040	;bltcon1
move.w		#%0001100000010100,$dff058	;high&bright
;	          hhhhhhhhhhwwwwww		;10bit=1024lines
						;6bit =64*16bit=1024br
bsr blitwait
rts
blitpixel_scroll:
move.l		sign_scroll,$dff050
move.l		#scrollfield+40,$dff054
move.w		#$7a,$dff064
move.w		#$28,$dff066
move.w		#$0,$dff042
move.l		#$ffffffff,$dff044
move.w		#$9f0,$
{=Y~=Br|ހHB0 ~ Z<@U	CEs #9pWz ߠ{??Tl kOUt|5y EE,`ϓ(#	]^WP ]a!NÀ@@?=|'R5a@```!`^^k ~} R5dP_H 		 0NGR-&DJt9h8 p `P   p~E~Y_``ʢm'K*` '`{bHį,  wB@52+1";(;(7=V˱ &*Q\/OTxtSeAdKWݖoX,YrT@>RYR(1ڡ߀|@q_T@TiW'#:o`ִ!Y[ ; ^(Jٟ	z(-qઊ bߔ&_Γ Xv5|,x>>̈Fp00H0.򲅊* RLp,V%y0UR4~H(d PTѐbΥ!-J$u؛%1
M>@Ӭ*" O0
t7%8V'Л8R/iD1$epHBѵt[ojpI<
4"Q%=:M0?45%TA N3Wx0KUpgјksu]IſҀYr!KE@	^n U,D)sy;4+[!j|Df qܶXR/ )I( zCYS4e@:Z+N(BI ," JX?}e.Hxz/x|ĖZ^aKU@f	!90*A+"l)h802I0ND+E~VTFv!8JȐEC?Z2,"m!H-Ed u1 1 C/WЉ` eAқ vE2	FbI CoYK>qH&yBX 1U}T_/U_Cv E5 	&QG*| HZSXl@ hX|A< q|%sUf25@8&Ǡ 0`Aj?'Y0"'ହZ~W<]B=X BbS$!KCOR_e? 3@ 44T ֤fT & Gʿ Yp[t. %a@A!G}$6Pȸ 0 ?8%? p ~	 ((W  ? 50 {&*ۦ)_FXuX
r
c'(xyyʹˌ3\G
,@{D  dx'͌[(c@7B|}['8\88_
Gzze}G@8@{@z+q6oÖ>|b=S+)*o@PD@<34+ Ԛ,"Qi!oMcRa!Ox;Po{X슕S;x_  &3 $e 9^=ҁc;oQCއ/6Ҹ< 8İ
I<k<A\ނѮ~OOǢKg36?p q=]#:GGB3)>y{9