The Beginner's Guide to Stage Modules

Started by PhantomWings, August 06, 2011, 12:09:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

I was going through my notes the other day when something caught my attention that I'd meant to expand on a little more. It's not really anything useable at the moment, but hey, I figure someone should be able to get something out of it.

First off, some class declarations

Sorry but you are not allowed to view spoiler contents.


You may have seen these classes before if you've ever taken the time to look inside any stage module. For the sake of the analysis, I used the Wifi Waiting Room stage(st_otrain.rel) - I will refer to it whenever necessary.

For now we'll look at stClassInfoImpl<55, stOnlineTrainning>, a derived class of the stClassInfo class. (you could argue that it's actually an implementation of the abstract interface stClassInfo, but let's not complicate the terminology) This is a lightweight class that Brawl uses whenever it needs to generate the Wifi Waiting Room stage for you to fight on. (Incidentally, the Results Screen stage's stClassInfo is always loaded into memory, so it can be loaded at any time)

The method in question that loads the stage is stClassInfoImpl<55, stOnlinetrainning>.Method[1]. I won't go into details, but it does 3 main things:

1. Allocate a block of memory on the StageInstance heap the size of the stOnlineTrainning class.
2. Call the stMelee constructor. (the base class of the stOnlineTrainning class)
3. Construct the remaining parts unique to the stOnlineTrainning class.

After the constructor returns, the address of the stOnlineTrainning class gets stored at 80B8A428. (Somewhere inside module 1B) When the match actually starts, stOnlineTrainning gets accessed from 80B8A428 and it's initializer gets called.

For all instances of the Stage class, method[23] is the initalizer. This is the function that is responsible for loading up all the assets from STGONLINETRAINING.pac. It is also responsible for creating any other instances that exist on the stage as separate objects. (The blocks from Mushroomy Kingdom, say)



And unfortunately, that's really as far as I got with this. I might venture a guess as to say that the method at 80015DDC is responsible for loading specific archives out of the .pac with r4 being the type and r5 being the FileIndex, but the rest of it is uncharted territory.

In case that all went by a little bit too fast for you, I whipped up a quick diagram for you to reference at your leisure.
(The diagram says that Method[22] is the Stage initializer - ignore that, it's really Method[23])
Sorry but you are not allowed to view spoiler contents.


Just a few more miscellaneous notes:

As mentioned above, the current existing stage instance can be accessed at any time from the pointer at 80B8A428.

All methods in a class that don't reference assembly inside it's own module are methods that have not been overridden from it's base class.

Method[127] is the main loop of the stage. It is constantly called and is used for things like the Sandbag in WWR or rebuilding the mansion in Luigi's Mansion.

Just as there are constructors and initializers, there are also destructors and finalizers. stClassInfo.Method[0] is used for removing the stClassInfo from memory and Stage.Method[22] is the destructor for the actual stage

The memory allocation function can be found at 8000C8B8, it may be a good idea to see what else calls it if you wish to find out where other classes get constructed. (8000C8C8 is the memory free function if anyone was wondering) Also, here's a list of the types of memory heaps.
Sorry but you are not allowed to view spoiler contents.



That's all for now folks. I'll hang around for a little while to see if this can be taken anywhere, but I'll be riding backseat for the most part.

Noone posted here yet?!
Wonderful guide, PW.
People were doubting you or Dant would come back. But here you are! :D

Whoa, this is nice! I don't even know what I'm supposed to say lol, this is just really, really awesome. Glad you're still around, PW.

inb40vah9000requests

Great guide PW, always depthening our knowledge, bit, by epic bit.
Sig by Segtendo. Epic

I did not notice this thread. Thanks for this info.

PM is back that can only means one thing :D
something awesome is Coming like always you leaving and then come back
I Dont Take Requests & Dont Do Brawl Mods anymore Maybe Sm4sh modz later

HES BACK EVERYBODY!!!

Welcome back Phantom Wings! Great to see ya!
By the way, I think every active hacker in this forum could use less distractions.

Sorry but you are not allowed to view spoiler contents.


Join my website, Brawl Imports, a gathering place for importers!
http://brawlimports.proboards.com/index.cgi

Support Project Darkrai? Put the official Project Darkrai banner in your siggy!
[PICTURE REMOVED. Reason: Total signature pic size exceeds 695x200.]



glad to see ya PW :D

teach me the REL format o great one *bows*

lol... nah... :laugh:
just send me a detailed PM of the format plz :)

I just need to figure out how to decompile the scripts >_>

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

Quote from: Tcll on August 10, 2011, 03:13:04 AM
glad to see ya PW :D

teach me the REL format o great one *bows*

lol... nah... :laugh:
just send me a detailed PM of the format plz :)

I just need to figure out how to decompile the scripts >_>

I think tcll just scared him off :srs: LOL
By the way, I think every active hacker in this forum could use less distractions.

Sorry but you are not allowed to view spoiler contents.


Join my website, Brawl Imports, a gathering place for importers!
http://brawlimports.proboards.com/index.cgi

Support Project Darkrai? Put the official Project Darkrai banner in your siggy!
[PICTURE REMOVED. Reason: Total signature pic size exceeds 695x200.]


Quote from: PhantomWings on August 06, 2011, 12:09:56 AMThat's all for now folks. I'll hang around for a little while to see if this can be taken anywhere, but I'll be riding backseat for the most part.
Looks like you misunderstood him a bit.
As you may have noticed, I don't answer PMs with problems anymore.

August 13, 2011, 12:32:37 AM #11 Last Edit: August 13, 2011, 12:33:32 AM by ds22
Hmm, interesting data you got there Phantom Wings.
Will probably help me get rid of the Parasite Queen's voice (loop) without getting rid of the rest.

To bad character modules aren't that easy to dissect though...
A man can dream

My understanding of code is extremely low, but this looks theoretically promising (honestly, probably because Phantom Wings posted it).

What exactly does knowing what stClassInfoImpl<55, stOnlineTrainning> do do for us? (Or more specifically, people who know this stuff.... @_@)