pokered/engine/movie/trade.asm

854 lines
17 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
InternalClockTradeAnim:
2015-03-14 22:25:21 +00:00
; Do the trading animation with the player's gameboy on the left.
; In-game trades and internally clocked link cable trades use this.
2015-02-07 10:43:08 +00:00
ld a, [wTradedPlayerMonSpecies]
2015-03-14 22:25:21 +00:00
ld [wLeftGBMonSpecies], a
2015-02-07 10:43:08 +00:00
ld a, [wTradedEnemyMonSpecies]
2015-03-14 22:25:21 +00:00
ld [wRightGBMonSpecies], a
ld de, InternalClockTradeFuncSequence
jr TradeAnimCommon
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
ExternalClockTradeAnim:
2015-03-14 22:25:21 +00:00
; Do the trading animation with the player's gameboy on the right.
; Externally clocked link cable trades use this.
2015-02-07 10:43:08 +00:00
ld a, [wTradedEnemyMonSpecies]
2015-03-14 22:25:21 +00:00
ld [wLeftGBMonSpecies], a
2015-03-15 01:29:53 +00:00
ld a, [wTradedPlayerMonSpecies]
2015-03-14 22:25:21 +00:00
ld [wRightGBMonSpecies], a
ld de, ExternalClockTradeFuncSequence
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeAnimCommon:
2015-08-31 02:38:41 +00:00
ld a, [wOptions]
2014-05-22 22:13:20 +00:00
push af
ldh a, [hSCY]
2014-05-22 22:13:20 +00:00
push af
ldh a, [hSCX]
2014-05-22 22:13:20 +00:00
push af
xor a
2015-08-31 02:38:41 +00:00
ld [wOptions], a
ldh [hSCY], a
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
push de
2015-03-14 22:25:21 +00:00
.loop
2014-05-22 22:13:20 +00:00
pop de
ld a, [de]
cp $ff
2015-03-14 22:25:21 +00:00
jr z, .done
2014-05-22 22:13:20 +00:00
inc de
push de
2015-03-14 22:25:21 +00:00
ld hl, TradeFuncPointerTable
2014-05-22 22:13:20 +00:00
add a
ld c, a
ld b, $0
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
2015-03-14 22:25:21 +00:00
ld de, .loop
2014-05-22 22:13:20 +00:00
push de
jp hl ; call trade func, which will return to the top of the loop
2015-03-14 22:25:21 +00:00
.done
2014-05-22 22:13:20 +00:00
pop af
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
pop af
ldh [hSCY], a
2014-05-22 22:13:20 +00:00
pop af
2015-08-31 02:38:41 +00:00
ld [wOptions], a
2014-05-22 22:13:20 +00:00
ret
2015-03-14 22:25:21 +00:00
addtradefunc: MACRO
\1TradeFunc::
dw \1
ENDM
tradefunc: MACRO
db (\1TradeFunc - TradeFuncPointerTable) / 2
ENDM
; The functions in the sequences below are executed in order by TradeFuncCommon.
; They are from opposite perspectives. The external clock one makes use of
; Trade_SwapNames to swap the player and enemy names for some functions.
2016-06-12 00:24:04 +00:00
InternalClockTradeFuncSequence:
2015-03-14 22:25:21 +00:00
tradefunc LoadTradingGFXAndMonNames
tradefunc Trade_ShowPlayerMon
tradefunc Trade_DrawOpenEndOfLinkCable
tradefunc Trade_AnimateBallEnteringLinkCable
tradefunc Trade_AnimLeftToRight
tradefunc Trade_Delay100
tradefunc Trade_ShowClearedWindow
tradefunc PrintTradeWentToText
tradefunc PrintTradeForSendsText
tradefunc PrintTradeFarewellText
tradefunc Trade_AnimRightToLeft
tradefunc Trade_ShowClearedWindow
tradefunc Trade_DrawOpenEndOfLinkCable
tradefunc Trade_ShowEnemyMon
tradefunc Trade_Delay100
tradefunc Trade_Cleanup
db $FF
2016-06-12 00:24:04 +00:00
ExternalClockTradeFuncSequence:
2015-03-14 22:25:21 +00:00
tradefunc LoadTradingGFXAndMonNames
tradefunc Trade_ShowClearedWindow
tradefunc PrintTradeWillTradeText
tradefunc PrintTradeFarewellText
tradefunc Trade_SwapNames
tradefunc Trade_AnimLeftToRight
tradefunc Trade_SwapNames
tradefunc Trade_ShowClearedWindow
tradefunc Trade_DrawOpenEndOfLinkCable
tradefunc Trade_ShowEnemyMon
tradefunc Trade_SlideTextBoxOffScreen
tradefunc Trade_ShowPlayerMon
tradefunc Trade_DrawOpenEndOfLinkCable
tradefunc Trade_AnimateBallEnteringLinkCable
tradefunc Trade_SwapNames
tradefunc Trade_AnimRightToLeft
tradefunc Trade_SwapNames
tradefunc Trade_Delay100
tradefunc Trade_ShowClearedWindow
tradefunc PrintTradeWentToText
tradefunc Trade_Cleanup
db $FF
2016-06-12 00:24:04 +00:00
TradeFuncPointerTable:
2015-03-14 22:25:21 +00:00
addtradefunc LoadTradingGFXAndMonNames
addtradefunc Trade_ShowPlayerMon
addtradefunc Trade_DrawOpenEndOfLinkCable
addtradefunc Trade_AnimateBallEnteringLinkCable
addtradefunc Trade_ShowEnemyMon
addtradefunc Trade_AnimLeftToRight
addtradefunc Trade_AnimRightToLeft
addtradefunc Trade_Delay100
addtradefunc Trade_ShowClearedWindow
addtradefunc PrintTradeWentToText
addtradefunc PrintTradeForSendsText
addtradefunc PrintTradeFarewellText
addtradefunc PrintTradeTakeCareText
addtradefunc PrintTradeWillTradeText
addtradefunc Trade_Cleanup
addtradefunc Trade_SlideTextBoxOffScreen
addtradefunc Trade_SwapNames
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Trade_Delay100:
2015-02-07 10:43:08 +00:00
ld c, 100
2014-05-22 22:13:20 +00:00
jp DelayFrames
2016-06-12 00:24:04 +00:00
Trade_CopyTileMapToVRAM:
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call Delay3
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_Delay80:
2015-02-07 10:43:08 +00:00
ld c, 80
2014-05-22 22:13:20 +00:00
jp DelayFrames
2016-06-12 00:24:04 +00:00
Trade_ClearTileMap:
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-08-10 04:56:20 +00:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-02-07 10:43:08 +00:00
ld a, " "
2014-05-22 22:13:20 +00:00
jp FillMemory
2016-06-12 00:24:04 +00:00
LoadTradingGFXAndMonNames:
2015-02-07 10:43:08 +00:00
call Trade_ClearTileMap
2014-05-22 22:13:20 +00:00
call DisableLCD
2015-02-07 10:43:08 +00:00
ld hl, TradingAnimationGraphics
2014-05-29 08:31:46 +00:00
ld de, vChars2 + $310
2015-08-10 04:56:20 +00:00
ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics
2014-05-22 22:13:20 +00:00
ld a, BANK(TradingAnimationGraphics)
call FarCopyData2
2015-02-07 10:43:08 +00:00
ld hl, TradingAnimationGraphics2
2014-05-29 08:31:46 +00:00
ld de, vSprites + $7c0
2015-08-10 04:56:20 +00:00
ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2
2014-05-22 22:13:20 +00:00
ld a, BANK(TradingAnimationGraphics2)
call FarCopyData2
2014-05-29 08:31:46 +00:00
ld hl, vBGMap0
2014-05-22 22:13:20 +00:00
ld bc, $800
2015-02-07 10:43:08 +00:00
ld a, " "
2014-05-22 22:13:20 +00:00
call FillMemory
2014-05-23 22:34:35 +00:00
call ClearSprites
2014-05-22 22:13:20 +00:00
ld a, $ff
2014-09-13 07:50:56 +00:00
ld [wUpdateSpritesEnabled], a
ld hl, wd730
2015-03-14 22:25:21 +00:00
set 6, [hl] ; turn on instant text printing
2014-09-13 07:50:56 +00:00
ld a, [wOnSGB]
2014-05-22 22:13:20 +00:00
and a
2015-03-14 22:25:21 +00:00
ld a, $e4 ; non-SGB OBP0
jr z, .next
ld a, $f0 ; SGB OBP0
.next
ldh [rOBP0], a
2014-05-22 22:13:20 +00:00
call EnableLCD
xor a
ldh [hAutoBGTransferEnabled], a
2015-02-07 10:43:08 +00:00
ld a, [wTradedPlayerMonSpecies]
ld [wd11e], a
2014-05-22 22:13:20 +00:00
call GetMonName
ld hl, wcd6d
ld de, wcf4b
ld bc, NAME_LENGTH
2014-05-22 22:13:20 +00:00
call CopyData
2015-02-07 10:43:08 +00:00
ld a, [wTradedEnemyMonSpecies]
ld [wd11e], a
2014-05-22 22:13:20 +00:00
jp GetMonName
2016-06-12 00:24:04 +00:00
Trade_LoadMonPartySpriteGfx:
2015-02-07 10:43:08 +00:00
ld a, %11010000
ldh [rOBP1], a
farjp LoadMonPartySpriteGfx
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Trade_SwapNames:
ld hl, wPlayerName
2015-02-07 10:43:08 +00:00
ld de, wBuffer
ld bc, NAME_LENGTH
2014-05-22 22:13:20 +00:00
call CopyData
2015-02-07 10:43:08 +00:00
ld hl, wLinkEnemyTrainerName
ld de, wPlayerName
ld bc, NAME_LENGTH
2014-05-22 22:13:20 +00:00
call CopyData
2015-02-07 10:43:08 +00:00
ld hl, wBuffer
ld de, wLinkEnemyTrainerName
ld bc, NAME_LENGTH
2014-05-22 22:13:20 +00:00
jp CopyData
2016-06-12 00:24:04 +00:00
Trade_Cleanup:
2014-05-22 22:13:20 +00:00
xor a
call LoadGBPal
ld hl, wd730
2015-03-14 22:25:21 +00:00
res 6, [hl] ; turn off instant text printing
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_ShowPlayerMon:
2015-02-07 10:43:08 +00:00
ld a, %10101011
ldh [rLCDC], a
2014-05-22 22:13:20 +00:00
ld a, $50
ldh [hWY], a
2014-05-22 22:13:20 +00:00
ld a, $86
ldh [rWX], a
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2015-07-18 20:52:03 +00:00
coord hl, 4, 0
2015-02-07 10:43:08 +00:00
ld b, 6
ld c, 10
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-02-07 10:43:08 +00:00
call Trade_PrintPlayerMonInfoText
2020-07-07 15:10:29 +00:00
ld b, HIGH(vBGMap0)
2014-05-22 22:13:20 +00:00
call CopyScreenTileBufferToVRAM
call ClearScreen
2015-02-07 10:43:08 +00:00
ld a, [wTradedPlayerMonSpecies]
call Trade_LoadMonSprite
2014-05-22 22:13:20 +00:00
ld a, $7e
2015-02-07 10:43:08 +00:00
.slideScreenLoop
2014-05-22 22:13:20 +00:00
push af
call DelayFrame
pop af
ldh [rWX], a
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
dec a
dec a
and a
2015-02-07 10:43:08 +00:00
jr nz, .slideScreenLoop
call Trade_Delay80
ld a, TRADE_BALL_POOF_ANIM
call Trade_ShowAnimation
ld a, TRADE_BALL_DROP_ANIM
2015-03-15 01:29:53 +00:00
call Trade_ShowAnimation ; clears mon pic
2015-02-07 10:43:08 +00:00
ld a, [wTradedPlayerMonSpecies]
2014-05-22 22:13:20 +00:00
call PlayCry
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_DrawOpenEndOfLinkCable:
2015-02-07 10:43:08 +00:00
call Trade_ClearTileMap
2020-07-07 15:10:29 +00:00
ld b, HIGH(vBGMap0)
2014-05-22 22:13:20 +00:00
call CopyScreenTileBufferToVRAM
2015-08-12 09:16:56 +00:00
ld b, SET_PAL_GENERIC
call RunPaletteCommand
2015-03-15 01:29:53 +00:00
; This function call is pointless. It just copies blank tiles to VRAM that was
; already filled with blank tiles.
2014-05-29 08:31:46 +00:00
ld hl, vBGMap1 + $8c
2015-03-14 22:25:21 +00:00
call Trade_CopyCableTilesOffScreen
2015-03-15 01:29:53 +00:00
2014-05-22 22:13:20 +00:00
ld a, $a0
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
call DelayFrame
2015-02-07 10:43:08 +00:00
ld a, %10001011
ldh [rLCDC], a
2015-07-18 20:52:03 +00:00
coord hl, 6, 2
2015-02-07 10:43:08 +00:00
ld b, $7 ; open end of link cable tile ID list index
call CopyTileIDsFromList_ZeroBaseTileID
call Trade_CopyTileMapToVRAM
2015-07-19 08:46:12 +00:00
ld a, SFX_HEAL_HP
2014-05-22 22:13:20 +00:00
call PlaySound
2015-02-07 10:43:08 +00:00
ld c, 20
.loop
ldh a, [hSCX]
2015-02-07 10:43:08 +00:00
add 4
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
dec c
2015-02-07 10:43:08 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_AnimateBallEnteringLinkCable:
2015-02-07 10:43:08 +00:00
ld a, TRADE_BALL_SHAKE_ANIM
call Trade_ShowAnimation
ld c, 10
2014-05-22 22:13:20 +00:00
call DelayFrames
2015-02-07 10:43:08 +00:00
ld a, %11100100
ldh [rOBP0], a
2014-05-22 22:13:20 +00:00
xor a
2015-07-24 21:39:45 +00:00
ld [wLinkCableAnimBulgeToggle], a
2016-06-12 04:30:05 +00:00
lb bc, $20, $60
2015-02-07 10:43:08 +00:00
.moveBallInsideLinkCableLoop
2014-05-22 22:13:20 +00:00
push bc
xor a
2015-02-07 10:43:08 +00:00
ld de, Trade_BallInsideLinkCableOAM
2014-05-22 22:13:20 +00:00
call WriteOAMBlock
2015-07-24 21:39:45 +00:00
ld a, [wLinkCableAnimBulgeToggle]
2014-05-22 22:13:20 +00:00
xor $1
2015-07-24 21:39:45 +00:00
ld [wLinkCableAnimBulgeToggle], a
2014-05-22 22:13:20 +00:00
add $7e
ld hl, wOAMBuffer + $02
2015-07-24 21:39:45 +00:00
ld de, 4
2014-05-22 22:13:20 +00:00
ld c, e
2015-07-24 21:39:45 +00:00
.cycleLinkCableBulgeTile
2014-05-22 22:13:20 +00:00
ld [hl], a
add hl, de
dec c
2015-07-24 21:39:45 +00:00
jr nz, .cycleLinkCableBulgeTile
2014-05-22 22:13:20 +00:00
call Delay3
pop bc
ld a, c
add $4
ld c, a
cp $a0
2015-02-07 10:43:08 +00:00
jr nc, .ballSpriteReachedEdgeOfScreen
2015-07-19 08:46:12 +00:00
ld a, SFX_TINK
2014-05-22 22:13:20 +00:00
call PlaySound
2015-02-07 10:43:08 +00:00
jr .moveBallInsideLinkCableLoop
.ballSpriteReachedEdgeOfScreen
2014-05-23 22:34:35 +00:00
call ClearSprites
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call ClearScreen
ld b, $98
call CopyScreenTileBufferToVRAM
call Delay3
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_BallInsideLinkCableOAM:
2014-05-22 22:13:20 +00:00
db $7E,$00,$7E,$20
db $7E,$40,$7E,$60
2016-06-12 00:24:04 +00:00
Trade_ShowEnemyMon:
2015-02-07 10:43:08 +00:00
ld a, TRADE_BALL_TILT_ANIM
call Trade_ShowAnimation
2015-03-14 22:25:21 +00:00
call Trade_ShowClearedWindow
2015-07-18 20:52:03 +00:00
coord hl, 4, 10
2015-02-07 10:43:08 +00:00
ld b, 6
ld c, 10
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-02-07 10:43:08 +00:00
call Trade_PrintEnemyMonInfoText
call Trade_CopyTileMapToVRAM
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2015-02-07 10:43:08 +00:00
ld a, [wTradedEnemyMonSpecies]
call Trade_LoadMonSprite
ld a, TRADE_BALL_POOF_ANIM
call Trade_ShowAnimation
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2015-02-07 10:43:08 +00:00
ld a, [wTradedEnemyMonSpecies]
2014-05-22 22:13:20 +00:00
call PlayCry
2015-02-07 10:43:08 +00:00
call Trade_Delay100
2015-07-18 20:52:03 +00:00
coord hl, 4, 10
2015-08-05 21:20:29 +00:00
lb bc, 8, 12
2014-05-22 22:13:20 +00:00
call ClearScreenArea
jp PrintTradeTakeCareText
2016-06-12 00:24:04 +00:00
Trade_AnimLeftToRight:
2015-03-14 22:25:21 +00:00
; Animates the mon moving from the left GB to the right one.
call Trade_InitGameboyTransferGfx
2014-05-22 22:13:20 +00:00
ld a, $1
2015-03-14 22:25:21 +00:00
ld [wTradedMonMovingRight], a
2016-06-12 04:30:05 +00:00
ld a, %11100100
ldh [rOBP0], a
2014-05-22 22:13:20 +00:00
ld a, $54
2015-08-31 02:38:41 +00:00
ld [wBaseCoordX], a
2014-05-22 22:13:20 +00:00
ld a, $1c
2015-08-31 02:38:41 +00:00
ld [wBaseCoordY], a
2015-03-14 22:25:21 +00:00
ld a, [wLeftGBMonSpecies]
ld [wMonPartySpriteSpecies], a
call Trade_WriteCircledMonOAM
call Trade_DrawLeftGameboy
2015-02-07 10:43:08 +00:00
call Trade_CopyTileMapToVRAM
2015-03-14 22:25:21 +00:00
call Trade_DrawCableAcrossScreen
2014-05-29 08:31:46 +00:00
ld hl, vBGMap1 + $8c
2015-03-14 22:25:21 +00:00
call Trade_CopyCableTilesOffScreen
2014-05-22 22:13:20 +00:00
ld b, $6
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveHorizontal
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2015-03-14 22:25:21 +00:00
call Trade_DrawCableAcrossScreen
2014-05-22 22:13:20 +00:00
ld b, $4
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveHorizontal
call Trade_DrawRightGameboy
2014-05-22 22:13:20 +00:00
ld b, $6
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveHorizontal
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveVertical
2014-05-23 22:34:35 +00:00
jp ClearSprites
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Trade_AnimRightToLeft:
2015-03-14 22:25:21 +00:00
; Animates the mon moving from the right GB to the left one.
call Trade_InitGameboyTransferGfx
2014-05-22 22:13:20 +00:00
xor a
2015-03-14 22:25:21 +00:00
ld [wTradedMonMovingRight], a
2014-05-22 22:13:20 +00:00
ld a, $64
2015-08-31 02:38:41 +00:00
ld [wBaseCoordX], a
2014-05-22 22:13:20 +00:00
ld a, $44
2015-08-31 02:38:41 +00:00
ld [wBaseCoordY], a
2015-03-14 22:25:21 +00:00
ld a, [wRightGBMonSpecies]
ld [wMonPartySpriteSpecies], a
call Trade_WriteCircledMonOAM
call Trade_DrawRightGameboy
2015-02-07 10:43:08 +00:00
call Trade_CopyTileMapToVRAM
2015-03-14 22:25:21 +00:00
call Trade_DrawCableAcrossScreen
2014-05-29 08:31:46 +00:00
ld hl, vBGMap1 + $94
2015-03-14 22:25:21 +00:00
call Trade_CopyCableTilesOffScreen
call Trade_AnimMonMoveVertical
2014-05-22 22:13:20 +00:00
ld b, $6
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveHorizontal
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2015-03-14 22:25:21 +00:00
call Trade_DrawCableAcrossScreen
2014-05-22 22:13:20 +00:00
ld b, $4
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveHorizontal
call Trade_DrawLeftGameboy
2014-05-22 22:13:20 +00:00
ld b, $6
2015-03-14 22:25:21 +00:00
call Trade_AnimMonMoveHorizontal
2014-05-22 22:13:20 +00:00
xor a
ldh [hAutoBGTransferEnabled], a
2014-05-23 22:34:35 +00:00
jp ClearSprites
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Trade_InitGameboyTransferGfx:
2015-03-14 22:25:21 +00:00
; Initialises the graphics for showing a mon moving between gameboys.
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call ClearScreen
xor a
ldh [hAutoBGTransferEnabled], a
2015-03-14 22:25:21 +00:00
call Trade_LoadMonPartySpriteGfx
2014-05-22 22:13:20 +00:00
call DelayFrame
2015-02-07 10:43:08 +00:00
ld a, %10101011
ldh [rLCDC], a
2014-05-22 22:13:20 +00:00
xor a
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
ld a, $90
ldh [hWY], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_DrawLeftGameboy:
2015-02-07 10:43:08 +00:00
call Trade_ClearTileMap
2015-03-14 22:25:21 +00:00
; draw link cable
2015-07-18 20:52:03 +00:00
coord hl, 11, 4
2014-05-22 22:13:20 +00:00
ld a, $5d
ld [hli], a
ld a, $5e
2016-06-12 04:30:05 +00:00
ld c, 8
2015-03-14 22:25:21 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld [hli], a
dec c
2015-03-14 22:25:21 +00:00
jr nz, .loop
; draw gameboy pic
2015-07-18 20:52:03 +00:00
coord hl, 5, 3
2014-05-22 22:13:20 +00:00
ld b, $6
2015-02-07 10:43:08 +00:00
call CopyTileIDsFromList_ZeroBaseTileID
2015-03-14 22:25:21 +00:00
; draw text box with player name below gameboy pic
2015-07-18 20:52:03 +00:00
coord hl, 4, 12
2015-02-07 10:43:08 +00:00
ld b, 2
ld c, 7
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 5, 14
2015-02-07 10:43:08 +00:00
ld de, wPlayerName
2014-05-22 22:13:20 +00:00
call PlaceString
2015-03-14 22:25:21 +00:00
2014-05-22 22:13:20 +00:00
jp DelayFrame
2016-06-12 00:24:04 +00:00
Trade_DrawRightGameboy:
2015-02-07 10:43:08 +00:00
call Trade_ClearTileMap
2015-03-14 22:25:21 +00:00
; draw horizontal segment of link cable
2015-07-18 20:52:03 +00:00
coord hl, 0, 4
2014-05-22 22:13:20 +00:00
ld a, $5e
ld c, $e
2015-03-14 22:25:21 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld [hli], a
dec c
2015-03-14 22:25:21 +00:00
jr nz, .loop
; draw vertical segment of link cable
2014-05-22 22:13:20 +00:00
ld a, $5f
ld [hl], a
2015-03-14 22:25:21 +00:00
ld de, SCREEN_WIDTH
2014-05-22 22:13:20 +00:00
add hl, de
ld a, $61
ld [hl], a
add hl, de
ld [hl], a
add hl, de
ld [hl], a
add hl, de
ld [hl], a
add hl, de
ld a, $60
ld [hld], a
ld a, $5d
ld [hl], a
2015-03-14 22:25:21 +00:00
; draw gameboy pic
2015-07-18 20:52:03 +00:00
coord hl, 7, 8
2014-05-22 22:13:20 +00:00
ld b, $6
2015-02-07 10:43:08 +00:00
call CopyTileIDsFromList_ZeroBaseTileID
2015-03-14 22:25:21 +00:00
; draw text box with enemy name above link cable
2015-07-18 20:52:03 +00:00
coord hl, 6, 0
2016-06-12 04:30:05 +00:00
ld b, 2
ld c, 7
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 7, 2
2015-02-07 10:43:08 +00:00
ld de, wLinkEnemyTrainerName
2014-05-22 22:13:20 +00:00
call PlaceString
2015-03-14 22:25:21 +00:00
2014-05-22 22:13:20 +00:00
jp DelayFrame
2016-06-12 00:24:04 +00:00
Trade_DrawCableAcrossScreen:
2015-03-14 22:25:21 +00:00
; Draws the link cable across the screen.
2015-02-07 10:43:08 +00:00
call Trade_ClearTileMap
2015-07-18 20:52:03 +00:00
coord hl, 0, 4
2014-05-22 22:13:20 +00:00
ld a, $5e
2015-03-14 22:25:21 +00:00
ld c, SCREEN_WIDTH
.loop
2014-05-22 22:13:20 +00:00
ld [hli], a
dec c
2015-03-14 22:25:21 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_CopyCableTilesOffScreen:
2015-03-14 22:25:21 +00:00
; This is used to copy the link cable tiles off screen so that the cable
; continues when the screen is scrolled.
2014-05-22 22:13:20 +00:00
push hl
2015-07-18 20:52:03 +00:00
coord hl, 0, 4
call CopyToRedrawRowOrColumnSrcTiles
2014-05-22 22:13:20 +00:00
pop hl
ld a, h
ldh [hRedrawRowOrColumnDest + 1], a
2014-05-22 22:13:20 +00:00
ld a, l
ldh [hRedrawRowOrColumnDest], a
ld a, REDRAW_ROW
ldh [hRedrawRowOrColumnMode], a
2015-02-07 10:43:08 +00:00
ld c, 10
2014-05-22 22:13:20 +00:00
jp DelayFrames
2016-06-12 00:24:04 +00:00
Trade_AnimMonMoveHorizontal:
2015-03-14 22:25:21 +00:00
; Animates the mon going through the link cable horizontally over a distance of
; b 16-pixel units.
ld a, [wTradedMonMovingRight]
2014-05-22 22:13:20 +00:00
ld e, a
ld d, $8
2015-03-14 22:25:21 +00:00
.scrollLoop
2014-05-22 22:13:20 +00:00
ld a, e
dec a
2015-03-14 22:25:21 +00:00
jr z, .movingRight
; moving left
ldh a, [hSCX]
2014-05-22 22:13:20 +00:00
sub $2
2015-03-14 22:25:21 +00:00
jr .next
.movingRight
ldh a, [hSCX]
2014-05-22 22:13:20 +00:00
add $2
2015-03-14 22:25:21 +00:00
.next
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
call DelayFrame
dec d
2015-03-14 22:25:21 +00:00
jr nz, .scrollLoop
call Trade_AnimCircledMon
2014-05-22 22:13:20 +00:00
dec b
2015-03-14 22:25:21 +00:00
jr nz, Trade_AnimMonMoveHorizontal
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_AnimCircledMon:
2015-03-14 22:25:21 +00:00
; Cycles between the two animation frames of the mon party sprite, cycles
; between a circle and an oval around the mon sprite, and makes the cable flash.
2014-05-22 22:13:20 +00:00
push de
push bc
push hl
ldh a, [rBGP]
2015-03-14 22:25:21 +00:00
xor $3c ; make link cable flash
ldh [rBGP], a
ld hl, wOAMBuffer + $02
2014-05-22 22:13:20 +00:00
ld de, $4
ld c, $14
2015-03-14 22:25:21 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld a, [hl]
xor $40
ld [hl], a
add hl, de
dec c
2015-03-14 22:25:21 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
pop hl
pop bc
pop de
ret
2016-06-12 00:24:04 +00:00
Trade_WriteCircledMonOAM:
farcall WriteMonPartySpriteOAMBySpecies
2015-03-14 22:25:21 +00:00
call Trade_WriteCircleOAM
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Trade_AddOffsetsToOAMCoords:
2014-05-22 22:13:20 +00:00
ld hl, wOAMBuffer
ld c, $14
2015-03-14 22:25:21 +00:00
.loop
2015-08-31 02:38:41 +00:00
ld a, [wBaseCoordY]
2014-05-22 22:13:20 +00:00
add [hl]
ld [hli], a
2015-08-31 02:38:41 +00:00
ld a, [wBaseCoordX]
2014-05-22 22:13:20 +00:00
add [hl]
ld [hli], a
inc hl
inc hl
dec c
2015-03-14 22:25:21 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_AnimMonMoveVertical:
2015-03-14 22:25:21 +00:00
; Animates the mon going through the link cable vertically as well as
; horizontally for a bit. The last bit of horizontal movement (when moving
; right) or the first bit of horizontal movement (when moving left) are done
; here instead of Trade_AnimMonMoveHorizontal because this function moves the
; sprite itself rather than scrolling the screen around the sprite. Moving the
; sprite itself is necessary because the vertical segment of the link cable is
; to the right of the screen position that the mon sprite has when
; Trade_AnimMonMoveHorizontal is executing.
ld a, [wTradedMonMovingRight]
2014-05-22 22:13:20 +00:00
and a
2015-03-14 22:25:21 +00:00
jr z, .movingLeft
; moving right
2015-08-05 21:20:29 +00:00
lb bc, 4, 0 ; move right
2015-03-14 22:25:21 +00:00
call .doAnim
2015-08-05 21:20:29 +00:00
lb bc, 0, 10 ; move down
2015-03-14 22:25:21 +00:00
jr .doAnim
.movingLeft
2015-08-05 21:20:29 +00:00
lb bc, 0, -10 ; move up
2015-03-14 22:25:21 +00:00
call .doAnim
2015-08-05 21:20:29 +00:00
lb bc, -4, 0 ; move left
2015-03-14 22:25:21 +00:00
.doAnim
2014-05-22 22:13:20 +00:00
ld a, b
2015-08-31 02:38:41 +00:00
ld [wBaseCoordX], a
2014-05-22 22:13:20 +00:00
ld a, c
2015-08-31 02:38:41 +00:00
ld [wBaseCoordY], a
2014-05-22 22:13:20 +00:00
ld d, $4
2015-03-14 22:25:21 +00:00
.loop
call Trade_AddOffsetsToOAMCoords
call Trade_AnimCircledMon
ld c, 8
2014-05-22 22:13:20 +00:00
call DelayFrames
dec d
2015-03-14 22:25:21 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_WriteCircleOAM:
2015-03-14 22:25:21 +00:00
; Writes the OAM blocks for the circle around the traded mon as it passes
; the link cable.
ld hl, Trade_CircleOAMPointers
2014-05-22 22:13:20 +00:00
ld c, $4
xor a
2015-03-14 22:25:21 +00:00
.loop
2014-05-22 22:13:20 +00:00
push bc
ld e, [hl]
inc hl
ld d, [hl]
inc hl
ld c, [hl]
inc hl
ld b, [hl]
inc hl
push hl
inc a
push af
call WriteOAMBlock
pop af
pop hl
pop bc
dec c
2015-03-14 22:25:21 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_CircleOAMPointers:
2015-03-14 22:25:21 +00:00
dw Trade_CircleOAM0
2014-05-22 22:13:20 +00:00
db $08,$08
2015-03-14 22:25:21 +00:00
dw Trade_CircleOAM1
2014-05-22 22:13:20 +00:00
db $18,$08
2015-03-14 22:25:21 +00:00
dw Trade_CircleOAM2
2014-05-22 22:13:20 +00:00
db $08,$18
2015-03-14 22:25:21 +00:00
dw Trade_CircleOAM3
2014-05-22 22:13:20 +00:00
db $18,$18
2016-06-12 00:24:04 +00:00
Trade_CircleOAM0:
2014-05-22 22:13:20 +00:00
db $38,$10,$39,$10
db $3A,$10,$3B,$10
2016-06-12 00:24:04 +00:00
Trade_CircleOAM1:
2014-05-22 22:13:20 +00:00
db $39,$30,$38,$30
db $3B,$30,$3A,$30
2016-06-12 00:24:04 +00:00
Trade_CircleOAM2:
2014-05-22 22:13:20 +00:00
db $3A,$50,$3B,$50
db $38,$50,$39,$50
2016-06-12 00:24:04 +00:00
Trade_CircleOAM3:
2014-05-22 22:13:20 +00:00
db $3B,$70,$3A,$70
db $39,$70,$38,$70
2015-02-07 10:43:08 +00:00
; a = species
2016-06-12 00:24:04 +00:00
Trade_LoadMonSprite:
ld [wcf91], a
ld [wd0b5], a
2015-08-12 09:16:56 +00:00
ld [wWholeScreenPaletteMonSpecies], a
ld b, SET_PAL_POKEMON_WHOLE_SCREEN
ld c, 0
call RunPaletteCommand
ldh a, [hAutoBGTransferEnabled]
2014-05-22 22:13:20 +00:00
xor $1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call GetMonHeader
2015-07-18 20:52:03 +00:00
coord hl, 7, 2
2014-05-22 22:13:20 +00:00
call LoadFlippedFrontSpriteByMonIndex
2015-02-07 10:43:08 +00:00
ld c, 10
2014-05-22 22:13:20 +00:00
jp DelayFrames
2016-06-12 00:24:04 +00:00
Trade_ShowClearedWindow:
2015-03-14 22:25:21 +00:00
; clears the window and covers the BG entirely with the window
2014-05-22 22:13:20 +00:00
ld a, $1
ldh [hAutoBGTransferEnabled], a
2014-05-22 22:13:20 +00:00
call ClearScreen
2015-02-07 10:43:08 +00:00
ld a, %11100011
ldh [rLCDC], a
2014-05-22 22:13:20 +00:00
ld a, $7
ldh [rWX], a
2014-05-22 22:13:20 +00:00
xor a
ldh [hWY], a
2014-05-22 22:13:20 +00:00
ld a, $90
ldh [hSCX], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
Trade_SlideTextBoxOffScreen:
2015-03-15 01:29:53 +00:00
; Slides the window right until it's off screen. The window usually just has
; a text box at the bottom when this is called. However, when this is called
; after Trade_ShowEnemyMon in the external clock sequence, there is a mon pic
; above the text box and it is also scrolled off the screen.
2015-02-07 10:43:08 +00:00
ld c, 50
2014-05-22 22:13:20 +00:00
call DelayFrames
2015-02-07 10:43:08 +00:00
.loop
2014-05-22 22:13:20 +00:00
call DelayFrame
ldh a, [rWX]
2014-05-22 22:13:20 +00:00
inc a
inc a
ldh [rWX], a
2014-05-22 22:13:20 +00:00
cp $a1
2015-02-07 10:43:08 +00:00
jr nz, .loop
call Trade_ClearTileMap
ld c, 10
2014-05-22 22:13:20 +00:00
call DelayFrames
ld a, $7
ldh [rWX], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
PrintTradeWentToText:
2014-05-22 22:13:20 +00:00
ld hl, TradeWentToText
call PrintText
2015-02-07 10:43:08 +00:00
ld c, 200
2014-05-22 22:13:20 +00:00
call DelayFrames
2015-03-14 22:25:21 +00:00
jp Trade_SlideTextBoxOffScreen
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeWentToText:
text_far _TradeWentToText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PrintTradeForSendsText:
2014-05-22 22:13:20 +00:00
ld hl, TradeForText
call PrintText
2015-02-07 10:43:08 +00:00
call Trade_Delay80
2014-05-22 22:13:20 +00:00
ld hl, TradeSendsText
call PrintText
2015-02-07 10:43:08 +00:00
jp Trade_Delay80
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeForText:
text_far _TradeForText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeSendsText:
text_far _TradeSendsText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PrintTradeFarewellText:
2014-05-22 22:13:20 +00:00
ld hl, TradeWavesFarewellText
call PrintText
2015-02-07 10:43:08 +00:00
call Trade_Delay80
2014-05-22 22:13:20 +00:00
ld hl, TradeTransferredText
call PrintText
2015-02-07 10:43:08 +00:00
call Trade_Delay80
2015-03-14 22:25:21 +00:00
jp Trade_SlideTextBoxOffScreen
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeWavesFarewellText:
text_far _TradeWavesFarewellText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeTransferredText:
text_far _TradeTransferredText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PrintTradeTakeCareText:
2014-05-22 22:13:20 +00:00
ld hl, TradeTakeCareText
call PrintText
2015-02-07 10:43:08 +00:00
jp Trade_Delay80
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeTakeCareText:
text_far _TradeTakeCareText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PrintTradeWillTradeText:
2014-05-22 22:13:20 +00:00
ld hl, TradeWillTradeText
call PrintText
2015-02-07 10:43:08 +00:00
call Trade_Delay80
2014-05-22 22:13:20 +00:00
ld hl, TradeforText
call PrintText
2015-02-07 10:43:08 +00:00
jp Trade_Delay80
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeWillTradeText:
text_far _TradeWillTradeText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TradeforText:
text_far _TradeforText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Trade_ShowAnimation:
2015-08-31 02:38:41 +00:00
ld [wAnimationID], a
2014-05-22 22:13:20 +00:00
xor a
2015-08-13 05:14:31 +00:00
ld [wAnimationType], a
predef_jump MoveAnimation