Identify remaining Mystery Gift labels and constants

Source: https://projectpokemon.org/home/forums/topic/43930-mystery-gift-reverse-engineering-of-ir-protocol/
This commit is contained in:
Rangi 2020-10-27 13:22:27 -04:00
parent 2738858985
commit 446f1846b1
11 changed files with 667 additions and 519 deletions

View File

@ -71,10 +71,10 @@ rTIMA EQU $ff05 ; Timer counter (R/W)
rTMA EQU $ff06 ; Timer Modulo (R/W) rTMA EQU $ff06 ; Timer Modulo (R/W)
rTAC EQU $ff07 ; Timer Control (R/W) rTAC EQU $ff07 ; Timer Control (R/W)
rTAC_ON EQU 2 rTAC_ON EQU 2
rTAC_4096_HZ EQU 0 rTAC_4096_HZ EQU %00
rTAC_262144_HZ EQU 1 rTAC_262144_HZ EQU %01
rTAC_65536_HZ EQU 2 rTAC_65536_HZ EQU %10
rTAC_16384_HZ EQU 3 rTAC_16384_HZ EQU %11
rIF EQU $ff0f ; Interrupt Flag (R/W) rIF EQU $ff0f ; Interrupt Flag (R/W)
rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W) rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W)
rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W) rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W)
@ -147,6 +147,9 @@ rHDMA3 EQU $ff53 ; CGB Mode Only - New DMA Destination, High
rHDMA4 EQU $ff54 ; CGB Mode Only - New DMA Destination, Low rHDMA4 EQU $ff54 ; CGB Mode Only - New DMA Destination, Low
rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start
rRP EQU $ff56 ; CGB Mode Only - Infrared Communications Port rRP EQU $ff56 ; CGB Mode Only - Infrared Communications Port
rRP_LED_ON EQU 0
rRP_RECEIVING EQU 1
rRP_ENABLE_READ_MASK EQU %11000000
rBGPI EQU $ff68 ; CGB Mode Only - Background Palette Index rBGPI EQU $ff68 ; CGB Mode Only - Background Palette Index
rBGPI_AUTO_INCREMENT EQU 7 ; increment rBGPI after write to rBGPD rBGPI_AUTO_INCREMENT EQU 7 ; increment rBGPI after write to rBGPD
rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data

View File

@ -14,6 +14,8 @@ FEMALE EQU 1
; G/S version ID: 0 = Gold, 1 = Silver (used by checkver) ; G/S version ID: 0 = Gold, 1 = Silver (used by checkver)
GS_VERSION EQU 0 GS_VERSION EQU 0
; Pokémon Pikachu 2, a step counter / virtual pet device (used by Mystery Gift)
POKEMON_PIKACHU_2_VERSION EQU 3
; save file corruption check values ; save file corruption check values
SAVE_CHECK_VALUE_1 EQU 99 SAVE_CHECK_VALUE_1 EQU 99

View File

@ -30,3 +30,5 @@ 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
MAX_MYSTERY_GIFT_PARTNERS EQU 5

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
PrepMysteryGiftDataToSend: StageDataForMysteryGift:
ld de, wMysteryGiftStaging ld de, wMysteryGiftStaging
ld a, $1 + GS_VERSION ld a, GS_VERSION + 1
ld [de], a ld [de], a
inc de ; wMysteryGiftStaging+1 inc de ; wMysteryGiftStaging+1
ld a, BANK(sGameData) ld a, BANK(sGameData)
@ -46,10 +46,10 @@ PrepMysteryGiftDataToSend:
ld a, [sBackupMysteryGiftItem] ld a, [sBackupMysteryGiftItem]
ld [de], a ld [de], a
inc de inc de
ld a, [sBackupMysteryGiftItem + 1] ld a, [sNumDailyMysteryGiftPartnerIDs]
ld [de], a ld [de], a
ld a, $14 ld a, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
ld [wca00], a ld [wUnusedMysteryGiftStagedDataLength], a
call CloseSRAM call CloseSRAM
ld hl, wMysteryGiftStaging ld hl, wMysteryGiftStaging
ld de, wMysteryGiftPlayerData ld de, wMysteryGiftPlayerData
@ -121,7 +121,7 @@ PrepMysteryGiftDataToSend:
pop de pop de
ret ret
MysteryGiftGetItemHeldEffect: MysteryGiftGetItem:
ld a, c ld a, c
cp MysteryGiftItems.End - MysteryGiftItems cp MysteryGiftItems.End - MysteryGiftItems
jr nc, MysteryGiftFallbackItem jr nc, MysteryGiftFallbackItem

View File

@ -173,12 +173,13 @@ _ResetWRAM:
ld [wRoamMon2MapNumber], a ld [wRoamMon2MapNumber], a
ld [wRoamMon3MapNumber], a ld [wRoamMon3MapNumber], a
ld a, BANK(sMysteryGiftItem) ld a, BANK(sMysteryGiftItem) ; aka BANK(sMysteryGiftUnlocked)
call OpenSRAM call OpenSRAM
ld hl, sMysteryGiftItem ld hl, sMysteryGiftItem
xor a xor a
ld [hli], a ld [hli], a
dec a assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked
dec a ; -1
ld [hl], a ld [hl], a
call CloseSRAM call CloseSRAM
@ -370,7 +371,7 @@ Continue:
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
farcall JumpRoamMons farcall JumpRoamMons
farcall MysteryGift_CopyReceivedDecosToPC farcall CopyMysteryGiftReceivedDecorationsToPC
farcall ClockContinue farcall ClockContinue
ld a, [wSpawnAfterChampion] ld a, [wSpawnAfterChampion]
cp SPAWN_LANCE cp SPAWN_LANCE

View File

@ -206,7 +206,7 @@ MainMenu_GetWhichMenu:
ld a, BANK(sNumDailyMysteryGiftPartnerIDs) ld a, BANK(sNumDailyMysteryGiftPartnerIDs)
call OpenSRAM call OpenSRAM
ld a, [sNumDailyMysteryGiftPartnerIDs] ld a, [sNumDailyMysteryGiftPartnerIDs]
cp -1 cp -1 ; locked?
call CloseSRAM call CloseSRAM
jr nz, .mystery_gift jr nz, .mystery_gift
; This check makes no difference. ; This check makes no difference.

View File

@ -272,7 +272,7 @@ DoMysteryGiftIfDayHasPassed:
ld hl, wBuffer1 ld hl, wBuffer1
call InitOneDayCountdown call InitOneDayCountdown
call CloseSRAM call CloseSRAM
farcall Function1050c8 farcall ResetDailyMysteryGiftLimitIfUnlocked
.not_timed_out .not_timed_out
ld a, BANK(sMysteryGiftTimer) ld a, BANK(sMysteryGiftTimer)

View File

@ -88,8 +88,14 @@ NEXTU
hPrintNumBuffer:: ds 10 hPrintNumBuffer:: ds 10
NEXTU NEXTU
; miscellaneous ; Mystery Gift
ds 9 hMGExchangedByte:: db
hMGExchangedWord:: dw
hMGNumBits:: db
hMGChecksum:: dw
ds 1
hMGUnusedMsgLength:: db
hMGRole:: db
hMGStatusFlags:: db hMGStatusFlags:: db
ENDU ENDU

View File

@ -47,19 +47,20 @@ sMailbox8Backup:: mailmsg sMailbox8Backup
sMailbox9Backup:: mailmsg sMailbox9Backup sMailbox9Backup:: mailmsg sMailbox9Backup
sMailbox10Backup:: mailmsg sMailbox10Backup sMailbox10Backup:: mailmsg sMailbox10Backup
sMysteryGiftData::
sMysteryGiftItem:: db sMysteryGiftItem:: db
sMysteryGiftUnlocked:: db sMysteryGiftUnlocked:: db
sBackupMysteryGiftItem:: db sBackupMysteryGiftItem:: db
sNumDailyMysteryGiftPartnerIDs:: db sNumDailyMysteryGiftPartnerIDs:: db
sDailyMysteryGiftPartnerIDs:: ds 5 * 2 ; maximum 5 per day, 2 bytes per ID sDailyMysteryGiftPartnerIDs:: ds MAX_MYSTERY_GIFT_PARTNERS * 2
sMysteryGiftDecorationsReceived:: flag_array NUM_NON_TROPHY_DECOS sMysteryGiftDecorationsReceived:: flag_array NUM_NON_TROPHY_DECOS
ds 4 ds 4
sMysteryGiftTimer:: dw sMysteryGiftTimer:: dw
ds 1 ds 1
sMysteryGiftTrainerHouseFlag:: db sMysteryGiftTrainerHouseFlag:: db
sMysteryGiftPartnerName:: ds NAME_LENGTH sMysteryGiftPartnerName:: ds NAME_LENGTH
ds 1 sMysteryGiftUnusedFlag:: db
sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 sMysteryGiftTrainer:: ds wMysteryGiftTrainerEnd - wMysteryGiftTrainer
sBackupMysteryGiftItemEnd:: sBackupMysteryGiftItemEnd::
ds $30 ds $30

View File

@ -1000,29 +1000,11 @@ ENDU
NEXTU NEXTU
; mystery gift data ; mystery gift data
UNION
wMysteryGiftPartyTemp:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH
NEXTU
wMysteryGiftStaging:: ds 80 wMysteryGiftStaging:: ds 80
NEXTU
ds 7
wc807:: ds 1
ds 10
wMobileSDK_PacketChecksum:: dw
ds 4
wMobileSDK_AdapterType:: db
ds 5
wMobileSDK_SendCommandID:: db
ds 2
wc821:: ds 1
wc822:: ds 46
ENDU
UNION UNION
wMysteryGiftTrainerData:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 wMysteryGiftTrainer:: ds 1 + (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1
wMysteryGiftTrainerDataEnd:: wMysteryGiftTrainerEnd::
NEXTU NEXTU
wMysteryGiftCardHolderName:: ds PLAYER_NAME_LENGTH wMysteryGiftCardHolderName:: ds PLAYER_NAME_LENGTH
@ -1031,7 +1013,7 @@ ENDU
ds 138 ds 138
wMysteryGiftPartnerData:: wMysteryGiftPartnerData::
wc900:: db wMysteryGiftGameVersion:: db
wMysteryGiftPartnerID:: dw wMysteryGiftPartnerID:: dw
wMysteryGiftPartnerName:: ds NAME_LENGTH wMysteryGiftPartnerName:: ds NAME_LENGTH
wMysteryGiftPartnerDexCaught:: db wMysteryGiftPartnerDexCaught:: db
@ -1069,9 +1051,9 @@ wCreditsBlankFrame2bppEnd::
NEXTU NEXTU
; mystery gift data ; mystery gift data
wca00:: db wUnusedMysteryGiftStagedDataLength:: db
wca01:: db wMysteryGiftMessageCount:: db
wca02:: db wMysteryGiftStagedDataLength:: db
NEXTU NEXTU
; link data ; link data
@ -1108,6 +1090,20 @@ wccb8:: ds 1
wccb9:: ds 1 wccb9:: ds 1
wccba:: ds 102 wccba:: ds 102
NEXTU
; mobile
ds 7
wc807:: ds 1
ds 10
wMobileSDK_PacketChecksum:: dw
ds 4
wMobileSDK_AdapterType:: db
ds 5
wMobileSDK_SendCommandID:: db
ds 2
wc821:: ds 1
wc822:: ds 46
if DEF(_DEBUG) if DEF(_DEBUG)
NEXTU NEXTU
; debug room ; debug room