
	processor 6502
	include "vcs.h"
	include "macro.h"
	
	seg.u vars
	org $80
	
Horizontal		ds 1
	
	seg code
	org $F800
	
Start
	CLEAN_START
	
	lda #$1F
	sta COLUP0
	
	lda #$FF
	sta GRP0
	
	sta WSYNC
	sta RESP0
	
Start_Frame
	lda #2
	sta VBLANK
	sta VSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	lsr
	sta VSYNC
	
	ldy #37
VerticalBlank
	sta WSYNC
	dey
	bne VerticalBlank
	
	sty VBLANK
	
	ldy #192
Picture
	sta WSYNC
	dey
	bne Picture

	
	lda #2
	sta VBLANK
	
	ldy #30
OverScan
	sta WSYNC
	dey
	bne OverScan
	
	lda INPT4
	bmi No_Button

	jsr ResetSync
	inc Horizontal
	
No_Button
	
	jmp Start_Frame
	
ResetSync	
	ldy Horizontal
	sta WSYNC
DelayLoop
	dey
	bne DelayLoop
	sta RSYNC
	rts
	
	org $FFFC
	.word Start
	.word Start
	
