Here's the mail it never fails

This commit is contained in:
PikalaxALT 2015-11-17 17:56:49 -05:00
parent e88c88ff20
commit 27ef600ace
19 changed files with 444 additions and 389 deletions

View File

@ -32,6 +32,10 @@ HP_RED EQU 2
MONS_PER_BOX EQU 20 MONS_PER_BOX EQU 20
NUM_BOXES EQU 14 NUM_BOXES EQU 14
; mail
MAIL_STRUCT_LENGTH EQU $2f
MAILBOX_CAPACITY EQU 10
; hall of fame ; hall of fame
HOF_MON_LENGTH = 1 + 2 + 2 + 1 + (PKMN_NAME_LENGTH +- 1) ; species, id, dvs, level, nick HOF_MON_LENGTH = 1 + 2 + 2 + 1 + (PKMN_NAME_LENGTH +- 1) ; species, id, dvs, level, nick
HOF_LENGTH = 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator HOF_LENGTH = 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator

View File

@ -291,7 +291,6 @@ MON_SAT EQUS "(PartyMon1SpclAtk - PartyMon1)"
MON_SDF EQUS "(PartyMon1SpclDef - PartyMon1)" MON_SDF EQUS "(PartyMon1SpclDef - PartyMon1)"
BOXMON_STRUCT_LENGTH EQUS "(PartyMon1End - PartyMon1)" BOXMON_STRUCT_LENGTH EQUS "(PartyMon1End - PartyMon1)"
PARTYMON_STRUCT_LENGTH EQUS "(PartyMon1StatsEnd - PartyMon1)" PARTYMON_STRUCT_LENGTH EQUS "(PartyMon1StatsEnd - PartyMon1)"
SCRATCHMON_STRUCT_LENGTH EQUS "(PartyMon1StatsEnd - PartyMon1Item)"
const_value SET 1 const_value SET 1
const MONMENU_CUT ; 1 const MONMENU_CUT ; 1

View File

@ -192,7 +192,7 @@ OverworldHatchEgg:: ; 16f5e
call ResetWindow call ResetWindow
call LoadStandardMenuDataHeader call LoadStandardMenuDataHeader
call Function16f70 call Function16f70
call Function2b4d call ExitAllMenus
call RestartMapMusic call RestartMapMusic
jp LoadMoveSprites jp LoadMoveSprites
; 16f70 ; 16f70

View File

@ -834,9 +834,9 @@ Function28595: ; 28595
ld de, wc9f4 ld de, wc9f4
ld a, $20 ld a, $20
call Function28682 call Function28682
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
ld hl, sPartyScratch1 ld hl, sPartyMail
ld b, PARTY_LENGTH ld b, PARTY_LENGTH
.loop2 .loop2
push bc push bc
@ -847,7 +847,7 @@ Function28595: ; 28595
pop bc pop bc
dec b dec b
jr nz, .loop2 jr nz, .loop2
ld hl, sPartyScratch1 ld hl, sPartyMail
ld b, PARTY_LENGTH ld b, PARTY_LENGTH
.loop3 .loop3
push bc push bc
@ -859,7 +859,7 @@ Function28595: ; 28595
dec b dec b
jr nz, .loop3 jr nz, .loop3
ld b, PARTY_LENGTH ld b, PARTY_LENGTH
ld de, sPartyScratch1 ld de, sPartyMail
ld hl, wc9f9 ld hl, wc9f9
.loop4 .loop4
push bc push bc
@ -883,7 +883,7 @@ Function28595: ; 28595
.next .next
pop de pop de
ld hl, SCRATCHMON_STRUCT_LENGTH ld hl, MAIL_STRUCT_LENGTH
add hl, de add hl, de
ld d, h ld d, h
ld e, l ld e, l
@ -1744,15 +1744,15 @@ Function28b87: ; 28b87
jp Function28ea3 jp Function28ea3
.asm_28c7b .asm_28c7b
ld hl, sPartyScratch1 ld hl, sPartyMail
ld a, [wd002] ld a, [wd002]
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
ld d, h ld d, h
ld e, l ld e, l
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
add hl, bc add hl, bc
ld a, [wd002] ld a, [wd002]
ld c, a ld c, a
@ -1762,24 +1762,24 @@ Function28b87: ; 28b87
cp $6 cp $6
jr z, .asm_28ca6 jr z, .asm_28ca6
push bc push bc
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
pop bc pop bc
jr .asm_28c96 jr .asm_28c96
.asm_28ca6 .asm_28ca6
ld hl, sPartyScratch1 ld hl, sPartyMail
ld a, [PartyCount] ld a, [PartyCount]
dec a dec a
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
push hl push hl
ld hl, wc9f4 ld hl, wc9f4
ld a, [wd003] ld a, [wd003]
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
pop de pop de
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
call CloseSRAM call CloseSRAM
ld hl, PlayerName ld hl, PlayerName

190
engine/mail.asm Executable file
View File

@ -0,0 +1,190 @@
SendMailToPC: ; 4456e
ld a, MON_ITEM
call GetPartyParamLocation
ld d, [hl]
callba ItemIsMail
jr nc, .full
call GetMailboxCount
cp MAILBOX_CAPACITY
jr nc, .full
ld bc, MAIL_STRUCT_LENGTH
ld hl, sMailbox
call AddNTimes
ld d, h
ld e, l
ld a, [CurPartyMon]
ld bc, MAIL_STRUCT_LENGTH
ld hl, sPartyMail
call AddNTimes
push hl
ld a, BANK(sMailboxCount)
call GetSRAMBank
ld bc, MAIL_STRUCT_LENGTH
call CopyBytes
pop hl
xor a
ld bc, MAIL_STRUCT_LENGTH
call ByteFill
ld a, MON_ITEM
call GetPartyParamLocation
ld [hl], $0
ld hl, sMailboxCount
inc [hl]
call CloseSRAM
xor a
ret
.full
scf
ret
; 445c0
Function445c0: ; 445c0 (11:45c0)
ld a, BANK(sMailboxCount)
call GetSRAMBank
ld a, b
push bc
ld hl, sMailbox
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
push hl
add hl, bc
pop de
pop bc
.loop
ld a, b
cp $9
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
; 445f4 (11:45f4)
ReadMailMessage: ; 445f4
ld a, b
ld hl, sMailbox
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
callba ReadAnyMail
ret
Function44607: ; 44607
ld a, BANK(sMailboxCount)
call GetSRAMBank
push bc
ld a, b
ld bc, MAIL_STRUCT_LENGTH
ld hl, sMailbox
call AddNTimes
push hl
ld a, [CurPartyMon]
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]
ld a, [CurPartyMon]
ld hl, PartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld [hl], d
call CloseSRAM
pop bc
jp Function445c0
; 44648 (11:4648)
GetMailboxCount: ; 44648
ld a, BANK(sMailboxCount)
call GetSRAMBank
ld a, [sMailboxCount]
ld c, a
jp CloseSRAM
; 44654
Function44654:: ; 44654
push bc
push de
callba SelectMonFromParty
ld a, $2
jr c, .asm_446c6
ld a, [CurPartyMon]
ld hl, PartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, [hl]
callba ItemIsMail
ld a, $3
jr nc, .asm_446c6
ld a, BANK(sPartyMail)
call GetSRAMBank
ld a, [CurPartyMon]
ld hl, sPartyMail
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
pop hl
pop bc
ld a, $20
ld [wd265], a
.asm_44691
ld a, [de]
ld c, a
ld a, b
call GetFarByte
cp "@"
jr z, .asm_446ab
cp c
ld a, $0
jr nz, .asm_446c1
inc hl
inc de
ld a, [wd265]
dec a
ld [wd265], a
jr nz, .asm_44691
.asm_446ab
callba CheckCurPartyMonFainted
ld a, $4
jr c, .asm_446c1
xor a
ld [wPokemonWithdrawDepositParameter], a
callba Functione039
ld a, $1
.asm_446c1
call CloseSRAM
jr .asm_446c8
.asm_446c6
pop de
pop bc
.asm_446c8
ld [ScriptVar], a
ret
; 446cc

