Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2012-01-27 16:12:08

Miksy91
Member
Registered: 2010-10-16
Post 750/2,311

ASM code for storing item in PC

I for now have a small bug in my hack (which I can fix easily another way too but don't feel like wasting two bits for "no reason").
Besides, it's fun to try out something different and more challenging for once in a while.

Anyway, is there any easy way to make a person put an item in your pc ?
In D616, the game is told how many items you've in PC so basically, I was wondering if I could possibly make the game 2x "jp a" bytes ahead (the byte in offset D616 would be stored in a), store that address in some register pair, increment that address (and that way, I'd be modifying "the first" FF after D616), change the byte in that register pair into xx (given item) and after all that, increase the byte in offset D616 by one.

I've a feeling it can't be done this way but I'm not familiar with GB assembly well yet so I'm not quite sure (actually, only thing I'm concerned about is, how to do the "jp a" thing).
Also, if somebody can think of another method (expect, write byte at D618 into ramm --> if FF go to...) to do this, I'd appreciate it :)

Last edited by Miksy91 (2012-01-27 16:19:43)

Offline

#2 2012-01-27 16:47:41

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 1,204/3,480

Re: ASM code for storing item in PC

There should already be a routine that does this, because occasionally your mum will call and say "I found a useful item while shopping today. Its in your PC, you'll love it!"
I'm not sure where it is or if it would be adaptable enough to suit your needs, but it might be worth looking into.

Offline

#3 2012-01-27 17:12:45

431/700

Re: ASM code for storing item in PC

Mateo wrote:

There should already be a routine that does this, because occasionally your mum will call and say "I found a useful item while shopping today. Its in your PC, you'll love it!"
I'm not sure where it is or if it would be adaptable enough to suit your needs, but it might be worth looking into.

To figure out the code for this:

  1. Find the memory address for the first empty slot in the PC, and set a write watchpoint. (E.g., if your PC is empty, it would be the first entry.)

  2. Give your mom a bunch of money (at least ¥100000—I don’t remember the exact amounts).

  3. Get in a battle. BGB will stop execution when it puts the item in the PC.

#4 2012-01-27 20:25:24

Miksy91
Member
Registered: 2010-10-16
Post 751/2,311

Re: ASM code for storing item in PC

Thanks Marckus, figured it out that way :)

I didn't think I could find the code where it was - mainly because there was no "ld rp, $D616" anywhere near that offset.
The offset was loaded before hand by some other code as it looks like this code is used for giving an item in any item pocket / pc.

Anyway, here is what you want to do in case you want to use this kind of code too.
Make the wanted script call assembly code from bank 0x3.

Put the following code there:

21 16 D6; ld hl, $D616
C3 A7 52; jp $52A7

That way, you're choosing address $D616 as the offset where the game will start filling data according to the assembly code at $D2A7.
That code calls bytes from ram addresses $D002 and $D009 in which the byte in $D002 is used as the item number and $D009 as amount given.

Last edited by Miksy91 (2012-01-27 20:27:32)

Offline

Board footer

Powered by FluxBB