The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking > Binary Hack Research & Development
Reload this Page Code ASM Resource Thread

Notices
For all updates, view the main page.

Binary Hack Research & Development Got a well-founded knack with your binary Pokémon hacks? Love reverse-engineering them? For the traditional Pokémon ROM hacker, this is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!

Ad Content
Reply
 
Thread Tools
  #501   Link to this post, but load the entire thread.  
Old March 19th, 2015 (5:53 AM).
PokéMew's Avatar
PokéMew PokéMew is offline
Pokémon Fuchsia
 
Join Date: Sep 2013
Location: Refresh
Gender: Male
Nature: Modest
Posts: 484
Quote:
Originally Posted by RaileysXerilyasRX View Post
Can I request to have this thread to have examples of scripts (I mean the scripts which are XSE based)? Since a lot of people ask those here while checking ASMs. I think this should be started in the future posts of new ASMs (well, if you have effort enough to edit every single ASMs posted, then do so).
Erm.. Last time I checked, FBI posts how to use the ASM in a script, at the end of each post in the 'usage' part. If you mean a full on script starting from dynamic to end, well I guess thats FBI's chioce :/ But this isn't exactly a thread on scripting, which is why he includes basically everything you need to know in the usage section depending on the code. But again, it's FBI's decision lol.
Reply With Quote
  #502   Link to this post, but load the entire thread.  
Old March 19th, 2015 (12:38 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 destinedjagold View Post
Hm... How about a lazy method of doing this?
Like this...

Have 10/20 Shockwave -> Learn TM Hyperbeam 5/5 --> Learn Shockwave 5/20

Simply keep the numerator and only run a check if it's greater than the denominator. If the numerator's greater than the denominator, then make both values equal. :3
Yeah, this seems like the only solution that would help solve the problem. Unless someone comes up with something better, this is probably what I'm going to do. Thanks.

Quote:
Originally Posted by PokéMew View Post
Well, my intent was to use the bike as, well, a key item called the dive suit. Its an item needed to access a certain place in the game (underwater as you may guess). The bicycle has a number of features that the running shoes do not to make things a hell of a ton simpler. For one, it is an actual item, rather than a flag. Also, the bike has its own soundtrack, where as the running shoes simply stick with the current sound track playing. That was one thing I felt this suit must need, a custom track (which I already inserted in sappy.) Now, if these things could be done to the running shoes using ASM (But I'd imagine that making the shoes an actual item and have its own sound track would be awfully complicated) thats another story, but for now I've just decided to use the bicycle as the thing to replace, I didn't find myself using the bike in the games anyways, mainly the shoes. It only has a tiny bit of a speed difference anyway.

That was my motive :)

So, possible?
I understand now. Hmm, this is a little specific though. The thread rules state that I'm not going to do routines which are specific to a hack. Anyways, since this is your first request, and this is relatively simple I'll do it. Look at the bottom of this post.

Quote:
Originally Posted by Percy View Post
Can you be a more specific with the naming routines? Seems interesting :D
Sure. I'll give you a video. It's the naming portion of the video in this post: http://www.pokecommunity.com/showpost.php?p=8662862&postcount=10

Quote:
Originally Posted by RaileysXerilyasRX View Post
Can I request to have this thread to have examples of scripts (I mean the scripts which are XSE based)? Since a lot of people ask those here while checking ASMs. I think this should be started in the future posts of new ASMs (well, if you have effort enough to edit every single ASMs posted, then do so).
Hi, I think most of the ones that require scripts have script examples. There are a few simple ones which don't, but that's because all it is, is just a callasm command after setting a few variables. In future, I'll look into putting a little more effort into the usage portion.


Set Bike Speed to Walk speed



How to insert:
Change byte at 0x150514 to 01

This has got to be the simplest thing here. lol.
__________________
...
Reply With Quote
  #503   Link to this post, but load the entire thread.  
Old March 19th, 2015 (1:01 PM).
Mana's Avatar
Mana Mana is offline
 
Join Date: Jan 2009
Location: UK
Age: 31
Gender: Male
Posts: 10,075
Can I request something that I hope is relatively straight forward? A routine which adds 1 to a variable after winning a trainer battle? Could be used to record victories, count winning streaks, etc.
__________________
Reply With Quote
  #504   Link to this post, but load the entire thread.  
Old March 19th, 2015 (1:58 PM).
PokéMew's Avatar
PokéMew PokéMew is offline
Pokémon Fuchsia
 
Join Date: Sep 2013
Location: Refresh
Gender: Male
Nature: Modest
Posts: 484
Quote:
Originally Posted by FBI agent View Post

Set Bike Speed to Walk speed



How to insert:
Change byte at 0x150514 to 01
lol Thanks :P

I'm not sure how you found that offset.. I've been looking for it for a long time. Despite, it still partially does not work. Registering the bike is glitched up. You can register it fine, you can click select and use it fine, however you cannot recall it. I think I have a slight understanding why this is, but I have absolutely no idea how I could fix this. Do you, just maybe, know how it could be done? :)
Reply With Quote
  #505   Link to this post, but load the entire thread.  
Old March 19th, 2015 (2:49 PM).
kearnseyboy6 kearnseyboy6 is offline
Aussie's Toughest Mudder
 
Join Date: Dec 2008
Posts: 300
Quote:
Originally Posted by PokéMew View Post
lol Thanks :P

I'm not sure how you found that offset.. I've been looking for it for a long time. Despite, it still partially does not work. Registering the bike is glitched up. You can register it fine, you can click select and use it fine, however you cannot recall it. I think I have a slight understanding why this is, but I have absolutely no idea how I could fix this. Do you, just maybe, know how it could be done? :)
Well here is a complicated but theoretically working method.

Using Darthatron's script item hack, you can call FBI' overworld change with the code Playsong 0x## 0x1 the 0x1 will act like the bike music (ie only change after map change, not a trainer/wild battle).
__________________
HOLIDAYING CURRENTLY!!
Reply With Quote
  #506   Link to this post, but load the entire thread.  
Old March 19th, 2015 (6:05 PM).
Xencleamas's Avatar
Xencleamas Xencleamas is offline
Suddenly lurking in the shadows...
 
Join Date: Feb 2014
Gender: Male
Nature: Adamant
Posts: 456
Quote:
Originally Posted by FBI agent View Post

Set Bike Speed to Walk speed



