The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Script Using the pointer loaded to the script bank as a goto or call? (https://www.pokecommunity.com/showthread.php?t=410139)

hjk321 June 26th, 2018 8:35 PM

Using the pointer loaded to the script bank as a goto or call?
 
Now I'm sure a lot of us know you can use loadpointer in conjunction with preparemsg to dynamically change the value of a displayed textbox like so:

Spoiler:

Code:

loadpointer 0x0 0x740009      ' Points to a string, and loads it to bank 0x0

------------

'separate, generic function that gets called a lot
preparemsg 0x0
waitmsg
return




But I'm curious to know if there was a (preferrably non-ASM) way to do a similar thing and call the pointer at script bank 0? Like a script could, in effect, dynamically change the functionality of another script down the road.

I looked through the command listings and surprisingly the support for banks is very limited within the game engine. Most commands that accept banks as parameters simply perform operations of those banks.

But maybe I missed something. There's no possible way the engine could support strings and not other pointers within the banks. Anyone ever tried this before? It might just be that I'll have to either work around this or buckle down and learn how to code ASM.

DrFuji June 27th, 2018 12:27 AM

Quote:

Originally Posted by hjk321 (Post 9894481)
Now I'm sure a lot of us know you can use loadpointer in conjunction with preparemsg to dynamically change the value of a displayed textbox like so:

Spoiler:

Code:

loadpointer 0x0 0x740009      ' Points to a string, and loads it to bank 0x0

------------

'separate, generic function that gets called a lot
preparemsg 0x0
waitmsg
return




But I'm curious to know if there was a (preferrably non-ASM) way to do a similar thing and call the pointer at script bank 0? Like a script could, in effect, dynamically change the functionality of another script down the road.

I looked through the command listings and surprisingly the support for banks is very limited within the game engine. Most commands that accept banks as parameters simply perform operations of those banks.

But maybe I missed something. There's no possible way the engine could support strings and not other pointers within the banks. Anyone ever tried this before? It might just be that I'll have to either work around this or buckle down and learn how to code ASM.

Script banks are pretty terrible places to try and work with pointers as they are constantly being set and reset by interacting with the world. Entering a house, interacting with an NPC and loading a text box (as well as probably a dozen other things) clear the bank pointers and leave you with nothing. That being said, there's no real way to call the bank pointers in a script without using ASM. If you don't want to use ASM you might be able to use eval in some capacity depending on the situation, but it would be far easier to just use variables and flags to remember what's happened and change the functionality of your scripts off them.

The four script banks are loaded into the RAM starting at 0x03000F14 if you want to experiment with what actions clear the pointers there.


All times are GMT -8. The time now is 9:14 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.