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

Which mirroring to use when scrolling?

Which mirroring to use when scrolling?
by on (#48967)
In this topic we were talking about scrolling.

Bregalad wrote:
Quote:

What I had in mind (and I don't know if this is correct but the mega man series "seems" to do that) is to change the mirroring when I need to scroll up or down. This way you won't have any artifact in the over scan area. But because of the black bar... I cannot do that (I think).

Well if you want to know Mega Man 1&2 uses vertical mirroring all the way, and Mega Man 3-6 simulates 1-screen mirroring by setting it to horizontal when scrolling horizontally and vertical when scrolling vertically. Yes it does look a bit ugly on my overscan PAL TV, but not in emulators with default settings. And 99,5% of NES games are like that (the 0.5% are games that don't scroll). And I just made those numbers up, don't take them as accurate !


So what you're saying is that most game will simulate one screen mirroring? The only reason I would see that you would want to do that is because you don't have to worry about pattern table change since you technically always in the same one. Am I correct? That seems to make it simpler but at the cost of sloppiness on all side of the screen.

This is all theoretical since I didn't try it yet but what I had in mind was to use vertical mirroring while scrolling left and right. When you arrive at the end of the map, you switch to horizontal mirroring. I don't know if it's possible and I think there is catch: the final screen of the horizontal map must be in the right name table ($2000) to do it. This mean your map must be, how can I say, screen symmetric? It cannot be end in the middle of a pattern table. Then depending on how many screen you have, this will influence where you must start to write the first screen of the horizontal map.

For example, if you have 3 horizontal screen, you're fine since you will end up at $2000 at the end. On the other hand, if you have 2 screens, you must start writing your map at $2400 to be able to end at $2000.

This is what I "think" is possible and didn't try it yet. I always try to plan on how to approach the problem before coding, when possible. It impose you a few limitation on how you map are made and extra logic to decide when you finish to vertical scroll, in witch name table ($2000 or $2400) you must start to on the next horizontal scrolling based on the next map size.

Does my idea make sense? If my idea doesn't work then vertical scrolling will be my solution to limit the extra artifact.

by on (#48974)
The definitive answer for clean scrolling is certainly 4-screen mirroring, i.e. no mirroring at all. Carts with that configuration are very rare though, and I'm not certain about how hard it is to modify a cart to have it.

The next best thing, in my opinion, is using vertical mirroring and masking some of the top, or the bottom, or both, of the screen to hide glitches (Jurassic Park, Big Nose Freaks Out, my own game). Then I'd say using horizontal mirroring and masking the left side of the screen by hardware and the right side with sprites (Alfred Chicken, Felix the Cat).

The worst choice, in my opinion, is to have scrolling artifacts at the sides of the screen (Kirby's Adventure, SMB3). I can't believe how many famous games from big companies have these artifacts. They look awful!

Mega Man has very simple scrolling (only one type at a time), so it shouldn't be that hard to make it look right. If you are using the MMC3, the most logical choice would be to use vertical mirroring when scrolling sideways and horizontal mirroring when scrolling vertically. I don't see what the issue is with having to be aligned with a specific name table, since you can select the one to be displayed with register $2000.

For example, this is the name table layout with vertical mirroring:

Code:
+-------+-------+
|       |       |
|   A   |   B   |
|       |       |
+-------+-------+
|       |       |
|   A   |   B   |
|     M |       |
+-------+-------+

A is the first name table, B is the second, and M is Mega Man. If Mega Man climbs a ladder and goes up, you'll switch to horizontal mirroring and you'll get:

Code:
+-------+-------+
|       |       |
|   A   |   A   |
|       |       |
+-------+-------+
|     M |       |
|   B   |   B   |
|       |       |
+-------+-------+


Sure it will look wrong if you don't change the scroll, because Mega Man was in front of background A and now he's in front of background B. But all you really have to do is change the scroll (lower bits of $2000) so that we keep seeing background A (and background B is free to be redrawn), no big deal:

Code:
+-------+-------+
|       |       |
|   B   |   B   |
|       |       |
+-------+-------+
|     M |       |
|   A   |   A   |
|       |       |
+-------+-------+


This is why I think you are worrying too much about having the map aligned to the name tables. If it's not aligned, all you have to do is change the scroll to compensate before scrolling vertically.

What might be an issue is that different in map height you observed in MM9. If you leave 8 blank scanlines at the top and 8 at the bottom (simply by leaving blank tiles there and offsetting the vertical scroll by 8 pixels), you will not be able to keep them blank when scrolling vertically. Unless you use interrupts to manually blank those scanlines (like Jurassic Park does). You would only need this sort of special masking when actually scrolling, which shouldn't be a problem since the game is basically frozen anyway.

by on (#48976)
tokumaru wrote:
This is why I think you are worrying too much about having the map aligned to the name tables. If it's not aligned, all you have to do is change the scroll to compensate before scrolling vertically.


Ho. I was thinking too much like you said. When everything is theoretical, you can only guess how it work ;) I need to try it this weekend. Thanks for the drawn example, it's a lot easier to understand (I'm a visual person).

tokumaru wrote:
What might be an issue is that different in map height you observed in MM9. If you leave 8 blank scanlines at the top and 8 at the bottom (simply by leaving blank tiles there and offsetting the vertical scroll by 8 pixels), you will not be able to keep them blank when scrolling vertically. Unless you use interrupts to manually blank those scanlines (like Jurassic Park does). You would only need this sort of special masking when actually scrolling, which shouldn't be a problem since the game is basically frozen anyway.


Manually blank by interrupt? (!) You get me interested here. This seems to mean that the black line at the bottom, when scrolling vertically, would not be shown because they would be skipped? If that's possible then I want to know more details.

by on (#48978)
Quote:
So what you're saying is that most game will simulate one screen mirroring? The only reason I would see that you would want to do that is because you don't have to worry about pattern table change since you technically always in the same one. Am I correct? That seems to make it simpler but at the cost of sloppiness on all side of the screen.

No, no, no !! I was saying that 99.5% of games show unclean borders (especially at top&bottom).

If you use vertical mirroring for horizontal scrolling and horizontal mirroring for vertical scrolling (whew), like toku said, you should be fine without too much glitches as long as you change your scrolling direction on name-table aligned data. That's pretty much what Metroid does. However, this is NOT what Mega Man 3-6 does. They do it all the opposite (horizontal mirroring for horizontal scrolling, vertical mirroring for vertical scrolling) so that the playfield is always in NT #0, and NT #1 is always blank for the menu (in MM3) or used only on special places raster effects (MM4,5,6) (for example the Knight Man Level with spikes wouldn't have been (without terrible complications) possible with vertical mirroring, same applies with the first castle of SMB3.

Now there is no way you can have a "correct" or "wrong" way to scroll your map, you are free to do it the way you want.

by on (#48979)
Ho, sorry. I understood your comment the wrong way.

So with that way of mirroring, they use it for raster effect. I see. For my current test project there is no raster effect during that specific level so it's not an issue. They do it a few other place but I have no intention to remake the complete game (I'm not that crazy).

I know that in the end I'm the one that will ultimately decide how to scroll but it's always good to plan in advance because of the possible impact if you do the wrong decision from the get go. You commented about it in another thread too.

That irq thingy that Tokumaru said, if it does give me a solution without improvising data, I will be more than happy to try it.

by on (#48983)
Banshaku wrote:
That irq thingy that Tokumaru said, if it does give me a solution without improvising data, I will be more than happy to try it.

I gave some more thought to the subject, and concluded that having those blank scanlines can be more complicated than I initially thought. When scrolling up or down, the blank scanlines will have to be filled with something, or else there will be a very undesirable gap between screens. So if your screens are 14 metatiles tall and you draw them without a gap in between, when the camera arrives at it's destination it will be offset one metatile vertically compared to the previous horizontal scrolling section. Not that this is a problem for the hardware, but will make things harder to manage on the software side during horizointal scrolling (since the screens will not be aligned to the name tables anymore), much harder than it should be just to have that blank space.

I guess I'll have to say that the easiest choice is to make up the missing row, it will make everything else much easier.

by on (#49016)
tokumaru wrote:
I guess I'll have to say that the easiest choice is to make up the missing row, it will make everything else much easier.


Yeah, that's what I thought with my current knowledge about the nes. I banged my head a lot on the wall before arriving to this conclusion. Thanks to confirm that it was the better solution.

What came out of this discussion is that I worried too much about alignment and it's not an issue. This will simplify a lot of things.