Kitty Corp Meow Mix Forums

Super Smash Bros. Brawl Hacking => Programming => Topic started by: PhantomWings on August 05, 2011, 06:09:56 PM



Title: The Beginner's Guide to Stage Modules
Post by: PhantomWings on August 05, 2011, 06:09:56 PM
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

stClassInfo:
Declaration: 80B292A8
Constructor Method: 809301d0
Inherits: None
Methods: 3
Size: 0x04

gfTask:
Declaration: 80422F08
Constructor Method: 8002d8b8
Inherits: None
Methods: 23
Method Range: 0 - 22
Size: 0x44

Stage:
Declaration: 80B29088
Constructor Method: 8092c478
Inherits: gfTask
Methods: 127
Method Range: 23 - 126
Size: 0x1A0

stCommonGimmick:
Declaration: 80B2B608
Constructor Method: 80942614
Inherits: Stage, gfTask
Methods: 127
Size: 0x1D0

stMelee:
Declaration: 80B2B8E8
Constructor Method: 809435F0
Inherits: stCommonGimmick, Stage, gfTask
Methods: 132
Method Range: 127 - 132
Size: 0x1D8

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])
(http://img713.imageshack.us/img713/7865/diagramy.png) (http://imageshack.us/photo/my-images/713/diagramy.png/)

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.
Code:
00 *Null
01 System FW
02 System
03 Effect
04 RenderFifo
05 Sound
06 Network
07 WiiPad
08 IteamResource
09 InfoResource
0A CommonResource
0B Replay
0C Tmp
0D Physics
0E ItemInstance
0F StageInstance
10 *Null
11 StageResoruce
12 Fighter1Resoruce
13 Fighter2Resoruce
14 Fighter3Resoruce
15 Fighter4Resoruce
16 Fighter1Resoruce2
17 Fighter2Resoruce2
18 Fighter3Resoruce2
19 Fighter4Resoruce2
1A FighterEffect
1B Fighter1Instance
1C Fighter2Instance
1D Fighter3Instance
1E Fighter4Instance
1F FighterTechqniq
20 FighterKirbyResource1
21 FighterKirbyResource2
22 FighterKirbyResource3
23 AssistFigureResource
24 ItemExtraResource
25 *Null
26 PokemonResource
27 *Null
28 InfoInstance
29 *Null
2A MenuInstance
2B *Null
2C CopyFB
2D GameGlobal
2E GlobalMode
2F *Null
30 MeleeFont
31 *Null
32 OverlayCommon
33 OverlayStage
34 OverlayMenu
35 OverlayFighter1
36 OverlayFighter2
37 OverlayFighter3
38 OverlayFighter4
39 *Null
3A Thread


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.


Title: Re: The Beginner's Guide to Stage Modules
Post by: SmashClash on August 05, 2011, 06:18:57 PM
Noone posted here yet?!
Wonderful guide, PW.
People were doubting you or Dant would come back. But here you are! :D


Title: Re: The Beginner's Guide to Stage Modules
Post by: BlackJax96 on August 05, 2011, 06:43:01 PM
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.


Title: Re: The Beginner's Guide to Stage Modules
Post by: Protoman.EXE on August 05, 2011, 09:19:08 PM
inb40vah9000requests

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


Title: Re: The Beginner's Guide to Stage Modules
Post by: Eternal Yoshi on August 05, 2011, 09:39:50 PM
I did not notice this thread. Thanks for this info.


Title: Re: The Beginner's Guide to Stage Modules
Post by: DoctorFlux(Mariodk) on August 06, 2011, 01:23:32 AM
PM is back that can only means one thing :D
something awesome is Coming like always you leaving and then come back


Title: Re: The Beginner's Guide to Stage Modules
Post by: xxmasal22xx on August 07, 2011, 08:43:46 PM
HES BACK EVERYBODY!!!

Welcome back Phantom Wings! Great to see ya!


Title: Re: The Beginner's Guide to Stage Modules
Post by: nanobuds on August 09, 2011, 03:09:08 PM
well.... now hes gone...  :>.>:


Title: Re: The Beginner's Guide to Stage Modules
Post by: DarkPikachu on August 09, 2011, 09:13:04 PM
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 >_>


Title: Re: The Beginner's Guide to Stage Modules
Post by: xxmasal22xx on August 10, 2011, 07:56:55 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


Title: Re: The Beginner's Guide to Stage Modules
Post by: Jaklub on August 10, 2011, 11:04:30 AM
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.
Looks like you misunderstood him a bit.


Title: Re: The Beginner's Guide to Stage Modules
Post by: ♤♡◇♧ on August 12, 2011, 06:32:37 PM
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


Title: Re: The Beginner's Guide to Stage Modules
Post by: Sajiao Omelette on August 12, 2011, 06:47:34 PM
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.... @_@)