Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
Acmlm's Board - I2 Archive - - Posts by caitsith2
User Post
caitsith2
Newcomer
Level: 3

Posts: 1/3
EXP: 76
For next: 52

Since: 04-01-05

Since last post: 12 days
Last activity: 7 days
Posted on 10-19-05 04:58 AM, in INCOMPLETE SMA4 Level Data Document Link
I have been doing some reverse engineering of the format myself, and came up with a few things.

After level decompression (and I even reversed the decompression, just not the recompression), however, I still was able to figure out the level format regardless, on the emulator. Here is the necessary breakpoints/memory locations for the US version.

The compressed data ends up at 0x2014BD8. The data is decompressed into 0x2005000. You can change the decompressed data in runtime, however, for the change to actually take effect, you have to do something that changes the area, like go down a pipe or enter a door. However, there are some things that cannot be changed at runtime, like how many A-coins to collect, and whether or not there is an e-coin to collect, It only can be changed immediately after the decompression has finished. The end of the decompressor code is at 0x80A7BEC. If you can stop execution at this point, you can change the data, and have the changes take effect when the level loads.

There is always 0x40 bytes in the header, following this format.

Header format
------------------------------------
0x000 0x01 E-Coin present (0,1)
0x001 0x01 Ace Coins present (0-7)
0x002 0x01 E-Level Class (0x01 = Star, 0x02 = Mushroom, 0x30 = Promotional)
0x003 0x01 E-Level Number
0x004 0x01 Level Icon
Repeat the following 4 times. (Only the first entry is absolutely required.)
0x005 0x02 Level Objects (required)
0x007 0x02 Level Settings (required)
0x009 0x02 Level to Level transports (pipes/doors)
0x00B 0x02 Level Sprites (Some form of level ending sprite required)
0x00D 0x02 Unknown
0x00F 0x02 Level Scroll vectors (Optional)
End Repeat, Fill with 0x00 until end of header.

Whether to follow this with the 0xFF terminated level name, depends on if an e-coin is present. If an e-coin is present, then there is (IIRC) 0x800 bytes for the e-coin pallete/gfx data, that must be filled in first.

Here is the name character set.
Title Format Character Set (US version)
----------------------------------
ABCDEFGHIJKLMNOPQRSTUVWXYZ - 00-19
abcdefghijklmnopqrstuvwxyz - 20-39
0123456789 - 76-7F (normal)
0123456789 - E4-ED (supertyped)
0123456789 - EE-F7 (subtyped)
'?!- ' - E0-E3
[PR] - FE
[NULL] - FF

Just one correction I would like to make with objects.

The first byte should be broken into 8 Bits
AABBBBBB CC DD EE FF
A - Bank (2 bits)
B - First Length (6 bits)
C - X
D - Y
E - Type
F - Second Length (Only if 5 byte object type.)

Enemy/Sprite types
AA BB CC DD
A - Enemy/Sprite
B - X
C - Y
D - Parameter, usually 0 for most purposes. However, for things like A coins, 0 is the first coin, 1 is the second, and so on.

The level object pointer also contains a header that I have yet to document.

-----------------------------
Level Transport format
----------------------------
0x000 0x02 Number of transports (ZZ)
[REPEAT ZZ times]
0x002 0x01 Source entrance X (This should match X location of pipe/door you can enter)
0x003 0x01 Soucce entrance Y (Should also match pipe/door).
0x004 0x01 Area to transport to. 0-3
0x005 0x01 unknown
0x006 0x01 Destination X
0x007 0x01 Destination Y
0x008 0x01 View screen Center X
0x009 0x01 View screen Center Y
0x00A 0x01 unknown
0x00B 0x01 Exit type
[END REPEAT]

Level Transport Exit Types
------------------------------
0 - Appear at X, Y (used for Doors)
1 - Come up from pipe
2 - Come down from pipe
3 - Come right from pipe
4 - Come Left from pipe
5 - Drop from X, Y

--------------------------
Scroll Vector format
---------------------------
Offset Length Description
[REPEAT START]
0x000 0x01 X position to travel to.
0x001 0x01 Y position to travel to.
0x002 0x01 Speed to travel at.
[REPEAT END] - Repeat until X = 0xFF, Y = 0xFF, Speed = 0xFF.

caitsith2
Newcomer
Level: 3

Posts: 2/3
EXP: 76
For next: 52

Since: 04-01-05

Since last post: 12 days
Last activity: 7 days
Posted on 10-20-05 07:22 PM, in INCOMPLETE SMA4 Level Data Document Link
One other detail I forgot to mention is where e-level slots 13-32 exist in the save. The only reason they are not in the above list, is because there were only 12 levels officially released in the US.

E-Level: (All of them are compressed.)
(In .sav file)
0x00000808 Unfinished e-level, primary slot.
0x00006018 E-Level 1
0x00006808 E-Level 2
0x00007018 E-Level 3
0x00007808 E-Level 4
0x00008018 E-Level 5
0x00008808 E-Level 6
0x00009018 E-Level 7
0x00009808 E-Level 8
0x0000A018 E-Level 9
0x0000A808 E-Level 10
0x0000B018 E-Level 11
0x0000B808 E-Level 12
0x0000C018 E-Level 13
0x0000C808 E-Level 14
0x0000D018 E-Level 15
0x0000D808 E-Level 16
0x0000E018 E-Level 17
0x0000E808 E-Level 18
0x0000F018 E-Level 19
0x0000F808 E-Level 20
0x00010808 Unfinished e-level, backup slot.
0x00016018 E-Level 21
0x00016808 E-Level 22
0x00017018 E-Level 23
0x00017808 E-Level 24
0x00018018 E-Level 25
0x00018808 E-Level 26
0x00019018 E-Level 27
0x00019808 E-Level 28
0x0001A018 E-Level 29
0x0001A808 E-Level 30
0x0001B018 E-Level 31
0x0001B808 E-Level 32

