Using window/shape mask directly on the background colour . . .

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

jeffythedragonslayer wrote: Wed Jun 29, 2022 6:40 am
rainwarrior wrote: Wed Jun 29, 2022 12:56 am I didn't mean to imply that it only does convex shapes, but you can do any convex shape with just 1 window. OP was talking about a "planet" which seems like it'd probably be convex.

I don't have a name for a shape that matches exactly the capabilities of 1 window. Convex is a subset of that. Maybe "horizontally convex"? The shape can either have 2 edges on a scanline (1 window) or 4 (2 windows).
Monotone polygon. With two windows you can draw the 5 pointed star and ninja star shapes as well:

https://en.m.wikipedia.org/wiki/Monotone_polygon
If the semi-transparent position numbers in Super Mario Kart are done with window/shape masking as I have been informed, it seems you can do some pretty sophisticated shapes in the right hands.

Now, how is something like this scaling Batman logo window/shape done, I wonder (can't be Mode 7 as there's an entire game's graphics behind it): https://youtu.be/ZfadgUz8uRE?t=488

Edit: Watching it in slow-mo, it actually looks like it might be done via cycling a few pre-cut-out shapes on a single background layer to create the effect of a nice Batman logo-shaped window smoothly scaling in and out. So, would that mean the shapes are basically all pre-drawn onto the single background tilemap in different positions and then it just jumps the correct part of the background into view at the appropriate time? Or would it be a matter of switching the tiles in view with other ones on the tilemap at the appropriate time? What's the way that's best done, jumping background position to show the part you want in-view or switching around tiles from the tilemap to display the shape you want when you want it (are those even different things or basically the same from the code's point of view)?
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Using window/shape mask directly on the background colour . . .

Post by Pokun »

I thought you could do about any shape using a Window. The thing is that you can only control a Window's horizontal start and end position on the screen, while the height is always the full height of the screen. HDMA has to be used to change the horizontal start position each line as the screen is drawn to fully manipulate the shape of the cutout for more advanced shapes.

So Streets of Rage 2 seems to have the top part of the sky black to hide the fact that there is no parallax background behind it the HUD? Simple yet very nicely done as it seems to melt in pretty well.

dougeff wrote: Tue Jun 28, 2022 7:01 pm the "window" on the Sega Genesis and the Gameboy work like a static (non-scrolling) layer... and not at all like the SNES "windows" that just punch holes in real layers.
Yeah I always thought that to be funny too.
Basically Megadrive and Gameboy uses the term "Window" to mean a dialogue box type of window since the "Window" on those systems is basically just another tiled background layer with some special rules and limitations.
The SNES and SuperGrafx uses the term "Window" to mean a hole or "window" cut out in a graphics layer.
I could swear I saw some other video hardware that uses the SNES/SuperGrafx type of advanced display priority control Window, but I can't remember what it was. CPS1 maybe? Or X68000? Maybe it was just my imagination.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using window/shape mask directly on the background colour . . .

Post by rainwarrior »

iNCEPTIONAL wrote: Wed Jun 29, 2022 6:49 amNow, how is something like this scaling Batman logo window/shape done, I wonder (can't be Mode 7 as there's an entire game's graphics behind it)

...

What's the way that's best done, jumping background position to show the part you want in-view or switching around tiles from the tilemap to display the shape you want when you want it (are those even different things or basically the same from the code's point of view)?
You can see that the BG3 HUD disappears when the logo appears, so I'd definitely suspect it's BG3. The shape has too many changes on the horizontal for a window.

You can easily upload 0.5k (16x16) or 2k (8x8) to replace an entire screen of tilemap in a single vblank, with tons of time left over if it needs to swap in tiles as well (especially since they're only 2bpp). I don't think this needs to be pre-loaded at all. (See: Tom & Jerry prototype, or TMNT tossing enemies at the screen for similar examples.)
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using window/shape mask directly on the background colour . . .

Post by rainwarrior »

iNCEPTIONAL wrote: Wed Jun 29, 2022 6:49 amIf the semi-transparent position numbers in Super Mario Kart are done with window/shape masking as I have been informed, it seems you can do some pretty sophisticated shapes in the right hands.
The numbers 1 2 3 4 5 6 7 8 9 never have more than two vertical strokes side by side, so they're all shapes you can do with 2 windows.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

rainwarrior wrote: Wed Jun 29, 2022 1:10 pm
iNCEPTIONAL wrote: Wed Jun 29, 2022 6:49 amIf the semi-transparent position numbers in Super Mario Kart are done with window/shape masking as I have been informed, it seems you can do some pretty sophisticated shapes in the right hands.
The numbers 1 2 3 4 5 6 7 8 9 never have more than two vertical strokes side by side, so they're all shapes you can do with 2 windows.
Yeah, and it works really well. Once I saw those, I realised that the window/shape masking really is pretty versatile.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

rainwarrior wrote: Wed Jun 29, 2022 12:31 pm
iNCEPTIONAL wrote: Wed Jun 29, 2022 6:49 amNow, how is something like this scaling Batman logo window/shape done, I wonder (can't be Mode 7 as there's an entire game's graphics behind it)

...

What's the way that's best done, jumping background position to show the part you want in-view or switching around tiles from the tilemap to display the shape you want when you want it (are those even different things or basically the same from the code's point of view)?
You can see that the BG3 HUD disappears when the logo appears, so I'd definitely suspect it's BG3. The shape has too many changes on the horizontal for a window.

You can easily upload 0.5k (16x16) or 2k (8x8) to replace an entire screen of tilemap in a single vblank, with tons of time left over if it needs to swap in tiles as well (especially since they're only 2bpp). I don't think this needs to be pre-loaded at all. (See: Tom & Jerry prototype, or TMNT tossing enemies at the screen for similar examples.)
With the TMNT tossing enemies at the screen, the three or so poses are all pre-loaded onto a single background layer and just positioned onscreen accordingly during each frame of the animation, right?

But in Tom & Jerry it's swapping in a whole new set of tiles for each animation frame, correct?
Last edited by iNCEPTIONAL on Wed Jun 29, 2022 1:51 pm, edited 1 time in total.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

Pokun wrote: Wed Jun 29, 2022 12:20 pm I thought you could do about any shape using a Window. The thing is that you can only control a Window's horizontal start and end position on the screen, while the height is always the full height of the screen. HDMA has to be used to change the horizontal start position each line as the screen is drawn to fully manipulate the shape of the cutout for more advanced shapes.

So Streets of Rage 2 seems to have the top part of the sky black to hide the fact that there is no parallax background behind it the HUD? Simple yet very nicely done as it seems to melt in pretty well.

dougeff wrote: Tue Jun 28, 2022 7:01 pm the "window" on the Sega Genesis and the Gameboy work like a static (non-scrolling) layer... and not at all like the SNES "windows" that just punch holes in real layers.
Yeah I always thought that to be funny too.
Basically Megadrive and Gameboy uses the term "Window" to mean a dialogue box type of window since the "Window" on those systems is basically just another tiled background layer with some special rules and limitations.
The SNES and SuperGrafx uses the term "Window" to mean a hole or "window" cut out in a graphics layer.
I could swear I saw some other video hardware that uses the SNES/SuperGrafx type of advanced display priority control Window, but I can't remember what it was. CPS1 maybe? Or X68000? Maybe it was just my imagination.
Again, it's not another tiled background layer but part of one of the other layers that is sacrificed to be used as a "window" section of said layer on Genesis (at least based on everything I've read about how it works). So, just to be clear, it's still always only two background layers on Genesis, unlike with SNES where it's the four background layers plus window/shape making, which can be cut into layers or done more like an effect on top of all the layers (effectively allowing for two faux [mostly silhouette style] layers). Just want to point that out because I often read online that the Genesis has two background layers, a window layer and sprite layer for basically four in total (that's how it's "sold" on the Genesis blogs and the like), which isn't quite true. And, if people can put it like that for Genesis then we can just as easily claim the SNES had four background layers, the sprite layer and two window/shape layers for a total of seven layers. But no one claims the SNES has seven layers, even though it's technically more true than the Genesis having four layers. Well, I do when I'm in an argument with some Genesis fanboy and really want to wind them up. LOL
Last edited by iNCEPTIONAL on Wed Jun 29, 2022 2:10 pm, edited 1 time in total.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using window/shape mask directly on the background colour . . .

Post by rainwarrior »

iNCEPTIONAL wrote: Wed Jun 29, 2022 1:38 pmWith the TMNT tossing enemies at the screen, the three or so poses are all pre-loaded onto a single background layer and just positioned onscreen accordingly during each frame of the animation, right?

But in Tom & Jerry is swapping in a whole new set of tiles for each animation frame, correct?
TMNT IV does just seem to keep 2 frames of animation for it constantly loaded on the same BG3 tilemap it uses for the HUD. The tiles take up about 2k, the tilemap takes up about 4k. (You can see that it has to cut off the top of the image to accomodate the HUD when it overlaps.)
tmnt4_big_throw_foot.png
Jerry uploads both a new tilemap and a new tileset in a single frame, whenever needed.

TMNT could probably have just switched tilemaps, and uploaded 1k tilemap + 1k tiles when needed (2k always needed), but by using 6k of always loaded memory they don't have to think about managing it, I guess.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

rainwarrior wrote: Wed Jun 29, 2022 1:55 pm
iNCEPTIONAL wrote: Wed Jun 29, 2022 1:38 pmWith the TMNT tossing enemies at the screen, the three or so poses are all pre-loaded onto a single background layer and just positioned onscreen accordingly during each frame of the animation, right?

But in Tom & Jerry is swapping in a whole new set of tiles for each animation frame, correct?
TMNT IV does just seem to keep 2 frames of animation for it constantly loaded on the same BG3 tilemap it uses for the HUD. The tiles take up about 2k, the tilemap takes up about 4k. (You can see that it has to cut off the top of the image to accomodate the HUD when it overlaps.)
tmnt4_big_throw_foot.png

Jerry uploads both a new tilemap and a new tileset in a single frame, whenever needed.

TMNT could probably have just switched tilemaps, and uploaded 1k tilemap + 1k tiles when needed (2k always needed), but by using 6k of always loaded memory they don't have to think about managing it, I guess.
It's a pretty interesting way of doing that effect in TMNT, and also impressive that it's never obvious during actual play that the character being thrown into the screen is limited by the three colours per tile restriction of layer 3. A novel and effective solution, and something that would be hard to do on Genesis, especially given two full backgrounds and even part of background 3 are normally used for the levels and overlaid HUD in the SNES game. You'd have to waste a lot of sprites to do the same thing on Genesis, and it would probably cause a lot of flicker at times too. I guess that's why we never saw the effect in the Genesis version (and also why the HUD there is in a big black bar). Bonus point to SNES right there.

The Tom & Jerry example is very impressive too, very near cartoon animation level considering it's on a SNES, and also deals with the 3 colour limitation of layer 3 similarly well (I think I recall seeing it was using layer 3). Although the backgrounds there look very simple compared to TMNT, I think they're even on just a single layer, so I wonder if they could have used the higher colour layer for Tom's character (not that it really needs any more colours), or at least had more detail and parallax in the backgrounds using those two high-colour layers to their full capacity. And they've barely used any of the available sprites there too. Crazy to think they could go even further and make it even more impressive.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using window/shape mask directly on the background colour . . .

Post by rainwarrior »

Nekotako has a beatiful little "fish" window transition at the end of each level:
https://youtu.be/fMjG0qRQ7zI?t=32

It's carefully planned to only need 1 window, rather than 2.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

rainwarrior wrote: Wed Jun 29, 2022 2:39 pm Nekotako has a beatiful little "fish" window transition at the end of each level:
https://youtu.be/fMjG0qRQ7zI?t=32

It's carefully planned to only need 1 window, rather than 2.
Cool that it actually animates.

I know I've seem some really cool use of the window/shape masks for screen transitions in games with pretty detailed shapes on SNES--I'm sure of it--but I can't recall any just now. I'll tell you this though, there's a very cool use of window/shape masking in Pugsley's Scavenger Hunt: https://youtu.be/tVg8m_BYqcw?t=1740

Again, something that would be basically impossible on Genesis due to a lack of layers, semi-transparency and the window/shape masking all combined.
Last edited by iNCEPTIONAL on Wed Jun 29, 2022 4:09 pm, edited 1 time in total.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Using window/shape mask directly on the background colour . . .

Post by Pokun »

That crystal ball is indeed a cool way to use the Window.
Nekotako also looks great! I just wish I wouldn't have to register an account to download the demo.

iNCEPTIONAL wrote: Wed Jun 29, 2022 1:42 pm
Pokun wrote: Wed Jun 29, 2022 12:20 pm Basically Megadrive and Gameboy uses the term "Window" to mean a dialogue box type of window since the "Window" on those systems is basically just another tiled background layer with some special rules and limitations.
The SNES and SuperGrafx uses the term "Window" to mean a hole or "window" cut out in a graphics layer.
I could swear I saw some other video hardware that uses the SNES/SuperGrafx type of advanced display priority control Window, but I can't remember what it was. CPS1 maybe? Or X68000? Maybe it was just my imagination.
Again, it's not another tiled background layer but part of one of the other layers that is sacrificed to be used as a "window" section of said layer on Genesis (at least based on everything I've read about how it works). So, just to be clear, it's still always only two background layers on Genesis, unlike with SNES where it's the four background layers plus window/shape making, which can be cut into layers or done more like an effect on top of all the layers (effectively allowing for two faux [mostly silhouette style] layers). Just want to point that out because I often read online that the Genesis has two background layers, a window layer and sprite layer for basically four in total (that's how it's "sold" on the Genesis blogs and the like), which isn't quite true. And, if people can put it like that for Genesis then we can just as easily claim the SNES had four background layers, the sprite layer and two window/shape layers for a total of seven layers. But no one claims the SNES has seven layers, even though it's technically more true than the Genesis having four layers. Well, I do when I'm in an argument with some Genesis fanboy and really want to wind them up. LOL
I see, I haven't yet tried to make any Megadrive homebrew (only Master System), I need to learn 68000 assembly more properly first.
But it sounds like the Megadrive window is almost a mix of the Gameboy and SNES/SuperGrafx windows. It is part of one of the two BG layers but it changes its display priority to part of it so that it can overlay everything else, that sounds like display priority manipulation.
The Gameboy only have a single background layer like NES so a SNES/SuperGrafx-style window wouldn't make any sense. The window is instead a separate tiled layer (sharing the same tileset as the background) that is always on top of the background if enabled and it basically can't scroll (but its top-left corner can be moved until the window covers the screen fully). It's used in many games for status bars, dialogue boxes and menus but some games also use it for cooler effects like large bosses.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

Pokun wrote: Wed Jun 29, 2022 4:02 pm That crystal ball is indeed a cool way to use the Window.
Nekotako also looks great! I just wish I wouldn't have to register an account to download the demo.

iNCEPTIONAL wrote: Wed Jun 29, 2022 1:42 pm
Pokun wrote: Wed Jun 29, 2022 12:20 pm Basically Megadrive and Gameboy uses the term "Window" to mean a dialogue box type of window since the "Window" on those systems is basically just another tiled background layer with some special rules and limitations.
The SNES and SuperGrafx uses the term "Window" to mean a hole or "window" cut out in a graphics layer.
I could swear I saw some other video hardware that uses the SNES/SuperGrafx type of advanced display priority control Window, but I can't remember what it was. CPS1 maybe? Or X68000? Maybe it was just my imagination.
Again, it's not another tiled background layer but part of one of the other layers that is sacrificed to be used as a "window" section of said layer on Genesis (at least based on everything I've read about how it works). So, just to be clear, it's still always only two background layers on Genesis, unlike with SNES where it's the four background layers plus window/shape making, which can be cut into layers or done more like an effect on top of all the layers (effectively allowing for two faux [mostly silhouette style] layers). Just want to point that out because I often read online that the Genesis has two background layers, a window layer and sprite layer for basically four in total (that's how it's "sold" on the Genesis blogs and the like), which isn't quite true. And, if people can put it like that for Genesis then we can just as easily claim the SNES had four background layers, the sprite layer and two window/shape layers for a total of seven layers. But no one claims the SNES has seven layers, even though it's technically more true than the Genesis having four layers. Well, I do when I'm in an argument with some Genesis fanboy and really want to wind them up. LOL
I see, I haven't yet tried to make any Megadrive homebrew (only Master System), I need to learn 68000 assembly more properly first.
But it sounds like the Megadrive window is almost a mix of the Gameboy and SNES/SuperGrafx windows. It is part of one of the two BG layers but it changes its display priority to part of it so that it can overlay everything else, that sounds like display priority manipulation.
The Gameboy only have a single background layer like NES so a SNES/SuperGrafx-style window wouldn't make any sense. The window is instead a separate tiled layer (sharing the same tileset as the background) that is always on top of the background if enabled and it basically can't scroll (but its top-left corner can be moved until the window covers the screen fully). It's used in many games for status bars, dialogue boxes and menus but some games also use it for cooler effects like large bosses.
I think the window on Genesis does basically what SNES can do with layer 3 in Mode 1, where you can set its priority bit so it always displays on top of everything else in the game, and then on SNES I guess you just tell it not to move on the screen and there's your HUD. That's how the vast majority of SNES games do their HUD and it's why they can easily have a HUD overlaid on top of the main game while still having two full background layers of high colour graphics at the same time. The limitation on that is the 2bpp restriction of layer 3, so you have to make good colour choices or the HUD ends up looking more like it belongs in a NES game, which I've noticed a lot of beat 'em ups and quite a few fighting games on SNES choose rather badly for some reason. Some games get it right though and the HUD looks very nice while still letting the SNES have two fully overlapping high colour backgrounds layers for the rest of the game. But the cool thing about SNES here is that it can just as easily use part of one of the high colour layers as a high colour HUD if it wants, just like Genesis, and this still gives it a whole 2bpp layer free to do whatever it wants with additionally. Also, some games actually go a bit further, using the layer 3 HUD at the top of the screen on top of the two high colour layers and then switching out the layer 3 function below the HUD to have another background layer too. When used properly, this can be very effective for having both an overlaid HUD plus levels with three layers of overlapping parallax. And this can go even further on SNES using Mode 0 where the SNES can have four fully overlapping background layers, with the limitation on that being every layer has to be 2bpp, but I think my SNES shmup has shown it's still possible to do some nice graphics even with that limitation, especially when all the layers can be used to really add some depth and parallax to the levels. I don't have a HUD in my game yet, but I could just cut off a small strip on one of the layers and then have a HUD on top of everything else going on too, although I'll probably just use some sprites for the same result.
User avatar
TmEE
Posts: 960
Joined: Wed Feb 13, 2008 9:10 am
Location: Norway (50 and 60Hz compatible :P)
Contact:

Re: Using window/shape mask directly on the background colour . . .

Post by TmEE »

The window layer on MD is not a full 3rd layer, but a nonscrollable segment that can grow out of one or two sides of screen in either direction while replacing A layer where it resides (it uses tile data fetches of A layer). It is meant to do what "FIX" layer on many arcade machines does, primarly for HUDs and other stuff that doesn't need to scroll or need any special handling. All rules of layer A apply to the W segment.
iNCEPTIONAL

Re: Using window/shape mask directly on the background colour . . .

Post by iNCEPTIONAL »

TmEE wrote: Wed Jun 29, 2022 4:58 pm The window layer on MD is not a full 3rd layer, but a nonscrollable segment that can grow out of one or two sides of screen in either direction while replacing A layer where it resides (it uses tile data fetches of A layer). It is meant to do what "FIX" layer on many arcade machines does, primarly for HUDs and other stuff that doesn't need to scroll or need any special handling. All rules of layer A apply to the W segment.
Yeah, this.
Post Reply