Jump to content

Recommended Posts

Posted

I know ARs are capable of setting one hex value to another hex value or a predefined constant (like the wild pokemon modifier and such), but can they set a hex value to the result of a formula?

For example, it would calculate the result of ((A+B/2)+7)*C (where A, B and C are in-game hex values), and set hex value D equal to that number.

I have not seen any AR codes that do this (or at least they aren't obvious about it) so I have no idea whether it is even possible..... :confused:

Any help would be appreciated. Thank you!

Posted

you would need to do it in assembly and write it into the ram using the ar. you would also need to find a place to hook the routine and make sure you don;t wreck any registers.

e: something like...

push {r0, r1}

ldr r0, [a]

ldr r1,

add r0, r0, r1

lsr r0, #0x1

add r0, r0, #0x7

ldr r1, [c]

mul r0, r0, r1

str r0, [d]

pop {r0, r1}

bx lr

that's really simplistic, though, and doesn't account for the work of finding an open area that won;t be written over, finding a hook spot, etc.

Posted
you would need to do it in assembly and write it into the ram using the ar. you would also need to find a place to hook the routine and make sure you don;t wreck any registers.

e: something like...

push {r0, r1}

ldr r0, [a]

ldr r1,

add r0, r0, r1

lsr r0, #0x1

add r0, r0, #0x7

ldr r1, [c]

mul r0, r0, r1

str r0, [d]

pop {r0, r1}

bx lr

that's really simplistic, though, and doesn't account for the work of finding an open area that won;t be written over, finding a hook spot, etc.

This is a bit more complicating than I thought, but I think I see what you're saying:

- Have the bulk of the code be made in assembler (execpt for the first and last lines) and compile based on absolute addresses, and program in the absolute addresses for the variables, the hex to be overwritten, and where the function goes based on the hex values in-game.

- Have said code compute the formula, and overwrite a hex value with the results.

- Use somewhere that won't mess anything up or be overwritten to store the function and hook spot.

I can get all the help I need with the assembler part, but I still have a couple questions:

Can you give me any help or direct me to a resource to help with finding the right open area and hook spot?

With regards to natures of pokemon, how specifically are natures factored in the calculation of a stat?

Ie: Are there mulitpliers stored for each stat that get changed based on the nature, are there values which coorespond to which stat gets the + and - that natures like modest and quiet would share one of as they boost the same stat, are stats calculated from the natures with if statements, etc?

Where would be a good place to get the hex values for whatever natures use to change stats (if they are not done with if statements), the lvl of a pokemon, ivs, evs, ect? (for the 1st pokemon in the party)Could I use pokegen to get the correct values?

Thanks!

Posted

well, the first thing you need to decide on is how often your code needs to run. if it's a constant write, you'll need to hook an irq handler or something. if it's once, then you can maybe hook the pass from the arm9 bootup code to the main loop and then pass off to the main loop. i dunno, something that runs once. you probably want to read this:

http://crackerscrap.com/ddoc.php?p=dshooking.html&n=1

you can probably use something like asm to ards to translate your code to hex for running on the ar.

i'm really not sure how the nature/stat thing works aside from that it's multiplied and saved somewhere as the stat is needed for whatever it's used in.

also, a lot of the area before the arm9 binary is never used. roughly 2000100->2003FFC is unused, i think. you could use some of that.

Posted (edited)

It is clear I should include some specifics, so here they are:

-The goal of the code is to manually set the stats (like in pokegen) of the first pokemon in the party to specific values, based on formulas similar- but not identical- to the current stat formulas, but using my own base stat. (but, unlike pokegen, I could have change things about the pokemon and it would still work, and work on different variations of the simulated pokemon without requiring multiple codes)

-Like most AR codes, this code will run when a button is pressed (the whole 94000130 FFFB0000 thing or whatever) so it won't, say, overwrite the stats of a pokemon I don't want it to, yet allow it to be used on any pokemon that I put in the lead spot, and can fix the stats after a battle or level up recalculates them.

-in calculating the stats, it needs to know nature, level, ev, iv, my defined base stat, the normal stat, and any other values I use (such as a multiplier I will use in calculating attaks to acount for a non-exsistant power boost) (I should be able to get these via pokegen)

-I don't need the function to be saved in the memory (ie, the code will re-do it everytime), as it will just be multiple one-time uses, and I will probably use the same space multiple times to calculate all 6 stats.

For the nature, I just realized I could run a neutral nature calc on the stat, then based on whether that number is lower or higher that the actual stat, apply the appropriate multiplier in my formula.

IDK, I should be able to use the static hooking or something.

Let me know if there is anything else, and thanks for the help! :smile:

Edited by liaF cipE
Posted

what you might want to try, then, is this hack for the ar:

023FE074 012FFF11

that makes the ar execute data using the "E" code type, not patch it. so you could do..

94000130 FFFB0000(run on hitting select, can be changed to whatever)

023FE074 012FFF11

E0000000 0000XXXX(the Xs here are the number of bytes being run in total, 4 per word)

AAAAAAAA BBBBBBBB

CCCCCCCC DDDDDDDD

EEEEEEEE FFFFFFFF

GGGGGGGG E12FFF1E

you can make it as long as you want, that's just an example. that will execute the arm assembly(must be arm, not thumb) you put in the code every time you hit select. that way you can just run it from the ar and you won't need to worry about finding free memory, etc.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...