’Cause all games were better on the GBC

You are not logged in.

#1 2011-06-17 19:28:51

Registered: 2010-10-16
Post 410/2,348

How to make a properly functioning "Give Item" -script

It's not that hard to input something like:
6A 47 4C xx yy 53 1F zz 01 49 90 or alternatively, 6A 47 4C xx yy 53 9D zz 01 49 90.
This is a type of a script in which a person event talks to hiro and gives hiro an item (zz).
However, this is something you may not want to do in case you want your game to work perfectly.

By doing this, the game doesn't check the certain ram address how many items you've in the item pocket.
With code 1F, either 00 or 01 is written in RAM. If RAM = 01, the item is given in original scripts in G/S/C.
When RAM = 00, the script will continue in some other part of the rom and message such as this is load: "You've no more room for this !".

So, if you're making a script in which you'll get a normal item (for example Moon Stone that belongs to Item Pocket), you'll have to make the script like this instead: 6A 47 4C xx yy 53 1F zz 01 08 00 40 49 90.

51 xx yy

Now this wasn't that hard now was it?
Anyways, the same way cannot be applied for receiving Key Items (because the RAM address where Key item count is stored is different from the RAM address where Item count is stored).

I believe scripts such as this don't exist in the original games 'cause of two reasons:
1) They'd have probably created a scripting command for it
2) It requires a little bit of "adjusting"

Well, you begin the script in the same way.
However, before 1F zz 01, you're going to have to write a little code there.
*This is just one way to do this of course.

I was going to write a better explanation here but in case you want to try this out, you probably already know how to script (at least somehow).
So, you're going to have to make the script continue at another point with a pointer code.
Where the pointer leads, you're going to have to input this: 19 E1 D5 06 19 XX YY

This basically writes the byte at ram address $D5E1 to RAM.
After that, the game checks if the [RAM] is 19 and if it is, the script will continue through a pointer.

D5E1 is the ram address where Key item count is stored and key items are stored between offsets D5E2 and D5FA (so there are 0x19 of them in all).

Last edited by Miksy91 (2011-06-25 15:47:30)


#2 2011-06-25 15:52:15

Registered: 2010-10-16
Post 435/2,348

Re: How to make a properly functioning "Give Item" -script

Found out something more related to this !

The asm of withdrawing key items from Hiro's PC is located somewhere over here, 0xD3yy, in the rom.
In offset 0xD36A byte 19 tells the game that you can withdraw up to 0x19 key items from your pc.
However, there is actually only room for 0x13 because the game stores Mom's held money in $D5F6-D5F8 in ram.
According to KBM's ram map, bytes in $D5F9-D5FB are likely unused in the game.

Could it be so that the game was originally programmed to store up to 0x19 key items but because there aren't that many in the game, they left that "bug" in there and decided to put mom's stored money in the same area of ram where the rest of the key items were intented to be ?

Well, anyways...
If you want to have more key items in your hack, you'd better change byte at 0xD36A to 13 (or change the asm code of storing money).

I tested this out and noticed that mom's held money is actually stored straight after the money that player keeps himself.
I corrected the ram map a little bit and it looks like the item withdrawing was coded right after all.

Last edited by Miksy91 (2011-06-25 15:53:03)


#3 2011-06-27 23:50:48

From: Philippines
Registered: 2011-06-27
Post 1/600

Re: How to make a properly functioning "Give Item" -script

can i ask? Can i make the give item script existing in the ROM to a give pokemon script?

Trust me, I'm an Engineer

>>>Pinoy ka ba? Pasok ka dito<<<


#4 2011-06-28 01:32:49

From: Brooklyn, New York
Registered: 2010-11-02
Post 79/132

Re: How to make a properly functioning "Give Item" -script

How would you insert a script after writing it? You should write/make a tutorial video on that.

I don't calculate stat values, I don't breed my way to perfection, and I don't care about natures. I catch my Pokemon the way they are, and treat them like individuals instead of brainless drones.


Board footer

Powered by FluxBB