Juan
Brazilian with a bad English
- 92
- Posts
- 17
- Years
- Age 34
- Pindamonhangaba - SP
- Seen Sep 21, 2016
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:
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:
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:
Just change them to the new offset.
The next pointers, store pointers to the end of the function table (0x081DC2CC):
To change them, just follow the following form:
This will be the new offset the end of the function table.
Example:
======================================================
Data:
BPEE
BPRE
======================================================
BPEE Functions:
0x0:
0x1:
0x2:
0x3:
0x4:
0x5:
0x6:
0x7:
0x8:
0x9:
0xA:
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
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
After copying, you must edit 8 pointers.
The following offsets store pointers to the table of functions:
Code:
0x08099530
0x08099560
0x080995AC
0x080995AC
The next pointers, store pointers to the end of the function table (0x081DC2CC):
Code:
0x00099534
0x00099564
0x000995B0
0x000995FC
Code:
Offset = TableOffset + (number of functions * 4)
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
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.
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.
Code:
'---------------
#org 0x271315
lock
faceplayer
preparemsg 0x0
waitmsg
waitkeypress
release
return
Code:
'---------------
#org 0x271320
lockall
preparemsg 0x0
waitmsg
waitkeypress
releaseall
return
Code:
'---------------
#org 0x27132A
preparemsg 0x0
waitmsg
waitkeypress
return
Code:
'---------------
#org 0x271332
preparemsg 0x0
waitmsg
yesnobox 0x14 0x8
return
Code:
'---------------
#org 0x271494
preparemsg 0x0
waitmsg
waitkeypress
release
return
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.
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.
Code:
'---------------
#org 0x27133C
preparemsg 0x0
fanfare 0x1CB
waitfanfare
waitmsg
return
Code:
'---------------
#org 0x271347
pokenavcall 0x0
waitmsg
return
Last edited by a moderator: