shithub: pokered

Download patch

ref: 0996a964bdb597b9cd0c087fde5926980eac900a
parent: ec76703936ae690411a29c4f6ff11eef41ebdfd3
author: YamaArashi <shadow962@live.com>
date: Sat Mar 14 11:25:21 EDT 2015

commented trade amim functions

--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -840,10 +840,10 @@
 	ld a, [hSerialConnectionStatus]
 	cp USING_EXTERNAL_CLOCK
 	jr z, .usingExternalClock
-	predef Func_410e2
+	predef InternalClockTradeAnim
 	jr .tradeCompleted
 .usingExternalClock
-	predef Func_410f3
+	predef ExternalClockTradeAnim
 .tradeCompleted
 	callab TryEvolvingMon
 	call ClearScreen
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -122,7 +122,7 @@
 	push af
 	call LoadHpBarAndStatusTilePatterns
 	call InGameTrade_PrepareTradeData
-	predef Func_410e2
+	predef InternalClockTradeAnim
 	pop af
 	ld [W_CURENEMYLVL],a
 	pop af
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -470,9 +470,9 @@
 	dec a
 	jr z, .notNickname
 	ld a, [wcf91]
-	ld [wcd5d], a
+	ld [wMonPartySpriteSpecies], a
 	push af
-	callba WriteMonPartySpriteOAMByMonID
+	callba WriteMonPartySpriteOAMBySpecies
 	pop af
 	ld [wd11e], a
 	call GetMonName
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -322,11 +322,12 @@
 	pop hl
 	ret
 
-WriteMonPartySpriteOAMByMonID: ; 71882 (1c:5882)
-; Write OAM blocks for mon ID in [wcd5d].
+WriteMonPartySpriteOAMBySpecies: ; 71882 (1c:5882)
+; Write OAM blocks for the party sprite of the species in
+; [wMonPartySpriteSpecies].
 	xor a
 	ld [hPartyMonIndex], a
-	ld a, [wcd5d]
+	ld a, [wMonPartySpriteSpecies]
 	call GetPartyMonSpriteID
 	ld [wcd5b], a
 	jr WriteMonPartySpriteOAM
@@ -334,7 +335,7 @@
 UnusedPartyMonSpriteFunction: ; 71890 (1c:5890)
 ; This function is unused and doesn't appear to do anything useful. It looks
 ; like it may have been intended to load the tile patterns and OAM data for
-; the mon party sprite associated with the mon ID in a.
+; the mon party sprite associated with the species in [wcf91].
 ; However, its calculations are off and it loads garbage data.
 	ld a, [wcf91]
 	call GetPartyMonSpriteID
@@ -346,8 +347,8 @@
 	ld hl, vSprites + $40
 	call .LoadTilePatterns
 	xor a
-	ld [wcd5d], a
-	jr WriteMonPartySpriteOAMByMonID
+	ld [wMonPartySpriteSpecies], a
+	jr WriteMonPartySpriteOAMBySpecies
 
 .LoadTilePatterns ; 718ac (1c:58ac)
 	push hl
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -99,7 +99,7 @@
 	add_predef InitOpponent
 	add_predef CableClub_Run
 	add_predef DrawBadges
-	add_predef Func_410f3
+	add_predef ExternalClockTradeAnim
 	add_predef BattleTransition
 	add_predef CopyTileIDsFromList
 	add_predef PlayIntro
@@ -108,7 +108,7 @@
 	add_predef GetTileAndCoordsInFrontOfPlayer
 	add_predef StatusScreen
 	add_predef StatusScreen2
-	add_predef Func_410e2
+	add_predef InternalClockTradeAnim
 	add_predef TrainerEngage
 	add_predef IndexToPokedex
 	add_predef Predef3B; 3B display pic?
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -1,19 +1,23 @@
-Func_410e2: ; 410e2 (10:50e2)
+InternalClockTradeAnim: ; 410e2 (10:50e2)
+; 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]
-	ld [wcd5e], a
+	ld [wLeftGBMonSpecies], a
 	ld a, [wTradedEnemyMonSpecies]
-	ld [wcd5f], a
-	ld de, PointerIDs_41138
-	jr Func_41102
+	ld [wRightGBMonSpecies], a
+	ld de, InternalClockTradeFuncSequence
+	jr TradeAnimCommon
 
