Identify mobile Name Card exchange labels

This commit is contained in:
Rangi 2020-10-30 10:45:31 -04:00
parent ba5bc304f9
commit 1237156948
9 changed files with 194 additions and 152 deletions

View File

@ -35,6 +35,12 @@
SCGB_PARTY_MENU_HP_BARS EQU $fc SCGB_PARTY_MENU_HP_BARS EQU $fc
SCGB_DEFAULT EQU $ff SCGB_DEFAULT EQU $ff
; GetCrystalCGBLayout arguments (see engine/gfx/crystal_layouts.asm)
const_def
const CRYSTAL_CGB_MOBILE_0
const CRYSTAL_CGB_MOBILE_1
const CRYSTAL_CGB_NAME_CARD
; PredefPals indexes (see gfx/sgb/predef.pal) ; PredefPals indexes (see gfx/sgb/predef.pal)
; GetPredefPal arguments (see engine/gfx/color.asm) ; GetPredefPal arguments (see engine/gfx/color.asm)
const_def const_def

View File

@ -260,14 +260,14 @@ _MysteryGiftSentHomeText::
text "'s home." text "'s home."
prompt prompt
_MysteryGiftReceivedCardText:: _NameCardReceivedCardText::
text "Received" text "Received"
line "@" line "@"
text_ram wMysteryGiftCardHolderName text_ram wMysteryGiftCardHolderName
text "'s CARD." text "'s CARD."
prompt prompt
_MysteryGiftListedCardText:: _NameCardListedCardText::
text_ram wMysteryGiftCardHolderName text_ram wMysteryGiftCardHolderName
text "'s CARD was" text "'s CARD was"
line "listed as no.@" line "listed as no.@"
@ -275,17 +275,17 @@ _MysteryGiftListedCardText::
text "." text "."
prompt prompt
_MysteryGiftNotRegisteredCardText:: _NameCardNotRegisteredCardText::
text "The CARD was not" text "The CARD was not"
line "registered." line "registered."
prompt prompt
_MysteryGiftLinkCancelledText:: _NameCardLinkCancelledText::
text "The link has been" text "The link has been"
line "cancelled." line "cancelled."
prompt prompt
_MysteryGiftLinkCommErrorText:: _NameCardLinkCommErrorText::
text "Communication" text "Communication"
line "error." line "error."
prompt prompt

View File

@ -17,19 +17,18 @@ LoadSGBLayoutCGB:
ld l, a ld l, a
ld h, 0 ld h, 0
add hl, hl add hl, hl
ld de, .dw ld de, .Jumptable
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld de, .ReturnFromJumpTable ld de, .done
push de push de
jp hl jp hl
.done:
.ReturnFromJumpTable:
ret ret
.dw .Jumptable:
dw _CGB_BattleGrayscale dw _CGB_BattleGrayscale
dw _CGB_BattleColors dw _CGB_BattleColors
dw _CGB_PokegearPals dw _CGB_PokegearPals

View File

