The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.


Advertise here

Reply
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old November 19th, 2009, 08:33 AM
Juan
Brazilian with a bad English
 
Join Date: Jun 2007
Location: Pindamonhangaba - SP
Age: 23
Nature: Adamant

Advertise here
Following the discussion that Pokepal17 started on the topic of discussion on reusing scripts several times to save space, I come with this tutorial on how to add more functions (std's).

Functions are pre-defined scripts that can be used in any script(gotostd, callstd, gotostdif, callstdif).

Example(BPEE):

std 0x06:
Code:
#org 0x271494
preparemsg 0x0
waitmsg
waitkeypress
release
return
These are the commands to display a normal message box.
You do not need to always use these commands, simply call with callstd 0x06.

In Emerald (BPEE), the table of pointers start in 0x081DC2A0 and ends in 0x081DC2CC.
o we can say that there are 11 functions. (0x0 - 0xA)

Functions in BPEE:

Code:
ROM:081DC2A0                 DCD off_8271AD3         ; 0x0
ROM:081DC2A4                 DCD off_8271BFD         ; 0x1
ROM:081DC2A8                 DCD off_8271315         ; 0x2
ROM:081DC2AC                 DCD off_8271320         ; 0x3
ROM:081DC2B0                 DCD off_827132A         ; 0x4
ROM:081DC2B4                 DCD off_8271332         ; 0x5
ROM:081DC2B8                 DCD off_8271494         ; 0x6
ROM:081DC2BC                 DCD off_8271BB7         ; 0x7
ROM:081DC2C0                 DCD off_82742C9         ; 0x8
ROM:081DC2C4                 DCD off_827133C         ; 0x9
ROM:081DC2C8                 DCD off_8271347         ; 0xA
To add more functions, just copy the table of pointers to an empty space.
After copying, you must edit 8 pointers.

The following offsets store pointers to the table of functions:
Code:
0x08099530
0x08099560
0x080995AC
0x080995AC
Just change them to the new offset.

The next pointers, store pointers to the end of the function table (0x081DC2CC):
Code:
0x00099534
0x00099564
0x000995B0
0x000995FC
To change them, just follow the following form:

Code:
Offset = TableOffset + (number of functions * 4)
This will be the new offset the end of the function table.

Example:
Code:
Offset = 0x081DC2A0  + (11 * 4)
Offset = 0x81DC2CC
======================================================

Data:
BPEE
Code:
Number of Functions=    11
Table Start=         0x081DC2A0
Table End=         0x081DC2CC
Table Begin Pointers=     0x08099530
             0x08099560
                0x080995AC
            0x080995AC
Table End Pointers=     0x08099534
            0x08099564
            0x080995B0
            0x080995FC
BPRE
Code:
Number of Functions=    9
Table Start=         0x08160450
Table End=         0x08160478
Table Begin Pointers=     0x0806A178
             0x0806A1A8
                0x0806A1F4
            0x0806A240
Table End Pointers=     0x0806A17C
            0x0806A1AC
            0x0806A1F8
            0x0806A244
======================================================

BPEE Functions:

0x0:
Code:
'---------------
#org 0x271AD3
additem 0x8000 0x8001
copyvar 0x8007 LASTRESULT
call 0x8271AE3
return

'---------------
#org 0x271AE3
bufferitems2 0x1 0x8000 0x8001
checkitemtype 0x8000
call 0x8271B08
compare 0x8007 0x1
if 0x1 call 0x8271B95
compare 0x8007 0x0
if 0x1 call 0x8271BA9
return

'---------------
#org 0x271B08
copyvar 0x8000 LASTRESULT
compare 0x8000 0x1
if 0x1 goto 0x8271B45
compare 0x8000 0x5
if 0x1 goto 0x8271B55
compare 0x8000 0x2
if 0x1 goto 0x8271B65
compare 0x8000 0x3
if 0x1 goto 0x8271B75
compare 0x8000 0x4
if 0x1 goto 0x8271B85
end

'---------------
#org 0x271B95
preparemsg 0x8272A78 '"Obtained the [buffer2]!"
waitfanfare
msgbox 0x8272A9A MSG_KEEPOPEN '"[player] put away the [buffer2]\ni..."
setvar LASTRESULT 0x1
return

'---------------
#org 0x271BA9
setvar LASTRESULT 0x0
return

'---------------
#org 0x271B45
bufferstd 0x2 0xE
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271B55
bufferstd 0x2 0xF
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271B65
bufferstd 0x2 0x10
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271B75
bufferstd 0x2 0x11
compare 0x8007 0x1
if 0x1 call 0x8271BB3
return

'---------------
#org 0x271B85
bufferstd 0x2 0x12
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271BAF
fanfare 0x172
return

'---------------
#org 0x271BB3
fanfare 0x174
return


'---------
' Strings
'---------
#org 0x272A78
= Obtained the [buffer2]!

#org 0x272A9A
= [player] put away the [buffer2]\nin the [buffer3] POCKET.
0x1:
Code:
'---------------
#org 0x271BFD
lock
faceplayer
checksound
copyvar 0x8004 0x8000
copyvar 0x8005 0x8001
checkitemroom 0x8000 0x8001
copyvar 0x8007 LASTRESULT
bufferitems2 0x1 0x8000 0x8001
checkitemtype 0x8000
call 0x8271B08
compare 0x8007 0x1
if 0x1 call 0x8271C3A
compare 0x8007 0x0
if 0x1 call 0x8271CA1
release
return

'---------------
#org 0x271B08
copyvar 0x8000 LASTRESULT
compare 0x8000 0x1
if 0x1 goto 0x8271B45
compare 0x8000 0x5
if 0x1 goto 0x8271B55
compare 0x8000 0x2
if 0x1 goto 0x8271B65
compare 0x8000 0x3
if 0x1 goto 0x8271B75
compare 0x8000 0x4
if 0x1 goto 0x8271B85
end

'---------------
#org 0x271C3A
hidesprite LASTTALKED
additem 0x8004 0x8005
special2 LASTRESULT 0x19E
copyvar 0x8008 LASTRESULT
compare 0x8008 0x1
if 0x1 call 0x8271C8F
compare 0x8008 0x0
if 0x1 call 0x8271C9B
waitfanfare
waitmsg
bufferitems2 0x1 0x8004 0x8005
setvar 0x8004 0xC
special 0xF3
compare LASTRESULT 0x1
if 0x1 goto 0x8271C86
msgbox 0x8272A9A MSG_KEEPOPEN '"[player] put away the [buffer2]\ni..."
return

'---------------
#org 0x271CA1
msgbox 0x8272A78 MSG_KEEPOPEN '"Obtained the [buffer2]!"
msgbox 0x8272AD0 MSG_KEEPOPEN '"Too bad!\nThe BAG is full[.]"
setvar LASTRESULT 0x0
return

'---------------
#org 0x271B45
bufferstd 0x2 0xE
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271B55
bufferstd 0x2 0xF
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271B65
bufferstd 0x2 0x10
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271B75
bufferstd 0x2 0x11
compare 0x8007 0x1
if 0x1 call 0x8271BB3
return

'---------------
#org 0x271B85
bufferstd 0x2 0x12
compare 0x8007 0x1
if 0x1 call 0x8271BAF
return

'---------------
#org 0x271C8F
bufferitems2 0x0 0x8004 0x8005
preparemsg 0x82731A9 '"[player] found one [buffer1]\n[buf..."
return

'---------------
#org 0x271C9B
preparemsg 0x8272ABF '"[player] found one [buffer2]!"
return

'---------------
#org 0x271C86
msgbox 0x8272AEA MSG_KEEPOPEN '"[player] put away the [buffer2]\ni..."
return

'---------------
#org 0x271BAF
fanfare 0x172
return

'---------------
#org 0x271BB3
fanfare 0x174
return


'---------
' Strings
'---------
#org 0x272A9A
= [player] put away the [buffer2]\nin the [buffer3] POCKET.

#org 0x272A78
= Obtained the [buffer2]!

#org 0x272AD0
= Too bad!\nThe BAG is full[.]

#org 0x2731A9
= [player] found one [buffer1]\n[buffer2]!

#org 0x272ABF
= [player] found one [buffer2]!

#org 0x272AEA
= [player] put away the [buffer2]\nin the BAG.
0x2:
Code:
'---------------
#org 0x271315
lock
faceplayer
preparemsg 0x0
waitmsg
waitkeypress
release
return
0x3:
Code:
'---------------
#org 0x271320
lockall
preparemsg 0x0
waitmsg
waitkeypress
releaseall
return
0x4:
Code:
'---------------
#org 0x27132A
preparemsg 0x0
waitmsg
waitkeypress
return
0x5:
Code:
'---------------
#org 0x271332
preparemsg 0x0
waitmsg
yesnobox 0x14 0x8
return
0x6:
Code:
'---------------
#org 0x271494
preparemsg 0x0
waitmsg
waitkeypress
release
return
0x7:
Code:
'---------------
#org 0x271BB7
adddecoration 0x8000
copyvar 0x8007 LASTRESULT
call 0x8271BC5
return

'---------------
#org 0x271BC5
bufferdecoration 0x1 0x8000
compare 0x8007 0x1
if 0x1 call 0x8271BE0
compare 0x8007 0x0
if 0x1 call 0x8271BF7
return

'---------------
#org 0x271BE0
fanfare 0x172
preparemsg 0x8272B09 '"Obtained the [buffer2]!"
waitfanfare
msgbox 0x8272B48 MSG_KEEPOPEN '"The [buffer2] was transferred\nto ..."
setvar LASTRESULT 0x1
return

'---------------
#org 0x271BF7
setvar LASTRESULT 0x0
return


'---------
' Strings
'---------
#org 0x272B09
= Obtained the [buffer2]!

#org 0x272B48
= The [buffer2] was transferred\nto the PC.
0x8:
Code:
'---------------
#org 0x2742C9
buffertrainerclass 0x0 0x8000
buffertrainername 0x1 0x8000
closeonkeypress
pause 0x1E
fanfare 0x1CC
msgbox 0x8272E0F MSG_KEEPOPEN '"Registered [buffer1] [buffer2]\nin..."
waitfanfare
closeonkeypress
pause 0x1E
return


'---------
' Strings
'---------
#org 0x272E0F
= Registered [buffer1] [buffer2]\nin the POKéNAV.
0x9:
Code:
'---------------
#org 0x27133C
preparemsg 0x0
fanfare 0x1CB
waitfanfare
waitmsg
return
0xA:
Code:
'---------------
#org 0x271347
pokenavcall 0x0
waitmsg
return
__________________

Last edited by hashtag; April 15th, 2010 at 08:12 AM.
Reply With Quote
  #2    
Old November 19th, 2009, 11:19 AM
Tropical Sunlight's Avatar
Tropical Sunlight
The Faltine
 
Join Date: Mar 2008
Location: Slovenia
Age: 18
Gender: Male
Send a message via Windows Live Messenger to Tropical Sunlight
I'm not getting this. What's this for?
I'm sorry for being such a nuisance.
__________________
Reply With Quote
  #3    
Old November 19th, 2009, 11:45 AM
Wichu's Avatar
Wichu
Project Amethyst
 
Join Date: Sep 2007
Location: North Herts, England
Age: 21
Gender: Male
Nature: Naive
It's about adding/using standard functions (for example, instead of manually scripting the commands for an item ball, you can just call the item ball standard function instead).
__________________
Reply With Quote
  #4    
Old November 19th, 2009, 11:47 AM
Tropical Sunlight's Avatar
Tropical Sunlight
The Faltine
 
Join Date: Mar 2008
Location: Slovenia
Age: 18
Gender: Male
Send a message via Windows Live Messenger to Tropical Sunlight
Quote:
Originally Posted by Wichu View Post
It's about adding/using standard functions (for example, instead of manually scripting the commands for an item ball, you can just call the item ball standard function instead).
Oh.
Seems useful.
Thank you
__________________
Reply With Quote
  #5    
Old November 19th, 2009, 01:10 PM
Pokepal17's Avatar
Pokepal17
More cowbell~
 
Join Date: Oct 2008
Location: Steeltown
Age: 19
Gender: Male
Nature: Modest
Wow its useful and I'm gonna try this out. Glad I could be of help.
__________________
Pokémon Stardrop
Reply With Quote
  #6    
Old November 19th, 2009, 03:01 PM
Juan
Brazilian with a bad English
 
Join Date: Jun 2007
Location: Pindamonhangaba - SP
Age: 23
Nature: Adamant
Quote:
Originally Posted by H2O Turquoise View Post
I'm not getting this. What's this for?
I'm sorry for being such a nuisance.
Quote:
Originally Posted by Wichu View Post
It's about adding/using standard functions (for example, instead of manually scripting the commands for an item ball, you can just call the item ball standard function instead).
[2]
Instead of entering multiple commands always, you can enter only one and save space.
Ex: Yes/No msgbox:

Code:
loadpointer 0x0 @message     ' "loadpointer 0x0" is the same than "msgbox"
preparemsg 0x0
waitmsg
yesnobox 0x14 0x8
15 bytes

Alternative:
Code:
loadpointer 0x0 @message     ' "loadpointer 0x0" is the same than "msgbox"  
callstd 0x5
8 bytes

Or in actual XSE:
Code:
msgbox @message 0x5
8 bytes

You'll economize 7 bytes whenever you use a yes/no msgbox.

Scripts related items are bigger, so you save even more bytes.

Quote:
Originally Posted by Pokepal17 View Post
Wow its useful and I'm gonna try this out. Glad I could be of help. :P
:D
__________________
Reply With Quote
  #7    
Old November 19th, 2009, 03:48 PM
colcolstyles's Avatar
colcolstyles
Yours truly
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
Very helpful. Thanks a lot. :)
__________________

