How to Make your own Cheat Codes
#1
How to Make your own Cheat Codes

This guide will teach you how to become an actual real Code Creator. You will use what is called the Dolphin Emulator to make your codes. The Dolphin Emulator is software installed on your computer meant to emulate the Wii Console and its games.

IMPORTANT: This guide shows the steps on re-creating a primitive version of a cheat code (Insert ASM Gecko code aka C2 code) in MKWii I personally made during my early days of learning how to create codes. It's not important to worry about having the ability to exactly mimic the creation of this code (considering the fact there may be readers here who don't own MKWii and want to make codes for other Wii games). What's important is to understand how the code was made (methods & tools used) and know how to apply that methodology to other codes that you desire to make in the future.

Chapter 1. Requirements

- A computer with decent specs (at least 8GB of RAM, and a recent/new-gen i5 processor, preferably an i7 or something similar)
- (Recommended)**: A Wii or Wii U console already capable of letting you play your Wii games with cheat codes

**Certain codes may not work in Dolphin or a code could work on Dolphin but not on the Wii/Wii U Console. At the end of the day Dolphin is just an emulator. It is impossible for Dolphin to 100% replicate the Wii Console entirely. Therefore it's recommended to have some sort of Console so you can test your new codes on both the Console and Dolphin.

All other requirements:
Know basic/simple Cheat Code Documentation - http://mkwii.com/showthread.php?tid=434
Know how create activators and deactivators for Codes (not needed if you don't care about adding activators + deactivators for your codes) - http://mkwii.com/showthread.php?tid=68
Know how to port Codes (not needed if you don't care about making your codes work on other regions/versions) - http://mkwii.com/showthread.php?tid=113


Chapter 2. Installing Dolphin & Aldelaro5's Dolphin-memory-engine

Dolphin Installation Guide - http://mkwii.com/showthread.php?tid=625

Once Dolphin has been installed and you can run your Wii games at 60fps, you will need to install Aldelaro5's Dolphin-memory-engine.

Dolphin-memory-engine Installation guide - http://mkwii.com/showthread.php?tid=626

Chapter 3. Overview of Dolphin

Dolphin comes with a debugger mode. There are a variety of panels/tabs that come with the debugger mode. However, we will only be focusing on the following three:
Breakpoints
Code (will be called Code View in this guide)
Registers

There is another panel/tab called Memory to view the game's memory, but we will use Aldelaro5's Dolphin-memory-engine instead because Dolphin's memory view is not live.

How to Launch the Debug Mode (Windows):
Go to the folder where your Dolphin application file is at. Do Shift+Right click inside that folder. Command prompt will appear. Now just type "Dolphin.exe -d" (without the quotations, be sure the D in Dolphin is capitalized).

How to Launch the Debug Mode (Linux): 
Type this command in your terminal:  "dolphin-emu -d" (without the quotations)

NOTE: Later versions of Dolphin (10xxx and beyond) don't require manual booting of the debugger mode. Launch Dolphin normally, click options, click the Interface tab. And select (checkmark) the 'Show Debugging UI' option.

---

Once Dolphin Debugger Mode has launched: At the top, click on View, you will see a list of features including the ones I mentioned earlier. Select the following: Breakpoints, Code View, and Registers. It's recommended you click on each tab/panel and hold/drag them, so they each become their own 'window'. This will allow you to view all 3 of these tabs/panels at the same time.

---

Breakpoints:

http://mkwii.com/pics/screenshots/Breakpoint.png

This is how all codes begin. A user sets a breakpoint thinking that breakpoint will effect a certain instruction of the game. If their guess is correct, the game will pause and they would work from there.

There are two main breakpoints: Instruction & Memory

Without going into too much detail...

Instruction Breakpoints are used when you are working on an existing ASM Gecko code (want to modify it). You use these on static memory.

Memory Breakpoints are used when you are making a new code from scratch. You use these on dynamic memory.

Code View:

http://mkwii.com/pics/screenshots/CodeView.png

Dolphin should already be running, boot your MKWii ISO/WBFS. Once it has booted, pause the game. You can now see the Code View.

The Code View lets you view a section of the game's ASM instructions. It takes the compiled hex byte code of the game's memory and decompiles it all to readable ASM instructions, so you know what instructions are being executed at every static memory address. The code view can only be seen when the emulation is paused.

Registers:

http://mkwii.com/pics/screenshots/Registers.png

Your game should still be paused (unless you have un-paused it yourself). This panel will allow you to view the values of all the Registers. The Register tab can be viewed at anytime, BUT it only updates the values when the game has been paused.

Chapter 4. Overview of Dolphin-memory-engine

Dolphin should already be opened with your game paused. Launch Dolphin-memory-engine.

Picture - http://mkwii.com/pics/screenshots/RAMViewer.png

Pic of Dolphin-memory-engine with the Memory Viewer opened while MKWii is playing - http://mkwii.com/pics/screenshots/LiveViewMemory.png

Overview of Dolphin-memory-engine:
First scan = Initiates a search in memory (changes to two options of Next Scan and Reset Scan once a first scan has been issued)
Byte w/ drop down arrow = List of options to specify the length of the data that will be searched
Exact Value w/ drop down arrow = List of options for conditional searching
Empty Field bar immediately underneath = The data/value to search for

The Memory Viewer button opens up a new tab that shows a live view of a particular region of the Game's Memory. The large left hand box displays the results (memory addresses) of your scans. The bottom box will contain results that you decide to add into it and can save them for later use. The rest of program is pretty much self-explanatory.

Pic of many panels (game paused) - http://mkwii.com/pics/screenshots/AllPanels.png

Chapter 5. PowerPC Compiler

http://mkwii.org/pics/screenshots/codewrite.png

You need a compiler to transform your PowerPC instructions into usable ASM Gecko codes. Unfortunately, dolphin doesn't come with an ASM Gecko Code compiler. We will use the CodeWrite compiler. It is the easiest to install.

Download CodeWrite - HERE (Linux users will need the Wine emulator to run it)

Move the zip package to a desired folder. Extract/unzip the package. Launch the Codewrite.exe file. This is the compiler.

The left hand box is where you would write your ASM instructions from scratch! The right hand box is the result of the compilation into an ASM Gecko Code. If you have some ASM instructions in the left hand box and hit the right arrow key, your code will be compiled. If there are any errors on your part, the code will not compile and the program will give a broad answer on why the compilation fail.

Obviously, you can insert an already made ASM Gecko code in the right hand box, and then decompile it by hitting the left arrow button. Finally, Insertion Address is for your code's address.

Can't get CodeWrite compiler to launch on your computer?
There is another compiler called PyiiASMH, it has more features, but requires other files to be installed on your computer beforehand. Guide to install PyiiASMH - https://mkwii.com/showthread.php?tid=1529 When compiling with PyiiASMH, be sure the 'C2/D2' option is checked.

Chapter 6. PowerPC Assembly

Before continuing any further in this guide, you MUST learn PowerPC Assembly language. There's no way around it.

When you read the thread... you MUST ACTUALLY READ THE THREAD! Don't be inpatient and 'skim' through just looking for things that catch your eye. You have to buckle down and take the time to read everything.

Assembly Tutorial - http://mkwii.com/showthread.php?tid=940

Chapter 7. Making your first code (Pt 1)

Let's get Started!

Alright for this guide, we want to make a code to that forces our CC mode chosen in Grand Prix in MKWii regardless of what we select in the game.

Launch Dolphin debugger mode, bring up the Code View, Breakpoints, and Registers. Boot your game first then launch Dolphin-memory-engine. On the memory-engine, click the Memory Viewer button to launch the live view of the game's memory.

Select any license, choose Single Player, choose Grand Prix. At this point you will see options for 50cc, 100cc, 150cc (and Mirror Mode if it's unlocked). Whenever you make codes, sometimes you will need to do some brainstorming or guess work on what numerical values the game uses for various items. For what we are working on, we will make the assumption that the game uses the value '0' for 50cc, '1' for 100cc, and '2' for 150cc.

Select the 50cc option! You should now be at the character select screen.

On Dolphin-memory-engine, make sure Byte is selected on the drop down menu. Change 'Base to Use' from Decimal to Hex. Enter 0 for the search field.

Click First Scan!

The memory-engine will scan for any instance of the hex byte value of '00' in memory. Obviously, we will have millions of results. The objective is to narrow down those results down to a few, and work from there. Let's say we end up with around 5 million results, way too many results. In fact, there's so many results, the memory-engine will not even bother listing them.

Exit out of the character selection screen back to the Grand Prix CC selection screen. Select 100cc option!

On Dolphin-memory-engine, change the value of 0 to 1.

Click Next Scan!

The Next Scan feature will use your current 5 million results and rerun the search using '01' this time, thus eliminating any of the '00' results.

Now we are down to about 5000 results. This list is still to large. Exit out of the character selection screen again. Select the 150cc option! Change the byte value from 1 to 2. Click NEXT scan to further narrow down the list.

At this point you should have under 100 results. Exit out of the character selection screen one more time. Now just repeatedly hit NEXT Scan on Dolphin-memory-engine. Keep doing this until the list gets down to 3 results. It will be 3 mem90 results if you did everything correctly.

Mem90 addresses are dynamic memory addresses, meaning if you did this guide again and again those 3 addresses will be slightly different every time, this is normal.

When I did this for the sake of making this tutorial, I had these addresses:
9023BC6F
9023BC7F
90A26E7F


Please remember that your list will be slightly different than mine! Your addresses should still be in mem90 like the list shown.

Click the 'Add All' button in Dolphin-memory-engine to put all the addresses in the lower box.

Right click on your first address (9023BC6F), and select 'Browse memory at this address'. Your memory viewer will auto navigate to that address. In your memory viewer, the byte value (02) will be at that address. It will at the very top left and highlighted in blue.

Now that we have our list of addresses, it's time to use our Breakpoints! Obviously, we will start with the first address on the list (spoiler alert: this address is the one that will work for making this code). Keep in mind that in many cases, the first address listed will not pan out in making your desired code.


It's Breakpoint time!

Go to your Breakpoints tab. Click the New button. Select Memory Breakpoint. Address will be auto selected, while the other option is Range. Leave it selected on Address.

Set the Address value to 9023BC6F

Condition will be auto selected on Write. Let's talk about Read Vs Write Breakpoints before continuing any further:

Which one do we set? Read or Write? Well this all depends on the scenario. Let's say you have a value in memory, and you know that the game reads said value later on during a certain event in the game. Well, you would use a Read Breakpoint because we want to know what address/instruction that's read the value before utilizing it.

Let's say we have a value that changes while you are in the race, or changes periodically after certain events in the game, or a value that's constantly changing nonstop. We would use a Write Breakpoint because we need to figure out what address/instruction in memory is writing the value.

Just use some common sense, that's all. We will set a Write Breakpoint to make our code. We want to know what address/instruction is responsible for writing the byte value that we have been searching for.

---

Referring back to the Breakpoints Tab. Leave the condition to Write. Action will be auto selected on 'Write to Log and Break'. Change it to 'Break'.

CLICK OK!

As long as you have followed everything step by step, you should currently be at the Grand Prix CC selection screen pre-selected on 150cc. Simply select 150cc again.

The game will instantly pause, and we will be able to see the Code View. If the game doesn't pause, your assumptions were incorrect and the Breakpoint failed. Remember, you will fail a lot when making codes! Re-read the earlier steps and try again.

Take a look at your Code View. The address that the game 'broke' on will be highlighted in GREEN.

The address that the game broke on should be one of the following 4 (depending no what region of MKWii you are using)

NTSC-U = 8082509C
PAL = 8083FAFC
NTSC-J = 8083F168
NTSC-K = 8082DEBC


The address has this instruction: stw r0, 0x175C (r5)

This is called the default instruction. If a coder was to say what's the default instruction of your code? You now know what that coder is referring to.

Chapter 8. Making your first code (Pt 2)

Alright at this point, you now have the address you need for making the code, and we have the address's default instruction. We can now move onto to actually making/writing the code.

So we have our code's default instruction: stw r0, 0x175C (r5)

Let's break it down.

stw = Store the Word
The game is deciding to use an entire word value (instead of just storing a byte) to store the CC value to memory. This isn't an issue at all, just something to note.

stw r0 = Store the Word of Register 0
Go to your Registers tab. Take a look at what is in r0. It's 00000002! The last value that you had searched for on Dolphin-memory-engine (for 150cc selection).

stw r0, 0x175C (r5)
Store the Word of r0 (CC value) to the memory address of r5+0x175C. Take the value of r5 and add 0x175C (use a hex calculator). Guess what value it is? It's the address value you used to set the Write Breakpoint!

This instruction is telling us that we our storing the CC selection word value to dynamic memory (mem90).

Our goal is to modify this r0 value before the instruction writes it to memory.


TIME TO WRITE SOME ASM!

First, we need to manually change the value of r0. We do this with a simple Load Immediate instruction. From reading the ASM tutorial, you should know how to do this.

li r0, X

X being the position value you want to apply to r0. We can use 0, 1, or 2. Let's use the value of 0 to force 50cc.

li r0, 0

Alright, we have r0 set to the value we want, now all we need to do for the next instruction is use the address's original instruction to allow the forced 50cc value to be written to memory.

So we have the following two instructions...

li r0, 0
stw r0, 0x175C (r5)

CAUTION: in MOST codes you will need to have the default instruction, or else you could break some other function of the game or the code might not work at all.

Open up CodeWrite! Time to compile!

Put the two instructions into the large lefthand box. The green highlighted address from the Code View goes into the Insert Address field (the Mem80 address, NOT the Mem90 address!)

Click the right arrow button to compile the ASM!

C283FAFC 00000002 #Example compilation of PAL version of code
38000000 9005175C
60000000 00000000

Let's break down the compilation one word at a time.

C283FAFC = The C2 byte is for the Gecko code handler to designate an Insert ASM Code. The 83FAFC is for the static memory address 8083FAFC.
00000002 = The amount of lines (in hex) below.
38000000 = li r0, 0
9005175C = stw r0, 0x175C (r5); default instruction
60000000 = nop; auto added by the compiler so compiled code can have odd amount of instructions
00000000 = For the code handler to know it's the end of the code, all Insert ASM codes will have a final word of 00000000

You can remove the final '0' on '38000000' and plug in an 'X' value to allow you to force a different CC option, since the CC value can only be 0, 1, or 2.

PAL Force CC Selection on Grand Prix
C283FAFC 00000002
3800000X 9005175C
60000000 00000000

Keep in mind this is a primitive version. A better version (that allows utilizing Mirror Mode in other CC's) is located HERE Feel free to analyze the better version if you want to take a crack to learn how I was able to add more features.

Chapter 9. Testing Your Codes

Read this thread HERE to learn how to apply cheat codes in Dolphin.

Testing codes can be annoying at times, but thorough testing is always recommended.  Some codes won't work on Dolphin or a code could work in Dolphin but not on the Wii/Wii U Console. If possible, test your codes on both Dolphin and Console.
Reply
#2
While USB Geckos are superior, finding one is quite the challenge. Luckily, we have Dolphin and a RAM Viewer made by person named Aldelaro5.

You CANNOT use a public/stable release. Those versions are VERY outdated, making codes with those types of dolphins is simply not possible.

1. Download the latest dev version of Dolphin HERE.

2. Once Downloaded, open the zip folder, there you will find a folder named: "Dolphin-x64" (for 64 bit versions.

3. Open the Folder and Run the application named "Dolphin"

Second, you need the RAM Viewer.

1. Download the latest version of aldelaro5's dolphin memory engine (This will prompt an auto download) HERE


2. open the zip folder, and put the folder entitled "Windows" wherever you want.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Simply:

1. Run Dolphin with your iso

2. Open the memory engine, and click "hook"

Good Job xD
Reply
#3
Windows support added!

Thank you Phyz!
Reply
#4
Great tutorial! Very detailed and helpful to people like me who wanna get better and more experienced in this kind of stuff. Unfortunately when I try to run Dolphin in debugger mode, it loads up, then the application crashes 5 seconds later... Idk why it happens, but I checked to see all my settings were correct and they were. I tried it 2 days ago. I woke up just now from sleeping and I remembered to say this. Gonna sleep again now goodnight.
Reply
#5
Are you on Windows? if so, what processor are you using? You will need a modern i5 or better w/ a decent graphics card.

If you have a good processor plus graphics card, head over to the Dolphin forums for assistance.

On Linux (base debian), I can strip the OS down so much, that I can get Dolphin to run on an old Windows 8 laptop w/ a crapshoot AMD E-300 processor.
Reply
#6
How to run Dolphin debug mode in Windows:

1. Go to the folder where Dolphin is found

2. Right click on the Dolphin application and click "Create Shortcut"

3. Right click on the new shortcut, and click properties

4. the "Target:" will be highlighted blue

5. Un-highlight and move the keyboard to the right of the quotations, which should end with Dolphin.exe"

6. Creat a space after the quote, and type: "-d"

The Targe should now look like: "C:\Users\Santoro\Desktop\Code Dev\Dolphin-x64\Dolphin.exe" -d

7. Click "Apply"

8. Click Ok

9. Run the shortcut, and Dolphin Debugger should come up.

10. Go to "View" (On the drop-down menu)

11. Select "Code", "Registers", and "BreakPoints"

12. Now, Run MKWii, and learn how to make Breakpoints, glance at some registers, and try to read some ASM.

Congrats
Reply
#7
^That's exactly what my steps in the Tut already do but with much much less steps.

Whenever you shift+right click in a directory/folder on windows, the command prompt opens up in that directory. Thus, on my part of the tut, it says just type "Dolphin.exe -d" which would do exactly what you are saying.
Reply
#8
(08-17-2018, 05:58 PM)Vega Wrote: Are you on Windows? if so, what processor are you using? You will need a modern i5 or better w/ a decent graphics card.

If you have a good processor plus graphics card, head over to the Dolphin forums for assistance.

On Linux (base debian), I can strip the OS down so much, that I can get Dolphin to run on an old Windows 8 laptop w/ a crapshoot AMD E-300 processor.

Yes. Windows 10 Pro. I have a gaming PC HP Omen i7 Octa Core, 8 GB RAM 1TB HDD, Nividia GeForce GTX I forgot the number, but you get the point. I don't have the vcredist x64 installed tho. Could that be the reason why it is crashing?
Reply
#9
(08-19-2018, 01:07 AM)420 Matt Wrote:
(08-17-2018, 05:58 PM)Vega Wrote: Are you on Windows? if so, what processor are you using? You will need a modern i5 or better w/ a decent graphics card.

If you have a good processor plus graphics card, head over to the Dolphin forums for assistance.

On Linux (base debian), I can strip the OS down so much, that I can get Dolphin to run on an old Windows 8 laptop w/ a crapshoot AMD E-300 processor.

Yes. Windows 10 Pro. I have a gaming PC HP Omen i7 Octa Core, 8 GB RAM 1TB HDD, Nividia GeForce GTX I forgot the number, but you get the point. I don't have the vcredist x64 installed tho. Could that be the reason why it is crashing?

Could be. It's what the Dolphin Devs recommend to install if your Dolphin cannot boot, or is crashing constantly. The link is posted directly on their downloads page - https://dolphin-emu.org/download/
Reply
#10
(08-19-2018, 02:28 PM)Vega Wrote:
(08-19-2018, 01:07 AM)420 Matt Wrote:
(08-17-2018, 05:58 PM)Vega Wrote: Are you on Windows? if so, what processor are you using? You will need a modern i5 or better w/ a decent graphics card.

If you have a good processor plus graphics card, head over to the Dolphin forums for assistance.

On Linux (base debian), I can strip the OS down so much, that I can get Dolphin to run on an old Windows 8 laptop w/ a crapshoot AMD E-300 processor.

Yes. Windows 10 Pro. I have a gaming PC HP Omen i7 Octa Core, 8 GB RAM 1TB HDD, Nividia GeForce GTX I forgot the number, but you get the point. I don't have the vcredist x64 installed tho. Could that be the reason why it is crashing?

Could be. It's what the Dolphin Devs recommend to install if your Dolphin cannot boot, or is crashing constantly. The link is posted directly on their downloads page - https://dolphin-emu.org/download/
Oh okay. Thanks. Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)