The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Help Thread ASM & Disassembly

Notices
For all updates, view the main page.

Binary ROM Hacking Need 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.

Ad Content
Closed Thread
 
Thread Tools
  #76   Link to this post, but load the entire thread.  
Old January 16th, 2015 (2:21 PM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by FBI agent View Post
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.
  #77   Link to this post, but load the entire thread.  
Old January 16th, 2015 (3:13 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Lance32497 View Post
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.
__________________
...
  #78   Link to this post, but load the entire thread.  
Old January 16th, 2015 (5:53 PM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by FBI agent View Post
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.
  #79   Link to this post, but load the entire thread.  
Old January 17th, 2015 (3:25 AM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
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:
Spoiler:
#dynamic 0x800000
#org @start
callasm 0x8378D1
buffernumber 0x0 LASTRESULT
msgbox @a 0x2
end

#org @a
= Does it work? [buffer1]


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?
__________________
Support Pokeemerald!

Pokeemerald starter pack:
Emerald Expansion
  #80   Link to this post, but load the entire thread.  
Old January 17th, 2015 (4:05 AM).
Deokishisu's Avatar
Deokishisu Deokishisu is offline
Mr. Magius
 
Join Date: Feb 2006
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 View Post
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:
Spoiler:
#dynamic 0x800000
#org @start
callasm 0x8378D1
buffernumber 0x0 LASTRESULT
msgbox @a 0x2
end

#org @a
= Does it work? [buffer1]


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!
  #81   Link to this post, but load the entire thread.  
Old January 17th, 2015 (4:07 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by DizzyEgg View Post
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:
Spoiler:
#dynamic 0x800000
#org @start
callasm 0x8378D1
buffernumber 0x0 LASTRESULT
msgbox @a 0x2
end

#org @a
= Does it work? [buffer1]


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?
I've sent you a vm
__________________
  #82   Link to this post, but load the entire thread.  
Old January 17th, 2015 (12:47 PM). Edited January 17th, 2015 by Blah.
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by DizzyEgg View Post
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:
Spoiler:
#dynamic 0x800000
#org @start
callasm 0x8378D1
buffernumber 0x0 LASTRESULT
msgbox @a 0x2
end

#org @a
= Does it work? [buffer1]


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
__________________
...
  #83   Link to this post, but load the entire thread.  
Old January 17th, 2015 (1:14 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Lance32497 View Post
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
__________________
...
  #84   Link to this post, but load the entire thread.  
Old January 17th, 2015 (1:17 PM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by FBI agent View Post
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.
  #85   Link to this post, but load the entire thread.  
Old January 19th, 2015 (1:11 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
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

Spoiler:

.align 2
.thumb
main:
push {r0-r2,lr}
ldr r1, var
ldrb r1, [r1]
mov r0, #0x64
mul r0, r0, r1
mov r2, r0
ldr r0, OTID
ldrh r0, [r0, #0x4]
strh r0, [r2]
pop {r0-r3,pc}
var:
.word 0x20270B8 + (0x8000 *2)
OTID
.word 0x2024284
__________________
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.
  #86   Link to this post, but load the entire thread.  
Old January 19th, 2015 (1:37 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by Lance32497 View Post
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

Spoiler:

.align 2
.thumb
main:
push {r0-r2,lr}
ldr r1, var
ldrb r1, [r1]
mov r0, #0x64
mul r0, r0, r1
mov r2, r0
ldr r0, OTID
ldrh r0, [r0, #0x4]
strh r0, [r2]
pop {r0-r3,pc}
var:
.word 0x20270B8 + (0x8000 *2)
OTID
.word 0x2024284
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
__________________
  #87   Link to this post, but load the entire thread.  
Old January 19th, 2015 (1:56 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by daniilS View Post
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.
  #88   Link to this post, but load the entire thread.  
Old January 19th, 2015 (2:01 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by Lance32497 View Post
Oh, Yah, errors lol...
Will this work now if I replaced r3 to r2?
Join the irc
__________________
  #89   Link to this post, but load the entire thread.  
Old January 19th, 2015 (2:06 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by daniilS View Post
Join the irc
IRC?
__________________
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.
  #90   Link to this post, but load the entire thread.  
Old January 19th, 2015 (2:12 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by Lance32497 View Post
IRC?
http://chat.linkandzelda.com:9090/?channels=GoGo
__________________
  #91   Link to this post, but load the entire thread.  
Old January 19th, 2015 (2:20 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by daniilS View Post
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.
  #92   Link to this post, but load the entire thread.  
Old January 19th, 2015 (2:48 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by Lance32497 View Post
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 :/
__________________
  #93   Link to this post, but load the entire thread.  
Old January 19th, 2015 (2:53 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by daniilS View Post
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 :/
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.
  #94   Link to this post, but load the entire thread.  
Old January 30th, 2015 (2:49 PM).
Mickey` Mickey` is offline
 
Join Date: May 2011
Posts: 88
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.

Can someone help me ? Thanks ^^
  #95   Link to this post, but load the entire thread.  
Old February 1st, 2015 (9:25 PM).
laxe laxe is offline
 
Join Date: Jan 2015
Gender: Male
Posts: 17
@daniilS:

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. :-)
  #96   Link to this post, but load the entire thread.  
Old February 2nd, 2015 (12:53 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by laxe View Post
@daniilS:

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.
__________________
  #97   Link to this post, but load the entire thread.  
Old February 5th, 2015 (1:58 PM).
Edwearth's Avatar
Edwearth Edwearth is offline
 
Join Date: May 2014
Location: Paris
Gender: Male
Posts: 40
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.

So i did this :
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func
.global swap

main:
	push {r0-r3, lr}
	ldr r0, .DEF
	ldr r1, .DEF
	
	ldr r2, .SPEDEF
	ldr r3, .SPEDEF
	
	strh r0, [r3]
	strh r2, [r1]
	
	
	pop {r0-r3, pc}
	
.align 2
.DEF:
	.word 0x02024548
.SPEDEF:
	.word 0x0202454E


It is to swap the def and the spe of my first pokemon.
But obviously it doesn't work. The game resets.
Why?
Thanks
  #98   Link to this post, but load the entire thread.  
Old February 6th, 2015 (10:37 AM).
Mickey` Mickey` is offline
 
Join Date: May 2011
Posts: 88
You have to load the Defense and the Sp. Defense, not just their offset.

Code:
.text
.align 2
.thumb
.thumb_func
.global swap

main:
	push {r0-r3, lr}

	ldr r0, .DEF
	ldrh r1, [r0]
	
	ldr r2, .SPEDEF
	ldrh r3, [r2]
	
	strh r1, [r2]
	strh r3, [r0]
	
	pop {r0-r3, pc}
	
.align 2
.DEF:
	.word 0x02024548
.SPEDEF:
	.word 0x0202454E
  #99   Link to this post, but load the entire thread.  
Old February 6th, 2015 (3:31 PM).
Edwearth's Avatar
Edwearth Edwearth is offline
 
Join Date: May 2014
Location: Paris
Gender: Male
Posts: 40
Thank you for your reply, but the game is still reseting.
Maybe it is due to my script. In order to do my test, I call my asm in an signpost.
Spoiler:

Code:
'---------------
#org 0xF10050
lock
faceplayer
callasm 0x8F10000
msgbox 0x8F100A0 MSG_FACE '"Hello world !"
release
end


'---------
' Strings
'---------
#org 0xF100A0
= Hello world !


There is nothing special, so it's a bit strange.
  #100   Link to this post, but load the entire thread.  
Old February 6th, 2015 (4:52 PM).
Deokishisu's Avatar
Deokishisu Deokishisu is offline
Mr. Magius
 
Join Date: Feb 2006
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 Edwearth View Post
Thank you for your reply, but the game is still reseting.
Maybe it is due to my script. In order to do my test, I call my asm in an signpost.
Spoiler:

Code:
'---------------
#org 0xF10050
lock
faceplayer
callasm 0x8F10000
msgbox 0x8F100A0 MSG_FACE '"Hello world !"
release
end


'---------
' Strings
'---------
#org 0xF100A0
= Hello world !


There is nothing special, so it's a bit strange.
Wait, you're trying to test Psystrike's battle effect in the OW with a signpost script? Really?

This should be put in a battlescript which is then attached to an attack. Then used in a battle. Wow.
Closed Thread

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content
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 9:23 AM.