talarubi: (Default)
Talarubi ([personal profile] talarubi) wrote2005-10-08 06:34 am

I broke it! :D

Anyone remember that crazyass robot in Mario Paint? The thing that held a single measly slot and took a couple minutes just to fecking save?

Well apparently Mario Paint has 32KBytes of saveram on the cart. When I read this I was skeptical... Hmm, I thought, that's enough for one screen, but what about the rest? Well let's find out!

2 * 248x168 pixels * 4/8 bytes/pixel (16 colors) (drawing and animation areas, = 41664 bytes)
+ 256 * 2 (x,y) (animation path = 512 bytes)
+ 16 * 16x16 pixels * 4/8 bytes/pixel (stamps, = 2048 bytes)
+ 96 bars * 3 notes (music, = 288 bytes)
= at least 44512 bytes or 43.5KB

Okay fine, the SNES comes with 128KB of memory built-in. Tons of room for even lavish auxiliary buffers. However, 44KB is almost half again the size of the saveram. What you say!! Well they must be compressing it. Oh ho hooohhh... this gives me evil ideass...

Those of you who tried to be smartarses and .zip your .jpg files (or worse your .zip files :D) before you realised what happened, will see what's coming. No "compression" tool can shrink everything, because if it could, you'd just .zip your .zips until they disappeared into nothing! And then upload your nothing in infinitesimal time! As cool as that would be, the fact is that some data will not shrink, in fact some of it will expand. Namely, the "densest" data, with the fewest patterns (like, say, your .zip files). Data like the canvas to the right.

So for this to work, Nintendo (bless their skimping hearts) need to shrink everything to about 70% of the original size... a reasonable margin. Given the sloooow speed, they are probably using LZW or somesuch—not a favorite of their 3Mhz CPU, but something respectable that will get the job done, and crunch all the simple kiddie drawings, and even then most anything worth saving. But look what happens when you airbrush the whole canvas! Ahahahaaah! Yes, the robot explodes! They even included a helpful message and a little animation. This SO just made my day! ^..^;

[identity profile] coderlemming.livejournal.com 2005-10-08 05:29 pm (UTC)(link)
Hah, that's awesome. I guess they didn't really expect that kind of thing to happen very often... still, pretty lame, if you ask me.

[identity profile] draci.livejournal.com 2005-10-08 10:57 pm (UTC)(link)
It does not; I don't ever remember seeing it, and Google doesn't seem to know either. I figured the code might just bomb spectacularly so it was a great surprise that it doesn't. XD In fact if it fails it will keep your old save...

You're right though. It would have been much easier to use 64 or even 128K (so we could have 3 slots plus some real music and animation dammit!), and I dunno why they didn't. Prolly it saved a few cents, thus management won. :( ("Save slots? But what's wrong with VHS?")

[identity profile] dwaggy.livejournal.com 2005-10-08 08:36 pm (UTC)(link)
Your art Asplode! ;D

[identity profile] pyxaron.livejournal.com 2005-12-06 08:29 am (UTC)(link)
*laughs* This is good.

I'm surprised that they actually added that, instead of mysteriously being unable to draw at some point.

Just out of curiosity, how long did it take to make it break?

[identity profile] draci.livejournal.com 2005-12-09 09:40 am (UTC)(link)
Just long enough to spraypaint both canvases (background + animation frames), which is the bulk of the data. Note that it doesn't break when you draw, just when you try to save.

And now that you mention, I think the message is still pretty mysterious—only recently has the public been introduced to buffer overflows, so most people wouldn't have gotten it. ^..^