Quantcast
Channel: nesdev.org
Viewing all articles
Browse latest Browse all 746

Fast Sprite Shrinking Demo

$
0
0
Hey, Lex here. Lately I've been working on a demo showcasing fast sprite shrinking on a stock SNES. In this demo, you will
see two smoothly shrinking 64x64 sprites. Is it real time sprite shrinking? No, the SNES CPU is obviously too slow to do that
at a decent framerate.

How this demo works is that I wrote a program that takes a sprite in the 4BPP SNES format and renders all the frames needed
to smoothly scale the sprite. However, even after creating the sprite sheet with all the scaled frames; the sprite sheet
is still too large to fit in a single bank.

So how did I get all the frames to fit in a single 64kb bank? Well, I wrote a program that removes all empty 8x8 sprite tiles,
then groups the remaining 8x8 tiles into a tileset. Then I made it so that program generates tilemap data for each sprite frame.

In the sprite tileset, each 8x8 tile has a 16-bit index. The 16-bit indexes in the tilemap tell you which 8x8 tiles will be
displayed.

Then on the SNES, I wrote ASM code to read a 16-bit index from the tilemap, find the location where the tile associated with that
index is and then upload the tile to WRAM using MVN block moves.

If this all sounds a little complicated; basically I was able to fit the data in a 64kb bank by writing a program that removes
all empty tiles. Empty tiles are tiles that have all zero bytes.

The downside with this method is that it takes up a lot of ROM. To store the data needed to smoothly scale a 64x64 sprite
you need an entire 64kb bank. However, you can fit multiple 32kb scaled sprites in a bank.

I may expand upon this and make a sprite scaling racer or shooter in the future.

Instructions:
Press up to scale up the sprite, press down to scale down the sprite.

You can view a video of the demo here:
https://www.youtube.com/watch?v=m9uU6BU8q_g
SNES_scaling_rom.smc

Statistics: Posted by lex — Fri Jan 05, 2024 12:31 am — Replies 1 — Views 86



Viewing all articles
Browse latest Browse all 746

Trending Articles