-Func_410f3: ; 410f3 (10:50f3)
+ExternalClockTradeAnim: ; 410f3 (10:50f3)
+; Do the trading animation with the player's gameboy on the right.
+; Externally clocked link cable trades use this.
 	ld a, [wTradedEnemyMonSpecies]
-	ld [wcd5e], a
+	ld [wLeftGBMonSpecies], a
 	ld a, [wTrainerSpriteOffset]
-	ld [wcd5f], a
-	ld de, PointerIDs_41149
+	ld [wRightGBMonSpecies], a
+	ld de, ExternalClockTradeFuncSequence
 
-Func_41102: ; 41102 (10:5102)
+TradeAnimCommon: ; 41102 (10:5102)
 	ld a, [W_OPTIONS]
 	push af
 	ld a, [hSCY]
@@ -25,14 +29,14 @@
 	ld [hSCY], a
 	ld [hSCX], a
 	push de
-.asm_41115
+.loop
 	pop de
 	ld a, [de]
 	cp $ff
-	jr z, .asm_4112d
+	jr z, .done
 	inc de
 	push de
-	ld hl, PointerTable_4115f
+	ld hl, TradeFuncPointerTable
 	add a
 	ld c, a
 	ld b, $0
@@ -40,10 +44,10 @@
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ld de, .asm_41115
+	ld de, .loop
 	push de
-	jp [hl]
-.asm_4112d
+	jp [hl] ; call trade func, which will return to the top of the loop
+.done
 	pop af
 	ld [hSCX], a
 	pop af
@@ -52,32 +56,81 @@
 	ld [W_OPTIONS], a
 	ret
 
-; these bytes refer to the $00th through $10th pointer of PointerTable_4115f
-PointerIDs_41138: ; 41138 (10:5138)
-	db $00,$01,$02,$03,$05,$07,$08,$09,$0A,$0B,$06,$08,$02,$04,$07,$0E,$FF
+addtradefunc: MACRO
+\1TradeFunc::
+	dw \1
+	ENDM
 
-PointerIDs_41149: ; 41149 (10:5149)
-	db $00,$08,$0D,$0B,$10,$05,$10,$08,$02,$04,$0F,$01,$02,$03,$10,$06,$10,$07,$08,$09,$0E,$FF
+tradefunc: MACRO
+	db (\1TradeFunc - TradeFuncPointerTable) / 2
+	ENDM
 
-PointerTable_4115f: ; 4115f (10:515f)
-	dw LoadTradingGFXAndMonNames
-	dw Trade_ShowPlayerMon
-	dw Trade_DrawOpenEndOfLinkCable
-	dw Trade_AnimateBallEnteringLinkCable
-	dw Trade_ShowEnemyMon
-	dw Func_41376
-	dw Func_413c6
-	dw Trade_Delay100
-	dw Func_415c8
-	dw PrintTradeWentToText
-	dw PrintTradeForSendsText
-	dw PrintTradeFarewellText
-	dw PrintTradeTakeCareText
-	dw PrintTradeWillTradeText
-	dw Func_4123b
-	dw Func_415df
-	dw Trade_SwapNames
+; 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.
 
+InternalClockTradeFuncSequence: ; 41138 (10:5138)
+	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
+
+ExternalClockTradeFuncSequence: ; 41149 (10:5149)
+	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
+
+TradeFuncPointerTable: ; 4115f (10:515f)
+	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
+
 Trade_Delay100: ; 41181 (10:5181)
 	ld c, 100
 	jp DelayFrames
@@ -121,13 +174,13 @@
 	ld a, $ff
 	ld [wUpdateSpritesEnabled], a
 	ld hl, wd730
-	set 6, [hl]
+	set 6, [hl] ; turn on instant text printing
 	ld a, [wOnSGB]
 	and a
-	ld a, $e4
-	jr z, .asm_411e5
-	ld a, $f0
-.asm_411e5
+	ld a, $e4 ; non-SGB OBP0
+	jr z, .next
+	ld a, $f0 ; SGB OBP0
+.next
 	ld [rOBP0], a
 	call EnableLCD
 	xor a
@@ -143,7 +196,7 @@
 	ld [wd11e], a
 	jp GetMonName
 
