diff options
author | Remy Oukaour <remy.oukaour@gmail.com> | 2018-01-19 14:49:43 -0500 |
---|---|---|
committer | Remy Oukaour <remy.oukaour@gmail.com> | 2018-01-19 14:49:43 -0500 |
commit | 0c6338836d714f464bfcaa0c8c5b8c76e6f4958d (patch) | |
tree | 99c26ca80f95266c633427e30ba7e856ec500c92 /engine | |
parent | 52993d20efd5315c9d3e2e684a84456783717fc8 (diff) |
Resolve #471 (although link code still needs more cleanup, like its WRAM labels)
Diffstat (limited to 'engine')
-rw-r--r-- | engine/battle/core.asm | 42 | ||||
-rwxr-xr-x | engine/link.asm | 286 | ||||
-rw-r--r-- | engine/link_2.asm | 2 | ||||
-rwxr-xr-x | engine/link_trade.asm | 2 |
4 files changed, 168 insertions, 164 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 189ebf195..9ec9cc63e 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -26,7 +26,7 @@ DoBattle: ; 3c000 and a jr z, .not_linked - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $2 jr z, .player_2 @@ -97,7 +97,7 @@ DoBattle: ; 3c000 ld a, [wLinkMode] and a jr z, .not_linked_2 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $2 jr nz, .not_linked_2 xor a @@ -251,7 +251,7 @@ Stubbed_Function3c1bf: ; 3c1d6 HandleBetweenTurnEffects: ; 3c1d6 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .CheckEnemyFirst call CheckFaint_PlayerThenEnemy @@ -350,7 +350,7 @@ CheckFaint_EnemyThenPlayer: ; 3c25c ; 3c27c HandleBerserkGene: ; 3c27c - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .reverse @@ -458,7 +458,7 @@ DetermineMoveOrder: ; 3c314 ld a, [wPlayerAction] cp $2 jr nz, .switch - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $2 jr z, .player_2 @@ -515,7 +515,7 @@ DetermineMoveOrder: ; 3c314 jp .enemy_first .both_have_quick_claw - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $2 jr z, .player_2b call BattleRandom @@ -545,7 +545,7 @@ DetermineMoveOrder: ; 3c314 jp .enemy_first .speed_tie - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $2 jr z, .player_2c call BattleRandom @@ -709,7 +709,7 @@ ParsePlayerAction: ; 3c434 ; 3c4df HandleEncore: ; 3c4df - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .player_1 call .do_player @@ -1161,7 +1161,7 @@ ResidualDamage: ; 3c716 ; 3c801 HandlePerishSong: ; 3c801 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .EnemyFirst call SetPlayerTurn @@ -1230,7 +1230,7 @@ HandlePerishSong: ; 3c801 ; 3c874 HandleWrap: ; 3c874 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .EnemyFirst call SetPlayerTurn @@ -1302,7 +1302,7 @@ SwitchTurnCore: ; 3c8e4 ; 3c8eb HandleLeftovers: ; 3c8eb - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .DoEnemyFirst call SetPlayerTurn @@ -1352,7 +1352,7 @@ HandleLeftovers: ; 3c8eb ; 3c93c HandleMysteryberry: ; 3c93c - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .DoEnemyFirst call SetPlayerTurn @@ -1491,7 +1491,7 @@ HandleMysteryberry: ; 3c93c ; 3ca26 HandleFutureSight: ; 3ca26 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .enemy_first call SetPlayerTurn @@ -1550,7 +1550,7 @@ HandleFutureSight: ; 3ca26 ; 3ca8f HanleDefrost: ; 3ca8f - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .enemy_first call .do_player_turn @@ -1610,7 +1610,7 @@ HanleDefrost: ; 3ca8f ; 3cafb HandleSafeguard: ; 3cafb - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .player1 call .CheckPlayer @@ -1647,7 +1647,7 @@ HandleSafeguard: ; 3cafb jp StdBattleTextBox HandleScreens: ; 3cb36 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp 1 jr z, .Both call .CheckPlayer @@ -1731,7 +1731,7 @@ HandleWeather: ; 3cb9e cp WEATHER_SANDSTORM ret nz - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp 1 jr z, .enemy_first @@ -2115,7 +2115,7 @@ HandleEnemyMonFaint: ; 3cd55 ; 3cdca DoubleSwitch: ; 3cdca - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .player_1 call ClearSprites @@ -4350,7 +4350,7 @@ RecallPlayerMon: ; 3dce6 ; 3dcf9 HandleHealingItems: ; 3dcf9 - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .player_1 call SetPlayerTurn @@ -4595,7 +4595,7 @@ UseConfusionHealingItem: ; 3de51 HandleStatBoostingHeldItems: ; 3de97 ; The effects handled here are not used in-game. - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .player_1 call .DoPlayer @@ -5374,7 +5374,7 @@ PlayerSwitch: ; 3e3ad ret .dont_run - ld a, [hLinkPlayerNumber] + ld a, [hSerialConnectionStatus] cp $1 jr z, .player_1 call BattleMonEntrance diff --git a/engine/link.asm b/engine/link.asm index daa986c67..0de4eab2d 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -28,9 +28,9 @@ LinkCommunications: ; 28000 call SetTradeRoomBGPals call WaitBGMap2 ld hl, wcf5d - xor a + xor a ; LOW($5000) ld [hli], a - ld [hl], $50 + ld [hl], HIGH($5000) ld a, [wLinkMode] cp LINK_TIMECAPSULE jp nz, Gen2ToGen2LinkComms @@ -42,29 +42,31 @@ TimeCapsule: ; 2805d xor a ld [wPlayerLinkAction], a call WaitLinkTransfer - ld a, [hLinkPlayerNumber] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK jr nz, .player_1 + ld c, 3 call DelayFrames xor a ld [hSerialSend], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a + call DelayFrame xor a ld [hSerialSend], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a .player_1 ld de, MUSIC_NONE call PlayMusic - ld c, $3 + ld c, 3 call DelayFrames xor a ld [rIF], a @@ -73,19 +75,19 @@ TimeCapsule: ; 2805d ld hl, wd1f3 ld de, EnemyMonSpecies ld bc, $11 - call Function75f - ld a, $fe + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE ld [de], a ld hl, wLinkData ld de, OTPlayerName ld bc, $1a8 - call Function75f - ld a, $fe + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE ld [de], a ld hl, wMisc ld de, wPlayerTrademonSpecies ld bc, wPlayerTrademonSpecies - wMisc - call Function75f + call Serial_ExchangeBytes xor a ld [rIF], a ld a, $1d @@ -107,25 +109,25 @@ TimeCapsule: ; 2805d call Link_CopyOTData ld de, wPlayerTrademonSpecies ld hl, wTimeCapsulePartyMon1Species - ld c, $2 + ld c, 2 .loop ld a, [de] inc de and a jr z, .loop - cp $fd + cp SERIAL_PREAMBLE_BYTE jr z, .loop - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop - cp $ff + cp SERIAL_PATCH_LIST_PART_TERMINATOR jr z, .next push hl push bc - ld b, $0 + ld b, 0 dec a ld c, a add hl, bc - ld a, $fe + ld a, SERIAL_NO_DATA_BYTE ld [hl], a pop bc pop hl @@ -168,8 +170,8 @@ TimeCapsule: ; 2805d ld [wUnusedD102 + 1], a ld de, MUSIC_NONE call PlayMusic - ld a, [hLinkPlayerNumber] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK ld c, 66 call z, DelayFrames ld de, MUSIC_ROUTE_30 @@ -185,23 +187,25 @@ Gen2ToGen2LinkComms: ; 28177 ld a, [ScriptVar] and a jp z, LinkTimeout - ld a, [hLinkPlayerNumber] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK jr nz, .Player1 + ld c, 3 call DelayFrames xor a ld [hSerialSend], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a + call DelayFrame xor a ld [hSerialSend], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a .Player1: @@ -216,26 +220,26 @@ Gen2ToGen2LinkComms: ; 28177 ld hl, wd1f3 ld de, EnemyMonSpecies ld bc, $11 - call Function75f - ld a, $fe + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE ld [de], a ld hl, wLinkData ld de, OTPlayerName ld bc, $1c2 - call Function75f - ld a, $fe + call Serial_ExchangeBytes + ld a, SERIAL_NO_DATA_BYTE ld [de], a ld hl, wMisc ld de, wPlayerTrademonSpecies ld bc, $c8 - call Function75f + call Serial_ExchangeBytes ld a, [wLinkMode] cp LINK_TRADECENTER jr nz, .not_trading ld hl, wc9f4 ld de, wcb84 ld bc, $186 - call Function283f2 + call ExchangeBytes .not_trading xor a @@ -252,25 +256,25 @@ Gen2ToGen2LinkComms: ; 28177 call Link_CopyOTData ld de, wPlayerTrademonSpecies ld hl, wLinkPlayerPartyMon1Species - ld c, $2 + ld c, 2 .loop1 ld a, [de] inc de and a jr z, .loop1 - cp $fd + cp SERIAL_PREAMBLE_BYTE jr z, .loop1 - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop1 - cp $ff + cp SERIAL_PATCH_LIST_PART_TERMINATOR jr z, .next1 push hl push bc - ld b, $0 + ld b, 0 dec a ld c, a add hl, bc - ld a, $fe + ld a, SERIAL_NO_DATA_BYTE ld [hl], a pop bc pop hl @@ -286,13 +290,13 @@ Gen2ToGen2LinkComms: ; 28177 ld hl, wcb84 .loop2 ld a, [hli] - cp $20 + cp MAIL_MSG_LENGTH jr nz, .loop2 .loop3 ld a, [hli] - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop3 - cp $20 + cp MAIL_MSG_LENGTH jr z, .loop3 dec hl ld de, wcb84 @@ -302,9 +306,9 @@ Gen2ToGen2LinkComms: ; 28177 ld bc, $c6 ; 198 .loop4 ld a, [hl] - cp $21 + cp MAIL_MSG_LENGTH + 1 jr nz, .okay1 - ld [hl], $fe + ld [hl], SERIAL_NO_DATA_BYTE .okay1 inc hl dec bc @@ -315,14 +319,14 @@ Gen2ToGen2LinkComms: ; 28177 .loop5 ld a, [de] inc de - cp $ff + cp SERIAL_PATCH_LIST_PART_TERMINATOR jr z, .start_copying_mail ld hl, wcc4a dec a ld b, $0 ld c, a add hl, bc - ld [hl], $fe + ld [hl], SERIAL_NO_DATA_BYTE jr .loop5 .start_copying_mail @@ -395,7 +399,7 @@ Gen2ToGen2LinkComms: ; 28177 ld bc, NAME_LENGTH call CopyBytes ld de, OTPartyCount - ld bc, 8 + ld bc, 1 + PARTY_LENGTH + 1 call CopyBytes ld de, OTPlayerID ld bc, 2 @@ -409,8 +413,8 @@ Gen2ToGen2LinkComms: ; 28177 ld [wUnusedD102 + 1], a ld de, MUSIC_NONE call PlayMusic - ld a, [hLinkPlayerNumber] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK ld c, 66 call z, DelayFrames ld a, [wLinkMode] @@ -423,8 +427,8 @@ Gen2ToGen2LinkComms: ; 28177 ld hl, Options ld a, [hl] push af - and $20 - or $3 + and 1 << STEREO + or TEXT_DELAY_MED ld [hl], a ld hl, OTPlayerName ld de, OTClassName @@ -510,28 +514,28 @@ LinkTimeout: ; 283b2 db "@" ; 0x283f2 -Function283f2: ; 283f2 - ld a, $1 - ld [hFFCC], a +ExchangeBytes: ; 283f2 + ld a, TRUE + ld [hSerialIgnoringInitialData], a .loop ld a, [hl] ld [hSerialSend], a - call Function78a + call Serial_ExchangeByte push bc ld b, a inc hl - ld a, $30 + ld a, 48 .delay_cycles dec a jr nz, .delay_cycles - ld a, [hFFCC] + ld a, [hSerialIgnoringInitialData] and a ld a, b pop bc jr z, .load dec hl xor a - ld [hFFCC], a + ld [hSerialIgnoringInitialData], a jr .loop .load @@ -563,7 +567,7 @@ ClearLinkData: ; 28426 FixDataForLinkTransfer: ; 28434 ld hl, wd1f3 - ld a, $fd + ld a, SERIAL_PREAMBLE_BYTE ld b, LinkBattleRNs - wd1f3 .loop1 ld [hli], a @@ -572,13 +576,13 @@ FixDataForLinkTransfer: ; 28434 ld b, TempEnemyMonSpecies - LinkBattleRNs .loop2 call Random - cp $fd + cp SERIAL_PREAMBLE_BYTE jr nc, .loop2 ld [hli], a dec b jr nz, .loop2 ld hl, wMisc - ld a, $fd + ld a, SERIAL_PREAMBLE_BYTE ld [hli], a ld [hli], a ld [hli], a @@ -594,7 +598,7 @@ FixDataForLinkTransfer: ; 28434 .loop4 inc c ld a, c - cp $fd + cp SERIAL_PREAMBLE_BYTE jr z, .next1 ld a, b dec a @@ -613,31 +617,31 @@ FixDataForLinkTransfer: ; 28434 .next2 inc hl ld a, [hl] - cp $fe + cp SERIAL_NO_DATA_BYTE jr nz, .loop4 ld a, c ld [de], a inc de - ld [hl], $ff + ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR jr .loop4 .next1 - ld a, $ff + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR ld [de], a inc de lb bc, 1, 0 jr .loop4 .done - ld a, $ff + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR ld [de], a ret ; 28499 Link_PrepPartyData_Gen1: ; 28499 ld de, wLinkData - ld a, $fd - ld b, 6 + ld a, SERIAL_PREAMBLE_BYTE + ld b, PARTY_LENGTH .loop1 ld [de], a inc de @@ -804,8 +808,8 @@ Link_PrepPartyData_Gen1: ; 28499 Link_PrepPartyData_Gen2: ; 28595 ld de, wLinkData - ld a, $fd - ld b, 6 + ld a, SERIAL_PREAMBLE_BYTE + ld b, PARTY_LENGTH .loop1 ld [de], a inc de @@ -907,7 +911,7 @@ Link_PrepPartyData_Gen2: ; 28595 ld bc, PARTY_LENGTH * (sPartyMon1MailAuthor - sPartyMon1Mail) .loop5 ld a, [hl] - cp $fe + cp SERIAL_NO_DATA_BYTE jr nz, .skip2 ld [hl], sPartyMon1MailAuthor - sPartyMon1Mail @@ -924,9 +928,9 @@ Link_PrepPartyData_Gen2: ; 28595 .loop6 inc c ld a, [hl] - cp $fe + cp SERIAL_NO_DATA_BYTE jr nz, .skip3 - ld [hl], $ff + ld [hl], SERIAL_PATCH_LIST_PART_TERMINATOR ld a, c ld [de], a inc de @@ -935,13 +939,13 @@ Link_PrepPartyData_Gen2: ; 28595 inc hl dec b jr nz, .loop6 - ld a, $ff + ld a, SERIAL_PATCH_LIST_PART_TERMINATOR ld [de], a ret ; 28682 Function28682: ; 28682 - ld c, $5 + ld c, 5 .loop ld [de], a inc de @@ -1129,7 +1133,7 @@ INCLUDE "data/items/catch_rate_items.asm" Link_CopyOTData: ; 2879e .loop ld a, [hli] - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop ld [de], a inc de @@ -1141,8 +1145,8 @@ Link_CopyOTData: ; 2879e ; 287ab Link_CopyRandomNumbers: ; 287ab - ld a, [hLinkPlayerNumber] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK ret z ld hl, EnemyMonSpecies call Link_FindFirstNonControlCharacter_AllowZero @@ -1150,9 +1154,9 @@ Link_CopyRandomNumbers: ; 287ab ld c, 10 .loop ld a, [hli] - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop - cp $fd + cp SERIAL_PREAMBLE_BYTE jr z, .loop ld [de], a inc de @@ -1166,9 +1170,9 @@ Link_FindFirstNonControlCharacter_SkipZero: ; 287ca ld a, [hli] and a jr z, .loop - cp $fd + cp SERIAL_PREAMBLE_BYTE jr z, .loop - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop dec hl ret @@ -1177,9 +1181,9 @@ Link_FindFirstNonControlCharacter_SkipZero: ; 287ca Link_FindFirstNonControlCharacter_AllowZero: ; 287d8 .loop ld a, [hli] - cp $fd + cp SERIAL_PREAMBLE_BYTE jr z, .loop - cp $fe + cp SERIAL_NO_DATA_BYTE jr z, .loop dec hl ret @@ -1219,7 +1223,7 @@ LinkTrade_OTPartyMenu: ; 28803 ld [wMenuCursorX], a ln a, 1, 0 ld [w2DMenuCursorOffsets], a - ld a, $20 + ld a, MENU_UNUSED_3 ld [w2DMenuFlags1], a xor a ld [w2DMenuFlags2], a @@ -1231,7 +1235,7 @@ LinkTradeOTPartymonMenuLoop: ; 28835 jp z, LinkTradePartiesMenuMasterLoop bit A_BUTTON_F, a jr z, .not_a_button - ld a, $1 + ld a, INIT_ENEMYOT_LIST ld [wInitListType], a callfar InitList ld hl, OTPartyMon1Species @@ -1284,7 +1288,7 @@ LinkTrade_PlayerPartyMenu: ; 2888b ld [wMenuCursorX], a ln a, 1, 0 ld [w2DMenuCursorOffsets], a - ld a, $20 + ld a, MENU_UNUSED_3 ld [w2DMenuFlags1], a xor a ld [w2DMenuFlags2], a @@ -1424,7 +1428,7 @@ Function28926: ; 28926 .show_stats pop af ld [wMenuCursorY], a - ld a, $4 + ld a, INIT_PLAYEROT_LIST ld [wInitListType], a callfar InitList farcall LinkMonStatsScreen @@ -1478,7 +1482,7 @@ Function28926: ; 28926 ld a, [wd003] ld hl, OTPartySpecies ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld [wd265], a @@ -1583,9 +1587,9 @@ Function28b22: ; 28b22 xor a ld [rSB], a ld [hSerialSend], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a ret ; 28b42 @@ -1639,14 +1643,14 @@ LinkTrade: ; 28b87 ld [wcf57], a ld [wOtherPlayerLinkAction], a hlcoord 0, 12 - ld b, $4 - ld c, $12 + ld b, 4 + ld c, 18 call LinkTextboxAtHL farcall Link_WaitBGMap ld a, [wd002] ld hl, PartySpecies ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld [wd265], a @@ -1658,7 +1662,7 @@ LinkTrade: ; 28b87 ld a, [wd003] ld hl, OTPartySpecies ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld [wd265], a @@ -1749,7 +1753,7 @@ LinkTrade: ; 28b87 .asm_28c96 inc c ld a, c - cp $6 + cp PARTY_LENGTH jr z, .asm_28ca6 push bc ld bc, MAIL_STRUCT_LENGTH @@ -1778,7 +1782,7 @@ LinkTrade: ; 28b87 call CopyBytes ld a, [wd002] ld hl, PartySpecies - ld b, $0 + ld b, 0 ld c, a add hl, bc ld a, [hl] @@ -1818,7 +1822,7 @@ LinkTrade: ; 28b87 call CopyBytes ld a, [wd003] ld hl, OTPartySpecies - ld b, $0 + ld b, 0 ld c, a add hl, bc ld a, [hl] @@ -1854,7 +1858,7 @@ LinkTrade: ; 28b87 ld a, [wd002] ld [CurPartyMon], a ld hl, PartySpecies - ld b, $0 + ld b, 0 ld c, a add hl, bc ld a, [hl] @@ -1865,12 +1869,12 @@ LinkTrade: ; 28b87 ld a, [PartyCount] dec a ld [CurPartyMon], a - ld a, $1 + ld a, TRUE ld [wForceEvolution], a ld a, [wd003] push af ld hl, OTPartySpecies - ld b, $0 + ld b, 0 ld c, a add hl, bc ld a, [hl] @@ -1881,8 +1885,8 @@ LinkTrade: ; 28b87 call LoadFontsBattleExtra ld b, SCGB_DIPLOMA call GetSGBLayout - ld a, [hLinkPlayerNumber] - cp $1 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK jr z, .player_2 predef TradeAnimation jr .done_animation @@ -1895,7 +1899,7 @@ LinkTrade: ; 28b87 ld c, a ld [CurPartyMon], a ld hl, OTPartySpecies - ld d, $0 + ld d, 0 ld e, a add hl, de ld a, [hl] @@ -1936,7 +1940,7 @@ LinkTrade: ; 28b87 ld a, b ld [wPlayerLinkAction], a push bc - call Function862 + call Serial_PrintWaitingTextAndSyncAndExchangeNybble pop bc ld a, [wLinkMode] cp LINK_TIMECAPSULE @@ -2113,7 +2117,7 @@ Function29c67: ; 29c67 sub b ld c, a inc c - ld b, $0 + ld b, 0 ld hl, PartyCount add hl, bc ld a, [hl] @@ -2140,24 +2144,24 @@ Special_WaitForOtherPlayerToExit: ; 29c92 ld c, 3 call DelayFrames ld a, -1 - ld [hLinkPlayerNumber], a + ld [hSerialConnectionStatus], a xor a ld [rSB], a ld [hSerialReceive], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a ld c, 3 call DelayFrames xor a ld [rSB], a ld [hSerialReceive], a - ld a, $0 + ld a, (0 << rSC_ON) | 0 ld [rSC], a - ld a, $80 + ld a, (1 << rSC_ON) | 0 ld [rSC], a - ld c, $3 + ld c, 3 call DelayFrames xor a ld [rSB], a @@ -2166,7 +2170,7 @@ Special_WaitForOtherPlayerToExit: ; 29c92 ld c, 3 call DelayFrames ld a, -1 - ld [hLinkPlayerNumber], a + ld [hSerialConnectionStatus], a ld a, [rIF] push af xor a @@ -2203,9 +2207,9 @@ Special_SetBitsForTimeCapsuleRequest: ; 29cfa ld [rSB], a xor a ld [hSerialReceive], a - ld a, $0 + ld a, (0 << rSC_ON) | 0 ld [rSC], a - ld a, $80 + ld a, (1 << rSC_ON) | 0 ld [rSC], a xor a ; LINK_TIMECAPSULE - 1 ld [wPlayerLinkAction], a @@ -2221,9 +2225,9 @@ Special_WaitForLinkedFriend: ; 29d11 ld [rSB], a xor a ld [hSerialReceive], a - ld a, $0 + ld a, (0 << rSC_ON) | 0 ld [rSC], a - ld a, $80 + ld a, (1 << rSC_ON) | 0 ld [rSC], a call DelayFrame call DelayFrame @@ -2235,20 +2239,20 @@ Special_WaitForLinkedFriend: ; 29d11 ld a, $ff ld [wLinkTimeoutFrames], a .loop - ld a, [hLinkPlayerNumber] - cp $2 + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK jr z, .connected - cp $1 + cp USING_EXTERNAL_CLOCK jr z, .connected - ld a, -1 - ld [hLinkPlayerNumber], a + ld a, CONNECTION_NOT_ESTABLISHED + ld [hSerialConnectionStatus], a ld a, $2 ld [rSB], a xor a ld [hSerialReceive], a - ld a, $0 + ld a, (0 << rSC_ON) | 0 ld [rSC], a - ld a, $80 + ld a, (1 << rSC_ON) | 0 ld [rSC], a ld a, [wLinkTimeoutFrames] dec a @@ -2262,9 +2266,9 @@ Special_WaitForLinkedFriend: ; 29d11 .not_done ld a, $1 ld [rSB], a - ld a, $1 + ld a, (0 << rSC_ON) | 1 ld [rSC], a - ld a, $81 + ld a, (1 << rSC_ON) | 1 ld [rSC], a call DelayFrame jr .loop @@ -2357,7 +2361,7 @@ Function29dba: ; 29dba Link_CheckCommunicationError: ; 29e0c xor a - ld [hFFCA], a + ld [hSerialReceivedNewData], a ld a, [wLinkTimeoutFrames] ld h, a ld a, [wLinkTimeoutFrames + 1] @@ -2409,7 +2413,7 @@ Link_CheckCommunicationError: ; 29e0c .ConvertDW: ; 29e53 ; [wLinkTimeoutFrames] = ((hl - $100) / 4) + $100 - ; = (hl / 4) + $c0 + ; = (hl / 4) + $c0 dec h srl h rr l @@ -2427,9 +2431,9 @@ Special_TryQuickSave: ; 29e66 ld a, [wd265] push af farcall Link_SaveGame - ld a, $1 + ld a, TRUE jr nc, .return_result - xor a + xor a ; FALSE .return_result ld [ScriptVar], a ld c, 30 @@ -2456,12 +2460,12 @@ Special_CheckBothSelectedSameRoom: ; 29e82 ld [wLinkMode], a xor a ld [hVBlank], a - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret .fail - xor a + xor a ; FALSE ld [ScriptVar], a ret ; 29eaf @@ -2517,8 +2521,8 @@ Special_FailedLinkToPast: ; 29efa Link_ResetSerialRegistersAfterLinkClosure: ; 29f04 ld c, 3 call DelayFrames - ld a, -1 - ld [hLinkPlayerNumber], a + ld a, CONNECTION_NOT_ESTABLISHED + ld [hSerialConnectionStatus], a ld a, $2 ld [rSB], a xor a @@ -2536,7 +2540,7 @@ Link_EnsureSync: ; 29f17 call DelayFrame call DelayFrame .receive_loop - call Function83b + call Serial_ExchangeLinkMenuSelection ld a, [wOtherPlayerLinkMode] ld b, a and $f0 @@ -2557,11 +2561,11 @@ Link_EnsureSync: ; 29f17 ; 29f47 Special_CableClubCheckWhichChris: ; 29f47 - ld a, [hLinkPlayerNumber] - cp $1 - ld a, $1 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + ld a, TRUE jr z, .yes - dec a + dec a ; FALSE .yes ld [ScriptVar], a @@ -2575,7 +2579,7 @@ INCBIN "gfx/trade/unused_gen_1_border_tiles.2bpp" Unreferenced_Function29fe4: ld a, BANK(sPartyMail) call GetSRAMBank - ld d, $0 + ld d, FALSE ld b, CHECK_FLAG predef SmallFarFlagAction call CloseSRAM diff --git a/engine/link_2.asm b/engine/link_2.asm index 866126cd2..7923f9c9d 100644 --- a/engine/link_2.asm +++ b/engine/link_2.asm @@ -56,7 +56,7 @@ LinkTextbox2: ; 4d35b .PlaceBorder: ; 4d37e push hl - ld a, $76 + ld a, "ぁ" ; $76 ld [hli], a inc a call .PlaceRow diff --git a/engine/link_trade.asm b/engine/link_trade.asm index ae84a7beb..9a7a2e3d7 100755 --- a/engine/link_trade.asm +++ b/engine/link_trade.asm @@ -139,7 +139,7 @@ _LoadTradeScreenBorder: ; 16d696 LinkComms_LoadPleaseWaitTextboxBorderGFX: ; 16d69a ld de, LinkCommsBorderGFX + $30 tiles - ld hl, vTiles2 tile $76 + ld hl, vTiles2 tile "ぁ" lb bc, BANK(LinkCommsBorderGFX), 8 call Get2bpp ret |