Port more pokegold link engine symbols, and name an unused WRAM byte

This commit is contained in:
Rangi 2020-10-29 15:15:14 -04:00
parent bcc0d633e9
commit a51b1a2f13
3 changed files with 68 additions and 43 deletions

View File

@ -101,9 +101,9 @@ Gen2ToGen1LinkComms:
ld a, [hl] ld a, [hl]
pop hl pop hl
and a and a
jp z, Function28b22 jp z, ExitLinkCommunications
cp $7 cp $7
jp nc, Function28b22 jp nc, ExitLinkCommunications
ld de, wLinkData ld de, wLinkData
ld bc, $1a2 ld bc, $1a2
call Link_CopyOTData call Link_CopyOTData
@ -163,7 +163,7 @@ Gen2ToGen1LinkComms:
.done_party .done_party
ld [de], a ld [de], a
ld hl, wTimeCapsulePlayerData ld hl, wTimeCapsulePlayerData
call Function2868a call Link_ConvertPartyStruct1to2
ld a, LOW(wOTPartyMonOT) ld a, LOW(wOTPartyMonOT)
ld [wUnusedNamesPointer], a ld [wUnusedNamesPointer], a
ld a, HIGH(wOTPartyMonOT) ld a, HIGH(wOTPartyMonOT)
@ -467,7 +467,7 @@ Gen2ToGen2LinkComms:
pop af pop af
ld [wOptions], a ld [wOptions], a
farcall LoadPokemonData farcall LoadPokemonData
jp Function28b22 jp ExitLinkCommunications
.ready_to_trade .ready_to_trade
ld de, MUSIC_ROUTE_30 ld de, MUSIC_ROUTE_30
@ -833,7 +833,7 @@ Link_PrepPartyData_Gen2:
; Fill 5 bytes at wc9f4 with $20 ; Fill 5 bytes at wc9f4 with $20
ld de, wc9f4 ld de, wc9f4
ld a, $20 ld a, $20
call Function28682 call Link_CopyMailPreamble
; Copy all the mail messages to wc9f9 ; Copy all the mail messages to wc9f9
ld a, BANK(sPartyMail) ld a, BANK(sPartyMail)
@ -934,7 +934,8 @@ Link_PrepPartyData_Gen2:
ld [de], a ld [de], a
ret ret
Function28682: Link_CopyMailPreamble:
; fill 5 bytes with the value of a, starting at de
ld c, 5 ld c, 5
.loop .loop
ld [de], a ld [de], a
@ -943,7 +944,7 @@ Function28682:
jr nz, .loop jr nz, .loop
ret ret
Function2868a: Link_ConvertPartyStruct1to2:
push hl push hl
ld d, h ld d, h
ld e, l ld e, l
@ -1247,7 +1248,7 @@ LinkTradeOTPartymonMenuLoop:
.not_d_up .not_d_up
bit D_DOWN_F, a bit D_DOWN_F, a
jp z, LinkTradePartiesMenuMasterLoop jp z, LinkTradePartiesMenuMasterLoop
jp Function28ac9 jp LinkTradeCheckCancel
LinkTrade_PlayerPartyMenu: LinkTrade_PlayerPartyMenu:
farcall InitMG_Mobile_LinkTradePalMap farcall InitMG_Mobile_LinkTradePalMap
@ -1283,7 +1284,7 @@ LinkTradePartymonMenuLoop:
.check_joypad .check_joypad
bit A_BUTTON_F, a bit A_BUTTON_F, a
jr z, .not_a_button jr z, .not_a_button
jp Function28926 jp LinkTrade_TradeStatsMenu
.not_a_button .not_a_button
bit D_DOWN_F, a bit D_DOWN_F, a
@ -1329,7 +1330,7 @@ LinkTradePartiesMenuMasterLoop:
jp z, LinkTradePartymonMenuLoop ; PARTYMON jp z, LinkTradePartymonMenuLoop ; PARTYMON
jp LinkTradeOTPartymonMenuLoop ; OTPARTYMON jp LinkTradeOTPartymonMenuLoop ; OTPARTYMON
Function28926: LinkTrade_TradeStatsMenu:
call LoadTilemapToTempTilemap call LoadTilemapToTempTilemap
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
push af push af
@ -1427,12 +1428,12 @@ Function28926:
dec a dec a
ld [wCurTradePartyMon], a ld [wCurTradePartyMon], a
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
farcall Function16d6ce farcall PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode] ld a, [wOtherPlayerLinkMode]
cp $f cp $f
jp z, InitTradeMenuDisplay jp z, InitTradeMenuDisplay
ld [wCurOTTradePartyMon], a ld [wCurOTTradePartyMon], a
call Function28b68 call LinkTradePlaceArrow
ld c, 100 ld c, 100
call DelayFrames call DelayFrames
farcall ValidateOTTrademon farcall ValidateOTTrademon
@ -1483,7 +1484,7 @@ Function28926:
call PlaceString call PlaceString
ld a, $1 ld a, $1
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
farcall Function16d6ce farcall PrintWaitingTextAndSyncAndExchangeNybble
ld c, 100 ld c, 100
call DelayFrames call DelayFrames
jp InitTradeMenuDisplay jp InitTradeMenuDisplay
@ -1499,7 +1500,7 @@ Function28926:
text_far _LinkAbnormalMonText text_far _LinkAbnormalMonText
text_end text_end
Function28ac9: LinkTradeCheckCancel:
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
cp 1 cp 1
jp nz, LinkTradePartiesMenuMasterLoop jp nz, LinkTradePartiesMenuMasterLoop
@ -1542,18 +1543,18 @@ Function28ade:
ldcoord_a 9, 17 ldcoord_a 9, 17
ld a, $f ld a, $f
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
farcall Function16d6ce farcall PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode] ld a, [wOtherPlayerLinkMode]
cp $f cp $f
jr nz, .loop1 jr nz, .loop1
Function28b22: ExitLinkCommunications:
call RotateThreePalettesRight call RotateThreePalettesRight
call ClearScreen call ClearScreen
ld b, SCGB_DIPLOMA ld b, SCGB_DIPLOMA
call GetSGBLayout call GetSGBLayout
call WaitBGMap2 call WaitBGMap2
xor a xor a
ld [wcfbb], a ld [wUnusedLinkCommunicationByte], a
xor a xor a
ldh [rSB], a ldh [rSB], a
ldh [hSerialSend], a ldh [hSerialSend], a
@ -1563,15 +1564,18 @@ Function28b22:
ldh [rSC], a ldh [rSC], a
ret ret
Function28b42: ; unreferenced GSPlaceTradeScreenFooter: ; unreferenced
; Fill the screen footer with pattern tile
hlcoord 0, 16 hlcoord 0, 16
ld a, "┘" ld a, $7e
ld bc, 2 * SCREEN_WIDTH ld bc, 2 * SCREEN_WIDTH
call ByteFill call ByteFill
; Clear out area for cancel string
hlcoord 1, 16 hlcoord 1, 16
ld a, " " ld a, " "
ld bc, SCREEN_WIDTH - 2 ld bc, SCREEN_WIDTH - 2
call ByteFill call ByteFill
; Place the string
hlcoord 2, 16 hlcoord 2, 16
ld de, .CancelString ld de, .CancelString
jp PlaceString jp PlaceString
@ -1579,7 +1583,8 @@ Function28b42: ; unreferenced
.CancelString: .CancelString:
db "CANCEL@" db "CANCEL@"
Function28b68: LinkTradePlaceArrow:
; Indicates which pokemon the other player has selected to trade
ld a, [wOtherPlayerLinkMode] ld a, [wOtherPlayerLinkMode]
hlcoord 6, 9 hlcoord 6, 9
ld bc, SCREEN_WIDTH ld bc, SCREEN_WIDTH
@ -1640,7 +1645,7 @@ LinkTrade:
ld b, 3 ld b, 3
ld c, 7 ld c, 7
call LinkTextboxAtHL call LinkTextboxAtHL
ld de, String28eab ld de, String_TradeCancel
hlcoord 12, 8 hlcoord 12, 8
call PlaceString call PlaceString
ld a, 8 ld a, 8
@ -1668,12 +1673,12 @@ LinkTrade:
call WaitBGMap2 call WaitBGMap2
pop af pop af
bit 1, a bit 1, a
jr nz, .asm_28c33 jr nz, .canceled
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
dec a dec a
jr z, .asm_28c54 jr z, .try_trade
.asm_28c33 .canceled
ld a, $1 ld a, $1
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
hlcoord 0, 12 hlcoord 0, 12
@ -1683,16 +1688,17 @@ LinkTrade:
hlcoord 1, 14 hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled ld de, String_TooBadTheTradeWasCanceled
call PlaceString call PlaceString
farcall Function16d6ce farcall PrintWaitingTextAndSyncAndExchangeNybble
jp Function28ea3 jp InitTradeMenuDisplay_Delay
.asm_28c54 .try_trade
ld a, $2 ld a, $2
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
farcall Function16d6ce farcall PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode] ld a, [wOtherPlayerLinkMode]
dec a dec a
jr nz, .asm_28c7b jr nz, .do_trade
; If we're here, the other player canceled the trade
hlcoord 0, 12 hlcoord 0, 12
ld b, 4 ld b, 4
ld c, 18 ld c, 18
@ -1700,9 +1706,9 @@ LinkTrade:
hlcoord 1, 14 hlcoord 1, 14
ld de, String_TooBadTheTradeWasCanceled ld de, String_TooBadTheTradeWasCanceled
call PlaceString call PlaceString
jp Function28ea3 jp InitTradeMenuDisplay_Delay
.asm_28c7b .do_trade
ld hl, sPartyMail ld hl, sPartyMail
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
ld bc, MAIL_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
@ -1715,18 +1721,18 @@ LinkTrade:
add hl, bc add hl, bc
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
ld c, a ld c, a
.asm_28c96 .copy_mail
inc c inc c
ld a, c ld a, c
cp PARTY_LENGTH cp PARTY_LENGTH
jr z, .asm_28ca6 jr z, .copy_player_data
push bc push bc
ld bc, MAIL_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
pop bc pop bc
jr .asm_28c96 jr .copy_mail
.asm_28ca6 .copy_player_data
ld hl, sPartyMail ld hl, sPartyMail
ld a, [wPartyCount] ld a, [wPartyCount]
dec a dec a
@ -1741,10 +1747,14 @@ LinkTrade:
ld bc, MAIL_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
call CloseSRAM call CloseSRAM
; Buffer player data
; nickname
ld hl, wPlayerName ld hl, wPlayerName
ld de, wPlayerTrademonSenderName ld de, wPlayerTrademonSenderName
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyBytes call CopyBytes
; species
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
ld hl, wPartySpecies ld hl, wPartySpecies
ld b, 0 ld b, 0
@ -1753,12 +1763,14 @@ LinkTrade:
ld a, [hl] ld a, [hl]
ld [wPlayerTrademonSpecies], a ld [wPlayerTrademonSpecies], a
push af push af
; OT name
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
ld hl, wPartyMonOT ld hl, wPartyMonOT
call SkipNames call SkipNames
ld de, wPlayerTrademonOTName ld de, wPlayerTrademonOTName
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyBytes call CopyBytes
; ID
ld hl, wPartyMon1ID ld hl, wPartyMon1ID
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
call GetPartyLocation call GetPartyLocation
@ -1766,6 +1778,7 @@ LinkTrade:
ld [wPlayerTrademonID], a ld [wPlayerTrademonID], a
ld a, [hl] ld a, [hl]
ld [wPlayerTrademonID + 1], a ld [wPlayerTrademonID + 1], a
; DVs
ld hl, wPartyMon1DVs ld hl, wPartyMon1DVs
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
call GetPartyLocation call GetPartyLocation
@ -1773,6 +1786,7 @@ LinkTrade:
ld [wPlayerTrademonDVs], a ld [wPlayerTrademonDVs], a
ld a, [hl] ld a, [hl]
ld [wPlayerTrademonDVs + 1], a ld [wPlayerTrademonDVs + 1], a
; caught data
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
ld hl, wPartyMon1Species ld hl, wPartyMon1Species
call GetPartyLocation call GetPartyLocation
@ -1781,10 +1795,14 @@ LinkTrade:
farcall GetCaughtGender farcall GetCaughtGender
ld a, c ld a, c
ld [wPlayerTrademonCaughtData], a ld [wPlayerTrademonCaughtData], a
; Buffer other player data
; nickname
ld hl, wOTPlayerName ld hl, wOTPlayerName
ld de, wOTTrademonSenderName ld de, wOTTrademonSenderName
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyBytes call CopyBytes
; species
ld a, [wCurOTTradePartyMon] ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies ld hl, wOTPartySpecies
ld b, 0 ld b, 0
@ -1792,12 +1810,14 @@ LinkTrade:
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld [wOTTrademonSpecies], a ld [wOTTrademonSpecies], a
; OT name
ld a, [wCurOTTradePartyMon] ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMonOT ld hl, wOTPartyMonOT
call SkipNames call SkipNames
ld de, wOTTrademonOTName ld de, wOTTrademonOTName
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyBytes call CopyBytes
; ID
ld hl, wOTPartyMon1ID ld hl, wOTPartyMon1ID
ld a, [wCurOTTradePartyMon] ld a, [wCurOTTradePartyMon]
call GetPartyLocation call GetPartyLocation
@ -1805,6 +1825,7 @@ LinkTrade:
ld [wOTTrademonID], a ld [wOTTrademonID], a
ld a, [hl] ld a, [hl]
ld [wOTTrademonID + 1], a ld [wOTTrademonID + 1], a
; DVs
ld hl, wOTPartyMon1DVs ld hl, wOTPartyMon1DVs
ld a, [wCurOTTradePartyMon] ld a, [wCurOTTradePartyMon]
call GetPartyLocation call GetPartyLocation
@ -1812,6 +1833,7 @@ LinkTrade:
ld [wOTTrademonDVs], a ld [wOTTrademonDVs], a
ld a, [hl] ld a, [hl]
ld [wOTTrademonDVs + 1], a ld [wOTTrademonDVs + 1], a
; caught data
ld a, [wCurOTTradePartyMon] ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMon1Species ld hl, wOTPartyMon1Species
call GetPartyLocation call GetPartyLocation
@ -1820,6 +1842,7 @@ LinkTrade:
farcall GetCaughtGender farcall GetCaughtGender
ld a, c ld a, c
ld [wOTTrademonCaughtData], a ld [wOTTrademonCaughtData], a
ld a, [wCurTradePartyMon] ld a, [wCurTradePartyMon]
ld [wCurPartyMon], a ld [wCurPartyMon], a
ld hl, wPartySpecies ld hl, wPartySpecies
@ -1828,6 +1851,7 @@ LinkTrade:
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld [wCurTradePartyMon], a ld [wCurTradePartyMon], a
xor a ; REMOVE_PARTY xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a ld [wPokemonWithdrawDepositParameter], a
callfar RemoveMonFromPartyOrBox callfar RemoveMonFromPartyOrBox
@ -1844,6 +1868,7 @@ LinkTrade:
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld [wCurOTTradePartyMon], a ld [wCurOTTradePartyMon], a
ld c, 100 ld c, 100
call DelayFrames call DelayFrames
call ClearTilemap call ClearTilemap
@ -1935,7 +1960,7 @@ LinkTrade:
ld c, 18 ld c, 18
call LinkTextboxAtHL call LinkTextboxAtHL
hlcoord 1, 14 hlcoord 1, 14
ld de, String28ebd ld de, String_TradeCompleted
call PlaceString call PlaceString
farcall Link_WaitBGMap farcall Link_WaitBGMap
ld c, 50 ld c, 50
@ -1945,12 +1970,12 @@ LinkTrade:
jp z, Gen2ToGen1LinkComms jp z, Gen2ToGen1LinkComms
jp Gen2ToGen2LinkComms jp Gen2ToGen2LinkComms
Function28ea3: InitTradeMenuDisplay_Delay:
ld c, 100 ld c, 100
call DelayFrames call DelayFrames
jp InitTradeMenuDisplay jp InitTradeMenuDisplay
String28eab: String_TradeCancel:
db "TRADE" db "TRADE"
next "CANCEL@" next "CANCEL@"
@ -1958,7 +1983,7 @@ LinkAskTradeForText:
text_far _LinkAskTradeForText text_far _LinkAskTradeForText
text_end text_end
String28ebd: String_TradeCompleted:
db "Trade completed!@" db "Trade completed!@"
String_TooBadTheTradeWasCanceled: String_TooBadTheTradeWasCanceled:

View File

@ -153,15 +153,15 @@ LinkTextbox:
call _LinkTextbox call _LinkTextbox
ret ret
Function16d6ce: PrintWaitingTextAndSyncAndExchangeNybble:
call LoadStandardMenuHeader call LoadStandardMenuHeader
call Function16d6e1 call .PrintWaitingText
farcall WaitLinkTransfer farcall WaitLinkTransfer
call Call_ExitMenu call Call_ExitMenu
call WaitBGMap2 call WaitBGMap2
ret ret
Function16d6e1: .PrintWaitingText:
hlcoord 4, 10 hlcoord 4, 10
ld b, 1 ld b, 1
ld c, 10 ld c, 10

View File

@ -1580,7 +1580,7 @@ wPredefTemp:: dw
wPredefAddress:: dw wPredefAddress:: dw
wFarCallBCBuffer:: dw wFarCallBCBuffer:: dw
wcfbb:: db wUnusedLinkCommunicationByte:: db
wGameTimerPaused:: wGameTimerPaused::
; bit 0: game timer paused ; bit 0: game timer paused