RTCLOC	EQU	$14
VDSLST	EQU	$200
SDMCTL	EQU	$22F
SDLSTL	EQU	$230
PCOLR0	EQU	$2C0
PCOLR1	EQU	$2C1
COLOR2	EQU	$2C6
HPOSP0	EQU	$D000
HPOSP1	EQU	$D001
COLPF2	EQU	$D018
GRACTL	EQU	$D01D
RANDOM	EQU	$D20A
PMBASE	EQU	$D407
WSYNC	EQU	$D40A
NMIEN	EQU	$D40E
SETVBV	EQU	$E45C
XITVBV	EQU	$E462
PAGE0	EQU	$F0
PDATA	EQU	$5000
PLAYR0	EQU	PDATA+$400
PLAYR1	EQU	PDATA+$500
;
	ORG	$4000
START
	LDA	#$03		; SET UP PLAYER/MISSILE GRAPHICS
	STA	GRACTL
	LDA	#<PDATA
	STA	PMBASE
	LDA	#$3E
	STA	SDMCTL
	LDA	#$00		; CLEAR PLAYER RAM
	TAX
AA1
	STA	PLAYR0,X
	STA	PLAYR1,X
	DEX
	BNE	AA1
	LDX	#$07
AA2
	LDA	LHALF,X		; PUT LEFT HALF OF BOAT ON SCREEN
	STA	PLAYR0+$3C,X
	LDA	RHALF,X		; PUT RIGHT HLAF OF BOAT ON SCREEN
	STA	PLAYR1+$3C,X
	DEX
	BPL	AA2
	LDA	#$94		; BLUE
	STA	COLOR2		; TEXT BACKGROUND
	LDA	#$0E		; WHITE
	STA	PCOLR0		; MAKE BOAT WHITE
	STA	PCOLR1
	LDA	#$00		; SET HORIZONTAL POS. TO 0
	STA	P0H
	LDA	#$08		; RIGHT HALF OF BOAT HORIZ. POS. IS 8 GREATER -
	STA	P1H		; -THAN LEFT HALF
	LDA	SDLSTL		; MAKE A PAGE 0 POINTER TO CURRENT DISPLAY LIST
	STA	PAGE0
	LDA	SDLSTL+1
	STA	PAGE0+1
	LDY	#$08		; FIND THE 4TH TEXT LINE
	LDA	(PAGE0),Y
	ORA	#%10000000	; TURN ON HIGH BIT FOR INTERRUPT
	STA	(PAGE0),Y	; STORE IT BACK
	LDA	#$00
	STA	WAVE
	LDA	#>DLI		; STORE ADDRESS OF DLI IN PAGE 2 VECTOR
	STA	VDSLST
	LDA	#<DLI
	STA	VDSLST+1
	LDA	#%11000000	; TELL ANTIC TO OK DLI
	STA	NMIEN
	LDA	#$07		; SET UP DEFFERRED VBLANK
	LDY	#>VBI
	LDX	#<VBI
	JSR	SETVBV
	RTS			; THIS SHOULD RTS BACK TO YOUR ASSEMBLER DEBUGGER
DLI
	PHA
	TXA
	PHA
	TYA
	PHA
	LDA	#$A2		; DARK BLUE
	LDY	#$A6		; LIGHT BLUE
	LDX	#$08		; WE ARE GOING TO PLAY WITH THE NEXT 8 SCAN LINES
AB1
	LSR	TWAVE		; CHECK NEXT BIT OF OUR RANDOM NUMBER
	STA	WSYNC		; WAIT TILL BEAM OFFSCREEN
	STA	COLPF2		; ASSUME DARK BLUE
	BCC	AB2		; IF RANDOM # BIT WAS OFF
	STY	COLPF2		; IF ON TURN LIGHT BLUE
AB2
	DEX
	BNE	AB1		; TILL ALL 8 LINES DONE
	STA	WSYNC		; WAIT TILL OFF SCREEN
	STA	COLPF2		; TURN SCREEN DARK BLUE FOR REMAINDER OF SCREEN
	PLA			; RESTORE REGISTERS & LEAVE
	TAY
	PLA
	TAX
	PLA
	RTI
VBI
	LDA	RTCLOC
	AND	#$07		; A NEW WAVE PATTERN IS PICKED EVERY 8TH VBLANK
	BNE	AC1		; - OTHERWISE IT WOULD CHANGE TOO FAST
	LDA	RANDOM		; GET A NEW WAVE VALUE
	STA	WAVE
AC1
	LDA	WAVE		; GET CURRENT WAVE VALUE
	STA	TWAVE		; PASS TO DLI VARIABLE
	INC	P0H		; MOVE BOAT ACCROSS SCREEN
	INC	P1H
	LDA	P0H
	STA	HPOSP0		; TELL ANTIC NEW POS.
	LDA	P1H
	STA	HPOSP1
	JMP	XITVBV
;
LHALF
	DB	$00,$00,$60,$EF,$EF,$5F,$40,$C0
RHALF
	DB	$80,$40,$20,$FF,$FC,$F0,$00,$00
;
WAVE	DS	1
TWAVE	DS	1
P0H	DS	1
P1H	DS	1
