PHO - Pokémon Hackers Online
Go Back   PHO - Pokémon Hackers Online > Discussion Board > Archive

Notices

Archive Old threads that serve no purpose are here.

 
 
Thread Tools Display Modes
Old 3rd November 2013, 03:36 PM   #1
mewthree9000
Junior Trainer
 
mewthree9000's Avatar
 
Join Date: May 2010
Location: U.S.A.
Age: 28
Posts: 70
mewthree9000 mewthree9000
Default [THUMB MODE] How to run scripts via ASM


Translated by: Mewthree9000

Today we will be running scripts through ASM!
This method only works on overworld events. These will NOT work in bag or in battle.

Minimum requirements:
  1. Basic knowledge of routines
  2. Knowledge of these ASM commands: Ldr, Bl, push {LR}, pop {pc}, and Branch&Exchange (Bx)
  3. Basic Knowledge of Registers

Here is a brief explanation of each command with a scripting analogy, in order to perceive them better:

Ldr, the command used to loadnumbers in the registers and RAM. This command is a kind of loadpointer in the literal sense. This command loads a 32bit number in the memory (in this case, the registers)

Bl, is like the scripting command 'call', which calls a subroutine (In scripting, a subscript, like 'CallStd'). To function properly, the subroutine call must end in Pop {pc}...Pop {pc} is like the command 'Return' in scripting: It returns to the function that has been called.

Bx rX, It's like the command 'Goto' in scripting.
---------------------------------------------

ATTENTION: I DO NOT USE THE COMPILER 'Goldroad'.
THIS CODE IS FOR DEVKITARM and THE BUILDER MID2AGB (as.exe and objcopy.exe)



Example for FireRed:
Code:
Spoiler:

.thumb
.align 2
push {lr}
ldr r0, SCRIPT_ADDRESS
bl SCRIPT_ROUTINE / / subroutine that will run the scripts
pop {pc}

SCRIPT_ROUTINE:
ldr r1, SCRIPT_EXECUTOR
Bx r1

.align 2
SCRIPT_ADDRESS: .word 0x081624F5 / / Here is where you define your script offset.
SCRIPT_EXECUTOR: .word 0x08069AE5 / / This is the routine that executes the scripts. Offset +1


The arguments are:
r0 = Script offset (the offset of a script you want to use)
r1 = Script executor (the offset of the script executor)