@ -1,16 +1,16 @@
GetMysteryGift_MobileAdapterLayout: GetCrystalCGBLayout:
ld a, b ld a, b
cp SCGB_DEFAULT cp SCGB_DEFAULT
jr nz, .not_ram jr nz, .not_default
ld a, [wDefaultSGBLayout] ld a, [wDefaultSGBLayout]
.not_ram .not_default
push af push af
farcall ResetBGPals farcall ResetBGPals
pop af pop af
ld l, a ld l, a
ld h, 0 ld h, 0
add hl, hl add hl, hl
ld de, .dw ld de, .Jumptable
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
@ -18,15 +18,16 @@ GetMysteryGift_MobileAdapterLayout:
ld de, .done ld de, .done
push de push de
jp hl jp hl
.done .done:
ret ret
.dw .Jumptable:
dw MG_Mobile_Layout00 dw _CrystalCGB_MobileLayout0
dw MG_Mobile_Layout01 dw _CrystalCGB_MobileLayout1
dw MG_Mobile_Layout02 dw _CrystalCGB_NameCard
MG_Mobile_Layout_FillBox: Crystal_FillBoxCGB:
; This is a copy of FillBoxCGB.
.row .row
push bc push bc
push hl push hl
@ -42,7 +43,8 @@ MG_Mobile_Layout_FillBox:
jr nz, .row jr nz, .row
ret ret
MG_Mobile_Layout_WipeAttrmap: Crystal_WipeAttrmap:
; This is a copy of WipeAttrmap.
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a xor a
@ -62,9 +64,9 @@ MG_Mobile_Layout_LoadPals:
call FarCopyWRAM call FarCopyWRAM
ret ret
MG_Mobile_Layout00: _CrystalCGB_MobileLayout0:
call MG_Mobile_Layout_LoadPals call MG_Mobile_Layout_LoadPals
call MG_Mobile_Layout_WipeAttrmap call Crystal_WipeAttrmap
call MG_Mobile_Layout_CreatePalBoxes call MG_Mobile_Layout_CreatePalBoxes
farcall ApplyAttrmap farcall ApplyAttrmap
farcall ApplyPals farcall ApplyPals
@ -74,33 +76,33 @@ MG_Mobile_Layout_CreatePalBoxes:
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
lb bc, 4, 1 lb bc, 4, 1
ld a, $1 ld a, $1
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
lb bc, 2, 1 lb bc, 2, 1
ld a, $2 ld a, $2
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
lb bc, 6, 1 lb bc, 6, 1
ld a, $3 ld a, $3
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 1, 0, wAttrmap hlcoord 1, 0, wAttrmap
ld a, $1 ld a, $1
lb bc, 3, 18 lb bc, 3, 18
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
lb bc, 2, 18 lb bc, 2, 18
ld a, $2 ld a, $2
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
lb bc, 12, 18 lb bc, 12, 18
ld a, $3 ld a, $3
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 19, 0, wAttrmap hlcoord 19, 0, wAttrmap
lb bc, 4, 1 lb bc, 4, 1
ld a, $1 ld a, $1
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
lb bc, 2, 1 lb bc, 2, 1
ld a, $2 ld a, $2
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
lb bc, 6, 1 lb bc, 6, 1
ld a, $3 ld a, $3
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 0, 12, wAttrmap hlcoord 0, 12, wAttrmap
ld bc, 6 * SCREEN_WIDTH ld bc, 6 * SCREEN_WIDTH
ld a, $7 ld a, $7
@ -129,14 +131,14 @@ Function49420::
call FarCopyWRAM call FarCopyWRAM
ret ret
MG_Mobile_Layout01: _CrystalCGB_MobileLayout1:
call MG_Mobile_Layout_LoadPals call MG_Mobile_Layout_LoadPals
ld de, wBGPals1 palette PAL_BG_TEXT ld de, wBGPals1 palette PAL_BG_TEXT
ld hl, .TextPalette ld hl, .TextPalette
ld bc, 1 palettes ld bc, 1 palettes
ld a, BANK(wBGPals1) ld a, BANK(wBGPals1)
call FarCopyWRAM call FarCopyWRAM
call MG_Mobile_Layout_WipeAttrmap call Crystal_WipeAttrmap
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a xor a
@ -170,7 +172,7 @@ Function49480:
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
lb bc, 4, SCREEN_WIDTH lb bc, 4, SCREEN_WIDTH
ld a, $7 ld a, $7
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 0, 2, wAttrmap hlcoord 0, 2, wAttrmap
ld a, $4 ld a, $4
ld [hl], a ld [hl], a
@ -182,7 +184,7 @@ Function49496:
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
lb bc, 2, SCREEN_WIDTH lb bc, 2, SCREEN_WIDTH
ld a, $7 ld a, $7
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 0, 1, wAttrmap hlcoord 0, 1, wAttrmap
ld a, $4 ld a, $4
ld [hl], a ld [hl], a
@ -192,14 +194,14 @@ Function49496:
INCLUDE "engine/tilesets/tileset_palettes.asm" INCLUDE "engine/tilesets/tileset_palettes.asm"
MG_Mobile_Layout02: _CrystalCGB_NameCard:
ld hl, .BGPalette ld hl, .BGPalette
ld de, wBGPals1 ld de, wBGPals1
ld bc, 1 palettes ld bc, 1 palettes
ld a, BANK(wBGPals1) ld a, BANK(wBGPals1)
call FarCopyWRAM call FarCopyWRAM
farcall ApplyPals farcall ApplyPals
call MG_Mobile_Layout_WipeAttrmap call Crystal_WipeAttrmap
farcall ApplyAttrmap farcall ApplyAttrmap
ld hl, .OBPalette ld hl, .OBPalette
ld de, wOBPals1 ld de, wOBPals1
@ -236,38 +238,38 @@ _InitMG_Mobile_LinkTradePalMap:
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
lb bc, 16, 2 lb bc, 16, 2
ld a, $4 ld a, $4
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
ld a, $3 ld a, $3
ldcoord_a 0, 1, wAttrmap ldcoord_a 0, 1, wAttrmap
ldcoord_a 0, 14, wAttrmap ldcoord_a 0, 14, wAttrmap
hlcoord 2, 0, wAttrmap hlcoord 2, 0, wAttrmap
lb bc, 8, 18 lb bc, 8, 18
ld a, $5 ld a, $5
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 2, 8, wAttrmap hlcoord 2, 8, wAttrmap
lb bc, 8, 18 lb bc, 8, 18
ld a, $6 ld a, $6
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
hlcoord 0, 16, wAttrmap hlcoord 0, 16, wAttrmap
lb bc, 2, SCREEN_WIDTH lb bc, 2, SCREEN_WIDTH
ld a, $4 ld a, $4
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
ld a, $3 ld a, $3
lb bc, 6, 1 lb bc, 6, 1
hlcoord 6, 1, wAttrmap hlcoord 6, 1, wAttrmap
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
ld a, $3 ld a, $3
lb bc, 6, 1 lb bc, 6, 1
hlcoord 17, 1, wAttrmap hlcoord 17, 1, wAttrmap
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
ld a, $3 ld a, $3
lb bc, 6, 1 lb bc, 6, 1
hlcoord 6, 9, wAttrmap hlcoord 6, 9, wAttrmap
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
ld a, $3 ld a, $3
lb bc, 6, 1 lb bc, 6, 1
hlcoord 17, 9, wAttrmap hlcoord 17, 9, wAttrmap
call MG_Mobile_Layout_FillBox call Crystal_FillBoxCGB
ld a, $2 ld a, $2
hlcoord 2, 16, wAttrmap hlcoord 2, 16, wAttrmap
ld [hli], a ld [hli], a

