MMC3 "3D" scrolling tricks

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Celius
Posts: 2159
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

MMC3 "3D" scrolling tricks

Post by Celius »

Okay, I'm really wondering how games like 3D World Runner do their 3D tricks. Does anybody know? Is there some sort of 2D to 3D formula that they use? It really doesn't make much sense to me how they do it, and I was just curious, because I'd like to know so in the far far away future, maybe I can use it somehow.

I'm not planning on making any 3Dish games yet, but maybe I'd like to make a small tech demo. Is this way too complicated even for someone who has been doing nesdev for a long time?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

It's a raster effect, and it's easiest to understand Pole Position first. I wrote much of Wikipedia's article on parallax effects.
-_pentium5.1_-
Posts: 76
Joined: Sat May 13, 2006 1:05 pm
Location: USA

Post by -_pentium5.1_- »

Speaking as a non-developer, I don't know much about the math. I would like to clarify that "3D-type" parallax scrolling on the NES uses timed code to decide the scroll position(?) for each scanline; a mapper-based IRQ (if present) is used only to define the start or end of the effect. (I'm just trying to explain why the thread's title is inaccurate; feel free to correct me on this oversimplification.)
This signature intentionally contains no text other than this sentence.
Celius
Posts: 2159
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius »

EDIT: Okay, I think I get the concept of layers. But still, how does stuff come towards the screen? How do they create that effect? Do they do anything with the CHR data? Or is it just warping whats already on screen?
LocalH
Posts: 180
Joined: Thu Mar 02, 2006 12:30 pm

Post by LocalH »

Sprites for different Z-levels coupled with 3d-to-2d coordinate conversion and sprite selection.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

I think that the effect in 3D World Runner is much simpler than the one in Cosmic Epsilon. That one actually has different patterns on the ground, instead of a simple checkerboard. I still don't understand how that one is done.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

3D world runner is UNROM, not MMC3, so your title is wrong. (note that the original verison was on FDS). There is also it's japaneese-only sequel, but it is the exact same game engine with better graphics and different levels (there is the same ending, tough).
It use some tricky horizontal scrolling change to make the chessboard look 3D. I don't even think the vertical scroll is changed mid-frame in 3D-world runner.
Sprites are level of farity (does it say that way ?) so a sigle sprites is present smaller and bigger in the pattern table to look far and near respectively.
The ground just move forwards, I'm unsure how this is done, but it is nothing complex. For pits, the BG rendering is disabled, but not sprites. That's it all.

Rad Racer is exactly the same but a bit more complex. There is no chessboard, but a pre-rendered flat 3D road, and its moving is done by palette cycling. Then, road curves are done by changing horizontal and vertical scrolling. It looks much more impressive. As above the objects have level of detail, where each car/three/whatever comes in many size to look 3D.

Rad Racer II uses MMC3, but it is basically the same, but in more advanced. It use 4-screen mirroring to memorise a lot of different pre-rendered 3D road tiles, and doesn't use palette swapping any longer. I think the MMC3 helped with CHRROM switching, allowing the game to use more tiles. It's IRQ counter may also help the life of squaresoft programmers.
Useless, lumbering half-wits don't scare us.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Bregalad wrote:Sprites are level of farity (does it say that way ?)
I don't think this is a word.. =) I assume you meant that there are sprites avaliable for various possible distances.
The ground just move forwards, I'm unsure how this is done, but it is nothing complex.
It could be a palette change, but I don't think it is. There is a game that alternated between two CHR banks, one with the colors inverted when compared to the other. But since UNROM has no bankswitching, it's probably not that either. I guess it can "slide" the scroll a full square to the left or to the right whenever it has to alternate the rows on the floor.

For Cosmic Epsilon, no matter how much I watch the pattern tables and the name tables I can't figure out how that effect is done. It has bitmaps on the floor! That's texture mapping! And it uses more than 2 colors! That's pretty amazing for me.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Cosmic Epsilon zips at 3:1, so it's probably really repetitive.

It seems to use Yoshi's Island style texture mapping, where each possible texture row is pre-rendered into a triangle shape and then bankswitched on each scanline.
Celius
Posts: 2159
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius »

Oh! I kind of get it! They just do a pallete change for all of the tiles on 3D world runner? That's not complicated really. And for sprites, don't they just have all sprite sizes in the pattern tables? But yeah, I don't get how Cosmic Epsilon's levels work. I am trying to think of methods for making more detailed floors.

We should try and figure out Cosmic Epsilon's flooring here. So what we can see:

There appears to be nothing in the Name Tables besides the city background.

Nothing that is on screen appears to be in the Pattern Tables.

