- 8
- Posts
- 9
- Years
- Seen Mar 31, 2016
I understand how to write script in XSE, and I'm learning ASM. But I have some questions that maybe someone can answer quickly? (note: for some reason I can't bring up irc).
EDIT: I've answered all my questions and posted the answers in this post for reference to others who find this. If you have any questions or more to add, feel free to post anyways, I'll be around! :)
My Questions [Pokemon Emerald]:
As I research and get help I will post Answers:
Thanks for your time!
Regards,
Lavits
EDIT: I've answered all my questions and posted the answers in this post for reference to others who find this. If you have any questions or more to add, feel free to post anyways, I'll be around! :)
My Questions [Pokemon Emerald]:
Spoiler:
How do I set a value to a variable using ASM? How many bytes is a variable?
I understand that 4011 to 40ff are safe, can I also use 8000+? what's the difference?
How are variables related to the script buffer values (XSE)? What is the best way to create a message box that contains a value that I stored in a variable (XSE)?
What is the best way to transfer the value from one variable to another using XSE?
I understand that 4011 to 40ff are safe, can I also use 8000+? what's the difference?
How are variables related to the script buffer values (XSE)? What is the best way to create a message box that contains a value that I stored in a variable (XSE)?
What is the best way to transfer the value from one variable to another using XSE?
As I research and get help I will post Answers:
Spoiler:
To set the value of variables 4010+ using ASM one must load r0 with a number referencing how many past 4010 you want (0 = 4010, 1 = 4011, ...), then, call 0x0809D6D0. This ASM routine puts an address in r0 referencing the current location of the variable you are looking for.
Variables are halfwords (2 bytes). Once you have the address you can load/store 2 bytes in them.
Variables less than 8000 are dynamic, meaning their address is not always the same (thus thy must be determined by an ASM routine call).
Variables 8000+ are static, meaning their addresses are the same, always, BUT, they are used often, so don't expect the value to remain behind for very long. Variable 8000 is at offset 0x020375D8 (Pokemon Emerald). Variables 8000-800B can be found using the formula: 0x020375D8 + (2 * (800# - 8000)) [i.e. they are every two bytes starting at 0x020375D80]. Two bytes after 800B is 800D, then 800F, then 800C (800C is not in order with the rest). Do yourself a favor and only use 4011-4020, 8000-800B, and 800D.
In XSE the buffernumber function can be used to put two bytes from a variable into a two byte buffer space. The buffer can then be used in the middle of a string.
You can use setvar to place any value in any variable.
Variables are halfwords (2 bytes). Once you have the address you can load/store 2 bytes in them.
Variables less than 8000 are dynamic, meaning their address is not always the same (thus thy must be determined by an ASM routine call).
Variables 8000+ are static, meaning their addresses are the same, always, BUT, they are used often, so don't expect the value to remain behind for very long. Variable 8000 is at offset 0x020375D8 (Pokemon Emerald). Variables 8000-800B can be found using the formula: 0x020375D8 + (2 * (800# - 8000)) [i.e. they are every two bytes starting at 0x020375D80]. Two bytes after 800B is 800D, then 800F, then 800C (800C is not in order with the rest). Do yourself a favor and only use 4011-4020, 8000-800B, and 800D.
In XSE the buffernumber function can be used to put two bytes from a variable into a two byte buffer space. The buffer can then be used in the middle of a string.
You can use setvar to place any value in any variable.
Thanks for your time!
Regards,
Lavits
Last edited: