PDA

View Full Version : Giving Items In the PC


ZodiacDaGreat
July 11th, 2008, 03:30 AM
Warning: This is not your average ROM Hacking tutorial.

Hello all, its been a while since I've posted some tuts. Lately, I've been learning some stuff, from here and there. I finally found out something on my own, and wrote my own asm routine.

Ok, let's get down to business... Today I'll be teaching and showing you all how to make a Item appear on the first slot, in your PC. Here's what you'll be using and what you'll need:

-VBA 1.7.2
-A ASM Assembler - for people who really want to learn the hard way
(Goldroad, etc)
-Knowledge on using an Assembler
-Pokemon Ruby ROM - my favorite version

Part 1:Searching/Calculating For the Offsets
First open your ROM in VBA, load up to a place where you can access your PC. Open your PC, you'll see some items already in your PC, which for my case is: - EON TICKET

http://www.divshare.com/img/4922269-62e.gif

So, open Search For Cheats function, by pressing ctrl + C, or open it manually, and set these:

-Specific Value
-16 bits
-Equal
-Hexadecimal
-Update Values

Now, after you're done, you must be wondering what value to search for? Now, we need to search for the EON Ticket - where the item is located, and the HEX value for EON Ticket is 0x113, so type in 113, and click start followed by search. You should get something around:

02025BCC - 0113 - 0113
02025D1C - 0113 - 0113
Two values, is not exactly what we want so, we got to narrow the values, withdraw the EON Ticket and open the window again, and you'll see this:

02025BCC - 0113 - 0000
02025D1C - 0113 - 0113
Alright, we did it! Thats the offset to the Slot 1 of the Item Storage PC Item Value, which is
"02025BCC".

Next, is the Offset to the Item Quantity, value. So suppose we had 10 EON TICKETs back then in the first slot, to search we're do this:

-Specific Value
-16 bits
-Equal
-Unsigned
-Update Values

First type in 10, Start then Search, you'll see too much values/offsets, withdraw a few tickets, say 3. This time type in 7, and search (Don't press start). When the offsets keep narrowing in the end you'll get "02025BCE" Phew.

Part 2: The ASM routine
Now, theres two routines, one to give the item, and one to give the quantity. We're gonna put MAX Potion in the first slot of the PC, if there's any items in the first slot, it'll get overwritten, so be warned. For people who know how to use a assembler, I provide 2 routines made by me.

Routine #1, Item:

.code 16
push {lr}
ldr r0, =0x2025BCC @loads register to PC address
mov r2, #0x14 @loads Max Potion, #20 is Max Potion in Decimal
strh r2, [r0] @stores Max Potion at PC address
pop {pc}

Routine #2, Quantity:

.code 16
push {lr}
mov r0, #0x01 @Quantity, which is 0x1
ldr r1,=0x2025BCE @ Address to write to
strh r0, [r1]
pop {pc}

Now, for those that don't know how to use a Assembler - don't worry your code has been translated by hex for me:

Routine #1:
00B502481422026000BD0000CC5B0202

where bold = Item Offset which was calculated above
and underlined is = Item in Hex, max of 0xFF, ie BlueScarf

Routine #2:
00B501200149087000BD0000CE5B0202

where bold = Item Qunatity Offset which was calculated above
and underlined is = amount in Hex, max of 0xFF, ie 255, in this case is 0x1

Now, you must be thinking what to do with the codes above, Now, to explain, open your hex editor goto some free space, and insert these 2 routines. After that you'll need a script to call the routines, so you'll be using XSE.

Your script will be:

#dynamic 0x800000
#org @Start
callasm 0xXXXXXX ' first routine offset + 1
callasm 0xWWWW ' second routine offset + 1
end
Run, the script ingame and check your PC, you should get a Max Potion in the first slot. :) Phew! My longest tut yet. Remember, the routines will overwrite the item already in slot one, so use it like say, in the beginning of the game.

To conclude, I'd like to say that asm hacking is got to do with calculating pointers and offsets, as well as writing routines to patch certain routines ;), and I leave to you all a small challenge:

As mentioned earlier, this routine is for the first slot, see if you can make it for the second slot, and try to change the quantity as well as giving items above Blue Scarf. Happy Hacking.

thethethethe
July 11th, 2008, 04:49 AM
Doesn't the command 0x49 do this? :P
Anyway great tutorial Zodiacdagreat. Good to see some ASM things here at PC.
Hope to see more from you soon.

EDIT: I just noticed something.
str r2, [r0] @stores Max Potion at PC address
Shouldn't that be
strh r2, [r0]
Or is it stored through four bytes?

liuyanghejerry
July 11th, 2008, 07:30 AM
Looks great,and not puzzling to me.
And how about giving pokemon in PC?

ZodiacDaGreat
July 11th, 2008, 11:50 AM
Doesn't the command 0x49 do this?
Anyway great tutorial Zodiacdagreat. Good to see some ASM things here at PC.
Hope to see more from you soon.

EDIT: I just noticed something.
str r2, [r0] @stores Max Potion at PC address
Shouldn't that be
strh r2, [r0]
Or is it stored through four bytes?

Thanks alot, thethethethe, I totally forgot there's a command for this, anyways its good to know how most asm hacking is done, searching and patching etc.
I think both "str" & "strh" will work, but use strh, the difference is str is for 16 bit, and str's for 32 bit.

Looks great,and not puzzling to me.
And how about giving pokemon in PC?
Thanks Man, I'm glad you understood too, um that's already covered by Mastermind_X, check his site. His given the pointer to Fire Red US only, for other versions you need to search for it. Anyways, I can try now, but the end result is the pokemon won't have any obiedent bit.

Cy-Chan
July 12th, 2008, 01:50 AM
Very cool tutorial. This place definitely needs more ASM-related stuff.

GBChacker
July 12th, 2008, 10:34 AM
Why? Nobody would understand it. This is very basic code, yet it still should be smaller. Combine both routines... Also strh means store halfword. str is not limited to the arm instrution set. I really suggest you all learn the gba's hardware, offsets, and the thumb and arm instruction sets for gba before doing any actual asm. Also from the simplicity of this tutorial I'm gonna guess your gonna make a tutorial everytime you find a new offset or learn a new insctruction? I know asm looks so amazing to noobs, but please refrain from doing such.

ZodiacDaGreat
July 12th, 2008, 01:00 PM
-.-' Doesn't mean that if you understand it others will, and after all I'm still learning. Also, you don't have to read it if you don't want to, everyone was once a noob.

Here's the shorter routine:

.code 16

push {r0, r1, r2, lr}
ldr r0, =0x2025BCC
mov r1, #0x14
strh r1, [r0]
add r0, #0x02
mov r2, #0x01
strb r2, [r0]
pop {r0, r1, r2, pc}

When assembled gives:
07B503481421018002300122027007BDCC5B0202.

DarkFear
July 15th, 2008, 05:03 PM
This is great stuff Zodiac. I see ASM as the future of ROM-Hacking :D

Teh Baro
July 18th, 2008, 04:13 AM
This is great stuff Zodiac. I see ASM as the future of ROM-Hacking :D
Actually it's the present, but pokemon hacking is in the past.
----------

Actually there's a command that adds an item to your PC (dunno what number it was, look for mastermind_X command list). At least it exists in fire red. There's also a command that checks if you ahve an item on the PC. There isn't a test item on pc command, but you can add it and then check if it was added.

ZodiacDaGreat
July 18th, 2008, 12:14 PM
Actually it's the present, but pokemon hacking is in the past.
----------
Actually there's a command that adds an item to your PC (dunno what number it was, look for mastermind_X command list). At least it exists in fire red. There's also a command that checks if you ahve an item on the PC. There isn't a test item on pc command, but you can add it and then check if it was added.
Yeah, there is - sorry, If I would've remembered theres a command I wouldn't have wrote this tut, but this basically tells you how to perform other stuff - As long as you calculate the offsets and are able to manipulate values :), anyways, for that ASM isn't quite necessary, you can use commands like "writebytetooffset" and "loadbytefromoffset" command 11 & 12 I think.