Brother of Vrai
Reply With Quote
  #8    
Old May 30th, 2010, 05:51 PM
colcolstyles's Avatar
colcolstyles
Yours truly
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
Quote:
Originally Posted by Juan View Post
The following offsets store pointers to the table of functions:
Code:
0x08099530
0x08099560
0x080995AC
0x080995AC
A great tutorial but I think that in the above quote, the bolded text should be "0x080995F8" and not a repeat of the previous address. At least, that's where I found a pointer to "0x081DC2A0".
__________________

Brother of Vrai
Reply With Quote
  #9    
Old June 7th, 2010, 09:08 PM
X-Buster
Advanced Trainer
 
Join Date: Feb 2008
i did try this and it work, now i can manage to call my arcanine jump script with call std 0xA.

one question, is there a limit in adding std functions? what if you exceeded 255(0xFF). 256(0x00 0x01) or more is already a word, and callstd needs only a byte. is it possible to have more than 256(0 - 255) functions?

i know 256 std functions is a crazy idea. but hey, they can be useful tho.
__________________

Last edited by X-Buster; June 7th, 2010 at 10:59 PM.
Reply With Quote
  #10    
Old December 4th, 2011, 02:54 PM
droomph's Avatar
droomph
mmm gurl that 90s
Community Supporter
 
