Pages: 1
Posted on 07-04-15, 10:54 am
Mariomaster

Karma: 8166
Posts: 470/1609
Since: 06-09-12
In the symbols.x there are a lot of functions which seem to load files.

Here a few examples:
  • loadFileByExtId
  • loadFileByExtId_LZ
  • loadFileByExtId_3dModel
  • loadFileByExtId_FlushDC_2
  • loadFileByExtId_Dest
  • and a bunch more

  • Can somebody explain how these functions work and which parameters they take (generally how to do that).
    _________________________
    GitHub - Kuribo64 - YouTube
    Posted on 07-04-15, 02:23 pm
    Super Mario
    ( ͡° ͜ʖ ͡°)

    Karma: 9591
    Posts: 4284/4446
    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.

    Posted on 07-04-15, 04:53 pm (rev. 3 by RicBent on 07-08-15, 06:20 pm)
    Mariomaster

    Karma: 8166
    Posts: 471/1609
    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:
  • Why 4096? Wreckring_crew.narc is 11424 bytes big.
  • Am I able to fill an array with that loaded data (Kinda like a for loop that starts at (in this case) animationFile) blarg


  • 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