2018-06-24 07:09:41 -07:00
|
|
|
SendMailToPC:
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, MON_ITEM
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld d, [hl]
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ItemIsMail
|
2015-11-17 14:56:49 -08:00
|
|
|
jr nc, .full
|
|
|
|
call GetMailboxCount
|
|
|
|
cp MAILBOX_CAPACITY
|
|
|
|
jr nc, .full
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
2020-10-26 12:45:57 -07:00
|
|
|
ld hl, sMailboxes
|
2015-11-17 14:56:49 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
ld hl, sPartyMail
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
xor a
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call ByteFill
|
|
|
|
ld a, MON_ITEM
|
|
|
|
call GetPartyParamLocation
|
2015-12-28 14:09:53 -08:00
|
|
|
ld [hl], 0
|
2015-11-17 14:56:49 -08:00
|
|
|
ld hl, sMailboxCount
|
|
|
|
inc [hl]
|
|
|
|
call CloseSRAM
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.full
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DeleteMailFromPC:
|
2015-11-18 07:42:42 -08:00
|
|
|
; Shift all mail messages in the mailbox
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, b
|
|
|
|
push bc
|
2020-10-26 12:45:57 -07:00
|
|
|
ld hl, sMailboxes
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
|
|
|
add hl, bc
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
.loop
|
|
|
|
ld a, b
|
2015-11-18 07:42:42 -08:00
|
|
|
cp MAILBOX_CAPACITY - 1
|
2015-11-17 14:56:49 -08:00
|
|
|
jr z, .done
|
|
|
|
push bc
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
inc b
|
|
|
|
jr .loop
|
|
|
|
.done
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
xor a
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call ByteFill
|
|
|
|
ld hl, sMailboxCount
|
|
|
|
dec [hl]
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReadMailMessage:
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, b
|
2020-10-26 12:45:57 -07:00
|
|
|
ld hl, sMailboxes
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ReadAnyMail
|
2015-11-17 14:56:49 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MoveMailFromPCToParty:
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-17 14:56:49 -08:00
|
|
|
push bc
|
|
|
|
ld a, b
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
2020-10-26 12:45:57 -07:00
|
|
|
ld hl, sMailboxes
|
2015-11-17 14:56:49 -08:00
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
ld hl, sPartyMail
|
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
push hl
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
ld de, PARTYMON_STRUCT_LENGTH - MON_MOVES
|
|
|
|
add hl, de
|
|
|
|
ld d, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
ld hl, wPartyMon1Item
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld [hl], d
|
|
|
|
call CloseSRAM
|
|
|
|
pop bc
|
2015-11-18 07:42:42 -08:00
|
|
|
jp DeleteMailFromPC
|
2015-11-17 14:56:49 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMailboxCount:
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, [sMailboxCount]
|
|
|
|
ld c, a
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckPokeMail::
|
2015-11-17 14:56:49 -08:00
|
|
|
push bc
|
|
|
|
push de
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall SelectMonFromParty
|
2018-01-11 22:40:20 -08:00
|
|
|
ld a, POKEMAIL_REFUSED
|
2015-11-18 07:42:42 -08:00
|
|
|
jr c, .pop_return
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
ld hl, wPartyMon1Item
|
2015-11-17 14:56:49 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld d, [hl]
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ItemIsMail
|
2018-01-11 22:40:20 -08:00
|
|
|
ld a, POKEMAIL_NO_MAIL
|
2015-11-18 07:42:42 -08:00
|
|
|
jr nc, .pop_return
|
|
|
|
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartyMon]
|
2015-11-17 14:56:49 -08:00
|
|
|
ld hl, sPartyMail
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
|
2015-11-18 07:42:42 -08:00
|
|
|
; Compare the mail message, byte for byte, with the expected message.
|
|
|
|
ld a, MAIL_MSG_LENGTH
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wTempByteValue], a
|
2015-11-18 07:42:42 -08:00
|
|
|
.loop
|
2015-11-17 14:56:49 -08:00
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
ld a, b
|
|
|
|
call GetFarByte
|
|
|
|
cp "@"
|
2015-11-18 07:42:42 -08:00
|
|
|
jr z, .done
|
2015-11-17 14:56:49 -08:00
|
|
|
cp c
|
2018-01-11 22:40:20 -08:00
|
|
|
ld a, POKEMAIL_WRONG_MAIL
|
2015-11-18 07:42:42 -08:00
|
|
|
jr nz, .close_sram_return
|
2015-11-17 14:56:49 -08:00
|
|
|
inc hl
|
|
|
|
inc de
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wTempByteValue]
|
2015-11-17 14:56:49 -08:00
|
|
|
dec a
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wTempByteValue], a
|
2015-11-18 07:42:42 -08:00
|
|
|
jr nz, .loop
|
2015-11-17 14:56:49 -08:00
|
|
|
|
2015-11-18 07:42:42 -08:00
|
|
|
.done
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckCurPartyMonFainted
|
2018-01-11 22:40:20 -08:00
|
|
|
ld a, POKEMAIL_LAST_MON
|
2015-11-18 07:42:42 -08:00
|
|
|
jr c, .close_sram_return
|
2018-02-22 12:35:11 -08:00
|
|
|
xor a ; REMOVE_PARTY
|
2015-11-17 14:56:49 -08:00
|
|
|
ld [wPokemonWithdrawDepositParameter], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall RemoveMonFromPartyOrBox
|
2018-01-11 22:40:20 -08:00
|
|
|
ld a, POKEMAIL_CORRECT
|
2015-11-17 14:56:49 -08:00
|
|
|
|
2015-11-18 07:42:42 -08:00
|
|
|
.close_sram_return
|
2015-11-17 14:56:49 -08:00
|
|
|
call CloseSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
jr .return
|
2015-11-17 14:56:49 -08:00
|
|
|
|
2015-11-18 07:42:42 -08:00
|
|
|
.pop_return
|
2015-11-17 14:56:49 -08:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
|
2015-11-18 07:42:42 -08:00
|
|
|
.return
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptVar], a
|
2015-11-17 14:56:49 -08:00
|
|
|
ret
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GivePokeMail::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
|
|
|
push af
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Item
|
2015-11-18 07:42:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
pop bc
|
|
|
|
ld [hl], b
|
|
|
|
pop af
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
ld hl, sPartyMail
|
2015-12-29 10:15:58 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2020-10-29 11:45:40 -07:00
|
|
|
ld hl, wMonMailMessageBuffer
|
2015-12-29 10:15:58 -08:00
|
|
|
ld bc, MAIL_MSG_LENGTH + 1
|
2015-11-18 07:42:42 -08:00
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
|
|
|
push af
|
2021-03-17 13:16:02 -07:00
|
|
|
ld hl, wPartyMonOTs
|
2015-11-18 07:42:42 -08:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call AddNTimes
|
2015-12-29 10:15:58 -08:00
|
|
|
ld bc, NAME_LENGTH - 1
|
2015-11-18 07:42:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1ID
|
2015-11-18 07:42:42 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-11-18 07:42:42 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
ld [de], a
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BackupPartyMonMail:
|
2015-11-18 07:42:42 -08:00
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
ld hl, sPartyMail
|
|
|
|
ld de, sPartyMailBackup
|
2021-02-10 05:50:39 -08:00
|
|
|
ld bc, PARTY_LENGTH * MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
ld hl, sMailboxCount
|
|
|
|
ld de, sMailboxCountBackup
|
2021-02-10 05:50:39 -08:00
|
|
|
ld bc, 1 + MAILBOX_CAPACITY * MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RestorePartyMonMail:
|
2015-11-18 07:42:42 -08:00
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
ld hl, sPartyMailBackup
|
|
|
|
ld de, sPartyMail
|
2021-02-10 05:50:39 -08:00
|
|
|
ld bc, PARTY_LENGTH * MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
ld hl, sMailboxCountBackup
|
|
|
|
ld de, sMailboxCount
|
2021-02-10 05:50:39 -08:00
|
|
|
ld bc, 1 + MAILBOX_CAPACITY * MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call CopyBytes
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DeletePartyMonMail:
|
2015-11-18 07:42:42 -08:00
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
xor a
|
|
|
|
ld hl, sPartyMail
|
2021-02-10 05:50:39 -08:00
|
|
|
ld bc, PARTY_LENGTH * MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call ByteFill
|
|
|
|
xor a
|
|
|
|
ld hl, sMailboxCount
|
2021-02-10 05:50:39 -08:00
|
|
|
ld bc, 1 + MAILBOX_CAPACITY * MAIL_STRUCT_LENGTH
|
2015-11-18 07:42:42 -08:00
|
|
|
call ByteFill
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IsAnyMonHoldingMail:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPartyCount]
|
2015-11-18 07:42:42 -08:00
|
|
|
and a
|
2015-11-18 10:01:55 -08:00
|
|
|
jr z, .no_mons
|
2015-11-18 07:42:42 -08:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1Item
|
2015-11-18 10:01:55 -08:00
|
|
|
.loop
|
2015-11-18 07:42:42 -08:00
|
|
|
ld d, [hl]
|
|
|
|
push hl
|
|
|
|
push de
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ItemIsMail
|
2015-11-18 07:42:42 -08:00
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
dec e
|
2015-11-18 10:01:55 -08:00
|
|
|
jr nz, .loop
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2015-11-18 10:01:55 -08:00
|
|
|
.no_mons
|
2015-11-18 07:42:42 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
_PlayerMailBoxMenu:
|
2015-11-18 07:42:42 -08:00
|
|
|
call InitMail
|
|
|
|
jr z, .nomail
|
2018-01-23 13:08:43 -08:00
|
|
|
call LoadStandardMenuHeader
|
2015-11-18 07:42:42 -08:00
|
|
|
call MailboxPC
|
2015-12-24 19:58:42 -08:00
|
|
|
jp CloseWindow
|
2015-11-18 07:42:42 -08:00
|
|
|
|
|
|
|
.nomail
|
|
|
|
ld hl, .EmptyMailboxText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp MenuTextboxBackup
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.EmptyMailboxText:
|
2018-10-28 09:16:55 -07:00
|
|
|
text_far _EmptyMailboxText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
InitMail:
|
2020-10-26 12:45:57 -07:00
|
|
|
; return z if no mail
|
2015-11-18 07:42:42 -08:00
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
ld a, [sMailboxCount]
|
|
|
|
call CloseSRAM
|
2020-10-26 12:45:57 -07:00
|
|
|
|
|
|
|
; initialize wMailboxCount from sMailboxCount
|
2015-11-18 10:01:55 -08:00
|
|
|
ld hl, wMailboxCount
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [hli], a
|
|
|
|
assert wMailboxCount + 1 == wMailboxItems
|
2015-11-18 07:42:42 -08:00
|
|
|
and a
|
|
|
|
jr z, .done ; if no mail, we're done
|
|
|
|
|
2020-10-26 12:45:57 -07:00
|
|
|
; initialize wMailboxItems with incrementing values starting at 1
|
2015-11-18 07:42:42 -08:00
|
|
|
ld b, a
|
2015-11-18 10:01:55 -08:00
|
|
|
ld a, 1
|
2015-11-18 07:42:42 -08:00
|
|
|
.loop
|
|
|
|
ld [hli], a
|
|
|
|
inc a
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
2020-10-26 12:45:57 -07:00
|
|
|
|
2015-11-18 07:42:42 -08:00
|
|
|
.done
|
2015-11-18 10:01:55 -08:00
|
|
|
ld [hl], -1 ; terminate
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2015-11-18 10:01:55 -08:00
|
|
|
ld a, [wMailboxCount]
|
2015-11-18 07:42:42 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
MailboxPC_GetMailAuthor:
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
|
|
|
ld hl, sMailbox1Author
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer2
|
2015-11-18 07:42:42 -08:00
|
|
|
push de
|
|
|
|
ld bc, NAME_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
ld a, "@"
|
|
|
|
ld [de], a
|
|
|
|
call CloseSRAM
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
MailboxPC_PrintMailAuthor:
|
2015-11-18 07:42:42 -08:00
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMenuSelection]
|
2015-12-28 14:09:53 -08:00
|
|
|
call MailboxPC_GetMailAuthor
|
2015-11-18 07:42:42 -08:00
|
|
|
pop hl
|
|
|
|
jp PlaceString
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
MailboxPC:
|
2015-11-18 07:42:42 -08:00
|
|
|
xor a
|
2017-12-27 21:56:45 -08:00
|
|
|
ld [wCurMessageScrollPosition], a
|
2015-12-28 14:09:53 -08:00
|
|
|
ld a, 1
|
2015-11-18 10:01:55 -08:00
|
|
|
ld [wCurMessageIndex], a
|
2015-11-18 07:42:42 -08:00
|
|
|
.loop
|
|
|
|
call InitMail
|
2018-01-23 13:08:43 -08:00
|
|
|
ld hl, .TopMenuHeader
|
|
|
|
call CopyMenuHeader
|
2015-11-18 07:42:42 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2015-11-18 07:42:42 -08:00
|
|
|
call InitScrollingMenu
|
|
|
|
call UpdateSprites
|
2015-11-18 10:01:55 -08:00
|
|
|
|
|
|
|
ld a, [wCurMessageIndex]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wMenuCursorPosition], a
|
2017-12-27 21:56:45 -08:00
|
|
|
ld a, [wCurMessageScrollPosition]
|
2015-11-23 13:04:53 -08:00
|
|
|
ld [wMenuScrollPosition], a
|
2015-12-17 19:31:16 -08:00
|
|
|
call ScrollingMenu
|
2015-11-23 13:04:53 -08:00
|
|
|
ld a, [wMenuScrollPosition]
|
2017-12-27 21:56:45 -08:00
|
|
|
ld [wCurMessageScrollPosition], a
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2015-11-18 10:01:55 -08:00
|
|
|
ld [wCurMessageIndex], a
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuJoypad]
|
2015-12-28 14:09:53 -08:00
|
|
|
cp B_BUTTON
|
2015-11-18 07:42:42 -08:00
|
|
|
jr z, .exit
|
2015-12-28 14:09:53 -08:00
|
|
|
call .Submenu
|
2015-11-18 07:42:42 -08:00
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.exit
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.Submenu:
|
2018-01-23 13:08:43 -08:00
|
|
|
ld hl, .SubMenuHeader
|
|
|
|
call LoadMenuHeader
|
2015-12-15 15:59:49 -08:00
|
|
|
call VerticalMenu
|
2015-11-18 07:42:42 -08:00
|
|
|
call ExitMenu
|
2015-12-28 14:09:53 -08:00
|
|
|
jr c, .subexit
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
2021-06-19 16:52:05 -07:00
|
|
|
ld hl, .Jumptable
|
2015-11-18 07:42:42 -08:00
|
|
|
rst JumpTable
|
|
|
|
|
2015-12-28 14:09:53 -08:00
|
|
|
.subexit
|
2015-11-18 07:42:42 -08:00
|
|
|
ret
|
|
|
|
|
2021-06-19 16:52:05 -07:00
|
|
|
.Jumptable:
|
2015-11-18 07:42:42 -08:00
|
|
|
dw .ReadMail
|
|
|
|
dw .PutInPack
|
|
|
|
dw .AttachMail
|
|
|
|
dw .Cancel
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.ReadMail:
|
2015-11-18 07:42:42 -08:00
|
|
|
call FadeToMenu
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMenuSelection]
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
|
|
|
ld b, a
|
|
|
|
call ReadMailMessage
|
2015-12-01 18:54:11 -08:00
|
|
|
jp CloseSubmenu
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.PutInPack:
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .MailMessageLostText
|
2019-04-08 05:15:10 -07:00
|
|
|
call MenuTextbox
|
2015-11-18 07:42:42 -08:00
|
|
|
call YesNoBox
|
|
|
|
call ExitMenu
|
|
|
|
ret c
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMenuSelection]
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
|
|
|
call .GetMailType
|
2015-12-28 14:09:53 -08:00
|
|
|
ld a, 1
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wItemQuantityChange], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wNumItems
|
2015-11-18 07:42:42 -08:00
|
|
|
call ReceiveItem
|
|
|
|
jr c, .put_in_bag
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .MailPackFullText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp MenuTextboxBackup
|
2015-11-18 07:42:42 -08:00
|
|
|
|
|
|
|
.put_in_bag
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMenuSelection]
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
|
|
|
ld b, a
|
|
|
|
call DeleteMailFromPC
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .MailClearedPutAwayText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp MenuTextboxBackup
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.MailClearedPutAwayText:
|
|
|
|
text_far _MailClearedPutAwayText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.MailPackFullText:
|
|
|
|
text_far _MailPackFullText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.MailMessageLostText:
|
|
|
|
text_far _MailMessageLostText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.GetMailType:
|
2015-11-18 07:42:42 -08:00
|
|
|
push af
|
|
|
|
ld a, BANK(sMailboxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-18 07:42:42 -08:00
|
|
|
pop af
|
2015-11-22 21:21:21 -08:00
|
|
|
ld hl, sMailbox1Type
|
2015-11-18 07:42:42 -08:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurItem], a
|
2015-11-18 07:42:42 -08:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.AttachMail:
|
2015-11-18 07:42:42 -08:00
|
|
|
call FadeToMenu
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPartyMenuActionText], a
|
2015-11-18 07:42:42 -08:00
|
|
|
call ClearBGPalettes
|
|
|
|
.try_again
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall LoadPartyMenuGFX
|
|
|
|
farcall InitPartyMenuWithCancel
|
|
|
|
farcall InitPartyMenuGFX
|
|
|
|
farcall WritePartyMenuTilemap
|
2023-08-11 03:28:14 -07:00
|
|
|
farcall PlacePartyMenuText
|
2015-11-18 07:42:42 -08:00
|
|
|
call WaitBGMap
|
|
|
|
call SetPalettes
|
|
|
|
call DelayFrame
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall PartyMenuSelect
|
2015-11-18 07:42:42 -08:00
|
|
|
jr c, .exit2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPartySpecies]
|
2015-11-18 07:42:42 -08:00
|
|
|
cp EGG
|
|
|
|
jr z, .egg
|
|
|
|
ld a, MON_ITEM
|
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .attach_mail
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .MailAlreadyHoldingItemText
|
2023-08-11 03:28:14 -07:00
|
|
|
call PrintText1bpp
|
2015-11-18 07:42:42 -08:00
|
|
|
jr .try_again
|
|
|
|
|
|
|
|
.egg
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .MailEggText
|
2023-08-11 03:28:14 -07:00
|
|
|
call PrintText1bpp
|
2015-11-18 07:42:42 -08:00
|
|
|
jr .try_again
|
|
|
|
|
|
|
|
.attach_mail
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMenuSelection]
|
2015-11-18 07:42:42 -08:00
|
|
|
dec a
|
|
|
|
ld b, a
|
|
|
|
call MoveMailFromPCToParty
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .MailMovedFromBoxText
|
2023-08-11 03:28:14 -07:00
|
|
|
call PrintText1bpp
|
2015-11-18 07:42:42 -08:00
|
|
|
|
|
|
|
.exit2
|
2015-12-01 18:54:11 -08:00
|
|
|
jp CloseSubmenu
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.MailAlreadyHoldingItemText:
|
|
|
|
text_far _MailAlreadyHoldingItemText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.MailEggText:
|
|
|
|
text_far _MailEggText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.MailMovedFromBoxText:
|
|
|
|
text_far _MailMovedFromBoxText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Cancel:
|
2015-11-18 07:42:42 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.TopMenuHeader:
|
2018-01-14 02:59:56 -08:00
|
|
|
db MENU_BACKUP_TILES ; flags
|
2018-01-13 13:38:14 -08:00
|
|
|
menu_coords 8, 1, SCREEN_WIDTH - 2, 10
|
2018-01-23 13:08:43 -08:00
|
|
|
dw .TopMenuData
|
2015-11-18 07:42:42 -08:00
|
|
|
db 1 ; default option
|
|
|
|
|
2018-01-23 13:08:43 -08:00
|
|
|
.TopMenuData:
|
2018-01-14 02:59:56 -08:00
|
|
|
db SCROLLINGMENU_DISPLAY_ARROWS ; flags
|
2019-06-08 17:31:24 -07:00
|
|
|
db 4, 0 ; rows, columns
|
|
|
|
db SCROLLINGMENU_ITEMS_NORMAL ; item format
|
2021-03-08 06:41:55 -08:00
|
|
|
dbw 0, wMailboxCount
|
2015-12-28 14:09:53 -08:00
|
|
|
dba MailboxPC_PrintMailAuthor
|
|
|
|
dba NULL
|
|
|
|
dba NULL
|
2015-11-18 07:42:42 -08:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.SubMenuHeader:
|
2018-01-14 02:59:56 -08:00
|
|
|
db MENU_BACKUP_TILES ; flags
|
2018-01-13 13:38:14 -08:00
|
|
|
menu_coords 0, 0, 13, 9
|
2018-01-23 13:08:43 -08:00
|
|
|
dw .SubMenuData
|
2015-11-18 07:42:42 -08:00
|
|
|
db 1 ; default option
|
|
|
|
|
2018-01-23 13:08:43 -08:00
|
|
|
.SubMenuData:
|
2018-01-14 02:59:56 -08:00
|
|
|
db STATICMENU_CURSOR ; flags
|
2015-11-18 07:42:42 -08:00
|
|
|
db 4 ; items
|
|
|
|
db "READ MAIL@"
|
|
|
|
db "PUT IN PACK@"
|
|
|
|
db "ATTACH MAIL@"
|
|
|
|
db "CANCEL@"
|