• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Script] [Pokeemerald] Calling C/ASM routines from inside scripts.inc?

222
Posts
6
Years
    • Age 22
    • Seen Nov 18, 2023
    Hello,

    I am trying to invoke a custom C function of mine through an event. However, I have not found a way to do this. Is this possible? Do I have to register my function in a special way, like make a custom command or something? Even if I don't *have* to, if I'm going to be calling this a lot would it be better that way? How would I go about that?

    Thanks.
     
    88
    Posts
    7
    Years
    • Age 34
    • Seen Jan 16, 2020
    you can use callasm for custom assembly functions. Adding your function the special table would essentially be the same, unless you needed the special2 function with the extra argument.
     
    222
    Posts
    6
    Years
    • Age 22
    • Seen Nov 18, 2023
    you can use callasm for custom assembly functions. Adding your function the special table would essentially be the same, unless you needed the special2 function with the extra argument.

    Thanks for your help, although I was actually talking about the pokéemerald decomp ??????

    I did find the answer though. There is a command called callnative that lets you put any function name as an argument and it will run that function. You may want to add a waitstate depending on the command or the script will end before the command does!

    Example script: (SaveGame is an internal function in start_menu.c)

    Code:
    devtest_savegame::
    lock
    callnative SaveGame
    waitstate
    release
     
    Last edited:
    788
    Posts
    17
    Years
    • Age 29
    • Seen yesterday
    Callnative is the equivalent of callasm.

    The other alternatives would be to make a script command, or to set your code as a special.
     
    Back
    Top