summaryrefslogtreecommitdiff
path: root/engine/link/link.asm
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-10-30 12:26:03 -0400
committerGitHub <noreply@github.com>2020-10-30 12:26:03 -0400
commit7a42f1790ae1e9e357593879bd38c6596dcb03da (patch)
treedbf4ee19995364f15a3b3f98925f606c50598334 /engine/link/link.asm
parenta2b6befd7d12b2ad8bb97979a10519500dcdd870 (diff)
parent1092983bde65bbf1a27eeabbfbceec1f278a4831 (diff)
Merge pull request #776 from Rangi42/unreferenced
Comment, remove, or revise many unreferenced labels
Diffstat (limited to 'engine/link/link.asm')
-rw-r--r--engine/link/link.asm184
1 files changed, 106 insertions, 78 deletions
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 3d6d5cf24..3fa34df03 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -27,10 +27,11 @@ LinkCommunications:
call PlaceString
call SetTradeRoomBGPals
call WaitBGMap2
- ld hl, wcf5d
- xor a ; LOW($5000)
+ ld hl, wLinkByteTimeout
+ assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0
+ xor a ; LOW(SERIAL_LINK_BYTE_TIMEOUT)
ld [hli], a
- ld [hl], HIGH($5000)
+ ld [hl], HIGH(SERIAL_LINK_BYTE_TIMEOUT)
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
jp nz, Gen2ToGen2LinkComms
@@ -101,14 +102,14 @@ Gen2ToGen1LinkComms:
ld a, [hl]
pop hl
and a
- jp z, Function28b22
+ jp z, ExitLinkCommunications
cp $7
- jp nc, Function28b22
+ jp nc, ExitLinkCommunications
ld de, wLinkData
ld bc, $1a2
call Link_CopyOTData
- ld de, wPlayerTrademonSpecies
- ld hl, wTimeCapsulePartyMon1Species
+ ld de, wPlayerTrademon
+ ld hl, wTimeCapsulePlayerData
ld c, 2
.loop
ld a, [de]
@@ -162,12 +163,12 @@ Gen2ToGen1LinkComms:
.done_party
ld [de], a
- ld hl, wTimeCapsulePartyMon1Species
- call Function2868a
+ ld hl, wTimeCapsulePlayerData
+ call Link_ConvertPartyStruct1to2
ld a, LOW(wOTPartyMonOT)
- ld [wUnusedD102], a
+ ld [wUnusedNamesPointer], a
ld a, HIGH(wOTPartyMonOT)
- ld [wUnusedD102 + 1], a
+ ld [wUnusedNamesPointer + 1], a
ld de, MUSIC_NONE
call PlayMusic
ldh a, [hSerialConnectionStatus]
@@ -253,8 +254,8 @@ Gen2ToGen2LinkComms:
ld de, wLinkData
ld bc, $1b9
call Link_CopyOTData
- ld de, wPlayerTrademonSpecies
- ld hl, wLinkPlayerPartyMon1Species
+ ld de, wPlayerTrademon
+ ld hl, wLinkPlayerData
ld c, 2
.loop1
ld a, [de]
@@ -407,9 +408,9 @@ Gen2ToGen2LinkComms:
ld bc, wOTPartyDataEnd - wOTPartyMons
call CopyBytes
ld a, LOW(wOTPartyMonOT)
- ld [wUnusedD102], a
+ ld [wUnusedNamesPointer], a
ld a, HIGH(wOTPartyMonOT)
- ld [wUnusedD102 + 1], a
+ ld [wUnusedNamesPointer + 1], a
ld de, MUSIC_NONE
call PlayMusic
ldh a, [hSerialConnectionStatus]
@@ -467,7 +468,7 @@ Gen2ToGen2LinkComms:
pop af
ld [wOptions], a
farcall LoadPokemonData
- jp Function28b22
+ jp ExitLinkCommunications
.ready_to_trade
ld de, MUSIC_ROUTE_30
@@ -510,6 +511,8 @@ LinkTimeout:
text_end
ExchangeBytes:
+; This is similar to Serial_ExchangeBytes,
+; but without a SERIAL_PREAMBLE_BYTE check.
ld a, TRUE
ldh [hSerialIgnoringInitialData], a
.loop
@@ -520,9 +523,9 @@ ExchangeBytes:
ld b, a
inc hl
ld a, 48
-.delay_cycles
+.wait
dec a
- jr nz, .delay_cycles
+ jr nz, .wait
ldh a, [hSerialIgnoringInitialData]
and a
ld a, b
@@ -584,7 +587,7 @@ FixDataForLinkTransfer:
ld [hli], a
dec b
jr nz, .loop3
- ld hl, wTimeCapsulePartyMon1 - 1 + PARTY_LENGTH
+ ld hl, wTimeCapsulePlayerData - 1 + PARTY_LENGTH
ld de, wc612
lb bc, 0, 0
.loop4
@@ -831,7 +834,7 @@ Link_PrepPartyData_Gen2:
; Fill 5 bytes at wc9f4 with $20
ld de, wc9f4
ld a, $20
- call Function28682
+ call Link_CopyMailPreamble
; Copy all the mail messages to wc9f9
ld a, BANK(sPartyMail)
@@ -932,7 +935,8 @@ Link_PrepPartyData_Gen2:
ld [de], a
ret
-Function28682:
+Link_CopyMailPreamble:
+; fill 5 bytes with the value of a, starting at de
ld c, 5
.loop
ld [de], a
@@ -941,7 +945,7 @@ Function28682:
jr nz, .loop
ret
-Function2868a:
+Link_ConvertPartyStruct1to2:
push hl
ld d, h
ld e, l
@@ -1245,7 +1249,7 @@ LinkTradeOTPartymonMenuLoop:
.not_d_up
bit D_DOWN_F, a
jp z, LinkTradePartiesMenuMasterLoop
- jp Function28ac9
+ jp LinkTradeCheckCancel
LinkTrade_PlayerPartyMenu:
farcall InitMG_Mobile_LinkTradePalMap
@@ -1281,7 +1285,7 @@ LinkTradePartymonMenuLoop:
.check_joypad
bit A_BUTTON_F, a
jr z, .not_a_button
- jp Function28926
+ jp LinkTrade_TradeStatsMenu
.not_a_button
bit D_DOWN_F, a
@@ -1327,7 +1331,7 @@ LinkTradePartiesMenuMasterLoop:
jp z, LinkTradePartymonMenuLoop ; PARTYMON
jp LinkTradeOTPartymonMenuLoop ; OTPARTYMON
-Function28926:
+LinkTrade_TradeStatsMenu:
call LoadTilemapToTempTilemap
ld a, [wMenuCursorY]
push af
@@ -1423,14 +1427,14 @@ Function28926:
pop af
ld [wMenuCursorY], a
dec a
- ld [wd002], a
+ ld [wCurTradePartyMon], a
ld [wPlayerLinkAction], a
- farcall Function16d6ce
+ farcall PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode]
cp $f
jp z, InitTradeMenuDisplay
- ld [wd003], a
- call Function28b68
+ ld [wCurOTTradePartyMon], a
+ call LinkTradePlaceArrow
ld c, 100
call DelayFrames
farcall ValidateOTTrademon
@@ -1454,7 +1458,7 @@ Function28926:
xor a
ld [wcf57], a
ld [wOtherPlayerLinkAction], a
- ld a, [wd003]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies
ld c, a
ld b, 0
@@ -1481,7 +1485,7 @@ Function28926:
call PlaceString
ld a, $1
ld [wPlayerLinkAction], a
- farcall Function16d6ce
+ farcall PrintWaitingTextAndSyncAndExchangeNybble
ld c, 100
call DelayFrames
jp InitTradeMenuDisplay
@@ -1497,7 +1501,7 @@ Function28926:
text_far _LinkAbnormalMonText
text_end
-Function28ac9:
+LinkTradeCheckCancel:
ld a, [wMenuCursorY]
cp 1
jp nz, LinkTradePartiesMenuMasterLoop
@@ -1540,18 +1544,18 @@ Function28ade:
ldcoord_a 9, 17
ld a, $f
ld [wPlayerLinkAction], a
- farcall Function16d6ce
+ farcall PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode]
cp $f
jr nz, .loop1
-Function28b22:
+ExitLinkCommunications:
call RotateThreePalettesRight
call ClearScreen
ld b, SCGB_DIPLOMA
call GetSGBLayout
call WaitBGMap2
xor a
- ld [wcfbb], a
+ ld [wUnusedLinkCommunicationByte], a
xor a
ldh [rSB], a
ldh [hSerialSend], a
@@ -1561,15 +1565,18 @@ Function28b22:
ldh [rSC], a
ret
-Function28b42: ; unreferenced
+GSPlaceTradeScreenFooter: ; unreferenced
+; Fill the screen footer with pattern tile
hlcoord 0, 16
- ld a, "┘"
+ ld a, $7e
ld bc, 2 * SCREEN_WIDTH
call ByteFill
+; Clear out area for cancel string
hlcoord 1, 16
ld a, " "
ld bc, SCREEN_WIDTH - 2
call ByteFill
+; Place the string
hlcoord 2, 16
ld de, .CancelString
jp PlaceString
@@ -1577,7 +1584,8 @@ Function28b42: ; unreferenced
.CancelString:
db "CANCEL@"
-Function28b68:
+LinkTradePlaceArrow:
+; Indicates which pokemon the other player has selected to trade
ld a, [wOtherPlayerLinkMode]
hlcoord 6, 9
ld bc, SCREEN_WIDTH
@@ -1610,7 +1618,7 @@ LinkTrade:
ld c, 18
call LinkTextboxAtHL
farcall Link_WaitBGMap
- ld a, [wd002]
+ ld a, [wCurTradePartyMon]
ld hl, wPartySpecies
ld c, a
ld b, 0
@@ -1619,10 +1627,10 @@ LinkTrade:
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, wStringBuffer1
- ld de, wd004
+ ld de, wBufferTrademonNick
ld bc, MON_NAME_LENGTH
call CopyBytes
- ld a, [wd003]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies
ld c, a
ld b, 0
@@ -1638,7 +1646,7 @@ LinkTrade:
ld b, 3
ld c, 7
call LinkTextboxAtHL
- ld de, String28eab
+ ld de, String_TradeCancel
hlcoord 12, 8
call PlaceString
ld a, 8
@@ -1666,12 +1674,12 @@ LinkTrade:
call WaitBGMap2
pop af
bit 1, a
- jr nz, .asm_28c33
+ jr nz, .canceled
ld a, [wMenuCursorY]
dec a
- jr z, .asm_28c54
+ jr z, .try_trade
-.asm_28c33
+.canceled
ld a, $1
ld [wPlayerLinkAction], a
hlcoord 0, 12
@@ -1681,16 +1689,17 @@ LinkTrade:
hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled
call PlaceString
- farcall Function16d6ce
- jp Function28ea3
+ farcall PrintWaitingTextAndSyncAndExchangeNybble
+ jp InitTradeMenuDisplay_Delay
-.asm_28c54
+.try_trade
ld a, $2
ld [wPlayerLinkAction], a
- farcall Function16d6ce
+ farcall PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode]
dec a
- jr nz, .asm_28c7b
+ jr nz, .do_trade
+; If we're here, the other player canceled the trade
hlcoord 0, 12
ld b, 4
ld c, 18
@@ -1698,11 +1707,11 @@ LinkTrade:
hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled
call PlaceString
- jp Function28ea3
+ jp InitTradeMenuDisplay_Delay
-.asm_28c7b
+.do_trade
ld hl, sPartyMail
- ld a, [wd002]
+ ld a, [wCurTradePartyMon]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
ld a, BANK(sPartyMail)
@@ -1711,20 +1720,20 @@ LinkTrade:
ld e, l
ld bc, MAIL_STRUCT_LENGTH
add hl, bc
- ld a, [wd002]
+ ld a, [wCurTradePartyMon]
ld c, a
-.asm_28c96
+.copy_mail
inc c
ld a, c
cp PARTY_LENGTH
- jr z, .asm_28ca6
+ jr z, .copy_player_data
push bc
ld bc, MAIL_STRUCT_LENGTH
call CopyBytes
pop bc
- jr .asm_28c96
+ jr .copy_mail
-.asm_28ca6
+.copy_player_data
ld hl, sPartyMail
ld a, [wPartyCount]
dec a
@@ -1732,18 +1741,22 @@ LinkTrade:
call AddNTimes
push hl
ld hl, wc9f4
- ld a, [wd003]
+ ld a, [wCurOTTradePartyMon]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
pop de
ld bc, MAIL_STRUCT_LENGTH
call CopyBytes
call CloseSRAM
+
+; Buffer player data
+; nickname
ld hl, wPlayerName
ld de, wPlayerTrademonSenderName
ld bc, NAME_LENGTH
call CopyBytes
- ld a, [wd002]
+; species
+ ld a, [wCurTradePartyMon]
ld hl, wPartySpecies
ld b, 0
ld c, a
@@ -1751,27 +1764,31 @@ LinkTrade:
ld a, [hl]
ld [wPlayerTrademonSpecies], a
push af
- ld a, [wd002]
+; OT name
+ ld a, [wCurTradePartyMon]
ld hl, wPartyMonOT
call SkipNames
ld de, wPlayerTrademonOTName
ld bc, NAME_LENGTH
call CopyBytes
+; ID
ld hl, wPartyMon1ID
- ld a, [wd002]
+ ld a, [wCurTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wPlayerTrademonID], a
ld a, [hl]
ld [wPlayerTrademonID + 1], a
+; DVs
ld hl, wPartyMon1DVs
- ld a, [wd002]
+ ld a, [wCurTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wPlayerTrademonDVs], a
ld a, [hl]
ld [wPlayerTrademonDVs + 1], a
- ld a, [wd002]
+; caught data
+ ld a, [wCurTradePartyMon]
ld hl, wPartyMon1Species
call GetPartyLocation
ld b, h
@@ -1779,38 +1796,46 @@ LinkTrade:
farcall GetCaughtGender
ld a, c
ld [wPlayerTrademonCaughtData], a
+
+; Buffer other player data
+; nickname
ld hl, wOTPlayerName
ld de, wOTTrademonSenderName
ld bc, NAME_LENGTH
call CopyBytes
- ld a, [wd003]
+; species
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
ld [wOTTrademonSpecies], a
- ld a, [wd003]
+; OT name
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMonOT
call SkipNames
ld de, wOTTrademonOTName
ld bc, NAME_LENGTH
call CopyBytes
+; ID
ld hl, wOTPartyMon1ID
- ld a, [wd003]
+ ld a, [wCurOTTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wOTTrademonID], a
ld a, [hl]
ld [wOTTrademonID + 1], a
+; DVs
ld hl, wOTPartyMon1DVs
- ld a, [wd003]
+ ld a, [wCurOTTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wOTTrademonDVs], a
ld a, [hl]
ld [wOTTrademonDVs + 1], a
- ld a, [wd003]
+; caught data
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMon1Species
call GetPartyLocation
ld b, h
@@ -1818,14 +1843,16 @@ LinkTrade:
farcall GetCaughtGender
ld a, c
ld [wOTTrademonCaughtData], a
- ld a, [wd002]
+
+ ld a, [wCurTradePartyMon]
ld [wCurPartyMon], a
ld hl, wPartySpecies
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
- ld [wd002], a
+ ld [wCurTradePartyMon], a
+
xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
callfar RemoveMonFromPartyOrBox
@@ -1834,14 +1861,15 @@ LinkTrade:
ld [wCurPartyMon], a
ld a, TRUE
ld [wForceEvolution], a
- ld a, [wd003]
+ ld a, [wCurOTTradePartyMon]
push af
ld hl, wOTPartySpecies
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
- ld [wd003], a
+ ld [wCurOTTradePartyMon], a
+
ld c, 100
call DelayFrames
call ClearTilemap
@@ -1933,7 +1961,7 @@ LinkTrade:
ld c, 18
call LinkTextboxAtHL
hlcoord 1, 14
- ld de, String28ebd
+ ld de, String_TradeCompleted
call PlaceString
farcall Link_WaitBGMap
ld c, 50
@@ -1943,12 +1971,12 @@ LinkTrade:
jp z, Gen2ToGen1LinkComms
jp Gen2ToGen2LinkComms
-Function28ea3:
+InitTradeMenuDisplay_Delay:
ld c, 100
call DelayFrames
jp InitTradeMenuDisplay
-String28eab:
+String_TradeCancel:
db "TRADE"
next "CANCEL@"
@@ -1956,7 +1984,7 @@ LinkAskTradeForText:
text_far _LinkAskTradeForText
text_end
-String28ebd:
+String_TradeCompleted:
db "Trade completed!@"
String_TooBadTheTradeWasCanceled:
@@ -2248,7 +2276,7 @@ CheckLinkTimeout_Receptionist:
ld a, $1
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
- ld a, $3
+ ld a, 3
ld [hli], a
xor a
ld [hl], a