2015-07-17 04:21:57 +00:00
|
|
|
; performs the appropriate action when the player uses the gameboy on the table in the Colosseum or Trade Center
|
|
|
|
; In the Colosseum, it starts a battle. In the Trade Center, it displays the trade selection screen.
|
2015-02-07 10:43:08 +00:00
|
|
|
; Before doing either action, it swaps random numbers, trainer names and party data with the other gameboy.
|
|
|
|
CableClub_DoBattleOrTrade: ; 5317 (1:5317)
|
2015-07-03 19:37:53 +00:00
|
|
|
ld c, 80
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
|
|
|
call ClearScreen
|
|
|
|
call UpdateSprites
|
|
|
|
call LoadFontTilePatterns
|
|
|
|
call LoadHpBarAndStatusTilePatterns
|
|
|
|
call LoadTrainerInfoTextBoxTiles
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 3, 8
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 2
|
|
|
|
ld c, 12
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 4, 10
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, PleaseWaitString
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wPlayerNumHits
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], $50
|
2015-02-07 10:43:08 +00:00
|
|
|
; fall through
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
; This is called after completing a trade.
|
|
|
|
CableClub_DoBattleOrTradeAgain: ; 5345
|
|
|
|
ld hl, wSerialPlayerDataBlock
|
|
|
|
ld a, SERIAL_PREAMBLE_BYTE
|
|
|
|
ld b, 6
|
|
|
|
.writePlayeDataBlockPreambleLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .writePlayeDataBlockPreambleLoop
|
|
|
|
ld hl, wSerialRandomNumberListBlock
|
|
|
|
ld a, SERIAL_PREAMBLE_BYTE
|
|
|
|
ld b, 7
|
|
|
|
.writeRandomNumberListPreambleLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .writeRandomNumberListPreambleLoop
|
|
|
|
ld b, 10
|
|
|
|
.generateRandomNumberListLoop
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
2015-02-07 10:43:08 +00:00
|
|
|
cp SERIAL_PREAMBLE_BYTE ; all the random numbers have to be less than the preamble byte
|
|
|
|
jr nc, .generateRandomNumberListLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .generateRandomNumberListLoop
|
|
|
|
ld hl, wSerialPartyMonsPatchList
|
|
|
|
ld a, SERIAL_PREAMBLE_BYTE
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld b, $c8
|
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
.zeroPlayerDataPatchListLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .zeroPlayerDataPatchListLoop
|
|
|
|
ld hl, W_GRASSRATE
|
|
|
|
ld bc, W_TRAINERHEADERPTR - W_GRASSRATE
|
|
|
|
.zeroEnemyPartyLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
dec bc
|
|
|
|
ld a, b
|
|
|
|
or c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .zeroEnemyPartyLoop
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wPartyMons - 1
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wSerialPartyMonsPatchList + 10
|
|
|
|
ld bc, 0
|
|
|
|
.patchPartyMonsLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
inc c
|
|
|
|
ld a, c
|
2015-02-07 10:43:08 +00:00
|
|
|
cp SERIAL_PREAMBLE_BYTE
|
|
|
|
jr z, .startPatchListPart2
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, b
|
2015-02-07 10:43:08 +00:00
|
|
|
dec a ; are we in part 2 of the patch list?
|
|
|
|
jr nz, .checkPlayerDataByte ; jump if in part 1
|
|
|
|
; if we're in part 2
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c
|
2015-02-07 10:43:08 +00:00
|
|
|
cp (wPartyMonOT - (wPartyMons - 1)) - (SERIAL_PREAMBLE_BYTE - 1)
|
|
|
|
jr z, .finishedPatchingPlayerData
|
|
|
|
.checkPlayerDataByte
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2015-02-07 10:43:08 +00:00
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr nz, .patchPartyMonsLoop
|
|
|
|
; if the player data byte matches SERIAL_NO_DATA_BYTE, patch it with $FF and record the offset in the patch list
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [hl], $ff
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .patchPartyMonsLoop
|
|
|
|
.startPatchListPart2
|
|
|
|
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
|
|
|
ld [de], a ; end of part 1
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 1, 0
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .patchPartyMonsLoop
|
|
|
|
.finishedPatchingPlayerData
|
|
|
|
ld a, SERIAL_PATCH_LIST_PART_TERMINATOR
|
|
|
|
ld [de], a ; end of part 2
|
|
|
|
call Serial_SyncAndExchangeNybble
|
|
|
|
ld a, [hSerialConnectionStatus]
|
|
|
|
cp USING_INTERNAL_CLOCK
|
|
|
|
jr nz, .skipSendingTwoZeroBytes
|
|
|
|
; if using internal clock
|
|
|
|
; send two zero bytes for syncing purposes?
|
2014-05-22 22:13:20 +00:00
|
|
|
call Delay3
|
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [hSerialSendData], a
|
|
|
|
ld a, START_TRANSFER_INTERNAL_CLOCK
|
|
|
|
ld [rSC], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrame
|
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [hSerialSendData], a
|
|
|
|
ld a, START_TRANSFER_INTERNAL_CLOCK
|
|
|
|
ld [rSC], a
|
|
|
|
.skipSendingTwoZeroBytes
|
2014-05-22 22:13:20 +00:00
|
|
|
call Delay3
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, (1 << SERIAL)
|
|
|
|
ld [rIE], a
|
|
|
|
ld hl, wSerialRandomNumberListBlock
|
|
|
|
ld de, wSerialOtherGameboyRandomNumberListBlock
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc, $11
|
2015-02-07 10:43:08 +00:00
|
|
|
call Serial_ExchangeBytes
|
|
|
|
ld a, SERIAL_NO_DATA_BYTE
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wSerialPlayerDataBlock
|
|
|
|
ld de, wSerialEnemyDataBlock
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc, $1a8
|
2015-02-07 10:43:08 +00:00
|
|
|
call Serial_ExchangeBytes
|
|
|
|
ld a, SERIAL_NO_DATA_BYTE
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wSerialPartyMonsPatchList
|
|
|
|
ld de, wSerialEnemyMonsPatchList
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc, $c8
|
2015-02-07 10:43:08 +00:00
|
|
|
call Serial_ExchangeBytes
|
|
|
|
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
|
|
|
|
ld [rIE], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $ff
|
|
|
|
call PlaySound
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [hSerialConnectionStatus]
|
|
|
|
cp USING_INTERNAL_CLOCK
|
|
|
|
jr z, .skipCopyingRandomNumberList ; the list generated by the gameboy clocking the connection is used by both gameboys
|
|
|
|
ld hl, wSerialOtherGameboyRandomNumberListBlock
|
|
|
|
.findStartOfRandomNumberListLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jr z, .findStartOfRandomNumberListLoop
|
|
|
|
cp SERIAL_PREAMBLE_BYTE
|
|
|
|
jr z, .findStartOfRandomNumberListLoop
|
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .findStartOfRandomNumberListLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wLinkBattleRandomNumberList
|
|
|
|
ld c, 10
|
|
|
|
.copyRandomNumberListLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
2015-02-07 10:43:08 +00:00
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .copyRandomNumberListLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .copyRandomNumberListLoop
|
|
|
|
.skipCopyingRandomNumberList
|
|
|
|
ld hl, wSerialEnemyDataBlock + 3
|
|
|
|
.findStartOfEnemyNameLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jr z, .findStartOfEnemyNameLoop
|
|
|
|
cp SERIAL_PREAMBLE_BYTE
|
|
|
|
jr z, .findStartOfEnemyNameLoop
|
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .findStartOfEnemyNameLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wLinkEnemyTrainerName
|
2015-08-11 04:51:20 +00:00
|
|
|
ld c, NAME_LENGTH
|
2015-02-07 10:43:08 +00:00
|
|
|
.copyEnemyNameLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
2015-02-07 10:43:08 +00:00
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .copyEnemyNameLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .copyEnemyNameLoop
|
|
|
|
ld de, wEnemyPartyCount
|
|
|
|
ld bc, W_TRAINERHEADERPTR - wEnemyPartyCount
|
|
|
|
.copyEnemyPartyLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
2015-02-07 10:43:08 +00:00
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .copyEnemyPartyLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec bc
|
|
|
|
ld a, b
|
|
|
|
or c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .copyEnemyPartyLoop
|
|
|
|
ld de, wSerialPartyMonsPatchList
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wPartyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 2 ; patch list has 2 parts
|
|
|
|
.unpatchPartyMonsLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jr z, .unpatchPartyMonsLoop
|
|
|
|
cp SERIAL_PREAMBLE_BYTE
|
|
|
|
jr z, .unpatchPartyMonsLoop
|
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .unpatchPartyMonsLoop
|
|
|
|
cp SERIAL_PATCH_LIST_PART_TERMINATOR
|
|
|
|
jr z, .finishedPartyMonsPatchListPart
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
2014-06-14 11:12:40 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, SERIAL_NO_DATA_BYTE
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .unpatchPartyMonsLoop
|
|
|
|
.finishedPartyMonsPatchListPart
|
|
|
|
ld hl, wPartyMons + (SERIAL_PREAMBLE_BYTE - 1)
|
|
|
|
dec c ; is there another part?
|
|
|
|
jr nz, .unpatchPartyMonsLoop
|
|
|
|
ld de, wSerialEnemyMonsPatchList
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wEnemyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 2 ; patch list has 2 parts
|
|
|
|
.unpatchEnemyMonsLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jr z, .unpatchEnemyMonsLoop
|
|
|
|
cp SERIAL_PREAMBLE_BYTE
|
|
|
|
jr z, .unpatchEnemyMonsLoop
|
|
|
|
cp SERIAL_NO_DATA_BYTE
|
|
|
|
jr z, .unpatchEnemyMonsLoop
|
|
|
|
cp SERIAL_PATCH_LIST_PART_TERMINATOR
|
|
|
|
jr z, .finishedEnemyMonsPatchListPart
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, SERIAL_NO_DATA_BYTE
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .unpatchEnemyMonsLoop
|
|
|
|
.finishedEnemyMonsPatchListPart
|
|
|
|
ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1)
|
2014-05-22 22:13:20 +00:00
|
|
|
dec c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .unpatchEnemyMonsLoop
|
|
|
|
ld a, wEnemyMonOT % $100
|
2015-08-07 19:39:29 +00:00
|
|
|
ld [wUnusedCF8D], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, wEnemyMonOT / $100
|
2015-08-07 19:39:29 +00:00
|
|
|
ld [wUnusedCF8D + 1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradeCenterPointerTableIndex], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $ff
|
|
|
|
call PlaySound
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [hSerialConnectionStatus]
|
|
|
|
cp USING_INTERNAL_CLOCK
|
|
|
|
ld c, 66
|
|
|
|
call z, DelayFrames ; delay if using internal clock
|
|
|
|
ld a, [wLinkState]
|
|
|
|
cp LINK_STATE_START_BATTLE
|
|
|
|
ld a, LINK_STATE_TRADING
|
|
|
|
ld [wLinkState], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz, .asm_5506
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, LINK_STATE_BATTLING
|
|
|
|
ld [wLinkState], a
|
2015-08-10 16:09:16 +00:00
|
|
|
ld a, OPP_SONY1
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [W_CUROPPONENT], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call ClearScreen
|
|
|
|
call Delay3
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, W_OPTIONS
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-06-16 20:57:26 +00:00
|
|
|
predef InitOpponent
|
|
|
|
predef HealParty
|
2015-02-07 10:43:08 +00:00
|
|
|
jp ReturnToCableClubRoom
|
2014-05-22 22:13:20 +00:00
|
|
|
.asm_5506
|
|
|
|
ld c, BANK(Music_GameCorner)
|
|
|
|
ld a, MUSIC_GAME_CORNER
|
|
|
|
call PlayMusic
|
2015-02-07 10:43:08 +00:00
|
|
|
jr CallCurrentTradeCenterFunction
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
PleaseWaitString: ; 550f (1:550f)
|
|
|
|
db "PLEASE WAIT!@"
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
CallCurrentTradeCenterFunction:
|
|
|
|
ld hl, TradeCenterPointerTable
|
|
|
|
ld b, 0
|
|
|
|
ld a, [wTradeCenterPointerTableIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $ff
|
2015-07-19 03:49:52 +00:00
|
|
|
jp z, DisplayTitleScreen
|
2014-05-22 22:13:20 +00:00
|
|
|
add a
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jp [hl]
|
|
|
|
|
|
|
|
TradeCenter_SelectMon:
|
|
|
|
call ClearScreen
|
|
|
|
call LoadTrainerInfoTextBoxTiles
|
2015-02-07 10:43:08 +00:00
|
|
|
call TradeCenter_DrawPartyLists
|
|
|
|
call TradeCenter_DrawCancelBox
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wSerialSyncAndExchangeNybbleReceiveData
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2015-07-13 07:32:03 +00:00
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
|
|
|
ld [wLastMenuItem], a
|
|
|
|
ld [wMenuJoypadPollCount], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wSerialExchangeNybbleSendData], a
|
|
|
|
jp .playerMonMenu
|
|
|
|
.enemyMonMenu
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-13 07:32:03 +00:00
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wWhichTradeMonSelectionMenu], a
|
|
|
|
ld a, D_DOWN | D_LEFT | A_BUTTON
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMenuWatchedKeys], a
|
|
|
|
ld a, [wEnemyPartyCount]
|
|
|
|
ld [wMaxMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 9
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemY], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 1
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemX], a
|
2015-02-07 10:43:08 +00:00
|
|
|
.enemyMonMenu_HandleInput
|
2015-02-08 00:24:16 +00:00
|
|
|
ld hl, hFlags_0xFFF6
|
2014-05-22 22:13:20 +00:00
|
|
|
set 1, [hl]
|
|
|
|
call HandleMenuInput
|
2015-02-08 00:24:16 +00:00
|
|
|
ld hl, hFlags_0xFFF6
|
2014-05-22 22:13:20 +00:00
|
|
|
res 1, [hl]
|
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jp z, .getNewInput
|
|
|
|
bit 0, a ; A button pressed?
|
|
|
|
jr z, .enemyMonMenu_ANotPressed
|
|
|
|
; if A button pressed
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMaxMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr c, .displayEnemyMonStats
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMaxMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
.displayEnemyMonStats
|
2015-07-13 06:00:48 +00:00
|
|
|
ld a, INIT_ENEMYOT_LIST
|
|
|
|
ld [wInitListType], a
|
|
|
|
callab InitList ; the list isn't used
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, wEnemyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
call TradeCenter_DisplayStats
|
|
|
|
jp .getNewInput
|
|
|
|
.enemyMonMenu_ANotPressed
|
|
|
|
bit 5, a ; Left pressed?
|
|
|
|
jr z, .enemyMonMenu_LeftNotPressed
|
|
|
|
; if Left pressed, switch back to the player mon menu
|
|
|
|
xor a ; player mon menu
|
|
|
|
ld [wWhichTradeMonSelectionMenu], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMenuCursorLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld l, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMenuCursorLocation + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld h, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wTileBehindCursor]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a, [wPartyCount]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
cp b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nc, .playerMonMenu
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .playerMonMenu
|
|
|
|
.enemyMonMenu_LeftNotPressed
|
|
|
|
bit 7, a ; Down pressed?
|
|
|
|
jp z, .getNewInput
|
|
|
|
jp .selectedCancelMenuItem ; jump if Down pressed
|
|
|
|
.playerMonMenu
|
|
|
|
xor a ; player mon menu
|
|
|
|
ld [wWhichTradeMonSelectionMenu], a
|
2015-07-13 07:32:03 +00:00
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, D_DOWN | D_RIGHT | A_BUTTON
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMenuWatchedKeys], a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a, [wPartyCount]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMaxMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 1
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemY], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 1
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemX], a
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 1
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 6, 1
|
2014-05-22 22:13:20 +00:00
|
|
|
call ClearScreenArea
|
2015-02-07 10:43:08 +00:00
|
|
|
.playerMonMenu_HandleInput
|
2015-02-08 00:24:16 +00:00
|
|
|
ld hl, hFlags_0xFFF6
|
2014-05-22 22:13:20 +00:00
|
|
|
set 1, [hl]
|
|
|
|
call HandleMenuInput
|
2015-02-08 00:24:16 +00:00
|
|
|
ld hl, hFlags_0xFFF6
|
2014-05-22 22:13:20 +00:00
|
|
|
res 1, [hl]
|
2015-02-07 10:43:08 +00:00
|
|
|
and a ; was anything pressed?
|
|
|
|
jr nz, .playerMonMenu_SomethingPressed
|
|
|
|
jp .getNewInput
|
|
|
|
.playerMonMenu_SomethingPressed
|
|
|
|
bit 0, a ; A button pressed?
|
|
|
|
jr z, .playerMonMenu_ANotPressed
|
|
|
|
jp .chosePlayerMon ; jump if A button pressed
|
|
|
|
; unreachable code
|
2015-07-13 06:00:48 +00:00
|
|
|
ld a, INIT_PLAYEROT_LIST
|
|
|
|
ld [wInitListType], a
|
|
|
|
callab InitList ; the list isn't used
|
2015-02-07 10:43:08 +00:00
|
|
|
call TradeCenter_DisplayStats
|
|
|
|
jp .getNewInput
|
|
|
|
.playerMonMenu_ANotPressed
|
|
|
|
bit 4, a ; Right pressed?
|
|
|
|
jr z, .playerMonMenu_RightNotPressed
|
|
|
|
; if Right pressed, switch to the enemy mon menu
|
|
|
|
ld a, $1 ; enemy mon menu
|
|
|
|
ld [wWhichTradeMonSelectionMenu], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMenuCursorLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld l, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMenuCursorLocation + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld h, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wTileBehindCursor]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wEnemyPartyCount]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
cp b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nc, .notPastLastEnemyMon
|
|
|
|
; when switching to the enemy mon menu, if the menu selection would be past the last enemy mon, select the last enemy mon
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
.notPastLastEnemyMon
|
|
|
|
jp .enemyMonMenu
|
|
|
|
.playerMonMenu_RightNotPressed
|
|
|
|
bit 7, a ; Down pressed?
|
|
|
|
jr z, .getNewInput
|
|
|
|
jp .selectedCancelMenuItem ; jump if Down pressed
|
|
|
|
.getNewInput
|
|
|
|
ld a, [wWhichTradeMonSelectionMenu]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jp z, .playerMonMenu_HandleInput
|
|
|
|
jp .enemyMonMenu_HandleInput
|
|
|
|
.chosePlayerMon
|
2014-05-22 22:13:20 +00:00
|
|
|
call SaveScreenTilesToBuffer1
|
|
|
|
call PlaceUnfilledArrowMenuCursor
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMaxMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr c, .displayStatsTradeMenu
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMaxMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2015-02-07 10:43:08 +00:00
|
|
|
.displayStatsTradeMenu
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 14
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 2
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 16
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, .statsTrade
|
|
|
|
call PlaceString
|
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
|
|
|
ld [wLastMenuItem], a
|
|
|
|
ld [wMenuJoypadPollCount], a
|
|
|
|
ld [wMaxMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 16
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemY], a
|
2015-02-07 10:43:08 +00:00
|
|
|
.selectStatsMenuItem
|
|
|
|
ld a, " "
|
|
|
|
Coorda 11, 16
|
|
|
|
ld a, D_RIGHT | B_BUTTON | A_BUTTON
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMenuWatchedKeys], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 1
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemX], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call HandleMenuInput
|
2015-02-07 10:43:08 +00:00
|
|
|
bit 4, a ; Right pressed?
|
|
|
|
jr nz, .selectTradeMenuItem
|
|
|
|
bit 1, a ; B button pressed?
|
|
|
|
jr z, .displayPlayerMonStats
|
|
|
|
.cancelPlayerMonChoice
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadScreenTilesFromBuffer1
|
2015-02-07 10:43:08 +00:00
|
|
|
jp .playerMonMenu
|
|
|
|
.selectTradeMenuItem
|
|
|
|
ld a, " "
|
|
|
|
Coorda 1, 16
|
|
|
|
ld a, D_LEFT | B_BUTTON | A_BUTTON
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMenuWatchedKeys], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, 11
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemX], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call HandleMenuInput
|
2015-02-07 10:43:08 +00:00
|
|
|
bit 5, a ; Left pressed?
|
|
|
|
jr nz, .selectStatsMenuItem
|
|
|
|
bit 1, a ; B button pressed?
|
|
|
|
jr nz, .cancelPlayerMonChoice
|
|
|
|
jr .choseTrade
|
|
|
|
.displayPlayerMonStats
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2015-07-13 06:00:48 +00:00
|
|
|
ld a, INIT_PLAYEROT_LIST
|
|
|
|
ld [wInitListType], a
|
|
|
|
callab InitList ; the list isn't used
|
2015-02-07 10:43:08 +00:00
|
|
|
call TradeCenter_DisplayStats
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadScreenTilesFromBuffer1
|
2015-02-07 10:43:08 +00:00
|
|
|
jp .playerMonMenu
|
|
|
|
.choseTrade
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceUnfilledArrowMenuCursor
|
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradingWhichPlayerMon], a
|
|
|
|
ld [wSerialExchangeNybbleSendData], a
|
2015-02-07 11:04:50 +00:00
|
|
|
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wSerialSyncAndExchangeNybbleReceiveData]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $f
|
2015-02-07 10:43:08 +00:00
|
|
|
jp z, CallCurrentTradeCenterFunction ; go back to the beginning of the trade selection menu if the other person cancelled
|
|
|
|
ld [wTradingWhichEnemyMon], a
|
|
|
|
call TradeCenter_PlaceSelectedEnemyMonMenuCursor
|
|
|
|
ld a, $1 ; TradeCenter_Trade
|
|
|
|
ld [wTradeCenterPointerTableIndex], a
|
|
|
|
jp CallCurrentTradeCenterFunction
|
2014-05-22 22:13:20 +00:00
|
|
|
.statsTrade
|
|
|
|
db "STATS TRADE@"
|
2015-02-07 10:43:08 +00:00
|
|
|
.selectedCancelMenuItem
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMaxMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2015-02-07 10:43:08 +00:00
|
|
|
jp nz, .getNewInput
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMenuCursorLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld l, a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wMenuCursorLocation + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld h, a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, " "
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
2015-02-07 10:43:08 +00:00
|
|
|
.cancelMenuItem_Loop
|
|
|
|
ld a, $ed ; filled arrow cursor
|
|
|
|
Coorda 1, 16
|
|
|
|
.cancelMenuItem_JoypadLoop
|
2014-05-25 18:21:48 +00:00
|
|
|
call JoypadLowSensitivity
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [$ffb5]
|
|
|
|
and a ; pressed anything?
|
|
|
|
jr z, .cancelMenuItem_JoypadLoop
|
|
|
|
bit 0, a ; A button pressed?
|
|
|
|
jr nz, .cancelMenuItem_APressed
|
|
|
|
bit 6, a ; Up pressed?
|
|
|
|
jr z, .cancelMenuItem_JoypadLoop
|
|
|
|
; if Up pressed
|
|
|
|
ld a, " "
|
|
|
|
Coorda 1, 16
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a, [wPartyCount]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2015-02-07 10:43:08 +00:00
|
|
|
jp .playerMonMenu
|
|
|
|
.cancelMenuItem_APressed
|
|
|
|
ld a, $ec ; unfilled arrow cursor
|
|
|
|
Coorda 1, 16
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $f
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wSerialExchangeNybbleSendData], a
|
2015-02-07 11:04:50 +00:00
|
|
|
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wSerialSyncAndExchangeNybbleReceiveData]
|
|
|
|
cp $f ; did the other person choose Cancel too?
|
|
|
|
jr nz, .cancelMenuItem_Loop
|
|
|
|
; fall through
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
ReturnToCableClubRoom: ; 577d (1:577d)
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOutWithDelay3
|
2015-02-09 02:40:08 +00:00
|
|
|
ld hl, wFontLoaded
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
res 0, [hl]
|
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd72d], a
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wDestinationWarpID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadMapData
|
2014-09-14 18:29:18 +00:00
|
|
|
callba ClearVariablesAfterLoadingMapData
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
2014-09-13 07:50:56 +00:00
|
|
|
call GBFadeInFromWhite
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
TradeCenter_DrawCancelBox:
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 11, 15
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $7e
|
2015-08-10 04:56:20 +00:00
|
|
|
ld bc, 2 * SCREEN_WIDTH + 9
|
2014-05-22 22:13:20 +00:00
|
|
|
call FillMemory
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 15
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 1
|
|
|
|
ld c, 9
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 16
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, CancelTextString
|
|
|
|
jp PlaceString
|
|
|
|
|
|
|
|
CancelTextString:
|
|
|
|
db "CANCEL@"
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
TradeCenter_PlaceSelectedEnemyMonMenuCursor:
|
|
|
|
ld a, [wSerialSyncAndExchangeNybbleReceiveData]
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 9
|
2015-08-10 04:56:20 +00:00
|
|
|
ld bc, SCREEN_WIDTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [hl], $ec ; cursor
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
TradeCenter_DisplayStats:
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [wWhichPokemon], a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef StatusScreen
|
|
|
|
predef StatusScreen2
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalNormal
|
|
|
|
call LoadTrainerInfoTextBoxTiles
|
2015-02-07 10:43:08 +00:00
|
|
|
call TradeCenter_DrawPartyLists
|
|
|
|
jp TradeCenter_DrawCancelBox
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
TradeCenter_DrawPartyLists:
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 0
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 6
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 8
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 6
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 5, 0
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de, wPlayerName
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 5, 8
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wLinkEnemyTrainerName
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 1
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de, wPartySpecies
|
2015-02-07 10:43:08 +00:00
|
|
|
call TradeCenter_PrintPartyListNames
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 9
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wEnemyPartyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
; fall through
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
TradeCenter_PrintPartyListNames:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, $0
|
2015-02-07 10:43:08 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
cp $ff
|
|
|
|
ret z
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
ld a, c
|
|
|
|
ld [$ff95], a
|
|
|
|
call GetMonName
|
|
|
|
pop hl
|
|
|
|
call PlaceString
|
|
|
|
pop de
|
|
|
|
inc de
|
|
|
|
pop hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld bc, 20
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
inc c
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
TradeCenter_Trade:
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 100
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wSerialExchangeNybbleSendData + 1], a ; unnecessary
|
|
|
|
ld [wSerialExchangeNybbleReceiveData], a
|
2015-07-13 07:32:03 +00:00
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMenuJoypadPollCount], a
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 12
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 4
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
|
|
|
ld a, [wTradingWhichPlayerMon]
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wPartySpecies
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wcd6d
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wNameOfPlayerMonToBeTraded
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wTradingWhichEnemyMon]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wEnemyPartyMons
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
|
|
|
ld hl, WillBeTradedText
|
2015-07-18 20:52:03 +00:00
|
|
|
coord bc, 1, 14
|
2014-05-22 22:13:20 +00:00
|
|
|
call TextCommandProcessor
|
|
|
|
call SaveScreenTilesToBuffer1
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 10, 7
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 8, 11
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, TRADE_CANCEL_MENU
|
|
|
|
ld [wTwoOptionMenuID], a
|
2015-02-07 20:27:36 +00:00
|
|
|
ld a, TWO_OPTION_MENU
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTextBoxID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayTextBoxID
|
|
|
|
call LoadScreenTilesFromBuffer1
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-02-07 10:43:08 +00:00
|
|
|
jr z, .tradeConfirmed
|
|
|
|
; if trade cancelled
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $1
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wSerialExchangeNybbleSendData], a
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 12
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 4
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 14
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, TradeCanceled
|
|
|
|
call PlaceString
|
2015-02-07 11:04:50 +00:00
|
|
|
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
|
2015-02-07 10:43:08 +00:00
|
|
|
jp .tradeCancelled
|
|
|
|
.tradeConfirmed
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $2
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wSerialExchangeNybbleSendData], a
|
2015-02-07 11:04:50 +00:00
|
|
|
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wSerialSyncAndExchangeNybbleReceiveData]
|
|
|
|
dec a ; did the other person cancel?
|
|
|
|
jr nz, .doTrade
|
|
|
|
; if the other person cancelled
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 12
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 4
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 14
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, TradeCanceled
|
|
|
|
call PlaceString
|
2015-02-07 10:43:08 +00:00
|
|
|
jp .tradeCancelled
|
|
|
|
.doTrade
|
|
|
|
ld a, [wTradingWhichPlayerMon]
|
|
|
|
ld hl, wPartyMonOT
|
2014-05-22 22:13:20 +00:00
|
|
|
call SkipFixedLengthTextEntries
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wTradedPlayerMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wPartyMon1Species
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wTradingWhichPlayerMon]
|
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2015-02-07 10:43:08 +00:00
|
|
|
ld bc, wPartyMon1OTID - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradedPlayerMonOTID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradedPlayerMonOTID + 1], a
|
|
|
|
ld a, [wTradingWhichEnemyMon]
|
|
|
|
ld hl, wEnemyMonOT
|
2014-05-22 22:13:20 +00:00
|
|
|
call SkipFixedLengthTextEntries
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wTradedEnemyMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
ld hl, wEnemyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wTradingWhichEnemyMon]
|
|
|
|
ld bc, wEnemyMon2 - wEnemyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2015-02-07 10:43:08 +00:00
|
|
|
ld bc, wEnemyMon1OTID - wEnemyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradedEnemyMonOTID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl]
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradedEnemyMonOTID + 1], a
|
|
|
|
ld a, [wTradingWhichPlayerMon]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [wWhichPokemon], a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wPartySpecies
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradedPlayerMonSpecies], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-13 06:36:56 +00:00
|
|
|
ld [wRemoveMonFromBox], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call RemovePokemon
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wTradingWhichEnemyMon]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
|
|
|
ld [wWhichPokemon], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wEnemyPartyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
ld d, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld e, a
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, wEnemyMons
|
|
|
|
ld a, c
|
2015-02-07 10:43:08 +00:00
|
|
|
ld bc, wEnemyMon2 - wEnemyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2015-02-08 02:37:40 +00:00
|
|
|
ld de, wLoadedMon
|
2015-02-07 10:43:08 +00:00
|
|
|
ld bc, wEnemyMon2 - wEnemyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
call AddEnemyMonToPlayerParty
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a, [wPartyCount]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld [wWhichPokemon], a
|
|
|
|
ld a, $1
|
2015-07-14 08:46:23 +00:00
|
|
|
ld [wForceEvolution], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wTradingWhichEnemyMon]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wEnemyPartyMons
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradedEnemyMonSpecies], a
|
2015-08-09 05:32:44 +00:00
|
|
|
ld a, 10
|
|
|
|
ld [wAudioFadeOutControl], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $2
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wAudioSavedROMBank], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, MUSIC_SAFARI_ZONE
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wNewSoundID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaySound
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 100
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
|
|
|
call ClearScreen
|
|
|
|
call LoadHpBarAndStatusTilePatterns
|
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcc5b], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [hSerialConnectionStatus]
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
|
|
|
jr z, .usingExternalClock
|
2015-03-14 22:25:21 +00:00
|
|
|
predef InternalClockTradeAnim
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .tradeCompleted
|
|
|
|
.usingExternalClock
|
2015-03-14 22:25:21 +00:00
|
|
|
predef ExternalClockTradeAnim
|
2015-02-07 10:43:08 +00:00
|
|
|
.tradeCompleted
|
2014-08-09 05:39:13 +00:00
|
|
|
callab TryEvolvingMon
|
2014-05-22 22:13:20 +00:00
|
|
|
call ClearScreen
|
|
|
|
call LoadTrainerInfoTextBoxTiles
|
2015-02-07 11:04:50 +00:00
|
|
|
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 40
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 12
|
2015-02-07 10:43:08 +00:00
|
|
|
ld b, 4
|
|
|
|
ld c, 18
|
|
|
|
call CableClub_TextBoxBorder
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 14
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, TradeCompleted
|
|
|
|
call PlaceString
|
2014-06-16 20:57:26 +00:00
|
|
|
predef SaveSAVtoSRAM2
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 50
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTradeCenterPointerTableIndex], a
|
|
|
|
jp CableClub_DoBattleOrTradeAgain
|
|
|
|
.tradeCancelled
|
|
|
|
ld c, 100
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
2015-02-07 10:43:08 +00:00
|
|
|
xor a ; TradeCenter_SelectMon
|
|
|
|
ld [wTradeCenterPointerTableIndex], a
|
|
|
|
jp CallCurrentTradeCenterFunction
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
WillBeTradedText: ; 5a24 (1:5a24)
|
|
|
|
TX_FAR _WillBeTradedText
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
TradeCompleted:
|
|
|
|
db "Trade completed!@"
|
|
|
|
|
|
|
|
TradeCanceled:
|
|
|
|
db "Too bad! The trade"
|
|
|
|
next "was canceled!@"
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
TradeCenterPointerTable: ; 5a5b (1:5a5b)
|
2014-05-22 22:13:20 +00:00
|
|
|
dw TradeCenter_SelectMon
|
|
|
|
dw TradeCenter_Trade
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
CableClub_Run: ; 5a5f (1:5a5f)
|
|
|
|
ld a, [wLinkState]
|
|
|
|
cp LINK_STATE_START_TRADE
|
|
|
|
jr z, .doBattleOrTrade
|
|
|
|
cp LINK_STATE_START_BATTLE
|
|
|
|
jr z, .doBattleOrTrade
|
|
|
|
cp LINK_STATE_RESET ; this is never used
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nz
|
2015-02-07 10:43:08 +00:00
|
|
|
predef EmptyFunc3
|
2014-05-23 22:34:35 +00:00
|
|
|
jp Init
|
2015-02-07 10:43:08 +00:00
|
|
|
.doBattleOrTrade
|
|
|
|
call CableClub_DoBattleOrTrade
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, Club_GFX
|
|
|
|
ld a, h
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [W_TILESETGFXPTR + 1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, l
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [W_TILESETGFXPTR], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, Bank(Club_GFX)
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [W_TILESETBANK], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, Club_Coll
|
|
|
|
ld a, h
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [W_TILESETCOLLISIONPTR + 1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, l
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [W_TILESETCOLLISIONPTR], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [W_GRASSRATE], a
|
|
|
|
inc a ; LINK_STATE_IN_CABLE_CLUB
|
|
|
|
ld [wLinkState], a
|
|
|
|
ld [$ffb5], a
|
2015-08-09 05:32:44 +00:00
|
|
|
ld a, 10
|
|
|
|
ld [wAudioFadeOutControl], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, BANK(Music_Celadon)
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wAudioSavedROMBank], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, MUSIC_CELADON
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wNewSoundID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PlaySound
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
EmptyFunc3: ; 5aaf (1:5aaf)
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
Diploma_TextBoxBorder: ; 5ab0 (1:5ab0)
|
2014-05-23 22:11:09 +00:00
|
|
|
call GetPredefRegisters
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
; b = height
|
|
|
|
; c = width
|
|
|
|
CableClub_TextBoxBorder: ; 5ab3 (1:5ab3)
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, $78 ; border upper left corner tile
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
2015-02-07 10:43:08 +00:00
|
|
|
inc a ; border top horizontal line tile
|
|
|
|
call CableClub_DrawHorizontalLine
|
|
|
|
inc a ; border upper right corner tile
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl], a
|
|
|
|
pop hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, 20
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, de
|
2015-02-07 10:43:08 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, $7b ; border left vertical line tile
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, " "
|
|
|
|
call CableClub_DrawHorizontalLine
|
|
|
|
ld [hl], $77 ; border right vertical line tile
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, 20
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, de
|
|
|
|
dec b
|
2015-02-07 10:43:08 +00:00
|
|
|
jr nz, .loop
|
|
|
|
ld a, $7c ; border lower left corner tile
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli], a
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, $76 ; border bottom horizontal line tile
|
|
|
|
call CableClub_DrawHorizontalLine
|
|
|
|
ld [hl], $7d ; border lower right corner tile
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
; c = width
|
|
|
|
CableClub_DrawHorizontalLine: ; 5ae0 (1:5ae0)
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d, c
|
|
|
|
.asm_5ae1
|
|
|
|
ld [hli], a
|
|
|
|
dec d
|
|
|
|
jr nz, .asm_5ae1
|
|
|
|
ret
|