View File

@ -377,7 +377,7 @@ BuyMenu: ; 15c62
.loop .loop
call BuyMenuLoop ; menu loop call BuyMenuLoop ; menu loop
jr nc, .loop jr nc, .loop
call Function2b3c call ReturnToCallingMenu
ret ret
; 15c7d ; 15c7d

View File

@ -140,7 +140,7 @@ HallOfFamePC: ; 1569a
call PC_PlayChoosePCSound call PC_PlayChoosePCSound
call FadeToMenu call FadeToMenu
callba _HallOfFamePC callba _HallOfFamePC
call Function2b3c call ReturnToCallingMenu
and a and a
ret ret
; 156ab ; 156ab
@ -323,7 +323,7 @@ KrisWithdrawItemMenu: ; 0x157d1
jr .asm_157da jr .asm_157da
.asm_157e4 .asm_157e4
call Function2b3c call ReturnToCallingMenu
xor a xor a
ret ret
; 0x157e9 ; 0x157e9
@ -403,7 +403,7 @@ KrisTossItemMenu: ; 0x1585f
jr .asm_15868 jr .asm_15868
.asm_15878 .asm_15878
call Function2b3c call ReturnToCallingMenu
xor a xor a
ret ret
; 0x1587d ; 0x1587d
@ -442,7 +442,7 @@ KrisDepositItemMenu: ; 0x1588b
jr .asm_1589c jr .asm_1589c
.asm_158b3 .asm_158b3
call Function2b3c call ReturnToCallingMenu
.asm_158b6 .asm_158b6
xor a xor a
@ -450,7 +450,7 @@ KrisDepositItemMenu: ; 0x1588b
; 0x158b8 ; 0x158b8
Function158b8: ; 0x158b8 Function158b8: ; 0x158b8
callba Function129d5 callba HasNoItems
ret nc ret nc
ld hl, UnknownText_0x158c7 ld hl, UnknownText_0x158c7
call MenuTextBoxBackup call MenuTextBoxBackup

View File

@ -1,4 +1,4 @@
Function14a1a: ; 14a1a SaveMenu: ; 14a1a
call LoadStandardMenuDataHeader call LoadStandardMenuDataHeader
callba Function5e9a callba Function5e9a
call SpeechTextBox call SpeechTextBox
@ -30,7 +30,7 @@ Function14a58: ; 14a58
call Function14e13 call Function14e13
call SaveBackupPokemonData call SaveBackupPokemonData
call SaveBackupChecksum call SaveBackupChecksum
callba BackupScratchmons callba BackupPartyMonMail
callba Function1406a callba Function1406a
call ClearWRAMStateAfterSave call ClearWRAMStateAfterSave
ret ret
@ -106,7 +106,7 @@ Function14ad5: ; 14ad5
call SaveBackupPlayerData call SaveBackupPlayerData
call SaveBackupPokemonData call SaveBackupPokemonData
call SaveBackupChecksum call SaveBackupChecksum
callba BackupScratchmons callba BackupPartyMonMail
callba BackupMobileEventIndex callba BackupMobileEventIndex
callba Function1406a callba Function1406a
call LoadBox call LoadBox
@ -284,7 +284,7 @@ SaveGameData_: ; 14c10
call SaveBackupPokemonData call SaveBackupPokemonData
call SaveBackupChecksum call SaveBackupChecksum
call UpdateStackTop call UpdateStackTop
callba BackupScratchmons callba BackupPartyMonMail
callba BackupMobileEventIndex callba BackupMobileEventIndex
callba Function1406a callba Function1406a
ld a, BANK(s1_be45) ld a, BANK(s1_be45)
@ -630,7 +630,7 @@ TryLoadSaveFile: ; 14ea5 (5:4ea5)
call LoadPlayerData call LoadPlayerData
call LoadPokemonData call LoadPokemonData
call LoadBox call LoadBox
callba RestoreScratchmons callba RestorePartyMonMail
callba RestoreMobileEventIndex callba RestoreMobileEventIndex
callba Function1050ea callba Function1050ea
call ValidateBackupSave call ValidateBackupSave
@ -647,7 +647,7 @@ TryLoadSaveFile: ; 14ea5 (5:4ea5)
call LoadBackupPlayerData call LoadBackupPlayerData
call LoadBackupPokemonData call LoadBackupPokemonData
call LoadBox call LoadBox
callba RestoreScratchmons callba RestorePartyMonMail
callba RestoreMobileEventIndex callba RestoreMobileEventIndex
callba Function1050ea callba Function1050ea
call ValidateSave call ValidateSave

View File

@ -158,7 +158,7 @@ UseRegisteredItem: ; 133c3
call ResetWindow call ResetWindow
call FadeToMenu call FadeToMenu
call DoItemEffect call DoItemEffect
call Function2b3c call ReturnToCallingMenu
call LoadMoveSprites call LoadMoveSprites
and a and a
ret ret

View File