-Func_4120b: ; 4120b (10:520b)
+Trade_LoadMonPartySpriteGfx: ; 4120b (10:520b)
 	ld a, %11010000
 	ld [rOBP1], a
 	ld b, BANK(LoadMonPartySpriteGfx)
@@ -164,11 +217,11 @@
 	ld bc, 11
 	jp CopyData
 
-Func_4123b: ; 4123b (10:523b)
+Trade_Cleanup: ; 4123b (10:523b)
 	xor a
 	call LoadGBPal
 	ld hl, wd730
-	res 6, [hl]
+	res 6, [hl] ; turn off instant text printing
 	ret
 
 Trade_ShowPlayerMon: ; 41245 (10:5245)
@@ -186,7 +239,7 @@
 	ld c, 10
 	call TextBoxBorder
 	call Trade_PrintPlayerMonInfoText
-	ld b, $98
+	ld b, vBGMap0 / $100
 	call CopyScreenTileBufferToVRAM
 	call ClearScreen
 	ld a, [wTradedPlayerMonSpecies]
@@ -215,12 +268,12 @@
 
 Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298)
 	call Trade_ClearTileMap
-	ld b, $98
+	ld b, vBGMap0 / $100
 	call CopyScreenTileBufferToVRAM
 	ld b, $8
 	call GoPAL_SET
 	ld hl, vBGMap1 + $8c
-	call Trade_RedrawRows4And5
+	call Trade_CopyCableTilesOffScreen
 	ld a, $a0
 	ld [hSCX], a
 	call DelayFrame
@@ -297,7 +350,7 @@
 Trade_ShowEnemyMon: ; 41336 (10:5336)
 	ld a, TRADE_BALL_TILT_ANIM
 	call Trade_ShowAnimation
-	call Func_415c8
+	call Trade_ShowClearedWindow
 	hlCoord 4, 10
 	ld b, 6
 	ld c, 10
@@ -320,10 +373,11 @@
 	call ClearScreenArea
 	jp PrintTradeTakeCareText
 
-Func_41376: ; 41376 (10:5376)
-	call Func_41411
+Trade_AnimLeftToRight: ; 41376 (10:5376)
+; Animates the mon moving from the left GB to the right one.
+	call Trade_InitGameboyTransferGfx
 	ld a, $1
-	ld [wd08a], a
+	ld [wTradedMonMovingRight], a
 	ld a, $e4
 	ld [rOBP0], a
 	ld a, $54
@@ -330,67 +384,69 @@
 	ld [W_BASECOORDX], a
 	ld a, $1c
 	ld [W_BASECOORDY], a
-	ld a, [wcd5e]
-	ld [wcd5d], a
-	call Func_41505
-	call Func_4142d
+	ld a, [wLeftGBMonSpecies]
+	ld [wMonPartySpriteSpecies], a
+	call Trade_WriteCircledMonOAM
+	call Trade_DrawLeftGameboy
 	call Trade_CopyTileMapToVRAM
-	call Func_4149f
+	call Trade_DrawCableAcrossScreen
 	ld hl, vBGMap1 + $8c
-	call Trade_RedrawRows4And5
+	call Trade_CopyCableTilesOffScreen
 	ld b, $6
-	call Func_414c5
+	call Trade_AnimMonMoveHorizontal
 	ld a, $1
 	ld [H_AUTOBGTRANSFERENABLED], a
-	call Func_4149f
+	call Trade_DrawCableAcrossScreen
 	ld b, $4
-	call Func_414c5
-	call Func_4145c
+	call Trade_AnimMonMoveHorizontal
+	call Trade_DrawRightGameboy
 	ld b, $6
-	call Func_414c5
+	call Trade_AnimMonMoveHorizontal
 	xor a
 	ld [H_AUTOBGTRANSFERENABLED], a
-	call Func_41525
+	call Trade_AnimMonMoveVertical
 	jp ClearSprites
 
-Func_413c6: ; 413c6 (10:53c6)
-	call Func_41411
+Trade_AnimRightToLeft: ; 413c6 (10:53c6)
+; Animates the mon moving from the right GB to the left one.
+	call Trade_InitGameboyTransferGfx
 	xor a
-	ld [wd08a], a
+	ld [wTradedMonMovingRight], a
 	ld a, $64
 	ld [W_BASECOORDX], a
 	ld a, $44
 	ld [W_BASECOORDY], a