Join Date: Sep 2011
Location: bar'jách
Age: 17
Gender: Male
Nature: Impish
Quote:
Originally Posted by X-Buster View Post
i did try this and it work, now i can manage to call my arcanine jump script with call std 0xA.

one question, is there a limit in adding std functions? what if you exceeded 255(0xFF). 256(0x00 0x01) or more is already a word, and callstd needs only a byte. is it possible to have more than 256(0 - 255) functions?

i know 256 std functions is a crazy idea. but hey, they can be useful tho.
You would probably have to change the actual engine of the game, which is something *nobody* should really want to do, and if you don't change all the callstd/gostd/jumpstd 0xyy commands in the game to callstd/gostd/jumpstd 0xyyyy, the game is unplayable, as it will do crazy things to the commands after every callstd/gostd/jumpstd from then on.






(It's also not very realistic to have 257 standard function anyways, because then you would need 257 6-byte-or-more string of frequently-used pattern of commands to make everything economical. And judging by how many standard functions even GameFreak used for ALL the games, you will need one complicated/long storyline to utilize every standard function you make.

I'm not saying you shouldn't, but that's reality.)
__________________
did u no there r 21 letters in the alphabet
o i forgot 5
uraqt


Reply With Quote
  #11    
Old December 7th, 2011, 02:27 PM
Full Metal's Avatar
Full Metal
C(++) Developer.
Community Supporter
 
Join Date: Jan 2008
Location: In my mind.
Age: 19
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to Full Metal
The absence of the on-slaught of n00bs asking questions bothers me.
This is a great tutorial, and one of the few decent ( and useful ) ones
that I have seen in a while. It covers something that isn't so ( forgive me, those of you who think Advance Map is hard to figure out and requires a tutorial ) simple, or obvious. If I was still hacking actively ( as opposed to passively ) I would definitely be using this. -- Thumbs Up --
__________________

★ full metal.

I like to push it,
and push it,
until my luck is over.
Reply With Quote
Reply
Quick Reply

Sponsored Links


Advertise here
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 08:12 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.