How to insert:
Change byte at 0x150514 to 01

This has got to be the simplest thing here. lol.
Hmmm... so that means can we also fasten up the FR Bike to match RSE Mach Bike?
__________________
Reply With Quote
  #507   Link to this post, but load the entire thread.  
Old March 19th, 2015 (6:35 PM).
PokéMew's Avatar
PokéMew PokéMew is offline
Pokémon Fuchsia
 
Join Date: Sep 2013
Location: Refresh
Gender: Male
Nature: Modest
Posts: 484
Quote:
Originally Posted by RaileysXerilyasRX View Post
Hmmm... so that means can we also fasten up the FR Bike to match RSE Mach Bike?
Not nessisarily, at least using this method. I've already tested it, if you keep going higher, it still does the exact same thing as the bike for 2-7. Everything above there still has the same speed, except you get the oak message (nows not the time to use that!) when trying to recall it after using it. Basically meaning you can't get off of it unless you warp somewhere.
Reply With Quote
  #508   Link to this post, but load the entire thread.  
Old March 19th, 2015 (11:13 PM). Edited March 20th, 2015 by Percy.
Percy's Avatar
Percy Percy is offline
 
Join Date: Sep 2014
Location: Asia
Gender: Male
Nature: Quiet
Posts: 3,045
I'm right! The naming routine is very interesting :D

edit: I can't understand the Re-usable TM's. (This one).
It says:
Quote:
To insert:
Do the byte changes below
0x124F78: 00 00 00 00
0x125C80: 00 00 00 00

Make it Ungivable:
insert that at 0x1326B8: 00 00 17 E0

Make it consumable after animation:
Insert: 00 00 00 00 at 0x124F78
I can't understand that... :s
Am I just dumb or ...
__________________
i don't want to have a signature
Reply With Quote
  #509   Link to this post, but load the entire thread.  
Old March 20th, 2015 (1:48 PM).
InfiniteZero's Avatar
InfiniteZero InfiniteZero is offline
I never change my Avatar. D=
 
Join Date: Aug 2006
Age: 33
Nature: Brave
Posts: 61
Quote:
Originally Posted by Percy View Post
I'm right! The naming routine is very interesting :D

edit: I can't understand the Re-usable TM's. (This one).
It says:


I can't understand that... :s
Am I just dumb or ...
For example, at 0x124F78, in the default game it has 75 F7 2E F9. You insert 00 over those four bytes, essentially replacing them. That goes for all of the offsets you listed - the four two digit bytes at each offset, replace them with 00 in a hex editor.
Reply With Quote
  #510   Link to this post, but load the entire thread.  
Old March 20th, 2015 (2:49 PM).
Percy's Avatar
Percy Percy is offline
 
Join Date: Sep 2014
Location: Asia
Gender: Male
Nature: Quiet
Posts: 3,045
Quote:
Originally Posted by InfiniteZero View Post
For example, at 0x124F78, in the default game it has 75 F7 2E F9. You insert 00 over those four bytes, essentially replacing them. That goes for all of the offsets you listed - the four two digit bytes at each offset, replace them with 00 in a hex editor.
I know that, lol.
I'm confused of this:
Quote:
To insert:
Do the byte changes below
0x124F78: 00 00 00 00
0x125C80: 00 00 00 00

Make it Ungivable:
insert that at 0x1326B8: 00 00 17 E0

Make it consumable after animation:
Insert: 00 00 00 00 at 0x124F78
The offsets highlighted is the same, by the way. Anyway, that's fixed now! Thanks FBI!
__________________
i don't want to have a signature
Reply With Quote
  #511   Link to this post, but load the entire thread.  
Old March 20th, 2015 (8:32 PM).
Atmosphere Atmosphere is offline
 
Join Date: Mar 2015
Posts: 1
I saw a post in the script help thread by Méw who said he was trying to make it so that when you make a warp script, when you warp a key item is also activated. I looked through all of XSE's commands and there is no command that uses an item. I think this is the right place to post this, but how possible is it to make an item activated when making a warp script? I'm assuming the only thing the routine would involve is using an item, and the script does the rest..
Reply With Quote
  #512   Link to this post, but load the entire thread.  
Old March 20th, 2015 (11:54 PM).
robinjea's Avatar
robinjea robinjea is offline
 
Join Date: Sep 2012
Age: 25
Gender: Male
Nature: Quirky
Posts: 534
Quote:
Originally Posted by FBI agent View Post
Wow. I'm genuinely happy someone requested this. Believe it or not, this exact routine was my first ever routine. Darthatron held my hand through the process, and it's been years since I've done it. I'd be happy to redo it just for the nostalgia

However, I should warn you that fitting it all into one routine is not possible.
Okay then! Now I don't care how many routines it needs just to work! Just knowing that it can be done and how you've had an experience with this fires me up! Teach us how and I'll put it to good use! Thank you!
Reply With Quote
  #513   Link to this post, but load the entire thread.  
Old March 25th, 2015 (8:00 AM). Edited March 25th, 2015 by Blah.
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924

Battle by turn addon HP-regen



Before inserting this routine, you need to have the battle by turn routine enabled. See first post for that.

Intro:

A simple routine which adds HP regeneration to a Pokemon every odd turn of battle. The amount added can be changed (read the comment in the code).

How to insert:

Insert as a new battle by turn routine specified by the battle by turn frame. No further instructions required.

Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r7, lr}
	ldr r0, =(0x3004FA3)
	ldrb r0, [r0]
	mov r1, #0x2
	ldr r3, =(0x81E4684 +1)
	bl linker
	cmp r0, #0x0
	beq end
	ldr r0, =(0x2024284)
	mov r6, #0x0
	ldr r7, =(0x2024029)
	ldrb r7, [r7]

	
loop:
	cmp r6, r7
	beq end
	mov r1, #0x64
	mul r1, r1, r6
	add r0, r0, r1
	mov r5, r0
	mov r1, #0x39
	ldr r3, =(0x803FBE8 +1)
	bl linker
	mov r4, r0
	cmp r4, #0x0
	beq next
	mov r0, r5
	mov r1, #0x3A
	ldr r3, =(0x803FBE8 +1)
	bl linker
	add r6, r6, #0x1
	cmp r4, r0
	beq loop

addOn:
	add r4, r4, #0x5 @amount to add every other turn, here it's 5
	cmp r4, r5
	ble cont
	mov r4, r5
	
