Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → Pokémon Red: How to edit the assembly code so that Recover heals less

#1 2022-01-07 00:53:17

Eonbane
New member
Registered: 2018-11-13
Post 4/6

Pokémon Red: How to edit the assembly code so that Recover heals less

I recently figured out how I could edit some parts of the assembly code in order to change some things.

For example I managed to locate where the Rest Sleep Turn Count is located, normally a 02 for 2 turns and I edited it successfully to last 4 turns instead.

Problem is I can't seem to edit Recover and Softboiled to heal 20% max HP instead of the usual 50%.

I thought changing the 32 at the offset $3ba16 would do but it didn't change a dang thing.

I'm scouring the aseembly code trying to match them to their hex values as I can only hex edit them due to not having a laptop or pc and only an android phone.

If anyone can help me, I'd appreciate it. Thanks in advance.

Offline

#2 2022-01-10 05:08:23

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,200/1,202

Re: Pokémon Red: How to edit the assembly code so that Recover heals less

The code you're looking for is here: https://github.com/pret/pokered/blob/ma … s/heal.asm

This is the relevant snippet:

.healHP
    ld a, [hld]
    ld [wHPBarMaxHP], a
    ld c, a
    ld a, [hl]
    ld [wHPBarMaxHP+1], a
    ld b, a
    jr z, .gotHPAmountToHeal
; Recover and Softboiled only heal for half the mon's max HP
    srl b
    rr c
.gotHPAmountToHeal

The amount healed is not a static amount, but is based on the mon's max HP. The max HP is put into bc and then bc is shifted to the right which means the amount healed will be equal to half the max HP.
Also note this is code is used for Softboiled too, so if you only want to change the behavior of Recover then some more modifications will be needed.

Offline

#3 2022-01-10 14:26:00

Eonbane
New member
Registered: 2018-11-13
Post 5/6

Re: Pokémon Red: How to edit the assembly code so that Recover heals less

I see.

Makes sense, by shifting the bits of the loaded Max HP value to the right, you get half it's value, which makes it so recover and softboiled heals half the max value.

I read about bit shifting in basic assembly yesterday but as I'm new to learning basic assembly, I've not thought of that.

The question now is: Would it be possible to change the following line of code: [ srl b ]
               [ rr c ]

………so that the value is shifted twice thus making recover heal 25% instead?

I greatly appreciate the help, thanks alot. :)

Last edited by Eonbane (2022-01-10 14:26:57)

Offline

#4 2022-01-11 07:48:22

nightbringer
Member
Registered: 2021-08-18
Post 21/21

Re: Pokémon Red: How to edit the assembly code so that Recover heals less

Try replacing those two lines with either:

srl b
rr c
srl b
rr c

or:

srl c
srl c

One of those two options will hopefully work.

Offline

#5 2022-01-13 01:13:03

Eonbane
New member
Registered: 2018-11-13
Post 6/6

Re: Pokémon Red: How to edit the assembly code so that Recover heals less

Unfortunately after doing some more ASM research, I find that the first option requires that the ASM be redone(and possibly recompiled which I cannot do as I'm limited to my android phone) and the second option won't work for mons that have HP Over 255 as the a combo of 'srl b' and 'rr c' work together to perform a 16 bit shift as the z80 opcode has no other way of doing a 16-bit shift.

Thanks guys I really appreciate your help I really do, but it looks like I'll ax my plans to nerf Recover and Softboiled, for now at least.

Cheers!!  :)

Anyways

Offline

  • Index
  • → Help/Question
  • → Pokémon Red: How to edit the assembly code so that Recover heals less

Board footer

Powered by FluxBB