diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 7a0f40a..3085ba7 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -2793,8 +2793,8 @@ HandleCardPopCommunications: .loop_request call TryReceiveIRRequest ; receive request jr nc, .execute_commands - bit 1, a - jp nz, .asm_19e7f + bit B_PAD_B, a + jp nz, .cancelled call TrySendIRRequest ; send request jr c, .loop_request @@ -2833,7 +2833,7 @@ HandleCardPopCommunications: jr nz, .fail ld a, STRBYTE("{IR_MAGIC_STRING_TCG2}", 2) - ld [wOtherIRCommunicationParams + 3], a + ld [wOtherIRCommunicationMagicString + 2], a call DecideCardToReceiveFromCardPop call SetCardPopRecord call FillCardPopSummary @@ -2862,12 +2862,12 @@ HandleCardPopCommunications: .fail ld a, [wIRCommunicationErrorCode] cp $01 - jr nz, .asm_19e7f + jr nz, .cancelled ldtx hl, CardPopModeMismatchedText ; Card Pop from one side and Rare Card Pop from the other scf ret -.asm_19e7f +.cancelled ldtx hl, CardPopUnsuccessfulTryAgainText .set_carry scf @@ -2898,9 +2898,9 @@ HandleCardPopCommunications: ld a, BANK("SRAM1") call BankswitchSRAM call CopyDataHLtoDE - ld a, [wOtherIRCommunicationParams + 3] + ld a, [wOtherIRCommunicationMagicString + 2] cp STRBYTE("{IR_MAGIC_STRING_TCG2}", 2) - jr nz, .asm_19ecb + jr nz, .done ; copy SRAM so that sCardPopRecords is moved $20 forward ld hl, sCardPopRecords + MAX_NUM_CARDPOP_RECORDS * CARDPOP_RECORD_SIZE - 1 @@ -2918,11 +2918,11 @@ HandleCardPopCommunications: ld de, sCardPopRecords ld bc, CARDPOP_RECORD_SIZE call CopyDataHLtoDE -.asm_19ecb +.done xor a call BankswitchSRAM call DisableSRAM - or a + or a ; redundant, leftover from tcg1 ret ; looks up the name in wNameBuffer in wCardPopNameList @@ -3814,7 +3814,7 @@ ENDR ; pressed A call RestoreVBlankFunction ld a, STRBYTE("{IR_MAGIC_STRING_TCG2}", 2) - ld [wOtherIRCommunicationParams + 3], a + ld [wOtherIRCommunicationMagicString + 2], a call HandleCardPopCommunications.success call LoadCardPopSceneAndHandleCommunications.add_sram0 ldtx hl, ReceivedThroughCardPopText diff --git a/src/engine/link/ir_core.asm b/src/engine/link/ir_core.asm index 781c69e..f242df4 100644 --- a/src/engine/link/ir_core.asm +++ b/src/engine/link/ir_core.asm @@ -384,7 +384,7 @@ TrySendIRRequest: pop af ret -; returns carry set if request was not received +; returns carry set and the pressed button (A or B) in a if request was not received TryReceiveIRRequest: call StartIRCommunications ld hl, rRP @@ -394,8 +394,9 @@ TryReceiveIRRequest: jr z, .send_ack ldh a, [rJOYP] cpl - and JOYP_A | JOYP_B + and PAD_A | PAD_B jr z, .wait_request +; not received scf jr .close diff --git a/src/engine/link/ir_functions.asm b/src/engine/link/ir_functions.asm index 0a98278..0fa5c27 100644 --- a/src/engine/link/ir_functions.asm +++ b/src/engine/link/ir_functions.asm @@ -37,7 +37,7 @@ ClearRPAndRestoreVBlankFunction: ; prepares IR communication parameter data ; a = a IRPARAM_* constant for the function of this connection InitIRCommunications: - ld hl, wOwnIRCommunicationParams + ld hl, wOwnIRCommunicationMode ld [hl], a FOR n, IR_MAGIC_STRING_SIZE inc hl @@ -101,7 +101,7 @@ PrepareSendCardOrDeckConfigurationThroughIR: .request_success call ExchangeIRCommunicationParameters ret c - ld a, [wOtherIRCommunicationParams + 3] + ld a, [wOtherIRCommunicationMagicString + 2] cp STRBYTE("{IR_MAGIC_STRING_TCG2}", 2) jr nz, SetIRCommunicationErrorCode_Error or a @@ -116,16 +116,16 @@ ExchangeIRCommunicationParameters: ld c, IR_PARAMS_STRUCT_SIZE call RequestDataTransmissionThroughIR jr c, .error - ld hl, wOtherIRCommunicationParams + 1 + ld hl, wOtherIRCommunicationMagicString ld a, [hli] cp STRBYTE("{IR_MAGIC_STRING_TCG2}", 0) jr nz, .error ld a, [hli] cp STRBYTE("{IR_MAGIC_STRING_TCG2}", 1) jr nz, .error - ld a, [wOwnIRCommunicationParams] - ld hl, wOtherIRCommunicationParams - cp [hl] ; do parameters match? + ld a, [wOwnIRCommunicationMode] + ld hl, wOtherIRCommunicationMode + cp [hl] ; does the mode parameter match? jr nz, SetIRCommunicationErrorCode_Error ; receives wDefaultText from other device @@ -162,7 +162,7 @@ SetIRCommunicationErrorCode_Error: ret SetIRCommunicationErrorCode_NoError: - ld hl, wOwnIRCommunicationParams + ld hl, wOwnIRCommunicationMode ld [hl], NONE ld de, wIRCommunicationErrorCode ld c, 1 @@ -219,7 +219,7 @@ _SendCard: jr c, .fail call ExecuteReceivedIRCommands jr c, .fail - ld a, [wOwnIRCommunicationParams + 1] + ld a, [wOwnIRCommunicationMagicString] cp STRBYTE("{IR_ACK_MAGIC_STRING_TCG2}", 0) jr nz, .fail call PlayCardPopSong @@ -247,7 +247,7 @@ _ReceiveCard: call TryReceiveCardOrDeckConfigurationThroughIR jr c, .fail ld a, STRBYTE("{IR_ACK_MAGIC_STRING_TCG2}", 0) - ld [wOwnIRCommunicationParams + 1], a + ld [wOwnIRCommunicationMagicString], a ld hl, wOwnIRCommunicationParams ld e, l ld d, h diff --git a/src/wram.asm b/src/wram.asm index 7e3ddfb..e9523ec 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -94,10 +94,16 @@ wIRCommunicationErrorCode:: ; c5ea ; and received from the other device respectively ; these must match for successful communication wOwnIRCommunicationParams:: ; c5eb - ds IR_PARAMS_STRUCT_SIZE -wOtherIRCommunicationParams:: ; c5ef - ds IR_PARAMS_STRUCT_SIZE +wOwnIRCommunicationMode:: ; c5eb + ds $1 +wOwnIRCommunicationMagicString:: ; c5ec + ds IR_MAGIC_STRING_SIZE +wOtherIRCommunicationParams:: ; c5ef +wOtherIRCommunicationMode:: ; c5ef + ds $1 +wOtherIRCommunicationMagicString:: ; c5f0 + ds IR_MAGIC_STRING_SIZE ; stores the result from LookUpNameInCardPopNameList ; is $ff if name was found in the Card Pop! list