-	ld a, [wcd5f]
-	ld [wcd5d], a
-	call Func_41505
-	call Func_4145c
+	ld a, [wRightGBMonSpecies]
+	ld [wMonPartySpriteSpecies], a
+	call Trade_WriteCircledMonOAM
+	call Trade_DrawRightGameboy
 	call Trade_CopyTileMapToVRAM
-	call Func_4149f
+	call Trade_DrawCableAcrossScreen
 	ld hl, vBGMap1 + $94
-	call Trade_RedrawRows4And5
-	call Func_41525
+	call Trade_CopyCableTilesOffScreen
+	call Trade_AnimMonMoveVertical
 	ld b, $6
-	call Func_414c5
+	call Trade_AnimMonMoveHorizontal
 	ld a, $1
 	ld [H_AUTOBGTRANSFERENABLED], a
-	call Func_4149f
+	call Trade_DrawCableAcrossScreen
 	ld b, $4
-	call Func_414c5
-	call Func_4142d
+	call Trade_AnimMonMoveHorizontal
+	call Trade_DrawLeftGameboy
 	ld b, $6
-	call Func_414c5
+	call Trade_AnimMonMoveHorizontal
 	xor a
 	ld [H_AUTOBGTRANSFERENABLED], a
 	jp ClearSprites
 
-Func_41411: ; 41411 (10:5411)
+Trade_InitGameboyTransferGfx: ; 41411 (10:5411)
+; Initialises the graphics for showing a mon moving between gameboys.
 	ld a, $1
 	ld [H_AUTOBGTRANSFERENABLED], a
 	call ClearScreen
 	xor a
 	ld [H_AUTOBGTRANSFERENABLED], a
-	call Func_4120b
+	call Trade_LoadMonPartySpriteGfx
 	call DelayFrame
 	ld a, %10101011
 	ld [rLCDC], a
@@ -400,20 +456,26 @@
 	ld [hWY], a
 	ret
 
-Func_4142d: ; 4142d (10:542d)
+Trade_DrawLeftGameboy: ; 4142d (10:542d)
 	call Trade_ClearTileMap
+
+; draw link cable
 	hlCoord 11, 4
 	ld a, $5d
 	ld [hli], a
 	ld a, $5e
 	ld c, $8
-.asm_4143a
+.loop
 	ld [hli], a
 	dec c
-	jr nz, .asm_4143a
+	jr nz, .loop
+
+; draw gameboy pic
 	hlCoord 5, 3
 	ld b, $6
 	call CopyTileIDsFromList_ZeroBaseTileID
+
+; draw text box with player name below gameboy pic
 	hlCoord 4, 12
 	ld b, 2
 	ld c, 7
@@ -421,20 +483,25 @@
 	hlCoord 5, 14
 	ld de, wPlayerName
 	call PlaceString
+
 	jp DelayFrame
 
-Func_4145c: ; 4145c (10:545c)
+Trade_DrawRightGameboy: ; 4145c (10:545c)
 	call Trade_ClearTileMap
+
+; draw horizontal segment of link cable
 	hlCoord 0, 4
 	ld a, $5e
 	ld c, $e
-.asm_41466
+.loop
 	ld [hli], a
 	dec c
-	jr nz, .asm_41466
+	jr nz, .loop
+
+; draw vertical segment of link cable
 	ld a, $5f
 	ld [hl], a
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	add hl, de
 	ld a, $61
 	ld [hl], a
@@ -449,9 +516,13 @@
 	ld [hld], a
 	ld a, $5d
 	ld [hl], a
+
+; draw gameboy pic
 	hlCoord 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
@@ -459,20 +530,24 @@
 	hlCoord 7, 2
 	ld de, wLinkEnemyTrainerName
 	call PlaceString
+
 	jp DelayFrame
 
-Func_4149f: ; 4149f (10:549f)
+Trade_DrawCableAcrossScreen: ; 4149f (10:549f)
+; Draws the link cable across the screen.
 	call Trade_ClearTileMap
 	hlCoord 0, 4
 	ld a, $5e
-	ld c, $14
-.asm_414a9
+	ld c, SCREEN_WIDTH
+.loop
 	ld [hli], a
 	dec c
-	jr nz, .asm_414a9
+	jr nz, .loop
 	ret
 
