The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
Research & Development programs in this forum are subject to moderator approval before they are displayed.


Advertise here

Reply
 
Thread Tools
  #1    
Old October 9th, 2012, 11:55 AM
Spherical Ice's Avatar
Spherical Ice
Community Supporter
 
Join Date: Nov 2007
Location: UK
Send a message via Skype™ to Spherical Ice

Advertise here

Running Background Scripts


The following is referring to FireRed, BPRE.

Let me preface this with the fact that I know almost nothing about the game engine, how scripts are executed, and only understand the bare basics of ASM. I wonder, however, how possible it would be to execute scripts; level scripts, in particular; that run in the background without locking events such as the player.

The main purpose for this includes JPAN's engine's button checking specials running in the background which would activate a chain of events whenever you push a specific button/combination of buttons.

One theoretical problem I have thought of is lag: having a script constantly running in the background would surely cause lag, but would it be crippling? If so, are there other more direct ways of having an event occur from a button press in certain situations?

Hopefully this "brief" is enough to get some minds turning. I think this would open up loads of possibilities for minigamems, different types of gameplay, etc. I look forward to your ideas!
__________________

Last edited by Spherical Ice; October 9th, 2012 at 12:08 PM.
Reply With Quote
  #2    
Old October 19th, 2012, 03:16 AM
tajaros's Avatar
tajaros
Hi I'm dawg
 
Join Date: Apr 2012
Location: Philippines
Age: 15
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to tajaros
Hmm...

This is Interesting could be useful for some hacks...

Maybe we can learn how to do this if we knew how the Movement Types in A-map work and how they execute. It may also be called using callasm that will call the ASM Routine that would let us do that. Maybe some People like (Jambo51, Darthathron, shiny quagsire, etc.)
__________________
Reply With Quote
  #3    
Old October 19th, 2012, 08:20 AM
Spherical Ice's Avatar
Spherical Ice
Community Supporter
 
Join Date: Nov 2007
Location: UK
Send a message via Skype™ to Spherical Ice
Well, I think special 0xcb in JPAN's Hacked Engine allows you to set scripts upon button pressing but its really glitchy and I cant get it to work.
__________________
Reply With Quote
  #4    
Old October 19th, 2012, 08:53 AM
itman
Back to ROM hacking. :D
 
Join Date: May 2007
Age: 20
Nature: Adamant
Quote:
Originally Posted by Spherical Ice View Post
Well, I think special 0xcb in JPAN's Hacked Engine allows you to set scripts upon button pressing but its really glitchy and I cant get it to work.
You're supposed to make the script loop. Since you need to press the button at the "exact" second of execution (just the way the script was made). In his guide he shows how to make it loop so it'll get the button press. I've gotten it to work.


Speaking of the topic,
JPAN started this with his hack Engine, with having scripts activate everytime you take a step.
As he states in his guide, unfortunately, this CANNOT be used to make a follow me script, since it takes priority and has "lock" commands upon activating. Since script tiles naturally have a "lock" effect and that's what this feature was based on.

Jambo51 has made a successful follow me script (well, he says it's not completed, but it's the farthest anybody has gotten). Which means he understands running background scripts (from what I can see).
http://www.youtube.com/watch?v=y2hUo...4&feature=plcp
Reply With Quote
  #5    
Old October 19th, 2012, 10:01 AM
Spherical Ice's Avatar
Spherical Ice
Community Supporter
 
Join Date: Nov 2007
Location: UK
Send a message via Skype™ to Spherical Ice
No, you're thinking of a different special.
__________________
Reply With Quote
  #6    
Old October 19th, 2012, 11:37 AM
itman
Back to ROM hacking. :D
 
Join Date: May 2007
Age: 20
Nature: Adamant
Quote:
Originally Posted by Spherical Ice View Post
No, you're thinking of a different special.
I know which one you're referring to. I got it to work by making it loop. The guide that comes with it doesn't give a full example of how to use that special.
Reply With Quote
  #7    
Old October 19th, 2012, 12:26 PM
Spherical Ice's Avatar
Spherical Ice
Community Supporter
 
