Language…
4 users online: AJ1Ayrton, Ice Man, Skewer, X11Gbyte - Guests: 67 - Bots: 152
Users: 67,562 (2,002 active)
Latest user: Dilshacking

SMA3 documentation (including ROM/RAM maps, disassembly)

Resource

Wow it's been years.

Over a decade, in fact. No one from the old YI community seems to be here anymore, but I'll post this anyway in case anyone happens to check by and see it. (I'm sort of amazed just how far we all managed to document in the old thread from 2010-2011, by just comparing formats between the versions, and trial-and-error GBA editing/converting, without any assembly knowledge...)

---

SMA3 documentation spreadsheet
Holds most of my notes. It includes ROM/RAM maps, vanilla sublevel headers, some random IDs like game states and music, and random other notes in various stages of completion.

SMA3 disassembly
Update 2022-10-04: Now on Github, and split into more manageable code file sizes (it was formerly a single 23-million-character text file). Can be assembled with Armips.

Note: GBA assembly (ARM7TDMI processor, ARMv4 instruction set; in practice it's all Thumb code) is pretty messy and inefficient compared to older consoles such as SNES and GB. It's compiled rather than written in assembly, seemingly by a very inefficient compiler, and the ported code adds further confusion, e.g. most RAM addresses are halfwords for no reason (probably because the code worked on SNES with 16-bit addresses).

---

I've been working on documenting SMA3 for a while now, so might as well make it public?

In particular, I've been focusing on documenting how the game processes sublevel data (header, entrance bytes, objects, sprites)... this includes how the GBA handles graphics, palettes, music, layer tiles, etc., considering GBA is a distinct console with its own formats. I think a thorough documentation of the sublevel loading code is important... it'll not only help an editor display YI's complex objects and graphics, but should also allow for coding sublevel-specific overrides (unique sprite tilesets in every sublevel? Lunar-Magic-style custom palettes?) in the future.

Despite the overcomplicated vanilla code, and that existing SNES patches would need to be ported, I think hacking the GBA version should be well worth it in the long run... not only for avoiding the SuperFX ROM size limit, but for the hacking potential of GBA's higher capabilities:
- More WRAM (288 KiB, to SNES YI's ~160 KiB after accounting for its use of SRAM as WRAM... shouldn't be difficult to support more than 4 item memory settings, for example)
- More VRAM (including 8 dynamic sprite slots by default, instead of 4, and messages made of sprites so layer 3 settings won't interfere)
- Native support for sprite rotation/scaling without needing a dynamic slot
- 512-color palettes instead of 256
- Much faster processor at 16 MHz (hopefully less lag despite the inefficient compiler, and if not, there's still the potential for optimization patches)
- 4 layers by default (GBA layer 0, which seems to be only used in a few tilesets for foreground graphics, could be useful for hacks), or a mode-7-style layer with 2 normal layers (less restrictions on editing bosses like Hookbill, when they no longer displace layer 1?)

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3
Excellent work on this documentation! It's sure to come in very handy if I ever decide to work on ShyGuy Advance again.Free counters!
Some potentially useful SMA3 data from random export scripts I've written, that didn't fit in the spreadsheet:

All known variable-width text: sma3text.txt
Displayed characters are decoded according to the SMA3 font (082F63CC, 8x12 1bpp custom graphics format). End of data command (FF FF for most text, FD for level names) is excluded. Other commands (starting with FF for most text, FE for level names) are replaced by @{bytes}, with a line break added in front of any commands that function like one.

Also, lists of all sublevels containing each sprite and object ID:
Sublevels_with_each_object.txt
Sublevels_with_each_sprite.txt
Convenient for finding where a particular object/sprite ID is used, to more easily test it (in case it relies on particular header settings or hardcoding). A surprisingly large number of IDs are unused, though.

Edit 2022-3-16: updated Sublevels_with_each_object.txt, due to initially treating object 78 as a special case (see here), when after checking object 78's code and viewing 1-7 (which has 79 copies of object 78) in ShyGuy Advance, I've concluded it's not a special case.
Object length byte properties are in the ROM, by the way. Lowest 2 bits of 081C19D8; higher bits seem to be never loaded. (0=1 byte: width, 1=1 byte: height, 2=2 bytes: width then height)

Edit 2022-4-12: updated both files, to move the totals to the start of the line for readability.

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3
Why does this game have so many unused text commands?


BIIIIIIG text!


Stretched text!


Overwriting text!


4-line level names! This isn't even an unused text command, just using the existing FE XX YY command with Y=30... the variable-width text sprites cover just as much space for level names as they do for messages.

I've done plenty more documentation than this (level data format is almost entirely documented; see the "Sublevel load" spreadsheet tab), but I thought the text effects were amusing enough to post.

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3
I've been working on a SMA3 Level Editor on and off for years, and have built up a decent amount of decompiled code and object names. Can I assist with this?
Sure, why not post it? I've been documenting using assembly (not decompiling, which I don't have any experience with), so I'm not sure if I'd be able to incorporate that into the spreadsheet, but any data helps.

Object names will likely be up for debate (not sure whether to use terms like "cross-section" from the old YI community, for example, but I haven't thought of a decent unambiguous term), but having an object name is better than no name. I've only added data to the spreadsheet if I've verified it on GBA, to avoid any mistaken assumptions from SNES, but I suspect most objects match up.

How far along is your editor?

I've been working on an editor myself, though it's still in an early stage... my initial goal is to display a layer 1 16x16 tilemap, so that I can gradually replicate each object's code to generate that layer 1 tilemap. The random scattering of objects in the current spreadsheet mostly reflects my editor work so far: they're all global-graphics objects that appear in 1-1. (Despite the 0x1FE 0x1E3 objects to replicate, I'm not worried about generating the tilemap; my main concerns are GUI-related, like keeping the GUI classes organized, displaying graphics efficiently enough to not lag whenever they need to be recalculated, and implementing various mouse movements like selection or drag-and-drop. I'm much more comfortable working with assembly hacking than GUI.)

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3
It currently has graphics working (or at least 60% of them), and I'm currently working on the re-compilation exporting. Funnily enough, the most challenging part has been the front end, so I'm hoping to get a friend of mine on board.

Is it appropriate to post something that isn't ready for use? There's some basic functionality it's missing, as most of my time has been spent building the graphics. You cannot add objects, or change their scale, but everything else you'd expect is done.

In retrospect, I should probably get my priorities straight...
I guess I should post my patches/scripts here, so that they're not lost in the Discord channel? Might edit the first post with a code collection at some point.

messageimagefix.asm
Armips patch. Fixes an off-by-one error in GBA message images.

gfxsnesgba.py
Command-line script to convert SNES graphics files (such as the .bin files output by ycompress) to GBA format.

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3
objfix2.5D.asm
Fixes a porting error in the 2.5D stone bricks (objects 20/EE-F3). The right edge's bricks are cut off on GBA, but not on SNES.

Vanilla:

Patched:


objfixD4D5.asm
Another object fix, this time for the random generation in the sewer room left/right walls.

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3

Resource