Keeping your eyes on the size

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
Revenant
Posts: 462
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Keeping your eyes on the size

Post by Revenant »

Earlier this week, I decided to see if I could do something interesting with only 256 bytes of ROM ($FF00-FFFF). I managed to make a working implementation of the classic "Kefrens bars" effect (or "Alcatraz bars", if you're a history pedant) that fits entirely into 249 bytes (plus two more for the reset vector) and appears to work perfectly on a real SNES

Here's the ROM, and here's a considerably larger GIF of it in action.

(Bonus Pouet page, also)

I'll probably post slightly cleaned up/annotated source code later.

Has anyone else ever attempted to make anything impractically tiny on the SNES before? It definitely feels like a challenge even by the usual standards of "sizecoding", just because the amount of space it takes just to properly initialize enough of the hardware - especially compared to MS-DOS, the usual target, where it you can make a lot of assumptions and end up with working, interesting programs in 32 bytes or less.

I think there are probably some pretty interesting possibilities for sub-1kb programs on the SNES, though. I may try to experiment more in the future.
User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

Re: Keeping your eyes on the size

Post by jwdonal »

Very cool demo! Looks great on my FPGA SNES.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Keeping your eyes on the size

Post by ccovell »

If a large range of addresses needs to be set either to #$00 or #$FF, you could encode the addresses in a bitpattern.

%1001 could mean a 1 (/2/4 however) byte run of #$FF, #$00, #$00, #$FF each written to $21xx.
User avatar
HihiDanni
Posts: 186
Joined: Tue Apr 05, 2016 5:25 pm

Re: Keeping your eyes on the size

Post by HihiDanni »

Wow, this is great! I looked in the sprite, palette, and tilemap debuggers and all seem to be empty so I'm scratching my head at this one. Well done.

A lot of homebrew/demo ROMs I've seen are impractically large so I'm interested in seeing what you can get out of a more realistic ROM size from the 16-bit era. I thought up a compression scheme using RLE and a dictionary, I just need to code it. If it works well I might bundle it with my framework.
SNES NTSC 2/1/3 1CHIP | serial number UN318588627
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Keeping your eyes on the size

Post by Oziphantom »

256b demos usually have custom code generators build in them, you can't really get generic code packer for that size ;) And making something fractal also helps ;)

4K demos, it starts to get to the point where your encode you opcode stream and param streams separately, as you will typically do a
LDA XXXX
STA XXXX
LDA XXXX
STA XXXX
type code where the XXXXs will be different, but this way you can compress the LDA STA run, and then the hi bytes normally have a run so you get the unique lows and RLE the common His etc.
User avatar
HihiDanni
Posts: 186
Joined: Tue Apr 05, 2016 5:25 pm

Re: Keeping your eyes on the size

Post by HihiDanni »

Well for my purposes it wouldn't be quite *that* small. I was thinking more like being able to fit a full length game in about a megabyte.
SNES NTSC 2/1/3 1CHIP | serial number UN318588627
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Keeping your eyes on the size

Post by tepples »

HihiDanni wrote:Well for my purposes it wouldn't be quite *that* small. I was thinking more like being able to fit a full length game in about a megabyte.
It depends on the level of detail. There are plenty of full-length 16-bit games that size, such as Super Mario World, Super Mario Kart, and the first two Sonic the Hedgehog games. But something whose detail is comparable to that of Donkey Kong Country or Super Street Fighter II isn't going to fit in 8 Mbit. On the other hand, because original graphics and audio take time to create, I imagine that a full-length game created by one or two hobbyists will economize effort spent on creating assets to the point that the result fits in 8 Mbit.

What sort of overly large ROMs are you talking about? Tech demos that encode the fan video for "Bad Apple"?
Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: Keeping your eyes on the size

Post by Optiroc »

Great stuff! And challenge accepted!
User avatar
elseyf
Posts: 72
Joined: Sat Dec 01, 2012 4:10 am

Re: Keeping your eyes on the size

Post by elseyf »

Nice demo!
I wrote a BF Interpreter for SNES using 1kB in total for a contest held some time ago: SNESF1k
Revenant
Posts: 462
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Re: Keeping your eyes on the size

Post by Revenant »

https://gist.github.com/devinacker/3178 ... 646fd7d952

Source code for the OP demo, for your enjoyment(?) See if you can figure out the technique before spoiling yourself, though.
Revenant
Posts: 462
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Re: Keeping your eyes on the size

Post by Revenant »

I made another small demo for the Demosplash 2019 party held over the weekend. This time it's a 345-byte implementation of the Atari XL demo "Mona" originally created by Ilmenit.

https://www.youtube.com/watch?v=uDIGPATH7mM
https://demozoo.org/productions/270100/

It's a bit bigger than the original (345 vs. 250 bytes) due to having to manually init the screen and manage pixel plotting and all that, but I'm still fairly happy with the size of this version. (It's probably possible to make it a little bit smaller if you really try, but 345 is a nice number and I didn't really feel like spending more than a weekend on this silly thing.)

Theoretically works on a real console, though the Super Everdrive used at the party had trouble with it. (My own video was recorded from a sd2snes.)
Erockbrox
Posts: 397
Joined: Sun Nov 23, 2014 12:16 pm

Re: Keeping your eyes on the size

Post by Erockbrox »

You should make a music player out of it and have that wave animation fluctuate with the music.
Post Reply