-Trade_RedrawRows4And5: ; 414ae (10:54ae)
+Trade_CopyCableTilesOffScreen: ; 414ae (10:54ae)
+; 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
@@ -486,60 +561,65 @@
 	ld c, 10
 	jp DelayFrames
 
-Func_414c5: ; 414c5 (10:54c5)
-	ld a, [wd08a]
+Trade_AnimMonMoveHorizontal: ; 414c5 (10:54c5)
+; Animates the mon going through the link cable horizontally over a distance of
+; b 16-pixel units.
+	ld a, [wTradedMonMovingRight]
 	ld e, a
 	ld d, $8
-.asm_414cb
+.scrollLoop
 	ld a, e
 	dec a
-	jr z, .asm_414d5
+	jr z, .movingRight
+; moving left
 	ld a, [hSCX]
 	sub $2
-	jr .asm_414d9
-.asm_414d5
+	jr .next
+.movingRight
 	ld a, [hSCX]
 	add $2
-.asm_414d9
+.next
 	ld [hSCX], a
 	call DelayFrame
 	dec d
-	jr nz, .asm_414cb
-	call Func_414e8
+	jr nz, .scrollLoop
+	call Trade_AnimCircledMon
 	dec b
-	jr nz, Func_414c5
+	jr nz, Trade_AnimMonMoveHorizontal
 	ret
 
-Func_414e8: ; 414e8 (10:54e8)
+Trade_AnimCircledMon: ; 414e8 (10:54e8)
+; 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
 	push bc
 	push hl
 	ld a, [rBGP]
-	xor $3c
+	xor $3c ; make link cable flash
 	ld [rBGP], a
 	ld hl, wOAMBuffer + $02
 	ld de, $4
 	ld c, $14
-.asm_414f9
+.loop
 	ld a, [hl]
 	xor $40
 	ld [hl], a
 	add hl, de
 	dec c
-	jr nz, .asm_414f9
+	jr nz, .loop
 	pop hl
 	pop bc
 	pop de
 	ret
 
-Func_41505: ; 41505 (10:5505)
-	callba WriteMonPartySpriteOAMByMonID
-	call Func_41558
+Trade_WriteCircledMonOAM: ; 41505 (10:5505)
+	callba WriteMonPartySpriteOAMBySpecies
+	call Trade_WriteCircleOAM
 
-Func_41510: ; 41510 (10:5510)
+Trade_AddOffsetsToOAMCoords: ; 41510 (10:5510)
 	ld hl, wOAMBuffer
 	ld c, $14
-.asm_41515
+.loop
 	ld a, [W_BASECOORDY]
 	add [hl]
 	ld [hli], a
@@ -549,41 +629,52 @@
 	inc hl
 	inc hl
 	dec c
-	jr nz, .asm_41515
+	jr nz, .loop
 	ret
 
-Func_41525: ; 41525 (10:5525)
-	ld a, [wd08a]
+Trade_AnimMonMoveVertical: ; 41525 (10:5525)
+; 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]
 	and a
-	jr z, .asm_41536
-	ld bc, $400
-	call .asm_4153f
-	ld bc, $a
-	jr .asm_4153f
-.asm_41536
-	ld bc, $f6
-	call .asm_4153f
-	ld bc, $fc00
-.asm_4153f
+	jr z, .movingLeft
+; moving right
+	ld bc, $400 ; move right
+	call .doAnim
+	ld bc, $a ; move down
+	jr .doAnim
+.movingLeft
+	ld bc, $f6 ; move up
+	call .doAnim
+	ld bc, $fc00 ; move left
+.doAnim
 	ld a, b
 	ld [W_BASECOORDX], a
 	ld a, c
 	ld [W_BASECOORDY], a
 	ld d, $4
-.asm_41549
-	call Func_41510
-	call Func_414e8
+.loop
+	call Trade_AddOffsetsToOAMCoords
+	call Trade_AnimCircledMon
 	ld c, $8
 	call DelayFrames
 	dec d
-	jr nz, .asm_41549
+	jr nz, .loop
 	ret
 
-Func_41558: ; 41558 (10:5558)
-	ld hl, OAMPointers_41574
+Trade_WriteCircleOAM: ; 41558 (10:5558)
+; Writes the OAM blocks for the circle around the traded mon as it passes
+; the link cable.
+	ld hl, Trade_CircleOAMPointers
 	ld c, $4
 	xor a
