mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Resolve #471 (although link code still needs more cleanup, like its WRAM labels)
This commit is contained in:
parent
52993d20ef
commit
0c6338836d
@ -6,7 +6,25 @@
|
|||||||
const LINK_COLOSSEUM ; 3
|
const LINK_COLOSSEUM ; 3
|
||||||
const LINK_MOBILE ; 4
|
const LINK_MOBILE ; 4
|
||||||
|
|
||||||
|
; hSerialReceive high nybbles
|
||||||
SERIAL_TIMECAPSULE EQU $60
|
SERIAL_TIMECAPSULE EQU $60
|
||||||
SERIAL_TRADECENTER EQU $70
|
SERIAL_TRADECENTER EQU $70
|
||||||
SERIAL_BATTLE EQU $80
|
SERIAL_BATTLE EQU $80
|
||||||
|
|
||||||
|
ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
|
||||||
|
ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK EQU $02
|
||||||
|
|
||||||
|
START_TRANSFER_EXTERNAL_CLOCK EQU $80 ; 1 << rSC_ON
|
||||||
|
START_TRANSFER_INTERNAL_CLOCK EQU $81 ; (1 << rSC_ON) | 1
|
||||||
|
|
||||||
|
; hSerialConnectionStatus
|
||||||
|
USING_EXTERNAL_CLOCK EQU $01
|
||||||
|
USING_INTERNAL_CLOCK EQU $02
|
||||||
|
CONNECTION_NOT_ESTABLISHED EQU $ff
|
||||||
|
|
||||||
|
; signals the start of an array of bytes transferred over the link cable
|
||||||
|
SERIAL_PREAMBLE_BYTE EQU $fd
|
||||||
|
; this byte is used when there is no data to send
|
||||||
|
SERIAL_NO_DATA_BYTE EQU $fe
|
||||||
|
; signals the end of one part of a patch list (there are two parts) for player/enemy party data
|
||||||
|
SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
|
||||||
|
@ -26,7 +26,7 @@ DoBattle: ; 3c000
|
|||||||
and a
|
and a
|
||||||
jr z, .not_linked
|
jr z, .not_linked
|
||||||
|
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp $2
|
||||||
jr z, .player_2
|
jr z, .player_2
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ DoBattle: ; 3c000
|
|||||||
ld a, [wLinkMode]
|
ld a, [wLinkMode]
|
||||||
and a
|
and a
|
||||||
jr z, .not_linked_2
|
jr z, .not_linked_2
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp $2
|
||||||
jr nz, .not_linked_2
|
jr nz, .not_linked_2
|
||||||
xor a
|
xor a
|
||||||
@ -251,7 +251,7 @@ Stubbed_Function3c1bf:
|
|||||||
; 3c1d6
|
; 3c1d6
|
||||||
|
|
||||||
HandleBetweenTurnEffects: ; 3c1d6
|
HandleBetweenTurnEffects: ; 3c1d6
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .CheckEnemyFirst
|
jr z, .CheckEnemyFirst
|
||||||
call CheckFaint_PlayerThenEnemy
|
call CheckFaint_PlayerThenEnemy
|
||||||
@ -350,7 +350,7 @@ CheckFaint_EnemyThenPlayer: ; 3c25c
|
|||||||
; 3c27c
|
; 3c27c
|
||||||
|
|
||||||
HandleBerserkGene: ; 3c27c
|
HandleBerserkGene: ; 3c27c
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .reverse
|
jr z, .reverse
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ DetermineMoveOrder: ; 3c314
|
|||||||
ld a, [wPlayerAction]
|
ld a, [wPlayerAction]
|
||||||
cp $2
|
cp $2
|
||||||
jr nz, .switch
|
jr nz, .switch
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp $2
|
||||||
jr z, .player_2
|
jr z, .player_2
|
||||||
|
|
||||||
@ -515,7 +515,7 @@ DetermineMoveOrder: ; 3c314
|
|||||||
jp .enemy_first
|
jp .enemy_first
|
||||||
|
|
||||||
.both_have_quick_claw
|
.both_have_quick_claw
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp $2
|
||||||
jr z, .player_2b
|
jr z, .player_2b
|
||||||
call BattleRandom
|
call BattleRandom
|
||||||
@ -545,7 +545,7 @@ DetermineMoveOrder: ; 3c314
|
|||||||
jp .enemy_first
|
jp .enemy_first
|
||||||
|
|
||||||
.speed_tie
|
.speed_tie
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp $2
|
||||||
jr z, .player_2c
|
jr z, .player_2c
|
||||||
call BattleRandom
|
call BattleRandom
|
||||||
@ -709,7 +709,7 @@ ParsePlayerAction: ; 3c434
|
|||||||
; 3c4df
|
; 3c4df
|
||||||
|
|
||||||
HandleEncore: ; 3c4df
|
HandleEncore: ; 3c4df
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .player_1
|
jr z, .player_1
|
||||||
call .do_player
|
call .do_player
|
||||||
@ -1161,7 +1161,7 @@ ResidualDamage: ; 3c716
|
|||||||
; 3c801
|
; 3c801
|
||||||
|
|
||||||
HandlePerishSong: ; 3c801
|
HandlePerishSong: ; 3c801
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .EnemyFirst
|
jr z, .EnemyFirst
|
||||||
call SetPlayerTurn
|
call SetPlayerTurn
|
||||||
@ -1230,7 +1230,7 @@ HandlePerishSong: ; 3c801
|
|||||||
; 3c874
|
; 3c874
|
||||||
|
|
||||||
HandleWrap: ; 3c874
|
HandleWrap: ; 3c874
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .EnemyFirst
|
jr z, .EnemyFirst
|
||||||
call SetPlayerTurn
|
call SetPlayerTurn
|
||||||
@ -1302,7 +1302,7 @@ SwitchTurnCore: ; 3c8e4
|
|||||||
; 3c8eb
|
; 3c8eb
|
||||||
|
|
||||||
HandleLeftovers: ; 3c8eb
|
HandleLeftovers: ; 3c8eb
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .DoEnemyFirst
|
jr z, .DoEnemyFirst
|
||||||
call SetPlayerTurn
|
call SetPlayerTurn
|
||||||
@ -1352,7 +1352,7 @@ HandleLeftovers: ; 3c8eb
|
|||||||
; 3c93c
|
; 3c93c
|
||||||
|
|
||||||
HandleMysteryberry: ; 3c93c
|
HandleMysteryberry: ; 3c93c
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .DoEnemyFirst
|
jr z, .DoEnemyFirst
|
||||||
call SetPlayerTurn
|
call SetPlayerTurn
|
||||||
@ -1491,7 +1491,7 @@ HandleMysteryberry: ; 3c93c
|
|||||||
; 3ca26
|
; 3ca26
|
||||||
|
|
||||||
HandleFutureSight: ; 3ca26
|
HandleFutureSight: ; 3ca26
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .enemy_first
|
jr z, .enemy_first
|
||||||
call SetPlayerTurn
|
call SetPlayerTurn
|
||||||
@ -1550,7 +1550,7 @@ HandleFutureSight: ; 3ca26
|
|||||||
; 3ca8f
|
; 3ca8f
|
||||||
|
|
||||||
HanleDefrost: ; 3ca8f
|
HanleDefrost: ; 3ca8f
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .enemy_first
|
jr z, .enemy_first
|
||||||
call .do_player_turn
|
call .do_player_turn
|
||||||
@ -1610,7 +1610,7 @@ HanleDefrost: ; 3ca8f
|
|||||||
; 3cafb
|
; 3cafb
|
||||||
|
|
||||||
HandleSafeguard: ; 3cafb
|
HandleSafeguard: ; 3cafb
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .player1
|
jr z, .player1
|
||||||
call .CheckPlayer
|
call .CheckPlayer
|
||||||
@ -1647,7 +1647,7 @@ HandleSafeguard: ; 3cafb
|
|||||||
jp StdBattleTextBox
|
jp StdBattleTextBox
|
||||||
|
|
||||||
HandleScreens: ; 3cb36
|
HandleScreens: ; 3cb36
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp 1
|
cp 1
|
||||||
jr z, .Both
|
jr z, .Both
|
||||||
call .CheckPlayer
|
call .CheckPlayer
|
||||||
@ -1731,7 +1731,7 @@ HandleWeather: ; 3cb9e
|
|||||||
cp WEATHER_SANDSTORM
|
cp WEATHER_SANDSTORM
|
||||||
ret nz
|
ret nz
|
||||||
|
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp 1
|
cp 1
|
||||||
jr z, .enemy_first
|
jr z, .enemy_first
|
||||||
|
|
||||||
@ -2115,7 +2115,7 @@ HandleEnemyMonFaint: ; 3cd55
|
|||||||
; 3cdca
|
; 3cdca
|
||||||
|
|
||||||
DoubleSwitch: ; 3cdca
|
DoubleSwitch: ; 3cdca
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .player_1
|
jr z, .player_1
|
||||||
call ClearSprites
|
call ClearSprites
|
||||||
@ -4350,7 +4350,7 @@ RecallPlayerMon: ; 3dce6
|
|||||||
; 3dcf9
|
; 3dcf9
|
||||||
|
|
||||||
HandleHealingItems: ; 3dcf9
|
HandleHealingItems: ; 3dcf9
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .player_1
|
jr z, .player_1
|
||||||
call SetPlayerTurn
|
call SetPlayerTurn
|
||||||
@ -4595,7 +4595,7 @@ UseConfusionHealingItem: ; 3de51
|
|||||||
|
|
||||||
HandleStatBoostingHeldItems: ; 3de97
|
HandleStatBoostingHeldItems: ; 3de97
|
||||||
; The effects handled here are not used in-game.
|
; The effects handled here are not used in-game.
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .player_1
|
jr z, .player_1
|
||||||
call .DoPlayer
|
call .DoPlayer
|
||||||
@ -5374,7 +5374,7 @@ PlayerSwitch: ; 3e3ad
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.dont_run
|
.dont_run
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp $1
|
||||||
jr z, .player_1
|
jr z, .player_1
|
||||||
call BattleMonEntrance
|
call BattleMonEntrance
|
||||||
|
284
engine/link.asm
284
engine/link.asm
File diff suppressed because it is too large
Load Diff
@ -56,7 +56,7 @@ LinkTextbox2: ; 4d35b
|
|||||||
|
|
||||||
.PlaceBorder: ; 4d37e
|
.PlaceBorder: ; 4d37e
|
||||||
push hl
|
push hl
|
||||||
ld a, $76
|
ld a, "ぁ" ; $76
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
inc a
|
inc a
|
||||||
call .PlaceRow
|
call .PlaceRow
|
||||||
|
@ -139,7 +139,7 @@ _LoadTradeScreenBorder: ; 16d696
|
|||||||
|
|
||||||
LinkComms_LoadPleaseWaitTextboxBorderGFX: ; 16d69a
|
LinkComms_LoadPleaseWaitTextboxBorderGFX: ; 16d69a
|
||||||
ld de, LinkCommsBorderGFX + $30 tiles
|
ld de, LinkCommsBorderGFX + $30 tiles
|
||||||
ld hl, vTiles2 tile $76
|
ld hl, vTiles2 tile "ぁ"
|
||||||
lb bc, BANK(LinkCommsBorderGFX), 8
|
lb bc, BANK(LinkCommsBorderGFX), 8
|
||||||
call Get2bpp
|
call Get2bpp
|
||||||
ret
|
ret
|
||||||
|
@ -32,7 +32,7 @@ _Start:: ; 16e
|
|||||||
.load
|
.load
|
||||||
ld [hCGB], a
|
ld [hCGB], a
|
||||||
ld a, $1
|
ld a, $1
|
||||||
ld [hFFEA], a
|
ld [hSystemBooted], a
|
||||||
; 17d
|
; 17d
|
||||||
|
|
||||||
|
|
||||||
@ -84,14 +84,14 @@ Init:: ; 17d
|
|||||||
; Clear HRAM
|
; Clear HRAM
|
||||||
ld a, [hCGB]
|
ld a, [hCGB]
|
||||||
push af
|
push af
|
||||||
ld a, [hFFEA]
|
ld a, [hSystemBooted]
|
||||||
push af
|
push af
|
||||||
xor a
|
xor a
|
||||||
ld hl, HRAM_Begin
|
ld hl, HRAM_Begin
|
||||||
ld bc, HRAM_End - HRAM_Begin
|
ld bc, HRAM_End - HRAM_Begin
|
||||||
call ByteFill
|
call ByteFill
|
||||||
pop af
|
pop af
|
||||||
ld [hFFEA], a
|
ld [hSystemBooted], a
|
||||||
pop af
|
pop af
|
||||||
ld [hCGB], a
|
ld [hCGB], a
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ Init:: ; 17d
|
|||||||
ld [rLCDC], a
|
ld [rLCDC], a
|
||||||
|
|
||||||
ld a, -1
|
ld a, -1
|
||||||
ld [hLinkPlayerNumber], a
|
ld [hSerialConnectionStatus], a
|
||||||
|
|
||||||
farcall InitCGBPals
|
farcall InitCGBPals
|
||||||
|
|
||||||
|
@ -1352,7 +1352,7 @@ UpdateBGMapRow:: ; 27d3
|
|||||||
dec c
|
dec c
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
ld a, SCREEN_WIDTH
|
ld a, SCREEN_WIDTH
|
||||||
ld [hFFDC], a
|
ld [hBGMapTileCount], a
|
||||||
ret
|
ret
|
||||||
; 27f8
|
; 27f8
|
||||||
|
|
||||||
@ -1379,7 +1379,7 @@ UpdateBGMapColumn:: ; 27f8
|
|||||||
dec c
|
dec c
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
ld a, SCREEN_HEIGHT
|
ld a, SCREEN_HEIGHT
|
||||||
ld [hFFDC], a
|
ld [hBGMapTileCount], a
|
||||||
ret
|
ret
|
||||||
; 2816
|
; 2816
|
||||||
|
|
||||||
|
130
home/serial.asm
130
home/serial.asm
@ -14,9 +14,9 @@ Serial:: ; 6ef
|
|||||||
bit 0, a
|
bit 0, a
|
||||||
jr nz, .printer
|
jr nz, .printer
|
||||||
|
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
inc a ; is it equal to -1?
|
inc a ; is it equal to CONNECTION_NOT_ESTABLISHED?
|
||||||
jr z, .init_player_number
|
jr z, .establish_connection
|
||||||
|
|
||||||
ld a, [rSB]
|
ld a, [rSB]
|
||||||
ld [hSerialReceive], a
|
ld [hSerialReceive], a
|
||||||
@ -24,8 +24,8 @@ Serial:: ; 6ef
|
|||||||
ld a, [hSerialSend]
|
ld a, [hSerialSend]
|
||||||
ld [rSB], a
|
ld [rSB], a
|
||||||
|
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp USING_INTERNAL_CLOCK
|
||||||
jr z, .player2
|
jr z, .player2
|
||||||
|
|
||||||
ld a, 0 << rSC_ON
|
ld a, 0 << rSC_ON
|
||||||
@ -42,22 +42,22 @@ Serial:: ; 6ef
|
|||||||
call PrinterReceive
|
call PrinterReceive
|
||||||
jr .end
|
jr .end
|
||||||
|
|
||||||
.init_player_number
|
.establish_connection
|
||||||
ld a, [rSB]
|
ld a, [rSB]
|
||||||
cp $1
|
cp USING_EXTERNAL_CLOCK
|
||||||
jr z, .player1
|
jr z, .player1
|
||||||
cp $2
|
cp USING_INTERNAL_CLOCK
|
||||||
jr nz, .player2
|
jr nz, .player2
|
||||||
|
|
||||||
.player1
|
.player1
|
||||||
ld [hSerialReceive], a
|
ld [hSerialReceive], a
|
||||||
ld [hLinkPlayerNumber], a
|
ld [hSerialConnectionStatus], a
|
||||||
cp $2
|
cp USING_INTERNAL_CLOCK
|
||||||
jr z, ._player2
|
jr z, ._player2
|
||||||
|
|
||||||
xor a
|
xor a
|
||||||
ld [rSB], a
|
ld [rSB], a
|
||||||
ld a, $3
|
ld a, 3
|
||||||
ld [rDIV], a
|
ld [rDIV], a
|
||||||
|
|
||||||
.wait_bit_7
|
.wait_bit_7
|
||||||
@ -76,9 +76,9 @@ Serial:: ; 6ef
|
|||||||
ld [rSB], a
|
ld [rSB], a
|
||||||
|
|
||||||
.player2
|
.player2
|
||||||
ld a, $1
|
ld a, TRUE
|
||||||
ld [hFFCA], a
|
ld [hSerialReceivedNewData], a
|
||||||
ld a, $fe
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
ld [hSerialSend], a
|
ld [hSerialSend], a
|
||||||
|
|
||||||
.end
|
.end
|
||||||
@ -89,13 +89,13 @@ Serial:: ; 6ef
|
|||||||
reti
|
reti
|
||||||
; 75f
|
; 75f
|
||||||
|
|
||||||
Function75f:: ; 75f
|
Serial_ExchangeBytes:: ; 75f
|
||||||
ld a, $1
|
ld a, $1
|
||||||
ld [hFFCC], a
|
ld [hSerialIgnoringInitialData], a
|
||||||
.loop
|
.loop
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [hSerialSend], a
|
ld [hSerialSend], a
|
||||||
call Function78a
|
call Serial_ExchangeByte
|
||||||
push bc
|
push bc
|
||||||
ld b, a
|
ld b, a
|
||||||
inc hl
|
inc hl
|
||||||
@ -103,16 +103,16 @@ Function75f:: ; 75f
|
|||||||
.wait
|
.wait
|
||||||
dec a
|
dec a
|
||||||
jr nz, .wait
|
jr nz, .wait
|
||||||
ld a, [hFFCC]
|
ld a, [hSerialIgnoringInitialData]
|
||||||
and a
|
and a
|
||||||
ld a, b
|
ld a, b
|
||||||
pop bc
|
pop bc
|
||||||
jr z, .load
|
jr z, .load
|
||||||
dec hl
|
dec hl
|
||||||
cp $fd
|
cp SERIAL_PREAMBLE_BYTE
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
xor a
|
xor a
|
||||||
ld [hFFCC], a
|
ld [hSerialIgnoringInitialData], a
|
||||||
jr .loop
|
jr .loop
|
||||||
|
|
||||||
.load
|
.load
|
||||||
@ -125,24 +125,24 @@ Function75f:: ; 75f
|
|||||||
ret
|
ret
|
||||||
; 78a
|
; 78a
|
||||||
|
|
||||||
Function78a:: ; 78a
|
Serial_ExchangeByte:: ; 78a
|
||||||
.loop
|
.loop
|
||||||
xor a
|
xor a
|
||||||
ld [hFFCA], a
|
ld [hSerialReceivedNewData], a
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp USING_INTERNAL_CLOCK
|
||||||
jr nz, .not_player_2
|
jr nz, .not_player_2
|
||||||
ld a, $1
|
ld a, (0 << rSC_ON) | 1
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
ld a, $81
|
ld a, (1 << rSC_ON) | 1
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
.not_player_2
|
.not_player_2
|
||||||
.loop2
|
.loop2
|
||||||
ld a, [hFFCA]
|
ld a, [hSerialReceivedNewData]
|
||||||
and a
|
and a
|
||||||
jr nz, .reset_ffca
|
jr nz, .reset_ffca
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp USING_EXTERNAL_CLOCK
|
||||||
jr nz, .not_player_1_or_wLinkTimeoutFrames_zero
|
jr nz, .not_player_1_or_wLinkTimeoutFrames_zero
|
||||||
call CheckwLinkTimeoutFramesNonzero
|
call CheckwLinkTimeoutFramesNonzero
|
||||||
jr z, .not_player_1_or_wLinkTimeoutFrames_zero
|
jr z, .not_player_1_or_wLinkTimeoutFrames_zero
|
||||||
@ -162,8 +162,8 @@ Function78a:: ; 78a
|
|||||||
|
|
||||||
.not_player_1_or_wLinkTimeoutFrames_zero
|
.not_player_1_or_wLinkTimeoutFrames_zero
|
||||||
ld a, [rIE]
|
ld a, [rIE]
|
||||||
and $f
|
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
|
||||||
cp $8
|
cp 1 << SERIAL
|
||||||
jr nz, .loop2
|
jr nz, .loop2
|
||||||
ld a, [wcf5d]
|
ld a, [wcf5d]
|
||||||
dec a
|
dec a
|
||||||
@ -173,8 +173,8 @@ Function78a:: ; 78a
|
|||||||
dec a
|
dec a
|
||||||
ld [wcf5d + 1], a
|
ld [wcf5d + 1], a
|
||||||
jr nz, .loop2
|
jr nz, .loop2
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $1
|
cp USING_EXTERNAL_CLOCK
|
||||||
jr z, .reset_ffca
|
jr z, .reset_ffca
|
||||||
|
|
||||||
ld a, 255
|
ld a, 255
|
||||||
@ -184,19 +184,20 @@ Function78a:: ; 78a
|
|||||||
|
|
||||||
.reset_ffca
|
.reset_ffca
|
||||||
xor a
|
xor a
|
||||||
ld [hFFCA], a
|
ld [hSerialReceivedNewData], a
|
||||||
ld a, [rIE]
|
ld a, [rIE]
|
||||||
and $f
|
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
|
||||||
sub $8
|
sub 1 << SERIAL
|
||||||
jr nz, .rIE_not_equal_8
|
jr nz, .rIE_not_equal_8
|
||||||
|
|
||||||
|
; LOW($5000)
|
||||||
ld [wcf5d], a
|
ld [wcf5d], a
|
||||||
ld a, $50
|
ld a, HIGH($5000)
|
||||||
ld [wcf5d + 1], a
|
ld [wcf5d + 1], a
|
||||||
|
|
||||||
.rIE_not_equal_8
|
.rIE_not_equal_8
|
||||||
ld a, [hSerialReceive]
|
ld a, [hSerialReceive]
|
||||||
cp $fe
|
cp SERIAL_NO_DATA_BYTE
|
||||||
ret nz
|
ret nz
|
||||||
call CheckwLinkTimeoutFramesNonzero
|
call CheckwLinkTimeoutFramesNonzero
|
||||||
jr z, .wLinkTimeoutFrames_zero
|
jr z, .wLinkTimeoutFrames_zero
|
||||||
@ -216,9 +217,9 @@ Function78a:: ; 78a
|
|||||||
|
|
||||||
.wLinkTimeoutFrames_zero
|
.wLinkTimeoutFrames_zero
|
||||||
ld a, [rIE]
|
ld a, [rIE]
|
||||||
and $f
|
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
|
||||||
cp $8
|
cp 1 << SERIAL
|
||||||
ld a, $fe
|
ld a, SERIAL_NO_DATA_BYTE
|
||||||
ret z
|
ret z
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [hSerialSend], a
|
ld [hSerialSend], a
|
||||||
@ -243,29 +244,31 @@ CheckwLinkTimeoutFramesNonzero:: ; 82b
|
|||||||
; 833
|
; 833
|
||||||
|
|
||||||
SerialDisconnected:: ; 833
|
SerialDisconnected:: ; 833
|
||||||
dec a
|
dec a ; a is always 0 when this is called
|
||||||
ld [wLinkTimeoutFrames], a
|
ld [wLinkTimeoutFrames], a
|
||||||
ld [wLinkTimeoutFrames + 1], a
|
ld [wLinkTimeoutFrames + 1], a
|
||||||
ret
|
ret
|
||||||
; 83b
|
; 83b
|
||||||
|
|
||||||
Function83b:: ; 83b
|
; This is used to exchange the button press and selected menu item on the link menu.
|
||||||
|
; The data is sent thrice and read twice to increase reliability.
|
||||||
|
Serial_ExchangeLinkMenuSelection:: ; 83b
|
||||||
ld hl, wPlayerLinkAction
|
ld hl, wPlayerLinkAction
|
||||||
ld de, wOtherPlayerLinkMode
|
ld de, wOtherPlayerLinkMode
|
||||||
ld c, $2
|
ld c, 2
|
||||||
ld a, $1
|
ld a, TRUE
|
||||||
ld [hFFCC], a
|
ld [hSerialIgnoringInitialData], a
|
||||||
.asm_847
|
.asm_847
|
||||||
call DelayFrame
|
call DelayFrame
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [hSerialSend], a
|
ld [hSerialSend], a
|
||||||
call Function78a
|
call Serial_ExchangeByte
|
||||||
ld b, a
|
ld b, a
|
||||||
inc hl
|
inc hl
|
||||||
ld a, [hFFCC]
|
ld a, [hSerialIgnoringInitialData]
|
||||||
and a
|
and a
|
||||||
ld a, $0
|
ld a, FALSE
|
||||||
ld [hFFCC], a
|
ld [hSerialIgnoringInitialData], a
|
||||||
jr nz, .asm_847
|
jr nz, .asm_847
|
||||||
ld a, b
|
ld a, b
|
||||||
ld [de], a
|
ld [de], a
|
||||||
@ -275,15 +278,14 @@ Function83b:: ; 83b
|
|||||||
ret
|
ret
|
||||||
; 862
|
; 862
|
||||||
|
|
||||||
Function862:: ; 862
|
Serial_PrintWaitingTextAndSyncAndExchangeNybble:: ; 862
|
||||||
call LoadTileMapToTempTileMap
|
call LoadTileMapToTempTileMap
|
||||||
callfar PlaceWaitingText
|
callfar PlaceWaitingText
|
||||||
call WaitLinkTransfer
|
call WaitLinkTransfer
|
||||||
jp Call_LoadTempTileMapToTileMap
|
jp Call_LoadTempTileMapToTileMap
|
||||||
; 871
|
; 871
|
||||||
|
|
||||||
|
Serial_SyncAndExchangeNybble:: ; 871
|
||||||
Function871:: ; 871
|
|
||||||
call LoadTileMapToTempTileMap
|
call LoadTileMapToTempTileMap
|
||||||
callfar PlaceWaitingText
|
callfar PlaceWaitingText
|
||||||
jp WaitLinkTransfer
|
jp WaitLinkTransfer
|
||||||
@ -356,12 +358,12 @@ LinkTransfer:: ; 8c1
|
|||||||
ld a, [wPlayerLinkAction]
|
ld a, [wPlayerLinkAction]
|
||||||
add b
|
add b
|
||||||
ld [hSerialSend], a
|
ld [hSerialSend], a
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp USING_INTERNAL_CLOCK
|
||||||
jr nz, .player_1
|
jr nz, .player_1
|
||||||
ld a, $1
|
ld a, (0 << rSC_ON) | 1
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
ld a, $81
|
ld a, (1 << rSC_ON) | 1
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
|
|
||||||
.player_1
|
.player_1
|
||||||
@ -388,12 +390,12 @@ LinkDataReceived:: ; 908
|
|||||||
; Let the other system know that the data has been received.
|
; Let the other system know that the data has been received.
|
||||||
xor a
|
xor a
|
||||||
ld [hSerialSend], a
|
ld [hSerialSend], a
|
||||||
ld a, [hLinkPlayerNumber]
|
ld a, [hSerialConnectionStatus]
|
||||||
cp $2
|
cp USING_INTERNAL_CLOCK
|
||||||
ret nz
|
ret nz
|
||||||
ld a, $1
|
ld a, (0 << rSC_ON) | 1
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
ld a, $81
|
ld a, (1 << rSC_ON) | 1
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
ret
|
ret
|
||||||
; 919
|
; 919
|
||||||
@ -402,13 +404,13 @@ Unreferenced_Function919:: ; 919
|
|||||||
ld a, [wLinkMode]
|
ld a, [wLinkMode]
|
||||||
and a
|
and a
|
||||||
ret nz
|
ret nz
|
||||||
ld a, $2
|
ld a, USING_INTERNAL_CLOCK
|
||||||
ld [rSB], a
|
ld [rSB], a
|
||||||
xor a
|
xor a
|
||||||
ld [hSerialReceive], a
|
ld [hSerialReceive], a
|
||||||
ld a, $0
|
ld a, 0 << rSC_ON
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
ld a, $80
|
ld a, 1 << rSC_ON
|
||||||
ld [rSC], a
|
ld [rSC], a
|
||||||
ret
|
ret
|
||||||
; 92e
|
; 92e
|
||||||
|
@ -20,10 +20,10 @@ DMATransfer:: ; 15d8
|
|||||||
|
|
||||||
|
|
||||||
UpdateBGMapBuffer:: ; 15e3
|
UpdateBGMapBuffer:: ; 15e3
|
||||||
; Copy [hFFDC] 16x8 tiles from BGMapBuffer
|
; Copy [hBGMapTileCount] 16x8 tiles from BGMapBuffer
|
||||||
; to bg map addresses in BGMapBufferPtrs.
|
; to bg map addresses in BGMapBufferPtrs.
|
||||||
|
|
||||||
; [hFFDC] must be even since this is done in pairs.
|
; [hBGMapTileCount] must be even since this is done in pairs.
|
||||||
|
|
||||||
; Return carry on success.
|
; Return carry on success.
|
||||||
|
|
||||||
@ -76,10 +76,10 @@ rept 2
|
|||||||
endr
|
endr
|
||||||
|
|
||||||
; We've done 2 16x8 blocks
|
; We've done 2 16x8 blocks
|
||||||
ld a, [hFFDC]
|
ld a, [hBGMapTileCount]
|
||||||
dec a
|
dec a
|
||||||
dec a
|
dec a
|
||||||
ld [hFFDC], a
|
ld [hBGMapTileCount], a
|
||||||
|
|
||||||
jr nz, .next
|
jr nz, .next
|
||||||
|
|
||||||
|
12
hram.asm
12
hram.asm
@ -39,6 +39,7 @@ hInMenu EQU $ffaa
|
|||||||
hPrinter EQU $ffac
|
hPrinter EQU $ffac
|
||||||
hGraphicStartTile EQU $ffad
|
hGraphicStartTile EQU $ffad
|
||||||
hMoveMon EQU $ffae
|
hMoveMon EQU $ffae
|
||||||
|
|
||||||
hMapObjectIndexBuffer EQU $ffaf
|
hMapObjectIndexBuffer EQU $ffaf
|
||||||
hObjectStructIndexBuffer EQU $ffb0
|
hObjectStructIndexBuffer EQU $ffb0
|
||||||
|
|
||||||
@ -88,10 +89,11 @@ hMGJoypadReleased EQU $ffc4
|
|||||||
hLCDCPointer EQU $ffc6
|
hLCDCPointer EQU $ffc6
|
||||||
hLYOverrideStart EQU $ffc7
|
hLYOverrideStart EQU $ffc7
|
||||||
hLYOverrideEnd EQU $ffc8
|
hLYOverrideEnd EQU $ffc8
|
||||||
|
|
||||||
hMobileReceive EQU $ffc9
|
hMobileReceive EQU $ffc9
|
||||||
hFFCA EQU $ffca
|
hSerialReceivedNewData EQU $ffca
|
||||||
hLinkPlayerNumber EQU $ffcb
|
hSerialConnectionStatus EQU $ffcb
|
||||||
hFFCC EQU $ffcc
|
hSerialIgnoringInitialData EQU $ffcc
|
||||||
hSerialSend EQU $ffcd
|
hSerialSend EQU $ffcd
|
||||||
hSerialReceive EQU $ffce
|
hSerialReceive EQU $ffce
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ hOAMUpdate EQU $ffd8
|
|||||||
hSPBuffer EQU $ffd9
|
hSPBuffer EQU $ffd9
|
||||||
|
|
||||||
hBGMapUpdate EQU $ffdb
|
hBGMapUpdate EQU $ffdb
|
||||||
hFFDC EQU $ffdc
|
hBGMapTileCount EQU $ffdc
|
||||||
|
|
||||||
hMapAnims EQU $ffde
|
hMapAnims EQU $ffde
|
||||||
hTileAnimFrame EQU $ffdf
|
hTileAnimFrame EQU $ffdf
|
||||||
@ -125,5 +127,5 @@ hCGB EQU $ffe6
|
|||||||
hSGB EQU $ffe7
|
hSGB EQU $ffe7
|
||||||
hDMATransfer EQU $ffe8
|
hDMATransfer EQU $ffe8
|
||||||
hMobile EQU $ffe9
|
hMobile EQU $ffe9
|
||||||
hFFEA EQU $ffea
|
hSystemBooted EQU $ffea
|
||||||
hClockResetTrigger EQU $ffeb
|
hClockResetTrigger EQU $ffeb
|
||||||
|
@ -4056,7 +4056,7 @@ _StartMobileBattle: ; 1019ab
|
|||||||
jr z, .got_link_player_number
|
jr z, .got_link_player_number
|
||||||
ld a, 1
|
ld a, 1
|
||||||
.got_link_player_number
|
.got_link_player_number
|
||||||
ld [hLinkPlayerNumber], a
|
ld [hSerialConnectionStatus], a
|
||||||
ret
|
ret
|
||||||
; 101a21
|
; 101a21
|
||||||
|
|
||||||
@ -4076,7 +4076,7 @@ StartMobileBattle: ; 101a21
|
|||||||
xor a
|
xor a
|
||||||
ld [wDisableTextAcceleration], a
|
ld [wDisableTextAcceleration], a
|
||||||
ld a, $ff
|
ld a, $ff
|
||||||
ld [hLinkPlayerNumber], a
|
ld [hSerialConnectionStatus], a
|
||||||
pop af
|
pop af
|
||||||
ld [Options], a
|
ld [Options], a
|
||||||
ret
|
ret
|
||||||
|
@ -4,7 +4,7 @@ Unreferenced_Function16c000: ; 16c000
|
|||||||
and a
|
and a
|
||||||
ret z
|
ret z
|
||||||
; Only do this once per boot cycle
|
; Only do this once per boot cycle
|
||||||
ld a, [hFFEA]
|
ld a, [hSystemBooted]
|
||||||
and a
|
and a
|
||||||
ret z
|
ret z
|
||||||
; Set some flag, preserving the old state
|
; Set some flag, preserving the old state
|
||||||
@ -19,9 +19,9 @@ Unreferenced_Function16c000: ; 16c000
|
|||||||
call .RunJumptable
|
call .RunJumptable
|
||||||
farcall DisableMobile
|
farcall DisableMobile
|
||||||
; Prevent this routine from running again
|
; Prevent this routine from running again
|
||||||
; until the next time the syatem is turned on
|
; until the next time the system is turned on
|
||||||
xor a
|
xor a
|
||||||
ld [hFFEA], a
|
ld [hSystemBooted], a
|
||||||
; Restore the flag state
|
; Restore the flag state
|
||||||
pop af
|
pop af
|
||||||
ld [wcfbe], a
|
ld [wcfbe], a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user