SNES fast sprite shrinking demo

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.
Post Reply
lex
Posts: 13
Joined: Sat Dec 31, 2022 9:31 pm

SNES fast sprite shrinking demo

Post by lex »

Hi, I'm Lex. A few years ago I made this demo of a sprite scaling smoothly on the SNES.
However, I haven't shared the demo publicly until now.

So to explain the shrinking you first need to know that SNES graphics are made up of bytes. So to shrink an
8x8 sprite we would simply shrink all of its bytes. So in this demo, there are 8 lookup
tables. Each byte in each lookup table tells you how a certain byte would look when shrunken
by the shrink value.

To generate the lookup tables, I wrote a program in C#.

When a byte is loaded from the sprite data, it loads a byte from the lookup table associated
with the current shrink value for the current 8-pixel wide column. The byte in the lookup
table basically tells you what the byte would look like when shrunken by the shrink value.

A shrink value basically tells you how much a certain 8-pixel wide column will shrunken.
The value that controls how much a sprite is shrunken horizontally is the horizontal scale
value. Based on the horizontal scale value, a table of shrink values is created.
The table of shrink values tells you how much each 8-pixel wide column will be shrunken.

Once all of the shrunken columns have been written to a buffer in work ram; the program
updates OAM so that all of the sprites that make up your sprite are stitched together.

So basically you combine the different shrunken columns using sprite positions. This makes
it so that you don't have to do any bit-shifting. To know how much to move each sprite in
each column there is a table.
Attachments
64x64_scaling_demo.smc
(1 MiB) Downloaded 61 times
32x32_scaling_demo.smc
(1 MiB) Downloaded 56 times
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: SNES fast sprite shrinking demo

Post by tepples »

Similar concept to my NES demo from 2014?
turboxray
Posts: 348
Joined: Thu Oct 31, 2019 12:56 am

Re: SNES fast sprite shrinking demo

Post by turboxray »

I'm not sure your demo is working correctly for me in mesen... it doesn't looking like scaling.. until the last 2 or 3 frames. Otherwise it looks like distortion. Sort of like a coarse fish-eye lens effect - the center of the image isn't scaling but the edges are, so it looks like the edges are collapsing in on itself.
lex
Posts: 13
Joined: Sat Dec 31, 2022 9:31 pm

Re: SNES fast sprite shrinking demo

Post by lex »

tepples wrote: Sat Dec 31, 2022 11:40 pm Similar concept to my NES demo from 2014?
Yeah, the concept in that post inspired me to program this.

turboxray wrote: Sun Jan 01, 2023 12:08 am I'm not sure your demo is working correctly for me in mesen... it doesn't looking like scaling.. until the last 2 or 3 frames. Otherwise it looks like distortion. Sort of like a coarse fish-eye lens effect - the center of the image isn't scaling but the edges are, so it looks like the edges are collapsing in on itself.
Hmm, you're right it does have a fish-eye lens effect. Probably just a problem in how I generated the lookup tables. To do the horizontal scaling, I'm basically subtracting vertical lines from the sprite. I'll probably will fix it so it looks more like scaling though.
MSonage
Posts: 22
Joined: Fri May 06, 2022 4:34 pm

Re: SNES fast sprite shrinking demo

Post by MSonage »

The 64x64 example looks very fake because of how static the middle 16x16 part is during the scalling, but the 32x32 one looks nice.
Post Reply