Join Date: Nov 2007
Location: UK
Send a message via Skype™ to Spherical Ice
Well, wouldnt that defeat the purpose of that special? If it locks the player in place, its not really worth it haha.
__________________
Reply With Quote
  #8    
Old October 19th, 2012, 08:32 PM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter Tier 2
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 22
Gender: Male
Nature: Modest
I know where the check for the L/R button press is. It'd be easy to call a script based on that. Either way, it's easy to check the buttons every frame anyway. Really easy. Calling scripts is also really easy.
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #9    
Old October 19th, 2012, 08:39 PM
tajaros's Avatar
tajaros
Hi I'm dawg
 
Join Date: Apr 2012
Location: Philippines
Age: 15
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to tajaros
Quote:
Originally Posted by Darthatron View Post
I know where the check for the L/R button press is. It'd be easy to call a script based on that. Either way, it's easy to check the buttons every frame anyway. Really easy. Calling scripts is also really easy.
Woah, you already know how to do this? Can you please share it to us? Please...
__________________
Reply With Quote
  #10    
Old October 19th, 2012, 09:54 PM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter Tier 2
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 22
Gender: Male
Nature: Modest
Quote:
Originally Posted by tajaros View Post
Woah, you already know how to do this? Can you please share it to us? Please...
Sure thang.

Keypresses are handled as so:
Spoiler:
03003118 in the RAM contains a halfword value if buttons are being held.
0300311A in the RAM contains a halfword value if buttons are being pressed this frame.
0300311C and 0300311E are then clones of this.
0300311E is the one used by the game mostly.
Code:
  Bit   Button
  0     A                (0 = Released, 1 = Pressed)
  1     B
  2     Select
  3     Start
  4     Right
  5     Left
  6     Up
  7     Down
  8     R
  9     L
  10-15 Not used
So, say you want to check if the button Start is being pressed this frame:
Code:
<enter code here>
ldr r2, .KeyStates
ldrh r0, [r2, #2]
mov r1, #3
and r0, r1
cmp r0, #0
bne StartIsPressed
<enter code here>

.align 2
.KeyStates:
	.word 0x03003118


Calling scripts from ASM is also fairly simple:
You can run any script by calling 0x08069B48 with the script offset in the r0 register. This is how the game calls most scripts, such as level scripts and the flag setting script when you start a new game.

I hope this helps.

All offsets are for FireRed US (1.0) and may not work with other games or versions. Also, no code was tested. I just wrote it with the post.
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #11    
Old October 19th, 2012, 11:02 PM
tajaros's Avatar
tajaros
Hi I'm dawg
 
Join Date: Apr 2012
Location: Philippines
Age: 15
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to tajaros
Quote:
Originally Posted by Darthatron View Post
Sure thang.

Keypresses are handled as so:
Spoiler:
03003118 in the RAM contains a halfword value if buttons are being held.
0300311A in the RAM contains a halfword value if buttons are being pressed this frame.
0300311C and 0300311E are then clones of this.
0300311E is the one used by the game mostly.
Code:
  Bit   Button
  0     A                (0 = Released, 1 = Pressed)
  1     B
  2     Select
  3     Start
  4     Right
  5     Left
  6     Up
  7     Down
  8     R
  9     L
  10-15 Not used
So, say you want to check if the button Start is being pressed this frame:
Code:
<enter code here>
ldr r2, .KeyStates
ldrh r0, [r2, #2]
mov r1, #3
and r0, r1
cmp r0, #0
bne StartIsPressed
<enter code here>

.align 2
.KeyStates:
	.word 0x03003118


Calling scripts from ASM is also fairly simple:
You can run any script by calling 0x08069B48 with the script offset in the r0 register. This is how the game calls most scripts, such as level scripts and the flag setting script when you start a new game.

I hope this helps.

All offsets are for FireRed US (1.0) and may not work with other games or versions. Also, no code was tested. I just wrote it with the post.
Cool, I'll be sure to try this out when I'm on my free time...
__________________
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 02:19 AM.


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.