@ -216,7 +216,7 @@ Special_GameCornerPrizeMonCheckDex: ; c230
ld a, [ScriptVar] ld a, [ScriptVar]
ld [wd265], a ld [wd265], a
callba Functionfb877 callba Functionfb877
call Function2b4d call ExitAllMenus
ret ret
; c252 ; c252
@ -288,21 +288,21 @@ SpecialNameRater: ; c2b9
Special_TownMap: ; c2c0 Special_TownMap: ; c2c0
call FadeToMenu call FadeToMenu
callba _TownMap callba _TownMap
call Function2b4d call ExitAllMenus
ret ret
; c2cd ; c2cd
Special_UnownPrinter: ; c2cd Special_UnownPrinter: ; c2cd
call FadeToMenu call FadeToMenu
callba UnownPrinter callba UnownPrinter
call Function2b4d call ExitAllMenus
ret ret
; c2da ; c2da
Special_DisplayLinkRecord: ; c2da Special_DisplayLinkRecord: ; c2da
call FadeToMenu call FadeToMenu
callba DisplayLinkRecord callba DisplayLinkRecord
call Function2b4d call ExitAllMenus
ret ret
; c2e7 ; c2e7
@ -383,7 +383,7 @@ Special_UnownPuzzle: ; c360
callba Functione1190 callba Functione1190
ld a, [wd0ec] ld a, [wd0ec]
ld [ScriptVar], a ld [ScriptVar], a
call Function2b4d call ExitAllMenus
ret ret
; c373 ; c373
@ -425,7 +425,7 @@ Special_StartGameCornerGame: ; c39a
ld l, a ld l, a
pop af pop af
rst FarCall rst FarCall
call Function2b4d call ExitAllMenus
ret ret
; c3ae ; c3ae
@ -629,14 +629,14 @@ Special_FadeOutMusic: ; c48f
Diploma: ; c49f Diploma: ; c49f
call FadeToMenu call FadeToMenu
callba _Diploma callba _Diploma
call Function2b4d call ExitAllMenus
ret ret
; c4ac ; c4ac
PrintDiploma: ; c4ac PrintDiploma: ; c4ac
call FadeToMenu call FadeToMenu
callba _PrintDiploma callba _PrintDiploma
call Function2b4d call ExitAllMenus
ret ret
; c4b9 ; c4b9

View File

@ -422,7 +422,7 @@ StartMenu_Quit: ; 128f0
; Retire from the bug catching contest. ; Retire from the bug catching contest.
ld hl, .EndTheContestText ld hl, .EndTheContestText
call Function12cf5 call StartMenuYesNo
jr c, .DontEndContest jr c, .DontEndContest
ld a, BANK(BugCatchingContestReturnToGateScript) ld a, BANK(BugCatchingContestReturnToGateScript)
ld hl, BugCatchingContestReturnToGateScript ld hl, BugCatchingContestReturnToGateScript
@ -444,7 +444,7 @@ StartMenu_Save: ; 1290b
; Save the game. ; Save the game.
call BufferScreen call BufferScreen
callba Function14a1a callba SaveMenu
jr nc, .asm_12919 jr nc, .asm_12919
ld a, 0 ld a, 0
ret ret
@ -468,8 +468,8 @@ StartMenu_Status: ; 12928
; Player status. ; Player status.
call FadeToMenu call FadeToMenu
callba Function25105 callba TrainerCard
call Function2b3c call ReturnToCallingMenu
ld a, 0 ld a, 0
ret ret
; 12937 ; 12937
@ -483,7 +483,7 @@ StartMenu_Pokedex: ; 12937
call FadeToMenu call FadeToMenu
callba Pokedex callba Pokedex
call Function2b3c call ReturnToCallingMenu
.asm_12949 .asm_12949
ld a, 0 ld a, 0
@ -495,7 +495,7 @@ StartMenu_Pokegear: ; 1294c
call FadeToMenu call FadeToMenu
callba PokeGear callba PokeGear
call Function2b3c call ReturnToCallingMenu
ld a, 0 ld a, 0
ret ret
; 1295b ; 1295b
@ -507,12 +507,13 @@ StartMenu_Pack: ; 1295b
callba Pack callba Pack
ld a, [wcf66] ld a, [wcf66]
and a and a
jr nz, .asm_12970 jr nz, .used_item
call Function2b3c call ReturnToCallingMenu
ld a, 0 ld a, 0
ret ret
.asm_12970
call Function2b4d .used_item
call ExitAllMenus
ld a, 4 ld a, 4
ret ret
; 12976 ; 12976
@ -556,19 +557,19 @@ StartMenu_Pokemon: ; 12976
jr z, .quit jr z, .quit
.return .return
call Function2b3c call ReturnToCallingMenu
ld a, 0 ld a, 0
ret ret
.quit .quit
ld a, b ld a, b
push af push af
call Function2b4d call ExitAllMenus
pop af pop af
ret ret
; 129d5 ; 129d5
Function129d5: ; 129d5 HasNoItems: ; 129d5
ld a, [NumItems] ld a, [NumItems]
and a and a
ret nz ret nz
@ -580,15 +581,15 @@ Function129d5: ; 129d5
ret nz ret nz
ld hl, TMsHMs ld hl, TMsHMs
ld b, NUM_TMS + NUM_HMS ld b, NUM_TMS + NUM_HMS
.asm_129e9 .loop
ld a, [hli] ld a, [hli]
and a and a
jr nz, .asm_129f2 jr nz, .done
dec b dec b
jr nz, .asm_129e9 jr nz, .loop
scf scf
ret ret
.asm_129f2 .done
and a and a
ret ret
@ -882,7 +883,7 @@ Function12bd9: ; 12bd9
jr .asm_12c08 jr .asm_12c08
.asm_12bf4 .asm_12bf4
call Function12cea call GiveItemToPokemon
ld hl, MadeHoldText ld hl, MadeHoldText
call MenuTextBoxBackup call MenuTextBoxBackup
call GivePartyItem call GivePartyItem
@ -897,17 +898,17 @@ Function12bd9: ; 12bd9
ld [wd265], a ld [wd265], a
call GetItemName call GetItemName
ld hl, SwitchAlreadyHoldingText ld hl, SwitchAlreadyHoldingText
call Function12cf5 call StartMenuYesNo
jr c, .asm_12c4b jr c, .asm_12c4b
call Function12cea call GiveItemToPokemon
ld a, [wd265] ld a, [wd265]
push af push af
ld a, [CurItem] ld a, [CurItem]
ld [wd265], a ld [wd265], a
pop af pop af
ld [CurItem], a ld [CurItem], a
call Function12cdf call ReceiveItemFromPokemon
jr nc, .asm_12c3c jr nc, .asm_12c3c
ld hl, TookAndMadeHoldText ld hl, TookAndMadeHoldText
@ -920,7 +921,7 @@ Function12bd9: ; 12bd9
.asm_12c3c .asm_12c3c
ld a, [wd265] ld a, [wd265]
ld [CurItem], a ld [CurItem], a
call Function12cdf call ReceiveItemFromPokemon
ld hl, ItemStorageIsFullText ld hl, ItemStorageIsFullText
call MenuTextBoxBackup call MenuTextBoxBackup
@ -953,7 +954,7 @@ TakePartyItem: ; 12c60
jr z, .asm_12c8c jr z, .asm_12c8c
ld [CurItem], a ld [CurItem], a
call Function12cdf call ReceiveItemFromPokemon
jr nc, .asm_12c94 jr nc, .asm_12c94
callba ItemIsMail callba ItemIsMail
@ -1045,7 +1046,7 @@ GetPartyItemLocation: ; 12cd7
; 12cdf ; 12cdf
Function12cdf: ; 12cdf ReceiveItemFromPokemon: ; 12cdf
ld a, $1 ld a, $1
ld [wItemQuantityChangeBuffer], a ld [wItemQuantityChangeBuffer], a
ld hl, NumItems ld hl, NumItems
@ -1053,13 +1054,13 @@ Function12cdf: ; 12cdf
; 12cea ; 12cea
Function12cea: ; 12cea (4:6cea) GiveItemToPokemon: ; 12cea (4:6cea)
ld a, $1 ld a, $1
ld [wItemQuantityChangeBuffer], a ld [wItemQuantityChangeBuffer], a
ld hl, NumItems ld hl, NumItems
jp TossItem jp TossItem
Function12cf5: ; 12cf5 StartMenuYesNo: ; 12cf5
call MenuTextBox call MenuTextBox
call YesNoBox call YesNoBox
jp ExitMenu jp ExitMenu
@ -1071,7 +1072,7 @@ Function12cfe: ; 12cfe (4:6cfe)
callba Function11e75 callba Function11e75
ld hl, PlayerName ld hl, PlayerName
ld de, wd023 ld de, wd023
ld bc, $a ld bc, NAME_LENGTH - 1
call CopyBytes call CopyBytes
ld hl, PlayerID ld hl, PlayerID
ld bc, $2 ld bc, $2
@ -1082,14 +1083,14 @@ Function12cfe: ; 12cfe (4:6cfe)
ld a, [CurItem] ld a, [CurItem]
ld [de], a ld [de], a
ld a, [CurPartyMon] ld a, [CurPartyMon]
ld hl, sPartyScratch1 ld hl, sPartyMail
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
ld d, h ld d, h
ld e, l ld e, l
ld hl, wd002 ld hl, wd002
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
call CopyBytes call CopyBytes
call CloseSRAM call CloseSRAM
@ -1127,11 +1128,11 @@ MonMailAction: ; 12d45
.take .take
ld hl, .sendmailtopctext ld hl, .sendmailtopctext
call Function12cf5 call StartMenuYesNo
jr c, .RemoveMailToBag jr c, .RemoveMailToBag
ld a, [CurPartyMon] ld a, [CurPartyMon]
ld b, a ld b, a
callba Function4456e callba SendMailToPC
jr c, .MailboxFull jr c, .MailboxFull
ld hl, .sentmailtopctext ld hl, .sentmailtopctext
call MenuTextBoxBackup call MenuTextBoxBackup
@ -1144,12 +1145,12 @@ MonMailAction: ; 12d45
.RemoveMailToBag .RemoveMailToBag
ld hl, .mailwilllosemessagetext ld hl, .mailwilllosemessagetext
call Function12cf5 call StartMenuYesNo
jr c, .done jr c, .done
call GetPartyItemLocation call GetPartyItemLocation
ld a, [hl] ld a, [hl]
ld [CurItem], a ld [CurItem], a
call Function12cdf call ReceiveItemFromPokemon
jr nc, .BagIsFull jr nc, .BagIsFull
call GetPartyItemLocation call GetPartyItemLocation
ld [hl], $0 ld [hl], $0