There is only one attribute used for the whole ground (That's not anything special, but oh well.)


I still can't see how you can do pallete changes to color things that small without having anything in the pattern tables. I actually don't see how you can have anything without at least something in the pattern tables...
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Celius wrote:They just do a pallete change for all of the tiles on 3D world runner? That's not complicated really.
I don't know what exactly you mean by "all of the tiles", but although changing the palette is one of the options, I don't this is what World Runner does. Changing the palette is not so simple because you have to mess with 2006/2007, meaning you'd have to set 2005/2006 to point to the correct place for the next scanline. What I mean is that changing the palette is not that easy, and I don't think this is what this game does.
And for sprites, don't they just have all sprite sizes in the pattern tables?
Yeah, this is for sure.
There appears to be nothing in the Name Tables besides the city background.
There is. FCEUXD's Name Table Viewer has a "Display on scanline" field, wich you can set to 200 (or any other value that falls in the part of the screen where the special floor is). Then you'll see that the bottom part of the name table keeps changing through some predefined patterns.

It's probably like tepples said, the game has a bunch of pre-rendered floors, that are switched in as the different rows of squares need to be displayed. By timing the switches you can simulate the movement of going forward or backward.
Nothing that is on screen appears to be in the Pattern Tables.
Set the emulator to display scanline 200 here too and you'll see the fisrt half of the left pattern table swiching patterns that make up a section of the ground.
I still can't see how you can do pallete changes to color things that small without having anything in the pattern tables.
If you mean from one square to the other horizontally, then you really can't. You'll get distorted lines.
I actually don't see how you can have anything without at least something in the pattern tables...
Well, it is possible. Recently a demo that displays all the color of the NES was posted, and it didn't use any tiles, it was all done by manipulating the palette and the color emphasis at the right times. It would be very hard to use this concept for 3D floors, though.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

OK, I thing i get how the effect in Cosmic Epsilon works exactly.

The bottom half of the screen has a few stripes that come from far away until the bottom of the screen (pretty much like you see in the name tables of 3D World Runner). Now, the tiles used to draw those stripes are drawn in a way that each stripe uses it's own tiles.

So, by loading different tile sets, you can blank out specific stripes, set them to different colors, etc, wich results in different horizontal patterns. The name table is only set up once, and never changed again. The patterns for the bottom part of the screen, on the other hand, change a few times per frame, to create vertical patterns and movement.

It's not that hard, actually. It can waste a lot of CHR space, depending on how many different patterns you wish to be able to display. You you want to show true bitmaps on the floor you'll need tiles sets for all the combinations. With 8 stripes and 2 colors, there would be 256 combinations, and that'd be a lot of CHR space.

I think you'd better do it like Epsilon, keeping a few specific combinations, and you can even do more detailed things (such as the road you see on Cosmic Epsilon).

The idea is very creative...
Celius
Posts: 2159
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius »

Hmm, that's interesting. I think a level engine combining pallete changes and pattern table changes would be pretty cool. Is that what they do here? I mean, that's a little vague, sorry. Like, how they put the road with the white road strip (not strips like you were talking about, like an actual road strip) and just turn off the white part of the pallete for the individual dashes. Or is that not what they do? I have to look at it more, I guess.

Is it possible to take a fixed square tile (not strechted or anything), and stretch it towards the screen? I mean, is this possible at all? Because if I could figure out some way to do that, then that'd be really really cool. That'd be really tricky though. I think pretty much alot of things in NESdev are possible, just alot of them are rediculously tricky, like doing something like this. I'll think about it for a while. It's just an idea, though.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Celius wrote:Like, how they put the road with the white road strip (not strips like you were talking about, like an actual road strip) and just turn off the white part of the pallete for the individual dashes.
Easy. The game bankswitches between a bank containing a white strip and a bank not containing a white strip.
Is it possible to take a fixed square tile (not strechted or anything), and stretch it towards the screen? I mean, is this possible at all?
Vertical stretching of an entire row of tiles is possible, and this is how games such as Rad Racer make hills. Horizontal stretching, on the other hand, generally isn't doable on the NES unless you have an ASIC generating CHR data.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Celius wrote:I think a level engine combining pallete changes and pattern table changes would be pretty cool. Is that what they do here?
No, no palette changes here. It's just as tepples said, there is a bank where the space reserved for that stripe is white, and another where it's gray. Alternate between those 2 and you get a dashed stripe. You can see that if you use FCEUXD's name table viewer and set the scanline to 200, as I said before.

I can't think of one single game that changes the palette midframe. I mean, we know it is possible, but HBlank time is really tight, and having to fix the address in 2005/2006 for the next scanline does not make anything easier. You'd probably have to sacrifice some pixels that would otherwise be rendered, and that would introduce glitches. Not acceptable for most games.
Is it possible to take a fixed square tile (not strechted or anything), and stretch it towards the screen? I mean, is this possible at all? Because if I could figure out some way to do that, then that'd be really really cool. That'd be really tricky though.
Yes, it's the same as the "normal" scrolling effect that these games already use. They time the changes so that the squares seem to get bigger as they come closer, but if you change that timing you can get stretching effects quite easily.
Post Reply