Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2014-07-28 02:02:31

Siamese Dream
New member
Registered: 2014-04-19
Post 3/6

[G/S] Adding Move Effects

I've been wanting to add the move Sucker Punch into Pokemon Gold. I have written the effect in ASM, but I don't know how to actually add it into the game. Is there a table or pointer table that I don't know about?

Secondly, throughout this entire process I've been using the Pokemon Crystal disassembly document as a reference, and soemthing has me puzzled. Here (https://github.com/kanzure/pokecrystal/ … ffects.asm) it says that priority moves like Quick Attack are 'Normal Hits'. However, here (https://github.com/kanzure/pokecrystal/ … /moves.asm) is labelled as priority hit. The first link seems to be a list of all of the move effects and the moves that correspond to them, but priority isn't mentioned at all.

Offline

#2 2014-07-28 16:26:20

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

Re: [G/S] Adding Move Effects

Each move has its own data as a structure that probably contains also a byte that determines the index (or entry) in some pointer table of the move effects. I can't say it works like this for sure but so I would believe at least.

I don't know if some moves have higher probability of doing critical hits than others, but somebody else could help you out with that question.

Offline

#3 2014-07-28 17:31:41

Chamber_
Member
Registered: 2013-12-31
Post 73/119

Re: [G/S] Adding Move Effects

This is the routine that says what effects have priority:
(you only need a routine that skips sucker punch effect if the opponent don't use a damage move)

GetMovePriority: ; 3c5c5
; Return the priority (0-3) of move a.

    ld b, a

    ; Vital throw goes last.
    cp VITAL_THROW
    ld a, 0
    ret z

    call GetMoveEffect
    ld hl, MoveEffectPriorities
.loop
    ld a, [hli]
    cp b
    jr z, .done
    inc hl
    cp -1
    jr nz, .loop

    ld a, 1
    ret

.done
    ld a, [hl]
    ret
; 3c5df

MoveEffectPriorities: ; 3c5df
    db EFFECT_PROTECT,      3
    db EFFECT_ENDURE,       3
    db EFFECT_PRIORITY_HIT, 2
    db EFFECT_WHIRLWIND,    0
    db EFFECT_COUNTER,      0
    db EFFECT_MIRROR_COAT,  0
    db -1
; 3c5ec

You can create an effect that acts like "Normal Hits" (deal damage only), but her pointer is one of unused pointers in the move effect command table.


In pokemon GOLD, in $3FD3B start the effect command table. Is a 2-byte table to each effect. The effect 0x25 and 0x2B are unused according to Pokemon Crystal disassembly.

Last edited by Chamber_ (2014-07-28 17:33:01)

Offline

#4 2014-07-28 19:10:41

Siamese Dream
New member
Registered: 2014-04-19
Post 4/6

Re: [G/S] Adding Move Effects

Chamber_ wrote:

In pokemon GOLD, in $3FD3B start the effect command table. Is a 2-byte table to each effect. The effect 0x25 and 0x2B are unused according to Pokemon Crystal disassembly.

Thanks. What is the data structure for the move effects like? Is it just the assembly code stored in hex? I'm sorry for asking all these questions, it's just that there isn't much documentation around. I followed the second pointer (the one leading to offset $3C093 or effect 0x01 (sleep)), and didn't recognise anything.

Last edited by Siamese Dream (2014-07-28 20:42:24)

Offline

#5 2014-07-29 04:21:43

comet
Member
Registered: 2012-04-09
Post 467/679

Re: [G/S] Adding Move Effects

The pointers are in bank F, but move effect code is in bank D.

Offline

#6 2014-07-29 12:15:25

Siamese Dream
New member
Registered: 2014-04-19
Post 5/6

Re: [G/S] Adding Move Effects

Really? So they are two byte pointers that lead to another bank? I thought that two byte pointers could only point to something in their own bank.

Offline

#7 2014-07-29 15:03:20

comet
Member
Registered: 2012-04-09
Post 468/679

Re: [G/S] Adding Move Effects

Addresses lack banks, but there's nothing stopping you from supplying one. There's no universal "pointer reader" that has to take a certain format.

In this case, the address from bank F is actually grabbed by the handler in bank D.

; 3406e (Crystal)
        push bc
        dec a
        ld c, a
        ld b, 0
        ld hl, BattleCommandPointers
        add hl, bc
        add hl, bc
        pop bc

        ld a, BANK(BattleCommandPointers)
        call GetFarHalfword

        call .hl
        jr .next

.hl
        jp [hl]
; 34084

The descriptions of "two-byte" and "three-byte" pointers are just guides for common patterns. The only part that's inherent is that addresses can only fit into 16 bits, and most MBCs abstract this away with banks. How you handle pointers is totally up to you, so long as you end up at the right place.

You could store offsets directly if you wanted to, and unravel them at runtime. This probably sounds tempting to someone working with a binary. The reason this never shows up in real games is there's no point when most assemblers deal in banks to begin with, and you lose ram addressing.

Last edited by comet (2014-07-29 15:23:41)

Offline

#8 2014-07-29 17:46:54

Siamese Dream
New member
Registered: 2014-04-19
Post 6/6

Re: [G/S] Adding Move Effects

Thanks for all of your help comet, but I think that you have directed me to the battle commands, not the move effects. The disassembly has the locations of the battle commands labelled, but says next to nothing about the move effects. I can't find anything at all on where the move effects are and what the structure is like.

Offline

#9 2014-07-29 23:39:24

comet
Member
Registered: 2012-04-09
Post 469/679

Re: [G/S] Adding Move Effects

They're at the end of bank 9.

MoveEffectsPointers: ; 271f4
INCLUDE "battle/moves/move_effects_pointers.asm"

MoveEffects: ; 2732e
INCLUDE "battle/moves/move_effects.asm"

Each command represents one byte. Unlike event scripting, commands don't take arguments. A list of commands can be found here.

Offline

#10 2014-08-07 22:16:09

Chamber_
Member
Registered: 2013-12-31
Post 77/119

Re: [G/S] Adding Move Effects

I got your email.

----------

$3FD3B 2-pointer Table to Battelcommands (starts with 0x00)

BattleCommand3C and BattleCommand5D are unused.

----------

0x2739F Poiner Table of Move Effect. (move_effects.asm)

----------

When the move are ready you could share the information????

Offline

Board footer

Powered by FluxBB