Announcement

Collapse
No announcement yet.

help with this code? thank you :) dark dawn exp multiplier

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

  • help with this code? thank you :) dark dawn exp multiplier

    hi, i am trying to change a exp multiplier code for golden sun dark dawn.
    the (U) code(s) are here:
    Code:
    2x
    5212194C E0820000
    1212194C 00000080
    D0000000 00000000
    
    4x
    5212194C E0820000
    1212194C 00000100
    D0000000 00000000
    
    8x
    5212194C E0820000
    1212194C 00000180
    D0000000 00000000
    
    16x
    5212194C E0820000
    1212194C 00000200
    D0000000 00000000
    over at this forum (gbatemp.net/threads/reverse-engineering-golden-sun-dark-dawn-exp-multiplyer-code.272880) someone changed the code to 0.5x experience, since the game is easy, to make it harder.

    the (E) version of the game has a exp multiplier code as well:
    Code:
    x2
    52121a08 e0820000
    02121a08 e0820080
    d2000000 00000000
    comparing this to this (U) code (also above), how are they different, yet give the same output?

    Code:
    2x
    5212194C E0820000
    1212194C 00000080
    D0000000 00000000
    (this is what i think about the codes, from the what i could read about on the internet)
    the first line is the same, just a different memory address for the different region. correct?
    an if statement, the 5 at the start means it is 32 bit if, and to only do the following (until D0 or D2) if the memory at 212194C is equal to E0820000?

    the second line for (E) is doing a 16 bit write, but for (U) there is a 32 bit write? are these interchangeable for this code?

    with the third line, the difference between D0 and D2 is that D2 clears all the temporary data.


    BUT.

    someone explains what the code does on this post:
    gbatemp.net/threads/reverse-engineering-golden-sun-dark-dawn-exp-multiplyer-code.272880/#post-3370026


    This isn't as straightforward as it looks because the code is changing instructions, it's looking for a code E0820000 which is
    add r0, r2, r0 (r0 = r2 + r0)

    and editing only the low bits, for example the x4 code is changed into E0820100
    which is
    add r0, r2, r0, lsl 2 (this shifts r0 left twice for x4 before adding)

    what you want is the opposite, to do a right shift.
    add r0, r2, r0, lsr 1
    which is E08200A0 (you can use an assembler, maybe more information is in the rom hacking thread)

    Since your code is only changing the last part of the instruction, the updated code should be

    0.5x
    5212194C E0820000
    1212194C 000000A0
    D0000000 00000000
    so, does this mean the first line is not an IF? it is an asm instruction?


    i want to understand these more
    because, i want to modify it to make a 0.75x code.
    i understand that this cannot be done(?) like the other multiple of 2 codes?
    so i would need to make a 0.25x code, use the 0.5x code together.
    so, where the guy who made the 0.5x code, where he shifts it to the right once, i want to store that value.
    then, i want to right shift that stored value again, and add it to itself.
    like,
    data = shiftright(originalvalue)
    data += shiftright(data)
    originalvalue = data

    D5000000 XXXXXXXX makes the data register what XXXXXXXX is.

    D4000000 XXXXXXXX adds XXXXXXXX to the data register.


    i need some help, i am not trying to be a 'leech' and just ask for the code i really want to understand what is happening
    i use c++ and java a lot, yet never had to use any asm etc.

    in summary, i want to know how the U and E codes has a different 2nd line, and i want to understand the first line of the code

    thanks for the help, i really appreciate it

  • #2
    First things first:
    Code:
    ::US
    5212194C E0820000 ;@if the 32-bit value at [COLOR=#008000]0x0212194C[/COLOR] equals [COLOR=#008000]0xE0820000[/COLOR] ([COLOR=#0000ff]add r0,r2,r0[/COLOR])
    1212194C 00000080 ;@this will write a 16-bit value of [COLOR=#008000]0x0080[/COLOR] to [COLOR=#008000]0x0212194C[/COLOR]; the value at [COLOR=#008000]0x0212194E[/COLOR] ([COLOR=#008000]0xE082[/COLOR]) will remain untouched
    D0000000 00000000 ;@this is an end if; I went into depth about the use of D0 and D2 in [URL="http://gamehacking.org/vb/threads/8004-47iscool-s-NDS-Codes?p=67988#post67988"]this[/URL] thread
    
    ::EU
    52121A08 E0820000 ;@if the 32-bit value at [COLOR=#008000]0x02121A08[/COLOR] equals [COLOR=#008000]0xE0820000[/COLOR] ([COLOR=#0000ff]add r0,r2,r0[/COLOR])
    02121A08 E0820080 ;@this will write a 32-bit value of [COLOR=#008000]0xE0820080[/COLOR] to [COLOR=#008000]0x02121A08[/COLOR]
    D2000000 00000000 ;@refer to the other comment
    Both of these codes are doing the same thing in terms of producing the same output.

    Originally posted by sdljk33 View Post
    so, does this mean the first line is not an IF? it is an asm instruction?
    Well, it's an ASM code so yes, it's an ASM instruction being modified. The first line, however, is an IF statement (refer to my comments).

    Originally posted by sdljk33 View Post
    i want to understand these more
    because, i want to modify it to make a 0.75x code.
    i understand that this cannot be done(?) like the other multiple of 2 codes?
    so i would need to make a 0.25x code, use the 0.5x code together.
    so, where the guy who made the 0.5x code, where he shifts it to the right once, i want to store that value.
    then, i want to right shift that stored value again, and add it to itself.
    like,
    data = shiftright(originalvalue)
    data += shiftright(data)
    originalvalue = data

    D5000000 XXXXXXXX makes the data register what XXXXXXXX is.

    D4000000 XXXXXXXX adds XXXXXXXX to the data register.
    Why use those code types when you can do it all in ASM? It sounds like you're trying to do something like this:
    Code:
    add     r0,r2,r0,lsr #0x1          ;@r0 = (r2 + r0) / 2
    mov     r2,r0,lsr #0x1             ;@r2 = r0 / 2
    add     r0,r0,r2                   ;@r0 += r2
    str     r0,[rD]                    ;@rD = r0's value (rD = destination register)
    bx      lr                         ;@return
    If you need that much space, it's best that you branch to your own subroutine.

    Update:
    I made a thumb version for Pokemon Platinum and it seems to work fine. Normally, you'd get 24 EXP when fighting a level 3 Bidoof, but with my modified code you get 18 EXP (24 * 0.75).
    I only bother with things that interest me.

    Comment


    • #3
      first of all i would like to thank you so much for taking your time to help me.
      i'm also the person you replied to on that pokemon forum when you posted the walk while talking code for emerald, so, i'm very happy with seeing your username haha.

      so, how in the first line can doing an if equal to function also do those asm functions?
      Code:
      ::US
      5212194C E0820000 ;@if the 32-bit value at 0x0212194C equals 0xE0820000 (add r0,r2,r0)
      .....
      so the first line looks at the game and sees if at 0x0212194C, there is code to 'add r0,r2,r0'.
      that bit was really confusing me, i thought somehow we were checking if 'this' is equal to 'that', and at the same time do '(add r0,r2,r0)'.
      i was very confused... but i understand now

      well, when you ask why would i use 'those' codes when making the 0.75x code i want, well, sure i guess there are better/more compact ways of doing it, and for my first ds code i was not expecting to use asm, but, of course i would 'want' to, just, it would be more difficult for me.

      and when you say if i need that much space that i should use a subroutine, you mean using too many lines of code is not good for something simple like this? how many would it take without a subroutine do you think? and how many with?

      and by subroutine you mean this?
      Code:
      add     r0,r2,r0,lsr #0x1          ;@r0 = (r2 + r0) / 2
      mov     r2,r0,lsr #0x1             ;@r2 = r0 / 2
      add     r0,r0,r2                   ;@r0 += r2
      str     r0,[rD]                    ;@rD = r0's value (rD = destination register)
      bx      lr                         ;@return
      sure, i understand that, thank you, although what is this? - #0x1 ?

      ok, so, what do i do with this asm code then? how to i 'convert'/(compile it since it is asm right...?) it to an ar code?

      thank you so much, you helped a lot with my understanding, sorry if i gave you too many questions.


      -edit. also, how can i find out that E0820000 means 'add r0,r2,r0'? is this ds specific? certain type of asm specific? surely there are many many combinations of operators etc, people don't really remember what E0820000 does right? thanks again
      Last edited by sdljk33; 07-16-2013, 11:46:29 AM.

      Comment


      • #4
        Originally posted by sdljk33 View Post
        first of all i would like to thank you so much for taking your time to help me.
        i'm also the person you replied to on that pokemon forum when you posted the walk while talking code for emerald, so, i'm very happy with seeing your username haha.
        You're welcome.

        Originally posted by sdljk33 View Post
        so, how in the first line can doing an if equal to function also do those asm functions?
        Code:
        ::US
        5212194C E0820000 ;@if the 32-bit value at 0x0212194C equals 0xE0820000 (add r0,r2,r0)
        .....
        The value for the ASM Instruction "add r0,r2,r0" is 0xE0820000.

        Originally posted by sdljk33 View Post
        well, when you ask why would i use 'those' codes when making the 0.75x code i want, well, sure i guess there are better/more compact ways of doing it, and for my first ds code i was not expecting to use asm, but, of course i would 'want' to, just, it would be more difficult for me.
        When writing ASM Codes, try to stay away from non-conditional code types (unless you really need them) and let the ASM do the majority of the work.

        Originally posted by sdljk33 View Post
        and when you say if i need that much space that i should use a subroutine, you mean using too many lines of code is not good for something simple like this? how many would it take without a subroutine do you think? and how many with?
        You might end up overwriting significant data that's used for that routine or another. To avoid this, jump to your own subroutine (you're familiar with C++ and Java so you're well aware of functions) and return. I won't even bother guessing the amount of lines it would be without a subroutine since I frown upon it, but with a subroutine...maybe 8 lines of code.

        Originally posted by sdljk33 View Post
        and by subroutine you mean this?
        Code:
        add     r0,r2,r0,lsr #0x1          ;@r0 = (r2 + r0) / 2
        mov     r2,r0,lsr #0x1             ;@r2 = r0 / 2
        add     r0,r0,r2                   ;@r0 += r2
        str     r0,[rD]                    ;@rD = r0's value (rD = destination register)
        bx      lr                         ;@return
        That's the code that I came up with, but feel free to use it. Jump to your own subroutine and start implementing that code.

        Originally posted by sdljk33 View Post
        sure, i understand that, thank you, although what is this? - #0x1 ?
        You shift on the power of 2.
        Code:
        2^1 = 2
        2^2 = 4
        2^3 = 8
        etc.
        Originally posted by sdljk33 View Post
        ok, so, what do i do with this asm code then? how to i 'convert'/(compile it since it is asm right...?) it to an ar code?
        You're going to need a debugger and/or ASMtoARDS.

        Originally posted by sdljk33 View Post
        -edit. also, how can i find out that E0820000 means 'add r0,r2,r0'? is this ds specific? certain type of asm specific? surely there are many many combinations of operators etc, people don't really remember what E0820000 does right? thanks again
        Yeah, no one actually remembers that stuff unless it's common like a NOP (ARM: 0xE1A00000, Thumb: 0x46C0).

        Edit: I have a solution, but I don't have the game. If you want me to post it for you to test, let me know.
        I only bother with things that interest me.

        Comment


        • #5
          ok, again, thanks.
          so, i am guessing for the subroutine i need to find free space in the ram?
          for this do i use DSATM? what other ways are there? you say to use a debugger, is this to look at the ram and see is there are gaps?
          in what ways would a debugger help me?
          would a debugger, or asm to ards show me that E0820000 means 'add r0,r2,r0'?

          you say to stay away from non conditional code types when using asm codes.
          the only conditional bit in what we are doing with this code is the first line, not even in the asm, it just checks 'if the 32-bit value at 0x0212194C equals 0xE0820000 (add r0,r2,r0)' i assume because, maybe before the game starts something else may be in that memory position and we don't want to mess anything up? is this right?
          if so, should we always check to see if something is at the assumed value before changing it?

          well, ha i know how to make a function in c++ and java etc... but this is different!
          so,
          To avoid this, jump to your own subroutine (you're familiar with C++ and Java so you're well aware of functions) and return.
          return at the end, well the last line of the asm code you posted has a return, is that it?
          hmm... jump to my own subroutine, is this what i want?:

          NDS AR HACK #4 : Execute custom asm routine :
          ---------------------------------------------

          This code changes the E code type to make it execute the data you entered.

          023FE074 012FFF11

          And to 'revert' to the normal effect of the E code type, use this one :

          023FE074 E3520003

          exemple :
          023FE074 012FFF11
          EXXXXXXX 00000010
          AAAAAAAA BBBBBBBB
          CCCCCCCC E12FFF1E

          When the E code type will be encountered, the code handler will jump to and
          execute (ie. bx to) the AAAAAAAA, BBBBBBBB, CCCCCCCC and E12FFF1E instructions (means the instructions must be in ARM, and not THUMB).

          All the custom routines you make must end with E12FFF1E (bx r14).

          Also, you must not touch the following registers (or you must push/pop them),
          unless you know exactly what you are doing :

          r4 (holds the number of bytes of data you entered in the E code type)
          r5 ((holds the position of the data of the E code type from the start of the
          code list) >> 2)
          r7 (holds the 'execution status' data)
          r9 (holds the starting address of the AR codes list)
          r10 (holds the offset)
          r11 (holds the total number of codes enabled in the AR)
          r13 (SP)
          r14 (LR)

          On a side note, here is what the other register hold :

          r0 holds the address of the E code type plus the offset (0XXXXXXX + offset)
          r1 holds the starting address of the E code type data (what I used for the bx)
          r2 holds a copy of the data of the E code type (00000010 in the exemple)
          r3 is the same than r0
          r6 holds what the next 'execution status' data would look when set to true
          r8 holds what the next 'execution status' data would look when set to false
          r12 holds the 'full' data of the E code type (EXXXXXXXX)


          and finally, i downloaded asm to ards, i can't find any guide or readme, but i will have a go with it. i'll try to run it using wine, but i will have access to a windows computer in a few days to test it then.
          so, i give it the asm code, and this program will convert it to an ar code, ok.
          do i give it that asm code as it is? in this exp code, the only thing specific to this game are the registers that are being manipulated, correct?

          thanks again, i wish i had a way to pay you back! maybe an invite to a tracker?

          -edit. sure if you don't mind posting the code i would like to test it out thanks!
          Last edited by sdljk33; 07-16-2013, 01:36:08 PM.

          Comment


          • #6
            Test this code out:
            Code:
            ::x0.75
            E2000000 00000010
            E08200A0 E1A020A0
            E0800002 E12FFF1E
            5212194C E0820000
            0212194C EBFB79AB
            D2000000 00000000
            I'm basically blind coding since I don't have the game.

            Originally posted by sdljk33 View Post
            so, i am guessing for the subroutine i need to find free space in the ram?
            Indeed.

            Originally posted by sdljk33 View Post
            in what ways would a debugger help me?
            would a debugger, or asm to ards show me that E0820000 means 'add r0,r2,r0'?
            Yes.

            Originally posted by sdljk33 View Post
            you say to stay away from non conditional code types when using asm codes.
            the only conditional bit in what we are doing with this code is the first line, not even in the asm, it just checks 'if the 32-bit value at 0x0212194C equals 0xE0820000 (add r0,r2,r0)' i assume because, maybe before the game starts something else may be in that memory position and we don't want to mess anything up? is this right?
            if so, should we always check to see if something is at the assumed value before changing it?
            Correct! Also, applying code types like D4 & D5 to ASM codes is inefficient.

            Originally posted by sdljk33 View Post
            well, ha i know how to make a function in c++ and java etc... but this is different!
            so,
            return at the end, well the last line of the asm code you posted has a return, is that it?
            hmm... jump to my own subroutine, is this what i want?:
            Well, one similarity would be to create the function and then call it when needed. You return with "bx lr/bx r14" if you jump to the subroutine with "bl"; if you jump there with 'b', return with 'b'.

            Originally posted by sdljk33 View Post
            and finally, i downloaded asm to ards, i can't find any guide or readme, but i will have a go with it. i'll try to run it using wine, but i will have access to a windows computer in a few days to test it then.
            so, i give it the asm code, and this program will convert it to an ar code, ok.
            do i give it that asm code as it is? in this exp code, the only thing specific to this game are the registers that are being manipulated, correct?
            Spoiler Alert! Click to view...



            Minor change:
            * Change C2000000 to E2000000 because the address where our subroutine is located at is 0x02000000 and 'E' is the code type that we need to use.

            Spoiler Alert! Click to view...



            Minor change:
            * Change "EA" to "EB". 0xEAFB79AB performs a 'b'ranch to 0x02000000; 0xEBFB79AB performs a "bl" (branch with link) to 0x02000000.

            Originally posted by sdljk33 View Post
            thanks again, i wish i had a way to pay you back! maybe an invite to a tracker?
            No need to pay me back; we do things for free here. However, if you want to send a small donation to me or the site, send me a PM.
            I only bother with things that interest me.

            Comment


            • #7
              i will write a longer reply later, sorry, i'll be busy for a few days from now, i tested the code out quickly! it works!
              when you have a single enemy, it works great. when you have multiple enemies... it doesn't seem to work as it should.
              using the x0.5 code, i would get half (with multiple enemies) yet, with the x0.75, for this battle i had, i should have received 3861 if i was at x1, but with the code i recieved 4453.... very weird... but i have not played the game before, so, maybe it does something in game that alters the total you receive. i will need to look into it more

              but thank you so much for this! i don't really have any money to donate at the moment, but the help i have recieved here, from you, has been amazing, so when i can, i will keep it in mind

              Comment


              • #8
                Originally posted by sdljk33 View Post
                i will write a longer reply later, sorry, i'll be busy for a few days from now, i tested the code out quickly! it works!
                when you have a single enemy, it works great. when you have multiple enemies... it doesn't seem to work as it should.
                using the x0.5 code, i would get half (with multiple enemies) yet, with the x0.75, for this battle i had, i should have received 3861 if i was at x1, but with the code i recieved 4453.... very weird... but i have not played the game before, so, maybe it does something in game that alters the total you receive. i will need to look into it more

                but thank you so much for this! i don't really have any money to donate at the moment, but the help i have received here, from you, has been amazing, so when i can, i will keep it in mind
                This is reminiscent of my unfinished FF7 EXP Multiplier, in that game each of the same enemy has one address and any other different had a different ram address so the ASM code would need some more tweaking to cover these other enemies.

                Best bet would be to have a ram view looking at the addresses of enemy EXP or but a break on the EXP address and see whats writing to it when different enemies are defeated and determine what ASM instructions are writing to the address and make your custom routine to cover all addresses.

                Maybe we should start a thread with many different code hacking methods that we know and use including ASM codes, like we had in the cheats.gbatemp forum of yesterday so it can useful for any new hackers starting out.

                Taking requests of how to make certain code is welcome and encouraged and since learning all of this ASM in the hay day we have new tools (like your tool) to simplify making the more advanced codes a breeze so anyone with half a brain could learn to hack some advanced codes.
                Spoiler Alert! Click to view...

                THE BAD GUY!!!!!!

                Comment

                Working...
                X