These are the offsets for the Script Executors
(NOTE, don't forget to add +1 to the offset!):

Ruby: 080655B8
FireRed: 08069AE4
Emerald: 08098EF8

That's all for now! I hope I have helped!
-------------------------------------
Tutorial originally made by: Sonicarvalho AKA Dark Rayquaza
__________________
-Mewthree9000
We all fight a war within ourselves, a war of greatness, a war to become the best.
LIVE THE REVOLUTION, PHO!
Gotta Hack'em All!!




My current projects:
-Pokemon ChaosBlack[v2]
-!!Elite FireRed ROM Base!!

Last edited by mewthree9000; 12th November 2013 at 12:18 AM.
mewthree9000 is offline  
Likes Full Metal ★, Elsa, Jisuke, karatekid552 liked this post
Sponsored Links
Old 3rd November 2013, 06:02 PM   #2
karatekid552
What does this button do?.....
Ex-Staff
 
karatekid552's Avatar
 
Join Date: Feb 2013
Location: Stalker.......
Posts: 229
karatekid552 karatekid552
Default

Just to add to this, if you need to run a script from the bag, go here:

http://www.pokecommunity.com/showthread.php?t=281573
karatekid552 is offline  
Likes mewthree9000 liked this post
Old 3rd November 2013, 07:34 PM   #3
Jisuke
私の陰茎は非常に大きい
Ex-StaffPHO VIP
 
Jisuke's Avatar
 
Join Date: Mar 2013
Location: Brooooo...
Age: 22
Posts: 193
Jisuke Jisuke
Default

This get's my THUMBs up
huehuehuehue
Jisuke is offline  
Likes mewthree9000, karatekid552 liked this post
Old 4th November 2013, 12:01 AM   #4
droomph
握りモンスター
Ex-StaffPHO VIP
 
droomph's Avatar
 
Join Date: Apr 2012
Location: maybe.
Age: 21
Posts: 418
droomph
Default

Code:
.thumb
.align 2
push {lr}
ldr r0, SCRIPT_ADDRESS
bl SCRIPT_ROUTINE / / subroutine that will run the scripts
pop {pc}

SCRIPT_ROUTINE:
ldr r1, SCRIPT_EXECUTOR
Bx r1

.align 2
SCRIPT_ADDRESS: .word 0x081624F5 / / Here is where you define your script offset.
SCRIPT_EXECUTOR: .word 0x08069AE5 / / This is the routine that executes the scripts. Offset +1
I don't quite understand why you would need to bl that.
__________________
droomph is offline  
Old 4th November 2013, 12:26 AM   #5
Full Metal ★
Unstable?
Ex-StaffPHO VIP
 
Full Metal ★'s Avatar
 
Join Date: Oct 2012
Posts: 312
Full Metal ★ Full Metal ★
Default

Quote:
Originally Posted by droomph View Post
Code:
.thumb
.align 2
push {lr}
ldr r0, SCRIPT_ADDRESS
bl SCRIPT_ROUTINE / / subroutine that will run the scripts
pop {pc}

SCRIPT_ROUTINE:
ldr r1, SCRIPT_EXECUTOR
Bx r1

.align 2
SCRIPT_ADDRESS: .word 0x081624F5 / / Here is where you define your script offset.
SCRIPT_EXECUTOR: .word 0x08069AE5 / / This is the routine that executes the scripts. Offset +1
I don't quite understand why you would need to bl that.
so that...he can return the execution frame to where it was?????? ( ??!!?? )
__________________

★ full metal.

#busy
Full Metal ★ is offline  
Likes mewthree9000 liked this post
Old 4th November 2013, 12:58 AM   #6
droomph
握りモンスター
Ex-StaffPHO VIP
 
droomph's Avatar
 
Join Date: Apr 2012
Location: maybe.
Age: 21
Posts: 418
droomph
Default

Quote:
Originally Posted by Full Metal ★ View Post
so that...he can return the execution frame to where it was?????? ( ??!!?? )
it's two lines though. why would you need to make a whole subroutine for that?

also your elitism kinda annoys me. Maybe I don't know everything.
__________________
droomph is offline  
Old 4th November 2013, 01:41 AM   #7
Full Metal ★
Unstable?
Ex-StaffPHO VIP
 
Full Metal ★'s Avatar
 
Join Date: Oct 2012
Posts: 312
Full Metal ★ Full Metal ★
Default

Quote:
Originally Posted by droomph View Post
it's two lines though. why would you need to make a whole subroutine for that?

also your elitism kinda annoys me. Maybe I don't know everything.
I'm sorry, I just kinda felt that was a basic concept that was explained in many tutorials / documents / etc. I thought you were actually smarter. uh. Elitist, rah rah. There are lots of things that annoy me about you, also ( o no frick frack the police are coming )

Anyways, I'll explain this for you.

Code:
push {lr} // store the link register so that you can return the execution frame.
ldr r0, SCRIPT_ADDRESS // the offset of your script your executing.
bl SCRIPT_ROUTINE / / subroutine that will run the scripts ( so you can return to THIS frame of execution -- there are lots of those )
pop {pc} // go back the frame of execution mentioned on line one.

Now this bit is recyclable, and I imagine it's not really necessary to have this ( you could replace the bl SCRIPT_ROUTINE with the part in bold ) but it's for convenience and as far as I can tell, that's the only real reason for using a branching structure. Maybe it can be worked out that it's a more efficient use of your ROM's available space, but I don't feel like looking at the numbers tbh.
( You'll notice the whole thing is bolded, btw )

Code:
SCRIPT_ROUTINE:
ldr r1, SCRIPT_EXECUTOR
Bx r1
I'm not an elitist you're just hypersensitive and fail to realize that I'm just a ickday with a head -- all puns intended
__________________

★ full metal.

#busy

Last edited by Full Metal ★; 4th November 2013 at 01:47 AM.
Full Metal ★ is offline  
Likes mewthree9000, karatekid552 liked this post
Old 6th November 2013, 09:34 PM   #8
mewthree9000
Junior Trainer
 
mewthree9000's Avatar
 
Join Date: May 2010
Location: U.S.A.
Age: 28
Posts: 70
mewthree9000 mewthree9000
Default

Amazing elaboration, Full Metal! :3
__________________
-Mewthree9000
We all fight a war within ourselves, a war of greatness, a war to become the best.
LIVE THE REVOLUTION, PHO!
Gotta Hack'em All!!




My current projects:
-Pokemon ChaosBlack[v2]
-!!Elite FireRed ROM Base!!
mewthree9000 is offline  
Old 7th November 2013, 04:32 AM   #9
Diegoisawesome
Oh god the bees
Ex-Staff
 
Diegoisawesome's Avatar
 
Join Date: Jul 2013
Location: :noitacoL
Age: 21
Posts: 60
Diegoisawesome
Default

Quote:
Originally Posted by Full Metal ★ View Post
Now this bit is recyclable, and I imagine it's not really necessary to have this ( you could replace the bl SCRIPT_ROUTINE with the part in bold ) but it's for convenience and as far as I can tell, that's the only real reason for using a branching structure.
Well, if you don't do a bl to the bx, then it won't return to your routine and pop what you pushed. However, you could just replace everything with the two LDRs and the BX (not even having the push or pop) and it should work fine.
Diegoisawesome is offline  
Old 7th November 2013, 02:02 PM   #10
Full Metal ★
Unstable?
Ex-StaffPHO VIP
 
Full Metal ★'s Avatar
 
Join Date: Oct 2012
Posts: 312
Full Metal ★ Full Metal ★
Default

Quote:
Originally Posted by diegoisawesome View Post
Well, if you don't do a bl to the bx, then it won't return to your routine and pop what you pushed. However, you could just replace everything with the two LDRs and the BX (not even having the push or pop) and it should work fine.
that's...what I was saying... ;_;
__________________

★ full metal.

#busy
Full Metal ★ is offline  
 

Tags
asm, mode, run, scripts, thumb, [Tutorial]

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 10:58 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc. User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo.
Pokémon Hackers Online (PHO) is in no way affiliated with or endorsed by Nintendo LLC, Creatures, GAMEFREAK inc,
The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast.
All forum/site content (unless noted otherwise) and site designs are © 2006-2013 Pokémon Hackers Online (PHO).
Green Charizard Christos TreeckoLv100

"Black 2" by ARTPOP. Kyurem artwork by XOUS.

no new posts