Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2011-10-08 20:13:10

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

Taking pokemon away

It would be great to know how to do this so I was wondering if someone already knows how to do it.
It's easy to take pokemon away from the last party slot but I'd like to know how to do it professionally by making data of other pokemon jump ahead (to fill the space made empty by taking pokemon away from any other slot but the last).

This is actually done in some situations in the game already, for example when trading.
The traded pokemon will move in the place of the last pokemon in your party and the pokemon, between the original last and the one after the traded pokemon, move ahead.

The assembly for trading is in bank 3F and I noticed that a call (CD 69 4A) seems to have something to do with the trading itself.
That leads to some other code in which you can find a call to $2E49 (where something might be found but not sure).

Basically, I've no idea how to do this but if there's someone who wants to help, would appriciate it.

Offline

#2 2011-10-09 21:21:03

Sawakita
Administrator
Registered: 2010-10-16
Post 210/364

Re: Taking pokemon away

You have various possibilities: you could find the routine that runs when you deposit a pokemon in the PC, and hook, in your custom code, the sub-routine that updates the RAM; or you could write the code from scratch, which is rather simple, when you know where in the RAM the pokemon party data are stored. To do the latter you just build a routine that only needs the party offset (0-5) as argument and then, using addition and indexed looping, you just "shift" the data back. Remember to update the party pokemon counter and party IDs too.

You could also edit the scripting engine and add commands (I'm pretty sure it has been done before by someone), so once you have written your code you should be able to program a custom entry in the engine that takes one byte as argument (example: if your custom command ID is $E7 and the pokemon you want to remove is in the 3rd place of the party, your command would be "E7 02").

Offline

#3 2011-10-09 22:01:01

288/701

Re: Taking pokemon away

Miksy91 wrote:

It would be great to know how to do this so I was wondering if someone already knows how to do it.
It's easy to take pokemon away from the last party slot but I'd like to know how to do it professionally by making data of other pokemon jump ahead (to fill the space made empty by taking pokemon away from any other slot but the last).

This is actually done in some situations in the game already, for example when trading.
The traded pokemon will move in the place of the last pokemon in your party and the pokemon, between the original last and the one after the traded pokemon, move ahead.

Other places in GSC that do this are:

  • Mania, the Pokémaniac in Cianwood City who gives you Shuckie the Shuckle. After a period of time, he will ask for the Pokémon back, and will get it unless Shuckie is very happy.

  • The sleepy man on Route 31 will take a Pokémon with mail that came from Randy, the guard from the gatehouse on Route 35. Note that while Randy gives you a Spearow (Kenya) with the mail attached, the sleepy man will take any Pokémon that holds the mail.

Try decompiling these scripts to see how they work.

#4 2011-10-10 18:59:49

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

Re: Taking pokemon away

Sawakita's method of creating the code from  scratch is tempting :D
When I get out of army (or possibly even while being there) I should have time to study assembly a bit more.

About "shifting" though, do you mean it's possible to "copy" a set of data from ram adress to another or must I write every single instruction itself (ld [hl], a...) ?

Offline

#5 2011-10-11 14:56:39

Sawakita
Administrator
Registered: 2010-10-16
Post 212/364

Re: Taking pokemon away

Miksy91 wrote:

Sawakita's method of creating the code from  scratch is tempting :D
When I get out of army (or possibly even while being there) I should have time to study assembly a bit more.

About "shifting" though, do you mean it's possible to "copy" a set of data from ram adress to another or must I write every single instruction itself (ld [hl], a...) ?

You can copy a certain amount of data from an area to another by using a loop. For example this is the routine that RBGY uses (and which you find, identical or almost, in many GB/C games):

; hl = source
; de = destination
; bc = number of bytes to copy

loop:
    ld a,[hli]
    ld [de],a
    inc de
    dec bc
    ld a,c
    or b
    jr nz,loop
    ret

Registers de/bc are increased/decreased using a separate command while register hl is increased within the command "ld a,[hli]".

Last edited by Sawakita (2011-10-11 14:58:39)

Offline

#6 2011-10-14 19:22:18

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

Re: Taking pokemon away

Got it somewhat working, thanks :D

Glad you gave that info cause when I had made the code, I noticed I don't "point" it anywhere - I was just following your info without noticing I've to define hl, de and bc registers first (wouldn't have succeeded without this because to do what I just did was hard enough for the first try).

I already gave up an idea of making you lose a pokemon in certain event in dark future beta 2 but may implement it anyway.
(Will require some time to make it happen when your pokemon is in other party slots as well)

Last edited by Miksy91 (2011-10-14 19:23:04)

Offline

Board footer

Powered by FluxBB