summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormid-kid <esteve.varela@gmail.com>2020-08-19 13:32:11 +0200
committermid-kid <esteve.varela@gmail.com>2020-08-19 16:00:00 +0200
commite40f421ffb1b0029eaddab21252e324aa3ed4ac2 (patch)
tree05fb16709aa39c1d6e4331a31e49590e5a1d6ec3
parent0b31d12daceb9f431387951ee275e6147285cffd (diff)
Document weird code involving link trades of mew and celebi
This piece of code is frankly rather confusing, as it seemingly doesn't serve much of a purpose. Documenting it here for future reference.
-rw-r--r--engine/link/link.asm25
1 files changed, 16 insertions, 9 deletions
diff --git a/engine/link/link.asm b/engine/link/link.asm
index d42fb6818..72ad2263c 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -1882,24 +1882,31 @@ LinkTrade:
call LoadTradeScreenBorder
call SetTradeRoomBGPals
farcall Link_WaitBGMap
- ld b, $1
+
+; Check if either of the Pokémon sent was a Mew or Celebi, and send a different
+; byte depending on that. Presumably this would've been some prevention against
+; illicit trade machines, but it doesn't seem like a very effective one.
+; Removing this code breaks link compatibility with the vanilla gen2 games, but
+; has otherwise no consequence.
+ ld b, 1
pop af
ld c, a
cp MEW
- jr z, .loop
+ jr z, .send_checkbyte
ld a, [wCurPartySpecies]
cp MEW
- jr z, .loop
- ld b, $2
+ jr z, .send_checkbyte
+ ld b, 2
ld a, c
cp CELEBI
- jr z, .loop
+ jr z, .send_checkbyte
ld a, [wCurPartySpecies]
cp CELEBI
- jr z, .loop
- ld b, $0
+ jr z, .send_checkbyte
-.loop
+; Send the byte in a loop until the desired byte has been received.
+ ld b, 0
+.send_checkbyte
ld a, b
ld [wPlayerLinkAction], a
push bc
@@ -1913,7 +1920,7 @@ LinkTrade:
jr z, .save
ld a, [wOtherPlayerLinkAction]
cp b
- jr nz, .loop
+ jr nz, .send_checkbyte
.save
farcall SaveAfterLinkTrade