Bladecraft
It's written "Bladecraft" on my forehead.
- 83
- Posts
- 8
- Years
- Seen Jun 18, 2020
Introduction
So, what do we do to find the script?
Step One
Translating Into Hex
Last Step
Final Words & Removing The Script
What A Twist!
Actual Final Words:
Life lessons from a rom hacking tutorial. Bet you didn't expect that.
Honestly? Neither did I.
Eyryyybody! I'm Blade, and I'm a decent rom hacker with a nice knowledge of scripting.
This tutorial is made especially for NoMoreStars, and I thought considering I had this problem too, I'd make a tutorial for everyone, using NoMoreStars's problem as an example.
Let's beginThis tutorial is made especially for NoMoreStars, and I thought considering I had this problem too, I'd make a tutorial for everyone, using NoMoreStars's problem as an example.
So, we'll be attempting to remove the script where Mom asks the player to come over to the TV to see Dad in his gym. First of all, we need to find this script. Since this script happens after leaving the room into the living room in your house in Littleroot, we can assume that setting the clock sets some sort of variable, then there's a level script in the player's house, but that's incorrect.
A brief checking can tell that non of the tile scripts nor the level scripts in the living room in the player's house indicate of this script.
A brief checking can tell that non of the tile scripts nor the level scripts in the living room in the player's house indicate of this script.
So, what do we do to find the script?
We will need the following tools:
Any Hex Editor (most people including myself use HexD)
G3T (Gen 3 Tools for the Anti-Exploud feature)
XSE to easily change the script and find how does the game write commands in hex
G3T (Gen 3 Tools for the Anti-Exploud feature)
XSE to easily change the script and find how does the game write commands in hex
Step One
First, we ask ourselves the following question: What do we know about this script?
We need to find unique features about this script in order to find it.
The easiest to use are texts, so that's what we're going to do.
We're going to use this piece of text from the game.
Note that the text you use must be from the beginning of the msgbox, or you will be stuck later on.
We need to find unique features about this script in order to find it.
The easiest to use are texts, so that's what we're going to do.
![[PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map [PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map](https://i.imgur.com/wUj2lw7.png)
We're going to use this piece of text from the game.
Note that the text you use must be from the beginning of the msgbox, or you will be stuck later on.
Translating Into Hex
Now let's say we were to write this text string in a script, we would do it like so:
= MOM: Oh! [player], [player]!/nQuick! Come quickly!
= MOM: Oh! [player], [player]!/nQuick! Come quickly!
Hex Vocabulary
Spoiler:
At this point, we should figure out what we need to search in HxD, but first, some language you should know.
In hex, in Pokemon Emerald
FB = \p
FE = \n
FA = \l
FD 06 = [rival] | MAY/BRENDAN depending on your gender.
FD 01 = [player]
FD 01 FD 05 = [player]
Brief explanation about the [player] part:
This will help us out later.
In hex, in Pokemon Emerald
FB = \p
FE = \n
FA = \l
FD 06 = [rival] | MAY/BRENDAN depending on your gender.
FD 01 = [player]
FD 01 FD 05 = [player]
Brief explanation about the [player] part:
Spoiler:
Emerald uses "special letters" in order to write things that may be changing. These "letters" are two bytes long and always start with FD and another byte.
Technically, only FD 01 is [player], but due to some stuff in the Japanese version, sometimes there's the useless FD 05 coming after it.
If you can't find one, try either removing or adding the FD 05 after FD 01.
Technically, only FD 01 is [player], but due to some stuff in the Japanese version, sometimes there's the useless FD 05 coming after it.
If you can't find one, try either removing or adding the FD 05 after FD 01.
This will help us out later.
Now to the Translating Part
Now, we open up G3T (with any Emerald rom) and open the Anti-Exploud Feature.
Into the "Old Text" box, we write the text as it appears in the game.
MOM: Oh! [player], [player]! Quick! Come quickly!
Since G3T can't translate [player] into anything, we will just leave those as spaces for now.
Anyways, we copy the hex values from the box under "Old Text", make sure it's from Old and not New text, so it's not accidentally decapitalized, since we're looking for the text that's already in the game.
Now, we open up G3T (with any Emerald rom) and open the Anti-Exploud Feature.
Into the "Old Text" box, we write the text as it appears in the game.
MOM: Oh! [player], [player]! Quick! Come quickly!
Since G3T can't translate [player] into anything, we will just leave those as spaces for now.
![[PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map [PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map](https://i.imgur.com/BiMgRqe.png)
Anyways, we copy the hex values from the box under "Old Text", make sure it's from Old and not New text, so it's not accidentally decapitalized, since we're looking for the text that's already in the game.
Here's our result:
C7 C9 C7 F0 00 C9 DC AB 00 B8 00 AB 00 CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
C7 C9 C7 F0 00 C9 DC AB 00 B8 00 AB 00 CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
Fine Tuning
Anyhow, we got this pile of un-understandable garbage, what do we do with it?
First, we need to insert the [player] part.
You can start reading and translating from hex, but I just like matching up the letters like so:
M`O`M``:````O`h``!`````,````!`````Q`u``i``c``k``!````C``o`m`e````q`u``i``c``k``l``y``!
C7 C9 C7 F0 00 C9 DC AB 00 B8 00 AB 00 CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
So we simply put the hex value for [player] in the correct places, which is right before the first B8 and the second AB
And now we got this:
C7 C9 C7 F0 00 C9 DC AB 00 FD 01 B8 00 FD 01 AB 00 CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
Next is to put text commands (\p, \l, \n) in the correct places. We know that \n is FE, could you figure this out by yourself?
Answer:
It should be instead of the 00 after the second AB. Because it's right before the "Quick!" part begins, but there's no space in between the exclamation mark and the capital Q, so the 00 (space) should be removed.
C7 C9 C7 F0 00 C9 DC AB 00 FD 01 B8 00 FD 01 AB FE CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
Now that we know what should we be searching, we only now open our rom in HxD.
Anyhow, we got this pile of un-understandable garbage, what do we do with it?
First, we need to insert the [player] part.
You can start reading and translating from hex, but I just like matching up the letters like so:
M`O`M``:````O`h``!`````,````!`````Q`u``i``c``k``!````C``o`m`e````q`u``i``c``k``l``y``!
C7 C9 C7 F0 00 C9 DC AB 00 B8 00 AB 00 CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
So we simply put the hex value for [player] in the correct places, which is right before the first B8 and the second AB
And now we got this:
C7 C9 C7 F0 00 C9 DC AB 00 FD 01 B8 00 FD 01 AB 00 CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
Next is to put text commands (\p, \l, \n) in the correct places. We know that \n is FE, could you figure this out by yourself?
Answer:
Spoiler:
It should be instead of the 00 after the second AB. Because it's right before the "Quick!" part begins, but there's no space in between the exclamation mark and the capital Q, so the 00 (space) should be removed.
C7 C9 C7 F0 00 C9 DC AB 00 FD 01 B8 00 FD 01 AB FE CB E9 DD D7 DF AB 00 BD E3 E1 D9 00 E5 E9 DD D7 DF E0 ED AB
Now that we know what should we be searching, we only now open our rom in HxD.
Last Step
Once you opened your rom in HxD, press Ctrl+F to start the find function and make sure the Datatype is set to Hex Value.
Copy and paste the hex values we edited from G3T, and start by searching forward.
I found the text in 1F7B96. How do I know this? HxD is nice enough to tell us this information in various places.
Now, we would like to make sure we're on the correct string of text, and that this text does not accidentally appear twice. For that, we will simply search forward again.
In this instance we don't have this text appearing anywhere else in the game. This is because we've searched for enough text to make it unique to this cutscene. If we were to search for "MOM" or "[player]" and only that, there would be a risk that we're editing the wrong script, which we don't want.
Copy and paste the hex values we edited from G3T, and start by searching forward.
I found the text in 1F7B96. How do I know this? HxD is nice enough to tell us this information in various places.
![[PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map [PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map](https://i.imgur.com/fC1pLgd.png)
Now, we would like to make sure we're on the correct string of text, and that this text does not accidentally appear twice. For that, we will simply search forward again.
In this instance we don't have this text appearing anywhere else in the game. This is because we've searched for enough text to make it unique to this cutscene. If we were to search for "MOM" or "[player]" and only that, there would be a risk that we're editing the wrong script, which we don't want.
Anyways, we found that, now what do we do?
Simple. As we all should know, when we write a script and put a msgbox command somewhere, we always add a pointer to the text. Which means, this msgbox we just found is a part of a script, now we need to find that script.
What we do is find the pointer to the text. How do we do that? Great question.
We take the beginning offset of the text (1F7B96 in our example) and separate it into three bytes.
1F7B96
1F 7B 96
Now, we reverse the order of these three bytes (or simply replace the first and last one).
1F7B96
1F 7B 96
96 7B 1F
And put a 08 in the end of all that.
Here's the entire process:
Simple. As we all should know, when we write a script and put a msgbox command somewhere, we always add a pointer to the text. Which means, this msgbox we just found is a part of a script, now we need to find that script.
What we do is find the pointer to the text. How do we do that? Great question.
We take the beginning offset of the text (1F7B96 in our example) and separate it into three bytes.
1F7B96
1F 7B 96
Now, we reverse the order of these three bytes (or simply replace the first and last one).
1F7B96
1F 7B 96
96 7B 1F
And put a 08 in the end of all that.
Here's the entire process:
Spoiler:
1F7B96 // Separate into three bytes
1F 7B 96 // Reverse the order
96 7B 1F // Put a 08 in the end
96 7B 1F 08 // Done and ready to use
1F 7B 96 // Reverse the order
96 7B 1F // Put a 08 in the end
96 7B 1F 08 // Done and ready to use
Important Sidenote:
Anyways, back on track, now we search HxD for 96 7B 1F 08, which is the line "msgbox 0x001F7B96" in the script we're looking for. Making progress!
I found 96 7B 1F 08 in the offset 292964.
Now, we open 292964 in XSE, while our rom is open in it and we find this mumbo jumbo.
Spoiler:
I suggest writing down every offset you find and what that offset contains.
For example I'd write: 1F7B96 - MOM: oh! player come quick quickly...
For example I'd write: 1F7B96 - MOM: oh! player come quick quickly...
Anyways, back on track, now we search HxD for 96 7B 1F 08, which is the line "msgbox 0x001F7B96" in the script we're looking for. Making progress!
I found 96 7B 1F 08 in the offset 292964.
Now, we open 292964 in XSE, while our rom is open in it and we find this mumbo jumbo.
![[PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map [PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map](https://i.imgur.com/aF0Ce07.png)
In case you don't know what I just did, simply open XSE, go to File -> Open and open your rom. Then in the Offset box in the top right, write down your offset, 292964 in my case.
Back on track, I don't really know why that is, I only assume it's because XSE is reading the script wrong because it doesn't know the entire script.
Back on track, I don't really know why that is, I only assume it's because XSE is reading the script wrong because it doesn't know the entire script.
Final Step:
What we do now, is simply walk back byte by byte until we find the entire script, which lies in the offset 29294B. I know this is especially true because in the previous byte (29294A) there's simply the line "end".
Sometimes, you may see after putting in the offset for the first time comprehensible parts from the script you're looking for.
Anyways, here's the complete script:
'---------------
#org 0x29294B
sound 0x15
applymovement 0x8005 0x8272598
waitmovement 0x0
applymovement 0x8005 0x827259A
waitmovement 0x0
msgbox 0x81F7B96 MSG_KEEPOPEN '"MOM: Oh! [player], [player]!\nQuic..."
closeonkeypress
return
'---------
' Strings
'---------
#org 0x1F7B96
= MOM: Oh! [player], [player]!\nQuick! Come quickly!
'-----------
' Movements
'-----------
#org 0x272598
#raw 0x56 'Exclamation Mark (!)
#raw 0xFE 'End of Movements
#org 0x27259A
#raw 0x14 'Delay5
#raw 0x14 'Delay5
#raw 0x14 'Delay5
#raw 0xFE 'End of Movements
What we do now, is simply walk back byte by byte until we find the entire script, which lies in the offset 29294B. I know this is especially true because in the previous byte (29294A) there's simply the line "end".
Sometimes, you may see after putting in the offset for the first time comprehensible parts from the script you're looking for.
Anyways, here's the complete script:
Spoiler:
'---------------
#org 0x29294B
sound 0x15
applymovement 0x8005 0x8272598
waitmovement 0x0
applymovement 0x8005 0x827259A
waitmovement 0x0
msgbox 0x81F7B96 MSG_KEEPOPEN '"MOM: Oh! [player], [player]!\nQuic..."
closeonkeypress
return
'---------
' Strings
'---------
#org 0x1F7B96
= MOM: Oh! [player], [player]!\nQuick! Come quickly!
'-----------
' Movements
'-----------
#org 0x272598
#raw 0x56 'Exclamation Mark (!)
#raw 0xFE 'End of Movements
#org 0x27259A
#raw 0x14 'Delay5
#raw 0x14 'Delay5
#raw 0x14 'Delay5
#raw 0xFE 'End of Movements
Final Words & Removing The Script
That concludes the tutorial, so those who read it for this purpose may now thank me and accept me as their Lord and Savior. To be honest, this may seems like a long and complicated process, but with some experience you can do this in only five minutes and with extreme ease. However, my job is not done.
To be honest... I completely lied to you guys.
All of this tutorial might be helpful, but it is definitely NOT the way to remove that event from the game. The solution is actually a lot simpler than this.
To be honest... I completely lied to you guys.
All of this tutorial might be helpful, but it is definitely NOT the way to remove that event from the game. The solution is actually a lot simpler than this.
What A Twist!
As a lot of us know, vars, somewhat like flags are often used to trigger and block events from happening. We need to understand this in order to achieve our goal.
The var 0x4092 is in charge of the tutorial stuff.
For example, if it's set to 0x1 it means you left the truck. If it's set to 0x3 it means there are Vigoroth's doing stuff to your house.
Here's what we need to do:
We open the clock script from A-Map.
It's a pretty long script, so we'll be looking only at this specific part:
Notice the "setvar 0x4092 0x6" line.
If we will delete this line, or change the setvar from 0xE to something else, a different event will occur.
I am not sure what the var is set to right now, but I do know that if we delete the line entirely, the game will think that we haven't set the clock, and therefore will send us back to our room.
It's all about experimenting, I first deleted the line and then understood the above, and then I changed the line to "setvar 0x4092 0x8"
When var 0x4092 is set to 0x8, this means you left your house after setting the clock and you now should go to your Rival's house.
Here's a gif proving that this is working.
The var 0x4092 is in charge of the tutorial stuff.
For example, if it's set to 0x1 it means you left the truck. If it's set to 0x3 it means there are Vigoroth's doing stuff to your house.
Here's what we need to do:
We open the clock script from A-Map.
It's a pretty long script, so we'll be looking only at this specific part:
Spoiler:
#org 0x292799
checkflag 0x51
if 0x1 goto 0x829283F
msgbox 0x81F8668 MSG_KEEPOPEN '"The clock is stopped[.]\pBetter se..."
call 0x8292849
pause 0x1E
setvar 0x4092 0x6
setflag 0x51
setflag 0x2F2
setflag 0x2F3
checkgender
compare LASTRESULT 0x0
if 0x1 call 0x82927DF
compare LASTRESULT 0x1
if 0x1 call 0x829280F
sound 0x9
hidesprite 0x8008
releaseall
end
checkflag 0x51
if 0x1 goto 0x829283F
msgbox 0x81F8668 MSG_KEEPOPEN '"The clock is stopped[.]\pBetter se..."
call 0x8292849
pause 0x1E
setvar 0x4092 0x6
setflag 0x51
setflag 0x2F2
setflag 0x2F3
checkgender
compare LASTRESULT 0x0
if 0x1 call 0x82927DF
compare LASTRESULT 0x1
if 0x1 call 0x829280F
sound 0x9
hidesprite 0x8008
releaseall
end
Notice the "setvar 0x4092 0x6" line.
If we will delete this line, or change the setvar from 0xE to something else, a different event will occur.
I am not sure what the var is set to right now, but I do know that if we delete the line entirely, the game will think that we haven't set the clock, and therefore will send us back to our room.
It's all about experimenting, I first deleted the line and then understood the above, and then I changed the line to "setvar 0x4092 0x8"
When var 0x4092 is set to 0x8, this means you left your house after setting the clock and you now should go to your Rival's house.
Here's a gif proving that this is working.
![[PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map [PokeCommunity.com] How to [Probably] Find Any Script Even Outside A-Map](https://i.imgur.com/kZCopOS.gif)
Actual Final Words:
Now of course, I believe that I have done a good job constructing this tutorial, and explaining everything and what to do. However, the greatest lesson this tutorial presents is that sometimes, you're trying to do the right thing in the wrong way.
We've learned how to find any script, but it turns out we didn't need that information at all to do what we were trying to do for the longest time.
We've learned how to find any script, but it turns out we didn't need that information at all to do what we were trying to do for the longest time.
Life lessons from a rom hacking tutorial. Bet you didn't expect that.
Honestly? Neither did I.
Last edited: