Announcement

Collapse
No announcement yet.

[NDS] Execute an AR Code only once?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [NDS] Execute an AR Code only once?

    Hey, is there a way to make an AR Code for the Nintendo DS that is only executed once? I'm asking this because I'm making a code for Phantom Hourglass which would require me to increment a specific value by 1. I managed to pull that off already but the code is executed in a loop of course which makes my value go up the entire time the code is activated. Would it be possible to change some kind of execution state so that the code is only executed once?
    Last edited by MichiS97; 07-23-2015, 06:45:36 AM.

  • #2
    Type 0xD8
    8-Bit Incrementive Write
    D8000000 XXXXXXXX Writes the 'Dx data' byte to [XXXXXXXX+offset], and increments the offset by 1.

    Source
    The Hackmaster

    Comment


    • #3
      Uhm yeah...that's the code I've been using to increment my value. But I've already got that working, my question is how I can keep the code from looping.
      An educated guess I've just come up with is to put a button activator at the last line of the code and give it a pretty much impossible button combo, like pressing every button there is
      Last edited by MichiS97; 07-23-2015, 07:52:52 AM.

      Comment


      • #4
        You have to make a deactivator code.

        AR DS Code Basics Guide by Crazasta
        The Hackmaster

        Comment


        • #5
          That increments the offset value, not the data value, right? And unless you took control of setting the offset, all it would do is keep writing whatever is in Dx to the next address on subsequent passes.

          Is there a section of memory that isn't used by the games, that is accessible to the AR, and is initialized on start up? That's the easiest way to handle something like this. Check an address there for not-equal <value> and then at the tail end of your code, set the address to that value.

          Edit: Button activators may or may not work. The code engine usually executes several times in the duration of one button press, so checking that usually isn't sufficient to limit a code to one write.
          Last edited by Pyriel; 07-23-2015, 08:19:26 AM.

          Comment


          • #6
            Originally posted by dlevere View Post
            You have to make a deactivator code.

            AR DS Code Basics Guide by Crazasta
            I can't because I don't have any initial value I could assign when the deactivator is pressed

            Comment


            • #7
              Post the code so we can look at it.
              I only bother with things that interest me.

              Comment


              • #8
                Originally posted by Pyriel View Post
                Is there a section of memory that isn't used by the games, that is accessible to the AR, and is initialized on start up? That's the easiest way to handle something like this. Check an address there for not-equal <value> and then at the tail end of your code, set the address to that value.
                I tried to do that but the problem is that I don't know how to compare to offsets. Of course, there are code types which would let me check if the value of a given offset is bigger/smaller/equal/not equal to a value that is also given by me but AFAIK you can't just compare two offsets with another

                Here's the code:
                221BA598 00000002 //this gives my player a potion (that already works but the potion isn't usable since the icon for it is greyed out)
                94000130 FCFF0000 // simple button activator
                DB000000 021BA605 //loads the value at offset 0x021BA605, which determines which icons for the potions are greyed out
                D4000000 00000001 //increments the value by 1
                D8000000 021BA605 // stores the value back at its address

                Okay, so the code works flawlessly, if it wouldn't be for the fact that the value at 0x021BA605 mustn't be incremented more than once.
                Last edited by MichiS97; 07-23-2015, 09:42:18 AM.

                Comment


                • #9
                  Try something like this:
                  Code:
                  ::Your Code
                  221BA598 00000002
                  [COLOR=#008000]74000100 FF00000C[/COLOR]
                  94000130 FCFF0000
                  DB000000 021BA605
                  D4000000 00000001
                  D8000000 021BA605
                  D2000000 00000000
                  That line highlighted in green slows down the execution time. If that's too fast or slow, try adjusting the value.

                  Note: This will not perfect the code. To ensure the code increments by exactly 1 each button press/hold, ASM is your best option.
                  I only bother with things that interest me.

                  Comment


                  • #10
                    Well, I'm just talking something like:

                    94000130 FCFF0000
                    6XXXXXXX 00000001
                    your code
                    0XXXXXXX 00000001

                    The only purpose for XXXXXXX is to ensure the code can be used just once. You could have another code tied to a different combination of buttons set the flag off. However, looking at what you're doing, it seems like the goal might be to run the increment only once each time the code is used (i.e. every time a new potion is added by it). That will probably require ASM.

                    Comment


                    • #11
                      Originally posted by Pyriel View Post
                      Well, I'm just talking something like:

                      94000130 FCFF0000
                      6XXXXXXX 00000001
                      your code
                      0XXXXXXX 00000001

                      The only purpose for XXXXXXX is to ensure the code can be used just once. You could have another code tied to a different combination of buttons set the flag off. However, looking at what you're doing, it seems like the goal might be to run the increment only once each time the code is used (i.e. every time a new potion is added by it). That will probably require ASM.
                      Yeah I was thinking to complicatedly Thanks for your advice! I've got one last question though: Can you give me the link to a good tutorial about ASM hacking on the DS? I did some basic NES stuff in the past but nothing apart from that and I'd really like to look into it

                      Comment


                      • #12
                        static.patater.com/gbaguy/gbaasm.htm
                        Kenobi's GameBoy Advanced ASM Tutorial

                        www.coranac.com/tonc/text/asm.htm
                        Whirlwind Tour of ARM Assembly

                        http://www.codemasters-project.net/p...hp?content.202
                        Cursor Hacking and Advanced Tracing
                        The Hackmaster

                        Comment


                        • #13
                          Okay...now I've got a very strange problem. The code I made works flawlessly on my PC using the Desmume emulator, however, it doesn't work on my DS at all. I use a DSTWO flashcard for the game and the very same code and save file from the emulator. I really don't know what's going on here, I never had this happening before. Are there code types that are not supported by the cheat engine the DS flashcards use?
                          Last edited by MichiS97; 07-24-2015, 05:07:05 AM.

                          Comment


                          • #14
                            Are you properly terminating the code with the D2000000 00000000 line? also what game is it?
                            Spoiler Alert! Click to view...

                            THE BAD GUY!!!!!!

                            Comment


                            • #15
                              Originally posted by Helder View Post
                              Are you properly terminating the code with the D2000000 00000000 line? also what game is it?
                              Yes I am, it's Legend of Zelda Phantom Hourglass

                              Code:
                              221BA598 00000002
                              94000130 FCFE0000
                              A2FFFFFE 00000001
                              DB000000 021BA605
                              D4000000 00000002
                              D8000000 021BA605
                              12FFFFFE 00000001
                              D2000000 00000000
                              I made some changes to the code, here's the updated one
                              Last edited by MichiS97; 07-25-2015, 09:58:44 AM.

                              Comment

                              Working...
                              X