Welcome to the PokéCommunity!

Hi there! Thanks for visiting PokéCommunity. We’re a group of Pokémon fans dedicated to providing the best place on the Internet for discussing ideas and sharing fan-made content. Welcome! We’re glad you’re here.

In order to join our community we need you to create an account with us. Doing so will allow you to make posts, submit and view fan art and fan fiction, download fan-made games, and much more. It’s quick and easy; just click here and follow the instructions.

Research & DevelopmentGot a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. 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!

Research & Development programs in this forum are subject to moderator approval before they are displayed.

I would like to note that the general framework for these hacks were based on an idea that a Brazilian hacker had, his name escapes me right now, but some credit must be given to him/her!

These routines DO NOT support the new RTC and Day and Night Feature developed by Prime unless you use the same RAM offsets. Even if you do, I would ideally like to redevelop these routines to use the new system Prime has developed as it would be more efficient.

FireRed (Extensively Tested)

Spoiler:

First up is the routine which will make the wild Pokémon's level load correctly, rather than loading random garbage data after the repointing process is complete.

This routine performs a similar function to the level modification part from above. Changing the pointer to the wild data into a pointer to a table of pointers to wild data.

Insert the assembled routine and then modify the data at 0x08082B48 so that it repoints to the new routine's location plus 1:

Code:

00490847XXXXXX08

For the swarming code, you need to set the variable 0x4FFF to 0x2 or greater, and then set the variable 0x4FFE with the Pokémon number you want to be swarming.
eg. I want Taillow to swarm on Route 4:

Code:

setvar 0x4FFF 0x2
setvar 0x4FFE PKMN_TAILLOW
setvar 0x4FFD 0x68

The way the code works is that it always overwrites the standard Pokémon loading routine for the given map until you change one of the above parameters. How you do this is entirely up to you.

These 2 routines together allow you to have different pokémon at day and night, but read in more or less exactly the same way as before, meaning you can rely on it to produce common Pokémon more often than rare ones in the same way as any modified data in A-Map.