cont:
	mov r0, r5
	mov r1, #0x39
	ldr r2, =(0x20370D0)
	strh r4, [r2]
	ldr r3, =(0x804037C)
	bl linker
	b loop
	
next:
	add r6, r6, #0x1
	b loop
	
end:
	pop {r0-r7, pc}
	
linker:
	bx r3
	
.align 2


Usage:

No usage, it's automatic. Make sure you have set the battle by turn flag.
__________________
...
Reply With Quote
  #514   Link to this post, but load the entire thread.  
Old March 25th, 2015 (8:08 AM). Edited March 28th, 2015 by Blah.
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924

HP Regeneration per step



Intro:
Basically a routine to regenerate a Pokemon's HP every step. In this routine it's set to 3 per step. You may want to modify the exact amount to a percentage or something (see the commented line).

How to insert:

First compile and insert the following routine into free space.

Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r7}
	ldr r0, =(0x2024284)
	mov r6, #0x0
	ldr r7, =(0x2024029)
	ldrb r7, [r7]

	
loop:
	cmp r6, r7
	beq end
	mov r1, #0x64
	mul r1, r1, r6
	add r0, r0, r1
	mov r5, r0
	mov r1, #0x39
	ldr r3, =(0x803FBE8 +1)
	bl linker
	mov r4, r0
	cmp r4, #0x0
	beq next
	mov r0, r5
	mov r1, #0x3A
	ldr r3, =(0x803FBE8 +1)
	bl linker
	add r6, r6, #0x1
	cmp r4, r0
	beq loop

addOn:
	add r4, r4, #0x3 @amount to add per step. Here it's 3
	cmp r4, r0
	ble cont
	mov r4, r0
	
cont:
	mov r0, r5
	mov r1, #0x39
	ldr r2, =(0x20370D0)
	strh r4, [r2]
	ldr r3, =(0x804037C)
	bl linker
	b loop
	
next:
	add r6, r6, #0x1
	b loop

end:
	pop {r0-r7}
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	cmp r0, #0x1
	beq brancher
	mov r0, r5
	ldr r1, =(0x806D600 +1)
	bx r1

brancher:
	ldr r0, =(0x806D650 +1)
	bx r0
	
linker:
	bx r3
	
.align 2


Now in a hex editor navigate to 0x6D5F6. There you will need to insert the following byte changes:
Code:
 01 4A 10 47 00 00 XX XX XX 08
Where XX XX XX is the pointer to where you inserted the above routine +1.

Usage:

There isn't any usage. It's automatically done. You can change the amount generated by reading the line in the code which I've commented.
__________________
...
Reply With Quote
  #515   Link to this post, but load the entire thread.  
Old March 25th, 2015 (8:16 AM).
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 robin22gongon View Post
Okay then! Now I don't care how many routines it needs just to work! Just knowing that it can be done and how you've had an experience with this fires me up! Teach us how and I'll put it to good use! Thank you!
Done!

Quote:
Originally Posted by Percy View Post
I know that, lol.
I'm confused of this:


The offsets highlighted is the same, by the way. Anyway, that's fixed now! Thanks FBI!
That's because I wrote it down twice due to my brain malfunctioning. I'll have to edit that when I've mustered enough willpower.

Quote:
Originally Posted by Atmosphere View Post
I saw a post in the script help thread by Méw who said he was trying to make it so that when you make a warp script, when you warp a key item is also activated. I looked through all of XSE's commands and there is no command that uses an item. I think this is the right place to post this, but how possible is it to make an item activated when making a warp script? I'm assuming the only thing the routine would involve is using an item, and the script does the rest..
That's interesting. Why can't he use a level script? In the end, in my ASM routine, I will end up having to execute the item's script/routine as a level script anyways. It's better to just use scripting here I'd think. It's a matter of finding each item's function, see davidjcobb's tutorial on adding items. There's a field in each item where it's routine is located. Most times you can just callasm to this routine. If you have trouble running a specific routine there, shoot me to routine offsets.
__________________
...
Reply With Quote
  #516   Link to this post, but load the entire thread.  
Old March 25th, 2015 (9:49 AM).
Kenny1's Avatar
Kenny1 Kenny1 is offline
On a break from Rom hacking, to improve other skills.
 
Join Date: Nov 2013
Gender: Male
Posts: 86
Quote:
Originally Posted by FBI agent View Post
This is very dependent on what you're swapping. The solution is probably going to be a rewrite using the same skeleton. Also iirc, the badges are OAMs, not tile/bg graphics. You will need to generate/hide/show these extra OAMs on top of the BG overlay depending on the extra badge flags that have been implemented.
I was actually thinking of just swapping which graphics it loaded, but I actually think it'll be more than that. Sorry Dionen.
__________________
I'm no longer active here, I check back every now and then to see what happens, but that's it. I no longer hack either.
Reply With Quote
  #517   Link to this post, but load the entire thread.  
