Pokemon Pocket Computer: What is it and how to use it to make cheat codes

Pokemon Pocket Computer is a script that can be written into a Pokemon Red PC box. With a special item setup in your inventory, provided the current box is the one with Pocket Computer installed, you will get a memory editor.

How to install

Method 1: New Save

With an 8F ready save (if you don’t know what that means, see here) and the right itemlist, you can install Pocket Computer for yourself.

Follow the beginning instructions in this video (until about the 4:39 mark), and then you’ll have Pocket Computer in the current box. Save your game and you’ll have Pocket Computer in that box until your save battery dies or you lose your save file some other way.

Method 2: .SAV file

If you’re using a flashcart or an emulator, I’m providing a .SAV file with Pocket Computer installed in box 12, as well as the example script.

How to use

To move around, use the D-Pad (up/down = move by 0x01, left/right = move by 0x10). If you need to move faster than 0x10 bytes at a time, hold the Select button and press up or down to move by 0x0100 bytes at a time. To change values, hold Start and use the D-Pad. (up/down=add/subtract 0x01, respectively, left/right=subtract/add 0x10 respectively)

By using Pocket Computer, along with another concept known as DMA hijacking, we can make cheat codes that run everytime DMA occurs. (Which, if you weren’t aware, is very, very often.)

This example script will act like the GameShark code 0163D321, giving you infinite of whatever is in the second slot. (In the .SAV file, there are Master Balls in the 2nd slot.) To write the code (if you’re using the .SAV file, it’s already been written for you) put at D9EE (or any other free RAM) and going down through the data:

F5 E5 3E 63 21 21 D3 77 E1 F1 3E C3 0E 46 C9

This script decompiles to:

push af
push hl     ; Preserve registers
ld a,$63    ; load 99 (0x63) into A
ld hl,$D321 ; $D321 = quantity of second item in inventory
ld [hl],a   ; store 99 in $D321 (causing inventory item 2 to have infinite quantity due to how often this code runs)
pop hl
pop af      ; Restore registers
ld a,$c3
ld c,$46    ; This part will make sense later.
ret         ; Return.

In order to DMA hijack, we must overwrite 4 bytes of the OAM DMA routine used by the game. The OAM DMA routine is the routine used to pause while DMA is occurring. (During which time only HRAM is available.) This routine is most often stored at $FF80. By overwriting 4 of the bytes at the beginning, we piggyback the DMA routine to run our code before starting DMA. The DMA routine, as used in Pokemon Red, is:

ld a, $c3
ld [$FF46], a ; initiate DMA
ld a, $28 ; wait for DMA to finish by wasting some cycles
wait:
dec a
jr nz, wait ; loop until a=0
ret

If we can put a call instruction in there, we’re home free! But where, oh where, will we find space for it? We can’t put the call before the routine, as the game would simply ignore our call. But how else can we get our call instruction in there?

Remember this, from just a bit higher up the page?

ld a,$c3
ld c,$46 ; This part will make sense later.

It turns out, there is a one-byte instruction what will index HRAM with the value of the register c. By using this instruction, (saving one byte) as well as doing the setup of the register a within our routine, (saving two bytes) we free 3 bytes. Just enough for our call instruction! (Which is 3 bytes, if you don’t understand.)

However, if you, excited reader, tried to modify the DMA routine with Pocket Computer, you’d notice it simply crashes the game. (If you didn’t try it, make sure Pocket Computer is saved to the box you put it in (if you don’t want to spend time choosing the SAVE option in the start menu, just change to a different box and back) and try it.) The reason this occurs is that you are modifying the DMA routine while the game continues to try to use it. If you could get the bytes into the DMA routine without the game attempting to use it, it’d work. The easiest way to do this is to write some code somewhere else and run it. Now how are we going to do that? We can’t use 8F because we need it set up for Pocket Computer. You see, I’ve withheld some information from you until now. By pressing A+B while the cursor is on a memory address, the game will jump to that address and execute code from there. To somewhat complete our example, write to any free RAM (I suggest writing it directly after the script from earlier):

F5 E5 C5 D5 21 XX XX 11 80 FF 01 04 00 CD B5 00 D1 C1 E1 F1 C9 CD EE D9 E2

Leave the XX bytes blank and continue filling out the code until you finish the entire code. Take the memory address of the start of the “CD EE D9 E2” and reverse the bytes, putting them in the XX slots. For example, if the “CD EE D9 E2” starts on DA12, the “21 XX XX” would become “21 12 DA”. Also, if you put the code for the 1st part somewhere other than D9EE, change “EE D9” to the reversed bytes of that address. (once again, $DA12 would become “12 DA”)

Hover over the F5 byte at the beginning (if you’re using my save file, it’s at D9FD) and press A+B at the same time. The game should go back to the items menu. Try tossing any of the second item. (Any amount can be tossed but 99, as that would get rid of the stack and mess up our code for using Pocket Computer.) You will see that the quantity will never drop below 99.

There are precautions you need to take. DO NOT battle trainers with the cheat active unless the memory in which your main routine resides isn’t messed with by trainer battles. DO NOT!!!! It WILL crash your game! (If you’re using my .SAV file, this applies to you, as D9EE is where I store my routine, and that memory is used for trainer’s pokemon nicknames.) If you come to a spot where you must battle a trainer, save and reset your GameBoy before battling the trainer, as this will cause the game to put a fresh copy of the DMA routine in HRAM, undoing our exploit and saving your game from crashing. Alternatively, save and then soft-reset Pokemon Red, as this also refreshes the DMA routine.


go home