diff options
Diffstat (limited to 'engine/trade.asm')
-rwxr-xr-x | engine/trade.asm | 257 |
1 files changed, 131 insertions, 126 deletions
diff --git a/engine/trade.asm b/engine/trade.asm index bb4fa4e1..c3913a7e 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -1,4 +1,4 @@ -InternalClockTradeAnim: ; 410e2 (10:50e2) +InternalClockTradeAnim: ; Do the trading animation with the player's gameboy on the left. ; In-game trades and internally clocked link cable trades use this. ld a, [wTradedPlayerMonSpecies] @@ -8,24 +8,24 @@ InternalClockTradeAnim: ; 410e2 (10:50e2) ld de, InternalClockTradeFuncSequence jr TradeAnimCommon -ExternalClockTradeAnim: ; 410f3 (10:50f3) +ExternalClockTradeAnim: ; Do the trading animation with the player's gameboy on the right. ; Externally clocked link cable trades use this. ld a, [wTradedEnemyMonSpecies] ld [wLeftGBMonSpecies], a - ld a, [wTrainerSpriteOffset] + ld a, [wTradedPlayerMonSpecies] ld [wRightGBMonSpecies], a ld de, ExternalClockTradeFuncSequence -TradeAnimCommon: ; 41102 (10:5102) - ld a, [W_OPTIONS] +TradeAnimCommon: + ld a, [wOptions] push af ld a, [hSCY] push af ld a, [hSCX] push af xor a - ld [W_OPTIONS], a + ld [wOptions], a ld [hSCY], a ld [hSCX], a push de @@ -53,7 +53,7 @@ TradeAnimCommon: ; 41102 (10:5102) pop af ld [hSCY], a pop af - ld [W_OPTIONS], a + ld [wOptions], a ret addtradefunc: MACRO @@ -69,7 +69,7 @@ tradefunc: MACRO ; They are from opposite perspectives. The external clock one makes use of ; Trade_SwapNames to swap the player and enemy names for some functions. -InternalClockTradeFuncSequence: ; 41138 (10:5138) +InternalClockTradeFuncSequence: tradefunc LoadTradingGFXAndMonNames tradefunc Trade_ShowPlayerMon tradefunc Trade_DrawOpenEndOfLinkCable @@ -88,7 +88,7 @@ InternalClockTradeFuncSequence: ; 41138 (10:5138) tradefunc Trade_Cleanup db $FF -ExternalClockTradeFuncSequence: ; 41149 (10:5149) +ExternalClockTradeFuncSequence: tradefunc LoadTradingGFXAndMonNames tradefunc Trade_ShowClearedWindow tradefunc PrintTradeWillTradeText @@ -112,7 +112,7 @@ ExternalClockTradeFuncSequence: ; 41149 (10:5149) tradefunc Trade_Cleanup db $FF -TradeFuncPointerTable: ; 4115f (10:515f) +TradeFuncPointerTable: addtradefunc LoadTradingGFXAndMonNames addtradefunc Trade_ShowPlayerMon addtradefunc Trade_DrawOpenEndOfLinkCable @@ -131,11 +131,11 @@ TradeFuncPointerTable: ; 4115f (10:515f) addtradefunc Trade_SlideTextBoxOffScreen addtradefunc Trade_SwapNames -Trade_Delay100: ; 41181 (10:5181) +Trade_Delay100: ld c, 100 jp DelayFrames -Trade_CopyTileMapToVRAM: ; 41186 (10:5186) +Trade_CopyTileMapToVRAM: ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 @@ -143,27 +143,27 @@ Trade_CopyTileMapToVRAM: ; 41186 (10:5186) ld [H_AUTOBGTRANSFERENABLED], a ret -Trade_Delay80: ; 41191 (10:5191) +Trade_Delay80: ld c, 80 jp DelayFrames -Trade_ClearTileMap: ; 41196 (10:5196) - ld hl, wTileMap - ld bc, 20 * 18 +Trade_ClearTileMap: + coord hl, 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " jp FillMemory -LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) +LoadTradingGFXAndMonNames: call Trade_ClearTileMap call DisableLCD ld hl, TradingAnimationGraphics ld de, vChars2 + $310 - ld bc, $310 + ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics ld a, BANK(TradingAnimationGraphics) call FarCopyData2 ld hl, TradingAnimationGraphics2 ld de, vSprites + $7c0 - ld bc, $40 + ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2 ld a, BANK(TradingAnimationGraphics2) call FarCopyData2 ld hl, vBGMap0 @@ -190,41 +190,39 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) call GetMonName ld hl, wcd6d ld de, wcf4b - ld bc, $b + ld bc, NAME_LENGTH call CopyData ld a, [wTradedEnemyMonSpecies] ld [wd11e], a jp GetMonName -Trade_LoadMonPartySpriteGfx: ; 4120b (10:520b) +Trade_LoadMonPartySpriteGfx: ld a, %11010000 ld [rOBP1], a - ld b, BANK(LoadMonPartySpriteGfx) - ld hl, LoadMonPartySpriteGfx - jp Bankswitch + jpba LoadMonPartySpriteGfx -Trade_SwapNames: ; 41217 (10:5217) +Trade_SwapNames: ld hl, wPlayerName ld de, wBuffer - ld bc, 11 + ld bc, NAME_LENGTH call CopyData ld hl, wLinkEnemyTrainerName ld de, wPlayerName - ld bc, 11 + ld bc, NAME_LENGTH call CopyData ld hl, wBuffer ld de, wLinkEnemyTrainerName - ld bc, 11 + ld bc, NAME_LENGTH jp CopyData -Trade_Cleanup: ; 4123b (10:523b) +Trade_Cleanup: xor a call LoadGBPal ld hl, wd730 res 6, [hl] ; turn off instant text printing ret -Trade_ShowPlayerMon: ; 41245 (10:5245) +Trade_ShowPlayerMon: ld a, %10101011 ld [rLCDC], a ld a, $50 @@ -234,7 +232,7 @@ Trade_ShowPlayerMon: ; 41245 (10:5245) ld [hSCX], a xor a ld [H_AUTOBGTRANSFERENABLED], a - hlCoord 4, 0 + coord hl, 4, 0 ld b, 6 ld c, 10 call TextBoxBorder @@ -259,31 +257,35 @@ Trade_ShowPlayerMon: ; 41245 (10:5245) ld a, TRADE_BALL_POOF_ANIM call Trade_ShowAnimation ld a, TRADE_BALL_DROP_ANIM - call Trade_ShowAnimation + call Trade_ShowAnimation ; clears mon pic ld a, [wTradedPlayerMonSpecies] call PlayCry xor a ld [H_AUTOBGTRANSFERENABLED], a ret -Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298) +Trade_DrawOpenEndOfLinkCable: call Trade_ClearTileMap ld b, vBGMap0 / $100 call CopyScreenTileBufferToVRAM - ld b, $8 - call GoPAL_SET + ld b, SET_PAL_GENERIC + call RunPaletteCommand + +; This function call is pointless. It just copies blank tiles to VRAM that was +; already filled with blank tiles. ld hl, vBGMap1 + $8c call Trade_CopyCableTilesOffScreen + ld a, $a0 ld [hSCX], a call DelayFrame ld a, %10001011 ld [rLCDC], a - hlCoord 6, 2 + coord hl, 6, 2 ld b, $7 ; open end of link cable tile ID list index call CopyTileIDsFromList_ZeroBaseTileID call Trade_CopyTileMapToVRAM - ld a, (SFX_02_3d - SFX_Headers_02) / 3 + ld a, SFX_HEAL_HP call PlaySound ld c, 20 .loop @@ -294,7 +296,7 @@ Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298) jr nz, .loop ret -Trade_AnimateBallEnteringLinkCable: ; 412d2 (10:52d2) +Trade_AnimateBallEnteringLinkCable: ld a, TRADE_BALL_SHAKE_ANIM call Trade_ShowAnimation ld c, 10 @@ -302,25 +304,25 @@ Trade_AnimateBallEnteringLinkCable: ; 412d2 (10:52d2) ld a, %11100100 ld [rOBP0], a xor a - ld [wd09f], a - ld bc, $2060 + ld [wLinkCableAnimBulgeToggle], a + lb bc, $20, $60 .moveBallInsideLinkCableLoop push bc xor a ld de, Trade_BallInsideLinkCableOAM call WriteOAMBlock - ld a, [wd09f] + ld a, [wLinkCableAnimBulgeToggle] xor $1 - ld [wd09f], a + ld [wLinkCableAnimBulgeToggle], a add $7e ld hl, wOAMBuffer + $02 - ld de, $4 + ld de, 4 ld c, e -.cycleSpriteFramesLoop +.cycleLinkCableBulgeTile ld [hl], a add hl, de dec c - jr nz, .cycleSpriteFramesLoop + jr nz, .cycleLinkCableBulgeTile call Delay3 pop bc ld a, c @@ -328,7 +330,7 @@ Trade_AnimateBallEnteringLinkCable: ; 412d2 (10:52d2) ld c, a cp $a0 jr nc, .ballSpriteReachedEdgeOfScreen - ld a, (SFX_02_3c - SFX_Headers_02) / 3 + ld a, SFX_TINK call PlaySound jr .moveBallInsideLinkCableLoop .ballSpriteReachedEdgeOfScreen @@ -343,15 +345,15 @@ Trade_AnimateBallEnteringLinkCable: ; 412d2 (10:52d2) ld [H_AUTOBGTRANSFERENABLED], a ret -Trade_BallInsideLinkCableOAM: ; 4132e (10:532e) +Trade_BallInsideLinkCableOAM: db $7E,$00,$7E,$20 db $7E,$40,$7E,$60 -Trade_ShowEnemyMon: ; 41336 (10:5336) +Trade_ShowEnemyMon: ld a, TRADE_BALL_TILT_ANIM call Trade_ShowAnimation call Trade_ShowClearedWindow - hlCoord 4, 10 + coord hl, 4, 10 ld b, 6 ld c, 10 call TextBoxBorder @@ -368,22 +370,22 @@ Trade_ShowEnemyMon: ; 41336 (10:5336) ld a, [wTradedEnemyMonSpecies] call PlayCry call Trade_Delay100 - hlCoord 4, 10 - ld bc, $80c + coord hl, 4, 10 + lb bc, 8, 12 call ClearScreenArea jp PrintTradeTakeCareText -Trade_AnimLeftToRight: ; 41376 (10:5376) +Trade_AnimLeftToRight: ; Animates the mon moving from the left GB to the right one. call Trade_InitGameboyTransferGfx ld a, $1 ld [wTradedMonMovingRight], a - ld a, $e4 + ld a, %11100100 ld [rOBP0], a ld a, $54 - ld [W_BASECOORDX], a + ld [wBaseCoordX], a ld a, $1c - ld [W_BASECOORDY], a + ld [wBaseCoordY], a ld a, [wLeftGBMonSpecies] ld [wMonPartySpriteSpecies], a call Trade_WriteCircledMonOAM @@ -407,15 +409,15 @@ Trade_AnimLeftToRight: ; 41376 (10:5376) call Trade_AnimMonMoveVertical jp ClearSprites -Trade_AnimRightToLeft: ; 413c6 (10:53c6) +Trade_AnimRightToLeft: ; Animates the mon moving from the right GB to the left one. call Trade_InitGameboyTransferGfx xor a ld [wTradedMonMovingRight], a ld a, $64 - ld [W_BASECOORDX], a + ld [wBaseCoordX], a ld a, $44 - ld [W_BASECOORDY], a + ld [wBaseCoordY], a ld a, [wRightGBMonSpecies] ld [wMonPartySpriteSpecies], a call Trade_WriteCircledMonOAM @@ -439,7 +441,7 @@ Trade_AnimRightToLeft: ; 413c6 (10:53c6) ld [H_AUTOBGTRANSFERENABLED], a jp ClearSprites -Trade_InitGameboyTransferGfx: ; 41411 (10:5411) +Trade_InitGameboyTransferGfx: ; Initialises the graphics for showing a mon moving between gameboys. ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -456,41 +458,41 @@ Trade_InitGameboyTransferGfx: ; 41411 (10:5411) ld [hWY], a ret -Trade_DrawLeftGameboy: ; 4142d (10:542d) +Trade_DrawLeftGameboy: call Trade_ClearTileMap ; draw link cable - hlCoord 11, 4 + coord hl, 11, 4 ld a, $5d ld [hli], a ld a, $5e - ld c, $8 + ld c, 8 .loop ld [hli], a dec c jr nz, .loop ; draw gameboy pic - hlCoord 5, 3 + coord hl, 5, 3 ld b, $6 call CopyTileIDsFromList_ZeroBaseTileID ; draw text box with player name below gameboy pic - hlCoord 4, 12 + coord hl, 4, 12 ld b, 2 ld c, 7 call TextBoxBorder - hlCoord 5, 14 + coord hl, 5, 14 ld de, wPlayerName call PlaceString jp DelayFrame -Trade_DrawRightGameboy: ; 4145c (10:545c) +Trade_DrawRightGameboy: call Trade_ClearTileMap ; draw horizontal segment of link cable - hlCoord 0, 4 + coord hl, 0, 4 ld a, $5e ld c, $e .loop @@ -518,25 +520,25 @@ Trade_DrawRightGameboy: ; 4145c (10:545c) ld [hl], a ; draw gameboy pic - hlCoord 7, 8 + coord hl, 7, 8 ld b, $6 call CopyTileIDsFromList_ZeroBaseTileID ; draw text box with enemy name above link cable - hlCoord 6, 0 - ld b, $2 - ld c, $7 + coord hl, 6, 0 + ld b, 2 + ld c, 7 call TextBoxBorder - hlCoord 7, 2 + coord hl, 7, 2 ld de, wLinkEnemyTrainerName call PlaceString jp DelayFrame -Trade_DrawCableAcrossScreen: ; 4149f (10:549f) +Trade_DrawCableAcrossScreen: ; Draws the link cable across the screen. call Trade_ClearTileMap - hlCoord 0, 4 + coord hl, 0, 4 ld a, $5e ld c, SCREEN_WIDTH .loop @@ -545,23 +547,23 @@ Trade_DrawCableAcrossScreen: ; 4149f (10:549f) jr nz, .loop ret -Trade_CopyCableTilesOffScreen: ; 414ae (10:54ae) +Trade_CopyCableTilesOffScreen: ; This is used to copy the link cable tiles off screen so that the cable ; continues when the screen is scrolled. push hl - hlCoord 0, 4 - call CopyToScreenEdgeTiles + coord hl, 0, 4 + call CopyToRedrawRowOrColumnSrcTiles pop hl ld a, h - ld [H_SCREENEDGEREDRAWADDR + 1], a + ld [hRedrawRowOrColumnDest + 1], a ld a, l - ld [H_SCREENEDGEREDRAWADDR], a - ld a, REDRAWROW - ld [H_SCREENEDGEREDRAW], a + ld [hRedrawRowOrColumnDest], a + ld a, REDRAW_ROW + ld [hRedrawRowOrColumnMode], a ld c, 10 jp DelayFrames -Trade_AnimMonMoveHorizontal: ; 414c5 (10:54c5) +Trade_AnimMonMoveHorizontal: ; Animates the mon going through the link cable horizontally over a distance of ; b 16-pixel units. ld a, [wTradedMonMovingRight] @@ -588,7 +590,7 @@ Trade_AnimMonMoveHorizontal: ; 414c5 (10:54c5) jr nz, Trade_AnimMonMoveHorizontal ret -Trade_AnimCircledMon: ; 414e8 (10:54e8) +Trade_AnimCircledMon: ; 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. push de @@ -612,18 +614,18 @@ Trade_AnimCircledMon: ; 414e8 (10:54e8) pop de ret -Trade_WriteCircledMonOAM: ; 41505 (10:5505) +Trade_WriteCircledMonOAM: callba WriteMonPartySpriteOAMBySpecies call Trade_WriteCircleOAM -Trade_AddOffsetsToOAMCoords: ; 41510 (10:5510) +Trade_AddOffsetsToOAMCoords: ld hl, wOAMBuffer ld c, $14 .loop - ld a, [W_BASECOORDY] + ld a, [wBaseCoordY] add [hl] ld [hli], a - ld a, [W_BASECOORDX] + ld a, [wBaseCoordX] add [hl] ld [hli], a inc hl @@ -632,7 +634,7 @@ Trade_AddOffsetsToOAMCoords: ; 41510 (10:5510) jr nz, .loop ret -Trade_AnimMonMoveVertical: ; 41525 (10:5525) +Trade_AnimMonMoveVertical: ; 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 @@ -645,30 +647,30 @@ Trade_AnimMonMoveVertical: ; 41525 (10:5525) and a jr z, .movingLeft ; moving right - ld bc, $400 ; move right + lb bc, 4, 0 ; move right call .doAnim - ld bc, $a ; move down + lb bc, 0, 10 ; move down jr .doAnim .movingLeft - ld bc, $f6 ; move up + lb bc, 0, -10 ; move up call .doAnim - ld bc, $fc00 ; move left + lb bc, -4, 0 ; move left .doAnim ld a, b - ld [W_BASECOORDX], a + ld [wBaseCoordX], a ld a, c - ld [W_BASECOORDY], a + ld [wBaseCoordY], a ld d, $4 .loop call Trade_AddOffsetsToOAMCoords call Trade_AnimCircledMon - ld c, $8 + ld c, 8 call DelayFrames dec d jr nz, .loop ret -Trade_WriteCircleOAM: ; 41558 (10:5558) +Trade_WriteCircleOAM: ; Writes the OAM blocks for the circle around the traded mon as it passes ; the link cable. ld hl, Trade_CircleOAMPointers @@ -695,7 +697,7 @@ Trade_WriteCircleOAM: ; 41558 (10:5558) jr nz, .loop ret -Trade_CircleOAMPointers: ; 41574 (10:5574) +Trade_CircleOAMPointers: dw Trade_CircleOAM0 db $08,$08 dw Trade_CircleOAM1 @@ -705,40 +707,40 @@ Trade_CircleOAMPointers: ; 41574 (10:5574) dw Trade_CircleOAM3 db $18,$18 -Trade_CircleOAM0: ; 41584 (10:5584) +Trade_CircleOAM0: db $38,$10,$39,$10 db $3A,$10,$3B,$10 -Trade_CircleOAM1: ; 4158c (10:558c) +Trade_CircleOAM1: db $39,$30,$38,$30 db $3B,$30,$3A,$30 -Trade_CircleOAM2: ; 41594 (10:5594) +Trade_CircleOAM2: db $3A,$50,$3B,$50 db $38,$50,$39,$50 -Trade_CircleOAM3: ; 4159c (10:559c) +Trade_CircleOAM3: db $3B,$70,$3A,$70 db $39,$70,$38,$70 ; a = species -Trade_LoadMonSprite: ; 415a4 (10:55a4) +Trade_LoadMonSprite: ld [wcf91], a ld [wd0b5], a - ld [wcf1d], a - ld b, $b - ld c, $0 - call GoPAL_SET + ld [wWholeScreenPaletteMonSpecies], a + ld b, SET_PAL_POKEMON_WHOLE_SCREEN + ld c, 0 + call RunPaletteCommand ld a, [H_AUTOBGTRANSFERENABLED] xor $1 ld [H_AUTOBGTRANSFERENABLED], a call GetMonHeader - hlCoord 7, 2 + coord hl, 7, 2 call LoadFlippedFrontSpriteByMonIndex ld c, 10 jp DelayFrames -Trade_ShowClearedWindow: ; 415c8 (10:55c8) +Trade_ShowClearedWindow: ; clears the window and covers the BG entirely with the window ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -753,8 +755,11 @@ Trade_ShowClearedWindow: ; 415c8 (10:55c8) ld [hSCX], a ret -Trade_SlideTextBoxOffScreen: ; 415df (10:55df) -; Slides the window right until it's off screen. +Trade_SlideTextBoxOffScreen: +; 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. ld c, 50 call DelayFrames .loop @@ -772,18 +777,18 @@ Trade_SlideTextBoxOffScreen: ; 415df (10:55df) ld [rWX], a ret -PrintTradeWentToText: ; 415fe (10:55fe) +PrintTradeWentToText: ld hl, TradeWentToText call PrintText ld c, 200 call DelayFrames jp Trade_SlideTextBoxOffScreen -TradeWentToText: ; 4160c (10:560c) +TradeWentToText: TX_FAR _TradeWentToText db "@" -PrintTradeForSendsText: ; 41611 (10:5611) +PrintTradeForSendsText: ld hl, TradeForText call PrintText call Trade_Delay80 @@ -791,15 +796,15 @@ PrintTradeForSendsText: ; 41611 (10:5611) call PrintText jp Trade_Delay80 -TradeForText: ; 41623 (10:5623) +TradeForText: TX_FAR _TradeForText db "@" -TradeSendsText: ; 41628 (10:5628) +TradeSendsText: TX_FAR _TradeSendsText db "@" -PrintTradeFarewellText: ; 4162d (10:562d) +PrintTradeFarewellText: ld hl, TradeWavesFarewellText call PrintText call Trade_Delay80 @@ -808,24 +813,24 @@ PrintTradeFarewellText: ; 4162d (10:562d) call Trade_Delay80 jp Trade_SlideTextBoxOffScreen -TradeWavesFarewellText: ; 41642 (10:5642) +TradeWavesFarewellText: TX_FAR _TradeWavesFarewellText db "@" -TradeTransferredText: ; 41647 (10:5647) +TradeTransferredText: TX_FAR _TradeTransferredText db "@" -PrintTradeTakeCareText: ; 4164c (10:564c) +PrintTradeTakeCareText: ld hl, TradeTakeCareText call PrintText jp Trade_Delay80 -TradeTakeCareText: ; 41655 (10:5655) +TradeTakeCareText: TX_FAR _TradeTakeCareText db "@" -PrintTradeWillTradeText: ; 4165a (10:565a) +PrintTradeWillTradeText: ld hl, TradeWillTradeText call PrintText call Trade_Delay80 @@ -833,16 +838,16 @@ PrintTradeWillTradeText: ; 4165a (10:565a) call PrintText jp Trade_Delay80 -TradeWillTradeText: ; 4166c (10:566c) +TradeWillTradeText: TX_FAR _TradeWillTradeText db "@" -TradeforText: ; 41671 (10:5671) +TradeforText: TX_FAR _TradeforText db "@" -Trade_ShowAnimation: ; 41676 (10:5676) - ld [W_ANIMATIONID], a +Trade_ShowAnimation: + ld [wAnimationID], a xor a - ld [wcc5b], a + ld [wAnimationType], a predef_jump MoveAnimation |