



;
;compile with 
;      dasm  thisfile.asm -f3 -oresult.bin
;







	processor 6502
[[vcs.h]]
	org $F000

NO_ILLEGAL_OPCODES = 1



Start
	;STOLEN CLEAN START
	sei
	cld

	ldx #0
	txa
	tay
.CLEAR_STACK    dex
	txs
	pha
	bne .CLEAR_STACK     ; SP=$FF, X = A = Y = 0


	LDA #$00		
	STA COLUBK	
	LDA #33
	STA COLUP0
MainLoop
	LDA  #2
	STA  VSYNC	
	STA  WSYNC	
	STA  WSYNC 	
	STA  WSYNC	
	LDA  #43	
	STA  TIM64T	
	LDA #0		
	STA  VSYNC 	

WaitForVblankEnd
	LDA INTIM	
	BNE WaitForVblankEnd	
	LDY #191 	

	STA WSYNC	
	STA VBLANK  	
	LDA #$F0	
	STA HMM0	

	STA WSYNC	
	STA HMOVE 	

	lda #0
	sta CTRLPF	;playfield ain't reflected

	lda #$F4
	sta COLUPF

	ldx #191


TitleShowLoop
	sta WSYNC 	
	lda PFData0Left-1,X           ;[0]+4
	sta PF0                 ;[4]+3 = *7*   < 23	;PF0 visible
	lda PFData1Left-1,X           ;[7]+4
	sta PF1                 ;[11]+3 = *14*  < 29	;PF1 visible
	lda PFData2Left-1,X           ;[14]+4
	sta PF2                 ;[18]+3 = *21*  < 40	;PF2 visible
	nop			;[21]+2
	nop			;[23]+2
	nop			;[25]+2
	;six cycles available  Might be able to do something here
	lda PFData0Right-1,X          ;[27]+4
	;PF0 no longer visible, safe to rewrite
	sta PF0                 ;[31]+3 = *34* 
	lda PFData1Right-1,X		;[34]+4
	;PF1 no longer visible, safe to rewrite
	sta PF1			;[38]+3 = *41*  
	lda PFData2Right-1,X		;[41]+4
	;PF2 rewrite must begin at exactly cycle 45!!, no more, no less
	sta PF2			;[45]+2 = *47*  ; >

	dex ; we *are* changing what title pixel we're on...
	beq DoneWithTitle ; ...unless we're done, of course
	jmp TitleShowLoop
DoneWithTitle	

	lda #0
	sta PF0                 ;[4]+3 = *7*   < 23	;PF0 visible
	sta PF1                 ;[11]+3 = *14*  < 29	;PF1 visible
	sta PF2                 ;[18]+3 = *21*  < 40	;PF2 visible
	



	LDA #2		
	STA WSYNC  	
	STA VBLANK 	
	LDX #30		
OverScanWait
	STA WSYNC
	DEX
	BNE OverScanWait
	JMP  MainLoop      
 
 
 
	org $F400

;--------------------------------------
;GRAPHICS
;--------------------------------------
GraphicsPage



;[[DATA]];


	org $FFFC
	.word Start
	.word Start


