nesdev.com
http://forums.nesdev.com/

How do games with multidirectional scrolling display tiles?
http://forums.nesdev.com/viewtopic.php?f=10&t=16696
Page 1 of 1

Author:  YTisRW [ Fri Nov 10, 2017 5:39 pm ]
Post subject:  How do games with multidirectional scrolling display tiles?

I have been getting into NES programming using NESASM3 to better understand computers in a lower level.

Right now I'm having a hard time wrapping my head around games like Kirby and Battletoads that use multiple screens and yet hardly use nametables at all. Particularly Battletoads.

How is Battletoads able to display dozens of backgrounds even though the nametables show nothing but the status bar and the pattern tables don't have any of those background tiles either?!
I know for 4-screen data you need extra VRAM addresses in the ROM file, but even if thats how it works that doesn't explain how the tiles get on the screen.

With Kirby, it's a little different.
The tiles are loaded into the PPU and you can see the actual screen scroll in the nametable, but then the status bar tiles are not in the PPU, even though theres a bunch of garbage tiles that show the status bar is there! :?

I have google searched questions and looked at dozens of NES programming sites, but nobody seems to ask those questions or even talk about it in an official or satisfying way.

If anyone can PLEASE explain this or direct me to any mapper or site where I can read up on this, I will greatly appreciate it.

Author:  tokumaru [ Fri Nov 10, 2017 5:49 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

YTisRW wrote:
How is Battletoads able to display dozens of backgrounds even though the nametables show nothing but the status bar and the pattern tables don't have any of those background tiles either?!

Which emulator are you using to visualize the name and pattern tables? IIRC, Battletoeads starts the frame with rendering disabled, and it switches name tables mid-screen to switch from the status bar to the gameplay graphics. These types of mid-screen changes only show in the final output, while the debug windows will only show the state of everything in a determined instant. By default, this instant is usually the start of the frame, but in FCEUX for example you can change the "Display on scanline" box to see the state of the video in other moments. If you set it to a scanline further down the screen (e.g. 50) you should be able to see Battletoads' backgrounds.

The issue with Kirby is similar. It uses CHR bankswitching mid-screen to switch in the status bar patterns, but since you're visualizing the state of the name tables on scanline 0, those patterns have not yet been switched then, so the status bar looks like garbage. Change the "Display on scanline" box to 220 or something and you should see the opposite: the status bar is displayed correctly but the playfield area is garbled.

EDIT: Mesen also lets you specify on which scanline (and cycle!) to sample the PPU, but Nintendulator doesn't.

Author:  YTisRW [ Fri Nov 10, 2017 6:00 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

tokumaru wrote:
YTisRW wrote:
How is Battletoads able to display dozens of backgrounds even though the nametables show nothing but the status bar and the pattern tables don't have any of those background tiles either?!

Which emulator are you using to visualize the name and pattern tables? IIRC, Battletoeads starts the frame with rendering disabled, and it switches name tables mid-screen to switch from the status bar to the gameplay graphics. These types of mid-screen changes only show in the final output, while the debug windows will only show the state of everything in a determined instant. By default, this instant is usually the start of the frame, but in FCEUX for example you can change the "Display on scanline" box to see the state of the video in other moments. If you set it to a scanline further down the screen (e.g. 50) you should be able to see Battletoads' backgrounds.

The issue with Kirby is similar. It uses CHR bankswitching mid-screen to switch in the status bar patterns, but since you're visualizing the state of the name tables on scanline 0, those patterns have not yet been switched then, so the status bar looks like garbage. Change the "Display on scanline" box to 220 or something and you should see the opposite: the status bar is displayed correctly but the playfield area is garbled.


Idk how to reply so I'm just gonna quote.
You don't know how happy I am that you replied.

I was using FCEUX to view this and better understand it.

If it switches the nametables mid-frame, does it also do that for the tiles in the pattern tables too?

EDIT: I just finished reading your entire comment and realized you answered that already, sorry.

Author:  tokumaru [ Fri Nov 10, 2017 6:04 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

YTisRW wrote:
If it switches the nametables mid-frame, does it also do that for the tiles in the pattern tables too?

Battletoads doesn't, because it uses 8KB of CHR-RAM without bankswitching... The pattern tables are showing just fine for me though, they aren't blank. What version of FCEUX are you using?

Author:  YTisRW [ Fri Nov 10, 2017 6:06 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

tokumaru wrote:
Battletoads doesn't, because it uses 8KB of CHR-RAM without bankswitching... The pattern tables are showing just fine for me though, they aren't blank. What version of FCEUX are you using?


I'm using 2.2.2.

Author:  pubby [ Fri Nov 10, 2017 6:09 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

Battletoads uses 4-screen mirroring which means only one nametable is visible while the other is off-screen in memory. FCEUX doesn't show the off-screen nametable.

Also, understand that the PPU outputs scanline by scanline, starting at the top and working downwards. If you modify the PPU's state mid-frame, future scanlines will look different. Because of this, you can't always look at a single nametable and say "This is how the game will look!". Instead you have to think on a scanline-by-scanline basis.

Author:  tokumaru [ Fri Nov 10, 2017 6:15 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

YTisRW wrote:
I'm using 2.2.2.


That's pretty old... But now I realized you didn't say the pattern tables were blank, just that the tiles visible on the screen aren't there. Well, from what I can see they're all there, they're just being displayed with the same palette, since the emulator doesn't know which tiles use which palettes (it could in theory be smart and get that information from the name/attribute tables, although it could get confused if the same tiles are displayed using different palettes in different places), so by default all tiles are using the first palette. You can right-click on the patterns to cycle through the palettes, but that changes the colors of all tiles. Also notice that each debug windows has its own "display on scanline" box.

pubby wrote:
Battletoads uses 4-screen mirroring which means only one nametable is visible while the other is off-screen in memory. FCEUX doesn't show the off-screen nametable.

That's 1-screen name table mirroring (1 name table mapped to all 4 slots), 4-screen is 4 unique nametables mapped to the 4 slots at all times.

Author:  YTisRW [ Fri Nov 10, 2017 6:27 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

I just downloaded Mesen and realized how much I have missed.

I see now, that the IRQ is used to draw the tiles at a different time.
Thanks.

Author:  tokumaru [ Fri Nov 10, 2017 6:44 pm ]
Post subject:  Re: How do games with multidirectional scrolling display til

Mesen has a ton of useful debug tools, probably more advanced than FCEUX. The only reason I don't use it more often is because it's a little too heavy for the old laptop I use for development.

Yes, Kirby uses IRQs to know when to change the scroll and the pattern table to display the status bar. Battletoads on the other hand uses timed code and sprite 0 hits to time its effects.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/