• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best places on the 'net to talk Pokémon and more! Community members will not see the bottom screen advertisements.
  • Want to share your adventures playing Pokémon?
    Check out our new Travel Journals forum for sharing playthroughs of ROM Hacks, Fan Games, and other Pokémon content!
  • IMPORTANT: Following a takedown request, the following hacks have been delisted from PokéCommunity:

    • Pokémon Glazed
    • Pokémon: Giratina Strikes Back
    • Pokémon Flora Sky
    • Pokémon Stranded
    The downloads and discussion threads for these hacks will no longer be accessible, and staff will be unable to return questions regarding accessing this content.

Research: Study on the Special and Special2 commands

JPAN

pokemon rom researcher
104
Posts
15
Years
  • Seen Jul 2, 2016
After a long break, I came back today with a large document. Might I add, this document is still incomplete, but is an honest attempt at cracking this game.

This document I bring you is a List of All Special commands for Fire Red\Leaf Green and a small study on the Special and Special2 commands in XSE.

All of you must have worked at least once with this versatile command, that allows you to execute a pre-rendered function other than those of the script.
These commands range from small pieces of work, such as healing your pokemon, to more complex ones such as checking hardware. I shall make a brief explanation on how they work.
Special <special number> (0xaabb)
Code:
0x25 0xbb 0xaa
Special2 <variable number> <Special number> (0xvvww 0xaabb)
Code:
0x26 0xww 0xvv 0xbb 0xaa
Although slightly different in their making, they are both identical in nature. Special (also refered here as Special1) recives only the special you wish to perform. Special2 recieves also a variable to store a returned value.
Special1 and Special2 are interchangeable, meaning that using Special1 calls only for the execution of that special function for its effects, while Special2 also receives a value from the execution and stores it at the given variable.
When in doubt, using special2 will allow you to know if the function is meant to return something or not.
When searching for Specials that work in FR\LG, I found an interesting reaction from the return addresses.
Special functions can be divided in three cathegories:
The ones that return 9f69 (40809):
Code:
These are meant to be used with Special1, for their effects are what matter. 
Generaly they either return by themselves a value to the 0x800y familly (most often 0x8004,0x8005 or 0x800D)
The ones that return ADC1(44481):
Code:
These are special ones, for they seem to have fallen out of use from R\S, mostly because of the lack of real-time events,secret-bases and contests.
I Studied some of them through decompiling the ASM code, and all those I saw jumped to the same function, So I ruled them out as useless.
The ones that return other values:
Code:
These are meant to be called with Special2, as the value is what is important. 
Generaly, it's about reading values, not editing them.
Underneath, all of them function the same in the begining and in the end:
Code:
1. Special\2 found by script executer;
2. loads address based on Special appearece(special table pointer);
2.5. (the executer loads variable address in the 2nd case);
3. special number is loaded;
4. multiplies the number by 4 (adress byte size), adds it to the address loaded;
5. checks if bigger than address + (1BB*4). If not, load data from address(function address), then run it.

What the function do is what this document is all about.
This list here has all the specials I could understand what they were doing in game.
Spoiler:

Here, I place those I know what they do, but don't know what the offsets, flags and variables used mean in-game
Spoiler:

There are the ones I have no idea what they do. If any of them sound familiar, post what it does so it might be added.
Spoiler:


Just for completion, or if anyone wants to test them out, these are the specials that return ADC1:
Spoiler:

That's it for now. I hope you find this document helpful. I may return to post some more in-detailed analysis of this code to the more practice-oriented.

thanks to liuyanghejerry for the use of Special 0x39
 
Last edited:

.Seth

.explorer.
1,644
Posts
15
Years
This is a very nice document. I might add this to my upcoming scripting tutorial, if it's alright with you, of course.

I'm just wondering, would it possible to use special2 to store a variable into something like LASTRESULT to use for things like yes/no scripts, and other things?
 
219
Posts
16
Years
This is a very nice document. I might add this to my upcoming scripting tutorial, if it's alright with you, of course.

I'm just wondering, would it possible to use special2 to store a variable into something like LASTRESULT to use for things like yes/no scripts, and other things?


Yes, you can.LASTRESULT is a var too.But it will return not only 1,0,but also other hex numbers.
 
