# Plan 6 Task 1 (fix round): what the partner's game sends to the master is checked before the game reads it. The master's engine
# indexes gBattleMons / gPlayerParty by what a partner's controller answers (the action, the move slot and target, the party slot to
# switch to), so a forged answer must never reach gBlockRecvBuffer: pk_coop_link_give refuses it and the game's received flag
# stays as it was. Forged on the host (core A, the master) at its action prompt, as the partner would send them:
#   TO_ENGINE (buffer id 1) battler 2: TWORETURNVALUES (0x21) with move slot 9 / target 7; with action 7; CHOSENMONRETURNVALUE (0x22)
#   with party slot 1 (the host's own Pokemon, not the partner's slots 3-5); a reply for battler 0; an answer id that doesn't exist;
#   TO_CONTROLLER (a command, which only the master sends); IS_DONE as player 0; a payload of the wrong size;
#   and a Pokemon block with a species past the table, a move past the table, more PP than the move has, an item past the table.
# The battle goes on afterwards (the host is still at its prompt).
#
# want: link: give 0 status 0 -> 0 slot9target7
# want: link: give 0 status 0 -> 0 action7
# want: link: give 0 status 0 -> 0 party1
# want: link: give 0 status 0 -> 0 battler0
# want: link: give 0 status 0 -> 0 noreply
# want: link: give 0 status 0 -> 0 command
# want: link: give 0 status 0 -> 0 donep0
# want: link: give 0 status 0 -> 0 badsize
# want: link: give 0 status 0 -> 0 species
# want: link: give 0 status 0 -> 0 move
# want: link: give 0 status 0 -> 0 pp
# want: link: give 0 status 0 -> 0 item
# want: link: give 0 status 0 -> 0 baditem
# want: link: give 0 status 0 -> 0 level0
# want: link: give 0 status 0 -> 0 hpover
# want: link: give 0 status 0 -> 0 ppover
# want: link: give 0 status 0 -> 0 egg
# want: link: give 0 status 0 -> 0 status
# want: link: give 0 status 0 -> 0 badmove
# want: link: give 1 status 0 -> 1 badability
# want: link: give 1 status 0 -> 1 badtype
# want: link: give 1 status 0 -> 1 othertype
# want: link: give 1 status 0 -> 1 stage13
# want: link: give 1 status 0 -> 1 goodmon
# want: PASS linkwait 2
pair $PARTNER_SAVE
on b
@boot
poke16 0x02024542 999
poke16 0x02024544 999
on a
poke16 0x02024542 999
poke16 0x02024544 999
coopbegin 1 2 333 318
on b
coopbegin 0 2 333 318
linkwait 2 1500
on a
waitmem32 0x03005D60 0x08057589 3000
linkgivehex 5 slot9target7 0102000008000000210A090700000000
linkgivehex 5 action7 01020000080000002107000000000000
linkgivehex 5 party1 01020000080000002201000000000000
linkgivehex 5 battler0 01000000080000002100000000000000
linkgivehex 5 noreply 01020000080000007F00000000000000
linkgivehex 5 command 00020000080000002200000000000000
linkgivehex 5 donep0 02020000080000000000000000000000
linkgivehex 5 badsize 010200000C0000002100000000000000000000
linkgivemon 2 496 33 35 0 species
linkgivemon 2 280 9999 35 0 move
linkgivemon 2 280 33 36 0 pp
linkgivemon 2 280 33 35 9999 item
linkstate
waitmem32 0x03005D60 0x08057589 10
linkinfo
# Forged struct BattlePokemon replies (DATATRANSFER, 88 bytes, what the master loads into gBattleMons[2]). The fields the partner's
# CopyPlayerMonData really fills are checked: an item past the table, a level of 0, more HP than max HP, more PP than the move has, an
# egg, a status the game can't set, a data reply of any other size - all refused. The fields it leaves as stack junk in a real reply
# (ability, the two types, the stat stages, status2) are not the partner's to say: give puts the species' own there, so a forged ability
# (200), a type of 32 or a stage of 13 reaches the game's buffer as ability 66 / types 10, 10 / stages 6 (Torchic's: the block is in
# gBlockRecvBuffer[1] at 0x020224C4, the Pokemon at +12). The same Pokemon with every field right is taken.
linkgivehex 5 baditem 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420A0A002328000014000500140000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 level0 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420A0A002328000014000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 hpover 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420A0A0023280000FF000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 ppover 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420A0A009928000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 egg 01020000600000001D1D58001801000000000000000000000A002D0000000000000000400606060606060606420A0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 status 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420A0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000F00000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 badmove 01020000600000001D1D58001801000000000000000000000A7F2D0000000000000000000606060606060606420A0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
poke8 0x0203D015 0
linkgivehex 5 badability 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606C80A0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
expect8 0x020224F0 66
expect8 0x020224F1 10
expect8 0x020224F2 10
poke8 0x0300307D 0
linkgivehex 5 badtype 01020000600000001D1D58001801000000000000000000000A002D000000000000000000060606060606060642200A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
expect8 0x020224F0 66
expect8 0x020224F1 10
expect8 0x020224F2 10
poke8 0x0300307D 0
linkgivehex 5 othertype 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420B0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
expect8 0x020224F0 66
expect8 0x020224F1 10
expect8 0x020224F2 10
poke8 0x0300307D 0
linkgivehex 5 stage13 01020000600000001D1D58001801000000000000000000000A002D000000000000000000060606060606060D420A0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
expect8 0x020224E8 6
expect8 0x020224E9 6
expect8 0x020224EA 6
expect8 0x020224EB 6
expect8 0x020224EC 6
expect8 0x020224ED 6
expect8 0x020224EE 6
expect8 0x020224EF 6
poke8 0x0300307D 0
linkgivehex 5 goodmon 01020000600000001D1D58001801000000000000000000000A002D0000000000000000000606060606060606420A0A002328000014000500140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
