Jump to content

Photo

Beginner Timing Issues


3 replies to this topic

#1 Troy Fullwood OFFLINE  

Troy Fullwood

    Combat Commando

  • 2 posts

Posted Tue May 1, 2018 8:41 AM

My kernal timing is off by several scanlines; what am I doing wrong?

NewFrame
	VERTICAL_SYNC
	lda #44	;(37*76+13)/64=44
	sta WSYNC
	sta TIM64T
	jsr VRoutine
VWait
	lda INTIM
	bne VWait
	
	lda #0
	sta VBLANK
	ldx #192	;192 scanlines
	
	
ScanLoop
	sta HMCLR		;Clear horiz. pos.
	dec M0_COUNT
	bpl SkipMoveM0	;If M0_Count < 0, then move M0
	lda #M0_SLOPE	;Reset M0_COUNT
	sta M0_COUNT
	lda #$F0	;-1 nybble in two's complement
	sta HMM0	;move 1 pixel left
SkipMoveM0

	sta WSYNC
SkipWSYNC
	sta HMOVE
	dex
	bne ScanLoop
	
	
	
Overscan
	lda #35	;(30*76+13)/64=35
	sta WSYNC
	sta TIM64T
	jsr ORoutine
OWait
	lda INTIM
	bne OWait
	
	jmp NewFrame


#2 kdgarris OFFLINE  

kdgarris

    Moonsweeper

  • 319 posts

Posted Tue May 1, 2018 10:13 AM

You are missing the lines for VSYNC, nor are you generating the signal in your display.  You will want to add something like this before setting your vblank timer:

        lda #2      ; LoaD Accumulator with 2 so D1=1
        sta WSYNC   ; Wait for SYNC (halts CPU until end of scanline)
        sta VSYNC   ; Accumulator D1=1, turns on Vertical Sync signal
        sta WSYNC   ; Wait for Sync - halts CPU until end of 1st scanline of VSYNC
        sta WSYNC   ; wait until end of 2nd scanline of VSYNC
        lda #0      ; LoaD Accumulator with 0 so D1=0
        sta WSYNC   ; wait until end of 3rd scanline of VSYNC
        sta VSYNC   ; Accumulator D1=0, turns off Vertical Sync signal

This was taken from this tutorial.  Alternately, you can also set a shorter timer for the VSYNC time if you want to make use of those extra cycles.

 

The tutorial series pinned to the "2600 Programming For Newbies" forum also describes TV timings, etc. in great detail.



#3 TheHoboInYourRoom OFFLINE  

TheHoboInYourRoom

    Moonsweeper

  • 375 posts
  • Whackadoo thingamajig
  • Location:Illinois

Posted Tue May 1, 2018 4:27 PM

You are missing the lines for VSYNC, nor are you generating the signal in your display.

No, Troy's code uses the VERTICAL_SYNC macro from, presumably, macro.h.



#4 kdgarris OFFLINE  

kdgarris

    Moonsweeper

  • 319 posts

Posted Tue May 1, 2018 6:12 PM

Ahh, good point. I can't see anything that would cause it, then, unless either the VRoutine or ORoutine use too many cycles.




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users