View File

@ -1,4 +1,4 @@
Function25105: ; 25105 TrainerCard: ; 25105
ld a, [VramState] ld a, [VramState]
push af push af
xor a xor a
@ -211,16 +211,18 @@ Function25279: ; 25279 (9:5279)
ld hl, hJoyLast ld hl, hJoyLast
ld a, [hl] ld a, [hl]
and D_LEFT and D_LEFT
jr nz, .asm_2528d jr nz, .left
ld a, [hl] ld a, [hl]
and D_RIGHT and D_RIGHT
jr nz, .asm_25293 jr nz, .right
ret ret
.asm_2528d
.left
ld a, $2 ld a, $2
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
.asm_25293
.right
ld a, $0 ld a, $0
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
@ -466,24 +468,26 @@ Function25438: ; 25438 (9:5438)
jr Function25448 jr Function25448
Function25448: ; 25448 (9:5448) Function25448: ; 25448 (9:5448)
; copy flag array pointer
ld a, [hli] ld a, [hli]
ld e, a ld e, a
ld a, [hli] ld a, [hli]
; get flag array
ld d, a ld d, a
ld a, [de] ld a, [de]
ld c, a ld c, a
ld de, Sprites ld de, Sprites
ld b, 8 ld b, 8
.asm_25453 .loop
srl c srl c
push bc push bc
jr nc, .asm_25472 jr nc, .skip_badge
push hl push hl
ld a, [hli] ld a, [hli] ; y
ld b, a ld b, a
ld a, [hli] ld a, [hli] ; x
ld c, a ld c, a
ld a, [hli] ld a, [hli] ; pal
ld [wcf66], a ld [wcf66], a
ld a, [wcf64] ld a, [wcf64]
add l add l
@ -495,60 +499,64 @@ Function25448: ; 25448 (9:5448)
ld [wcf65], a ld [wcf65], a
call Function2547b call Function2547b
pop hl pop hl
.asm_25472 .skip_badge
ld bc, $b ld bc, $b ; 3 + 2 * 4
add hl, bc add hl, bc
pop bc pop bc
dec b dec b
jr nz, .asm_25453 jr nz, .loop
ret ret
Function2547b: ; 2547b (9:547b) Function2547b: ; 2547b (9:547b)
ld a, [wcf65] ld a, [wcf65]
and $80 and $80
jr nz, .asm_25487 jr nz, .xflip
ld hl, Unknown_254a7 ld hl, .facing1
jr .asm_2548a jr .loop
.asm_25487 .xflip
ld hl, Unknown_254b8 ld hl, .facing2
.asm_2548a .loop
ld a, [hli] ld a, [hli]
cp $ff cp $ff
ret z ret z
add b add b
ld [de], a ld [de], a
inc de inc de
ld a, [hli] ld a, [hli]
add c add c
ld [de], a ld [de], a
inc de inc de
ld a, [wcf65] ld a, [wcf65]
and $7f and $7f
add [hl] add [hl]
ld [de], a ld [de], a
inc hl inc hl
inc de inc de
ld a, [wcf66] ld a, [wcf66]
add [hl] add [hl]
ld [de], a ld [de], a
inc hl inc hl
inc de inc de
jr .asm_2548a jr .loop
; 254a7 (9:54a7) ; 254a7 (9:54a7)
Unknown_254a7: ; 254a7 .facing1: ; 254a7
db $00, $00, $00, $00 ; y, x, tile, OAM attributes
db $00, $08, $01, $00 db 0, 0, 0, 0
db $08, $00, $02, $00 db 0, 8, 1, 0
db $08, $08, $03, $00 db 8, 0, 2, 0
db $ff db 8, 8, 3, 0
db -1
Unknown_254b8: ; 254b8 .facing2: ; 254b8
db $00, $00, $01, $20 db 0, 0, 1, X_FLIP
db $00, $08, $00, $20 db 0, 8, 0, X_FLIP
db $08, $00, $03, $20 db 8, 0, 3, X_FLIP
db $08, $08, $02, $20 db 8, 8, 2, X_FLIP
db $ff db -1
Unknown_254c9: ; 254c9 Unknown_254c9: ; 254c9
; Template OAM data for each badge on the trainer card. ; Template OAM data for each badge on the trainer card.
@ -560,43 +568,43 @@ Unknown_254c9: ; 254c9
dw JohtoBadges dw JohtoBadges
; Zephyrbadge ; Zephyrbadge
db $68, $18, $00 db $68, $18, 0
db $00, $20, $24, $20 | $80 db $00, $20, $24, $20 | $80
db $00, $20, $24, $20 | $80 db $00, $20, $24, $20 | $80
; Hivebadge ; Hivebadge
db $68, $38, $00 db $68, $38, 0
db $04, $20, $24, $20 | $80 db $04, $20, $24, $20 | $80
db $04, $20, $24, $20 | $80 db $04, $20, $24, $20 | $80
; Plainbadge ; Plainbadge
db $68, $58, $00 db $68, $58, 0
db $08, $20, $24, $20 | $80 db $08, $20, $24, $20 | $80
db $08, $20, $24, $20 | $80 db $08, $20, $24, $20 | $80
; Fogbadge ; Fogbadge
db $68, $78, $00 db $68, $78, 0
db $0c, $20, $24, $20 | $80 db $0c, $20, $24, $20 | $80
db $0c, $20, $24, $20 | $80 db $0c, $20, $24, $20 | $80
; Mineralbadge ; Mineralbadge
db $80, $38, $00 db $80, $38, 0
db $10, $20, $24, $20 | $80 db $10, $20, $24, $20 | $80
db $10, $20, $24, $20 | $80 db $10, $20, $24, $20 | $80
; Stormbadge ; Stormbadge
db $80, $18, $00 db $80, $18, 0
db $14, $20, $24, $20 | $80 db $14, $20, $24, $20 | $80
db $14, $20, $24, $20 | $80 db $14, $20, $24, $20 | $80
; Glacierbadge ; Glacierbadge
db $80, $58, $00 db $80, $58, 0
db $18, $20, $24, $20 | $80 db $18, $20, $24, $20 | $80
db $18, $20, $24, $20 | $80 db $18, $20, $24, $20 | $80
; Risingbadge ; Risingbadge
; X-flips on alternate cycles. ; X-flips on alternate cycles.
db $80, $78, $00 db $80, $78, 0
db $1c, $20, $24, $20 | $80 db $1c, $20, $24, $20 | $80
db $1c | $80, $20, $24, $20 | $80 db $1c | $80, $20, $24, $20 | $80
; 25523 ; 25523

