fi, en, (sv, ja, hu, yi) | avatar by https://twitter.com/udonkimuchikaki


libera.chat, irc.sortix.org
nortti
microblog (that is, a blog with small entries)
microblog.ahti.space/nortti

rgmechex
@rgmechex

I'm hard at work trying to get the next video for the channel done soon, so I'm cheating this week. If you followed me (IsoFrieze) on Twitter about 3 years ago, I already talked about this there. But it's the exact sort of thing I love talking about so I don't mind sharing it again!

This will be the short story of why the grass metatile in the castle intro cutscenes in Super Mario World changed in the PAL v1.1 release of the game.

Two grass tiles, the first of which looks much better What a sad downgrade.

First lets look at the original grass metatile that was used here.

The ledge metatile made up of tiles $1C3, $1C4, $1D3, and $1D4 Only these four tiles are used for the grassy ledge. There are actually a few empty tiles in this graphics file but those weren't utilized.

It is made up of 4 unique 8x8 tiles that are found within a graphics file that is used with the castle tileset. It is also one of the more uncommon metatiles that uses more than one palette--the top half uses the green palette and the bottom half uses the yellow palette. (Yes this is important.)

This single metatile is repeated horizontally to create the ground in these cutscenes. Since the castle tileset is loaded at this point, the standard grassy ledge tiles are not available. Hence this extra grass metatile.

A grassy ledge So green and lush.

Now, for whatever reason, Super Mario World has the camera set up in such a way that a single pixel of the bottom row of metatiles of a level is visible. Granted, most of the time this was cut off by CRT overscan, but in some cases, it was actually visible to the player. This leaves an ugly gap where you can see the background shine through if you only make the ground one tile high.

Mario entering a castle; you can see the background poking through on the very bottom of the image Might be hard to see, but the bottom row of pixels lets the background poke through.

So the proper solution would be to also create a metatile that is only dirt with no grass. Which is exactly what they did. However, if you look at the tiles above, the shadow of the grass bleeds onto the yellow dirt tiles. This seems to be done on purpose, so that the shadow can be brown, which is a color only available to the yellow palette and not the green palette.

Now, you could create an extra tile that has only dirt and no shadow that would make up this dirt-only metatile. But since the only visible part of this metatile was going to be the very first row of pixels, the developers just reused the same tiles with the shadows, except they flipped them vertically so that the shadow wasn't visible.

The dirt metatile made up of tiles $1D3 and $1D4, but flipped vertically Why do more work when you don't have to?

This results in a weird looking metatile that doesn't look right at all. But! It solves the problem at hand. This metatile can be inserted on the bottom row of the level, and now that gap is non-existent.

Mario entering a castle; you can see the background poking through on the very bottom of the image Hmmmm, nothing has changed...

Wait, what? Why is it still there?

Well, turns out there was a bug with this ledge object that prevented it from being drawn properly, and it wasn't caught before release! Maybe the testers were playing on a CRT that didn't let them see the bottom row of pixels.


Here's the code responsible for writing metatile data for this ledge object:

; $0DC4C9: Write the grassy castle ledge object
Obj_GrassCastleLedge:
    LDY LevelLoadPos          ; offset of this metatile on this screen
    LDA LvlLoadObjSize
    AND #%00001111
    STA $00                   ; length of object goes in $00
    
    LDX $00                   ; write tile #$0109 (grass)
  - JSR WriteHighByte01
    LDA #$09
    JSR WriteLowByteMoveRight
    DEX
    BPL -
    
    JSR MoveDownAndReset      ; move down one row
    
    LDX $00                   ; write tile #$0086 (dirt)
  - JSR WriteHighByte00
    LDA #$86
    JSR WriteLowByteMoveRight
    DEX
    BPL -
    RTS

I don't want to get too much into the level loading routine of this game (it's a beast), but very quickly: the routine WriteLowByteMoveRight writes the metatile index to memory and advances the metatile pointer one block to the right. It takes care of screen boundaries--that is, if the metatile gets written to screen Z at X=15, then it knows to update the next position to be screeen Z+1 at X=0. The routine MoveDownAndReset moves this pointer down one row and resets the X position to be whatever it was at the start of this object (sort of like a carriage return). However! It does not revert the screen number! If advancing to the right results in crossing a screen boundary, the second row will be written to the adjacent screen instead. Which is exactly what happens:

The raw tilemap of the castle intro cutscene level; the ledge is split in half and part of it is out of bounds The camera is fixed so you never get to see the rest of the ledge (even if you'd only see 1 row of pixels of it).

So in the PAL v1.1 release, which shows an additional 15 rows of pixels at the bottom of the screen, this bug was easily noticed and fixed. You can find that in my disassembly here, but essentially it just saves the main pointer to a temporary register before writing the first row, and restores it afterwards. This ensures both rows of this object are drawn on the same screen. This push/pull pair of routines is used by a lot of other objects as well, so this one was just left out.

So now the ledge looks like this:

Mario entering a castle; now there is no gap, but the dirt tile looks wrong No more gap! But now there's a different problem...

Oh yeahhhh, now that the screen is bigger we can actually see that ugly metatile. Time to fix that!


So remember what I said about the shadow bleeding into the bottom pair of tiles not being a problem? Well now it is. The developers decided not to use any additional tile graphics, and they only modified what was already existing in place. This means squeezing the shadow into the upper half of the metatile.

The ledge metatile made up of the same four tiles, except they look worse since the shadow is forced into the upper 8x8 tiles They did their best.

This makes the yellow dirt tiles nicely repeatable, but also forces the shadow to be a shade of green now. It doesn't really look too great, but since it's only used in these intro cutscenes, I guess it was called good enough.

Mario entering a castle; now there is no gap, and it looks fine Finally it's fixed!

If you look carefully, you'll notice that the completely dirt metatile is also no longer mirrored vertically, and just repeats normally downward. I'm surprised they didn't shuffle the tiles in like a checkerboard pattern since you can really notice the repetition now.


You can support Retro Game Mechanics Explained on Patreon here! Any and all support is greatly appreciated!


You must log in to comment.

in reply to @rgmechex's post:

that's really neat, actually! just changing the tiles seems like a sensible solution to the problem of "we can see like a whole extra row of tiles now ffuck what do we do to make it not look ass" since theyve only got the one use anyway