Last edited:
219
Posts
16
Years
Sorry for double reply,but I do have one thing to say.
I just found that in FR/LG,special2 0x39 is for about VS Seekers.
When returns 0x1,it means player has used VS Seekers in this place.
example:
Code:
'script from BPRE at 0x1A9CBF
#org @start
trainerbattle 0x0 0x103 0x0 @string1 @string2
special2 0x800D 0x39
compare 0x800D 0x1
if 0x1 goto @snippet1
msgbox @string3 0x6 '"You can't be a coward in the world..."
end

'---------------
#org @snippet1
trainerbattle 0x5 0x103 0x0 @string4 @string2
msgbox @string3 0x6 '"You can't be a coward in the world..."
end


'---------
' Strings
'---------
#org @string1
= Competition!\nI can't get enough!

#org @string2
= I had a chance!

#org @string3
= You can't be a coward in the world\nof POKéMON!

#org @string4
= Competing is the ultimate thrill.\nI still can't get enough!
 
Last edited:

knizz

192
Posts
16
Years
  • Seen Oct 28, 2020
Special 18F sets the trainer-flag of the last opponent. I haven't checked whether it's correct yet.
 
275
Posts
13
Years
  • Seen Oct 9, 2019
I think I've identified a few more specials by looking at FireRed's default scripts. My findings:

D8
This special updates the value of script variable 0x403A, which seems to indicate the current floor. It is used by elevator scripts.

1B8
Called when an elevator script needs to know what floor should be the default in an upcoming multichoice2. It returns 0x0, 0x1, or 0x2 (going as high as there are floors?).

160
Called after the player selects a floor. It appears to generate a message box depending on the player's selection (though the messagebox is immediately hidden with releaseall if the player chose the floor they are already on). Does it accept 0x8006 as the floor the player has selected?

1A1
I don't know what it does, but I do know that it is called by level scripts in the chambers for each Elite Four member. It appears to take variable 0x8004 as input -- 0x8004's value seems to denote which Elite Four chamber you're in.

29
Specifically, this is used to select which 3 you'll use in a (EDIT) four-player link activity (four-way battle?).

83
Used in the Daycare Man egg-giving script. It appears to check how many Pokemon are in the player's party (between 0 and 6), returning that number to the supplied variable.

94
It's not from R/S, but it is a leftover. It's called in the script for Lostelle in Berry Forest, but the buffered strings aren't used. (Perhaps in other languages, they are used?)

A9
I don't know what it is, but it's called in the Hall of Fame registration room level scripts.

127
Called when talking to the woman in the Link Battle/Trade rooms -- just before she asks you to take your seat.

128
Called when talking to the woman in the Link Battle/Trade rooms -- just after she asks you to take your seat.

135
Part of Level Script 1 in ICEFALL CAVE (1.111). It appears to play a part in managing the breakable ice tiles.

165
Part of Pokemon-giving scripts when a Pokemon received via "givepokemon" is sent to the PC.

18A
Apparently returns the number of the currently-selected box in the PC. It is used by scripts when the player receives a Pokemon via "givepokemon" and the Pokemon was sent to a different PC box because the currently-selected one was full.

