mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Identify wLinkBattleRNPreamble
This commit is contained in:
parent
6220200f0f
commit
9ab9088a9f
@ -30,6 +30,8 @@ SERIAL_NO_DATA_BYTE EQU $fe
|
|||||||
SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
|
SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
|
||||||
|
|
||||||
SERIAL_PREAMBLE_LENGTH EQU 6
|
SERIAL_PREAMBLE_LENGTH EQU 6
|
||||||
|
SERIAL_RN_PREAMBLE_LENGTH EQU 7
|
||||||
|
SERIAL_RNS_LENGTH EQU 10
|
||||||
|
|
||||||
; timeout duration after exchanging a byte
|
; timeout duration after exchanging a byte
|
||||||
SERIAL_LINK_BYTE_TIMEOUT EQU $5000
|
SERIAL_LINK_BYTE_TIMEOUT EQU $5000
|
||||||
|
@ -73,9 +73,9 @@ Gen2ToGen1LinkComms:
|
|||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
ld a, 1 << SERIAL
|
ld a, 1 << SERIAL
|
||||||
ldh [rIE], a
|
ldh [rIE], a
|
||||||
ld hl, wd1f3
|
ld hl, wLinkBattleRNPreamble
|
||||||
ld de, wEnemyMonSpecies
|
ld de, wEnemyMonSpecies
|
||||||
ld bc, $11
|
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
|
||||||
@ -87,7 +87,7 @@ Gen2ToGen1LinkComms:
|
|||||||
ld [de], a
|
ld [de], a
|
||||||
ld hl, wLink_c608
|
ld hl, wLink_c608
|
||||||
ld de, wTrademons
|
ld de, wTrademons
|
||||||
ld bc, wTrademons - wLink_c608
|
ld bc, 200
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
xor a
|
xor a
|
||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
@ -217,9 +217,9 @@ Gen2ToGen2LinkComms:
|
|||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
ld a, 1 << SERIAL
|
ld a, 1 << SERIAL
|
||||||
ldh [rIE], a
|
ldh [rIE], a
|
||||||
ld hl, wd1f3
|
ld hl, wLinkBattleRNPreamble
|
||||||
ld de, wEnemyMonSpecies
|
ld de, wEnemyMonSpecies
|
||||||
ld bc, $11
|
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
|
||||||
@ -231,7 +231,7 @@ Gen2ToGen2LinkComms:
|
|||||||
ld [de], a
|
ld [de], a
|
||||||
ld hl, wLink_c608
|
ld hl, wLink_c608
|
||||||
ld de, wTrademons
|
ld de, wTrademons
|
||||||
ld bc, wTrademons - wLink_c608
|
ld bc, 200
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, [wLinkMode]
|
ld a, [wLinkMode]
|
||||||
cp LINK_TRADECENTER
|
cp LINK_TRADECENTER
|
||||||
@ -561,36 +561,41 @@ ClearLinkData:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
FixDataForLinkTransfer:
|
FixDataForLinkTransfer:
|
||||||
ld hl, wd1f3
|
ld hl, wLinkBattleRNPreamble
|
||||||
ld a, SERIAL_PREAMBLE_BYTE
|
ld a, SERIAL_PREAMBLE_BYTE
|
||||||
ld b, wLinkBattleRNs - wd1f3
|
ld b, SERIAL_RN_PREAMBLE_LENGTH
|
||||||
.loop1
|
.preamble_loop
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop1
|
jr nz, .preamble_loop
|
||||||
ld b, wTempEnemyMonSpecies - wLinkBattleRNs
|
|
||||||
.loop2
|
assert wLinkBattleRNPreamble + SERIAL_RN_PREAMBLE_LENGTH == wLinkBattleRNs
|
||||||
|
ld b, SERIAL_RNS_LENGTH
|
||||||
|
.rn_loop
|
||||||
call Random
|
call Random
|
||||||
cp SERIAL_PREAMBLE_BYTE
|
cp SERIAL_PREAMBLE_BYTE
|
||||||
jr nc, .loop2
|
jr nc, .rn_loop
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop2
|
jr nz, .rn_loop
|
||||||
|
|
||||||
ld hl, wLink_c608
|
ld hl, wLink_c608
|
||||||
ld a, SERIAL_PREAMBLE_BYTE
|
ld a, SERIAL_PREAMBLE_BYTE
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld b, $c8
|
|
||||||
|
ld b, 200
|
||||||
xor a
|
xor a
|
||||||
.loop3
|
.loop1
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop3
|
jr nz, .loop1
|
||||||
|
|
||||||
ld hl, wTimeCapsulePlayerData - 1 + PARTY_LENGTH
|
ld hl, wTimeCapsulePlayerData - 1 + PARTY_LENGTH
|
||||||
ld de, wc612
|
ld de, wc612
|
||||||
lb bc, 0, 0
|
lb bc, 0, 0
|
||||||
.loop4
|
.loop2
|
||||||
inc c
|
inc c
|
||||||
ld a, c
|
ld a, c
|
||||||
cp SERIAL_PREAMBLE_BYTE
|
cp SERIAL_PREAMBLE_BYTE
|
||||||
@ -613,19 +618,19 @@ FixDataForLinkTransfer:
|
|||||||
inc hl
|
inc hl
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
cp SERIAL_NO_DATA_BYTE
|
cp SERIAL_NO_DATA_BYTE
|
||||||
jr nz, .loop4
|
jr nz, .loop2
|
||||||
ld a, c
|
ld a, c
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR
|
ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR
|
||||||
jr .loop4
|
jr .loop2
|
||||||
|
|
||||||
.next1
|
.next1
|
||||||
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
lb bc, 1, 0
|
lb bc, 1, 0
|
||||||
jr .loop4
|
jr .loop2
|
||||||
|
|
||||||
.done
|
.done
|
||||||
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
||||||
|
12
wram.asm
12
wram.asm
@ -2263,6 +2263,12 @@ wEvolutionNewSpecies:: db
|
|||||||
wEvolutionPicOffset:: db
|
wEvolutionPicOffset:: db
|
||||||
wEvolutionCanceled:: db
|
wEvolutionCanceled:: db
|
||||||
|
|
||||||
|
NEXTU
|
||||||
|
; link
|
||||||
|
ds 9
|
||||||
|
wLinkBattleRNPreamble:: ds SERIAL_RN_PREAMBLE_LENGTH
|
||||||
|
wLinkBattleRNs:: ds SERIAL_RNS_LENGTH
|
||||||
|
|
||||||
NEXTU
|
NEXTU
|
||||||
; mobile
|
; mobile
|
||||||
ds 2
|
ds 2
|
||||||
@ -2273,7 +2279,7 @@ wd1ef:: ds 1
|
|||||||
wd1f0:: ds 1
|
wd1f0:: ds 1
|
||||||
wd1f1:: ds 1
|
wd1f1:: ds 1
|
||||||
wd1f2:: ds 1
|
wd1f2:: ds 1
|
||||||
wd1f3:: ds 4
|
wd1f3:: ds 1
|
||||||
|
|
||||||
NEXTU
|
NEXTU
|
||||||
; miscellaneous
|
; miscellaneous
|
||||||
@ -2284,10 +2290,6 @@ wOtherDecoration:: db
|
|||||||
wCurEnemyItem:: db
|
wCurEnemyItem:: db
|
||||||
ENDU
|
ENDU
|
||||||
|
|
||||||
ds 3
|
|
||||||
|
|
||||||
wLinkBattleRNs:: ds 10
|
|
||||||
|
|
||||||
wTempEnemyMonSpecies:: db
|
wTempEnemyMonSpecies:: db
|
||||||
wTempBattleMonSpecies:: db
|
wTempBattleMonSpecies:: db
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user