View File

@ -22,6 +22,8 @@ REGION_CODE EQU $90 ; USA
MESSAGE_PREFIX EQU $5a MESSAGE_PREFIX EQU $5a
NAME_CARD_PREFIX EQU $3c
DoMysteryGift: DoMysteryGift:
call ClearTilemap call ClearTilemap
call ClearSprites call ClearSprites
@ -260,14 +262,14 @@ DoMysteryGift:
ExchangeMysteryGiftData: ExchangeMysteryGiftData:
di di
farcall ClearChannels farcall ClearChannels
call InitializeMysteryGiftInterrupts call InitializeIRCommunicationInterrupts
.restart .restart
call BeginIRCommunication call BeginIRCommunication
call InitializeIRCommunicationRoles call InitializeIRCommunicationRoles
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_CANCELED cp MG_CANCELED
jp z, EndOrContinueIRCommunication jp z, EndOrContinueMysteryGiftIRCommunication
cp MG_OKAY cp MG_OKAY
jr nz, .restart jr nz, .restart
@ -279,8 +281,8 @@ ExchangeMysteryGiftData:
ld b, 1 ld b, 1
call TryReceivingIRDataBlock call TryReceivingIRDataBlock
jr nz, .failed jr nz, .failed
call ReceiveIRDataPayload_GotRegionPrefix call ReceiveMysteryGiftDataPayload_GotRegionPrefix
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
jr ReceiverExchangeMysteryGiftDataPayloads_GotPayload jr ReceiverExchangeMysteryGiftDataPayloads_GotPayload
.failed .failed
@ -328,52 +330,52 @@ ExchangeMysteryGiftData:
jr z, .continue jr z, .continue
ld a, MG_CANCELED ld a, MG_CANCELED
ldh [hMGStatusFlags], a ldh [hMGStatusFlags], a
jp EndOrContinueIRCommunication jp EndOrContinueMysteryGiftIRCommunication
ReceiverExchangeMysteryGiftDataPayloads: ReceiverExchangeMysteryGiftDataPayloads:
; Receive the data payload ; Receive the data payload
call ReceiveIRDataPayload call ReceiveMysteryGiftDataPayload
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; fallthrough ; fallthrough
ReceiverExchangeMysteryGiftDataPayloads_GotPayload: ReceiverExchangeMysteryGiftDataPayloads_GotPayload:
; Switch roles ; Switch roles
call BeginSendingIRCommunication call BeginSendingIRCommunication
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Send the data payload ; Send the data payload
call SendIRDataPayload call SendMysteryGiftDataPayload
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Switch roles ; Switch roles
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Receive an empty block ; Receive an empty block
call ReceiveEmptyIRDataBlock call ReceiveEmptyIRDataBlock
jp EndOrContinueIRCommunication jp EndOrContinueMysteryGiftIRCommunication
SenderExchangeMysteryGiftDataPayloads: SenderExchangeMysteryGiftDataPayloads:
; Send the data payload ; Send the data payload
call SendIRDataPayload call SendMysteryGiftDataPayload
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Switch roles ; Switch roles
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Receive the data payload ; Receive the data payload
call ReceiveIRDataPayload call ReceiveMysteryGiftDataPayload
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Switch roles ; Switch roles
call BeginSendingIRCommunication call BeginSendingIRCommunication
jp nz, EndOrContinueIRCommunication jp nz, EndOrContinueMysteryGiftIRCommunication
; Send an empty block ; Send an empty block
call SendEmptyIRDataBlock call SendEmptyIRDataBlock
jp EndOrContinueIRCommunication jp EndOrContinueMysteryGiftIRCommunication
ReceiveIRDataPayload: ReceiveMysteryGiftDataPayload:
; Receive the region prefix ; Receive the region prefix
ld hl, hMGExchangedByte ld hl, hMGExchangedByte
ld b, 1 ld b, 1
call TryReceivingIRDataBlock call TryReceivingIRDataBlock
ret nz ret nz
; fallthrough ; fallthrough
ReceiveIRDataPayload_GotRegionPrefix: ReceiveMysteryGiftDataPayload_GotRegionPrefix:
; Receive an empty block ; Receive an empty block
call ReceiveEmptyIRDataBlock call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
@ -413,7 +415,7 @@ ReceiveIRDataPayload_GotRegionPrefix:
cp MG_OKAY cp MG_OKAY
ret ret
SendIRDataPayload: SendMysteryGiftDataPayload:
; Send the region prefix ; Send the region prefix
ld a, REGION_PREFIX ld a, REGION_PREFIX
ldh [hMGExchangedByte], a ldh [hMGExchangedByte], a
@ -458,7 +460,7 @@ SendIRDataPayload:
cp MG_OKAY cp MG_OKAY
ret ret
EndOrContinueIRCommunication: EndOrContinueMysteryGiftIRCommunication:
nop nop
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
; Quit if player canceled ; Quit if player canceled
@ -491,12 +493,12 @@ EndOrContinueIRCommunication:
jr z, .sender jr z, .sender
; receiver ; receiver
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
jr nz, EndOrContinueIRCommunication jr nz, EndOrContinueMysteryGiftIRCommunication
jp ReceiverExchangeMysteryGiftDataPayloads jp ReceiverExchangeMysteryGiftDataPayloads
.sender .sender
call BeginSendingIRCommunication call BeginSendingIRCommunication
jr nz, EndOrContinueIRCommunication jr nz, EndOrContinueMysteryGiftIRCommunication
jp SenderExchangeMysteryGiftDataPayloads jp SenderExchangeMysteryGiftDataPayloads
.quit .quit
@ -513,121 +515,149 @@ EndOrContinueIRCommunication:
pop af pop af
ret ret
Function104c2d: ExchangeNameCardData:
di di
farcall ClearChannels farcall ClearChannels
call InitializeMysteryGiftInterrupts call InitializeIRCommunicationInterrupts
.loop2 .restart
call BeginIRCommunication call BeginIRCommunication
call InitializeIRCommunicationRoles call InitializeIRCommunicationRoles
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_CANCELED cp MG_CANCELED
jp z, Function104d1c jp z, EndNameCardIRCommunication
cp MG_OKAY cp MG_OKAY
jr nz, .loop2 jr nz, .restart
ldh a, [hMGRole] ldh a, [hMGRole]
cp IR_SENDER cp IR_SENDER
jr z, .sender jr z, .sender
; receiver ; receiver
call Function104c8a ; Receive the data payload
jp nz, Function104d1c call ReceiveNameCardDataPayload
jp nz, EndNameCardIRCommunication
; Switch roles
call BeginSendingIRCommunication call BeginSendingIRCommunication
jp nz, Function104d1c jp nz, EndNameCardIRCommunication
call Function104cd2 ; Send the data payload
jp nz, Function104d1c call SendNameCardDataPayload
jp nz, EndNameCardIRCommunication
; Switch roles
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
jp nz, Function104d1c jp nz, EndNameCardIRCommunication
; Receive an empty block
call ReceiveEmptyIRDataBlock call ReceiveEmptyIRDataBlock
jp Function104d1c jp EndNameCardIRCommunication
.sender .sender
call Function104cd2 ; Send the data payload
jp nz, Function104d1c call SendNameCardDataPayload
jp nz, EndNameCardIRCommunication
; Switch roles
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
jp nz, Function104d1c jp nz, EndNameCardIRCommunication
call Function104c8a ; Receive the data payload
jp nz, Function104d1c call ReceiveNameCardDataPayload
jp nz, EndNameCardIRCommunication
; Switch roles
call BeginSendingIRCommunication call BeginSendingIRCommunication
jp nz, Function104d1c jp nz, EndNameCardIRCommunication
; Send an empty block
call SendEmptyIRDataBlock call SendEmptyIRDataBlock
jp Function104d1c jp EndNameCardIRCommunication
Function104c8a: ReceiveNameCardDataPayload:
; Receive the Name Card prefix
ld hl, hMGExchangedByte ld hl, hMGExchangedByte
ld b, 1 ld b, 1
call TryReceivingIRDataBlock call TryReceivingIRDataBlock
ret nz ret nz
; Receive an empty block
call ReceiveEmptyIRDataBlock call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_OKAY cp MG_OKAY
ret nz ret nz
; Verify the received Name Card prefix
ldh a, [hMGExchangedByte] ldh a, [hMGExchangedByte]
cp $3c cp NAME_CARD_PREFIX
jp nz, WrongMysteryGiftRegion jp nz, WrongMysteryGiftRegion
swap a swap a
ldh [hMGExchangedByte], a ldh [hMGExchangedByte], a
; Switch roles
call BeginSendingIRCommunication call BeginSendingIRCommunication
ret nz ret nz
; Send the swapped Name Card prefix
ld hl, hMGExchangedByte ld hl, hMGExchangedByte
ld b, 1 ld b, 1
call TrySendingIRDataBlock call TrySendingIRDataBlock
ret nz ret nz
; Send an empty block
call SendEmptyIRDataBlock call SendEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_OKAY cp MG_OKAY
ret nz ret nz
; Switch roles
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
ret nz ret nz
ld hl, wMysteryGiftTrainer ; Receive the staged data
ld hl, wNameCardData
ld a, [wMysteryGiftStagedDataLength] ld a, [wMysteryGiftStagedDataLength]
ld b, a ld b, a
call TryReceivingIRDataBlock call TryReceivingIRDataBlock
ret nz ret nz
; Receive an empty block
call ReceiveEmptyIRDataBlock call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_OKAY cp MG_OKAY
ret ret
Function104cd2: SendNameCardDataPayload:
ld a, $3c ; Send the Name Card prefix
ld a, NAME_CARD_PREFIX
ldh [hMGExchangedByte], a ldh [hMGExchangedByte], a
ld hl, hMGExchangedByte ld hl, hMGExchangedByte
ld b, 1 ld b, 1
call TrySendingIRDataBlock call TrySendingIRDataBlock
ret nz ret nz
; Send an empty block
call SendEmptyIRDataBlock call SendEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_OKAY cp MG_OKAY
ret nz ret nz
; Switch roles
call BeginReceivingIRCommunication call BeginReceivingIRCommunication
ret nz ret nz
; Receive the swapped Name Card prefix
ld hl, hMGExchangedByte ld hl, hMGExchangedByte
ld b, 1 ld b, 1
call TryReceivingIRDataBlock call TryReceivingIRDataBlock
ret nz ret nz
; Receive an empty block
call ReceiveEmptyIRDataBlock call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_OKAY cp MG_OKAY
ret nz ret nz
; Verify the received swapped Name Card prefix
ldh a, [hMGExchangedByte] ldh a, [hMGExchangedByte]
swap a swap a
cp $3c cp NAME_CARD_PREFIX
jp nz, WrongMysteryGiftRegion jp nz, WrongMysteryGiftRegion
; Switch roles
call BeginSendingIRCommunication call BeginSendingIRCommunication
ret nz ret nz
; Send the staged data
ld hl, wMysteryGiftStaging ld hl, wMysteryGiftStaging
ld a, [wMysteryGiftStagedDataLength] ld a, [wMysteryGiftStagedDataLength]
ld b, a ld b, a
call TrySendingIRDataBlock call TrySendingIRDataBlock
ret nz ret nz
; Send an empty block
call SendEmptyIRDataBlock call SendEmptyIRDataBlock
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
cp MG_OKAY cp MG_OKAY
ret ret
Function104d1c: EndNameCardIRCommunication:
nop nop
ldh a, [hMGStatusFlags] ldh a, [hMGStatusFlags]
push af push af
@ -674,7 +704,7 @@ TryReceivingIRDataBlock:
cp MG_OKAY cp MG_OKAY
ret ret
InitializeMysteryGiftInterrupts: InitializeIRCommunicationInterrupts:
call StartFastIRTimer call StartFastIRTimer
ld a, 1 << TIMER ld a, 1 << TIMER
ldh [rIE], a ldh [rIE], a
@ -1175,6 +1205,7 @@ ReceiveIRDataMessage:
ld d, 0 ld d, 0
call ReceiveInfraredLEDOn call ReceiveInfraredLEDOn
jp z, InfraredLEDReceiveTimedOut jp z, InfraredLEDReceiveTimedOut
ld d, 16 ld d, 16
call SendInfraredLEDOff call SendInfraredLEDOff
ret ret
@ -1536,22 +1567,22 @@ InitMysteryGiftLayout:
MysteryGiftGFX: MysteryGiftGFX:
INCBIN "gfx/mystery_gift/mystery_gift.2bpp" INCBIN "gfx/mystery_gift/mystery_gift.2bpp"
Function105688: DoNameCardSwap:
call ClearTilemap call ClearTilemap
call ClearSprites call ClearSprites
call WaitBGMap call WaitBGMap
call Function1057d7 call InitNameCardLayout
hlcoord 3, 8 hlcoord 3, 8
ld de, String_PressAToLink_BToCancel_JP ld de, .String_PressAToLink_BToCancel_JP
call PlaceString call PlaceString
call WaitBGMap call WaitBGMap
call Function10578c call StageDataForNameCard
call ClearMysteryGiftTrainer call ClearMysteryGiftTrainer
ld a, $24 ld a, wNameCardDataEnd - wNameCardData
ld [wMysteryGiftStagedDataLength], a ld [wMysteryGiftStagedDataLength], a
ldh a, [rIE] ldh a, [rIE]
push af push af
call Function104c2d call ExchangeNameCardData
ld d, a ld d, a
xor a xor a
ldh [rIF], a ldh [rIF], a
@ -1559,25 +1590,25 @@ Function105688:
ldh [rIE], a ldh [rIE], a
ld a, d ld a, d
cp $10 cp $10
jp z, Function105712 jp z, .LinkCanceled
cp %01101100 cp MG_OKAY
jp nz, Function10571a jp nz, .CommunicationError
call Function1056eb call .SlideNameCardUpOffScreen
ld c, 60 ld c, 60
call DelayFrames call DelayFrames
call Function105777 call .ClearScreen
ld hl, MysteryGiftReceivedCardText ld hl, .NameCardReceivedCardText
call PrintText call PrintText
ld de, wMysteryGiftTrainer ld de, wNameCardData
farcall Function8ac70 farcall Function8ac70
ld a, c ld a, c
ld [wDeciramBuffer], a ld [wDeciramBuffer], a
ld hl, MysteryGiftNotRegisteredCardText ld hl, .NameCardNotRegisteredCardText
jr c, PrintTextAndExit_JP jr c, .PrintTextAndExit
ld hl, MysteryGiftListedCardText ld hl, .NameCardListedCardText
jr PrintTextAndExit_JP jr .PrintTextAndExit
Function1056eb: .SlideNameCardUpOffScreen:
ld c, 16 ld c, 16
.loop .loop
ld hl, wVirtualOAMSprite00YCoord ld hl, wVirtualOAMSprite00YCoord
@ -1606,51 +1637,51 @@ endr
pop bc pop bc
jr .loop jr .loop
Function105712: .LinkCanceled:
call Function105777 call .ClearScreen
ld hl, MysteryGiftLinkCancelledText ld hl, .NameCardLinkCancelledText
jr PrintTextAndExit_JP jr .PrintTextAndExit
Function10571a: .CommunicationError:
call Function105777 call .ClearScreen
ld hl, MysteryGiftLinkCommErrorText ld hl, .NameCardCommErrorText
call PrintText call PrintText
jp Function105688 jp DoNameCardSwap
PrintTextAndExit_JP: .PrintTextAndExit:
call PrintText call PrintText
ld a, LCDC_DEFAULT ld a, LCDC_DEFAULT
ldh [rLCDC], a ldh [rLCDC], a
ret ret
String_PressAToLink_BToCancel_JP: .String_PressAToLink_BToCancel_JP:
db "エーボタン<WO>おすと" db "エーボタン<WO>おすと"
next "つうしん<PKMN>おこなわれるよ!" next "つうしん<PKMN>おこなわれるよ!"
next "ビーボタン<WO>おすと" next "ビーボタン<WO>おすと"
next "つうしん<WO>ちゅうし します" next "つうしん<WO>ちゅうし します"
db "@" db "@"
MysteryGiftReceivedCardText: .NameCardReceivedCardText:
text_far _MysteryGiftReceivedCardText text_far _NameCardReceivedCardText
text_end text_end
MysteryGiftListedCardText: .NameCardListedCardText:
text_far _MysteryGiftListedCardText text_far _NameCardListedCardText
text_end text_end
MysteryGiftNotRegisteredCardText: .NameCardNotRegisteredCardText:
text_far _MysteryGiftNotRegisteredCardText text_far _NameCardNotRegisteredCardText
text_end text_end
MysteryGiftLinkCancelledText: .NameCardLinkCancelledText:
text_far _MysteryGiftLinkCancelledText text_far _NameCardLinkCancelledText
text_end text_end
MysteryGiftLinkCommErrorText: .NameCardCommErrorText:
text_far _MysteryGiftLinkCommErrorText text_far _NameCardLinkCommErrorText
text_end text_end
Function105777: .ClearScreen:
call ClearSprites call ClearSprites
call ClearTilemap call ClearTilemap
call EnableLCD call EnableLCD
@ -1660,8 +1691,8 @@ Function105777:
call SetPalettes call SetPalettes
ret ret
Function10578c: StageDataForNameCard:
ld de, wLinkData ld de, wMysteryGiftStaging
ld a, BANK(sPlayerData) ld a, BANK(sPlayerData)
call OpenSRAM call OpenSRAM
ld hl, sPlayerData + wPlayerName - wPlayerData ld hl, sPlayerData + wPlayerName - wPlayerData
@ -1682,15 +1713,15 @@ Function10578c:
ld a, BANK(s4_a603) ; aka BANK(s4_a007) ; MBC30 bank used by JP Crystal; inaccessible by MBC3 ld a, BANK(s4_a603) ; aka BANK(s4_a007) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call OpenSRAM call OpenSRAM
ld hl, s4_a603 ; address of MBC30 bank ld hl, s4_a603 ; address of MBC30 bank
ld bc, $8 ld bc, 8
call CopyBytes call CopyBytes
ld hl, s4_a007 ; address of MBC30 bank ld hl, s4_a007 ; address of MBC30 bank
ld bc, $c ld bc, 12
call CopyBytes call CopyBytes
call CloseSRAM call CloseSRAM
ret ret
Function1057d7: InitNameCardLayout:
call ClearBGPalettes call ClearBGPalettes
call DisableLCD call DisableLCD
ld hl, CardTradeGFX ld hl, CardTradeGFX
@ -1775,13 +1806,13 @@ Function1057d7:
hlcoord 17, 15 hlcoord 17, 15
ld [hl], $3e ld [hl], $3e
ld de, wVirtualOAMSprite00 ld de, wVirtualOAMSprite00
ld hl, .OAM_data ld hl, .NameCardOAMData
ld bc, 16 * SPRITEOAMSTRUCT_LENGTH ld bc, 16 * SPRITEOAMSTRUCT_LENGTH
call CopyBytes call CopyBytes
call EnableLCD call EnableLCD
call WaitBGMap call WaitBGMap
ld b, $2 ld b, CRYSTAL_CGB_NAME_CARD
farcall GetMysteryGift_MobileAdapterLayout farcall GetCrystalCGBLayout
jp SetPalettes jp SetPalettes
.Load6Row: .Load6Row:
@ -1829,7 +1860,7 @@ Function1057d7:
jr nz, .row_loop_no_inc jr nz, .row_loop_no_inc
ret ret
.OAM_data: .NameCardOAMData:
dbsprite 6, 2, 4, 1, $00, 0 dbsprite 6, 2, 4, 1, $00, 0
dbsprite 7, 2, 4, 1, $01, 0 dbsprite 7, 2, 4, 1, $01, 0
dbsprite 8, 2, 4, 1, $02, 0 dbsprite 8, 2, 4, 1, $02, 0