The save allows up to 32 saved levels, plus one in the unfinished slot. This means you can have up to 33 levels e-levels on one cartridge.

There appears to be These save sections.

--------- Repeated in both bank 0 & 1 of save file, for redundancy -------
SMA4MWE0 / SMA4MWJ0 - 0x0000 - 0x1000 - 1 (E-Level master index, including the unfinished level slot, and the names of up to 72 levels.
M3E0 / M3J0 - 0x1000 - 0x0800 - 6 (Save slots)
S4RE / S4RJ - 0x4000 - 0x2000 - 1 (unknown)
--------- End of Repeat --------------------
S4CE / S4CJ - [0x6000 - 0x1000 - 10], [0x16000 - 0x1000 - 6] (E-Levels (2 per slot))
S4KE / S4KJ - 0x1C000 - 0x1000 - 4 (Saved level replays)



In order to change the save, you have to know how to calculate the checksum. The formula is extremely easy. Add up the save slot section bytes (first 8 for SMA4MW?0, 4 for M3?0, S4R?, S4C?, S4K?). Skip over two bytes, and add each of the remaining bytes in that section.

Example, in the S4CE section (e-levels)
Add bytes 0, 1, 2, and 3 together. Skip bytes 4 and 5, then add the remainder of the bytes. The 2 bytes skipped at offset 4 & 5, should equal to the least significant 16 bits of the total you came up with. The game saves are specifically region coded.
caitsith2
Newcomer
Level: 3

Posts: 3/3
EXP: 76
For next: 52

Since: 04-01-05

Since last post: 12 days
Last activity: 7 days
Posted on 10-21-05 03:30 AM, in INCOMPLETE SMA4 Level Data Document Link
Or if we could figure out how to encode our own e-reader cards, they could be loaded up that way. [Firefly] figured out how to do so more than a year ago, unfortunately, he will not release his tools, for he fears they will be used for piracy purposes, and he is dead against piracy. This effectively means someone else is going to have to research it. It is possible, to print working dotcodes, and the tool to do so, is released.

I already know how to attach a valid e-reader card level header to the level data, but that info is useless if it can't be encoded to the raw format that it needs to be in, that includes reed solomon error correction info.

----------------- UPDATE, new info ---------------------------------

I found a level that fills in the unknown in the e-reader level data header, and fooled around with e-coin formats some more.

Header format
------------------------------------
0x000 0x01 E-Coin present (If 0, none is present. Anything other than 0 tells the game where in the ecoin fortress to place the coin.)
0x001 0x01 Ace Coins present (0-7)
0x002 0x01 E-Level Class (0x01 = Star, 0x02 = Mushroom, 0x30 = Promotional)
0x003 0x01 E-Level Number
0x004 0x01 Level Icon
Repeat the following 4 times. (Only the first entry is absolutely required.)
0x005 0x02 Level Objects (required)
0x007 0x02 Level Settings (required)
0x009 0x02 Level to Level transports (pipes/doors)
0x00B 0x02 Level Sprites (Some form of level ending sprite required)
0x00D 0x02 Block platform movement vectors
0x00F 0x02 Level Scroll vectors (Optional)
End Repeat, Fill with 0x00 until 0x40. What follows this depends on if an ecoin is present or not. If an ecoin is present, then the ecoin graphics follow, then the name of the level, otherwise just the name of the level follows. The name can be a maximum length of 0x15 characters. You do not have to terminate it with 0xFF if the name is exactly 0x15 characters long, but in practice, you should anyways.

The e-coin graphics is unfortunately, like the level, on the e-card, and not the game. On the bright side though, you can make the e-coin look like whatever you want, if you wish.

E-coin values 1-8 are the first floor. 9-16 for second floor, 17-24 for third floor. The game will only display one floor however, if you only have coins 9-16 loaded, or 17-24, or 1-8, and only two floors if a combination of 1-8 and 9-16, or 9-16 and 17-24, or any combination whatsoever. 24 e-coins is the maximum possible. If I make a level editor, I will not allow it to make e-coins 1-8, as nintendo has already used those.

For each moving block platform that exist in the level, the following format applies.
0x001 0x01 Block platform properties.
AB - A = Block length * 2. Valid values are 1-15.
B = Block platform speed.
0x002 0x01 First movement byte. Direction of the first movement must be right.
[Repeat while movement byte not = 0xFF]
0x003 0x01 Movement byte
[End Repeat]

Movement byte is in following format.
AAAAAABB
A = Number of blocks to move. (1-63)
B = Direction to move. (0 = Right, 1 = Left, 2 = Up, 3 = Down).
Because 0xFF is the stop platform movement command, it is not possible to move down 63 blocks, in one go, it must be done in two shorter ones.


(edited by caitsith2 on 10-21-05 07:58 AM)
(edited by caitsith2 on 10-22-05 12:16 AM)
Acmlm's Board - I2 Archive - - Posts by caitsith2


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.015 seconds.