Pages: 1
RicBent |
Posted on 07-04-15, 10:54 am
|
Mariomaster
Karma: 8528 Posts: 470/1681 Since: 06-09-12 |
In the symbols.x there are a lot of functions which seem to load files.
Here a few examples: Can somebody explain how these functions work and which parameters they take (generally how to do that). _________________________ GitHub - Kuribo64 - YouTube |
Dirbaio |
Posted on 07-04-15, 02:23 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10000 Posts: 4284/4457 Since: 06-08-11 |
Okay, let me write down what I remember on how this works (it's been a long time...)
NSMB internally loads files referenced by something I called the "Extended ID" or "ExtId" for short. Info on ExtIDs here: http://nsmbhd.net/thread/1095-no-more-sprite-set-limitation-in-mvsl/#16464 By default the game loads files into its own RAM storage that gets deleted when you exit the level. The "Dest" variations of the function allow you to provide your own pointer to where to load the data. The "LZ" variations LZ-uncompress the file when loading it. Example on how to load a file here: https://github.com/Dirbaio/NSMBCR/blob/master/source/animations.cpp#L187 The "allocFromCacheTable" function is like a malloc that gets automatically freed when you exit the level. I *think* it's the same function used by the non-Dest functions, so doing loadFileByExtId is the same as doing allocFromCacheTable+loadFileByExtId_Dest This is all I have, if you want more details you'll have to look at the IDA DB. |
RicBent |
Posted on 07-04-15, 04:53 pm (rev. 3 by RicBent on 07-08-15, 06:20 pm)
|
Mariomaster
Karma: 8528 Posts: 471/1681 Since: 06-09-12 |
animationFile = (u16*) allocFromCacheTable(4096);
loadFileByExtId_LZ_Dest(48, animationFile); Is my guess correct, that allocFromCacheTable(int size) reserves the needed ram (in this case 4096 bytes?) and loadFileByExtId_LZ_Dest(ExtId id, void* dest) writes the file with the ID ExtId - 131 to the reserved area in ram? This results in two questions: I know that I'm not a programming genius Edit: Wow. I got a file loaded succesfully. Thank you very much! And looks like your ASM hack isn't working because the size of the alloc was to small. Anyways, thank you _________________________ GitHub - Kuribo64 - YouTube |
Pages: 1