mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
IsMailEuropean → ParseMailLanguage (and give it constants)
This commit is contained in:
parent
1674b6ca5a
commit
a6ac67dea2
@ -59,6 +59,14 @@ DEF MAILBOX_CAPACITY EQU 10
|
||||
DEF MAIL_STRUCT_LENGTH EQU $2f ; mailmsg struct
|
||||
DEF MAIL_STRUCT_LENGTH_JP EQU $2a ; mailmsg_jp struct
|
||||
|
||||
; mail languages
|
||||
const_def
|
||||
const MAIL_LANG_ENGLISH
|
||||
const MAIL_LANG_FRENCH
|
||||
const MAIL_LANG_GERMAN
|
||||
const MAIL_LANG_ITALIAN
|
||||
const MAIL_LANG_SPANISH
|
||||
|
||||
; held item effects
|
||||
const_def
|
||||
const HELD_NONE
|
||||
|
@ -30,15 +30,16 @@ DEF SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
|
||||
; used to replace SERIAL_NO_DATA_BYTE
|
||||
DEF SERIAL_PATCH_REPLACEMENT_BYTE EQU $ff
|
||||
|
||||
DEF SERIAL_PREAMBLE_LENGTH EQU 6
|
||||
DEF SERIAL_RN_PREAMBLE_LENGTH EQU 7
|
||||
DEF SERIAL_RNS_LENGTH EQU 10
|
||||
DEF SERIAL_PREAMBLE_LENGTH EQU 6
|
||||
DEF SERIAL_RN_PREAMBLE_LENGTH EQU 7
|
||||
DEF SERIAL_RNS_LENGTH EQU 10
|
||||
|
||||
DEF SERIAL_MAIL_PREAMBLE_BYTE EQU $20
|
||||
DEF SERIAL_MAIL_REPLACEMENT_BYTE EQU $21
|
||||
DEF SERIAL_MAIL_PREAMBLE_LENGTH EQU 5
|
||||
DEF SERIAL_MAIL_PREAMBLE_BYTE EQU $20
|
||||
DEF SERIAL_MAIL_PREAMBLE_LENGTH EQU 5
|
||||
; used to replace SERIAL_NO_DATA_BYTE
|
||||
DEF SERIAL_MAIL_REPLACEMENT_BYTE EQU $21
|
||||
|
||||
; timeout duration after exchanging a byte
|
||||
DEF SERIAL_LINK_BYTE_TIMEOUT EQU $5000
|
||||
DEF SERIAL_LINK_BYTE_TIMEOUT EQU $5000
|
||||
|
||||
DEF MAX_MYSTERY_GIFT_PARTNERS EQU 5
|
||||
DEF MAX_MYSTERY_GIFT_PARTNERS EQU 5
|
||||
|
@ -406,7 +406,7 @@ endc
|
||||
.fix_mail_loop
|
||||
push bc
|
||||
push de
|
||||
farcall IsMailEuropean
|
||||
farcall ParseMailLanguage
|
||||
ld a, c
|
||||
or a
|
||||
jr z, .next
|
||||
@ -893,7 +893,7 @@ Link_PrepPartyData_Gen2:
|
||||
ret nz
|
||||
|
||||
; Fill 5 bytes at wLinkPlayerMailPreamble with $20
|
||||
ld de, wLinkPlayerMailPreamble
|
||||
ld de, wLinkPlayerMail
|
||||
ld a, SERIAL_MAIL_PREAMBLE_BYTE
|
||||
call Link_CopyMailPreamble
|
||||
|
||||
@ -911,6 +911,7 @@ Link_PrepPartyData_Gen2:
|
||||
pop bc
|
||||
dec b
|
||||
jr nz, .loop2
|
||||
|
||||
; Copy the mail data to wLinkPlayerMailMetadata
|
||||
ld hl, sPartyMail
|
||||
ld b, PARTY_LENGTH
|
||||
@ -923,6 +924,8 @@ Link_PrepPartyData_Gen2:
|
||||
pop bc
|
||||
dec b
|
||||
jr nz, .loop3
|
||||
|
||||
; Translate the messages if necessary
|
||||
ld b, PARTY_LENGTH
|
||||
ld de, sPartyMail
|
||||
ld hl, wLinkPlayerMailMessages
|
||||
@ -931,17 +934,17 @@ Link_PrepPartyData_Gen2:
|
||||
push hl
|
||||
push de
|
||||
push hl
|
||||
farcall IsMailEuropean
|
||||
farcall ParseMailLanguage
|
||||
pop de
|
||||
ld a, c
|
||||
or a
|
||||
or a ; MAIL_LANG_ENGLISH
|
||||
jr z, .next
|
||||
sub $3
|
||||
sub MAIL_LANG_ITALIAN
|
||||
jr nc, .italian_spanish
|
||||
farcall ConvertFrenchGermanMailToEnglish
|
||||
jr .next
|
||||
.italian_spanish
|
||||
cp $2
|
||||
cp (MAIL_LANG_SPANISH + 1) - MAIL_LANG_ITALIAN
|
||||
jr nc, .next
|
||||
farcall ConvertSpanishItalianMailToEnglish
|
||||
.next
|
||||
@ -958,6 +961,7 @@ Link_PrepPartyData_Gen2:
|
||||
jr nz, .loop4
|
||||
call CloseSRAM
|
||||
|
||||
; The SERIAL_NO_DATA_BYTE value isn't allowed anywhere in message text
|
||||
ld hl, wLinkPlayerMailMessages
|
||||
ld bc, (MAIL_MSG_LENGTH + 1) * PARTY_LENGTH
|
||||
.loop5
|
||||
@ -972,6 +976,7 @@ Link_PrepPartyData_Gen2:
|
||||
or c
|
||||
jr nz, .loop5
|
||||
|
||||
; Calculate the patch offsets for the mail metadata
|
||||
ld hl, wLinkPlayerMailMetadata
|
||||
ld de, wLinkPlayerMailPatchSet
|
||||
ld b, (MAIL_STRUCT_LENGTH - (MAIL_MSG_LENGTH + 1)) * PARTY_LENGTH
|
||||
|
@ -1,29 +1,24 @@
|
||||
IsMailEuropean:
|
||||
; return 1 if French
|
||||
; return 2 if German
|
||||
; return 3 if Italian
|
||||
; return 4 if Spanish
|
||||
; return 0 if none of the above
|
||||
ld c, $0
|
||||
ParseMailLanguage:
|
||||
ld c, MAIL_LANG_ENGLISH
|
||||
ld hl, sPartyMon1MailNationality - sPartyMon1Mail
|
||||
add hl, de
|
||||
ld a, [hli]
|
||||
cp "E"
|
||||
ret nz
|
||||
ld a, [hli]
|
||||
inc c
|
||||
inc c ; MAIL_LANG_FRENCH
|
||||
cp "F"
|
||||
ret z
|
||||
inc c
|
||||
inc c ; MAIL_LANG_GERMAN
|
||||
cp "G"
|
||||
ret z
|
||||
inc c
|
||||
inc c ; MAIL_LANG_ITALIAN
|
||||
cp "I"
|
||||
ret z
|
||||
inc c
|
||||
inc c ; MAIL_LANG_SPANISH
|
||||
cp "S"
|
||||
ret z
|
||||
ld c, $0
|
||||
ld c, MAIL_LANG_ENGLISH
|
||||
ret
|
||||
|
||||
; The regular font.
|
||||
|
@ -31,14 +31,14 @@ ReadAnyMail:
|
||||
push de
|
||||
ld a, BANK(sPartyMail)
|
||||
call OpenSRAM
|
||||
farcall IsMailEuropean
|
||||
farcall ParseMailLanguage
|
||||
call CloseSRAM
|
||||
ld a, c
|
||||
ld de, StandardEnglishFont
|
||||
or a
|
||||
or a ; MAIL_LANG_ENGLISH
|
||||
jr z, .got_font
|
||||
ld de, FrenchGermanFont
|
||||
sub $3
|
||||
sub MAIL_LANG_ITALIAN
|
||||
jr c, .got_font
|
||||
ld de, SpanishItalianFont
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user