View File

@ -45,8 +45,8 @@ InitMobileProfile:
ld [wMusicFadeID + 1], a ld [wMusicFadeID + 1], a
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
ld b, $1 ld b, CRYSTAL_CGB_MOBILE_1
call GetMysteryGift_MobileAdapterLayout call GetCrystalCGBLayout
call ClearBGPalettes call ClearBGPalettes
hlcoord 0, 0 hlcoord 0, 0
ld b, 2 ld b, 2
@ -652,8 +652,8 @@ Wakayama: db "わかやまけん@" ; Wakayama
Function48689: Function48689:
ld c, 7 ld c, 7
call DelayFrames call DelayFrames
ld b, $1 ld b, CRYSTAL_CGB_MOBILE_1
call GetMysteryGift_MobileAdapterLayout call GetCrystalCGBLayout
call ClearBGPalettes call ClearBGPalettes
hlcoord 0, 0 hlcoord 0, 0
ld b, 4 ld b, 4

View File

@ -3964,7 +3964,7 @@ Function8ab3b:
Function8ab93: Function8ab93:
call ClearBGPalettes call ClearBGPalettes
call LoadStandardMenuHeader call LoadStandardMenuHeader
farcall Function105688 farcall DoNameCardSwap
call ClearSprites call ClearSprites
call Function891fe call Function891fe
call Function89b28 call Function89b28

View File

@ -603,7 +603,7 @@ Function4a485:
ret ret
Function4a492: Function4a492:
call MG_Mobile_Layout00 call _CrystalCGB_MobileLayout0
ret ret
MainMenu_MobileStudium: MainMenu_MobileStudium:

View File

@ -1006,6 +1006,10 @@ UNION
wMysteryGiftTrainer:: ds 1 + (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1 wMysteryGiftTrainer:: ds 1 + (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1
wMysteryGiftTrainerEnd:: wMysteryGiftTrainerEnd::
NEXTU
wNameCardData:: ds NAME_LENGTH + 2 + 2 + 1 + 8 + 12
wNameCardDataEnd::
NEXTU NEXTU
wMysteryGiftCardHolderName:: ds PLAYER_NAME_LENGTH wMysteryGiftCardHolderName:: ds PLAYER_NAME_LENGTH
ENDU ENDU