How do some games change vertical scroll at IRQ?

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

Post Reply
100th_Coin
Posts: 2
Joined: Wed Jun 16, 2021 3:48 pm

How do some games change vertical scroll at IRQ?

Post by 100th_Coin »

To quote the wiki, "Changes made to the vertical scroll during rendering will only take effect on the next frame." But taking a look at Super Mario Bros. 3, the HUD clearly adjusts vertical position during the IRQ's interrupt. Looking through SMB3's disassembly, all it seems to do is write to the shift register like normal, but shouldn't the Y value only make changes on scanline -1?
100th_Coin
Posts: 2
Joined: Wed Jun 16, 2021 3:48 pm

Re: How do some games change vertical scroll at IRQ?

Post by 100th_Coin »

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

Re: How do some games change vertical scroll at IRQ?

Post by tokumaru »

The "normal" way of setting the vertical scroll (i.e. via $2000 and $2005) does not work mid-frame. Using $2006 you can partially modify the vertical scroll mid-frame (the fine Y scroll can't be > 3). Using combined $2005 and $2006 writes you can set the scroll to whatever you want.
User avatar
Controllerhead
Posts: 314
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: How do some games change vertical scroll at IRQ?

Post by Controllerhead »

The trick is, and what took me a while to understand admittedly, is you have to load the top left of the nametable address into PPU_ADDR ($2006). It's not just a matter of setting the coordinates with PPU_SCROLL ($2005) as one might assume.
Image
Post Reply