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!

Reply
 
Thread Tools
  #1    
Old October 9th, 2012 (11:55 AM). Edited October 9th, 2012 by Spherical Ice.
Spherical Ice's Avatar
Spherical Ice Spherical Ice is offline
  • Moderator
  • Silver Tier
 
Join Date: Nov 2007
Location: Bristol, UK
Age: 19
Posts: 5,202

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!

__________________


A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.

Reply With Quote

Relevant Advertising!

  #2    
Old October 19th, 2012 (3:16 AM).
tajaros's Avatar
tajaros tajaros is offline
Hi I'm dawg
     
    Join Date: Apr 2012
    Location: Philippines
    Age: 18
    Gender: Male
    Nature: Timid
    Posts: 857

    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 (8:20 AM).
    Spherical Ice's Avatar
    Spherical Ice Spherical Ice is offline
    • Moderator
    • Silver Tier
     
    Join Date: Nov 2007
    Location: Bristol, UK
    Age: 19
    Posts: 5,202

    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.

    __________________


    A Pokemon that is discriminated!
    Support squirtle and make it everyone's favourite.

    Reply With Quote
      #4    
    Old October 19th, 2012 (8:53 AM).
    itman itman is offline
    Back to ROM hacking. :D
       
      Join Date: May 2007
      Age: 23
      Nature: Adamant
      Posts: 100

      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=y2hUoO2yxcA&list=UUrYOFkbLGlELKwwN3bfmAkw&index=24&feature=plcp

      Reply With Quote
        #5    
      Old October 19th, 2012 (10:01 AM).
      Spherical Ice's Avatar
      Spherical Ice Spherical Ice is offline
      • Moderator
      • Silver Tier
       
      Join Date: Nov 2007
      Location: Bristol, UK
      Age: 19
      Posts: 5,202

      No, you're thinking of a different special.

      __________________


      A Pokemon that is discriminated!
      Support squirtle and make it everyone's favourite.

      Reply With Quote
        #6    
      Old October 19th, 2012 (11:37 AM).
      itman itman is offline
      Back to ROM hacking. :D
         
        Join Date: May 2007
        Age: 23
        Nature: Adamant
        Posts: 100

        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 Spherical Ice is offline
        • Moderator
        • Silver Tier
         
        Join Date: Nov 2007
        Location: Bristol, UK
        Age: 19
        Posts: 5,202

        Well, wouldnt that defeat the purpose of that special? If it locks the player in place, its not really worth it haha.

        __________________


        A Pokemon that is discriminated!
        Support squirtle and make it everyone's favourite.

        Reply With Quote
          #8    
        Old October 19th, 2012 (8:32 PM).
        Darthatron's Avatar
        Darthatron Darthatron is offline
        巨大なトロール。
        • Silver Tier
         
        Join Date: Jan 2006
        Location: Melbourne, Australia
        Age: 25
        Gender: Male
        Nature: Modest
        Posts: 1,152

        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 (8:39 PM).
        tajaros's Avatar
        tajaros tajaros is offline
        Hi I'm dawg
           
          Join Date: Apr 2012
          Location: Philippines
          Age: 18
          Gender: Male
          Nature: Timid
          Posts: 857

          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 (9:54 PM).
          Darthatron's Avatar
          Darthatron Darthatron is offline
          巨大なトロール。
          • Silver Tier
           
          Join Date: Jan 2006
          Location: Melbourne, Australia
          Age: 25
          Gender: Male
          Nature: Modest
          Posts: 1,152

          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 tajaros is offline
          Hi I'm dawg
             
            Join Date: Apr 2012
            Location: Philippines
            Age: 18
            Gender: Male
            Nature: Timid
            Posts: 857

            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
            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

            Forum Jump


            All times are GMT -8. The time now is 8:03 PM.