PPU synchronization from NMI

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

tepples wrote:and it's not even really wasting if you defer computation of some of the written values until that line.
The code I use takes significantly less than a scanline:

Code: Select all

	;start setting the scroll before the horizontal blank (48 cycles)
	lda ScrollX+1
	lsr
	lda ScrollY+1
	rol
	asl
	asl
	sta PPUADDR
	lda ScrollY+0
	sta PPUSCROLL
	asl
	asl
	and #%11100000
	ldx ScrollX+0
	sta ScrollX+0
	txa
	lsr
	lsr
	lsr
	ora ScrollX+0

	;finish setting the scroll during HBlank (11 cycles)
	stx PPUSCROLL
	sta PPUADDR
	stx ScrollX+0
But yeah, it makes sense to do these operations as the scanline is rendered, and have the final writes fall within HBlank. That way only a portion of the time will be wasted.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Post by Banshaku »

I see. I will need to check what was the issue in details once I can remember the code since I didn't touch for 7 months. I was just prototyping at the time so the code is not stable yet.

As for wasting time, this is not much an issue in my case since I only need to do this during screen transition so nothing intensive happen during that phase.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: PPU synchronization from NMI

Post by thefox »

Broken link in the original post, can somebody repost in an attachment? (Preferably a mod or blargg should edit the original post to include the attachment...)
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
freem
Posts: 176
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: PPU synchronization from NMI

Post by freem »

this link appears to still work: http://slack.net/~ant/old/nes-code/nmi_sync.zip

I've attached it to this post so it won't get lost in the future.
Attachments
nmi_sync.zip
(8.34 KiB) Downloaded 648 times
Post Reply