194
Unknown. Used in many TRAINER TOWER scripts. Before it is invoked, 0x8004 is set to some value (I've seen 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0xA, 0xB, 0xC, 0x10, 0x12, 0x13). It APPEARS to return a value in some cases (0x0, 0x1, or 0x2). It may also take 0x8005 and 0x8006 as input.

1BA
Used twice when stepping on the script tile that triggers the HO-OH encounter on NAVEL ROCK. Does it toggle camera movement without locking all OWs?

1BB
Sometimes used with 1BA.

EDIT:

AB
Triggering a Tree wild battle isn't the only thing this function does. It will actually decide at random whether or not to trigger the battle. If no battle is triggered, 0x0000 is written to script variable 0x800D (LASTRESULT). If a battle is triggered, 0x0001 is written (so that the script calling this special knows to use waitstate).

EDIT2:

196
I think it checks if var 0x8004 is the item ID of a TM, and if so, it buffers the attack that the item teaches. I think it's used upon picking up a TM (base script: 0x081A67B3).

15E
This is used in the internal script that the game calls when the player presses A on a hidden-item Signpost event. If the item found has index 0 (item: ????????), then it is treated as a Coins pickup, and this special is used to check if the player can carry the found coins.

17D
This is also used in PC scripts, and appears to use variable 0x8004 as an argument. 0x1B represents the PC and 0x1F represents the Hall of Fame display?

185
Unknown, but it's used in the Mystery Gift questionnaire script.

C7
Called from the internal script used when the player whites out (0x081A8DFD). It sets LASTRESULT; if LASTRESULT is set to 0x1, the calling script will attempt to take money from the player.

175
Called from the internal script used when the player whites out. It takes money from the player and buffers the amount taken to buffer 0.

5
Appears to terminate a link. Called by a script at 0x081BB9D4.

18F
Called after an endtrainerbattle2 command buried in some scripts I can't make sense of. According to the OP it sets flags above 0x500 -- trainer flags.
 
Last edited:
275
Posts
13
Years
  • Seen Oct 9, 2019
Special 135 appears to be related to Icefall Cave. It's used in a level script, and some really complicated functionality that manages its breakable ice tiles (using cmda6) sets some flags... I think that special 135 either reads certain flags (to check which ice tiles have broken, and re-break them on map entry) or writes certain flags (to reset the ice tile flags, thereby unbreaking them on map entry).
 
24
Posts
11
Years
  • Seen Apr 29, 2012
No, it only returns a number depending on what happened, and you have to make it display the message depending on the number.

Well, if you're saying what I think you're saying, then I was right. I didn't necessarily mean "saying" more than "indicating"? What values does it return and to where?
 

droomph

weeb
4,285
Posts
12
Years
Well, if you're saying what I think you're saying, then I was right. I didn't necessarily mean "saying" more than "indicating"? What values does it return and to where?
Well, you specify which variable, provided you're using special2. Then it returns value to it, and you do to it whatever you like, like maybe have a tea party with it.
 
24
Posts
11
Years
  • Seen Apr 29, 2012
Well, you specify which variable, provided you're using special2. Then it returns value to it, and you do to it whatever you like, like maybe have a tea party with it.

While you might enjoy the tea party scene, I was thinking of using it to implement a HG/SS style "Catch Legendaries you accidentally killed/didn't have the Balls to capture" system using this special on a map script to make the legendary reappear or to clear the flag of the script event. You know, practical stuff that doesn't involve tea.
 

droomph

weeb
4,285
Posts
12
Years
While you might enjoy the tea party scene, I was thinking of using it to implement a HG/SS style "Catch Legendaries you accidentally killed/didn't have the Balls to capture" system using this special on a map script to make the legendary reappear or to clear the flag of the script event. You know, practical stuff that doesn't involve tea.
Well, if you check the scripts for the legendary OWs, you will find that they have a system of specials that check, with much more ease, what you have done to the Pokémon.

I can't remember off the top of my head, but that's pretty much what you could do for that.
 
29
Posts
11
Years
Just adding a unknown special2:

14F = completed all 150 pokemon in pokedex.
(Pokemon - Fire Red 1.0)

Source inside spoiler
Person event person found in CELADON CITY (10,9)
Person event: 1
Person event no: 2
Spoiler:
 

redriders180

Mastermind of Pokemon Glazed
314
Posts
13
Years
I really hope that I won't get penalized for posting here...

I think I have what the use of two other specials are.
Special 0x129 activates the roaming legends. It uses variable 0x4031 to determine which will roam. I tested this out by activating the special, and "faking" a battle with the legend using the wildbattle command. The icon then showed up on the World Map, indicating where it was.

I think Special 0x175 is used to calculate the amount of money dropped when you whiteout. In the whiteout script, Special 0x175 is called, and immediately following is the "player dropped $[buffer1]s" message. You mentioned how the Special 0x175 buffers a calculated value, so it seems like this is a likely reason for it. I could be wrong, though, since the amount of money lost is based on level of Pokemon and number of badges, not status.
 
416
Posts
11
Years
  • Age 34
  • Seen Feb 10, 2024
I belive:

14F: Checks if KantoDex is Complete (Returns 1 if it is complete)

it is used by the "Game Designer" in Celadon Mansion
 
5,256
Posts
16
Years
1ab actually controls most of the Birth Island puzzle.

Every time the player hits the Triangle from the right angle/amount of steps (not sure which) 0x8000 is set to 0x1. If the player gets it wrong/takes too long, it is set to 0x0. Once the puzzle is completed, it is set to 0x2. Every time after, it is set to 0x3.
 
Back
Top