This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Dealing with large worlds/maps, screen panning

Dealing with large worlds/maps, screen panning
by on (#234944)
Calling all nesdev folks! :-)

A user over on the SNESdev board is having trouble understanding how one goes about implementing the part of a game/video engine that handles, essentially, updating the edges of the screen before doing scrolling/panning.

While the SNES is certainly a bigger and different beast than the NES -- for example, it has enough PPU RAM to hold 2x2 screens worth of data, has actual dedicated BG scroll/position X and Y MMIO registers, handles 4-way scrolling easier, has native DMA for transferring data to/from PPU RAM, has more RAM (~128KB), does not have CHR-ROM, etc. -- the overall model/methodology is exactly the same: you have to keep track of "where" in your map data you are (e.g. upper left corner) pointer-wise, correlate or convert that into SC data ("nametable" in NES terms), only update things in columns (e.g. 32) when panning left/right or things in rows (e.g. 1) when panning up/down, and all the related nuances.

It's a complicated subject simply because of, well, how complicated it can get. I myself have struggled for years trying to mentally grasp implementing this exact type of thing. (I still have hand-written 65816 assembly I wrote during high school trying to do this exact thing, heh. It's several pages, maybe 50% done, and I never bothered trying it.)

I was hoping folks might be able to chime in there, describing the overall implementation/methodology used in your engine/game, including all the stuff you keep track of at the variable level -- or if there are websites, docs, etc. describing all of this, linking them. Visuals I think would also help, if/where applicable.

Re: Dealing with large worlds/maps, screen panning
by on (#234948)
The most relevant visual I'm aware of is still this one from "PPU scrolling". But as that post is worded, it mostly seems to say "How should I traverse my tilemap data structures to generate the data for the column of tiles?"
Re: Dealing with large worlds/maps, screen panning
by on (#234949)
That visual is for understanding how BG scrolling/panning works. It's helpful, but only in understanding scrolling, and is substantially more NES-specific (especially with regards to nametable addresses, mirroring, and the nuances of $2000/2005/2006 -- several of these nuances are not really pertinent to the SNES). The official SNES manual actually sort of covers how the BG scroll registers work, including visuals (obviously not animated) (see my post in the thread for pages/reference material).

In either case, nothing seems to go over how to actually do all of this when it comes to a game engine. Using NES terms: correlating nametable data with your own "world map data", how to store/manage all of that (this will vary per game/engine/nees), *and* how to implement/code something that handles the relationship (code-wise) between all of that and BG scrolling/panning (where NES vs. SNES becomes more relevant).

I think the general concept/model of how to implement and solve this is universal across lots of systems (NES, SNES, Genesis, PC, etc**) -- you update edges of the screen (or part of "off-screen" memory). The complexity lies in correlating all of that with your own in-memory (ROM or RAM) "world".

Your last two paragraphs in this post start to touch base on that, and is super helpful.

** -- Apple II series is excluded because it had no screen panning capability (even on the IIGS) and due to how its graphics were implemented, both of which is why full-screen scrolling games basically never happened. Simple and hi-res graphics modes were different than the IIGS's graphics, with a lot less data involved -- but even Karateka, for example, gives the impression of scrolling/panning through some visual trickery but doesn't actually pan.
Re: Dealing with large worlds/maps, screen panning
by on (#234973)
@Tepples -- can the previous two posts be moved into the proper thread somehow?
Re: Dealing with large worlds/maps, screen panning
by on (#234985)
Posts have been moved. Locking duplicate topic.