mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
Define SERIAL_PATCH_PREAMBLE_LENGTH
This commit is contained in:
parent
5ae35e5770
commit
4c4fd7258c
@ -32,9 +32,10 @@ DEF SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
|
|||||||
; used to replace SERIAL_NO_DATA_BYTE
|
; used to replace SERIAL_NO_DATA_BYTE
|
||||||
DEF SERIAL_PATCH_REPLACEMENT_BYTE EQU $ff
|
DEF SERIAL_PATCH_REPLACEMENT_BYTE EQU $ff
|
||||||
|
|
||||||
DEF SERIAL_PREAMBLE_LENGTH EQU 6
|
DEF SERIAL_PREAMBLE_LENGTH EQU 6
|
||||||
DEF SERIAL_RN_PREAMBLE_LENGTH EQU 7
|
DEF SERIAL_RN_PREAMBLE_LENGTH EQU 7
|
||||||
DEF SERIAL_RNS_LENGTH EQU 10
|
DEF SERIAL_PATCH_PREAMBLE_LENGTH EQU 3
|
||||||
|
DEF SERIAL_RNS_LENGTH EQU 10
|
||||||
|
|
||||||
DEF SERIAL_MAIL_PREAMBLE_BYTE EQU $20
|
DEF SERIAL_MAIL_PREAMBLE_BYTE EQU $20
|
||||||
DEF SERIAL_MAIL_PREAMBLE_LENGTH EQU 5
|
DEF SERIAL_MAIL_PREAMBLE_LENGTH EQU 5
|
||||||
|
@ -90,7 +90,7 @@ endc
|
|||||||
|
|
||||||
ld hl, wLinkData
|
ld hl, wLinkData
|
||||||
ld de, wOTPartyData
|
ld de, wOTPartyData
|
||||||
ld bc, SERIAL_PREAMBLE_LENGTH + NAME_LENGTH + 1 + PARTY_LENGTH + 1 + (REDMON_STRUCT_LENGTH + NAME_LENGTH * 2) * PARTY_LENGTH + 3
|
ld bc, SERIAL_PREAMBLE_LENGTH + NAME_LENGTH + (1 + PARTY_LENGTH + 1) + (REDMON_STRUCT_LENGTH + NAME_LENGTH * 2) * PARTY_LENGTH + 3
|
||||||
vc_hook Wireless_ExchangeBytes_Gen2toGen1_party_structs
|
vc_hook Wireless_ExchangeBytes_Gen2toGen1_party_structs
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, SERIAL_NO_DATA_BYTE
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
@ -256,7 +256,7 @@ endc
|
|||||||
|
|
||||||
ld hl, wLinkData
|
ld hl, wLinkData
|
||||||
ld de, wOTPartyData
|
ld de, wOTPartyData
|
||||||
ld bc, SERIAL_PREAMBLE_LENGTH + NAME_LENGTH + 1 + PARTY_LENGTH + 1 + 2 + (PARTYMON_STRUCT_LENGTH + NAME_LENGTH * 2) * PARTY_LENGTH + 3
|
ld bc, SERIAL_PREAMBLE_LENGTH + NAME_LENGTH + (1 + PARTY_LENGTH + 1) + 2 + (PARTYMON_STRUCT_LENGTH + NAME_LENGTH * 2) * PARTY_LENGTH + 3
|
||||||
vc_hook Wireless_ExchangeBytes_party_structs
|
vc_hook Wireless_ExchangeBytes_party_structs
|
||||||
call Serial_ExchangeBytes
|
call Serial_ExchangeBytes
|
||||||
ld a, SERIAL_NO_DATA_BYTE
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
@ -276,8 +276,8 @@ endc
|
|||||||
ld bc, wLinkPlayerMailEnd - wLinkPlayerMail
|
ld bc, wLinkPlayerMailEnd - wLinkPlayerMail
|
||||||
vc_hook Wireless_ExchangeBytes_mail
|
vc_hook Wireless_ExchangeBytes_mail
|
||||||
call ExchangeBytes
|
call ExchangeBytes
|
||||||
|
|
||||||
.not_trading
|
.not_trading
|
||||||
|
|
||||||
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)
|
||||||
@ -355,7 +355,7 @@ endc
|
|||||||
ld a, b
|
ld a, b
|
||||||
or c
|
or c
|
||||||
jr nz, .loop4
|
jr nz, .loop4
|
||||||
ld de, wOTPlayerMailPatchSet
|
ld de, wLinkOTMailPatchSet
|
||||||
.loop5
|
.loop5
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc de
|
inc de
|
||||||
@ -629,9 +629,9 @@ FixDataForLinkTransfer:
|
|||||||
; Clear the patch list
|
; Clear the patch list
|
||||||
ld hl, wPlayerPatchLists
|
ld hl, wPlayerPatchLists
|
||||||
ld a, SERIAL_PREAMBLE_BYTE
|
ld a, SERIAL_PREAMBLE_BYTE
|
||||||
|
rept SERIAL_PATCH_PREAMBLE_LENGTH
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hli], a
|
endr
|
||||||
ld [hli], a
|
|
||||||
ld b, SERIAL_PATCH_LIST_LENGTH
|
ld b, SERIAL_PATCH_LIST_LENGTH
|
||||||
xor a
|
xor a
|
||||||
.clear_loop
|
.clear_loop
|
||||||
@ -864,11 +864,11 @@ Link_PrepPartyData_Gen2:
|
|||||||
ld de, wLinkData
|
ld de, wLinkData
|
||||||
ld a, SERIAL_PREAMBLE_BYTE
|
ld a, SERIAL_PREAMBLE_BYTE
|
||||||
ld b, SERIAL_PREAMBLE_LENGTH
|
ld b, SERIAL_PREAMBLE_LENGTH
|
||||||
.loop1
|
.preamble_loop
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop1
|
jr nz, .preamble_loop
|
||||||
|
|
||||||
ld hl, wPlayerName
|
ld hl, wPlayerName
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
@ -909,7 +909,7 @@ Link_PrepPartyData_Gen2:
|
|||||||
call OpenSRAM
|
call OpenSRAM
|
||||||
ld hl, sPartyMail
|
ld hl, sPartyMail
|
||||||
ld b, PARTY_LENGTH
|
ld b, PARTY_LENGTH
|
||||||
.loop2
|
.message_loop
|
||||||
push bc
|
push bc
|
||||||
ld bc, MAIL_MSG_LENGTH + 1
|
ld bc, MAIL_MSG_LENGTH + 1
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
@ -917,12 +917,12 @@ Link_PrepPartyData_Gen2:
|
|||||||
add hl, bc
|
add hl, bc
|
||||||
pop bc
|
pop bc
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop2
|
jr nz, .message_loop
|
||||||
|
|
||||||
; Copy the mail data to wLinkPlayerMailMetadata
|
; Copy the mail data to wLinkPlayerMailMetadata
|
||||||
ld hl, sPartyMail
|
ld hl, sPartyMail
|
||||||
ld b, PARTY_LENGTH
|
ld b, PARTY_LENGTH
|
||||||
.loop3
|
.metadata_loop
|
||||||
push bc
|
push bc
|
||||||
ld bc, MAIL_MSG_LENGTH + 1
|
ld bc, MAIL_MSG_LENGTH + 1
|
||||||
add hl, bc
|
add hl, bc
|
||||||
@ -930,13 +930,13 @@ Link_PrepPartyData_Gen2:
|
|||||||
call CopyBytes
|
call CopyBytes
|
||||||
pop bc
|
pop bc
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop3
|
jr nz, .metadata_loop
|
||||||
|
|
||||||
; Translate the messages if necessary
|
; Translate the messages if necessary
|
||||||
ld b, PARTY_LENGTH
|
ld b, PARTY_LENGTH
|
||||||
ld de, sPartyMail
|
ld de, sPartyMail
|
||||||
ld hl, wLinkPlayerMailMessages
|
ld hl, wLinkPlayerMailMessages
|
||||||
.loop4
|
.translate_loop
|
||||||
push bc
|
push bc
|
||||||
push hl
|
push hl
|
||||||
push de
|
push de
|
||||||
@ -945,16 +945,16 @@ Link_PrepPartyData_Gen2:
|
|||||||
pop de
|
pop de
|
||||||
ld a, c
|
ld a, c
|
||||||
or a ; MAIL_LANG_ENGLISH
|
or a ; MAIL_LANG_ENGLISH
|
||||||
jr z, .next
|
jr z, .translate_next
|
||||||
sub MAIL_LANG_ITALIAN
|
sub MAIL_LANG_ITALIAN
|
||||||
jr nc, .italian_spanish
|
jr nc, .italian_spanish
|
||||||
farcall ConvertFrenchGermanMailToEnglish
|
farcall ConvertFrenchGermanMailToEnglish
|
||||||
jr .next
|
jr .translate_next
|
||||||
.italian_spanish
|
.italian_spanish
|
||||||
cp (MAIL_LANG_SPANISH + 1) - MAIL_LANG_ITALIAN
|
cp (MAIL_LANG_SPANISH + 1) - MAIL_LANG_ITALIAN
|
||||||
jr nc, .next
|
jr nc, .translate_next
|
||||||
farcall ConvertSpanishItalianMailToEnglish
|
farcall ConvertSpanishItalianMailToEnglish
|
||||||
.next
|
.translate_next
|
||||||
pop de
|
pop de
|
||||||
ld hl, MAIL_STRUCT_LENGTH
|
ld hl, MAIL_STRUCT_LENGTH
|
||||||
add hl, de
|
add hl, de
|
||||||
@ -965,42 +965,42 @@ Link_PrepPartyData_Gen2:
|
|||||||
add hl, bc
|
add hl, bc
|
||||||
pop bc
|
pop bc
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop4
|
jr nz, .translate_loop
|
||||||
call CloseSRAM
|
call CloseSRAM
|
||||||
|
|
||||||
; The SERIAL_NO_DATA_BYTE value isn't allowed anywhere in message text
|
; The SERIAL_NO_DATA_BYTE value isn't allowed anywhere in message text
|
||||||
ld hl, wLinkPlayerMailMessages
|
ld hl, wLinkPlayerMailMessages
|
||||||
ld bc, (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
ld bc, (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
||||||
.loop5
|
.message_patch_loop
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
cp SERIAL_NO_DATA_BYTE
|
cp SERIAL_NO_DATA_BYTE
|
||||||
jr nz, .skip2
|
jr nz, .message_patch_skip
|
||||||
ld [hl], SERIAL_MAIL_REPLACEMENT_BYTE
|
ld [hl], SERIAL_MAIL_REPLACEMENT_BYTE
|
||||||
.skip2
|
.message_patch_skip
|
||||||
inc hl
|
inc hl
|
||||||
dec bc
|
dec bc
|
||||||
ld a, b
|
ld a, b
|
||||||
or c
|
or c
|
||||||
jr nz, .loop5
|
jr nz, .message_patch_loop
|
||||||
|
|
||||||
; Calculate the patch offsets for the mail metadata
|
; Calculate the patch offsets for the mail metadata
|
||||||
ld hl, wLinkPlayerMailMetadata
|
ld hl, wLinkPlayerMailMetadata
|
||||||
ld de, wLinkPlayerMailPatchSet
|
ld de, wLinkPlayerMailPatchSet
|
||||||
ld b, (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
ld b, (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
||||||
ld c, 0
|
ld c, 0
|
||||||
.loop6
|
.metadata_patch_loop
|
||||||
inc c
|
inc c
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
cp SERIAL_NO_DATA_BYTE
|
cp SERIAL_NO_DATA_BYTE
|
||||||
jr nz, .skip3
|
jr nz, .metadata_patch_skip
|
||||||
ld [hl], SERIAL_PATCH_REPLACEMENT_BYTE
|
ld [hl], SERIAL_PATCH_REPLACEMENT_BYTE
|
||||||
ld a, c
|
ld a, c
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
.skip3
|
.metadata_patch_skip
|
||||||
inc hl
|
inc hl
|
||||||
dec b
|
dec b
|
||||||
jr nz, .loop6
|
jr nz, .metadata_patch_loop
|
||||||
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
||||||
ld [de], a
|
ld [de], a
|
||||||
ret
|
ret
|
||||||
|
@ -114,7 +114,7 @@ Serial_ExchangeBytes::
|
|||||||
dec hl
|
dec hl
|
||||||
cp SERIAL_PREAMBLE_BYTE
|
cp SERIAL_PREAMBLE_BYTE
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
xor a
|
xor a ; FALSE
|
||||||
ldh [hSerialIgnoringInitialData], a
|
ldh [hSerialIgnoringInitialData], a
|
||||||
jr .loop
|
jr .loop
|
||||||
|
|
||||||
|
@ -1034,13 +1034,14 @@ wLinkPlayerMail::
|
|||||||
wLinkPlayerMailPreamble:: ds SERIAL_MAIL_PREAMBLE_LENGTH
|
wLinkPlayerMailPreamble:: ds SERIAL_MAIL_PREAMBLE_LENGTH
|
||||||
wLinkPlayerMailMessages:: ds (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
wLinkPlayerMailMessages:: ds (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
||||||
wLinkPlayerMailMetadata:: ds (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
wLinkPlayerMailMetadata:: ds (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
||||||
wLinkPlayerMailPatchSet:: ds 103
|
wLinkPlayerMailPatchSet:: ds 100 + SERIAL_PATCH_PREAMBLE_LENGTH
|
||||||
wLinkPlayerMailEnd::
|
wLinkPlayerMailEnd::
|
||||||
ds 10
|
ds 10
|
||||||
wLinkOTMail::
|
wLinkOTMail::
|
||||||
wLinkOTMailMessages:: ds (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
wLinkOTMailMessages:: ds (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
||||||
wLinkOTMailMetadata:: ds (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
wLinkOTMailMetadata:: ds (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
||||||
wOTPlayerMailPatchSet:: ds 103 + SERIAL_MAIL_PREAMBLE_LENGTH
|
wLinkOTMailPatchSet:: ds 100 + SERIAL_PATCH_PREAMBLE_LENGTH
|
||||||
|
wLinkOTMailPadding:: ds SERIAL_MAIL_PREAMBLE_LENGTH
|
||||||
wLinkOTMailEnd::
|
wLinkOTMailEnd::
|
||||||
ds 10
|
ds 10
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user