PDA

View Full Version : [Tutorial] Using ScriptDec to view RSE/FRLG Scripts


Dabomstew
October 4th, 2007, 01:25 AM
ScriptDec, as the title implies, is a program used to reverse compiled scripts into something a bit more viewable by humans. Unlike ScriptED or Pokescript, it actually does a decent job at doing this (no offense to the authors of those programs, but the decompilers are pretty unreliable, not that I'd ever want to be tasked with writing one). But being a DOS command line program, its use may confuse some people, so I compiled this small tutorial.

If you're a relative newbie to scripting, stop here. This tutorial isn't for you - it will not help you learn scripting. If you want to duplicate the effect of an existing script, you're better off just using that script as it is and changing the text.

Download ScriptDec: here (http://www.magicstone.de/rhw/files/gbatools/ScriptDec.zip)

ScriptDec is made by loadingNOW, not me. As such, I cannot answer questions about it, or fix any bugs. I am simply providing a tutorial for its use, as when used properly, it is a valuable resource to hackers seeking to add new features to their scripts. To my knowledge, the last release of the program was in 2005, so the likelihood of an update is very small, though the source was included with the release.

There are two ways to use ScriptDec, one is actually notoriously easy which involves using EliteMap, and one slightly more difficult, but more reliable.

The Easy Way:
Download ScriptDec from the above link, and extract it to a folder.
Rename the main ScriptDec EXE file to scripted.exe
Replace the scripted.exe in the folder of EliteMap with your renamed ScriptDec (remember to replace scripted with the original if you actually want to make a script using it!)
Make sure your ROM doesn't have any spaces in the filename! (Preferably no special characters at all, but I know it doesn't work with spaces.)
Open your ROM in EliteMap, find the event you want to see the script of, and Ctrl+click it.
Press N and then Enter, as it is not a level script.
The script will appear in your internet browser as a htm file.


The Other Way: (for if you dont like EliteMap, or it crashes when using your rom, etc)
Download ScriptDec from the above link, and extract it to a folder.
Copy the rom you want to view the script from into its directory.
Find the offset of the script you want to view in AdvanceMap or EliteMap, and make note of it.
Run the DOS command prompt, navigating to the directory with scriptdec in it, and run the command:
scriptdec romname.gba:offsetinhex
For example, for OAK's script in Fire Red:
scriptdec firered.gba:169595
For the offset, do not include any 0x or &H, just the six numbers/letters of the offset.
If your rom name has spaces in it, make sure to put quotes around the rom name (but not anything else), like so:
scriptdec "Fire Red.gba":169595
Press N and then Enter, as it is not a level script.
The script will appear in your internet browser as a htm file


ScriptDec can decode level scripts, but is not very good at doing so as it does not recognize the 02 structure that is used for the bulk of the script. If you want to actually view a level script, interpret the structure according to Baro's tutorial in order to find the offset of the main bulk of the script, and view it as a non-level script.

Sometimes, the script may appear blank or incomplete in your browser. Don't worry, this isn't a sign of failure, it just means ScriptDec opened the web browser before it finished decompiling the script. So just wait a couple of seconds, then refresh the page. The script should appear in its entirety, or at least up until the point which ScriptDec can decode (it seems to stumble on the hex command C7, but I haven't found any other problems yet).

ScriptDec is not a miracle program. It will not solve the problem of making custom trading scripts, or doing anything you want in a script. It is, however, very useful for finding new commands and specials to use in one's scripting.

If you understand scripting to a good extent, I recommend looking through the source-code of ScriptDec (provided in the zip) as it has several commands not found in the ScriptED or PokeScript command databases that can be useful to your scripts.

Tutorial by Dabomstew. Not to be copied without permission.

Juan
October 4th, 2007, 10:42 AM
Where he is link for Download?

cooley
October 4th, 2007, 02:24 PM
Where he is link for Download?

This doesn't work for me. I renamed it to 'firered.gba' but it tells me: Error opening file Firered,
Usage: ScriptDec Romname.gba: [offset in hex]

Elementologist
October 7th, 2007, 02:28 AM
I'll provide the link for everyone: ScriptDec (http://www.magicstone.de/rhw/files/gbatools/ScriptDec.zip)

This doesn't work for me. I renamed it to 'firered.gba' but it tells me: Error opening file Firered,
Usage: ScriptDec Romname.gba: [offset in hex]
I'm sure you did something wrong. I tried it at least five times to get it right. This is what you have to do: Say your rom is pokemonfirered.gba and your offset is 16582F. So you write (Once you are in the ScriptDEC dir in DOS):
scriptdec pokemonfirered.gba:16582F.
To go to the directory in DOS, you type cd and then your directory.
For Instance: cd Users\Person\Desktop\Scriptdec

I Have A Question. Okay, scriptdec decompiles scripts, but does it also compile, I mean, can I use it to add scripts to my rom?

D-Trogh
October 7th, 2007, 02:35 AM
Well.. I know ScriptDec for a while.. and I made a batch file so I can work faster XD
cls
@echo off
echo Pokemon FireRed
set choice=
set /p choice=Offset:
ScriptDec FireRed.gba:%choice%
Paste this in NotePad, save with 'All files' selected as: FireRed.bat
Now, when you have ScriptDec, this batch file and a FireRed ROM (Named: FireRed.gba) in the same folder and you execute the batch file.. You are asked to write the offset. Ones that's done, push enter and choose the script type (Level script or not).
Maybe I can edit ScriptDec source to be more user friendly.. :-\

HackMew
October 7th, 2007, 05:39 AM
I Have A Question. Okay, scriptdec decompiles scripts, but does it also compile, I mean, can I use it to add scripts to my rom?

No, it doesn't. You can only view scripts and nothing else.

Knox
October 7th, 2007, 07:18 AM
D-Trough yours does not work.

When I type in the offset the black box just disappears?

cooley
October 7th, 2007, 07:30 AM
@knox: I know what you mean....

Knox
October 7th, 2007, 12:34 PM
Hey cooley make sure your ROM isn't patched.

That might be the reason it doesn't work.

I haven't tried it yet so it may not work

thethethethe
October 7th, 2007, 12:35 PM
That shouldn't be the problem. It should work even if te rom is patched.

Knox
October 7th, 2007, 12:50 PM
Yeah but what if some of the offsets got deleted?

Like I was trying to use an oak script in a Shinygold ROM?

Wouldn't that not make it work?

thethethethe
October 7th, 2007, 12:58 PM
Yeah but that's different. That's kind of like looking for a fire red offset in a ruby rom. There is no point. The only reason you'd look at a patched rom would be to view an uncommon script like the Red Gyarados or any other new scripts. If you wanted to view the oak script, wouldn't you just look in a normal FR rom?

Knox
October 7th, 2007, 01:01 PM
Yeah I know.

I forgot it was a SG ROM.

cooley
October 8th, 2007, 07:56 AM
Although some people don't need to, a reason ScriptED may not work for many is because it doesn't see the file extension. To make it see it, in a folder, go to Tools> Folder Options> View, and turn off the "hide filetype extensions" box. That is how you make it work.


Works for me now.But, How do you know if it is a level script or not?

Knox
October 8th, 2007, 12:41 PM
Hey thanks cooley but I have no idea what a level script is.

But if your script is screwed up I guess that is when you can tell

thethethethe
October 8th, 2007, 01:05 PM
Well it depends what you clicked through in Elitemap. If you clicked on a person event or a trigger event, it's a normal script. If you clicked the button at the top that says view level script then, obviously, its a level script.

johnlycett
October 18th, 2007, 11:09 PM
Well, strange i did it but comes up with couldn't find scripted.exe When i renamed it so weird. lol

Satoshi Sugimori
October 23rd, 2007, 02:44 PM
uhm I have a question I do exactly as in the tutorial (The other way) and it works good but when i do n and then push enter it just goes away and nothing happend...
help please...

and maybe an idea
maybe you should use screenshots by every step it is easier to understand...:)

opeious
December 19th, 2007, 05:44 AM
Well i didn't use the first way because elitemap doesn't work on my PC bt it used to earliar mut anyway the second way works eg:-
"p-script dump by pscriptDec UNSTABLE (C)2005 loadingNOW
;SCRIPT ENTRY POINT08169BFF: 6A lock
08169C00: 5A faceplayer
08169C01: 16 store-h [ptr],I 4001 0000
08169C06: 16 store-h [ptr],I 4002 0001
08169C0B: 16 store-h [ptr],I 4003 0004
08169C10: 16 store-h [ptr],I 4004 0007
08169C15: 21 cmp16 [ptr],I 4055 0003
08169C1A: 06 jmp_if 04 08169E38
08169C20: 21 cmp16 [ptr],I 4055 0002
08169C25: 06 jmp_if 01 08169C35
08169C2B: 0F LoadPointer,bank,ofs 00 0818EA6D ;Possible String Ref: Those are POKé BALLS.\n They contain POKéMON!
08169C31: 09 call_standart,(0-7) 04
08169C33: 6C Release
08169C34: 02 quit

;Referenced by a conditional JUMP address @ 08169C2508169C35: 4F MoveSprite 0004 081A7643
08169C3C: 51 RunMove(wait) 0000
08169C3F: 75 Raw75 4002 0A 03
08169C44: C7 ???
08169C45: 00 nop
08169C46: 21 cmp16 [ptr],I 4001 0000
08169C4B: 06 jmp_if 01 08169C68
08169C51: 21 cmp16 [ptr],I 4001 0001
08169C56: 06 jmp_if 01 08169C87
08169C5C: 21 cmp16 [ptr],I 4001 0002
08169C61: 06 jmp_if 01 08169CA6
08169C67: 02 quit

;Referenced by a conditional JUMP address @ 08169C4B08169C68: 0F LoadPointer,bank,ofs 00 0818E2C6 ;Possible String Ref: I see! BULBASAUR is your choice.\n It's very easy to raise.\n\n\n So, {PLAYERNAME}, you want to go with\n the GRASS POKéMON BULBASAUR?
08169C6E: 09 call_standart,(0-7) 05
08169C70: 21 cmp16 [ptr],I 800D 0001
08169C75: 06 jmp_if 01 08169CC8
08169C7B: 21 cmp16 [ptr],I 800D 0000
08169C80: 06 jmp_if 01 08169CC5
08169C86: 02 quit

;Referenced by a conditional JUMP address @ 08169C5608169C87: 0F LoadPointer,bank,ofs 00 0818E25B ;Possible String Ref: Hm! SQUIRTLE is your choice.\n It's one worth raising.\n\n\n So, {PLAYERNAME}, you've decided on the\n WATER POKéMON SQUIRTLE?
08169C8D: 09 call_standart,(0-7) 05
08169C8F: 21 cmp16 [ptr],I 800D 0001
08169C94: 06 jmp_if 01 08169CC8
08169C9A: 21 cmp16 [ptr],I 800D 0000
08169C9F: 06 jmp_if 01 08169CC5
08169CA5: 02 quit

;Referenced by a conditional JUMP address @ 08169C6108169CA6: 0F LoadPointer,bank,ofs 00 0818E1E8 ;Possible String Ref: Ah! CHARMANDER is your choice.\n You should raise it patiently.\n\n\n So, {PLAYERNAME}, you're claiming the\n FIRE POKéMON CHARMANDER?
08169CAC: 09 call_standart,(0-7) 05
08169CAE: 21 cmp16 [ptr],I 800D 0001
08169CB3: 06 jmp_if 01 08169CC8
08169CB9: 21 cmp16 [ptr],I 800D 0000
08169CBE: 06 jmp_if 01 08169CC5
08169CC4: 02 quit

;Referenced by a conditional JUMP address @ 08169C80, 08169C9F, 08169CBE08169CC5: 76 ???
08169CC6: 6C Release
08169CC7: 02 quit

;Referenced by a conditional JUMP address @ 08169C75, 08169C94, 08169CB308169CC8: 76 ???
08169CC9: 53 Raw53 800F
08169CCC: 0F LoadPointer,bank,ofs 00 0818E339 ;Possible String Ref: This POKéMON is really quite\n energetic!
08169CD2: 09 call_standart,(0-7) 04
08169CD4: 04 call 081A66C9
08169CD9: 29 SetFlag 0828
08169CDC: 29 SetFlag 0291
08169CDF: 79 GivePokemon 4002 05 0000
08169CE5: 00 nop
08169CE6: 00 nop
08169CE7: 00 nop
08169CE8: 00 nop
08169CE9: 00 nop
08169CEA: 00 nop
08169CEB: 00 nop
08169CEC: 00 nop
08169CED: 00 nop
08169CEE: 19 Copy16 [ptr]<-[ptr] 4031 4001
08169CF3: 7D Raw7D 00 4002
08169CF7: 67 msgbox2 0818E361 ;Possible String Ref: {PLAYERNAME} received the {TEXTSTRING}\n from PROF. OAK!
08169CFC: 66 waitmsgbox2
08169CFD: 31 fanfare 013E
08169D00: 32 waitfanfare
08169D01: 0F LoadPointer,bank,ofs 00 081A56FB ;Possible String Ref: Do you want to give a nickname to\n this {TEXTSTRING}?
08169D07: 09 call_standart,(0-7) 05
08169D09: 21 cmp16 [ptr],I 800D 0001
08169D0E: 06 jmp_if 01 08169D20
08169D14: 21 cmp16 [ptr],I 800D 0000
08169D19: 06 jmp_if 01 08169D30
08169D1F: 02 quit

;Referenced by a conditional JUMP address @ 08169D0E08169D20: 16 store-h [ptr],I 8004 0000
08169D25: 04 call 081A753F
08169D2A: 05 jmp 08169D30
08169D2F: 02 quit

;Referenced by a conditional JUMP address @ 08169D19, 08169D2A08169D30: 68 grabmove
08169D31: 21 cmp16 [ptr],I 4001 0000
08169D36: 06 jmp_if 01 08169D53
08169D3C: 21 cmp16 [ptr],I 4001 0001
08169D41: 06 jmp_if 01 08169D73
08169D47: 21 cmp16 [ptr],I 4001 0002
08169D4C: 06 jmp_if 01 08169D63
08169D52: 02 quit

;Referenced by a conditional JUMP address @ 08169D3608169D53: 4F MoveSprite 0008 08169DB6
08169D5A: 51 RunMove(wait) 0000
08169D5D: 05 jmp 08169D83
08169D62: 02 quit

;Referenced by a conditional JUMP address @ 08169D4C08169D63: 4F MoveSprite 0008 08169DBF
08169D6A: 51 RunMove(wait) 0000
08169D6D: 05 jmp 08169D83
08169D72: 02 quit

;Referenced by a conditional JUMP address @ 08169D4108169D73: 4F MoveSprite 0008 08169DC6
08169D7A: 51 RunMove(wait) 0000
08169D7D: 05 jmp 08169D83
08169D82: 02 quit

;Referenced by a JUMP address @ 08169D5D, 08169D6D, 08169D7D08169D83: C7 ???
08169D84: 00 nop
08169D85: 0F LoadPointer,bank,ofs 00 0818DD88 ;Possible String Ref: {06}: I'll take this one, then!
08169D8B: 09 call_standart,(0-7) 04
08169D8D: 53 Raw53 4004
08169D90: C7 ???
08169D91: 03 ret

;Referenced by a conditional JUMP address @ 08169C1A08169E38: 0F LoadPointer,bank,ofs 00 0818EA99 ;Possible String Ref: That's PROF. OAK's last POKéMON.
08169E3E: 09 call_standart,(0-7) 04
08169E40: 6C Release
08169E41: 02 quit

;Referenced by a CALL address @ 08169CD4081A66C9: 19 Copy16 [ptr]<-[ptr] 8012 8013
081A66CE: 03 ret

;Referenced by a CALL address @ 08169D25081A753F: 97 fadescreen 01
081A7541: 25 Level2Cmd 009E ;9E Enter Nickname
081A7544: 27 [30005B0],1
081A7545: 03 ret"

ASuch
June 25th, 2010, 05:02 AM
I can't get this to work.... It automatically gives me this: C:\Users\Blank>, so this was what I put in:

C:\Users\Blank>cd Downloads> ScriptDec scriptdec firered.gba:800E9BN

I click enter, and then it says that the path could not be found. Can someone help?