Binary ROM HackingNeed a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.
1) I sense knowledge gaps in your questions. Did you actually read any ASM tutorials thoroughly? Try reading Jpan's thumb tutorial, he explains what each register is, in terms of functionality. Registers are just like 4 byte memory storage, which you can apply transformations to via ASM instructions such as sub, add, mul, mov ect. Some registers are special though, in the sense that you can't use all of these operations on them and they are expected to hold certain values. The program counter is an example of this. Normally you shouldn't use a register without pushing/popping it, save for the first 4 registers (r0-r3) in SAFE function calls. I say safe, because calling your own function from another existing function without proper preparation may mess up the yield of the function you're branching from.
2) When searching for things there's a kinda weird process which I use. First I check Knizz's IDA to see if he's discovered it already. If he hasn't, or if the address is DMA I would try to find where in the ROM the change occurs. Sometimes you get lucky and the DMA address has an easy algorithm to find the DMA address. Normally this isn't the case, and sometimes the game uses malloc. Then I backtrack and follow until I find where the change is done in RAM. Somethings are harder to find than others, but normally it's a similar process.
The Byte replacements you're talking about is normally just a hex version of instructions like this:
Code:
ldr rX, =(0xInsertion address +1)
bx rX
It's basically just like a jump in scripting. Though you'll notice, like jump, it doesn't store a return address, so we need to make our routine return manually by having a bx ect ourselves.
3) For Hackmew's tutorial, I would only read the first one. The second one doesn't really teach anything, and is too big of a technical jump for a beginner (not to mention his algorithm for shinies isn't very good). For starting off, I'd read Jpan's tutorial for a technical reference, then HackMew's first or ShinyQuagsire's tutorial are both similar. From there, you're rather screwed, because no one has a tutorial which would act as a good second step :D
Ahhm so all routines push 4 registers only? that always bother my mind, I dont know what to push and what will I use, anyways, I downloaded knizz's IDA but I dont know how to use it... Thanks anyway
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Ahhm so all routines push 4 registers only? that always bother my mind, I dont know what to push and what will I use, anyways, I downloaded knizz's IDA but I dont know how to use it... Thanks anyway
No, the first 4 are defined as Parameters in functions, thus don't need to be pushed for function calls. You should generally be pushing every register you want to preserve though. Knowing the technicalities will allow you to save some operation time and space by omitting excessive operations such as pushing needlessly.
To use Knizz's IDA, you need a program called IDA pro. Version 6.5 is the one I'm using. The program isn't free legally, and there are some websites with cracked versions which you should definitely avoid.
No, the first 4 are defined as Parameters in functions, thus don't need to be pushed for function calls. You should generally be pushing every register you want to preserve though. Knowing the technicalities will allow you to save some operation time and space by omitting excessive operations such as pushing needlessly.
To use Knizz's IDA, you need a program called IDA pro. Version 6.5 is the one I'm using. The program isn't free legally, and there are some websites with cracked versions which you should definitely avoid.
Ahhh Thanks pal, I still really cant understand the concept of registers, if it is ok to you, I want to be your student, I'll read again the JPANs tutorial
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
I read some tutorials on ASM, but there are many things that I don't understand. So, I decided to do something with ASM, something very simple but to no avail. I wanted to do a routine that adds 2 numbers and then create a script using XSE and insert it to somebody.
Here's my ASM:
Spoiler:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r2,lr}
sub r1, r1, r1 @ cleans r1, so it's now 0
add r1, #0xF @ adds F/15 to r1 which means r1 = 15 now
sub r0, r0, r0 @ r0 = 0
add r0, #0xC @ adds C/12 to r0 so r0 = 12 now
add r2, r0, r1 @ adds F and C to r2, so r2 = 1B/27
pop {r0-r2,pc}
.align 2
I also don't know why, but sometimes this code couldn't compile. I had to change some lines(for example adding r2 register). Oh and is pushing and popping necessary here? FBI mentioned earlier that registers r0-r4 don't have to be pushed.
I inserted this routine at 0x8378D0.
And here's my XSE code:
Location: If I'm online, it's a safe bet I'm at a computer.
Gender:
Male
Nature: Relaxed
Posts: 984
Quote:
Originally Posted by DizzyEgg
I read some tutorials on ASM, but there are many things that I don't understand. So, I decided to do something with ASM, something very simple but to no avail. I wanted to do a routine that adds 2 numbers and then create a script using XSE and insert it to somebody.
Here's my ASM:
Spoiler:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r2,lr}
sub r1, r1, r1 @ cleans r1, so it's now 0
add r1, #0xF @ adds F/15 to r1 which means r1 = 15 now
sub r0, r0, r0 @ r0 = 0
add r0, #0xC @ adds C/12 to r0 so r0 = 12 now
add r2, r0, r1 @ adds F and C to r2, so r2 = 1B/27
pop {r0-r2,pc}
.align 2
I also don't know why, but sometimes this code couldn't compile. I had to change some lines(for example adding r2 register). Oh and is pushing and popping necessary here? FBI mentioned earlier that registers r0-r4 don't have to be pushed.
I inserted this routine at 0x8378D0.
And here's my XSE code:
Unfortunately it doesn't work. When I talk with a person who I assigned the script to I get "Does it work? 1".
Could someone help, please?
Your ASM routine isn't dumping the final number into the LASTRESULT variable. Basically, you're coming up with a number, but not really putting it anywhere. I'm not experienced enough to tell you how to fix it though. Sorry!
I read some tutorials on ASM, but there are many things that I don't understand. So, I decided to do something with ASM, something very simple but to no avail. I wanted to do a routine that adds 2 numbers and then create a script using XSE and insert it to somebody.
Here's my ASM:
Spoiler:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r2,lr}
sub r1, r1, r1 @ cleans r1, so it's now 0
add r1, #0xF @ adds F/15 to r1 which means r1 = 15 now
sub r0, r0, r0 @ r0 = 0
add r0, #0xC @ adds C/12 to r0 so r0 = 12 now
add r2, r0, r1 @ adds F and C to r2, so r2 = 1B/27
pop {r0-r2,pc}
.align 2
I also don't know why, but sometimes this code couldn't compile. I had to change some lines(for example adding r2 register). Oh and is pushing and popping necessary here? FBI mentioned earlier that registers r0-r4 don't have to be pushed.
I inserted this routine at 0x8378D0.
And here's my XSE code:
I read some tutorials on ASM, but there are many things that I don't understand. So, I decided to do something with ASM, something very simple but to no avail. I wanted to do a routine that adds 2 numbers and then create a script using XSE and insert it to somebody.
Here's my ASM:
Spoiler:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r2,lr}
sub r1, r1, r1 @ cleans r1, so it's now 0
add r1, #0xF @ adds F/15 to r1 which means r1 = 15 now
sub r0, r0, r0 @ r0 = 0
add r0, #0xC @ adds C/12 to r0 so r0 = 12 now
add r2, r0, r1 @ adds F and C to r2, so r2 = 1B/27
pop {r0-r2,pc}
.align 2
I also don't know why, but sometimes this code couldn't compile. I had to change some lines(for example adding r2 register). Oh and is pushing and popping necessary here? FBI mentioned earlier that registers r0-r4 don't have to be pushed.
I inserted this routine at 0x8378D0.
And here's my XSE code:
Unfortunately it doesn't work. When I talk with a person who I assigned the script to I get "Does it work? 1".
Could someone help, please?
The way you're cleaning registers isn't efficient, and also register values can be negative so that "cleaning" method isn't very good. You've also pushed said registers :o
If you want to clean a register and assign it a value just use mov. Mov is like an assignment statement for values between 0x0-0xFF. Then, as someone stated, you haven't put the result in var 0x800D (Lastresult).
Here's a fixed up version:
Code:
.align 2
.thumb
.thumb_func
main:
push {r0-r1, lr}
mov r1, #0xF @write 0xF to r1
mov r0, #0xC @write 0xC to r0
add r1, r1, r0 @add r1 +r0, and put result in r1
ldr r0, =(0x20370D0) @lastresult's RAM location
strb r1, [r0] @write value of r1 into 0x20370D0 (r0)
pop {r0-r1, pc}
.align 2
Depending on where you call it, you don't even need the push/pop, but that's a different story for a different time :D
I'm asking you again lol.
what is 0x20370B8 function?
It's not a function. 0x20370D0 is a location in RAM, which just to happens to be where Lastresult is stored.
0x20370B8 is var 0x8000, which is my mistake. It should've been D0 not B8 :D
It's not a function. 0x20370D0 is a location in RAM, which just to happens to be where Lastresult is stored.
0x20370B8 is var 0x8000, which is my mistake. It should've been D0 not B8 :D
Sorry to quote your post up, I havent noticed that you stated that in your posted routine :v
anyways, thanks for that, I gradually understand the ASM concept
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
I know nothing else in ASM but to make an errored routine...
Yup I'm trying hard, and I really want to learn it although Its very hard
I made a routine, I want the Original ID of the pokemon set in Var 8000 be seen in a script..
example
setvar 0x8000 0x0
callasm 0x[myoffset+1]
then the Pokemon's OTID in first Party will be stored in bufferstring
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
I know nothing else in ASM but to make an errored routine...
Yup I'm trying hard, and I really want to learn it although Its very hard
I made a routine, I want the Original ID of the pokemon set in Var 8000 be seen in a script..
example
setvar 0x8000 0x0
callasm 0x[myoffset+1]
then the Pokemon's OTID in first Party will be stored in bufferstring
ALWAYS AND ONLY PUSH WHAT YOU POP
In other words, replace the r3 r2 (or even better, only push LR and pop PC because you don't need more for callasm)
Also you're missing a : after OTID
ALWAYS AND ONLY PUSH WHAT YOU POP
In other words, replace the r3 r2 (or even better, only push LR and pop PC because you don't need more for callasm)
Also you're missing a : after OTID
Oh, Yah, errors lol...
Will this work now if I replaced r3 to r2?
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Done registering, what's next err?
I dont know how to reply, I'm using mobile anyway
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Done registering, what's next err?
I dont know how to reply, I'm using mobile anyway
Improved version of your routine with comments:
Code:
.thumb @you only need this here
main:
push {lr} @when writing custom routines, you don't need to push/pop r0 to r3
ldr r0, var @address of the var is now in r0
ldrh r1, [r0] @value of the var is now loaded into r1 while the address stays in r0
mov r2, #0x64 @r2 is #0x64
mul r2, r1 @multiplying r2 by r1
ldr r1, pokedata @loading the pokemon data base address into r1
add r1, r2 @adding those two together finally gives us the address of the desired pokemon
ldrh r1, [r1, #0x4] @the OTID is a halfword four bytes into the structure, so we now load it into r1
strh r1, [r0] @r0 is still the address of the var, so we can store it there
pop {pc} @return from the routine
.align 2 @since you place 4-byte words here, they need to be aligned by 2
var: .word 0x20270B8 + (0x8000 *2)
pokedata .word 0x2024284
Come back when you have an internet connection that doesn't give you a ping of fifty seconds :/
.thumb @you only need this here
main:
push {lr} @when writing custom routines, you don't need to push/pop r0 to r3
ldr r0, var @address of the var is now in r0
ldrh r1, [r0] @value of the var is now loaded into r1 while the address stays in r0
mov r2, #0x64 @r2 is #0x64
mul r2, r1 @multiplying r2 by r1
ldr r1, pokedata @loading the pokemon data base address into r1
add r1, r2 @adding those two together finally gives us the address of the desired pokemon
ldrh r1, [r1, #0x4] @the OTID is a halfword four bytes into the structure, so we now load it into r1
strh r1, [r0] @r0 is still the address of the var, so we can store it there
pop {pc} @return from the routine
.align 2 @since you place 4-byte words here, they need to be aligned by 2
var: .word 0x20270B8 + (0x8000 *2)
pokedata .word 0x2024284
Come back when you have an internet connection that doesn't give you a ping of fifty seconds :/
I'm so sorry , anyways, thanks
I've sent you a VM
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.
You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.
Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
I would like to know, if it's possible, the offset of two routines :
- First, the one which creates an OW on the map when we come on this map ;
- And also, the one which check if there is an OW next to the player before walking.
When creating custom routines, it is essential that you push/pop all used registers in this routine. Otherwise you overwrite important values which are used by the scripting engine. :-)
When creating custom routines, it is essential that you push/pop all used registers in this routine. Otherwise you overwrite important values which are used by the scripting engine. :-)
Nope, it depends on where you call them from. Unless you place a hook in the middle of an existing routine, r0 to r3 can be overwritten.
I'm trying to make psystrike's effect, so to do this i want to swap the def with the spe def (and their changments in battle) of every pokemons in battle.
I'm on Emerald.