Skip to content

Commit

Permalink
Identify some more link.asm labels (syncing to pokegold)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Oct 23, 2020
1 parent 8a73bb9 commit 7991db9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 38 deletions.
2 changes: 1 addition & 1 deletion data/events/special_pointers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SpecialsPointers::
; Communications
add_special SetBitsForLinkTradeRequest
add_special WaitForLinkedFriend
add_special CheckLinkTimeout
add_special CheckLinkTimeout_Receptionist
add_special TryQuickSave
add_special CheckBothSelectedSameRoom
add_special FailedLinkToPast
Expand Down
63 changes: 36 additions & 27 deletions engine/link/link.asm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Gen2ToGen2LinkComms:
call ClearLinkData
call Link_PrepPartyData_Gen2
call FixDataForLinkTransfer
call Function29dba
call CheckLinkTimeout_Gen2
ld a, [wScriptVar]
and a
jp z, LinkTimeout
Expand Down Expand Up @@ -1170,7 +1170,7 @@ Link_FindFirstNonControlCharacter_AllowZero:

InitTradeMenuDisplay:
call ClearScreen
call LoadTradeScreenBorder
call LoadTradeScreenBorderGFX
farcall InitTradeSpeciesList
xor a
ld hl, wOtherPlayerLinkMode
Expand Down Expand Up @@ -1879,7 +1879,7 @@ LinkTrade:
ld [wCurPartyMon], a
callfar EvolvePokemon
call ClearScreen
call LoadTradeScreenBorder
call LoadTradeScreenBorderGFX
call SetTradeRoomBGPals
farcall Link_WaitBGMap

Expand Down Expand Up @@ -1969,16 +1969,16 @@ LinkTextboxAtHL:
farcall LinkTextbox
ret

LoadTradeScreenBorder:
farcall _LoadTradeScreenBorder
LoadTradeScreenBorderGFX:
farcall _LoadTradeScreenBorderGFX
ret

SetTradeRoomBGPals:
farcall LoadTradeRoomBGPals ; just a nested farcall; so wasteful
call SetPalettes
ret

Function28f09: ; unreferenced
PlaceTradeScreenTextbox: ; unreferenced
hlcoord 0, 0
ld b, 6
ld c, 18
Expand Down Expand Up @@ -2061,19 +2061,20 @@ CheckTimeCapsuleCompatibility:
call GetMoveName
call CopyName1
pop bc
call Function29c67
call GetIncompatibleMonName
ld a, $2
jr .done

.mon_has_mail
call Function29c67
call GetIncompatibleMonName
ld a, $3

.done
ld [wScriptVar], a
ret

Function29c67:
GetIncompatibleMonName:
; Calulate which pokemon is incompatible, and get that pokemon's name
ld a, [wPartyCount]
sub b
ld c, a
Expand Down Expand Up @@ -2243,7 +2244,7 @@ WaitForLinkedFriend:
ld [wScriptVar], a
ret

CheckLinkTimeout:
CheckLinkTimeout_Receptionist:
ld a, $1
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
Expand All @@ -2264,11 +2265,12 @@ CheckLinkTimeout:
ret nz
jp Link_ResetSerialRegistersAfterLinkClosure

Function29dba:
CheckLinkTimeout_Gen2:
; if wScriptVar = 0 on exit, link connection is closed
ld a, $5
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
ld a, $3
ld a, 3
ld [hli], a
xor a
ld [hl], a
Expand All @@ -2280,33 +2282,39 @@ Function29dba:
call Link_CheckCommunicationError
ld a, [wScriptVar]
and a
jr z, .vblank
ld bc, -1
jr z, .exit

; Wait for ~$70000 cycles to give the other GB time to be ready
ld bc, $ffff
.wait
dec bc
ld a, b
or c
jr nz, .wait

; If other GB is not ready at this point, disconnect due to timeout
ld a, [wOtherPlayerLinkMode]
cp $5
jr nz, .script_var
jr nz, .timeout

; Another check to increase reliability
ld a, $6
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
ld a, $1
ld a, 1
ld [hli], a
ld [hl], $32
ld [hl], 50
call Link_CheckCommunicationError
ld a, [wOtherPlayerLinkMode]
cp $6
jr z, .vblank
jr z, .exit

.script_var
.timeout
xor a
ld [wScriptVar], a
ret

