mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Group some link.asm code into "paragraphs"
This commit is contained in:
parent
1756a553f7
commit
01d6e6c758
@ -73,27 +73,33 @@ Gen2ToGen1LinkComms:
|
|||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
ld a, 1 << SERIAL
|
ld a, 1 << SERIAL
|
||||||
ldh [rIE], a
|
ldh [rIE], a
|
||||||
|
|
||||||
ld hl, wLinkBattleRNPreamble
|
ld hl, wLinkBattleRNPreamble
|
||||||
ld de, wEnemyMonSpecies
|
ld de, wEnemyMon
|
||||||
ld bc, SERIAL_RN_PREAMBLE_LENGTH + SERIAL_RNS_LENGTH
|
ld bc, SERIAL_RN_PREAMBLE_LENGTH + SERIAL_RNS_LENGTH
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, SERIAL_NO_DATA_BYTE
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
ld [de], a
|
ld [de], a
|
||||||
|
|
||||||
ld hl, wLinkData
|
ld hl, wLinkData
|
||||||
ld de, wOTPlayerName
|
ld de, wOTPlayerName
|
||||||
ld bc, $1a8
|
ld bc, $1a8
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, SERIAL_NO_DATA_BYTE
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
ld [de], a
|
ld [de], a
|
||||||
|
|
||||||
ld hl, wLink_c608
|
ld hl, wLink_c608
|
||||||
ld de, wTrademons
|
ld de, wTrademons
|
||||||
ld bc, 200
|
ld bc, 200
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
|
|
||||||
xor a
|
xor a
|
||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
|
ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
|
||||||
ldh [rIE], a
|
ldh [rIE], a
|
||||||
|
|
||||||
call Link_CopyRandomNumbers
|
call Link_CopyRandomNumbers
|
||||||
|
|
||||||
ld hl, wOTPlayerName
|
ld hl, wOTPlayerName
|
||||||
call Link_FindFirstNonControlCharacter_SkipZero
|
call Link_FindFirstNonControlCharacter_SkipZero
|
||||||
push hl
|
push hl
|
||||||
@ -105,9 +111,11 @@ Gen2ToGen1LinkComms:
|
|||||||
jp z, ExitLinkCommunications
|
jp z, ExitLinkCommunications
|
||||||
cp $7
|
cp $7
|
||||||
jp nc, ExitLinkCommunications
|
jp nc, ExitLinkCommunications
|
||||||
|
|
||||||
ld de, wLinkData
|
ld de, wLinkData
|
||||||
ld bc, $1a2
|
ld bc, $1a2
|
||||||
call Link_CopyOTData
|
call Link_CopyOTData
|
||||||
|
|
||||||
ld de, wPlayerTrademon
|
ld de, wPlayerTrademon
|
||||||
ld hl, wTimeCapsulePlayerData
|
ld hl, wTimeCapsulePlayerData
|
||||||
ld c, 2
|
ld c, 2
|
||||||
@ -138,10 +146,12 @@ Gen2ToGen1LinkComms:
|
|||||||
ld hl, wc90f
|
ld hl, wc90f
|
||||||
dec c
|
dec c
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
|
|
||||||
ld hl, wLinkPlayerName
|
ld hl, wLinkPlayerName
|
||||||
ld de, wOTPlayerName
|
ld de, wOTPlayerName
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld de, wOTPartyCount
|
ld de, wOTPartyCount
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [de], a
|
ld [de], a
|
||||||
@ -165,10 +175,12 @@ Gen2ToGen1LinkComms:
|
|||||||
ld [de], a
|
ld [de], a
|
||||||
ld hl, wTimeCapsulePlayerData
|
ld hl, wTimeCapsulePlayerData
|
||||||
call Link_ConvertPartyStruct1to2
|
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)
|
||||||
ld [wUnusedNamesPointer + 1], a
|
ld [wUnusedNamesPointer + 1], a
|
||||||
|
|
||||||
ld de, MUSIC_NONE
|
ld de, MUSIC_NONE
|
||||||
call PlayMusic
|
call PlayMusic
|
||||||
ldh a, [hSerialConnectionStatus]
|
ldh a, [hSerialConnectionStatus]
|
||||||
@ -189,7 +201,7 @@ Gen2ToGen2LinkComms:
|
|||||||
jp z, LinkTimeout
|
jp z, LinkTimeout
|
||||||
ldh a, [hSerialConnectionStatus]
|
ldh a, [hSerialConnectionStatus]
|
||||||
cp USING_INTERNAL_CLOCK
|
cp USING_INTERNAL_CLOCK
|
||||||
jr nz, .Player1
|
jr nz, .player_1
|
||||||
|
|
||||||
ld c, 3
|
ld c, 3
|
||||||
call DelayFrames
|
call DelayFrames
|
||||||
@ -208,7 +220,7 @@ Gen2ToGen2LinkComms:
|
|||||||
ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
|
ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
|
||||||
ldh [rSC], a
|
ldh [rSC], a
|
||||||
|
|
||||||
.Player1:
|
.player_1
|
||||||
ld de, MUSIC_NONE
|
ld de, MUSIC_NONE
|
||||||
call PlayMusic
|
call PlayMusic
|
||||||
ld c, 3
|
ld c, 3
|
||||||
@ -217,22 +229,26 @@ Gen2ToGen2LinkComms:
|
|||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
ld a, 1 << SERIAL
|
ld a, 1 << SERIAL
|
||||||
ldh [rIE], a
|
ldh [rIE], a
|
||||||
|
|
||||||
ld hl, wLinkBattleRNPreamble
|
ld hl, wLinkBattleRNPreamble
|
||||||
ld de, wEnemyMonSpecies
|
ld de, wEnemyMon
|
||||||
ld bc, SERIAL_RN_PREAMBLE_LENGTH + SERIAL_RNS_LENGTH
|
ld bc, SERIAL_RN_PREAMBLE_LENGTH + SERIAL_RNS_LENGTH
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, SERIAL_NO_DATA_BYTE
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
ld [de], a
|
ld [de], a
|
||||||
|
|
||||||
ld hl, wLinkData
|
ld hl, wLinkData
|
||||||
ld de, wOTPlayerName
|
ld de, wOTPlayerName
|
||||||
ld bc, $1c2
|
ld bc, $1c2
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, SERIAL_NO_DATA_BYTE
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
ld [de], a
|
ld [de], a
|
||||||
|
|
||||||
ld hl, wLink_c608
|
ld hl, wLink_c608
|
||||||
ld de, wTrademons
|
ld de, wTrademons
|
||||||
ld bc, 200
|
ld bc, 200
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
|
|
||||||
ld a, [wLinkMode]
|
ld a, [wLinkMode]
|
||||||
cp LINK_TRADECENTER
|
cp LINK_TRADECENTER
|
||||||
jr nz, .not_trading
|
jr nz, .not_trading
|
||||||
@ -248,12 +264,15 @@ Gen2ToGen2LinkComms:
|
|||||||
ldh [rIE], a
|
ldh [rIE], a
|
||||||
ld de, MUSIC_NONE
|
ld de, MUSIC_NONE
|
||||||
call PlayMusic
|
call PlayMusic
|
||||||
|
|
||||||
call Link_CopyRandomNumbers
|
call Link_CopyRandomNumbers
|
||||||
|
|
||||||
ld hl, wOTPlayerName
|
ld hl, wOTPlayerName
|
||||||
call Link_FindFirstNonControlCharacter_SkipZero
|
call Link_FindFirstNonControlCharacter_SkipZero
|
||||||
ld de, wLinkData
|
ld de, wLinkData
|
||||||
ld bc, $1b9
|
ld bc, $1b9
|
||||||
call Link_CopyOTData
|
call Link_CopyOTData
|
||||||
|
|
||||||
ld de, wPlayerTrademon
|
ld de, wPlayerTrademon
|
||||||
ld hl, wLinkPlayerData
|
ld hl, wLinkPlayerData
|
||||||
ld c, 2
|
ld c, 2
|
||||||
@ -284,6 +303,7 @@ Gen2ToGen2LinkComms:
|
|||||||
ld hl, wc90f
|
ld hl, wc90f
|
||||||
dec c
|
dec c
|
||||||
jr nz, .loop1
|
jr nz, .loop1
|
||||||
|
|
||||||
ld a, [wLinkMode]
|
ld a, [wLinkMode]
|
||||||
cp LINK_TRADECENTER
|
cp LINK_TRADECENTER
|
||||||
jp nz, .skip_mail
|
jp nz, .skip_mail
|
||||||
@ -398,19 +418,24 @@ Gen2ToGen2LinkComms:
|
|||||||
ld de, wOTPlayerName
|
ld de, wOTPlayerName
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld de, wOTPartyCount
|
ld de, wOTPartyCount
|
||||||
ld bc, 1 + PARTY_LENGTH + 1
|
ld bc, 1 + PARTY_LENGTH + 1
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld de, wOTPlayerID
|
ld de, wOTPlayerID
|
||||||
ld bc, 2
|
ld bc, 2
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld de, wOTPartyMons
|
ld de, wOTPartyMons
|
||||||
ld bc, wOTPartyDataEnd - wOTPartyMons
|
ld bc, wOTPartyDataEnd - wOTPartyMons
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld a, LOW(wOTPartyMonOT)
|
ld a, LOW(wOTPartyMonOT)
|
||||||
ld [wUnusedNamesPointer], a
|
ld [wUnusedNamesPointer], a
|
||||||
ld a, HIGH(wOTPartyMonOT)
|
ld a, HIGH(wOTPartyMonOT)
|
||||||
ld [wUnusedNamesPointer + 1], a
|
ld [wUnusedNamesPointer + 1], a
|
||||||
|
|
||||||
ld de, MUSIC_NONE
|
ld de, MUSIC_NONE
|
||||||
call PlayMusic
|
call PlayMusic
|
||||||
ldh a, [hSerialConnectionStatus]
|
ldh a, [hSerialConnectionStatus]
|
||||||
@ -646,9 +671,11 @@ Link_PrepPartyData_Gen1:
|
|||||||
inc de
|
inc de
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop1
|
jr nz, .loop1
|
||||||
|
|
||||||
ld hl, wPlayerName
|
ld hl, wPlayerName
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
push de
|
push de
|
||||||
ld hl, wPartyCount
|
ld hl, wPartyCount
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
@ -668,12 +695,12 @@ Link_PrepPartyData_Gen1:
|
|||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
jr .loop2
|
jr .loop2
|
||||||
|
|
||||||
.done_party
|
.done_party
|
||||||
ld [de], a
|
ld [de], a
|
||||||
pop de
|
pop de
|
||||||
ld hl, 1 + PARTY_LENGTH + 1
|
ld hl, 1 + PARTY_LENGTH + 1
|
||||||
add hl, de
|
add hl, de
|
||||||
|
|
||||||
ld d, h
|
ld d, h
|
||||||
ld e, l
|
ld e, l
|
||||||
ld hl, wPartyMon1Species
|
ld hl, wPartyMon1Species
|
||||||
@ -686,8 +713,10 @@ Link_PrepPartyData_Gen1:
|
|||||||
pop bc
|
pop bc
|
||||||
dec c
|
dec c
|
||||||
jr nz, .mon_loop
|
jr nz, .mon_loop
|
||||||
|
|
||||||
ld hl, wPartyMonOT
|
ld hl, wPartyMonOT
|
||||||
call .copy_ot_nicks
|
call .copy_ot_nicks
|
||||||
|
|
||||||
ld hl, wPartyMonNicknames
|
ld hl, wPartyMonNicknames
|
||||||
.copy_ot_nicks
|
.copy_ot_nicks
|
||||||
ld bc, PARTY_LENGTH * NAME_LENGTH
|
ld bc, PARTY_LENGTH * NAME_LENGTH
|
||||||
@ -812,21 +841,27 @@ Link_PrepPartyData_Gen2:
|
|||||||
inc de
|
inc de
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop1
|
jr nz, .loop1
|
||||||
|
|
||||||
ld hl, wPlayerName
|
ld hl, wPlayerName
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld hl, wPartyCount
|
ld hl, wPartyCount
|
||||||
ld bc, 1 + PARTY_LENGTH + 1
|
ld bc, 1 + PARTY_LENGTH + 1
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld hl, wPlayerID
|
ld hl, wPlayerID
|
||||||
ld bc, 2
|
ld bc, 2
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld hl, wPartyMon1Species
|
ld hl, wPartyMon1Species
|
||||||
ld bc, PARTY_LENGTH * PARTYMON_STRUCT_LENGTH
|
ld bc, PARTY_LENGTH * PARTYMON_STRUCT_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld hl, wPartyMonOT
|
ld hl, wPartyMonOT
|
||||||
ld bc, PARTY_LENGTH * NAME_LENGTH
|
ld bc, PARTY_LENGTH * NAME_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
|
|
||||||
ld hl, wPartyMonNicknames
|
ld hl, wPartyMonNicknames
|
||||||
ld bc, PARTY_LENGTH * MON_NAME_LENGTH
|
ld bc, PARTY_LENGTH * MON_NAME_LENGTH
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
@ -867,7 +902,6 @@ Link_PrepPartyData_Gen2:
|
|||||||
pop bc
|
pop bc
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop3
|
jr nz, .loop3
|
||||||
|
|
||||||
ld b, PARTY_LENGTH
|
ld b, PARTY_LENGTH
|
||||||
ld de, sPartyMail
|
ld de, sPartyMail
|
||||||
ld hl, wc9f9
|
ld hl, wc9f9
|
||||||
@ -885,12 +919,10 @@ Link_PrepPartyData_Gen2:
|
|||||||
jr nc, .italian_spanish
|
jr nc, .italian_spanish
|
||||||
farcall ConvertFrenchGermanMailToEnglish
|
farcall ConvertFrenchGermanMailToEnglish
|
||||||
jr .next
|
jr .next
|
||||||
|
|
||||||
.italian_spanish
|
.italian_spanish
|
||||||
cp $2
|
cp $2
|
||||||
jr nc, .next
|
jr nc, .next
|
||||||
farcall ConvertSpanishItalianMailToEnglish
|
farcall ConvertSpanishItalianMailToEnglish
|
||||||
|
|
||||||
.next
|
.next
|
||||||
pop de
|
pop de
|
||||||
ld hl, MAIL_STRUCT_LENGTH
|
ld hl, MAIL_STRUCT_LENGTH
|
||||||
@ -904,6 +936,7 @@ Link_PrepPartyData_Gen2:
|
|||||||
dec b
|
dec b
|
||||||
jr nz, .loop4
|
jr nz, .loop4
|
||||||
call CloseSRAM
|
call CloseSRAM
|
||||||
|
|
||||||
ld hl, wc9f9
|
ld hl, wc9f9
|
||||||
ld bc, PARTY_LENGTH * (sPartyMon1MailAuthor - sPartyMon1Mail)
|
ld bc, PARTY_LENGTH * (sPartyMon1MailAuthor - sPartyMon1Mail)
|
||||||
.loop5
|
.loop5
|
||||||
@ -911,13 +944,13 @@ Link_PrepPartyData_Gen2:
|
|||||||
cp SERIAL_NO_DATA_BYTE
|
cp SERIAL_NO_DATA_BYTE
|
||||||
jr nz, .skip2
|
jr nz, .skip2
|
||||||
ld [hl], sPartyMon1MailAuthor - sPartyMon1Mail
|
ld [hl], sPartyMon1MailAuthor - sPartyMon1Mail
|
||||||
|
|
||||||
.skip2
|
.skip2
|
||||||
inc hl
|
inc hl
|
||||||
dec bc
|
dec bc
|
||||||
ld a, b
|
ld a, b
|
||||||
or c
|
or c
|
||||||
jr nz, .loop5
|
jr nz, .loop5
|
||||||
|
|
||||||
ld hl, wcabf
|
ld hl, wcabf
|
||||||
ld de, wcb13
|
ld de, wcb13
|
||||||
ld b, PARTY_LENGTH * (sPartyMon1MailEnd - sPartyMon1MailAuthor)
|
ld b, PARTY_LENGTH * (sPartyMon1MailEnd - sPartyMon1MailAuthor)
|
||||||
@ -931,11 +964,11 @@ Link_PrepPartyData_Gen2:
|
|||||||
ld a, c
|
ld a, c
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
|
|
||||||
.skip3
|
.skip3
|
||||||
inc hl
|
inc hl
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop6
|
jr nz, .loop6
|
||||||
|
|
||||||
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
||||||
ld [de], a
|
ld [de], a
|
||||||
ret
|
ret
|
||||||
|
@ -89,6 +89,7 @@ Serial::
|
|||||||
reti
|
reti
|
||||||
|
|
||||||
Serial_ExchangeBytes::
|
Serial_ExchangeBytes::
|
||||||
|
; send bc bytes from hl, receive bc bytes to de
|
||||||
ld a, TRUE
|
ld a, TRUE
|
||||||
ldh [hSerialIgnoringInitialData], a
|
ldh [hSerialIgnoringInitialData], a
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user