There is another, entirely optional, hack related to this, which is having different wild Pokémon encounter rates between day and night. This hack also reads the ability byte of your first Pokémon, looking for specific conditions to be met. If your lead Pokémon has certain abilities (the list isn't yet complete, and some of the effects still need some research) then the wild encounter rate can be halved or doubled. For all of the abilities listed below, they only apply if the Pokémon with the ability is in slot 1. Otherwise, it'll work as per usual.

Anyhoo, the game reads the encounter rate like so:
This is for Route 1, but all encounter rates are stored in the same style:

Code:

DD 00 00 00

But it only reads the first byte of this. What a waste of space! So, I figured we could use this space to store upto an extra 3 encounter rates, making a total of 4 for every map! (Remember, the maximum encounter rate is 255 or 0xFF, meaning that even with all of them set to maximum, it will fit in here snugly. :D

This code makes the bytes following the normal encounter rate become encounter rates too, separate from the normal one, and only read when the hour byte is above or below a certain value.

Where one again, the XXXXXX is the reverse hex pointer to the new routine's location.

So, it marks them out like so for the 4 time set up I have created.

Code:

DD MM EE NN

I left the day encounter rate at the start in order to have the routine be as compatible with the original rom's data as possible.

Anyway, the code reads this byte, then runs some simple checks (credit for that particular part of the code goes to HackMew as it is taken almost wholesale from his Flame Body hack, which I suggest you all try out!), and based on the results of these checks, either halves, doubles, or continues with the given encounter rate. It then returns to the original routine for writing to memory.

OK, now a quick lesson on how to get the tables set up right.
Again, for a benchmark I'll use Route 1's data, but it can be expanded to every single wild data table in the game.

This is the Route 1 grass wild data as standard in the rom:

Code:

15 00 00 00 60 8E 3C 08

In order for the game to read this properly with the new routines, you need to repoint the pointer to a free space location in the rom. A good location for this would be 0x08B00000 as it's empty and has more than enough free space to hold the new data.

So, at 0xB00000, copy and paste the pointer to the original wild data. This will serve as our daytime data. Then after it, place another pointer to an empty area of the rom. Anywhere will do, as long as you have enough free space to put the correct number of wild Pokémon in. That will make it work, although you should obviously fill the new table with Pokémon data. This new table serves as our night time data. So, now whenever we encounter a wild Pokémon at night, it'll be loaded from the night time data, rather than the day time data.

Here is one final, separate routine which writes the map you are currently in and the weather on said map to a ram offset so that the routines above can use them to determine whether certain conditional modifications should be activated. (This is because I couldn't find either written to the ram although they are obviously written to the ram at some point by the actual routine).

In order for this to work properly, you need to update the RTC's time appropriately. But how to do this when Emerald only calls the time update routine when warping or connecting? Use the code shown in this post: http://www.pokecommunity.com/showpost.php?p=6395043&postcount=41. If you use that code and patch the time update routine onto the main loop of the game, the time updates once every frame! This means it works more like interdpth's RTC code for FireRed. A much better solution IMHO.

Ruby (Not Started Yet)

Spoiler:

__________________

Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

:D I've been working on the tool so far got the GUI down got most of the code but running into a few bugs will post it here and the tool section when i've finished doing it preview attatched as an attatchment

1. Make the window smaller, or items bigger. There is too much empty space
2. More options, if possible and simpler user interface. Instead of making them insert hex, make the program convert it to hex.
3.Why make a program? If you do that, then D/N Pokemon will be less common.

What this does is it checks for an 08 3 bytes after r0, which would be where your day pointer is. If not, it uses the pokemon table as normal data, like the game normally would. The byte that is actually checked is the flipped byte of the pokemon's species. Luckily, no pokemon goes over the number 2,048, so the check works. Another check you could add is to, instead of loading another pokemon data table, check the byte loaded into r0 after this instruction:

Code:

ldrh r0, [r0, #0x2]

This loads the pokemon's data, and once loaded, it can be checked. So let's say we wanted a pidgey to turn into a hoothoot. You could add this to next:

Also, It's pretty tedious to hex edit pokemon, so I'm going to create a tool sometime. It's not too hard in fact, since it's such a simple format:

Code:

[MinLV][MaxLV][Species][Species]

edit: I've also added backward support for the levels. Simply add this before pushing r0 at the beginning:

Code:

ldrb r2, [r2, #0x3]
cmp r2, #0x8
bne nextnormal

Add nextnormal to the second line in next:

Code:

next: ldr r0, [r0, #0x0] /*Loads the word stored at the location pointed to in R0, the pointer to the wild data*/
nextnormal:add r0, r4, r0 /*Adds the number of bytes from the start of the table that the wild Pokémon slot the game has selected is*/
add r4, r0, #0x0 /*Adds the contents of R0 into R4*/
ldrb r0, [r4, #0x1] /*Loads the upper level limit for the Pokémon if they're stored systematically*/
...

This essentially does the same thing as before. It checks if the pointer exists, and if not, it treats the table data as the normal pokemon data.

What this does is it checks for an 08 3 bytes after r0, which would be where your day pointer is. If not, it uses the pokemon table as normal data, like the game normally would. The byte that is actually checked is the flipped byte of the pokemon's species. Luckily, no pokemon goes over the number 2,048, so the check works. Another check you could add is to, instead of loading another pokemon data table, check the byte loaded into r0 after this instruction:

Code:

ldrh r0, [r0, #0x2]

This loads the pokemon's data, and once loaded, it can be checked. So let's say we wanted a pidgey to turn into a hoothoot. You could add this to next:

Also, It's pretty tedious to hex edit pokemon, so I'm going to create a tool sometime. It's not too hard in fact, since it's such a simple format:

Code:

[MinLV][MaxLV][Species][Species]

edit: I've also added backward support for the levels. Simply add this before pushing r0 at the beginning:

Code:

ldrb r2, [r2, #0x3]
cmp r2, #0x8
bne nextnormal

Add nextnormal to the second line in next:

Code:

next: ldr r0, [r0, #0x0] /*Loads the word stored at the location pointed to in R0, the pointer to the wild data*/
nextnormal:add r0, r4, r0 /*Adds the number of bytes from the start of the table that the wild Pokémon slot the game has selected is*/
add r4, r0, #0x0 /*Adds the contents of R0 into R4*/
ldrb r0, [r4, #0x1] /*Loads the upper level limit for the Pokémon if they're stored systematically*/
...

This essentially does the same thing as before. It checks if the pointer exists, and if not, it treats the table data as the normal pokemon data.

Since emerald is based off of fire red, it was actually only a search for a few bytes. The routine is at 080b4c76 for the level routine. However, it may be loaded differently, so I'll have to check if it's safe.

edit: Actually, the code from all games is exactly the same, except for when the data is written. Here are the level offsets:

Code:

Emerald: 080b4c76
Ruby: 08084d32

Unfortunatly, the wild data loading is very different. I'll have to dive a bit deeper on that one.

Adding morning would be very easy. In fact I originally developed it to support 4 times of day, morning, day, evening and night, but decided to cut it down for use as it takes a lot of work to manually hex edit the Pokémon in. As for Emerald support, I guess I could have a look and see if I can apply the principle, if not necessarily the exact same routine, to the rom. Although in order for me to do that, someone would need to supply me with the ram location of the RTC in an Emerald rom, as, unlike FR, it already has an RTC built in so I can't just look at the inserted routine of the D/N routine.

__________________

Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

Adding morning would be very easy. In fact I originally developed it to support 4 times of day, morning, day, evening and night, but decided to cut it down for use as it takes a lot of work to manually hex edit the Pokémon in. As for Emerald support, I guess I could have a look and see if I can apply the principle, if not necessarily the exact same routine, to the rom. Although in order for me to do that, someone would need to supply me with the ram location of the RTC in an Emerald rom, as, unlike FR, it already has an RTC built in so I can't just look at the inserted routine of the D/N routine.

Yeah, I'll be doing morning, and I'm developing a wild pokemon data editor for this D/N System. I'll post some pics later. As for the RTC, I'm sure ColColStyles might know it, since he does a lot of emerald hacking.

I look forward to seeing this tool, for my own use as well as for other XD :D.

I, in the mean time, will endeavour to port the code over to as many versions of the roms as I can. I'll start by extending support to Ruby and Emerald's english versions, and then go from there. Hopefully, the routines will be in exactly the same place for other language roms, thus requiring no modification. The routines should, in theory, be identical, if not necessarily in exactly the same place.

And I asked colcolstyles for any info he may have on the RTC in Emerald, hopefully he'll be able to provide me with at least a starting point to go from :D

__________________

Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

I look forward to seeing this tool, for my own use as well as for other XD :D.

I, in the mean time, will endeavour to port the code over to as many versions of the roms as I can. I'll start by extending support to Ruby and Emerald's english versions, and then go from there. Hopefully, the routines will be in exactly the same place for other language roms, thus requiring no modification. The routines should, in theory, be identical, if not necessarily in exactly the same place.

And I asked colcolstyles for any info he may have on the RTC in Emerald, hopefully he'll be able to provide me with at least a starting point to go from :D

I know it's not in exactly the same place between Ruby, FireRed and Emerald, but it may be in exactly the same locations in an English Fire Red rom and a Spanish Fire Red rom. I'll need to have a look. I don't expect them to be, but they'll more than likely be very similarly placed, and the actual routine should (in theory) be identical. So no rewriting for a Spanish rom, simply insert at a different location. I will have to rewrite the routines to work with Emerald after having a quick look at the offsets posted by shiny quagsire, but only because it uses different registers. I couldn't get Ruby to open in VHA-SDL-H (probably a messed up rom) but I'll have a look shortly.

__________________

Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

Alrighty! I've finally finished DN Pokemon Data Editor! The download is in an attachment as a zip file. Keep in mind this is only in it's early versions, and may have a bug in it. If you find a bug, contact me by way of PM.

I have an idea for the tool. How about instead of having the Pokemons names listed alphabetically, have the names of Pokemon from the rom listed by their pokedex order? Because I inserted a fakemon over another Pokemon, and since it's name isn't there, I can't remember which Pokemon I replaced, and the Pokemon are listed alphabetically, it makes it hard to find :\

Edit: For some reason it freezes when I run into a wild Pokemon at night :\

I THOUGHT I had the offset for the time in Emerald! I looked through my notes, and here it is: 0x03005CFA.
The reason that you probably didn't find it is probably that it doesn't update unless you do special things, like entering a new map, using a command\special that causes the time to be reloaded, etc.

The PokéCommunity

Meta

Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, or The Pokémon Company International. We just love Pokémon.