-.asm_4155e
+.loop
 	push bc
 	ld e, [hl]
 	inc hl
@@ -601,32 +692,32 @@
 	pop hl
 	pop bc
 	dec c
-	jr nz, .asm_4155e
+	jr nz, .loop
 	ret
 
-OAMPointers_41574: ; 41574 (10:5574)
-	dw UnknownOAM_41584
+Trade_CircleOAMPointers: ; 41574 (10:5574)
+	dw Trade_CircleOAM0
 	db $08,$08
-	dw UnknownOAM_4158c
+	dw Trade_CircleOAM1
 	db $18,$08
-	dw UnknownOAM_41594
+	dw Trade_CircleOAM2
 	db $08,$18
-	dw UnknownOAM_4159c
+	dw Trade_CircleOAM3
 	db $18,$18
 
-UnknownOAM_41584: ; 41584 (10:5584)
+Trade_CircleOAM0: ; 41584 (10:5584)
 	db $38,$10,$39,$10
 	db $3A,$10,$3B,$10
 
-UnknownOAM_4158c: ; 4158c (10:558c)
+Trade_CircleOAM1: ; 4158c (10:558c)
 	db $39,$30,$38,$30
 	db $3B,$30,$3A,$30
 
-UnknownOAM_41594: ; 41594 (10:5594)
+Trade_CircleOAM2: ; 41594 (10:5594)
 	db $3A,$50,$3B,$50
 	db $38,$50,$39,$50
 
-UnknownOAM_4159c: ; 4159c (10:559c)
+Trade_CircleOAM3: ; 4159c (10:559c)
 	db $3B,$70,$3A,$70
 	db $39,$70,$38,$70
 
@@ -647,7 +738,8 @@
 	ld c, 10
 	jp DelayFrames
 
-Func_415c8: ; 415c8 (10:55c8)
+Trade_ShowClearedWindow: ; 415c8 (10:55c8)
+; clears the window and covers the BG entirely with the window
 	ld a, $1
 	ld [H_AUTOBGTRANSFERENABLED], a
 	call ClearScreen
@@ -661,7 +753,8 @@
 	ld [hSCX], a
 	ret
 
-Func_415df: ; 415df (10:55df)
+Trade_SlideTextBoxOffScreen: ; 415df (10:55df)
+; Slides the window right until it's off screen.
 	ld c, 50
 	call DelayFrames
 .loop
@@ -684,7 +777,7 @@
 	call PrintText
 	ld c, 200
 	call DelayFrames
-	jp Func_415df
+	jp Trade_SlideTextBoxOffScreen
 
 TradeWentToText: ; 4160c (10:560c)
 	TX_FAR _TradeWentToText
@@ -713,7 +806,7 @@
 	ld hl, TradeTransferredText
 	call PrintText
 	call Trade_Delay80
-	jp Func_415df
+	jp Trade_SlideTextBoxOffScreen
 
 TradeWavesFarewellText: ; 41642 (10:5642)
 	TX_FAR _TradeWavesFarewellText
--- a/wram.asm
+++ b/wram.asm
@@ -658,10 +658,18 @@
 
 wcd5b:: ds 1
 wcd5c:: ds 1
-wcd5d:: ds 1
-wcd5e:: ds 1
-wcd5f:: ds 1
 
+wMonPartySpriteSpecies:: ; cd5d
+	ds 1
+
+wLeftGBMonSpecies:: ; cd5e
+; in the trade animation, the mon that leaves the left gameboy
+	ds 1
+
+wRightGBMonSpecies:: ; cd5f
+; in the trade animation, the mon that leaves the right gameboy
+	ds 1
+
 wFlags_0xcd60:: ; cd60
 ; bit 0: is player engaged by trainer (to avoid being engaged by multiple trainers simultaneously)
 ; bit 1: boulder dust animation (from using Strength) pending
@@ -1113,6 +1121,9 @@
 W_NUMFBTILES:: ; d089
 ; number of tiles in current battle animation frame block
 	ds 1
+
+wTradedMonMovingRight:: ; d08a
+; $01 if mon is moving from left gameboy to right gameboy; $00 if vice versa
 
 wd08a:: ds 1