View File

@ -2014,7 +2014,7 @@ FadeToMenu:: ; 2b29
; 2b3c ; 2b3c
Function2b3c:: ; 2b3c ReturnToCallingMenu:: ; 2b3c
call ClearBGPalettes call ClearBGPalettes
call Function2bae call Function2bae
call UpdateSprites call UpdateSprites
@ -2023,7 +2023,7 @@ Function2b3c:: ; 2b3c
jr Function2b5c jr Function2b5c
; 2b4d ; 2b4d
Function2b4d:: ; 2b4d ExitAllMenus:: ; 2b4d
call ClearBGPalettes call ClearBGPalettes
call Call_ExitMenu call Call_ExitMenu
call Function2bae call Function2bae

333
main.asm
View File

@ -285,7 +285,7 @@ ENDC
callba InitDecorations callba InitDecorations
callba DeleteScratchmons callba DeletePartyMonMail
callba DeleteMobileEventIndex callba DeleteMobileEventIndex
@ -9297,14 +9297,14 @@ Functione039: ; e039
ld a, [wLinkMode] ld a, [wLinkMode]
and a and a
ret nz ret nz
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
ld hl, PartyCount ld hl, PartyCount
ld a, [CurPartyMon] ld a, [CurPartyMon]
cp [hl] cp [hl]
jr z, .asm_e131 jr z, .asm_e131
ld hl, sPartyScratch1 ld hl, sPartyMail
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
push hl push hl
add hl, bc add hl, bc
@ -9314,11 +9314,11 @@ Functione039: ; e039
.asm_e11a .asm_e11a
push bc push bc
push hl push hl
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
pop hl pop hl
push hl push hl
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
add hl, bc add hl, bc
pop de pop de
pop bc pop bc
@ -9789,7 +9789,7 @@ InitNickname: ; e3de
ld de, StringBuffer1 ld de, StringBuffer1
call InitName call InitName
ld a, $4 ; XXX could this be in bank 4 in pokered? ld a, $4 ; XXX could this be in bank 4 in pokered?
ld hl, Function2b4d ld hl, ExitAllMenus
rst FarCall rst FarCall
ret ret
; e3fd ; e3fd
@ -9841,7 +9841,7 @@ UnknownText_0xe43a: ; 0xe43a
; 0xe43f ; 0xe43f
Functione43f: ; e43f (3:643f) Functione43f: ; e43f (3:643f)
call Function2b3c call ReturnToCallingMenu
ret ret
Functione443: ; e443 (3:6443) Functione443: ; e443 (3:6443)
@ -10414,7 +10414,7 @@ INCLUDE "engine/tmhm.asm"
INCLUDE "engine/namingscreen.asm" INCLUDE "engine/namingscreen.asm"
Function11e75: ; 11e75 (4:5e75) Function11e75: ; 11e75 (mail?)
ld hl, wc6d0 ld hl, wc6d0
ld [hl], e ld [hl], e
inc hl inc hl
@ -17957,197 +17957,7 @@ endr
PokedexDataPointerTable: ; 0x44378 PokedexDataPointerTable: ; 0x44378
INCLUDE "data/pokedex/entry_pointers.asm" INCLUDE "data/pokedex/entry_pointers.asm"
INCLUDE "engine/mail.asm"
Function4456e: ; 4456e
ld a, MON_ITEM
call GetPartyParamLocation
ld d, [hl]
callba ItemIsMail
jr nc, .asm_445be
call Function44648
cp $a
jr nc, .asm_445be
ld bc, SCRATCHMON_STRUCT_LENGTH
ld hl, s0_a835
call AddNTimes
ld d, h
ld e, l
ld a, [CurPartyMon]
ld bc, SCRATCHMON_STRUCT_LENGTH
ld hl, sPartyScratch1
call AddNTimes
push hl
ld a, BANK(s0_a834)
call GetSRAMBank
ld bc, SCRATCHMON_STRUCT_LENGTH
call CopyBytes
pop hl
xor a
ld bc, SCRATCHMON_STRUCT_LENGTH
call ByteFill
ld a, MON_ITEM
call GetPartyParamLocation
ld [hl], $0
ld hl, s0_a834
inc [hl]
call CloseSRAM
xor a
ret
.asm_445be
scf
ret
; 445c0
Function445c0: ; 445c0 (11:45c0)
ld a, BANK(s0_a834)
call GetSRAMBank
ld a, b
push bc
ld hl, s0_a835
ld bc, SCRATCHMON_STRUCT_LENGTH
call AddNTimes
push hl
add hl, bc
pop de
pop bc
.loop
ld a, b
cp $9
jr z, .done
push bc
ld bc, SCRATCHMON_STRUCT_LENGTH
call CopyBytes
pop bc
inc b
jr .loop
.done
ld h, d
ld l, e
xor a
ld bc, SCRATCHMON_STRUCT_LENGTH
call ByteFill
ld hl, s0_a834
dec [hl]
jp CloseSRAM
; 445f4 (11:45f4)
ReadMailMessage: ; 445f4
ld a, b
ld hl, s0_a835
ld bc, SCRATCHMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
callba ReadAnyMail
ret
Function44607: ; 44607
ld a, BANK(s0_a834)
call GetSRAMBank
push bc
ld a, b
ld bc, SCRATCHMON_STRUCT_LENGTH
ld hl, s0_a835
call AddNTimes
push hl
ld a, [CurPartyMon]
ld bc, SCRATCHMON_STRUCT_LENGTH
ld hl, sPartyScratch1
call AddNTimes
ld d, h
ld e, l
pop hl
push hl
ld bc, SCRATCHMON_STRUCT_LENGTH
call CopyBytes
pop hl
ld de, PARTYMON_STRUCT_LENGTH - MON_MOVES
add hl, de
ld d, [hl]
ld a, [CurPartyMon]
ld hl, PartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld [hl], d
call CloseSRAM
pop bc
jp Function445c0
; 44648 (11:4648)
Function44648: ; 44648
ld a, BANK(s0_a834)
call GetSRAMBank
ld a, [s0_a834]
ld c, a
jp CloseSRAM
; 44654
Function44654:: ; 44654
push bc
push de
callba SelectMonFromParty
ld a, $2
jr c, .asm_446c6
ld a, [CurPartyMon]
ld hl, PartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, [hl]
callba ItemIsMail
ld a, $3
jr nc, .asm_446c6
ld a, BANK(sPartyScratch1)
call GetSRAMBank
ld a, [CurPartyMon]
ld hl, sPartyScratch1
ld bc, SCRATCHMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
pop hl
pop bc
ld a, $20
ld [wd265], a
.asm_44691
ld a, [de]
ld c, a
ld a, b
call GetFarByte
cp "@"
jr z, .asm_446ab
cp c
ld a, $0
jr nz, .asm_446c1
inc hl
inc de
ld a, [wd265]
dec a
ld [wd265], a
jr nz, .asm_44691
.asm_446ab
callba CheckCurPartyMonFainted
ld a, $4
jr c, .asm_446c1
xor a
ld [wPokemonWithdrawDepositParameter], a
callba Functione039
ld a, $1
.asm_446c1
call CloseSRAM
jr .asm_446c8
.asm_446c6
pop de
pop bc
.asm_446c8
ld [ScriptVar], a
ret
; 446cc
GivePokeItem:: ; 446cc GivePokeItem:: ; 446cc
ld a, [PartyCount] ld a, [PartyCount]
@ -18162,14 +17972,14 @@ GivePokeItem:: ; 446cc
pop af pop af
push bc push bc
push af push af
ld hl, sPartyScratch1 ld hl, sPartyMail
ld bc, $2f ld bc, $2f
call AddNTimes call AddNTimes
ld d, h ld d, h
ld e, l ld e, l
ld hl, wd002 ld hl, wd002
ld bc, $21 ld bc, $21
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
call CopyBytes call CopyBytes
pop af pop af
@ -18199,43 +18009,43 @@ GivePokeItem:: ; 446cc
; 44725 ; 44725
BackupScratchmons: ; 44725 BackupPartyMonMail: ; 44725
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
ld hl, sPartyScratch1 ld hl, sPartyMail
ld de, sPartyScratch2 ld de, sPartyMailBackup
ld bc, 6 * SCRATCHMON_STRUCT_LENGTH ld bc, 6 * MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
ld hl, s0_a834 ld hl, sMailboxCount
ld de, s0_aa0b ld de, sMailboxCountBackup
ld bc, 1 + 10 * SCRATCHMON_STRUCT_LENGTH ld bc, 1 + 10 * MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
jp CloseSRAM jp CloseSRAM
; 44745 ; 44745
RestoreScratchmons: ; 44745 (11:4745) RestorePartyMonMail: ; 44745 (11:4745)
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
ld hl, sPartyScratch2 ld hl, sPartyMailBackup
ld de, sPartyScratch1 ld de, sPartyMail
ld bc, 6 * SCRATCHMON_STRUCT_LENGTH ld bc, 6 * MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
ld hl, s0_aa0b ld hl, sMailboxCountBackup
ld de, s0_a834 ld de, sMailboxCount
ld bc, 1 + 10 * SCRATCHMON_STRUCT_LENGTH ld bc, 1 + 10 * MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
jp CloseSRAM jp CloseSRAM
DeleteScratchmons: ; 44765 (11:4765) DeletePartyMonMail: ; 44765 (11:4765)
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
xor a xor a
ld hl, sPartyScratch1 ld hl, sPartyMail
ld bc, 6 * SCRATCHMON_STRUCT_LENGTH ld bc, 6 * MAIL_STRUCT_LENGTH
call ByteFill call ByteFill
xor a xor a
ld hl, s0_a834 ld hl, sMailboxCount
ld bc, 1 + 10 * SCRATCHMON_STRUCT_LENGTH ld bc, 1 + 10 * MAIL_STRUCT_LENGTH
call ByteFill call ByteFill
jp CloseSRAM jp CloseSRAM
; 44781 (11:4781) ; 44781 (11:4781)
@ -18284,9 +18094,9 @@ _KrisMailBoxMenu: ; 0x447a0
InitMail: ; 0x447b9 InitMail: ; 0x447b9
; initialize wd0f2 and beyond with incrementing values, one per mail ; initialize wd0f2 and beyond with incrementing values, one per mail
; set z if no mail ; set z if no mail
ld a, BANK(s0_a834) ld a, BANK(sMailboxCount)
call GetSRAMBank call GetSRAMBank
ld a, [s0_a834] ld a, [sMailboxCount]
call CloseSRAM call CloseSRAM
ld hl, wd0f2 ld hl, wd0f2
ld [hli], a ld [hli], a
@ -18312,10 +18122,10 @@ InitMail: ; 0x447b9
Function447da: ; 0x447da Function447da: ; 0x447da
dec a dec a
ld hl, s0_a835 + MON_HP - 1 ld hl, sMailbox + MON_HP - 1
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
ld a, BANK(s0_a834) ld a, BANK(sMailboxCount)
call GetSRAMBank call GetSRAMBank
ld de, StringBuffer2 ld de, StringBuffer2
push de push de
@ -18396,7 +18206,7 @@ Function4484a: ; 0x4484a
dec a dec a
ld b, a ld b, a
call ReadMailMessage call ReadMailMessage
jp Function2b3c jp ReturnToCallingMenu
; 0x44877 ; 0x44877
.PutInPack ; 0x44877 .PutInPack ; 0x44877
@ -18439,10 +18249,10 @@ Function4484a: ; 0x4484a
.Function448bb: ; 0x448bb .Function448bb: ; 0x448bb
push af push af
ld a, BANK(s0_a834) ld a, BANK(sMailboxCount)
call GetSRAMBank call GetSRAMBank
pop af pop af
ld hl, s0_a835 + $2e ld hl, sMailbox + $2e
ld bc, $2f ld bc, $2f
call AddNTimes call AddNTimes
ld a, [hl] ld a, [hl]
@ -18455,7 +18265,7 @@ Function4484a: ; 0x4484a
xor a xor a
ld [PartyMenuActionText], a ld [PartyMenuActionText], a
call ClearBGPalettes call ClearBGPalettes
.asm_448dc .try_again
callba Function5004f callba Function5004f
callba Function50405 callba Function50405
callba Function503e0 callba Function503e0
@ -18465,25 +18275,25 @@ Function4484a: ; 0x4484a
call SetPalettes call SetPalettes
call DelayFrame call DelayFrame
callba PartyMenuSelect callba PartyMenuSelect
jr c, .asm_44939 jr c, .exit
ld a, [CurPartySpecies] ld a, [CurPartySpecies]
cp EGG cp EGG
jr z, .asm_44923 jr z, .egg
ld a, MON_ITEM ld a, MON_ITEM
call GetPartyParamLocation call GetPartyParamLocation
ld a, [hl] ld a, [hl]
and a and a
jr z, .asm_4492b jr z, .attach_mail
ld hl, .HoldingMailText ld hl, .HoldingMailText
call PrintText call PrintText
jr .asm_448dc jr .try_again
.asm_44923 .egg
ld hl, .EggText ld hl, .EggText
call PrintText call PrintText
jr .asm_448dc jr .try_again
.asm_4492b .attach_mail
ld a, [MenuSelection] ld a, [MenuSelection]
dec a dec a
ld b, a ld b, a
@ -18491,8 +18301,8 @@ Function4484a: ; 0x4484a
ld hl, .MailMovedText ld hl, .MailMovedText
call PrintText call PrintText
.asm_44939 .exit
jp Function2b3c jp ReturnToCallingMenu
; 0x4493c ; 0x4493c
.HoldingMailText ; 0x4493c .HoldingMailText ; 0x4493c
@ -18720,7 +18530,7 @@ Special_MoveTutor: ; 4925b
ld [ScriptVar], a ld [ScriptVar], a
.asm_492a1 .asm_492a1
call Function2b3c call ReturnToCallingMenu
ret ret
; 492a5 ; 492a5
@ -19924,7 +19734,7 @@ Function4a94e: ; 4a94e
jr c, .asm_4a974 jr c, .asm_4a974
.asm_4a990 .asm_4a990
call Function2b3c call ReturnToCallingMenu
ld hl, wd002 ld hl, wd002
ld a, -1 ld a, -1
ld bc, 3 ld bc, 3
@ -19937,7 +19747,7 @@ Function4a94e: ; 4a94e
jr c, .asm_4a9b0 jr c, .asm_4a9b0
call Function4a9d7 call Function4a9d7
jr c, .asm_4a974 jr c, .asm_4a974
call Function2b3c call ReturnToCallingMenu
and a and a
.asm_4a9af .asm_4a9af
@ -24838,27 +24648,27 @@ _SwitchPartyMons:
pop de pop de
ld hl, wd002 ld hl, wd002
call .CopyName call .CopyName
ld hl, sPartyScratch1 ld hl, sPartyMail
ld a, [Buffer2] ; wd1eb (aliases: MovementType) ld a, [Buffer2] ; wd1eb (aliases: MovementType)
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
push hl push hl
ld de, wd002 ld de, wd002
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
call CopyBytes call CopyBytes
ld hl, sPartyScratch1 ld hl, sPartyMail
ld a, [Buffer3] ld a, [Buffer3]
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
pop de pop de
push hl push hl
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
pop de pop de
ld hl, wd002 ld hl, wd002
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call CopyBytes call CopyBytes
call CloseSRAM call CloseSRAM
pop bc pop bc
@ -31402,8 +31212,8 @@ INCLUDE "engine/radio.asm"
ReadPartyMonMail: ; b9229 ReadPartyMonMail: ; b9229
ld a, [CurPartyMon] ld a, [CurPartyMon]
ld hl, sPartyScratch1 ld hl, sPartyMail
ld bc, SCRATCHMON_STRUCT_LENGTH ld bc, MAIL_STRUCT_LENGTH
call AddNTimes call AddNTimes
ld d, h ld d, h
ld e, l ld e, l
@ -31416,7 +31226,7 @@ ReadAnyMail: ; b9237
call LoadFontsExtra call LoadFontsExtra
pop de pop de
push de push de
ld a, BANK(sPartyScratch1) ld a, BANK(sPartyMail)
call GetSRAMBank call GetSRAMBank
callba Function1de5c8 callba Function1de5c8
call CloseSRAM call CloseSRAM
@ -41337,24 +41147,25 @@ INCBIN "gfx/misc/pokegear.2bpp.lz"
; 1de5c8 ; 1de5c8
Function1de5c8: ; 1de5c8 Function1de5c8: ; 1de5c8
; reads mail message at de
ld c, $0 ld c, $0
ld hl, $29 ld hl, $29
add hl, de add hl, de
ld a, [hli] ld a, [hli]
cp $84 cp "E"
ret nz ret nz
ld a, [hli] ld a, [hli]
inc c inc c
cp $85 cp "F"
ret z ret z
inc c inc c
cp $86 cp "G"
ret z ret z
inc c inc c
cp $88 cp "I"
ret z ret z
inc c inc c
cp $92 cp "S"
ret z ret z
ld c, $0 ld c, $0
ret ret

View File

@ -2523,7 +2523,7 @@ Unknown_100fc0: ; 100fc0
db -1 db -1
Unknown_100feb: ; 100feb Unknown_100feb: ; 100feb
dbwww $00, sPartyScratch1, SCRATCHMON_STRUCT_LENGTH * PARTY_LENGTH, NULL dbwww $00, sPartyMail, MAIL_STRUCT_LENGTH * PARTY_LENGTH, NULL
db -1 db -1
Unknown_100ff3: ; 100ff3 Unknown_100ff3: ; 100ff3

View File

@ -5842,7 +5842,7 @@ Function11ac3e: ; 11ac3e
call FadeToMenu call FadeToMenu
callab InefficientlyClear121BytesAtwc300 callab InefficientlyClear121BytesAtwc300
call Function11ac51 call Function11ac51
call Function2b3c call ReturnToCallingMenu
ret ret
; 11ac51 ; 11ac51
@ -7697,7 +7697,7 @@ Function11b7e5: ; 11b7e5
ld [de], a ld [de], a
.asm_11b872 .asm_11b872
call Function2b3c call ReturnToCallingMenu
call RestartMapMusic call RestartMapMusic
ret ret
; 11b879 ; 11b879
@ -7919,7 +7919,7 @@ Function11b98f: ; 11b98f
call CopyBytes call CopyBytes
ld a, "@" ld a, "@"
ld [de], a ld [de], a
ld hl, sPartyScratch1 ld hl, sPartyMail
ld bc, PARTYMON_STRUCT_LENGTH - 1 ld bc, PARTYMON_STRUCT_LENGTH - 1
ld a, [wcd2a] ld a, [wcd2a]
.loop5 .loop5