.vblank
.exit
xor a
ldh [hVBlank], a
ret
Expand All @@ -2327,13 +2335,13 @@ Link_CheckCommunicationError:
call .CheckConnected
jr nz, .load_true
call .AcknowledgeSerial
xor a
jr .load_scriptvar
xor a ; FALSE
jr .done

.load_true
ld a, $1
ld a, TRUE

.load_scriptvar
.done
ld [wScriptVar], a
ld hl, wLinkTimeoutFrames
xor a
Expand Down Expand Up @@ -2513,10 +2521,11 @@ CableClubCheckWhichChris:
GSLinkCommsBorderGFX: ; unreferenced
INCBIN "gfx/trade/unused_gs_border_tiles.2bpp"

Function29fe4: ; unreferenced
ld a, BANK(sPartyMail)
CheckSRAM0Flag: ; unreferenced
; input: hl = unknown flag array in "SRAM Bank 0"
ld a, BANK("SRAM Bank 0")
call OpenSRAM
ld d, FALSE
ld d, 0
ld b, CHECK_FLAG
predef SmallFarFlagAction
call CloseSRAM
Expand Down
2 changes: 1 addition & 1 deletion engine/link/link_2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LinkMonStatsScreen:
call ClearScreen
call ClearBGPalettes
call MaxVolume
farcall LoadTradeScreenBorder
farcall LoadTradeScreenBorderGFX
farcall Link_WaitBGMap
farcall InitTradeSpeciesList
farcall SetTradeRoomBGPals
Expand Down
10 changes: 5 additions & 5 deletions engine/link/link_trade.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LinkCommsBorderGFX:
INCBIN "gfx/trade/border_tiles.2bpp"

__LoadTradeScreenBorder:
__LoadTradeScreenBorderGFX:
ld de, LinkCommsBorderGFX
ld hl, vTiles2
lb bc, BANK(LinkCommsBorderGFX), 70
Expand All @@ -20,7 +20,7 @@ Function16d43b:
call ClearBGPalettes
call ClearTilemap
call ClearSprites
farcall __LoadTradeScreenBorder ; useless to farcall
farcall __LoadTradeScreenBorderGFX ; useless to farcall
farcall Function16d42e ; useless to farcall
ld b, SCGB_DIPLOMA
call GetSGBLayout
Expand Down Expand Up @@ -110,7 +110,7 @@ _LinkTextbox:
ret

InitTradeSpeciesList:
call _LoadTradeScreenBorder
call _LoadTradeScreenBorderGFX
call Function16d6ae
farcall InitMG_Mobile_LinkTradePalMap
farcall PlaceTradePartnerNamesAndParty
Expand All @@ -122,8 +122,8 @@ InitTradeSpeciesList:
.CancelString:
db "CANCEL@"

_LoadTradeScreenBorder:
call __LoadTradeScreenBorder
_LoadTradeScreenBorderGFX:
call __LoadTradeScreenBorderGFX
ret

LinkComms_LoadPleaseWaitTextboxBorderGFX:
Expand Down
6 changes: 3 additions & 3 deletions maps/Pokecenter2F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ LinkReceptionistScript_Trade:
special TryQuickSave
iffalse .DidNotSave
writetext Text_PleaseWait
special CheckLinkTimeout
special CheckLinkTimeout_Receptionist
iffalse .LinkTimedOut
readmem wOtherPlayerLinkMode
iffalse .LinkedToFirstGen
Expand Down Expand Up @@ -193,7 +193,7 @@ LinkReceptionistScript_Battle:
special TryQuickSave
iffalse .DidNotSave
writetext Text_PleaseWait
special CheckLinkTimeout
special CheckLinkTimeout_Receptionist
iffalse .LinkTimedOut
readmem wOtherPlayerLinkMode
iffalse .LinkedToFirstGen
Expand Down Expand Up @@ -320,7 +320,7 @@ LinkReceptionistScript_TimeCapsule:
special TryQuickSave
iffalse .DidNotSave
writetext Text_PleaseWait
special CheckLinkTimeout
special CheckLinkTimeout_Receptionist
iffalse .LinkTimedOut
readmem wOtherPlayerLinkMode
iffalse .OK
Expand Down
2 changes: 1 addition & 1 deletion mobile/mobile_40.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6443,7 +6443,7 @@ Function102dd3:
ld hl, vTiles0
lb bc, BANK(MobileTradeLightsGFX), 4
call Get2bpp
farcall __LoadTradeScreenBorder
farcall __LoadTradeScreenBorderGFX
call EnableLCD
ret

Expand Down

0 comments on commit 7991db9

Please sign in to comment.