How to Port Codes to other Regions
#1
How to Port Codes to other Regions

Requirements:
- Hex Editor**
- RAM Dumps*** (you will need at least the RAM Dump of the region you are porting from and the region you are porting to)

**I recommend HxD. HxD is used in this guide. You can find it very easily on a google search for free download. If you are a Linux User, you will need Wine emulation to run HxD as HxD is natively for Windows.

***If you don't have RAM Dumps, contact me via discord (zakmkw#8365)





Chapter 1: Introduction

We will start off with the NTSC-U Show Item Early Code, we want to port our code to PAL. Now you could use an Auto Porter, but about 20% of the time, auto porters fail. Or in other instances, the auto porter will port most of the code correctly and it still works, but this is technically incorrect and could cause issues.

I chose the Show Item Early Code for this guide since ASM (C2 type) codes are not as simple as 32-bit (04 type) codes but still easy enough for any beginner to grasp quickly. Basically in 95% of all codes, the C2 and 04 lines are what need to be ported. All other lines remain the same. There are other codes where this isn't the case but this guide is meant for beginners.



Chapter 2: Finding Location of Code's Address in RAM

Your hex editor should be open , now open your RAM Dump file for NTSC-U/RMCE01. We always start off with the RAM Dump version that matches the region of code we are starting with.

So our NTSC-U Show Item Early code is...
C27AB9D4 00000002
807F0020 907F001C
60000000 00000000

What we want to do is find the RAM Address (offset & column location) where the Code is at. To figure this out simply take out the first 2 digits off the first line of the code. Since the other two lines are not C2/04 type, we leave them be. If you did the conversion correctly, you should come up with a RAM address value of...

7AB9D4

On you hex editor, press CTRL+G. a prompt will appear to enter in an offset to search for, paste in that number and be sure number/data type is in Hexadecimal (Hex)

Click OK and HXD will navigate you to row address 007AB9D0 under column 4. The last digit of a code RAM address is the column number value. You can also you use this conversion in reverse to change a RAM row+column location to a code address which is what we will do later in the guide.



Chapter 3: String Searching

What you need to do is highlight the first 4 bytes (8 digits) of code beginning where your cursor was navigated to. If done correctly you should have highlighted the following hex string...

90 7F 00 1C

You will notice that this string of hex matches the second half of the second line of the Show item early code. For 99% of C2 codes this will always be correct, but don't rely on it just in case you come across a rare C2 type code that doesn't follow those circumstances. Obviously this can't be done on 04 type codes.

Highlight the 90 7F 00 1C and type CTRL+C.

Now open the PAL RAM Dump.bin file on your Hex editor, HxD will add it as a new tab. You should automatically be in the PAL Ram dump now, if not click on the tab to be in it.

Now type CTRL+F and a prompt will appear. For the "Search for" field, paste in what you just copied. Change datatype to Hex. Click OK.

If done correctly, you will be brought to offset 000F4410 under column C. Right off the bat, I will you that this is the wrong address. If you have compared regions of codes before you will now that regions differ in addresses but not by too much. If we used this 000F4410 offset column C our PAL first line of Code would be converted to C20F441C, which is a Huge difference compared to the USA Code which means it's obviously wrong. 

There are many many many instances where a 4 byte string of hex is repeated in MKWii RAM. Sometimes, you only need to use a 4 byte string to find your address, other times you may need to copy something as long as 32 bytes. It all depends on the code.

Lets go back to our NTSC-U RAM Dump file. This time highlight the first 12 bytes (24 digits of code). You should have a hex string of...

90 7F 00 1C 88 1F 00 2D 2C 00 00 00

Copy that string. Go back to PAL RAM Dump file. Hit CTRL+F, paste in the new 12 byte string. However, we want to change search direction from "Forward" to "All". Since we searched in PAL RAM earlier, we are no longer at the very beginning of the PAL RAM Dump file. So we need the "All" search direction to tell HxD to search both ways from out current spot in PAL RAM. Click OK.

You will be navigated to the row of 007BA430 under Column 04. If we convert that to a usable C2 address , we get C27BA434. As you can see, this is slightly different than the USA address. Chances are, this address is the correct one. What you want to also do is compare the surrounding random numbers of both RAM Dumps, they should be very identical (doesn't have to be exactly the same). If it is, there's a very good chance the address is correct. So now you have the C2 line for PAL, complete the rest of the code....

PAL Show Item Early
C27BA434 00000002
807F0020 907F001C
60000000 00000000



Chapter 4: Testing; Conclusion

Test the code, if it works, success! (which this one does work as I've tested it myself). If your porting does not work, you need to research that string of hex again (try longer strings or you can hit F3 for the search next similiar result until you see that the surround RAM is similar when comparing both RAM Dumps)

Conclusion: I know this is a lot to take in, but once you grasp the concept that this is nothing more than copying RAM and searching it on a different region, then this will become very easy for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)