- 12
- Posts
- 3
- Years
- Seen Jul 19, 2022
Hello everyone,
I got back into playing Pokemon Ruby a few weeks ago and enjoyed it ever since.
Now that I 100%ed it, I wanted to get into ROM hacking of said game.
I have set myself a little challenge of fixing as many glitches in the game as I possibly can.
For now I did some minor corrections using Advance Map 1.92 to edit NPC properties or moving/removing tiles.
Yesterday I finally hit my first roadblock: I want to fix the PokeMart clerk in Oldale Town.
It's a well known glitch where they run into a tree, if you didn't have enough space in your inventory to receive the potion.
I have already set up XSE 1.1.1 to edit scripts, but I still have questions left, which hopefully one of the gurus here can answer :)
#1 What is the correct way to edit existing code?
From what I understood so far, XSE is able to dynamically use the ROMs available addresses to store data.
Take for example the existing PokeMart clerk:
* do I have to move all the existing code with my new additions to a new address and change the sprites script to the new offset address?
* or can I simply start adding, and XSE will change the offsets of all subsequent existing things (even data outside of the current sprite script) on it's own, without me overwriting stuff?
My goal is to fix the behaviour, but keeping everything as close to vanilla as possible.
#2 Are the flags simple Bits, or are they Bytes?
Just for understanding the concept behind them, I would like to know what the flags are actually.
They get accessed by something that looks like it could be a RAM address, but I would assume from my gut feeling that they actually are just Bits, not whole Bytes.
Some of those flags seem to be implicitly set by routine calls - the lower ones I assume, like 0x0 or 0x1 for example when doing a checkflag.
#3 Why does the script for the PokeMart clerk not work?
The sprites script starts at 0x14DDDC:
The Map Script of Oldale starts at 0x14DD88:
So far I understand that in the Map Script (which is executed when you enter the town) the clerk is moved to his starting position next to the bottom right house, if the flag 0x84 (promo potion received) is NOT set.
That way the walk can properly be played.
When you speak to the clerk and the walk is performed, the flax 0x1 gets set (line #9 of clerk script) - this way the game keeps track if you already have spoken to him (and thus walked up).
If you immediately talk to them again but didn't receive the promotion because of a full bag, the walk will not be performed.
---
To my understanding the bug occurs when you leave the map and enter again, because the Map Script executes and 0x1 is overwritten because of other calls in it.
And when you talk to the clerk again (while 0x84 still being false), the walk will be played.
This in itself wouldn't be an issue, but somehow the Map Script with the movesprite2 call does not execute (properly?) - the clerk still stands just before the PokeMart.
If I would have to guess, I would say that sprites can't be moved if they are considered to be on screen.
That guy isn't on screen when I just barely leave the town and come back, but maybe the game handles sprites up to X tiles outside of the viewable area as "still on screen" - veterans could maybe answer that question :)
Edit: if you walk far enough away from the town and then back in, the clerk will be reset at the correct position again.
#4 is RAM saved to the save file?
So my question is if ALL the flags and variables (or all the RAM for that matter) is stored in the save file.
I would assume so, because when I save the game and reload while something is temporarely changed, the change still exists when reloading.
Be it either the clerk standing next to the PokeMart even when 0x84 is false, or a tile existing near me, even when I changed it with Advance Map (will be corrected once you enter again though) - this at least would make me think certain stuff gets saved.
Kind regards
I got back into playing Pokemon Ruby a few weeks ago and enjoyed it ever since.
Now that I 100%ed it, I wanted to get into ROM hacking of said game.
I have set myself a little challenge of fixing as many glitches in the game as I possibly can.
For now I did some minor corrections using Advance Map 1.92 to edit NPC properties or moving/removing tiles.
Yesterday I finally hit my first roadblock: I want to fix the PokeMart clerk in Oldale Town.
It's a well known glitch where they run into a tree, if you didn't have enough space in your inventory to receive the potion.
Spoiler:
I have already set up XSE 1.1.1 to edit scripts, but I still have questions left, which hopefully one of the gurus here can answer :)
#1 What is the correct way to edit existing code?
From what I understood so far, XSE is able to dynamically use the ROMs available addresses to store data.
Take for example the existing PokeMart clerk:
* do I have to move all the existing code with my new additions to a new address and change the sprites script to the new offset address?
* or can I simply start adding, and XSE will change the offsets of all subsequent existing things (even data outside of the current sprite script) on it's own, without me overwriting stuff?
My goal is to fix the behaviour, but keeping everything as close to vanilla as possible.
#2 Are the flags simple Bits, or are they Bytes?
Just for understanding the concept behind them, I would like to know what the flags are actually.
They get accessed by something that looks like it could be a RAM address, but I would assume from my gut feeling that they actually are just Bits, not whole Bytes.
Some of those flags seem to be implicitly set by routine calls - the lower ones I assume, like 0x0 or 0x1 for example when doing a checkflag.
#3 Why does the script for the PokeMart clerk not work?
The sprites script starts at 0x14DDDC:
Spoiler:
![[PokeCommunity.com] Fixing the PokeMart clerk glitch in Pokemon Ruby [PokeCommunity.com] Fixing the PokeMart clerk glitch in Pokemon Ruby](https://i.ibb.co/55p92KQ/clerk-script.png)
The Map Script of Oldale starts at 0x14DD88:
Spoiler:
![[PokeCommunity.com] Fixing the PokeMart clerk glitch in Pokemon Ruby [PokeCommunity.com] Fixing the PokeMart clerk glitch in Pokemon Ruby](https://i.ibb.co/pfwPYpJ/map-script.png)
So far I understand that in the Map Script (which is executed when you enter the town) the clerk is moved to his starting position next to the bottom right house, if the flag 0x84 (promo potion received) is NOT set.
That way the walk can properly be played.
When you speak to the clerk and the walk is performed, the flax 0x1 gets set (line #9 of clerk script) - this way the game keeps track if you already have spoken to him (and thus walked up).
If you immediately talk to them again but didn't receive the promotion because of a full bag, the walk will not be performed.
---
To my understanding the bug occurs when you leave the map and enter again, because the Map Script executes and 0x1 is overwritten because of other calls in it.
And when you talk to the clerk again (while 0x84 still being false), the walk will be played.
This in itself wouldn't be an issue, but somehow the Map Script with the movesprite2 call does not execute (properly?) - the clerk still stands just before the PokeMart.
If I would have to guess, I would say that sprites can't be moved if they are considered to be on screen.
That guy isn't on screen when I just barely leave the town and come back, but maybe the game handles sprites up to X tiles outside of the viewable area as "still on screen" - veterans could maybe answer that question :)
Spoiler:
![[PokeCommunity.com] Fixing the PokeMart clerk glitch in Pokemon Ruby [PokeCommunity.com] Fixing the PokeMart clerk glitch in Pokemon Ruby](https://i.ibb.co/KXsx3GP/just-outside-of-oldale.png)
Edit: if you walk far enough away from the town and then back in, the clerk will be reset at the correct position again.
#4 is RAM saved to the save file?
So my question is if ALL the flags and variables (or all the RAM for that matter) is stored in the save file.
I would assume so, because when I save the game and reload while something is temporarely changed, the change still exists when reloading.
Be it either the clerk standing next to the PokeMart even when 0x84 is false, or a tile existing near me, even when I changed it with Advance Map (will be corrected once you enter again though) - this at least would make me think certain stuff gets saved.
Kind regards
Last edited: