diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-10-27 13:22:32 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-10-27 23:08:46 -0400 |
commit | 599046c89283997efac417c445d0bdcf75fd373c (patch) | |
tree | 96739c05bfcb374ebf26fa5833a11a49bc59a7a5 | |
parent | 6e142eb5b365659ec9e13360b663037cbfa615af (diff) |
Identify remaining Mystery Gift labels and constants
Source: https://projectpokemon.org/home/forums/topic/43930-mystery-gift-reverse-engineering-of-ir-protocol/
-rw-r--r-- | constants/hardware_constants.asm | 11 | ||||
-rw-r--r-- | constants/misc_constants.asm | 2 | ||||
-rw-r--r-- | constants/serial_constants.asm | 2 | ||||
-rw-r--r-- | engine/link/mystery_gift.asm | 969 | ||||
-rw-r--r-- | engine/link/mystery_gift_2.asm | 12 | ||||
-rw-r--r-- | engine/link/mystery_gift_3.asm | 4 | ||||
-rw-r--r-- | engine/menus/intro_menu.asm | 7 | ||||
-rw-r--r-- | engine/menus/main_menu.asm | 2 | ||||
-rw-r--r-- | engine/overworld/time.asm | 2 | ||||
-rw-r--r-- | hram.asm | 10 | ||||
-rw-r--r-- | sram.asm | 7 | ||||
-rw-r--r-- | wram.asm | 17 |
12 files changed, 594 insertions, 451 deletions
diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index 970acd2f..f9014380 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -71,10 +71,10 @@ rTIMA EQU $ff05 ; Timer counter (R/W) rTMA EQU $ff06 ; Timer Modulo (R/W) rTAC EQU $ff07 ; Timer Control (R/W) rTAC_ON EQU 2 -rTAC_4096_HZ EQU 0 -rTAC_262144_HZ EQU 1 -rTAC_65536_HZ EQU 2 -rTAC_16384_HZ EQU 3 +rTAC_4096_HZ EQU %00 +rTAC_262144_HZ EQU %01 +rTAC_65536_HZ EQU %10 +rTAC_16384_HZ EQU %11 rIF EQU $ff0f ; Interrupt Flag (R/W) rNR10 EQU $ff10 ; Channel 1 Sweep register (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 rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start 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_AUTO_INCREMENT EQU 7 ; increment rBGPI after write to rBGPD rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index ca9bc937..3847cf89 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -18,6 +18,8 @@ GS_VERSION EQU 0 ELIF DEF(_SILVER) GS_VERSION EQU 1 ENDC +; 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_CHECK_VALUE_1 EQU 99 diff --git a/constants/serial_constants.asm b/constants/serial_constants.asm index 81eadbf4..fd87e4a5 100644 --- a/constants/serial_constants.asm +++ b/constants/serial_constants.asm @@ -29,3 +29,5 @@ SERIAL_NO_DATA_BYTE EQU $fe SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff SERIAL_PREAMBLE_LENGTH EQU 6 + +MAX_MYSTERY_GIFT_PARTNERS EQU 5 diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm index 0d90ba9d..881845db 100644 --- a/engine/link/mystery_gift.asm +++ b/engine/link/mystery_gift.asm @@ -1,3 +1,27 @@ +; hMGRole values +IR_RECEIVER EQU 1 +IR_SENDER EQU 2 + +; hMGStatusFlags error bits +MG_WRONG_CHECKSUM_F EQU 0 +MG_TIMED_OUT_F EQU 1 +MG_CANCELED_F EQU 4 +MG_WRONG_PREFIX_F EQU 7 + +; hMGStatusFlags values +MG_WRONG_CHECKSUM EQU 1 << MG_WRONG_CHECKSUM_F +MG_TIMED_OUT EQU 1 << MG_TIMED_OUT_F +MG_CANCELED EQU 1 << MG_CANCELED_F +MG_WRONG_PREFIX EQU 1 << MG_WRONG_PREFIX_F +MG_NOT_OKAY EQU MG_WRONG_CHECKSUM | MG_TIMED_OUT | MG_CANCELED | MG_WRONG_PREFIX +MG_OKAY EQU $ff ^ MG_NOT_OKAY +MG_START_END EQU %11111111 + +REGION_PREFIX EQU $96 +REGION_CODE EQU $90 ; USA + +MESSAGE_PREFIX EQU $5a + DoMysteryGift: call ClearTilemap call ClearSprites @@ -7,22 +31,24 @@ DoMysteryGift: ld de, .String_PressAToLink_BToCancel call PlaceString call WaitBGMap - farcall PrepMysteryGiftDataToSend - call MysteryGift_ClearTrainerData - ld a, $2 - ld [wc901], a - ld a, $14 - ld [wc902], a - ldh a, [rIE] - push af - call Function29fc9 + ; Prepare the first of two messages for wMysteryGiftPartnerData + farcall StageDataForMysteryGift + call ClearMysteryGiftTrainer + ld a, 2 + ld [wMysteryGiftMessageCount], a + ld a, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData + ld [wMysteryGiftStagedDataLength], a + ldh a, [rIE] + push af + call ExchangeMysteryGiftData ld d, a xor a ldh [rIF], a pop af ldh [rIE], a + push de call ClearTilemap call EnableLCD @@ -31,15 +57,16 @@ DoMysteryGift: call GetSGBLayout call SetPalettes pop de + hlcoord 2, 8 ld a, d ld de, .MysteryGiftCanceledText ; Link has been canceled - cp $10 + cp MG_CANCELED jp z, .LinkCanceled - cp $6c + cp MG_OKAY jp nz, .CommunicationError - ld a, [wc800] - cp 3 + ld a, [wMysteryGiftGameVersion] + cp POKEMON_PIKACHU_2_VERSION jr z, .skip_checks call .CheckAlreadyGotFiveGiftsToday ld hl, .MysteryGiftFiveADayText ; Only 5 gifts a day @@ -54,25 +81,27 @@ DoMysteryGift: ld a, [wMysteryGiftPartnerBackupItem] and a jr nz, .FriendNotReady - ld a, [wc800] - cp 3 + ld a, [wMysteryGiftGameVersion] + cp POKEMON_PIKACHU_2_VERSION jr z, .skip_append_save call .AddMysteryGiftPartnerID - ld a, [wc800] - cp 4 + ld a, [wMysteryGiftGameVersion] + cp 4 ; ??? jr z, .skip_append_save call .SaveMysteryGiftTrainerName .skip_append_save ld a, [wMysteryGiftPartnerSentDeco] and a - jr z, .item + jr z, .SentItem +; sent decoration ld a, [wMysteryGiftPartnerWhichDeco] ld c, a farcall MysteryGiftGetDecoration push bc - call MysteryGift_CheckAndSetDecorationAlreadyReceived + call CheckAndSetMysteryGiftDecorationAlreadyReceived pop bc - jr nz, .item + jr nz, .SentItem +; keep the decoration if it wasn't already received callfar GetDecorationName_c ld h, d ld l, e @@ -82,17 +111,17 @@ DoMysteryGift: ld hl, .MysteryGiftSentHomeText ; sent decoration to home jr .PrintTextAndExit -.item +.SentItem: call GetMysteryGiftBank ld a, [wMysteryGiftPartnerWhichItem] ld c, a - farcall MysteryGiftGetItemHeldEffect + farcall MysteryGiftGetItem ld a, c ld [sBackupMysteryGiftItem], a ld [wNamedObjectIndexBuffer], a call CloseSRAM call GetItemName - ld hl, .MysteryGiftSentText ; sent item + ld hl, .MysteryGiftSentText ; sent item/decoration jr .PrintTextAndExit .LinkCanceled: @@ -110,6 +139,7 @@ DoMysteryGift: .FriendNotReady: ld hl, .YourFriendIsNotReadyText ; friend not ready + ; fallthrough .PrintTextAndExit: call PrintText @@ -159,7 +189,7 @@ DoMysteryGift: .CheckAlreadyGotFiveGiftsToday: call GetMysteryGiftBank ld a, [sNumDailyMysteryGiftPartnerIDs] - cp $5 + cp MAX_MYSTERY_GIFT_PARTNERS jp CloseSRAM .CheckAlreadyGotAGiftFromThatPerson: @@ -195,9 +225,9 @@ DoMysteryGift: ld hl, sNumDailyMysteryGiftPartnerIDs ld a, [hl] inc [hl] - ld hl, sDailyMysteryGiftPartnerIDs ; inc hl + ld hl, sDailyMysteryGiftPartnerIDs ; could have done "inc hl" instead ld e, a - ld d, $0 + ld d, 0 add hl, de add hl, de ld a, [wMysteryGiftPartnerID] @@ -208,223 +238,264 @@ DoMysteryGift: .SaveMysteryGiftTrainerName: call GetMysteryGiftBank - ld a, $1 + ld a, TRUE ld [sMysteryGiftTrainerHouseFlag], a ld hl, wMysteryGiftPartnerName ld de, sMysteryGiftPartnerName ld bc, NAME_LENGTH call CopyBytes - ld a, $1 + assert sMysteryGiftPartnerName + NAME_LENGTH == sMysteryGiftUnusedFlag + ld a, TRUE ld [de], a inc de - ld hl, wMysteryGiftTrainerData - ld bc, (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 + assert sMysteryGiftUnusedFlag + 1 == sMysteryGiftTrainer + ld hl, wMysteryGiftTrainer + ld bc, wMysteryGiftTrainerEnd - wMysteryGiftTrainer call CopyBytes jp CloseSRAM -Function29fc9: +ExchangeMysteryGiftData: farcall ClearChannels - call Function2a18c + call InitializeMysteryGiftInterrupts -.loop2 - call Function2a1c4 - call Function2a20b +.restart + call BeginIRCommunication + call InitializeIRCommunicationRoles ldh a, [hMGStatusFlags] - cp $10 - jp z, Function2a103 - cp $6c - jr nz, .loop2 - - ldh a, [hPrintNumBuffer + 8] - cp $2 - jr z, Function2a055 - ld hl, hPrintNumBuffer - ld b, $1 - call Function2a184 - jr nz, .ly_loop - call Function2a07c - jp nz, Function2a103 - jr Function2a03d + cp MG_CANCELED + jp z, EndOrContinueIRCommunication + cp MG_OKAY + jr nz, .restart + + ldh a, [hMGRole] + cp IR_SENDER + jr z, SenderExchangeMysteryGiftDataPayloads +; receiver + ld hl, hMGExchangedByte + ld b, 1 + call TryReceivingIRDataBlock + jr nz, .failed + call ReceiveIRDataPayload_GotRegionPrefix + jp nz, EndOrContinueIRCommunication + jr ReceiverExchangeMysteryGiftDataPayloads_GotPayload + +.failed ; Delay frame -.ly_loop +.wait_frame ldh a, [rLY] cp LY_VBLANK - jr c, .ly_loop + jr c, .wait_frame + ld c, LOW(rRP) - ld a, $c0 + ld a, rRP_ENABLE_READ_MASK ldh [c], a - ld b, 240 ; This might have been intended as a 4-second timeout buffer. - ; However, it is reset with each frame. -.loop3 - push bc - call MysteryGift_ReadJoypad - ld b, $2 + ld b, 60 * 4 ; 4 seconds +.continue + push bc + call MysteryGift_UpdateJoypad + ld b, 1 << rRP_RECEIVING ld c, LOW(rRP) - ; Delay frame -.ly_loop2 +.in_vblank ldh a, [c] and b ld b, a ldh a, [rLY] cp LY_VBLANK - jr nc, .ly_loop2 -.ly_loop3 + jr nc, .in_vblank +.wait_vblank ldh a, [c] and b ld b, a ldh a, [rLY] cp LY_VBLANK - jr c, .ly_loop3 - + jr c, .wait_vblank ld a, b pop bc + ; Restart if the 4-second timeout has elapsed dec b - jr z, .loop2 ; we never jump here + jr z, .restart + ; Restart if rRP is not receiving data or a - jr nz, .loop2 - ; Check if we've pressed the B button + jr nz, .restart + ; Check if we've pressed the B button to cancel ldh a, [hMGJoypadReleased] bit B_BUTTON_F, a - jr z, .loop3 - ld a, $10 + jr z, .continue + ld a, MG_CANCELED ldh [hMGStatusFlags], a - jp Function2a103 - -Function2a037: - call Function2a073 - jp nz, Function2a103 -; fallthrough -Function2a03d: - call Function2a166 - jp nz, Function2a103 - call Function2a0bb - jp nz, Function2a103 - call Function2a171 - jp nz, Function2a103 - call Function2a461 - jp Function2a103 - -Function2a055: - call Function2a0bb - jp nz, Function2a103 - call Function2a171 - jp nz, Function2a103 - call Function2a073 - jp nz, Function2a103 - call Function2a166 - jp nz, Function2a103 - call Function2a45c - jp Function2a103 - -Function2a073: - ld hl, hPrintNumBuffer - ld b, $1 - call Function2a184 + jp EndOrContinueIRCommunication + +ReceiverExchangeMysteryGiftDataPayloads: + ; Receive the data payload + call ReceiveIRDataPayload + jp nz, EndOrContinueIRCommunication + ; fallthrough +ReceiverExchangeMysteryGiftDataPayloads_GotPayload: + ; Switch roles + call BeginSendingIRCommunication + jp nz, EndOrContinueIRCommunication + ; Send the data payload + call SendIRDataPayload + jp nz, EndOrContinueIRCommunication + ; Switch roles + call BeginReceivingIRCommunication + jp nz, EndOrContinueIRCommunication + ; Receive an empty block + call ReceiveEmptyIRDataBlock + jp EndOrContinueIRCommunication + +SenderExchangeMysteryGiftDataPayloads: + ; Send the data payload + call SendIRDataPayload + jp nz, EndOrContinueIRCommunication + ; Switch roles + call BeginReceivingIRCommunication + jp nz, EndOrContinueIRCommunication + ; Receive the data payload + call ReceiveIRDataPayload + jp nz, EndOrContinueIRCommunication + ; Switch roles + call BeginSendingIRCommunication + jp nz, EndOrContinueIRCommunication + ; Send an empty block + call SendEmptyIRDataBlock + jp EndOrContinueIRCommunication + +ReceiveIRDataPayload: + ; Receive the region prefix + ld hl, hMGExchangedByte + ld b, 1 + call TryReceivingIRDataBlock ret nz -; fallthrough -Function2a07c: - call Function2a461 + ; fallthrough +ReceiveIRDataPayload_GotRegionPrefix: + ; Receive an empty block + call ReceiveEmptyIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret nz - ldh a, [hPrintNumBuffer] - cp $96 - jp nz, Function2a160 - ld a, $90 - ldh [hPrintNumBuffer], a - call Function2a166 + ; Verify the received region prefix + ldh a, [hMGExchangedByte] + cp REGION_PREFIX + jp nz, WrongMysteryGiftRegion + ld a, REGION_CODE + ldh [hMGExchangedByte], a + ; Switch roles + call BeginSendingIRCommunication ret nz - ld hl, hPrintNumBuffer - ld b, $1 - call Function2a17c + ; Send the region code + ld hl, hMGExchangedByte + ld b, 1 + call TrySendingIRDataBlock ret nz - call Function2a45c + ; Send an empty block + call SendEmptyIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret nz - call Function2a171 + ; Switch roles + call BeginReceivingIRCommunication ret nz - ld hl, wMysteryGiftTrainerData - ld a, [wc902] + ; Receive the staged data + ld hl, wMysteryGiftTrainer + ld a, [wMysteryGiftStagedDataLength] ld b, a - call Function2a184 + call TryReceivingIRDataBlock ret nz - call Function2a461 + ; Receive an empty block + call ReceiveEmptyIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret -Function2a0bb: - ld a, $96 - ldh [hPrintNumBuffer], a - ld hl, hPrintNumBuffer - ld b, $1 - call Function2a17c +SendIRDataPayload: + ; Send the region prefix + ld a, REGION_PREFIX + ldh [hMGExchangedByte], a + ld hl, hMGExchangedByte + ld b, 1 + call TrySendingIRDataBlock ret nz - call Function2a45c + ; Send an empty block + call SendEmptyIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret nz - call Function2a171 + ; Switch roles + call BeginReceivingIRCommunication ret nz - ld hl, hPrintNumBuffer - ld b, $1 - call Function2a184 + ; Receive the region code + ld hl, hMGExchangedByte + ld b, 1 + call TryReceivingIRDataBlock ret nz - call Function2a461 + ; Receive an empty block + call ReceiveEmptyIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret nz - ldh a, [hPrintNumBuffer] - cp $90 - jp nz, Function2a160 - call Function2a166 + ; Verify the received region code + ldh a, [hMGExchangedByte] + cp REGION_CODE + jp nz, WrongMysteryGiftRegion + ; Switch roles + call BeginSendingIRCommunication ret nz - ld hl, wLinkData - ld a, [wc902] + ; Send the staged data + ld hl, wMysteryGiftStaging + ld a, [wMysteryGiftStagedDataLength] ld b, a - call Function2a17c + call TrySendingIRDataBlock ret nz - call Function2a45c + ; Send an empty block + call SendEmptyIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret -Function2a103: +EndOrContinueIRCommunication: nop ldh a, [hMGStatusFlags] - cp $10 + ; Quit if player canceled + cp MG_CANCELED jr z, .quit - cp $6c + ; Quit if there was a communication error + cp MG_OKAY jr nz, .quit - ld hl, wc901 + ; Quit if all messages are sent/received + ld hl, wMysteryGiftMessageCount dec [hl] jr z, .quit - ld hl, wMysteryGiftTrainerData + ; Quit if communicating with Pokémon Pikachu 2 device + ld hl, wMysteryGiftTrainer ld de, wMysteryGiftPartnerData ld bc, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData call CopyBytes - ld a, [wMysteryGiftTrainerData] - cp $3 + ld a, [wMysteryGiftTrainer] ; first byte is the version + cp POKEMON_PIKACHU_2_VERSION jr nc, .quit + + ; Prepare the second message for wMysteryGiftTrainer farcall StagePartyDataForMysteryGift - call MysteryGift_ClearTrainerData - ld a, $26 - ld [wc902], a - ldh a, [hPrintNumBuffer + 8] - cp $2 - jr z, .asm_2a143 - call Function2a171 - jr nz, Function2a103 - jp Function2a037 - -.asm_2a143 - call Function2a166 - jr nz, Function2a103 - jp Function2a055 - -.quit: + call ClearMysteryGiftTrainer + ld a, wMysteryGiftTrainerEnd - wMysteryGiftTrainer + ld [wMysteryGiftStagedDataLength], a + + ldh a, [hMGRole] + cp IR_SENDER + jr z, .sender +; receiver + call BeginReceivingIRCommunication + jr nz, EndOrContinueIRCommunication + jp ReceiverExchangeMysteryGiftDataPayloads + +.sender + call BeginSendingIRCommunication + jr nz, EndOrContinueIRCommunication + jp SenderExchangeMysteryGiftDataPayloads + +.quit xor a ldh [rIF], a ldh a, [rIE] @@ -434,50 +505,50 @@ Function2a103: call DelayFrame ldh a, [hMGStatusFlags] push af - call Function2a1ce + call EndIRCommunication pop af ret -Function2a160: - ld a, $80 +WrongMysteryGiftRegion: + ld a, MG_WRONG_PREFIX ldh [hMGStatusFlags], a and a ret -Function2a166: - call Function2a1c4 - call Function2a274 +BeginSendingIRCommunication: + call BeginIRCommunication + call SendIRHelloMessage ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret -Function2a171: - call Function2a1c4 - call Function2a22c +BeginReceivingIRCommunication: + call BeginIRCommunication + call ReceiveIRHelloMessage ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret -Function2a17c: - call Function2a2c1 +TrySendingIRDataBlock: + call SendIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret -Function2a184: - call Function2a385 +TryReceivingIRDataBlock: + call ReceiveIRDataBlock ldh a, [hMGStatusFlags] - cp $6c + cp MG_OKAY ret -Function2a18c: - call Function2a1a2 +InitializeMysteryGiftInterrupts: + call StartFastIRTimer ld a, 1 << TIMER ldh [rIE], a xor a ldh [rIF], a - call Function2a1c4 -; runs for ~$40400 cycles + call BeginIRCommunication +; waits for ~$40400 cycles = ~0.25 seconds xor a ld b, a .busy_wait @@ -487,69 +558,76 @@ Function2a18c: jr nz, .busy_wait ret -Function2a1a2: +StartFastIRTimer: +; Starts a 65,536 Hz timer that interrupts every 3 increments (21,845 Hz). xor a ldh [rTAC], a - ld a, $fe + ld a, -2 ldh [rTMA], a ldh [rTIMA], a - ld a, $2 + ld a, rTAC_65536_HZ ldh [rTAC], a - or $4 + or 1 << rTAC_ON ldh [rTAC], a ret -Function2a1b4: +StartSlowIRTimer: +; Starts a 65,536 Hz timer that interrupts every 256 increments (256 Hz). xor a ldh [rTAC], a ldh [rTMA], a ldh [rTIMA], a - ld a, $2 + ld a, rTAC_65536_HZ ldh [rTAC], a - or $4 + or 1 << rTAC_ON ldh [rTAC], a ret -Function2a1c4: - ld a, $c0 - call Function2a2ba - ld a, $1 - ldh [hPrintNumBuffer + 8], a +BeginIRCommunication: + ld a, rRP_ENABLE_READ_MASK + call ToggleIRCommunication + ld a, IR_RECEIVER + ldh [hMGRole], a ret -Function2a1ce: +EndIRCommunication: xor a - call Function2a2ba - ld a, $2 + call ToggleIRCommunication + ld a, rTAC_65536_HZ ldh [rTAC], a ret -Function2a1d7: +ReceiveInfraredLEDOn: +; Count interrupts of the partner's IR LED on; quit after 256-d interrupts. +.recv_loop inc d ret z xor a ldh [rIF], a halt ldh a, [c] - bit 1, a - jr z, Function2a1d7 + bit rRP_RECEIVING, a + jr z, .recv_loop or a ret -Function2a1e5: +ReceiveInfraredLEDOff: +; Count interrupts of the partner's IR LED off; quit after 256-d interrupts. +.no_recv_loop inc d ret z xor a ldh [rIF], a halt ldh a, [c] - bit 1, a - jr nz, Function2a1e5 + bit rRP_RECEIVING, a + jr nz, .no_recv_loop or a ret -Function2a1f3: - ld a, $c1 +SendInfraredLEDOn: +; Holds the IR LED on for d-1 interrupts. + ld a, rRP_ENABLE_READ_MASK | (1 << rRP_LED_ON) ldh [c], a .wait dec d @@ -559,8 +637,9 @@ Function2a1f3: halt jr .wait -Function2a1ff: - ld a, $c0 +SendInfraredLEDOff: +; Holds the IR LED off for d-1 interrupts. + ld a, rRP_ENABLE_READ_MASK ldh [c], a .wait dec d @@ -570,175 +649,204 @@ Function2a1ff: halt jr .wait -Function2a20b: - ld d, $0 +InitializeIRCommunicationRoles: + ld d, 0 ld e, d - ld a, $1 - ldh [hPrintNumBuffer + 8], a + + ld a, IR_RECEIVER + ldh [hMGRole], a .loop - call MysteryGift_ReadJoypad - ld b, $2 + call MysteryGift_UpdateJoypad + ld b, 1 << rRP_RECEIVING ld c, LOW(rRP) + ; Check if we've pressed the B button to cancel ldh a, [hMGJoypadReleased] bit B_BUTTON_F, a - jr z, .next - ld a, $10 + jr z, .not_canceled + ld a, MG_CANCELED ldh [hMGStatusFlags], a ret -.next - bit 0, a - jr nz, Function2a268 +.not_canceled + ; Check if we've pressed the A button to start sending + bit A_BUTTON_F, a + jr nz, SendIRHelloMessageAfterDelay + ; If rRP is not receiving data, keep checking for input ldh a, [c] and b jr nz, .loop + ; fallthrough -Function2a22c: +ReceiveIRHelloMessage: ld c, LOW(rRP) - ld d, $0 + ld d, 0 ld e, d - call Function2a1e5 - jp z, Function2a370 + + call ReceiveInfraredLEDOff + jp z, InfraredLEDReceiveTimedOut ld d, e - call Function2a1d7 - jp z, Function2a370 - call Function2a1e5 - jp z, Function2a370 - call Function2a1d7 - jp z, Function2a370 - ld a, $6c + call ReceiveInfraredLEDOn + jp z, InfraredLEDReceiveTimedOut + call ReceiveInfraredLEDOff + jp z, InfraredLEDReceiveTimedOut + call ReceiveInfraredLEDOn + jp z, InfraredLEDReceiveTimedOut + + ld a, MG_OKAY ldh [hMGStatusFlags], a - ld d, $3d - call Function2a1ff - ld d, $5 - call Function2a1f3 - ld d, $15 - call Function2a1ff - ld d, $5 - call Function2a1f3 - ld d, $5 - call Function2a1ff + + ld d, 61 + call SendInfraredLEDOff + ld d, 5 + call SendInfraredLEDOn + ld d, 21 + call SendInfraredLEDOff + ld d, 5 + call SendInfraredLEDOn + ld d, 5 + call SendInfraredLEDOff ret -Function2a268: +SendIRHelloMessageAfterDelay: ; Wait a random amount of time call Random ld e, a and $f ld d, a -.loop +.wait_loop dec de ld a, d or e - jr nz, .loop -Function2a274: - ld a, $2 - ldh [hPrintNumBuffer + 8], a + jr nz, .wait_loop + ; fallthrough + +SendIRHelloMessage: + ld a, IR_SENDER + ldh [hMGRole], a + ld c, LOW(rRP) - ld d, $0 + ld d, 0 ld e, d - ld d, $3d - call Function2a1ff - ld d, $5 - call Function2a1f3 - ld d, $15 - call Function2a1ff - ld d, $5 - call Function2a1f3 - ld d, $5 - call Function2a1ff + + ld d, 61 + call SendInfraredLEDOff + ld d, 5 + call SendInfraredLEDOn + ld d, 21 + call SendInfraredLEDOff + ld d, 5 + call SendInfraredLEDOn + ld d, 5 + call SendInfraredLEDOff + ld d, e - call Function2a1e5 - jp z, Function2a370 + call ReceiveInfraredLEDOff + jp z, InfraredLEDReceiveTimedOut ld d, e - call Function2a1d7 - jp z, Function2a370 - call Function2a1e5 - jp z, Function2a370 - call Function2a1d7 - jp z, Function2a370 - ld d, $3d - call Function2a1ff - ld a, $6c + call ReceiveInfraredLEDOn + jp z, InfraredLEDReceiveTimedOut + call ReceiveInfraredLEDOff + jp z, InfraredLEDReceiveTimedOut + call ReceiveInfraredLEDOn + jp z, InfraredLEDReceiveTimedOut + + ld d, 61 + call SendInfraredLEDOff + + ld a, MG_OKAY ldh [hMGStatusFlags], a ret -Function2a2ba: +ToggleIRCommunication: ldh [rRP], a - ld a, $ff + ld a, MG_START_END ldh [hMGStatusFlags], a ret -Function2a2c1: +SendIRDataBlock: +; Send b bytes of data in three messages: +; 1. two bytes: MESSAGE_PREFIX and the length b +; 2. b bytes: the actual data +; 3. two bytes: a little-endian checksum +; Then receive a one-byte acknowledgement message: the status. xor a - ldh [hPrintNumBuffer + 4], a - ldh [hPrintNumBuffer + 5], a + ldh [hMGChecksum + 0], a + ldh [hMGChecksum + 1], a push hl push bc ld c, LOW(rRP) - ld d, $3d - call Function2a1ff - ld hl, hPrintNumBuffer + 1 - ld a, $5a + ld d, 61 + call SendInfraredLEDOff + ld hl, hMGExchangedWord + ld a, MESSAGE_PREFIX ld [hli], a ld [hl], b dec hl - ld b, $2 - call Function2a304 + ld b, 2 + call SendIRDataMessage pop bc pop hl - call Function2a304 - ldh a, [hPrintNumBuffer + 4] - ldh [hPrintNumBuffer + 1], a - ldh a, [hPrintNumBuffer + 5] - ldh [hPrintNumBuffer + 2], a + call SendIRDataMessage + ldh a, [hMGChecksum + 0] + ldh [hMGExchangedWord + 0], a + ldh a, [hMGChecksum + 1] + ldh [hMGExchangedWord + 1], a push hl - ld hl, hPrintNumBuffer + 1 - ld b, $2 - call Function2a304 + ld hl, hMGExchangedWord + ld b, 2 + call SendIRDataMessage ld hl, hMGStatusFlags - ld b, $1 - call Function2a3dd - ldh a, [hPrintNumBuffer + 1] - ldh [hPrintNumBuffer + 4], a - ldh a, [hPrintNumBuffer + 2] - ldh [hPrintNumBuffer + 5], a + ld b, 1 + call ReceiveIRDataMessage + ldh a, [hMGExchangedWord + 0] + ldh [hMGChecksum + 0], a + ldh a, [hMGExchangedWord + 1] + ldh [hMGChecksum + 1], a pop hl ret -Function2a304: +SendIRDataMessage: +; Send b bytes of data one bit at a time, and update the checksum. ld c, LOW(rRP) - ld d, $5 - call Function2a1ff - ld d, $5 - call Function2a1f3 - ld d, $15 - call Function2a1ff + + ld d, 5 + call SendInfraredLEDOff + ld d, 5 + call SendInfraredLEDOn + ld d, 21 + call SendInfraredLEDOff + + ; b = -b - 1; then count up to 0 ld a, b cpl ld b, a - ld a, $f4 + + ld a, -12 ldh [rTMA], a -.main_loop +.byte_loop inc b jr z, .done - ld a, $8 - ldh [hPrintNumBuffer + 3], a + ld a, 8 + ldh [hMGNumBits], a + ; Get the next data byte ld a, [hli] ld e, a - ldh a, [hPrintNumBuffer + 4] + ; Add the next data byte to the checksum + ldh a, [hMGChecksum + 0] add e - ldh [hPrintNumBuffer + 4], a - ldh a, [hPrintNumBuffer + 5] + ldh [hMGChecksum + 0], a + ldh a, [hMGChecksum + 1] adc 0 - ldh [hPrintNumBuffer + 5], a -.inner_loop + ldh [hMGChecksum + 1], a + ; Send each bit of the byte +.bit_loop xor a ldh [rIF], a halt - ld a, $c1 + ld a, rRP_ENABLE_READ_MASK | (1 << rRP_LED_ON) ldh [rRP], a - ld d, $1 + ; Turn the LED off for longer if the bit is 1 + ld d, 1 ld a, e rlca ld e, a @@ -746,9 +854,9 @@ Function2a304: inc d .wait ldh a, [rTIMA] - cp $f8 + cp -8 jr c, .wait - ld a, $c0 + ld a, rRP_ENABLE_READ_MASK ldh [rRP], a dec d jr z, .no_halt @@ -756,133 +864,145 @@ Function2a304: ldh [rIF], a halt .no_halt - ldh a, [hPrintNumBuffer + 3] + ldh a, [hMGNumBits] dec a - jr z, .main_loop - ldh [hPrintNumBuffer + 3], a - jr .inner_loop + jr z, .byte_loop + ldh [hMGNumBits], a + jr .bit_loop .done - ld a, $fe + ld a, -2 ldh [rTMA], a xor a ldh [rIF], a halt - ld d, $5 - call Function2a1f3 - ld d, $11 - call Function2a1ff + + ld d, 5 + call SendInfraredLEDOn + ld d, 17 + call SendInfraredLEDOff ret -Function2a370: +InfraredLEDReceiveTimedOut: ldh a, [hMGStatusFlags] - or $2 + or MG_TIMED_OUT ldh [hMGStatusFlags], a ret -Function2a377: +ReceivedWrongIRChecksum: ldh a, [hMGStatusFlags] - or $1 + or MG_WRONG_CHECKSUM ldh [hMGStatusFlags], a ret -Function2a37e: +ReceivedWrongIRMessagePrefix: ldh a, [hMGStatusFlags] - or $80 + or MG_WRONG_PREFIX ldh [hMGStatusFlags], a ret -Function2a385: +ReceiveIRDataBlock: +; Receive b bytes of data in three messages: +; 1. two bytes: MESSAGE_PREFIX and the length b +; 2. b bytes: the actual data +; 3. two bytes: a little-endian checksum +; Then send a one-byte acknowledgement message: the status. xor a - ldh [hPrintNumBuffer + 4], a - ldh [hPrintNumBuffer + 5], a + ldh [hMGChecksum + 0], a + ldh [hMGChecksum + 1], a push bc push hl - ld hl, hPrintNumBuffer + 1 - ld b, $2 - call Function2a3dd - ldh a, [hPrintNumBuffer + 2] - ldh [hPrintNumBuffer + 7], a + ld hl, hMGExchangedWord + ld b, 2 + call ReceiveIRDataMessage + ldh a, [hMGExchangedWord + 1] + ldh [hMGUnusedMsgLength], a ld b, a pop hl pop af cp b - jp c, Function2a37e - ldh a, [hPrintNumBuffer + 1] - cp $5a - jp nz, Function2a37e - call Function2a3dd - ldh a, [hPrintNumBuffer + 4] + jp c, ReceivedWrongIRMessagePrefix + ldh a, [hMGExchangedWord + 0] + cp MESSAGE_PREFIX + jp nz, ReceivedWrongIRMessagePrefix + call ReceiveIRDataMessage + ldh a, [hMGChecksum + 0] ld d, a - ldh a, [hPrintNumBuffer + 5] + ldh a, [hMGChecksum + 1] ld e, a push hl push de - ld hl, hPrintNumBuffer + 1 - ld b, $2 - call Function2a3dd + ld hl, hMGExchangedWord + ld b, 2 + call ReceiveIRDataMessage pop de - ld hl, hPrintNumBuffer + 1 + ld hl, hMGExchangedWord ld a, [hli] xor d ld b, a ld a, [hl] xor e or b - call nz, Function2a377 + call nz, ReceivedWrongIRChecksum push de - ld d, $3d - call Function2a1ff + + ld d, 61 + call SendInfraredLEDOff + ld hl, hMGStatusFlags - ld b, $1 - call Function2a304 + ld b, 1 + call SendIRDataMessage + pop de pop hl ld a, d - ldh [hPrintNumBuffer + 4], a + ldh [hMGChecksum + 0], a ld a, e - ldh [hPrintNumBuffer + 5], a + ldh [hMGChecksum + 1], a ret -Function2a3dd: +ReceiveIRDataMessage: ld c, LOW(rRP) - ld d, $0 - call Function2a1e5 - jp z, Function2a370 - ld d, $0 - call Function2a1d7 - jp z, Function2a370 - ld d, $0 - call Function2a1e5 - jp z, Function2a370 + + ld d, 0 + call ReceiveInfraredLEDOff + jp z, InfraredLEDReceiveTimedOut + ld d, 0 + call ReceiveInfraredLEDOn + jp z, InfraredLEDReceiveTimedOut + ld d, 0 + call ReceiveInfraredLEDOff + jp z, InfraredLEDReceiveTimedOut + ld a, b cpl ld b, a xor a ldh [hMGPrevTIMA], a - call Function2a1b4 + + call StartSlowIRTimer .main_loop inc b jr z, .done - ld a, $8 - ldh [hPrintNumBuffer + 3], a + ld a, 8 + ldh [hMGNumBits], a .inner_loop - ld d, $0 -.wait_one + ld d, 0 +.recv_loop inc d - jr z, .got_one + jr z, .recv_done ldh a, [c] - bit 1, a - jr z, .wait_one - ld d, $0 -.got_one -.wait_zero + bit rRP_RECEIVING, a + jr z, .recv_loop + ld d, 0 +.recv_done +.send_loop inc d - jr z, .got_zero + jr z, .send_done ldh a, [c] - bit 1, a - jr nz, .wait_zero -.got_zero + bit rRP_RECEIVING, a + jr nz, .send_loop +.send_done ldh a, [hMGPrevTIMA] ld d, a ldh a, [rTIMA] @@ -895,9 +1015,9 @@ Function2a3dd: .zero res 0, e .ok - ldh a, [hPrintNumBuffer + 3] + ldh a, [hMGNumBits] dec a - ldh [hPrintNumBuffer + 3], a + ldh [hMGNumBits], a jr z, .continue ld a, e rlca @@ -907,34 +1027,35 @@ Function2a3dd: .continue ld a, e ld [hli], a - ldh a, [hPrintNumBuffer + 4] + ldh a, [hMGChecksum + 0] add e - ldh [hPrintNumBuffer + 4], a - ldh a, [hPrintNumBuffer + 5] + ldh [hMGChecksum + 0], a + ldh a, [hMGChecksum + 1] adc 0 - ldh [hPrintNumBuffer + 5], a + ldh [hMGChecksum + 1], a jr .main_loop .done - call Function2a1a2 + call StartFastIRTimer xor a ldh [rIF], a - ld d, $0 - call Function2a1d7 - jp z, Function2a370 - ld d, $10 - call Function2a1ff + ld d, 0 + call ReceiveInfraredLEDOn + jp z, InfraredLEDReceiveTimedOut + + ld d, 16 + call SendInfraredLEDOff ret -Function2a45c: - ld b, $0 - jp Function2a2c1 +SendEmptyIRDataBlock: + ld b, 0 + jp SendIRDataBlock -Function2a461: - ld b, $0 - jp Function2a385 +ReceiveEmptyIRDataBlock: + ld b, 0 + jp ReceiveIRDataBlock -MysteryGift_ReadJoypad: +MysteryGift_UpdateJoypad: ; We can only get four inputs at a time. ; We take d-pad first for no particular reason. ld a, R_DPAD @@ -979,9 +1100,10 @@ endr ldh [rJOYP], a ret -MysteryGift_CheckAndSetDecorationAlreadyReceived: +CheckAndSetMysteryGiftDecorationAlreadyReceived: +; Return nz if decoration c was already received; otherwise receive it. call GetMysteryGiftBank - ld d, $0 + ld d, 0 ld b, CHECK_FLAG ld hl, sMysteryGiftDecorationsReceived lda_predef SmallFarFlagAction @@ -1001,12 +1123,12 @@ MysteryGift_CheckAndSetDecorationAlreadyReceived: xor a ret -MysteryGift_CopyReceivedDecosToPC: +CopyMysteryGiftReceivedDecorationsToPC: call GetMysteryGiftBank - ld c, $0 + ld c, 0 .loop push bc - ld d, $0 + ld d, 0 ld b, CHECK_FLAG ld hl, sMysteryGiftDecorationsReceived predef SmallFarFlagAction @@ -1025,52 +1147,63 @@ MysteryGift_CopyReceivedDecosToPC: jp CloseSRAM UnlockMysteryGift: +; If [sMysteryGiftUnlocked] was -1, this sets both +; [sMysteryGiftUnlocked] and [sMysteryGiftItem] to 0. call GetMysteryGiftBank ld hl, sMysteryGiftUnlocked ld a, [hl] inc a jr nz, .ok ld [hld], a + assert sMysteryGiftUnlocked - 1 == sMysteryGiftItem ld [hl], a .ok jp CloseSRAM -Function2a4f6: +ResetDailyMysteryGiftLimitIfUnlocked: call GetMysteryGiftBank ld a, [sNumDailyMysteryGiftPartnerIDs] - cp $ff - jr z, .okay + cp -1 ; locked? + jr z, .dont_clear xor a ld [sNumDailyMysteryGiftPartnerIDs], a -.okay +.dont_clear jp CloseSRAM BackupMysteryGift: +; Copies [sMysteryGiftItem] to [sBackupMysteryGiftItem], +; and [sMysteryGiftUnlocked] to [sNumDailyMysteryGiftPartnerIDs]. call GetMysteryGiftBank ld hl, sMysteryGiftItem ld de, sBackupMysteryGiftItem ld a, [hli] ld [de], a inc de + assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked + assert sBackupMysteryGiftItem + 1 == sNumDailyMysteryGiftPartnerIDs ld a, [hl] ld [de], a jp CloseSRAM RestoreMysteryGift: +; Copies [sBackupMysteryGiftItem] to [sMysteryGiftItem], +; and [sNumDailyMysteryGiftPartnerIDs] to [sMysteryGiftUnlocked]. call GetMysteryGiftBank ld hl, sBackupMysteryGiftItem ld de, sMysteryGiftItem ld a, [hli] ld [de], a inc de + assert sBackupMysteryGiftItem + 1 == sNumDailyMysteryGiftPartnerIDs + assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked ld a, [hl] ld [de], a jp CloseSRAM -MysteryGift_ClearTrainerData: - ld hl, wMysteryGiftTrainerData +ClearMysteryGiftTrainer: + ld hl, wMysteryGiftTrainer xor a - ld b, wMysteryGiftTrainerDataEnd - wMysteryGiftTrainerData + ld b, wMysteryGiftTrainerEnd - wMysteryGiftTrainer .loop ld [hli], a dec b @@ -1078,5 +1211,5 @@ MysteryGift_ClearTrainerData: ret GetMysteryGiftBank: - ld a, BANK(sBackupMysteryGiftItem) + ld a, BANK(sMysteryGiftData) jp OpenSRAM diff --git a/engine/link/mystery_gift_2.asm b/engine/link/mystery_gift_2.asm index 9c524182..af3715e0 100644 --- a/engine/link/mystery_gift_2.asm +++ b/engine/link/mystery_gift_2.asm @@ -1,6 +1,6 @@ -PrepMysteryGiftDataToSend: +StageDataForMysteryGift: ld de, wMysteryGiftStaging - ld a, $1 + GS_VERSION + ld a, GS_VERSION + 1 ld [de], a inc de ; wMysteryGiftStaging+1 ld a, BANK(sGameData) @@ -46,10 +46,10 @@ PrepMysteryGiftDataToSend: ld a, [sBackupMysteryGiftItem] ld [de], a inc de - ld a, [sBackupMysteryGiftItem + 1] + ld a, [sNumDailyMysteryGiftPartnerIDs] ld [de], a - ld a, $14 - ld [wc900], a + ld a, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData + ld [wUnusedMysteryGiftStagedDataLength], a call CloseSRAM ld hl, wMysteryGiftStaging ld de, wMysteryGiftPlayerData @@ -121,7 +121,7 @@ PrepMysteryGiftDataToSend: pop de ret -MysteryGiftGetItemHeldEffect: +MysteryGiftGetItem: ld a, c cp MysteryGiftItems.End - MysteryGiftItems jr nc, MysteryGiftFallbackItem diff --git a/engine/link/mystery_gift_3.asm b/engine/link/mystery_gift_3.asm index bc12d9c8..4a8d92c4 100644 --- a/engine/link/mystery_gift_3.asm +++ b/engine/link/mystery_gift_3.asm @@ -45,8 +45,8 @@ StagePartyDataForMysteryGift: .party_end ld a, -1 ld [de], a - ld a, $26 - ld [wc900], a + ld a, wMysteryGiftTrainerEnd - wMysteryGiftTrainer + ld [wUnusedMysteryGiftStagedDataLength], a jp CloseSRAM InitMysteryGiftLayout: diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 2155bdc3..2fe285b1 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -87,12 +87,13 @@ _ResetWRAM: ld [wRoamMon2MapNumber], a ld [wRoamMon3MapNumber], a - ld a, BANK(sMysteryGiftItem) + ld a, BANK(sMysteryGiftItem) ; aka BANK(sMysteryGiftUnlocked) call OpenSRAM ld hl, sMysteryGiftItem xor a ld [hli], a - dec a + assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked + dec a ; -1 ld [hl], a call CloseSRAM @@ -280,7 +281,7 @@ Continue: ld c, 20 call DelayFrames farcall JumpRoamMons - farcall MysteryGift_CopyReceivedDecosToPC + farcall CopyMysteryGiftReceivedDecorationsToPC farcall ClockContinue ld a, [wSpawnAfterChampion] cp SPAWN_LANCE diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm index 20c74336..22308a87 100644 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -132,7 +132,7 @@ MainMenu_GetWhichMenu: ld a, BANK(sNumDailyMysteryGiftPartnerIDs) call OpenSRAM ld a, [sNumDailyMysteryGiftPartnerIDs] - cp -1 + cp -1 ; locked? call CloseSRAM ld a, MAINMENU_CONTINUE ret z diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm index 4860c06c..5b4a96b5 100644 --- a/engine/overworld/time.asm +++ b/engine/overworld/time.asm @@ -227,7 +227,7 @@ DoMysteryGiftIfDayHasPassed: ld hl, wBuffer1 call InitOneDayCountdown call CloseSRAM - farcall Function2a4f6 + farcall ResetDailyMysteryGiftLimitIfUnlocked .not_timed_out ld a, BANK(sMysteryGiftTimer) @@ -85,8 +85,14 @@ NEXTU hPrintNumBuffer:: ds 10 NEXTU -; miscellaneous - ds 9 +; Mystery Gift +hMGExchangedByte:: db +hMGExchangedWord:: dw +hMGNumBits:: db +hMGChecksum:: dw + ds 1 +hMGUnusedMsgLength:: db +hMGRole:: db hMGStatusFlags:: db ENDU @@ -55,19 +55,20 @@ sMailbox8Backup:: mailmsg sMailbox8Backup sMailbox9Backup:: mailmsg sMailbox9Backup sMailbox10Backup:: mailmsg sMailbox10Backup +sMysteryGiftData:: sMysteryGiftItem:: db sMysteryGiftUnlocked:: db sBackupMysteryGiftItem:: 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 ds 4 sMysteryGiftTimer:: dw ds 1 sMysteryGiftTrainerHouseFlag:: db sMysteryGiftPartnerName:: ds NAME_LENGTH - ds 1 -sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 +sMysteryGiftUnusedFlag:: db +sMysteryGiftTrainer:: ds wMysteryGiftTrainerEnd - wMysteryGiftTrainer sBackupMysteryGiftItemEnd:: ds $30 @@ -569,20 +569,15 @@ ENDU NEXTU ; mystery gift data -UNION -wMysteryGiftPartyTemp:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH - -NEXTU wMysteryGiftStaging:: ds 80 -ENDU -wMysteryGiftTrainerData:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 -wMysteryGiftTrainerDataEnd:: +wMysteryGiftTrainer:: ds 1 + (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1 +wMysteryGiftTrainerEnd:: ds 138 wMysteryGiftPartnerData:: -wc800:: db +wMysteryGiftGameVersion:: db wMysteryGiftPartnerID:: dw wMysteryGiftPartnerName:: ds NAME_LENGTH wMysteryGiftPartnerDexCaught:: db @@ -636,9 +631,9 @@ wCreditsBlankFrame2bppEnd:: NEXTU ; mystery gift data -wc900:: db -wc901:: db -wc902:: db +wUnusedMysteryGiftStagedDataLength:: db +wMysteryGiftMessageCount:: db +wMysteryGiftStagedDataLength:: db NEXTU ; link |