View File

@ -278,7 +278,7 @@ Function1704e1: ; 1704e1
call FadeToMenu call FadeToMenu
call Function17021e call Function17021e
call Function1704f1 call Function1704f1
call Function2b3c call ReturnToCallingMenu
ret ret
; 1704f1 ; 1704f1

View File

@ -324,7 +324,7 @@ Function17d0f3: ; 17d0f3
ld [de], a ld [de], a
.asm_17d180 .asm_17d180
call Function2b3c call ReturnToCallingMenu
call RestartMapMusic call RestartMapMusic
ret ret
; 17d187 ; 17d187
@ -562,7 +562,7 @@ Function17d2ce: ; 17d2ce
ld [MusicFadeIDHi], a ld [MusicFadeIDHi], a
call PlayMusic call PlayMusic
call ReturnToMapFromSubmenu call ReturnToMapFromSubmenu
call Function2b3c call ReturnToCallingMenu
ret ret
; 17d314 ; 17d314
@ -4674,7 +4674,7 @@ Function17f53d: ; 17f53d
call Function17f555 call Function17f555
pop af pop af
ld [rSVBK], a ld [rSVBK], a
call Function2b4d call ExitAllMenus
ret ret
; 17f555 ; 17f555

View File

@ -9,12 +9,54 @@ sScratch::
SECTION "SRAM Bank 0", SRAM [$a600], BANK [0] SECTION "SRAM Bank 0", SRAM [$a600], BANK [0]
sPartyScratch1:: ds 6 * SCRATCHMON_STRUCT_LENGTH mailmsg: MACRO
sPartyScratch2:: ds 6 * SCRATCHMON_STRUCT_LENGTH \1Message:: ds $20
s0_a834:: ds 1 \1Author:: ds NAME_LENGTH
s0_a835:: ds 10 * SCRATCHMON_STRUCT_LENGTH ds 3
s0_aa0b:: ds 1 \1MailType:: ds 1
s0_aa0c:: ds 10 * SCRATCHMON_STRUCT_LENGTH endm
sPartyMail::
sPartyMon1Mail:: mailmsg sPartyMon1Mail
sPartyMon2Mail:: mailmsg sPartyMon2Mail
sPartyMon3Mail:: mailmsg sPartyMon3Mail
sPartyMon4Mail:: mailmsg sPartyMon4Mail
sPartyMon5Mail:: mailmsg sPartyMon5Mail
sPartyMon6Mail:: mailmsg sPartyMon6Mail
sPartyMailBackup::
sPartyMon1MailBackup:: mailmsg sPartyMon1MailBackup
sPartyMon2MailBackup:: mailmsg sPartyMon2MailBackup
sPartyMon3MailBackup:: mailmsg sPartyMon3MailBackup
sPartyMon4MailBackup:: mailmsg sPartyMon4MailBackup
sPartyMon5MailBackup:: mailmsg sPartyMon5MailBackup
sPartyMon6MailBackup:: mailmsg sPartyMon6MailBackup
sMailboxCount:: ds 1
sMailbox::
sMailbox1:: mailmsg sMailbox1
sMailbox2:: mailmsg sMailbox2
sMailbox3:: mailmsg sMailbox3
sMailbox4:: mailmsg sMailbox4
sMailbox5:: mailmsg sMailbox5
sMailbox6:: mailmsg sMailbox6
sMailbox7:: mailmsg sMailbox7
sMailbox8:: mailmsg sMailbox8
sMailbox9:: mailmsg sMailbox9
sMailbox10:: mailmsg sMailbox10
sMailboxCountBackup:: ds 1
sMailboxBackup::
sMailbox1Backup:: mailmsg sMailbox1Backup
sMailbox2Backup:: mailmsg sMailbox2Backup
sMailbox3Backup:: mailmsg sMailbox3Backup
sMailbox4Backup:: mailmsg sMailbox4Backup
sMailbox5Backup:: mailmsg sMailbox5Backup
sMailbox6Backup:: mailmsg sMailbox6Backup
sMailbox7Backup:: mailmsg sMailbox7Backup
sMailbox8Backup:: mailmsg sMailbox8Backup
sMailbox9Backup:: mailmsg sMailbox9Backup
sMailbox10Backup:: mailmsg sMailbox10Backup
sMysteryGiftItem:: ds 1 sMysteryGiftItem:: ds 1
s0_abe3:: ds 1 s0_abe3:: ds 1