| |||
Views: 88,313,417 |
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search | 03-28-24 03:39 PM |
|
Guest: Register | Login |
0 users currently in ROM Hacking | 1 guest | 2 bots |
Main - ROM Hacking - SMA4 level card level compressor | New thread | Thread closed |
RANDY Ruler of Zexernet |
| ||
Shyguy Level: 23 Posts: 10/89 EXP: 65573 Next: 2150 Since: 07-17-07 From: Arizona, US Last post: 4601 days Last view: 226 days |
I am not sure if this has been posted before, but I once saw someone say that the Super Mario Advance 4 level e-cards are encrypted (the actual level data, not the raw e-Reader card data). They are not - they are merely compressed using a dictionary compressor, after which the data & offset streams are separately compressed using range coding, then concatenated. Someone else already decompiled the decompressor, so I made a compressor.
Call compress with the size of the level, a pointer to the level data, the mode (0x00 or 0x80, use whichever gives a smaller output size), & a pointer to the destination buffer (which should be large enough - how large is left as an exercise for the reader). It writes the complete level (suitable for placing in the EEPROM save, though there might be more needed to print a level card) to the destination buffer.
Code for compressor ((poorly) written in ISO C99):
|
purplebridge001 |
| ||
Newcomer Level: 7 Posts: 2/7 EXP: 1439 Next: 9 Since: 09-13-07 From: Somewhere in world-e Last post: 5262 days Last view: 5262 days |
Wow, great job!
We will be able to create home made levels! If I remember correctly, we still need to fix the checksum (or something other) in the save data to actually work in SMA4. EDIT: It seems that the last byte of input can't compress correctly. (For example, "Hello" becomes "Helln") |
caitsith2 |
| ||
Newcomer Level: 8 Posts: 1/8 EXP: 1652 Next: 535 Since: 08-21-09 Last post: 3272 days Last view: 2984 days |
I fixed a bug in the code, that was causing the last byte to not be compressed correctly. Smaller compression doesn't do any good, if it does not decompress correctly. Turns out more than just 1 byte of l, at the end of the range stream was actually required to correctly decompress the last byte.
Also dealt with some input validation while I was at it, and final output, in case of e-reader levels.
|
KP9000 |
| |||
Boomboom Level: 90 Posts: 927/1975 EXP: 6937400 Next: 251209 Since: 02-19-07 Last post: 3551 days Last view: 3175 days |
|
Main - ROM Hacking - SMA4 level card level compressor | New thread | Thread closed |
© 2005-2023 Acmlm, blackhole89, Xkeeper et al. |
MySQL - queries: 52, rows: 76/76, time: 0.010 seconds. |