Old March 25th, 2015 (10:39 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 Kenny1 View Post
I was actually thinking of just swapping which graphics it loaded, but I actually think it'll be more than that. Sorry Dionen.
I think that's all it takes, honestly. Find where the pointers to the graphics are loaded and hijack that routine to potentially load different pointers.
__________________
Reply With Quote
  #518   Link to this post, but load the entire thread.  
Old March 26th, 2015 (3:37 PM).
Alexander Nicholi's Avatar
Alexander Nicholi Alexander Nicholi is offline
work hard, play hard
 
Join Date: Nov 2009
Location: Research Triangle / Jakarta
Age: 25
Gender: Male
Nature: Adamant
Posts: 5,498
I'd really like to see some ports of these routines (particulary this one, this one, this one, and this one) ported over to Ruby.

Dereferencing the necessary pointers should be easier in the absence of malloc(), so it shouldn't be too difficult. We should have better support for Ruby than this.
__________________
the beat goes on (ノ^o^;)ノ
ヽ(;^o^ヽ) the beat goes on
the beat goes on (ノ^o^;)ノ
ヽ(;^o^ヽ) the beat goes on
( don’t stop the groovin’ )
Reply With Quote
  #519   Link to this post, but load the entire thread.  
Old March 26th, 2015 (5:03 PM). Edited March 26th, 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 daniilS View Post
I think that's all it takes, honestly. Find where the pointers to the graphics are loaded and hijack that routine to potentially load different pointers.
He needs to load OAMs, the BGs are always easy to swap around. daniilS pls :x

Quote:
Originally Posted by Inyotef View Post
I'd really like to see some ports of these routines (particulary this one, this one, this one, and this one) ported over to Ruby.

Dereferencing the necessary pointers should be easier in the absence of malloc(), so it shouldn't be too difficult. We should have better support for Ruby than this.
Well you don't need to dereferencing pointers, most of the RAM pointers are statically allocated to specific portions which are flagged. \What you'd need to do is find these static RAM blocks equivalents in your game of choice.

Anyways, why do you want support for R/S or LG? They're all pretty bad bases to use. The biggest problem is their lack of research. It's pointless to research something for R/S when it's already been discovered for Emerald, because Emerald will be better than Ruby as a base, but never vise versa. It's just not worth the time researching things for a ROM base which is inferior.

Fire Red has the most research done, and in my opinion, is the best base to use. Second comes Emerald, and finally the rest are trash.

But, yeah, if you wanted to port them, the pointers are all that needs changing (for the ones you've linked). Actually, the surf one may be a little different depending on the base. Fire Red launches that routine when "A" is pressed on any tile. Other bases may be a little different.
__________________
...
Reply With Quote
  #520   Link to this post, but load the entire thread.  
Old March 27th, 2015 (8:26 AM).
Dionen's Avatar
Dionen Dionen is offline
deprived of sleep
 
Join Date: Jun 2011
Location: Brazil
Gender: Male
Nature: Quirky
Posts: 295
Quote:
Originally Posted by Kenny1 View Post
Sorry Dionen.
lol, relax dude {XD}

Quote:
Originally Posted by FBI agent View Post
He needs to load OAMs, the BGs are always easy to swap around. daniilS pls :x
Does your upcoming "- OAM generation/manipulation routine" might deal with that? I mean, altering existing OAMs, or just generated ones?
__________________
Reply With Quote
  #521   Link to this post, but load the entire thread.  
Old March 27th, 2015 (1:24 PM). Edited April 5th, 2015 by Blah.
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924

Field Moves



This, I think, deserves it's own thread. However, since I'd have about 90 threads by now if I followed that logic, I'm just going to make a post. I hope to cover how to add any arbitrary field move in addition to some research notes on the matter. This requires a little bit of patience and some table repointing/hex work in order to do. I should say that it's nothing hard, the hardest thing would be repointing a table, which is relatively easy. If you don't know how to do those hex manipulations, ask at the quick question thread, and hopefully myself or someone else will answer.

Research for Nerds:



Hi, if you're a noob just passing through trying to insert this without caring about the technical details, you can skip this section. Here I will be explaining as much as I know about the BRM for those who want to improve it or are generally curious about how it works in general.

The BRM menu is by far one of the more complicated data structures in the game. It's handled by several separate RAM and ROM data structures which I will attempt to explain. The first one is the BRM's RAM data structure. There are a few attributes which this structure contains, the main one, the one we care about in this case is the cursor's position. It's given in 0203B0A9 and changes depending on which Pokemon you're hovering over. In the case you're in a selection where there are more than one Pokemon to be selected, the byte next to it will hold the second selection. This byte is used (when the player presses the "A" button) to derive other menus and checks by using the simple formula: 0x2024284 + (0x64 * byte) to get the Pokemon.
There are a few others which are used to determine other things, which I don't be explaining in detail, mainly due to lack of my remembering (did this more than a month ago).

Once the Pokemon is selected using the "A" button, contrary to initial belief, the BRM is generated on the spot, then graphically generated right after. Initially when "A" is pressed, the game loops through the 0x0 terminated Move IDs table comparing each half-word represented move to each move the Pokemon selected has at the function 0x81229FC. If a move is found, then it will store it in a RAM data structure (same BRM structure) which works very similarly to the start menu. This routine handles Pokemon holding mail too.

With the given data structure fully formed the BRM is graphically created. There are some other things that go into it to pull up the "summary, cancel, item" fields and such (byte toggled in the BRM) but I'm not going to go too deeply about that. Anyways, the BRM RAM structure then handles the browsing of this smaller menu. Once "A" is pressed, the BRM table is used to determine which function to execute. It's format is [string pointer][routine pointer]. The HMs are at the end of this table. 0x81245A4 handles teh case where the selected item in an HM. It does things from badge checking to calling the actual routine, specific to the HM.

In general, you can edit the table for the BRM to change a function to execute a routine of your choosing. However, remember that you need to follow the correct procedures which including closing the BRM and exiting to Overworld ect. The graphics generation and such are left to you if you follow this method. Initially, this is the method I was using.

With some research, and studying, I was able to determine how the BRM item selection worked for HMs which excited to the overworld and called a routine. From there I was able to call a routine which ran a script.

Basically, there were other RAM locations allocated to hold routine pointers which were executed by the game at certain times. Cut for example, would first check the map, the tiles infront of the player (if they were grass), the coords infront of the player, ect. before executing. From there, there were two cases which executed differently. Believe it or not, cut does not always execute a script. The first method is that it sets the tiles infront of the player to plain grass (so it actually cuts wild grass, try it yourself by walking into a patch of grass and using CUT !), the second case it executed the script.

I think it's better to read the rest of the tutorial to see how those things work, rather than listening to my kinda long explanations.


Repointing some tables (noob friendly edition):



Before we begin, there are a few tables which need repointing. Please write down the offsets to where you paste the hex I give you. For your sake, once again, please write down where you place these tables to.

Table 1: Move IDs table:

Copy and place into free space:
Make sure the offset you copied this table to is half-word divisible (ends in 0, 2, 4, 6, 8, A, C, E)
Code:
94 00 0F 00 13 00 46 00 39 00 F9 00 7F 00 64 00 5B 00 D0 00 87 00 E6 00 0C 00

Now navigate to 0x122A7C and change the reverse hex pointer to be the pointer where you copied the above hex table to.

Table 2: Launch Pad routine table + properties

Copy and place into free space:
Make sure the free space offset is word divisible (ends in 0, 4, 8, C)
Code:
2D 9B 0C 08 0D 00 00 00 99 78 09 08 07 00 00 00 8D 4A 12 08 0D 00 00 00 ED 07 0D 08 0D 00 00 00 99 49 12 08 08 00 00 00 D9 99 0C 08 0D 00 00 00 F9 4A 12 08 0D 00 00 00 F1 66 0F 08 0D 00 00 00 79 9A 0C 08 0D 00 00 00 85 56 0E 08 10 00 00 00 85 56 0E 08 10 00 00 00 C9 E0 0D 08 0D 00 00 00
Now navigate to 0x124614 and 0x124680 and change the reverse hex pointer to be the pointer where you copied the above hex table to.

Table 3: BRM names + launcher

Copy and place into free space:
Make sure the free space offset is word divisible (ends in 0, 4, 8, C)
Code:
94 69 41 08 4D 2D 12 08 8D 69 41 08 01 2E 12 08 C1 61 41 08 41 36 12 08 D4 61 41 08 A1 36 12 08 B2 61 41 08 05 37 12 08 DE 61 41 08 39 3C 12 08 D9 61 41 08 F5 3C 12 08 B2 69 41 08 0D 3E 12 08 B7 69 41 08 59 3D 12 08 C1 61 41 08 65 40 12 08 7E 69 41 08 F5 40 12 08 84 69 41 08 F5 40 12 08 A3 69 41 08 55 41 12 08 A9 69 41 08 79 42 12 08 E3 61 41 08 55 43 12 08 F4 B6 41 08 85 43 12 08 BC 69 41 08 91 44 12 08 BC 69 41 08 A1 45 12 08 18 78 24 08 A5 45 12 08 57 71 24 08 A5 45 12 08 8B 71 24 08 A5 45 12 08 22 74 24 08 A5 45 12 08 79 73 24 08 A5 45 12 08 39 7D 24 08 A5 45 12 08 07 77 24 08 A5 45 12 08 A8 75 24 08 A5 45 12 08 33 75 24 08 A5 45 12 08 24 7B 24 08 A5 45 12 08 6F 77 24 08 A5 45 12 08 42 7C 24 08 A5 45 12 08
Now navigate to 0x120F74, 0x121FB8, 0x122D18, 0x122D48 and change the reverse hex pointer to be the pointer where you copied the above hex table to.

Table 4: Field move description pointers table

Copy and place into free space:
Make sure the free space offset is word divisible (ends in 0, 4, 8, C)
Code:
83 75 41 08 33 75 41 08 48 75 41 08 6E 75 41 08 5D 75 41 08 96 75 41 08 AE 75 41 08 FB 75 41 08 CC 75 41 08 F1 75 41 08 F1 75 41 08 DE 75 41 08
Now navigate to 0x1221D0 and change the reverse hex pointer to be the pointer where you copied the above hex table to.

That's all for table repointing. I hope you wrote down the offsets for them in some recognizable format. I.e:
Table 1: Offset
Table 2: Offset
Table 3: Offset
Table 4: Offset
Because that's how I will refer to them AND we'll need them very soon.


Making your move's script -> The fuel



You are lucky. You are lucky I suffered many hours figuring this out so you can use scripts rather than routines and have an easy time setting up field moves. Anyways, the first step is to write out your script which you will be using. In this "tutorial/resource/research" thing I will be inserting Sunny Day in an attempt to give a relevant example of how to set things up.

Here's my PKSV script:
Spoiler:

Code:
#dyn 0x740000
#org @start
'-----------------------------------
'OK a little ASM-esque. Basically checking if we're indoors.
'If we aren't, jump @continue
'-----------------------------------
lockall
copybyte 0x20370B8 0x2036E13
compare 0x8000 0x3
if == jump @continue
compare 0x8000 0x1
if == jump @continue
compare 0x8000 0x6
if == jump @continue
compare 0x8000 0x2
if == jump @continue
msgbox @indoors
callstd MSG_NORMAL
release
end

#org @continue
'standard HM animation
doanimation 0x28
waitspecial
setweather 0x1
doweather
msgbox @text ' \v\h02 used Sunny Da...
callstd MSG_LOCK ' Built-in lock command
release
end


#org @text
= \v\h02 used Sunny Day!\nIt became Sunny outside.

#org @indoors
= Can't make it sunny inside[.]


If you're lost at the script, or don't know how to make a script, then you'd better go learn! This script is admittedly, a little more complicated than what I'd expect people to use. Its because I'm using some scripting and ASM knowledge to determine whether or not we're indoors. It's a special case only relevant to weather effects. The rest of the script is normal. Note that your script can be pretty much anything, but please beware of the recursion limits (i.e calling callasm and that ASM calling a script...ect..).

Once you've written the script, compile it to free space, and write down where you've compiled the script. Mine compiled to 0x740001 for example.


Setting up our Phase 2 routine -> The Rocket



Once you've compiled a suitable script, and tested the script individually to make sure it works, you're ready to set up your rocket. I call it Rocket because this routine will be the one calling the script.
It will also be the routine which is called by our launchpad routine. Anyways, more on that later.

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r4, lr}
	ldr r0, =(0x203B0A0)@selected mon
	ldrb r0, [r0, #0x9]
	ldr r1, =(0x20386E0) @oe state
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	str r0, [r1]
	ldr r0, =(0x8YYYYYY) @script pointer, don't +1
	ldr r4, =(0x8069AE4 +1)
	bl linker
	pop {r4, pc}
	
linker:
	bx r4
	
.align 2
In the above routine, you will need to modify the script pointer line. Change the YYYYYY into the offset your script was compiled into. Once you've done that, simply compile the routine into free space.
Once again, write down the offset in which you've compiled the routine into and make sure you've inserted this routine into a word aligned offset.


Setting up our Phase 1 routine -> The Launchpad



This routine is going to be our Phase 1 routine. This routine will do the initial checks we want and then call the rocket routine. Actually, this structure is a little weird, because you can just as easily fulfill it's functionalities within the second routine. I've yet to figure out the reason as to why this is, but it just is this way.

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {lr}
	ldr r1, =(0x3005024) @Phase 1
	ldr r0, =(0x81248B0 +1) @launch pase 2
	str r0, [r1]
	ldr r1, =(0x203B0C4) @Phase 2
	ldr r0, =(0x8YYYYYY) @Rocket routine
	str r0, [r1]
	mov r0, #0x1
	pop {r1}
	bx r1
	
.align 2
In the above routine, you will need to modify the Rocket routine line's "0x8YYYYYY" into a pointer to wherever you placed the Rocket 2 routine +1. Once you've done that compile this routine into free space. Make sure that this routine is compiled into a word aligned offset.

String setup



Our last task before modifying some tables is to set up the string descriptions which will be brought up when the move is hovered over. The first task is to create the string. My string will be,
"Makes it Sunny outside!". This in Hex is "C7D5DFD9E700DDE800CDE9E2E2ED00E3E9E8E7DDD8D9AB". Lastly, the game doesn't know how long or when the string ends. It's required that we specify this by using the string terminating character.
This in FireRed (and actually all ROMs in gen III) is 0xFF. So the string then becomes "C7D5DFD9E700DDE800CDE9E2E2ED00E3E9E8E7DDD8D9ABFF". If you're not sure how to convert an ASCII string to HEX without messing it up, then I'll tell you that there's a 1-1 correspondence between the two. Use this table to generate a string, or you can use this Python program I wrote (if you have Python).

Remember that the size of the string is also limited. I don't recall how many characters will fit before overflow, but keep it about 20 Characters long max.

Table:
Spoiler:

Code:
00= 
01=À
02=Á
03=Â
04=Ç
05=È
06=É
07=Ê
08=Ë
09=Ì
0B=Î
0C=Ï
0D=Ò
0E=Ó
0F=Ô
10=Œ
11=Ù
12=Ú
13=Û
14=Ñ
15=ß
16=à
17=á
19=ç
1A=è
1B=é
1C=ê
1D=ë
1E=ì
20=î
21=ï
22=ò
23=ó
24=ô
25=œ
26=ù
27=ú
28=û
29=ñ
2A=º
2B=ª
2D=&
2E=+
34=[Lv]
35==
36=;
51=¿
52=¡
53=[pk]
54=[mn]
55=[po]
56=[ké]
57=[bl]
58=[oc]
59=[k]
5A=Í
5B=%
5C=(
5D=)
68=â
6F=í
79=[U]
7A=[D]
7B=[L]
7C=[R]
85=<
86=>
A1=0
A2=1
A3=2
A4=3
A5=4
A6=5
A7=6
A8=7
A9=8
AA=9
AB=!
AC=?
AD=.
AE=-
AF=·
B0=[.]
B1=[""]
B2=""
B3=[']
B4='
B5=[m]
B6=[f]
B7=[$]
B8=,
B9=[x]
BA=/
BB=A
BC=B
BD=C
BE=D
BF=E
C0=F
C1=G
C2=H
C3=I
C4=J
C5=K
C6=L
C7=M
C8=N
C9=O
CA=P
CB=Q
CC=R
CD=S
CE=T
CF=U
D0=V
D1=W
D2=X
D3=Y
D4=Z
D5=a
D6=b
D7=c
D8=d
D9=e
DA=f
DB=g
DC=h
DD=i
DE=j
DF=k
E0=l
E1=m
E2=n
E3=o
E4=p
E5=q
E6=r
E7=s
E8=t
E9=u
EA=v
EB=w
EC=x
ED=y
EE=z
EF=[>]
F0=:
F1=Ä
F2=Ö
F3=Ü
F4=ä
F5=ö
F6=ü
F7=[u]
F8=[d]
F9=[l]
FA=\l
FB=\p
FC=\c
FD=\v
FE=\n
FF=\x
The Hex is on the left, and on the right is the Ascii equivalent.


Python program:
Spoiler:

Code:
with open('C:/-YOUR PATH TO THE TABLE FILE-/Table.txt') as f:
    lines = f.read().splitlines()
for i in range (0, len(lines)):
    lines[i] = lines[i].split('=')
convert = raw_input("enter string: ")
result = ""
check_version = raw_input('H2A or A2H?')
if (check_version == "1"):
    for char in convert:
        for element in lines:
            if element[1] == char:
                result += (element[0])
    print(result)
else:
    convert = convert.split(" ")
    for index in convert:
        for element in lines:
            if element[0] == index:
                result += (element[1])
    print(result)
For the prompts:
Prompt #1: Enter a hex or Ascii string
Prompt #2: 1 to convert to Hex; anything else to convert to Ascii.


Paste your Hex string into some free space in the ROM.

Next, we need to find our Move's name in hex. I recommend finding it in the Move name table at 0x247094. Here's a simple formula you can use to find it:
Offset = 0x247094 + (0xD * MoveID)
Where MoveID is the move index number. Pound is 0x1 for example. It should be noted that if you have expanded the move tables via MrDS's patch or on your own, that 0x247094 won't be the correct offset. Actually, I think his patch is bugged here because the BRM table uses points in the old table, which he couldn't possibly have repointed without knowing. Anyways, it doesn't prove a problem unless you plan to make one of the expanded move names to appear using the move name table. Write down the offset of your move name as well as the description pointer.

Editing the tables



Here are the important offsets you should have written:
Table 1-4 locations
Phase 1 routine: Launcher
Move Description pointer
Move Name pointer

Firstly, we're going to handle Table 1 first. This is a table of reversed half-word move IDs. The game reads these ID numbers using ldrh (load half-word) which internally reverses them. ldr is the same functionality, that why we need to reverse hex our routine pointers and various other things. Anyways, I'm getting off topic, so I'm going to explain what to do to this table.

The table itself is 0C 00 terminated, which is both weird and bad. Weird because 0xC is Guillotine, bad because someone may be interested in using Guillotine as a field move. So first of all, before we attempt anything, we'll be changing how the game reads this table, to terminate it upon reading 0x0 (which in the hex editor is 00 00 because it should be a half word), since 0x0 represents null move.

To do this, navigate to 0x122A8C and change the byte from 0C to 00.

Finally, edit your table to include the Move IDs of the field moves you want. My table for example looks like this right now:
Quote:
94 00 0F 00 13 00 46 00 39 00 F9 00 7F 00 64 00 5B 00 D0 00 87 00 E6 00 F0 00 59 00 57 00 C9 00 00 00
I've added after E6 00 (which is ID 0xE6 sweet scent) F0 00 59 00 57 00 C9 00 F1 00 00 00
F0: Rain dance, 59: Earthquake, 57: Thunder, C9: Sandstorm, F1: Sunny day. Then at the end I put in the "00 00" to show the end of the move detection table. Make sure your table is of similar format, except with the move IDs you want.

After these edits go in game, and check if your game freezes upon pressing "a" on the selected Pokemon. If it does, then your table is messed up OR you've messed up something with these last few steps. The expected result is that you get weird characters (or no chars at all) in blue if your Pokemon has a move whose ID is in the table. We will be fixing these "glitched" names and such soon. Don't try using the move outside of battle yet, because you will crash your game.


We're going to briefly skip table 2, and go onto table 3.
This table is a little weird, because it's not terminated at all. It's browsed using an index number. Generally the moves are at the bottom, and each successive move in the move ID table is 1 entry past the last entry. So in short, for every move we add the the move ID table (table 1) we need to add an entry to this table (table 3).

Table 3 is formatted: [4 bytes (Pointer to name)] [4 bytes (Pointer to Routine)]

If you're doing to launch a routine instead of a script, the pointer to routine will be your routine's address +1. The chances are, you're going to use a script though. So farmat your entries like this:
[Move name pointer (4 bytes)][081245A5 - BRM HM launching sequence].
Navigate to the word aligned offset you placed table 3 in, and add the following 8 bytes:
Code:
XX XX XX 08 A5 45 12 08
Where XX XX XX is a pointer to your moves name (which you should've written down prior). In my case, the hex was, "D1 C7 24 08 A5 45 12 08".

After these edits, test it again. This time the blue gibberish should've turned into a move name. If it hasn't, you've messed up somewhere above.

Now we'll edit table 2, this will make selecting the move actually do something.
Table 2 consists of a routine pointer that is called by the routine 081245A4, as well as a mode. 95% of the time this mode is 0xD (the other mode is 0x10 used for Milkdrink and Softboiled). The routine pointer is simply going to be a pointer to Phase 1 routine: Launcher (which you should have written down). Like table 3, this is browsed by index and isn't terminated by a byte or sequence of bytes. So simply add to the end of the table, the following hex string:
Code:
XX XX XX 08 0D 00 00 00
Where XX XX XX is a reverse hex pointer to Phase 1 routine: Launcher.

After these edits, test your game again. This time, everything should be fully functional. Routine should be called, and the whole effect should happen. If it doesn't, you've done something wrong in the above steps.

Finally, we're on the last step, it's to change the move description which pops up when the move is highlighted. The Move Description pointer which you should have written down is what I'm referring to.
In Table 4, simply append the move description pointer. That's it, you've successfully added a new field move!

My condition for using this hack


Unlike most hacks, this is a little different. It's open source, and you're free to use it. However, I require you post the script you use for any of your moves. This is because I want people to keep anything regarding this hack public.
Just post the script you use in your own thread, and that'll be it (like the Sunny Day script I used).
__________________
...
Reply With Quote
  #522   Link to this post, but load the entire thread.  
Old March 27th, 2015 (2:52 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924

Button detection in scripts




Intro:
There are a few hacks already existing which detect a button the player has pressed, but in my opinion they are a little over-complicated and unnecessary. There's a few RAM offsets which are allocated for I/O placed in the SuperState datastruture and keyinput bytes. However, reading these bytes in a script would give you the byte value in that specific frame. That's right, scripts run one command per frame (mostly. wait special, and other commands "pause" the cycle because the script pointer isn't updated). Anyways, inorder to do this, you'd need to write a task (which is also executed every frame) which detects a certain keypress. However, there already exists a command which pauses until a button is pressed. This command is the "waitbutton" command in PKSV or the "waitkeypress" command on XSE. We're going to be hacking this command to buffer the non-null button pressed into a variable.

How to insert:

First compile and insert into free space, the following routine
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	ldr r0, =(0x30030F0)
	ldrh r1, [r0, #0x2E] @byte in super state for keypress
	cmp r1, #0x0
	beq cont
	ldr r0, =(0x20370B8) @var 0x8000 location
	strh r1, [r0]
	ldr r4, =(0x806B922 +1)
	bx r4

cont:
	mov r0, #0x1
	and r0, r0, r1
	cmp r0, #0x0
	beq section
	ldr r1, =(0x806B922 +1)
	bx r1
	
section:
	ldr r0, =(0x806B8A6 +1)
	bx r0
	
.align 2


Now navigate to 0x6B89A and do the following byte changes:
Code:
 00 00 00 48 00 47 XX XX XX 08
Where XX XX XX is the pointer to wherever you inserted this routine +1

Usage:

Basically you just call the waitbutton command and then read the variable 0x8000 to see which button was pressed. Here's an example script:

Code:
#dyn 0x740000
#org @start
lock
faceplayer
msgbox @exit
callstd MSG_NORMAL
jump @loop

#org @loop
waitbutton
compare 0x8000 0x2
if != jump @start
msgbox @good
calllstd MSG_NORMAL
release
end

#org @exit
= You can't leave without\npressing "B"!!!

#org @good
= Alright, now you can go.
Here is what 0x8000 would yield depending on what was pressed.
Code:
Down: 0x80
Up:  0x40
Left: 0x20
Right: 0x10
A: 0x1
B: 0x2
Select: 0x4
Start: 0x8
Please note, if two keys are pressed at once or held at once, then 0x8000 will be the sum. I.e 0x8000 = 0x3 if A and B is pressed.
__________________
...
Reply With Quote
  #523   Link to this post, but load the entire thread.  
Old March 28th, 2015 (5:39 PM).
leyn09's Avatar
leyn09 leyn09 is offline
Truant Trainer
 
Join Date: May 2011
Location: Philippines
Gender: Male
Nature: Careful
Posts: 84
Quote:
Originally Posted by FBI agent View Post

Battle Modes!



Battle by turn:



This routine will run all of it's referenced routines at the end of the turn (right before the turn counter in incremented.

How to insert:
Look at the routine below. The last line .table has an incomplete pointer. It says 0x[pointer to routine table]. Find enough free space (takes 4 byte per routine) in your ROM and set the pointer for .table to that. You do not add +1 to the pointer, nor is it in reverse hex. Once you've fixed the pointer, compile the routine into free space.
Last entry in the table needs to be 00 00 00 00.

Credits to daniilS for helping with optimization.
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func
 
main:
        @check flag 0x2F8 to toggle routines (0xBE*4 = 0x2F8)
        mov r0, #0xBE
        lsl r0, r0, #0x2
        ldr r2, =(0x806E6D0 +1)
        bl linker
        cmp r0, #0x0
        beq skip
        ldr r4, .table
 
loop:
        ldr r2, [r4]
        cmp r2, #0x00
        beq skip
        bl linker @call table routine
        add r4, #0x4 @get next table routine
        b loop
       
skip:
        ldr r1, = 0x3004F90
        ldrb r0, [r1, #0x13]
        cmp r0, #0xFE
        bhi replacer
        add r0, #0x1
        strb r0, [r1, #0x13]
 
replacer:
        ldr r2, = (0x8013CBC + 1)
 
linker:
        bx r2
 
.align 2
 
.table:
        .word 0x[pointer to Routine table]


Now navigate to 0x13CB0 and insert the following byte changes:
Code:
00 48 00 47 XX XX XX 08

Usage:
The routine is toggled by flag 0x2F8. Activate the flag to toggle routines called by this routine. To add routines into the list of called routines, navigate to the pointer of freespace you made .table point to. Insert into that table pointers in reverse hex +1 to wherever you compiled the addon routines make sure they have the 0x8 prefix. The structure of the table should be: [routine pointer in reverse hex +1 (4 bytes)] for each pointer in the table. I.e if I put the addon at 0x740000, the pointer would read 01 00 74 08.

Battle by turn addons:



Sleeping clause:
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r3,lr}
	mov r2, #0x0 @pokemon counter
	mov r3, #0x0 @sleeping counter

loop:
	cmp r2, #0x5
	beq validateBattle
	ldr r0, =(0x202402C + 0x50)
	mov r1, #0x64
	mul r1, r1, r2
	add r0, r0, r1
	ldrb r0, [r0]
	lsl r0, r0, #0x5
	lsr r0, r0, #0x5
	cmp r0, #0x0 @check sleeping
	beq next
	add r3, r3, #0x1
next:
	add r2, r2, #0x1
	b loop

validateBattle:
	cmp r3, #0x1 @check amount sleeping <=1
	ble end
	ldr r0, =(0x2023E8A)
	mov r1, #0x5
	strb r1, [r0]	

end:
	pop {r0-r3, pc}
	
	
.align 2


Battle end by turn:
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r1,lr}
	ldr r0, =(0x20370CC)
	ldrb r0, [r0]
	ldr r1, =(0x3994FA3)
	ldrb r1, [r1]
	cmp r1, r0
	bne end
	ldr r0, =(0x2023E8A)
	mov r1, #0x5
	strb r1, [r0]	
end:
	pop {r0-r1, pc}
	
	
.align 2
I have a little problem with this sleep clause. As the post requires, I need to put battle by turn routine, the table pointer, and the sleep clause routine in my rom. So I put these in the following addresses:

1. Battle by turn routine: 850000
2. BbT table: 850040 (I already put at the first entry the sleep clause routine)
3. Sleep clause routine: 800050
Spoiler:


Then I insert 00 48 00 47 41 00 85 08 to 0x13cb0
Spoiler:


So, I'm about to test it but I'm not able to because whenever I battle a trainer/wild encountered pokemon, it freezes or restarts after the first round. Also, there are some cases of resetting when I encounter wild pokemon.

I direly in need of these sleeping clause. Btw, I used MrDollSteak Rom base and JPAN's fire red Hacked Engine.

Thanks in advance!
Reply With Quote
  #524   Link to this post, but load the entire thread.  
Old March 28th, 2015 (7:13 PM).
robinjea's Avatar
robinjea robinjea is offline
 
Join Date: Sep 2012
Age: 25
Gender: Male
Nature: Quirky
Posts: 534
Quote:
Originally Posted by FBI agent View Post

HP Regeneration per step



Intro:
Basically a routine to regenerate a Pokemon's HP every step. In this routine it's set to 3 per step. You may want to modify the exact amount to a percentage or something (see the commented line).

How to insert:

First compile and insert the following routine into free space.

Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
    push {r0-r7}
    ldr r0, =(0x2024284)
    mov r6, #0x0
    ldr r7, =(0x2024029)
    ldrb r7, [r7]

    
loop:
    cmp r6, r7
    beq end
    mov r1, #0x64
    mul r1, r1, r6
    add r0, r0, r1
    mov r5, r0
    mov r1, #0x39
    ldr r3, =(0x803FBE8 +1)
    bl linker
    mov r4, r0
    cmp r4, #0x0
    beq next
    mov r0, r5
    mov r1, #0x3A
    ldr r3, =(0x803FBE8 +1)
    bl linker
    add r6, r6, #0x1
    cmp r4, r0
    beq loop

addOn:
    add r4, r4, #0x3 @amount to add per step. Here it's 3
    cmp r4, r5
    ble cont
    mov r4, r5
    
cont:
    mov r0, r5
    mov r1, #0x39
    ldr r2, =(0x20370D0)
    strh r4, [r2]
    ldr r3, =(0x804037C)
    bl linker
    b loop
    
next:
    add r6, r6, #0x1
    b loop

end:
    pop {r0-r7}
    lsls r0, r0, #0x18
    lsrs r0, r0, #0x18
    cmp r0, #0x1
    beq brancher
    mov r0, r5
    ldr r1, =(0x806D600 +1)
    bx r1

brancher:
    ldr r0, =(0x806D650 +1)
    bx r0
    
linker:
    bx r3
    
.align 2


Now in a hex editor navigate to 0x6D5F6. There you will need to insert the following byte changes:
Code:
 01 4A 10 47 00 00 XX XX XX 08
Where XX XX XX is the pointer to where you inserted the above routine +1.

Usage:

There isn't any usage. It's automatically done. You can change the amount generated by reading the line in the code which I've commented.
I'm not sure why but I can't get this to compile. I get a message from the compiler like this:

Code:
Error: instruction not supported in Thumb16 mode -- 'lsls r0, r0, #0x18'
Error: instruction not supported in Thumb16 mode -- 'lsrs r0, r0, #0x18'
I don't know if that was a typo, or my compiler just came from the stone age. Please help.
Reply With Quote
  #525   Link to this post, but load the entire thread.  
Old March 28th, 2015 (7:31 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 robin22gongon View Post
I'm not sure why but I can't get this to compile. I get a message from the compiler like this:

Code:
Error: instruction not supported in Thumb16 mode -- 'lsls r0, r0, #0x18'
Error: instruction not supported in Thumb16 mode -- 'lsrs r0, r0, #0x18'
I don't know if that was a typo, or my compiler just came from the stone age. Please help.
I've fixed it. My brain went IDA mode when I wrote that, so accidentally did lsls instead of lsl, ect. :P
__________________
...
Reply With Quote
Reply

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

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 8:46 AM.