ref: 58020fb5f629693e3f90c0a3c6b417f61330802c
parent: 8740fc6e87f3d0c1099e5755488e61ff3c75ea8c
author: PikalaxALT <PikalaxALT@gmail.com>
date: Sun Nov 22 19:21:21 EST 2015
trade animation
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2532,48 +2532,48 @@
; 3d02b
Function3d02b: ; 3d02b
- ld a, [wc73d]
+ ld a, [wAmuletCoin]
and a
- call nz, Function3d099
- call Function3d0b1
+ call nz, .DoubleReward
+ call .CheckMaxedOutMomMoney
push af
ld a, $0
- jr nc, .asm_3d044
+ jr nc, .okay
ld a, [wMomSavingMoney]
and $7
cp $3
- jr nz, .asm_3d044
+ jr nz, .okay
inc a
-.asm_3d044
+.okay
ld b, a
ld c, $4
-.asm_3d047
+.loop
ld a, b
and a
- jr z, .asm_3d052
- call Function3d081
+ jr z, .loop2
+ call .SendMoneyToMom
dec c
dec b
- jr .asm_3d047
+ jr .loop
-.asm_3d052
+.loop2
ld a, c
and a
- jr z, .asm_3d05c
- call Function3d08d
+ jr z, .done
+ call .AddMoneyToWallet
dec c
- jr .asm_3d052
+ jr .loop2
-.asm_3d05c
- call Function3d099
- call Function3d099
+.done
+ call .DoubleReward
+ call .DoubleReward
pop af
jr nc, .KeepItAll
ld a, [wMomSavingMoney]
and $7
jr z, .KeepItAll
- ld hl, SentToMomTexts
+ ld hl, .SentToMomTexts
dec a
ld c, a
ld b, 0
@@ -2590,26 +2590,26 @@
jp StdBattleTextBox
; 3d081
-Function3d081: ; 3d081
+.SendMoneyToMom: ; 3d081
push bc
- ld hl, wc688
+ ld hl, wBattleReward + 2
ld de, wMomsMoney + 2
- call Function3d0be
+ call AddBattleMoneyToAccount
pop bc
ret
; 3d08d
-Function3d08d: ; 3d08d
+.AddMoneyToWallet: ; 3d08d
push bc
- ld hl, wc688
+ ld hl, wBattleReward + 2
ld de, Money + 2
- call Function3d0be
+ call AddBattleMoneyToAccount
pop bc
ret
; 3d099
-Function3d099: ; 3d099
- ld hl, wc688
+.DoubleReward: ; 3d099
+ ld hl, wBattleReward + 2
sla [hl]
dec hl
rl [hl]
@@ -2624,7 +2624,7 @@
ret
; 3d0ab
-SentToMomTexts: ; 3d0ab
+.SentToMomTexts: ; 3d0ab
dw SentSomeToMomText
dw SentHalfToMomText
dw SentAllToMomText
@@ -2631,7 +2631,7 @@
; 3d0b1
-Function3d0b1: ; 3d0b1
+.CheckMaxedOutMomMoney: ; 3d0b1
ld hl, wMomsMoney + 2
ld a, [hld]
cp 999999 % $100
@@ -2642,7 +2642,7 @@
ret
; 3d0be
-Function3d0be: ; 3d0be
+AddBattleMoneyToAccount: ; 3d0be
ld c, $3
and a
push de
@@ -2653,7 +2653,7 @@
callba MobileFn_106008
pop bc
pop hl
-.asm_3d0ce
+.loop
ld a, [de]
adc [hl]
ld [de], a
@@ -2660,7 +2660,7 @@
dec de
dec hl
dec c
- jr nz, .asm_3d0ce
+ jr nz, .loop
pop hl
ld a, [hld]
cp 999999 % $100
@@ -2823,7 +2823,7 @@
ld a, [CurBattleMon]
ld c, a
ld hl, wBattleParticipantsNotFainted
- ld b, $0
+ ld b, RESET_FLAG
predef FlagPredef
ld hl, EnemySubStatus3
res SUBSTATUS_IN_LOOP, [hl]
@@ -5602,7 +5602,7 @@
cp HELD_AMULET_COIN
ret nz
ld a, 1
- ld [wc73d], a
+ ld [wAmuletCoin], a
ret
; 3e4bc
@@ -6716,7 +6716,7 @@
ld a, [TempEnemyMonSpecies]
dec a
ld c, a
- ld b, 1 ; set
+ ld b, SET_FLAG
ld hl, PokedexSeen
predef FlagPredef
@@ -7741,7 +7741,7 @@
ld hl, EvolvableFlags
ld a, [CurPartyMon]
ld c, a
- ld b, $1
+ ld b, SET_FLAG
predef FlagPredef
pop af
ld [CurPartyLevel], a
@@ -8790,7 +8790,7 @@
inc hl
or [hl]
ret z
- ld a, [wc73d]
+ ld a, [wAmuletCoin]
and a
jr z, .okay
ld hl, wPayDayMoney + 2
@@ -8809,7 +8809,7 @@
.okay
ld hl, wPayDayMoney + 2
ld de, Money + 2
- call Function3d0be
+ call AddBattleMoneyToAccount
ld hl, BattleText_PlayerPickuedUpPayDayMoney
call StdBattleTextBox
ld a, [InBattleTowerBattle]
--- /dev/null
+++ b/battle/used_move_text.asm
@@ -1,0 +1,349 @@
+DisplayUsedMoveText: ; 105db0
+; battle command 03
+ ld hl, UsedMoveText
+ call BattleTextBox
+ jp WaitBGMap
+; 105db9
+
+
+UsedMoveText: ; 105db9
+; this is a stream of text and asm from 105db9 to 105ef6
+
+ text_jump _ActorNameText
+ start_asm
+
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .start
+
+ ld a, [wPlayerMoveStruct + MOVE_ANIM]
+ call UpdateUsedMoves
+
+.start
+ ld a, BATTLE_VARS_LAST_MOVE
+ call GetBattleVarAddr
+ ld d, h
+ ld e, l
+
+ ld a, BATTLE_VARS_LAST_COUNTER_MOVE
+ call GetBattleVarAddr
+
+ ld a, BATTLE_VARS_MOVE_ANIM
+ call GetBattleVar
+ ld [wd265], a
+
+ push hl
+ callba CheckUserIsCharging
+ pop hl
+ jr nz, .grammar
+
+ ; update last move
+ ld a, [wd265]
+ ld [hl], a
+ ld [de], a
+
+.grammar
+ call GetMoveGrammar
+; wd265 now contains MoveGrammar
+
+
+; everything except 'instead' made redundant in localization
+
+ ; check obedience
+ ld a, [AlreadyDisobeyed]
+ and a
+ ld hl, UsedMove2Text
+ ret nz
+
+ ; check move grammar
+ ld a, [wd265]
+ cp $3
+ ld hl, UsedMove2Text
+ ret c
+ ld hl, UsedMove1Text
+ ret
+; 105e04
+
+UsedMove1Text: ; 105e04
+ text_jump _UsedMove1Text
+ start_asm
+ jr Function105e10
+; 105e0b
+
+UsedMove2Text: ; 105e0b
+ text_jump _UsedMove2Text
+ start_asm
+; 105e10
+
+Function105e10: ; 105e10
+; check obedience
+ ld a, [AlreadyDisobeyed]
+ and a
+ jr z, GetMoveNameText
+; print "instead,"
+ ld hl, UsedInsteadText
+ ret
+; 105e1a
+
+UsedInsteadText: ; 105e1a
+ text_jump _UsedInsteadText
+ start_asm
+; 105e1f
+
+GetMoveNameText: ; 105e1f
+ ld hl, MoveNameText
+ ret
+; 105e23
+
+MoveNameText: ; 105e23
+ text_jump _MoveNameText
+ start_asm
+; 105e28
+
+GetUsedMoveTextEnder: ; 105e28
+; get start address
+ ld hl, .endusedmovetexts
+
+; get move id
+ ld a, [wd265]
+
+; 2-byte pointer
+ add a
+
+; seek
+ push bc
+ ld b, $0
+ ld c, a
+ add hl, bc
+ pop bc
+
+; get pointer to usedmovetext ender
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ret
+; 105e39
+
+.endusedmovetexts ; 105e39
+ dw EndUsedMove1Text
+ dw EndUsedMove2Text
+ dw EndUsedMove3Text
+ dw EndUsedMove4Text
+ dw EndUsedMove5Text
+; 105e43
+
+EndUsedMove1Text: ; 105e43
+ text_jump _EndUsedMove1Text
+ db "@"
+; 105e48
+EndUsedMove2Text: ; 105e48
+ text_jump _EndUsedMove2Text
+ db "@"
+; 105e4d
+EndUsedMove3Text: ; 105e4d
+ text_jump _EndUsedMove3Text
+ db "@"
+; 105e52
+EndUsedMove4Text: ; 105e52
+ text_jump _EndUsedMove4Text
+ db "@"
+; 105e57
+EndUsedMove5Text: ; 105e57
+ text_jump _EndUsedMove5Text
+ db "@"
+; 105e5c
+
+
+GetMoveGrammar: ; 105e5c
+; store move grammar type in wd265
+
+ push bc
+; c = move id
+ ld a, [wd265]
+ ld c, a
+ ld b, $0
+
+; read grammar table
+ ld hl, MoveGrammar
+.loop
+ ld a, [hli]
+; end of table?
+ cp $ff
+ jr z, .end
+; match?
+ cp c
+ jr z, .end
+; advance grammar type at $00
+ and a
+ jr nz, .loop
+; next grammar type
+ inc b
+ jr .loop
+
+.end
+; wd265 now contains move grammar
+ ld a, b
+ ld [wd265], a
+
+; we're done
+ pop bc
+ ret
+; 105e7a
+
+MoveGrammar: ; 105e7a
+; made redundant in localization
+; each move is given an identifier for what usedmovetext to use (0-4):
+
+; 0
+ db SWORDS_DANCE
+ db GROWTH
+ db STRENGTH
+ db HARDEN
+ db MINIMIZE
+ db SMOKESCREEN
+ db WITHDRAW
+ db DEFENSE_CURL
+ db EGG_BOMB
+ db SMOG
+ db BONE_CLUB
+ db FLASH
+ db SPLASH
+ db ACID_ARMOR
+ db BONEMERANG
+ db REST
+ db SHARPEN
+ db SUBSTITUTE
+ db MIND_READER
+ db SNORE
+ db PROTECT
+ db SPIKES
+ db ENDURE
+ db ROLLOUT
+ db SWAGGER
+ db SLEEP_TALK
+ db HIDDEN_POWER
+ db PSYCH_UP
+ db EXTREMESPEED
+ db 0 ; end set
+
+; 1
+ db RECOVER
+ db TELEPORT
+ db BIDE
+ db SELFDESTRUCT
+ db AMNESIA
+ db FLAIL
+ db 0 ; end set
+
+; 2
+ db MEDITATE
+ db AGILITY
+ db MIMIC
+ db DOUBLE_TEAM
+ db BARRAGE
+ db TRANSFORM
+ db STRUGGLE
+ db SCARY_FACE
+ db 0 ; end set
+
+; 3
+ db POUND
+ db SCRATCH
+ db VICEGRIP
+ db WING_ATTACK
+ db FLY
+ db BIND
+ db SLAM
+ db HORN_ATTACK
+ db WRAP
+ db THRASH
+ db TAIL_WHIP
+ db LEER
+ db BITE
+ db GROWL
+ db ROAR
+ db SING
+ db PECK
+ db ABSORB
+ db STRING_SHOT
+ db EARTHQUAKE
+ db FISSURE
+ db DIG
+ db TOXIC
+ db SCREECH
+ db METRONOME
+ db LICK
+ db CLAMP
+ db CONSTRICT
+ db POISON_GAS
+ db BUBBLE
+ db SLASH
+ db SPIDER_WEB
+ db NIGHTMARE
+ db CURSE
+ db FORESIGHT
+ db CHARM
+ db ATTRACT
+ db ROCK_SMASH
+ db 0 ; end set
+
+; all other moves = 4
+ db $ff ; end
+; 105ed0
+
+
+UpdateUsedMoves: ; 105ed0
+; append move a to PlayerUsedMoves unless it has already been used
+
+ push bc
+; start of list
+ ld hl, PlayerUsedMoves
+; get move id
+ ld b, a
+; next count
+ ld c, NUM_MOVES
+
+.loop
+; get move from the list
+ ld a, [hli]
+; not used yet?
+ and a
+ jr z, .add
+; already used?
+ cp b
+ jr z, .quit
+; next byte
+ dec c
+ jr nz, .loop
+
+; if the list is full and the move hasn't already been used
+; shift the list back one byte, deleting the first move used
+; this can occur with struggle or a new learned move
+ ld hl, PlayerUsedMoves + 1
+; 1 = 2
+ ld a, [hld]
+ ld [hli], a
+; 2 = 3
+ inc hl
+ ld a, [hld]
+ ld [hli], a
+; 3 = 4
+ inc hl
+ ld a, [hld]
+ ld [hl], a
+; 4 = new move
+ ld a, b
+ ld [PlayerUsedMoves + 3], a
+ jr .quit
+
+.add
+; go back to the byte we just inced from
+ dec hl
+; add the new move
+ ld [hl], b
+
+.quit
+; list updated
+ pop bc
+ ret
+; 105ef6
--- a/engine/billspc.asm
+++ b/engine/billspc.asm
@@ -2547,7 +2547,7 @@
; e36f9
Functione36f9: ; e36f9 (38:76f9)
- ld hl, MenuDataHeader_0xe377b
+ ld hl, .MenuDataHeader
call LoadMenuDataHeader
call InterpretMenu2
call ExitMenu
@@ -2554,34 +2554,34 @@
ret c
ld a, [MenuSelection2]
cp $1
- jr z, .asm_e3734
+ jr z, .Switch
cp $2
- jr z, .asm_e3745
+ jr z, .Name
cp $3
- jr z, .asm_e3717
+ jr z, .Print
and a
ret
-.asm_e3717
call GetBoxCount
and a
- jr z, .asm_e372f
+ jr z, .EmptyBox
ld e, l
ld d, h
ld a, [MenuSelection]
dec a
ld c, a
- callba Function844bc
+ callba PrintPCBox
call Functione35e2
and a
ret
-.asm_e372f
+.EmptyBox
call Functione37be
and a
ret
-.asm_e3734
+.Switch
ld a, [MenuSelection]
dec a
ld e, a
@@ -2591,8 +2591,8 @@
callba ChangeBoxSaveGame
ret
-.asm_e3745
- ld b, $4
+.Name
+ ld b, $4 ; box
ld de, wd002
callba NamingScreen
call ClearTileMap
@@ -2616,15 +2616,15 @@
hlcoord 11, 7 ; XXX
-MenuDataHeader_0xe377b: ; 0xe377b
+.MenuDataHeader: ; 0xe377b
db $40 ; flags
db 04, 11 ; start coords
db 13, 19 ; end coords
- dw MenuData2_0xe3783
+ dw .MenuData2
db 1 ; default option
; 0xe3783
-MenuData2_0xe3783: ; 0xe3783
+.MenuData2: ; 0xe3783
db $80 ; flags
db 4 ; items
db "SWITCH@"
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -83,8 +83,8 @@
ld a, $fe
ld [de], a
ld hl, wc608
- ld de, wc6d0
- ld bc, $c8
+ ld de, wPlayerTrademonSpecies
+ ld bc, wPlayerTrademonSpecies - wc608
call Function75f
xor a
ld [rIF], a
@@ -105,7 +105,7 @@
ld de, OverworldMap
ld bc, $1a2
call Function2879e
- ld de, wc6d0
+ ld de, wPlayerTrademonSpecies
ld hl, wc813
ld c, $2
.asm_280fe
@@ -226,7 +226,7 @@
ld a, $fe
ld [de], a
ld hl, wc608
- ld de, wc6d0
+ ld de, wPlayerTrademonSpecies
ld bc, $c8
call Function75f
ld a, [wLinkMode]
@@ -250,7 +250,7 @@
ld de, OverworldMap
ld bc, $1b9
call Function2879e
- ld de, wc6d0
+ ld de, wPlayerTrademonSpecies
ld hl, wc813
ld c, $2
.asm_28224
@@ -841,12 +841,12 @@
cp LINK_TRADECENTER
ret nz
-; Fill 32 bytes at wc9f4 with $05
+; Fill 5 bytes at wc9f4 with $20
ld de, wc9f4
ld a, $20
call Function28682
-; Copy all the mail messages to $ca14
+; Copy all the mail messages to wc9f9
ld a, BANK(sPartyMail)
call GetSRAMBank
ld hl, sPartyMail
@@ -855,12 +855,12 @@
push bc
ld bc, MAIL_MSG_LENGTH + 1
call CopyBytes
- ld bc, MAIL_STRUCT_LENGTH - MAIL_MSG_LENGTH - 1
+ ld bc, sPartyMon1MailEnd - sPartyMon1MailAuthor
add hl, bc
pop bc
dec b
jr nz, .loop2
-; Copy the mail metadata to $cada
+; Copy the mail metadata to wcabf
ld hl, sPartyMail
ld b, PARTY_LENGTH
.loop3
@@ -867,7 +867,7 @@
push bc
ld bc, MAIL_MSG_LENGTH + 1
add hl, bc
- ld bc, MAIL_STRUCT_LENGTH - MAIL_MSG_LENGTH - 1
+ ld bc, sPartyMon1MailEnd - sPartyMon1MailAuthor
call CopyBytes
pop bc
dec b
@@ -903,7 +903,7 @@
ld d, h
ld e, l
pop hl
- ld bc, $21
+ ld bc, sPartyMon1MailAuthor - sPartyMon1Mail
add hl, bc
pop bc
dec b
@@ -910,12 +910,12 @@
jr nz, .loop4
call CloseSRAM
ld hl, wc9f9
- ld bc, $c6
+ ld bc, PARTY_LENGTH * (sPartyMon1MailAuthor - sPartyMon1Mail)
.loop5
ld a, [hl]
cp $fe
jr nz, .skip2
- ld [hl], $21
+ ld [hl], sPartyMon1MailAuthor - sPartyMon1Mail
.skip2
inc hl
@@ -925,7 +925,7 @@
jr nz, .loop5
ld hl, wcabf
ld de, wcb13
- ld b, $54
+ ld b, PARTY_LENGTH * (sPartyMon1MailEnd - sPartyMon1MailAuthor)
ld c, $0
.loop6
inc c
@@ -1798,7 +1798,7 @@
call CopyBytes
call CloseSRAM
ld hl, PlayerName
- ld de, wc6e7
+ ld de, wPlayerTrademonSenderName
ld bc, NAME_LENGTH
call CopyBytes
ld a, [wd002]
@@ -1807,12 +1807,12 @@
ld c, a
add hl, bc
ld a, [hl]
- ld [wc6d0], a
+ ld [wPlayerTrademonSpecies], a
push af
ld a, [wd002]
ld hl, PartyMonOT
call SkipNames
- ld de, wc6f2
+ ld de, wPlayerTrademonOTName
ld bc, NAME_LENGTH
call CopyBytes
ld hl, PartyMon1ID
@@ -1819,16 +1819,16 @@
ld a, [wd002]
call GetPartyLocation
ld a, [hli]
- ld [PlayerScreens], a
+ ld [wPlayerTrademonID], a
ld a, [hl]
- ld [EnemyScreens], a
+ ld [wPlayerTrademonID + 1], a
ld hl, PartyMon1DVs
ld a, [wd002]
call GetPartyLocation
ld a, [hli]
- ld [wc6fd], a
+ ld [wPlayerTrademonDVs], a
ld a, [hl]
- ld [wPlayerMinimized], a
+ ld [wPlayerTrademonDVs + 1], a
ld a, [wd002]
ld hl, PartyMon1Species
call GetPartyLocation
@@ -1836,9 +1836,9 @@
ld c, l
callba GetCaughtGender
ld a, c
- ld [wc701], a
+ ld [wPlayerTrademonCaughtData], a
ld hl, wd26b
- ld de, wc719
+ ld de, wOTTrademonSenderName
ld bc, NAME_LENGTH
call CopyBytes
ld a, [wd003]
@@ -1847,11 +1847,11 @@
ld c, a
add hl, bc
ld a, [hl]
- ld [wc702], a
+ ld [wOTTrademonSpecies], a
ld a, [wd003]
ld hl, OTPartyMonOT
call SkipNames
- ld de, wc724
+ ld de, wOTTrademonOTName
ld bc, NAME_LENGTH
call CopyBytes
ld hl, OTPartyMon1ID
@@ -1858,16 +1858,16 @@
ld a, [wd003]
call GetPartyLocation
ld a, [hli]
- ld [wEnemyWrapCount], a
+ ld [wOTTrademonID], a
ld a, [hl]
- ld [wPlayerCharging], a
+ ld [wOTTrademonID + 1], a
ld hl, OTPartyMon1DVs
ld a, [wd003]
call GetPartyLocation
ld a, [hli]
- ld [wEnemyTrappingMove], a
+ ld [wOTTrademonDVs], a
ld a, [hl]
- ld [wPlayerWrapCount], a
+ ld [wOTTrademonDVs + 1], a
ld a, [wd003]
ld hl, OTPartyMon1Species
call GetPartyLocation
@@ -1875,7 +1875,7 @@
ld c, l
callba GetCaughtGender
ld a, c
- ld [wEnemyCharging], a
+ ld [wOTTrademonCaughtData], a
ld a, [wd002]
ld [CurPartyMon], a
ld hl, PartySpecies
@@ -1908,14 +1908,14 @@
call GetSGBLayout
ld a, [hLinkPlayerNumber]
cp $1
- jr z, .asm_28de4
- predef Function28f24
- jr .asm_28de9
+ jr z, .player_2
+ predef TradeAnimation
+ jr .done_animation
-.asm_28de4
- predef Function28f63
+.player_2
+ predef TradeAnimationPlayer2
-.asm_28de9
+.done_animation
pop af
ld c, a
ld [CurPartyMon], a
@@ -2050,1542 +2050,7 @@
ret
; 28f24
-Function28f24: ; 28f24
- xor a
- ld [wcf66], a
- ld hl, wc6e7
- ld de, wc719
- call Function297ff
- ld hl, wc6d0
- ld de, wc702
- call Function29814
- ld de, .data_28f3f
- jr Function28fa1
-
-.data_28f3f
- db $1b
- db $1
- db $1c
- db $21
- db $2d
- db $27
- db $23
- db $3
- db $25
- db $28
- db $25
- db $1e
- db $29
- db $6
- db $16
- db $1f
- db $19
- db $17
- db $22
- db $1f
- db $2a
- db $e
- db $3
- db $24
- db $5
- db $25
- db $2
- db $27
- db $25
- db $1d
- db $2c
- db $2e
- db $1e
- db $18
- db $1f
- db $2b
-
-Function28f63: ; 28f63
- xor a
- ld [wcf66], a
- ld hl, wc719
- ld de, wc6e7
- call Function297ff
- ld hl, wc702
- ld de, wc6d0
- call Function29814
- ld de, .data_28f7e
- jr Function28fa1
-
-.data_28f7e
- db $1a
- db $17
- db $22
- db $1f
- db $2a
- db $6
- db $3
- db $24
- db $5
- db $25
- db $2
- db $27
- db $25
- db $1d
- db $2c
- db $2f
- db $1e
- db $18
- db $1f
- db $1b
- db $1
- db $1c
- db $22
- db $27
- db $23
- db $3
- db $25
- db $28
- db $25
- db $1e
- db $29
- db $e
- db $16
- db $1f
- db $2b
-
-Function28fa1: ; 28fa1
- ld hl, BattleEnded
- ld [hl], e
- inc hl
- ld [hl], d
- ld a, [hMapAnims]
- push af
- xor a
- ld [hMapAnims], a
- ld hl, VramState
- ld a, [hl]
- push af
- res 0, [hl]
- ld hl, Options
- ld a, [hl]
- push af
- set 4, [hl]
- call Function28fdb
- ld a, [wcf66]
- and a
- jr nz, .asm_28fca
- ld de, MUSIC_EVOLUTION
- call PlayMusic2
-.asm_28fca
- call Function29082
- jr nc, .asm_28fca
- pop af
- ld [Options], a
- pop af
- ld [VramState], a
- pop af
- ld [hMapAnims], a
- ret
-; 28fdb
-
-Function28fdb: ; 28fdb
- xor a
- ld [wJumptableIndex], a
- call ClearBGPalettes
- call ClearSprites
- call ClearTileMap
- call DisableLCD
- call LoadFontsBattleExtra
- callab Function8cf53
- ld a, [hCGB]
- and a
- jr z, .asm_2900b
- ld a, $1
- ld [rVBK], a
- ld hl, VTiles0
- ld bc, sScratch - VTiles0
- xor a
- call ByteFill
- ld a, $0
- ld [rVBK], a
-
-.asm_2900b
- hlbgcoord 0, 0
- ld bc, sScratch - VBGMap0
- ld a, " "
- call ByteFill
- ld hl, TradeGameBoyLZ
- ld de, VTiles2 tile $31
- call Decompress
- ld hl, TradeArrowGFX
- ld de, VTiles1 tile $6d
- ld bc, $10
- ld a, BANK(TradeArrowGFX)
- call FarCopyBytes
- ld hl, TradeArrowGFX + $10
- ld de, VTiles1 tile $6e
- ld bc, $10
- ld a, BANK(TradeArrowGFX)
- call FarCopyBytes
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function4d7fd
- call EnableLCD
- call Function2982b
- ld a, [wc6d0]
- ld hl, wc6fd
- ld de, VTiles0
- call Function29491
- ld a, [wc702]
- ld hl, wEnemyTrappingMove
- ld de, VTiles0 tile $31
- call Function29491
- ld a, [wc6d0]
- ld de, wc6d1
- call Function294a9
- ld a, [wc702]
- ld de, wc703
- call Function294a9
- call Function297ed
- ret
-; 29082
-
-Function29082: ; 29082
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .asm_2909b
- call Function290a0
- callab Function8cf69
- ld hl, wcf65
- inc [hl]
- call DelayFrame
- and a
- ret
-
-.asm_2909b
- call LoadStandardFont
- scf
- ret
-; 290a0
-
-Function290a0: ; 290a0
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, JumpTable290af
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 290af
-
-JumpTable290af: ; 290af
- dw Function29114
- dw Function2942e
- dw Function29461
- dw Function29348
- dw Function2937e
- dw Function29391
- dw Function29129
- dw Function291af
- dw Function291c4
- dw Function291d9
- dw Function2925d
- dw Function29220
- dw Function2925d
- dw Function29229
- dw Function2913c
- dw Function2925d
- dw Function291e8
- dw Function291fd
- dw Function29211
- dw Function29220
- dw Function2925d
- dw Function29229
- dw Function29701
- dw Function2973c
- dw Function2975c
- dw Function2977f
- dw Function297a4
- dw Function293a6
- dw Function293b6
- dw Function293d2
- dw Function293de
- dw Function293ea
- dw Function2940c
- dw Function294e7
- dw Function294f0
- dw Function2961b
- dw Function2962c
- dw Function29879
- dw Function29886
- dw Function29649
- dw Function29660
- dw Function2926d
- dw Function29277
- dw Function29123
- dw Function29487
- dw Function294f9
- dw Function29502
- dw Function2950c
-; 2910f
-
-Function2910f: ; 2910f
- ld hl, wJumptableIndex
- inc [hl]
- ret
-; 29114
-
-Function29114: ; 29114
- ld hl, BattleEnded
- ld e, [hl]
- inc hl
- ld d, [hl]
- ld a, [de]
- ld [wJumptableIndex], a
- inc de
- ld [hl], d
- dec hl
- ld [hl], e
- ret
-; 29123
-
-Function29123: ; 29123
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-; 29129
-
-Function29129: ; 29129
- ld a, $ed
- call Function292f6
- ld a, [wc74c]
- ld [wd265], a
- xor a
- ld de, $2c58
- ld b, $0
- jr Function2914e
-
-Function2913c: ; 2913c
- ld a, $ee
- call Function292f6
- ld a, [wc74d]
- ld [wd265], a
- ld a, $2
- lb de, $4c, $94
- ld b, $4
-
-Function2914e: ; 2914e
- push bc
- push de
- push bc
- push de
- push af
- call DisableLCD
- callab Function8cf53
- hlbgcoord 20, 3
- ld bc, $c
- ld a, $60
- call ByteFill
- pop af
- call Function29281
- xor a
- ld [hSCX], a
- ld a, $7
- ld [hWX], a
- ld a, $70
- ld [hWY], a
- call EnableLCD
- call Function2985a
- pop de
- ld a, $11
- call _InitSpriteAnimStruct
- ld hl, $b
- add hl, bc
- pop bc
- ld [hl], b
- pop de
- ld a, $12
- call _InitSpriteAnimStruct
- ld hl, $b
- add hl, bc
- pop bc
- ld [hl], b
- call WaitBGMap
- ld b, SCGB_1B
- call GetSGBLayout
- ld a, $e4
- call DmgToCgbBGPals
- ld a, $d0
- call Functioncf8
- call Function2910f
- ld a, $5c
- ld [wcf64], a
- ret
-; 291af
-
-Function291af: ; 291af
- call Function2981d
- ld a, [hSCX]
- add $2
- ld [hSCX], a
- cp $50
- ret nz
- ld a, $1
- call Function29281
- call Function2910f
- ret
-; 291c4
-
-Function291c4: ; 291c4
- call Function2981d
- ld a, [hSCX]
- add $2
- ld [hSCX], a
- cp $a0
- ret nz
- ld a, $2
- call Function29281
- call Function2910f
- ret
-; 291d9
-
-Function291d9: ; 291d9
- call Function2981d
- ld a, [hSCX]
- add $2
- ld [hSCX], a
- and a
- ret nz
- call Function2910f
- ret
-; 291e8
-
-Function291e8: ; 291e8
- call Function2981d
- ld a, [hSCX]
- sub $2
- ld [hSCX], a
- cp $b0
- ret nz
- ld a, $1
- call Function29281
- call Function2910f
- ret
-; 291fd
-
-Function291fd: ; 291fd
- call Function2981d
- ld a, [hSCX]
- sub $2
- ld [hSCX], a
- cp $60
- ret nz
- xor a
- call Function29281
- call Function2910f
- ret
-; 29211
-
-Function29211: ; 29211
- call Function2981d
- ld a, [hSCX]
- sub $2
- ld [hSCX], a
- and a
- ret nz
- call Function2910f
- ret
-; 29220
-
-Function29220: ; 29220
- ld a, $80
- ld [wcf64], a
- call Function2910f
- ret
-; 29229
-
-Function29229: ; 29229
- call ClearBGPalettes
- call ClearTileMap
- call ClearSprites
- call DisableLCD
- callab Function8cf53
- hlbgcoord 0, 0
- ld bc, sScratch - VBGMap0
- ld a, " "
- call ByteFill
- xor a
- ld [hSCX], a
- ld a, $90
- ld [hWY], a
- call EnableLCD
- call Function2982b
- call WaitBGMap
- call Function297ed
- call Function29114
- ret
-; 2925d
-
-Function2925d: ; 2925d
- call Function2981d
- ld hl, wcf64
- ld a, [hl]
- and a
- jr z, .asm_29269
- dec [hl]
- ret
-
-.asm_29269
- call Function2910f
- ret
-; 2926d
-
-Function2926d: ; 2926d
- call Function29114
- ld de, SFX_GIVE_TRADEMON
- call PlaySFX
- ret
-; 29277
-
-Function29277: ; 29277
- call Function29114
- ld de, SFX_GET_TRADEMON
- call PlaySFX
- ret
-; 29281
-
-Function29281: ; 29281
- and 3
- ld e, a
- ld d, 0
- ld hl, Jumptable_2928f
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 2928f
-
-Jumptable_2928f: ; 2928f
- dw Function29297
- dw Function292af
- dw Function292be
- dw Function29297
-; 29297
-
-Function29297: ; 29297
- call Function297cf
- hlcoord 9, 3
- ld [hl], $5b
- inc hl
- ld bc, $a
- ld a, $60
- call ByteFill
- hlcoord 3, 2
- call Function292ec
- ret
-; 292af
-
-Function292af: ; 292af
- call Function297cf
- hlcoord 0, 3
- ld bc, SCREEN_WIDTH
- ld a, $60
- call ByteFill
- ret
-; 292be
-
-Function292be: ; 292be
- call Function297cf
- hlcoord 0, 3
- ld bc, $11
- ld a, $60
- call ByteFill
- hlcoord 17, 3
- ld a, $5d
- ld [hl], a
- ld a, $61
- ld de, SCREEN_WIDTH
- ld c, $3
-.asm_292d9
- add hl, de
- ld [hl], a
- dec c
- jr nz, .asm_292d9
- add hl, de
- ld a, $5f
- ld [hld], a
- ld a, $5b
- ld [hl], a
- hlcoord 10, 6
- call Function292ec
- ret
-; 292ec
-
-Function292ec: ; 292ec
- ld de, TradeGameBoyTilemap
- lb bc, 8, 6
- call Function297db
- ret
-; 292f6
-
-Function292f6: ; 292f6
- push af
- call ClearBGPalettes
- call WaitTop
- ld a, VBGMap1 / $100
- ld [hBGMapAddress + 1], a
- call ClearTileMap
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH
- ld a, "─"
- call ByteFill
- hlcoord 0, 1
- ld de, wc736
- call PlaceString
- ld hl, wc741
- ld de, 0
-.asm_2931e
- ld a, [hli]
- cp "@"
- jr z, .asm_29326
- dec de
- jr .asm_2931e
-
-.asm_29326
- hlcoord 0, 4
- add hl, de
- ld de, wc741
- call PlaceString
- hlcoord 7, 2
- ld bc, 6
- pop af
- call ByteFill
- call WaitBGMap
- call WaitTop
- ld a, VBGMap0 / $100
- ld [hBGMapAddress + 1], a
- call ClearTileMap
- ret
-; 29348
-
-Function29348: ; 29348
- call ClearTileMap
- call WaitTop
- ld a, $a0
- ld [hSCX], a
- call DelayFrame
- hlcoord 8, 2
- ld de, Tilemap_298f7
- lb bc, 3, 12
- call Function297db
- call WaitBGMap
- ld b, SCGB_1B
- call GetSGBLayout
- ld a, $e4
- call DmgToCgbBGPals
- ld de, $e4e4
- call DmgToCgbObjPals
- ld de, SFX_POTION
- call PlaySFX
- call Function2910f
- ret
-; 2937e
-
-Function2937e: ; 2937e
- ld a, [hSCX]
- and a
- jr z, .asm_29388
- add $4
- ld [hSCX], a
- ret
-
-.asm_29388
- ld c, $50
- call DelayFrames
- call Function29114
- ret
-; 29391
-
-Function29391: ; 29391
- ld a, [hSCX]
- cp $a0
- jr z, .asm_2939c
- sub $4
- ld [hSCX], a
- ret
-
-.asm_2939c
- call ClearTileMap
- xor a
- ld [hSCX], a
- call Function29114
- ret
-; 293a6
-
-Function293a6: ; 293a6
- ld a, $8f
- ld [hWX], a
- ld a, $88
- ld [hSCX], a
- ld a, $50
- ld [hWY], a
- call Function29114
- ret
-; 293b6
-
-Function293b6: ; 293b6
- ld a, [hWX]
- cp $7
- jr z, .asm_293c7
- sub $4
- ld [hWX], a
- ld a, [hSCX]
- sub $4
- ld [hSCX], a
- ret
-
-.asm_293c7
- ld a, $7
- ld [hWX], a
- xor a
- ld [hSCX], a
- call Function29114
- ret
-; 293d2
-
-Function293d2: ; 293d2
- ld a, $7
- ld [hWX], a
- ld a, $50
- ld [hWY], a
- call Function29114
- ret
-; 293de
-
-Function293de: ; 293de
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- call Function29114
- ret
-; 293ea
-
-Function293ea: ; 293ea
- call WaitTop
- ld a, VBGMap1 / $100
- ld [hBGMapAddress + 1], a
- call WaitBGMap
- ld a, $7
- ld [hWX], a
- xor a
- ld [hWY], a
- call DelayFrame
- call WaitTop
- ld a, VBGMap0 / $100
- ld [hBGMapAddress + 1], a
- call ClearTileMap
- call Function2910f
- ret
-; 2940c
-
-Function2940c: ; 2940c
- ld a, [hWX]
- cp $a1
- jr nc, .asm_29417
- add $4
- ld [hWX], a
- ret
-
-.asm_29417
- ld a, VBGMap1 / $100
- ld [hBGMapAddress + 1], a
- call WaitBGMap
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- ld a, VBGMap0 / $100
- ld [hBGMapAddress + 1], a
- call Function29114
- ret
-; 2942e
-
-Function2942e: ; 2942e
- call Function2951f
- ld a, [wc6d0]
- ld [CurPartySpecies], a
- ld a, [wc6fd]
- ld [TempMonDVs], a
- ld a, [wPlayerMinimized]
- ld [TempMonDVs + 1], a
- ld b, SCGB_1A
- call GetSGBLayout
- ld a, $e4
- call DmgToCgbBGPals
- call Function294bb
-
- ld a, [wc6d0]
- call GetCryIndex
- jr c, .asm_2945d
- ld e, c
- ld d, b
- call PlayCryHeader
-.asm_2945d
-
- call Function29114
- ret
-; 29461
-
-Function29461: ; 29461
- call Function29549
- ld a, [wc702]
- ld [CurPartySpecies], a
- ld a, [wEnemyTrappingMove]
- ld [TempMonDVs], a
- ld a, [wPlayerWrapCount]
- ld [TempMonDVs + 1], a
- ld b, SCGB_1A
- call GetSGBLayout
- ld a, $e4
- call DmgToCgbBGPals
- call Function294c0
- call Function29114
- ret
-; 29487
-
-Function29487: ; 29487
- callba Function4d81e
- call Function29114
- ret
-; 29491
-
-Function29491: ; 29491
- push de
- push af
- predef GetUnownLetter
- pop af
- ld [CurPartySpecies], a
- ld [CurSpecies], a
- call GetBaseData
- pop de
- predef GetFrontpic
- ret
-; 294a9
-
-Function294a9: ; 294a9
- push de
- ld [wd265], a
- call GetPokemonName
- ld hl, StringBuffer1
- pop de
- ld bc, NAME_LENGTH
- call CopyBytes
- ret
-; 294bb
-
-Function294bb: ; 294bb
- ld de, VTiles0
- jr Function294c3
-
-Function294c0: ; 294c0
- ld de, VTiles0 tile $31
-
-Function294c3: ; 294c3
- call DelayFrame
- ld hl, VTiles2
- ld bc, $a31
- call Request2bpp
- call WaitTop
- call Function297cf
- hlcoord 7, 2
- xor a
- ld [hFillBox], a
- lb bc, 7, 7
- predef FillBox
- call WaitBGMap
- ret
-; 294e7
-
-Function294e7: ; 294e7
- ld c, $50
- call DelayFrames
- call Function29114
- ret
-; 294f0
-
-Function294f0: ; 294f0
- ld c, $28
- call DelayFrames
- call Function29114
- ret
-; 294f9
-
-Function294f9: ; 294f9
- ld c, $60
- call DelayFrames
- call Function29114
- ret
-; 29502
-
-Function29502: ; 29502
- call Function29516
- ret nz
- ld c, $50
- call DelayFrames
- ret
-; 2950c
-
-Function2950c: ; 2950c
- call Function29516
- ret nz
- ld c, $b4
- call DelayFrames
- ret
-; 29516
-
-Function29516: ; 29516
- call Function29114
- ld a, [wc702]
- cp $fd
- ret
-; 2951f
-
-Function2951f: ; 2951f
- ld de, wc6d0
- ld a, [de]
- cp $fd
- jr z, Function295a1
- call Function29573
- ld de, wc6d0
- call Function295e3
- ld de, wc6d1
- call Function295ef
- ld a, [wc701]
- ld de, wc6f2
- call Function295f6
- ld de, PlayerScreens
- call Function29611
- call Function295d8
- ret
-; 29549
-
-Function29549: ; 29549
- ld de, wc702
- ld a, [de]
- cp $fd
- jr z, Function295a1
- call Function29573
- ld de, wc702
- call Function295e3
- ld de, wc703
- call Function295ef
- ld a, [wEnemyCharging]
- ld de, wc724
- call Function295f6
- ld de, wEnemyWrapCount
- call Function29611
- call Function295d8
- ret
-; 29573
-
-Function29573: ; 29573
- call WaitTop
- call Function297cf
- ld a, VBGMap1 / $100
- ld [hBGMapAddress + 1], a
- hlcoord 3, 0
- ld b, $6
- ld c, $d
- call TextBox
- hlcoord 4, 0
- ld de, String29591
- call PlaceString
- ret
-; 29591
-
-String29591: ; 29591
- db "─── №."
- next ""
- next "OT/"
- next $73, "№.@"
-; 295a1
-
-Function295a1: ; 295a1
- call WaitTop
- call Function297cf
- ld a, VBGMap1 / $100
- ld [hBGMapAddress + 1], a
- hlcoord 3, 0
- ld b, $6
- ld c, $d
- call TextBox
- hlcoord 4, 2
- ld de, String295c2
- call PlaceString
- call Function295d8
- ret
-; 295c2
-
-String295c2: ; 295c2
- db "EGG"
- next "OT/?????"
- next $73, "№.?????@"
-; 295d8
-
-Function295d8: ; 295d8
- call WaitBGMap
- call WaitTop
- ld a, VBGMap0 / $100
- ld [hBGMapAddress + 1], a
- ret
-; 295e3
-
-Function295e3: ; 295e3
- hlcoord 10, 0
- lb bc, PRINTNUM_LEADINGZEROS | 1, 3
- call PrintNum
- ld [hl], $7f
- ret
-; 295ef
-
-Function295ef: ; 295ef
- hlcoord 4, 2
- call PlaceString
- ret
-; 295f6
-
-Function295f6: ; 295f6
- cp 3
- jr c, .asm_295fb
- xor a
-
-.asm_295fb
- push af
- hlcoord 7, 4
- call PlaceString
- inc bc
- pop af
- ld hl, Unknown_2960e
- ld d, 0
- ld e, a
- add hl, de
- ld a, [hl]
- ld [bc], a
- ret
-; 2960e
-
-Unknown_2960e: ; 2960e
- db " ", "♂", "♀"
-; 29611
-
-Function29611: ; 29611
- hlcoord 7, 6
- lb bc, PRINTNUM_LEADINGZEROS | 2, 5
- call PrintNum
- ret
-; 2961b
-
-Function2961b: ; 2961b
- depixel 10, 11, 4, 0
- ld a, $e
- call _InitSpriteAnimStruct
- call Function29114
- ld a, $20
- ld [wcf64], a
- ret
-; 2962c
-
-Function2962c: ; 2962c
- depixel 10, 11, 4, 0
- ld a, $e
- call _InitSpriteAnimStruct
- ld hl, $b
- add hl, bc
- ld [hl], $1
- ld hl, $7
- add hl, bc
- ld [hl], $dc
- call Function29114
- ld a, $38
- ld [wcf64], a
- ret
-; 29649
-
-Function29649: ; 29649
- depixel 10, 11, 4, 0
- ld a, $f
- call _InitSpriteAnimStruct
- call Function29114
- ld a, $10
- ld [wcf64], a
- ld de, SFX_BALL_POOF
- call PlaySFX
- ret
-; 29660
-
-Function29660: ; 29660
- ld a, $e4
- call Functioncf8
- depixel 5, 11
- ld a, $10
- call _InitSpriteAnimStruct
- call Function29114
- ld a, $40
- ld [wcf64], a
- ret
-; 29676
-
-Function29676: ; 29676 (a:5676)
- ld hl, $b
- add hl, bc
- ld e, [hl]
- ld d, 0
- ld hl, Jumptable_29686
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 29686
-
-Jumptable_29686: ; 29686 (a:5686)
- dw Function2969a
- dw Function296a4
- dw Function296af
- dw Function296bd
- dw Function296cf
- dw Function296dd
- dw Function296f2
-; 2969a
-
-Function29694: ; 29694 (a:5694)
- ld hl, $b
- add hl, bc
- inc [hl]
- ret
-
-Function2969a: ; 2969a (a:569a)
- call Function29694
- ld hl, $c
- add hl, bc
- ld [hl], $80
- ret
-
-Function296a4: ; 296a4 (a:56a4)
- ld hl, $c
- add hl, bc
- ld a, [hl]
- dec [hl]
- and a
- ret nz
- call Function29694
-
-Function296af: ; 296af (a:56af)
- ld hl, $4
- add hl, bc
- ld a, [hl]
- cp $94
- jr nc, .asm_296ba
- inc [hl]
- ret
-.asm_296ba
- call Function29694
-
-Function296bd: ; 296bd (a:56bd)
- ld hl, $5
- add hl, bc
- ld a, [hl]
- cp $4c
- jr nc, .asm_296c8
- inc [hl]
- ret
-.asm_296c8
- ld hl, $
- add hl, bc
- ld [hl], $0
- ret
-
-Function296cf: ; 296cf (a:56cf)
- ld hl, $5
- add hl, bc
- ld a, [hl]
- cp $2c
- jr z, .asm_296da
- dec [hl]
- ret
-.asm_296da
- call Function29694
-
-Function296dd: ; 296dd (a:56dd)
- ld hl, $4
- add hl, bc
- ld a, [hl]
- cp $58
- jr z, .asm_296e8
- dec [hl]
- ret
-.asm_296e8
- call Function29694
- ld hl, $c
- add hl, bc
- ld [hl], $80
- ret
-
-Function296f2: ; 296f2 (a:56f2)
- ld hl, $c
- add hl, bc
- ld a, [hl]
- dec [hl]
- and a
- ret nz
- ld hl, $
- add hl, bc
- ld [hl], $0
- ret
-; 29701 (a:5701)
-
-Function29701: ; 29701
- ld a, [wLinkMode]
- cp LINK_TIMECAPSULE
- jr z, .asm_29725
- ld hl, UnknownText_0x29737
- call PrintText
- ld c, $bd
- call DelayFrames
- ld hl, UnknownText_0x29732
- call PrintText
- call Function297c9
- ld c, $80
- call DelayFrames
- call Function29114
- ret
-
-.asm_29725
- ld hl, UnknownText_0x29732
- call PrintText
- call Function297c9
- call Function29114
- ret
-; 29732
-
-UnknownText_0x29732: ; 0x29732
- ; was sent to @ .
- text_jump UnknownText_0x1bc6e9
- db "@"
-; 0x29737
-
-UnknownText_0x29737: ; 0x29737
- ;
- text_jump UnknownText_0x1bc701
- db "@"
-; 0x2973c
-
-Function2973c: ; 2973c
- ld hl, UnknownText_0x29752
- call PrintText
- call Function297c9
- ld hl, UnknownText_0x29757
- call PrintText
- call Function297c9
- call Function29114
- ret
-; 29752
-
-UnknownText_0x29752: ; 0x29752
- ; bids farewell to
- text_jump UnknownText_0x1bc703
- db "@"
-; 0x29757
-
-UnknownText_0x29757: ; 0x29757
- ; .
- text_jump UnknownText_0x1bc719
- db "@"
-; 0x2975c
-
-Function2975c: ; 2975c
- call WaitTop
- hlcoord 0, 10
- ld bc, 8 * SCREEN_WIDTH
- ld a, " "
- call ByteFill
- call WaitBGMap
- ld hl, UnknownText_0x2977a
- call PrintText
- call Function297c9
- call Function29114
- ret
-; 2977a
-
-UnknownText_0x2977a: ; 0x2977a
- ; Take good care of @ .
- text_jump UnknownText_0x1bc71f
- db "@"
-; 0x2977f
-
-Function2977f: ; 2977f
- ld hl, UnknownText_0x2979a
- call PrintText
- call Function297c9
- ld hl, UnknownText_0x2979f
- call PrintText
- call Function297c9
- ld c, $e
- call DelayFrames
- call Function29114
- ret
-; 2979a
-
-UnknownText_0x2979a: ; 0x2979a
- ; For @ 's @ ,
- text_jump UnknownText_0x1bc739
- db "@"
-; 0x2979f
-
-UnknownText_0x2979f: ; 0x2979f
- ; sends @ .
- text_jump UnknownText_0x1bc74c
- db "@"
-; 0x297a4
-
-Function297a4: ; 297a4
- ld hl, UnknownText_0x297bf
- call PrintText
- call Function297c9
- ld hl, UnknownText_0x297c4
- call PrintText
- call Function297c9
- ld c, $e
- call DelayFrames
- call Function29114
- ret
-; 297bf
-
-UnknownText_0x297bf: ; 0x297bf
- ; will trade @ @
- text_jump UnknownText_0x1bc75e
- db "@"
-; 0x297c4
-
-UnknownText_0x297c4: ; 0x297c4
- ; for @ 's @ .
- text_jump UnknownText_0x1bc774
- db "@"
-; 0x297c9
-
-Function297c9: ; 297c9
- ld c, $50
- call DelayFrames
- ret
-; 297cf
-
-Function297cf: ; 297cf
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, " "
- call ByteFill
- ret
-; 297db
-
-Function297db: ; 297db
-.asm_297db
- push bc
- push hl
-.asm_297dd
- ld a, [de]
- inc de
- ld [hli], a
- dec c
- jr nz, .asm_297dd
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .asm_297db
- ret
-; 297ed
-
-Function297ed: ; 297ed
- ld a, [hSGB]
- and a
- ld a, $e4
- jr z, .asm_297f6
- ld a, $f0
-
-.asm_297f6
- call Functioncf8
- ld a, $e4
- call DmgToCgbBGPals
- ret
-; 297ff
-
-Function297ff: ; 297ff
- push de
- ld de, wc736
- ld bc, NAME_LENGTH
- call CopyBytes
- pop hl
- ld de, wc741
- ld bc, NAME_LENGTH
- call CopyBytes
- ret
-; 29814
-
-Function29814: ; 29814
- ld a, [hl]
- ld [wc74c], a
- ld a, [de]
- ld [wc74d], a
- ret
-; 2981d
-
-Function2981d: ; 2981d
- ld a, [wcf65]
- and $7
- ret nz
- ld a, [rBGP]
- xor $3c
- call DmgToCgbBGPals
- ret
-; 2982b
-
-Function2982b: ; 2982b
- call DelayFrame
- ld de, TradeBallGFX
- ld hl, VTiles0 tile $62
- lb bc, BANK(TradeBallGFX), $6
- call Request2bpp
- ld de, TradePoofGFX
- ld hl, VTiles0 tile $68
- lb bc, BANK(TradePoofGFX), $c
- call Request2bpp
- ld de, TradeCableGFX
- ld hl, VTiles0 tile $74
- lb bc, BANK(TradeCableGFX), $4
- call Request2bpp
- xor a
- ld hl, wc300
- ld [hli], a
- ld [hl], $62
- ret
-; 2985a
-
-Function2985a: ; 2985a
- call DelayFrame
- ld e, $3
- callab Function8e83f
- ld de, TradeBubbleGFX
- ld hl, VTiles0 tile $72
- lb bc, BANK(TradeBubbleGFX), $4
- call Request2bpp
- xor a
- ld hl, wc300
- ld [hli], a
- ld [hl], $62
- ret
-; 29879
-
-Function29879: ; 29879
- ld hl, wcf64
- ld a, [hl]
- and a
- jr z, .asm_29882
- dec [hl]
- ret
-
-.asm_29882
- call Function29114
- ret
-; 29886
-
-Function29886: ; 29886
- ld hl, wcf64
- ld a, [hl]
- and a
- jr z, .asm_2988f
- dec [hl]
- ret
-
-.asm_2988f
- call Function29114
- ret
-; 29893
-
-
-Function29893: ; 29893
-; This function is unreferenced.
-; It was meant for use in Japanese versions, so the
-; constant used for copy length was changed by accident.
-
- ld hl, Unknown_298b5
-
- ld a, [hli]
- ld [wc6d0], a
- ld de, wc6e7
- ld c, 13 ; jp: 8
-.asm_2989f
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_2989f
-
- ld a, [hli]
- ld [wc702], a
- ld de, wc719
- ld c, 13 ; jp: 8
-.asm_298ae
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_298ae
- ret
-; 298b5
-
-Unknown_298b5: ; 298b5
- db $03, "ゲーフり@@", $23, $01 ; GAME FREAK
- db $06, "クりーチャ@", $56, $04 ; Creatures Inc.
-; 298c7
-
-
-TradeGameBoyTilemap: ; 298c7
-; 6x8
- db $31, $32, $32, $32, $32, $33
- db $34, $35, $36, $36, $37, $38
- db $34, $39, $3a, $3a, $3b, $38
- db $3c, $3d, $3e, $3e, $3f, $40
- db $41, $42, $43, $43, $44, $45
- db $46, $47, $43, $48, $49, $4a
- db $41, $43, $4b, $4c, $4d, $4e
- db $4f, $50, $50, $50, $51, $52
-; 297f7
-
-Tilemap_298f7: ; 297f7
-; 12x3
- db $43, $55, $56, $53, $53, $53, $53, $53, $53, $53, $53, $53
- db $43, $57, $58, $54, $54, $54, $54, $54, $54, $54, $54, $54
- db $43, $59, $5a, $43, $43, $43, $43, $43, $43, $43, $43, $43
-; 2991b
-
-TradeArrowGFX: INCBIN "gfx/trade/arrow.2bpp"
-TradeCableGFX: INCBIN "gfx/trade/cable.2bpp"
-TradeBubbleGFX: INCBIN "gfx/trade/bubble.2bpp"
-TradeGameBoyLZ: INCBIN "gfx/trade/game_boy.2bpp.lz"
-TradeBallGFX: INCBIN "gfx/trade/ball.2bpp"
-TradePoofGFX: INCBIN "gfx/trade/poof.2bpp"
+INCLUDE "engine/trade/animation.asm"
Special_CheckTimeCapsuleCompatibility: ; 29bfb
; Checks to see if your Party is compatible with the generation 1 games. Returns the following in ScriptVar:
--- a/engine/mail.asm
+++ b/engine/mail.asm
@@ -489,7 +489,7 @@
ld a, BANK(sMailboxCount)
call GetSRAMBank
pop af
- ld hl, sMailbox1MailType
+ ld hl, sMailbox1Type
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
--- a/engine/main_menu.asm
+++ b/engine/main_menu.asm
@@ -161,9 +161,9 @@
cp $1
ld a, $1
ret nz
- ld a, BANK(s0_abe5)
+ ld a, BANK(sNumDailyMysteryGiftPartnerIDs)
call GetSRAMBank
- ld a, [s0_abe5]
+ ld a, [sNumDailyMysteryGiftPartnerIDs]
cp $ff
call CloseSRAM
jr nz, .done
--- /dev/null
+++ b/engine/mysterygift.asm
@@ -1,0 +1,1702 @@
+DoMysteryGift: ; 1048ba (41:48ba)
+ call ClearTileMap
+ call ClearSprites
+ call WaitBGMap
+ call Function105153
+ hlcoord 3, 8
+ ld de, .String_PressAToLink_BToCancel
+ call PlaceString
+ call WaitBGMap
+ callba Function2c642
+ call Function1050fb
+ ld a, $2
+ ld [wca01], a
+ ld a, $14
+ ld [wca02], a
+ ld a, [rIE]
+ push af
+ call Function104a95
+ ld d, a
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ push de
+ call ClearTileMap
+ call EnableLCD
+ call WaitBGMap
+ ld b, SCGB_08
+ call GetSGBLayout
+ call SetPalettes
+ pop de
+ hlcoord 2, 8
+ ld a, d
+ ld de, .Text_LinkCanceled ; Link has been canceled
+ cp $10
+ jp z, .LinkCanceled
+ cp $6c
+ jp nz, .CommunicationError
+ ld a, [wc900]
+ cp $3
+ jr z, .skip_checks
+ call .CheckAlreadyGotFiveGiftsToday
+ ld hl, .Text_MaxFiveGifts ; Only 5 gifts a day
+ jp nc, .PrintTextAndExit
+ call .CheckAlreadyGotAGiftFromThatPerson
+ ld hl, .Text_MaxOneGiftPerPerson ; Only one gift a day per person
+ jp c, .PrintTextAndExit
+.skip_checks
+ ld a, [wc962]
+ and a
+ jp nz, .GiftWaiting
+ ld a, [wc912]
+ and a
+ jp nz, .FriendNotReady
+ ld a, [wc900]
+ cp $3
+ jr z, .skip_append_save
+ call .AddMysteryGiftPartnerID
+ ld a, [wc900]
+ cp $4
+ jr z, .skip_append_save
+ call .SaveMysteryGiftTrainerName
+ callba RestoreMobileEventIndex
+ callba MobileFn_1060a9
+ callba BackupMobileEventIndex
+.skip_append_save
+ ld a, [wc90f]
+ and a
+ jr z, .item
+ ld a, [wc911]
+ ld c, a
+ callba MysteryGiftGetDecoration
+ push bc
+ call Function105069
+ pop bc
+ jr nz, .item
+ callab GetDecorationName_c
+ ld h, d
+ ld l, e
+ ld de, StringBuffer1
+ ld bc, ITEM_NAME_LENGTH
+ call CopyBytes
+ ld hl, .Text_SentToHome ; sent decoration to home
+ jr .PrintTextAndExit
+
+.item
+ call GetMysteryGiftBank
+ ld a, [wc910]
+ ld c, a
+ callba MysteryGiftGetItemHeldEffect
+ ld a, c
+ ld [sBackupMysteryGiftItem], a
+ ld [wNamedObjectIndexBuffer], a
+ call CloseSRAM
+ call GetItemName
+ ld hl, .Text_Sent ; sent item
+ jr .PrintTextAndExit
+
+.LinkCanceled: ; 1049af (41:49af)
+ ld hl, .Text_LinkCanceled ; Link has been canceled
+ jr .PrintTextAndExit
+
+.CommunicationError: ; 1049b4 (41:49b4)
+ ld hl, .Text_CommunicationError ; Communication error
+ call PrintText
+ jp DoMysteryGift
+
+.GiftWaiting: ; 1049bd (41:49bd)
+ ld hl, .Text_ReceiveGiftAtCounter ; receive gift at counter
+ jr .PrintTextAndExit
+
+.FriendNotReady: ; 1049c2 (41:49c2)
+ ld hl, .Text_FriendNotReady ; friend not ready
+
+.PrintTextAndExit: ; 1049c5 (41:49c5)
+ call PrintText
+ ld a, $e3
+ ld [rLCDC], a
+ ret
+; 1049cd (41:49cd)
+
+.String_PressAToLink_BToCancel: ; 1049cd
+ db "Press A to"
+ next "link IR-Device"
+ next "Press B to"
+ next "cancel it."
+ db "@"
+; 1049fd
+
+.Text_LinkCanceled: ; 1049fd
+ text_jump UnknownText_0x1c0436
+ db "@"
+; 104a02
+
+.Text_CommunicationError: ; 104a02
+ text_jump UnknownText_0x1c0454
+ db "@"
+; 104a07
+
+.Text_ReceiveGiftAtCounter: ; 104a07
+ text_jump UnknownText_0x1c046a
+ db "@"
+; 104a0c
+
+.Text_FriendNotReady: ; 104a0c
+ text_jump UnknownText_0x1c048e
+ db "@"
+; 104a11
+
+.Text_MaxFiveGifts: ; 104a11
+ text_jump UnknownText_0x1c04a7
+ db "@"
+; 104a16
+
+.Text_MaxOneGiftPerPerson: ; 104a16
+ text_jump UnknownText_0x1c04c6
+ db "@"
+; 104a1b
+
+.Text_Sent: ; 104a1b
+ text_jump UnknownText_0x1c04e9
+ db "@"
+; 104a20
+
+.Text_SentToHome: ; 104a20
+ text_jump UnknownText_0x1c04fa
+ db "@"
+; 104a25
+
+.CheckAlreadyGotFiveGiftsToday: ; 104a25 (41:4a25)
+ call GetMysteryGiftBank
+ ld a, [sNumDailyMysteryGiftPartnerIDs]
+ cp $5
+ jp CloseSRAM
+
+.CheckAlreadyGotAGiftFromThatPerson: ; 104a30 (41:4a30)
+ call GetMysteryGiftBank
+ ld a, [wMysteryGiftPartnerID]
+ ld b, a
+ ld a, [wMysteryGiftPartnerID + 1]
+ ld c, a
+ ld a, [sNumDailyMysteryGiftPartnerIDs]
+ ld d, a
+ ld hl, sDailyMysteryGiftPartnerIDs
+.loop
+ ld a, d
+ and a
+ jr z, .No
+ ld a, [hli]
+ cp b
+ jr nz, .skip
+ ld a, [hl]
+ cp c
+ jr z, .Yes
+.skip
+ inc hl
+ dec d
+ jr .loop
+.Yes
+ scf
+.No
+ jp CloseSRAM
+
+.AddMysteryGiftPartnerID: ; 104a56 (41:4a56)
+ call GetMysteryGiftBank
+ ld hl, sNumDailyMysteryGiftPartnerIDs
+ ld a, [hl]
+ inc [hl]
+ ld hl, sDailyMysteryGiftPartnerIDs ; inc hl
+ ld e, a
+ ld d, $0
+rept 2
+ add hl, de
+endr
+ ld a, [wMysteryGiftPartnerID]
+ ld [hli], a
+ ld a, [wMysteryGiftPartnerID + 1]
+ ld [hl], a
+ jp CloseSRAM
+
+.SaveMysteryGiftTrainerName: ; 104a71 (41:4a71)
+ call GetMysteryGiftBank
+ ld a, $1
+ ld [sMysteryGiftTrainerHouseFlag], a
+ ld hl, wMysteryGiftPartnerName
+ ld de, sMysteryGiftPartnerName
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ld a, $1
+ ld [de], a
+ inc de
+ ld hl, wMysteryGiftTrainerData
+ ld bc, (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2
+ call CopyBytes
+ jp CloseSRAM
+
+Function104a95: ; 104a95 (41:4a95)
+ di
+ callba ClearChannels
+ call Function104d5e
+.loop2
+ call Function104d96
+ call Function104ddd
+ ld a, [hPrintNum10]
+ cp $10
+ jp z, Function104bd0
+ cp $6c
+ jr nz, .loop2
+ ld a, [hPrintNum9]
+ cp $2
+ jr z, Function104b22
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d56
+ jr nz, .ly_loop
+ call Function104b49
+ jp nz, Function104bd0
+ jr asm_104b0a
+.ly_loop
+ ld a, [rLY]
+ cp $90
+ jr c, .ly_loop
+ ld c, rRP % $100
+ ld a, $c0
+ ld [$ff00+c], a
+ ld b, $f0
+.loop3
+ push bc
+ call Function105038
+ ld b, $2
+ ld c, rRP % $100
+.ly_loop2
+ ld a, [$ff00+c]
+ and b
+ ld b, a
+ ld a, [rLY]
+ cp $90
+ jr nc, .ly_loop2
+.ly_loop3
+ ld a, [$ff00+c]
+ and b
+ ld b, a
+ ld a, [rLY]
+ cp $90
+ jr c, .ly_loop3
+ ld a, b
+ pop bc
+ dec b
+ jr z, .loop2
+ or a
+ jr nz, .loop2
+ ld a, [hMoneyTemp + 1]
+ bit 1, a
+ jr z, .loop3
+ ld a, $10
+ ld [hPrintNum10], a
+ jp Function104bd0
+
+Function104b04: ; 104b04 (41:4b04)
+ call Function104b40
+ jp nz, Function104bd0
+
+asm_104b0a: ; 104b0a (41:4b0a)
+ call Function104d38
+ jp nz, Function104bd0
+ call Function104b88
+ jp nz, Function104bd0
+ call Function104d43
+ jp nz, Function104bd0
+ call Function105033
+ jp Function104bd0
+
+Function104b22: ; 104b22 (41:4b22)
+ call Function104b88
+ jp nz, Function104bd0
+ call Function104d43
+ jp nz, Function104bd0
+ call Function104b40
+ jp nz, Function104bd0
+ call Function104d38
+ jp nz, Function104bd0
+ call Function10502e
+ jp Function104bd0
+
+Function104b40: ; 104b40 (41:4b40)
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d56
+ ret nz
+
+Function104b49: ; 104b49 (41:4b49)
+ call Function105033
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ ld a, [$ffb3]
+ cp $96
+ jp nz, Function104d32
+ ld a, $90
+ ld [$ffb3], a
+ call Function104d38
+ ret nz
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d4e
+ ret nz
+ call Function10502e
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ call Function104d43
+ ret nz
+ ld hl, wMysteryGiftTrainerData
+ ld a, [wca02]
+ ld b, a
+ call Function104d56
+ ret nz
+ call Function105033
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104b88: ; 104b88 (41:4b88)
+ ld a, $96
+ ld [$ffb3], a
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d4e
+ ret nz
+ call Function10502e
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ call Function104d43
+ ret nz
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d56
+ ret nz
+ call Function105033
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ ld a, [$ffb3]
+ cp $90
+ jp nz, Function104d32
+ call Function104d38
+ ret nz
+ ld hl, OverworldMap
+ ld a, [wca02]
+ ld b, a
+ call Function104d4e
+ ret nz
+ call Function10502e
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104bd0: ; 104bd0 (41:4bd0)
+ nop
+ ld a, [hPrintNum10]
+ cp $10
+ jr z, .asm_104c18
+ cp $6c
+ jr nz, .asm_104c18
+ ld hl, wca01
+ dec [hl]
+ jr z, .asm_104c18
+ ld hl, wMysteryGiftTrainerData
+ ld de, wc900
+ ld bc, $14
+ call CopyBytes
+ ld a, [wMysteryGiftTrainerData]
+ cp $3
+ jr nc, .asm_104c18
+ callba Function10510b
+ call Function1050fb
+ ld a, $26
+ ld [wca02], a
+ ld a, [hPrintNum9]
+ cp $2
+ jr z, .asm_104c10
+ call Function104d43
+ jr nz, Function104bd0
+ jp Function104b04
+.asm_104c10
+ call Function104d38
+ jr nz, Function104bd0
+ jp Function104b22
+.asm_104c18
+ ld a, [hPrintNum10]
+ push af
+ call Function104da0
+ xor a
+ ld [rIF], a
+ ld a, [rIE]
+ or $1
+ ld [rIE], a
+ ei
+ call DelayFrame
+ pop af
+ ret
+
+Function104c2d: ; 104c2d (41:4c2d)
+ di
+ callba ClearChannels
+ call Function104d5e
+.asm_104c37
+ call Function104d96
+ call Function104ddd
+ ld a, [hPrintNum10]
+ cp $10
+ jp z, Function104d1c
+ cp $6c
+ jr nz, .asm_104c37
+ ld a, [hPrintNum9]
+ cp $2
+ jr z, .asm_104c6c
+ call Function104c8a
+ jp nz, Function104d1c
+ call Function104d38
+ jp nz, Function104d1c
+ call Function104cd2
+ jp nz, Function104d1c
+ call Function104d43
+ jp nz, Function104d1c
+ call Function105033
+ jp Function104d1c
+.asm_104c6c
+ call Function104cd2
+ jp nz, Function104d1c
+ call Function104d43
+ jp nz, Function104d1c
+ call Function104c8a
+ jp nz, Function104d1c
+ call Function104d38
+ jp nz, Function104d1c
+ call Function10502e
+ jp Function104d1c
+
+Function104c8a: ; 104c8a (41:4c8a)
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d56
+ ret nz
+ call Function105033
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ ld a, [$ffb3]
+ cp $3c
+ jp nz, Function104d32
+ swap a
+ ld [$ffb3], a
+ call Function104d38
+ ret nz
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d4e
+ ret nz
+ call Function10502e
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ call Function104d43
+ ret nz
+ ld hl, wMysteryGiftTrainerData
+ ld a, [wca02]
+ ld b, a
+ call Function104d56
+ ret nz
+ call Function105033
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104cd2: ; 104cd2 (41:4cd2)
+ ld a, $3c
+ ld [$ffb3], a
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d4e
+ ret nz
+ call Function10502e
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ call Function104d43
+ ret nz
+ ld hl, $ffb3
+ ld b, $1
+ call Function104d56
+ ret nz
+ call Function105033
+ ld a, [hPrintNum10]
+ cp $6c
+ ret nz
+ ld a, [$ffb3]
+ swap a
+ cp $3c
+ jp nz, Function104d32
+ call Function104d38
+ ret nz
+ ld hl, OverworldMap
+ ld a, [wca02]
+ ld b, a
+ call Function104d4e
+ ret nz
+ call Function10502e
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104d1c: ; 104d1c (41:4d1c)
+ nop
+ ld a, [hPrintNum10]
+ push af
+ call Function104da0
+ xor a
+ ld [rIF], a
+ ld a, [rIE]
+ or $1
+ ld [rIE], a
+ ei
+ call DelayFrame
+ pop af
+ ret
+
+Function104d32: ; 104d32 (41:4d32)
+ ld a, $80
+ ld [hPrintNum10], a
+ and a
+ ret
+
+Function104d38: ; 104d38 (41:4d38)
+ call Function104d96
+ call Function104e46
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104d43: ; 104d43 (41:4d43)
+ call Function104d96
+ call Function104dfe
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104d4e: ; 104d4e (41:4d4e)
+ call Function104e93
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104d56: ; 104d56 (41:4d56)
+ call Function104f57
+ ld a, [hPrintNum10]
+ cp $6c
+ ret
+
+Function104d5e: ; 104d5e (41:4d5e)
+ call Function104d74
+ ld a, $4
+ ld [rIE], a
+ xor a
+ ld [rIF], a
+ call Function104d96
+ xor a
+ ld b, a
+.asm_104d6d
+ inc a
+ jr nz, .asm_104d6d
+ inc b
+ jr nz, .asm_104d6d
+ ret
+
+Function104d74: ; 104d74 (41:4d74)
+ xor a
+ ld [rTAC], a
+ ld a, $fe
+ ld [rTMA], a
+ ld [rTIMA], a
+ ld a, $2
+ ld [rTAC], a
+ or $4
+ ld [rTAC], a
+ ret
+
+Function104d86: ; 104d86 (41:4d86)
+ xor a
+ ld [rTAC], a
+ ld [rTMA], a
+ ld [rTIMA], a
+ ld a, $2
+ ld [rTAC], a
+ or $4
+ ld [rTAC], a
+ ret
+
+Function104d96: ; 104d96 (41:4d96)
+ ld a, $c0
+ call Function104e8c
+ ld a, $1
+ ld [hPrintNum9], a
+ ret
+
+Function104da0: ; 104da0 (41:4da0)
+ xor a
+ call Function104e8c
+ ld a, $2
+ ld [rTAC], a
+ ret
+
+Function104da9: ; 104da9 (41:4da9)
+ inc d
+ ret z
+ xor a
+ ld [rIF], a
+ halt
+ ld a, [$ff00+c]
+ bit 1, a
+ jr z, Function104da9
+ or a
+ ret
+
+Function104db7: ; 104db7 (41:4db7)
+ inc d
+ ret z
+ xor a
+ ld [rIF], a
+ halt
+ ld a, [$ff00+c]
+ bit 1, a
+ jr nz, Function104db7
+ or a
+ ret
+
+Function104dc5: ; 104dc5 (41:4dc5)
+ ld a, $c1
+ ld [$ff00+c], a
+.asm_104dc8
+ dec d
+ ret z
+ xor a
+ ld [rIF], a
+ halt
+ jr .asm_104dc8
+
+Function104dd1: ; 104dd1 (41:4dd1)
+ ld a, $c0
+ ld [$ff00+c], a
+.asm_104dd4
+ dec d
+ ret z
+ xor a
+ ld [rIF], a
+ halt
+ jr .asm_104dd4
+
+Function104ddd: ; 104ddd (41:4ddd)
+ ld d, $0
+ ld e, d
+ ld a, $1
+ ld [hPrintNum9], a
+.asm_104de4
+ call Function105038
+ ld b, $2
+ ld c, rRP % $100
+ ld a, [hMoneyTemp + 1]
+ bit 1, a
+ jr z, .asm_104df6
+ ld a, $10
+ ld [hPrintNum10], a
+ ret
+.asm_104df6
+ bit 0, a
+ jr nz, asm_104e3a
+ ld a, [$ff00+c]
+ and b
+ jr nz, .asm_104de4
+
+Function104dfe: ; 104dfe (41:4dfe)
+ ld c, rRP % $100
+ ld d, $0
+ ld e, d
+ call Function104db7
+ jp z, Function104f42
+ ld d, e
+ call Function104da9
+ jp z, Function104f42
+ call Function104db7
+ jp z, Function104f42
+ call Function104da9
+ jp z, Function104f42
+ ld a, $6c
+ ld [hPrintNum10], a
+ ld d, $3d
+ call Function104dd1
+ ld d, $5
+ call Function104dc5
+ ld d, $15
+ call Function104dd1
+ ld d, $5
+ call Function104dc5
+ ld d, $5
+ call Function104dd1
+ ret
+
+asm_104e3a: ; 104e3a (41:4e3a)
+ call Random
+ ld e, a
+ and $f
+ ld d, a
+.asm_104e41
+ dec de
+ ld a, d
+ or e
+ jr nz, .asm_104e41
+
+Function104e46: ; 104e46 (41:4e46)
+ ld a, $2
+ ld [hPrintNum9], a
+ ld c, $56
+ ld d, $0
+ ld e, d
+ ld d, $3d
+ call Function104dd1
+ ld d, $5
+ call Function104dc5
+ ld d, $15
+ call Function104dd1
+ ld d, $5
+ call Function104dc5
+ ld d, $5
+ call Function104dd1
+ ld d, e
+ call Function104db7
+ jp z, Function104f42
+ ld d, e
+ call Function104da9
+ jp z, Function104f42
+ call Function104db7
+ jp z, Function104f42
+ call Function104da9
+ jp z, Function104f42
+ ld d, $3d
+ call Function104dd1
+ ld a, $6c
+ ld [hPrintNum10], a
+ ret
+
+Function104e8c: ; 104e8c (41:4e8c)
+ ld [rRP], a
+ ld a, $ff
+ ld [hPrintNum10], a
+ ret
+
+Function104e93: ; 104e93 (41:4e93)
+ xor a
+ ld [hDivisor], a
+ ld [hMathBuffer], a
+ push hl
+ push bc
+ ld c, $56
+ ld d, $3d
+ call Function104dd1
+ ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
+ ld a, $5a
+ ld [hli], a
+ ld [hl], b
+ dec hl
+ ld b, $2
+ call Function104ed6
+ pop bc
+ pop hl
+ call Function104ed6
+ ld a, [hDivisor]
+ ld [hQuotient], a
+ ld a, [hMathBuffer]
+ ld [$ffb5], a
+ push hl
+ ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
+ ld b, $2
+ call Function104ed6
+ ld hl, hPrintNum10
+ ld b, $1
+ call Function104faf
+ ld a, [hQuotient]
+ ld [hDivisor], a
+ ld a, [$ffb5]
+ ld [hMathBuffer], a
+ pop hl
+ ret
+
+Function104ed6: ; 104ed6 (41:4ed6)
+ ld c, $56
+ ld d, $5
+ call Function104dd1
+ ld d, $5
+ call Function104dc5
+ ld d, $15
+ call Function104dd1
+ ld a, b
+ cpl
+ ld b, a
+ ld a, $f4
+ ld [rTMA], a
+.asm_104eee
+ inc b
+ jr z, .asm_104f2e
+ ld a, $8
+ ld [$ffb6], a
+ ld a, [hli]
+ ld e, a
+ ld a, [hDivisor]
+ add e
+ ld [hDivisor], a
+ ld a, [hMathBuffer]
+ adc $0
+ ld [hMathBuffer], a
+.asm_104f02
+ xor a
+ ld [rIF], a
+ halt
+ ld a, $c1
+ ld [rRP], a
+ ld d, $1
+ ld a, e
+ rlca
+ ld e, a
+ jr nc, .asm_104f13
+ inc d
+.asm_104f13
+ ld a, [rTIMA]
+ cp $f8
+ jr c, .asm_104f13
+ ld a, $c0
+ ld [rRP], a
+ dec d
+ jr z, .asm_104f25
+ xor a
+ ld [rIF], a
+ halt
+.asm_104f25
+ ld a, [$ffb6]
+ dec a
+ jr z, .asm_104eee
+ ld [$ffb6], a
+ jr .asm_104f02
+.asm_104f2e
+ ld a, $fe
+ ld [rTMA], a
+ xor a
+ ld [rIF], a
+ halt
+ ld d, $5
+ call Function104dc5
+ ld d, $11
+ call Function104dd1
+ ret
+
+Function104f42: ; 104f42 (41:4f42)
+ ld a, [hPrintNum10]
+ or $2
+ ld [hPrintNum10], a
+ ret
+
+Function104f49: ; 104f49 (41:4f49)
+ ld a, [hPrintNum10]
+ or $1
+ ld [hPrintNum10], a
+ ret
+
+Function104f50: ; 104f50 (41:4f50)
+ ld a, [hPrintNum10]
+ or $80
+ ld [hPrintNum10], a
+ ret
+
+Function104f57: ; 104f57 (41:4f57)
+ xor a
+ ld [hDivisor], a
+ ld [hMathBuffer], a
+ push bc
+ push hl
+ ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
+ ld b, $2
+ call Function104faf
+ ld a, [$ffb5]
+ ld [$ffba], a
+ ld b, a
+ pop hl
+ pop af
+ cp b
+ jp c, Function104f50
+ ld a, [hQuotient]
+ cp $5a
+ jp nz, Function104f50
+ call Function104faf
+ ld a, [hDivisor]
+ ld d, a
+ ld a, [hMathBuffer]
+ ld e, a
+ push hl
+ push de
+ ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
+ ld b, $2
+ call Function104faf
+ pop de
+ ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
+ ld a, [hli]
+ xor d
+ ld b, a
+ ld a, [hl]
+ xor e
+ or b
+ call nz, Function104f49
+ push de
+ ld d, $3d
+ call Function104dd1
+ ld hl, hPrintNum10
+ ld b, $1
+ call Function104ed6
+ pop de
+ pop hl
+ ld a, d
+ ld [hDivisor], a
+ ld a, e
+ ld [hMathBuffer], a
+ ret
+
+Function104faf: ; 104faf (41:4faf)
+ ld c, rRP % $100
+ ld d, $0
+ call Function104db7
+ jp z, Function104f42
+ ld d, $0
+ call Function104da9
+ jp z, Function104f42
+ ld d, $0
+ call Function104db7
+ jp z, Function104f42
+ ld a, b
+ cpl
+ ld b, a
+ xor a
+ ld [hMoneyTemp + 2], a
+ call Function104d86
+.asm_104fd2
+ inc b
+ jr z, .asm_10501a
+ ld a, $8
+ ld [$ffb6], a
+.asm_104fd9
+ ld d, $0
+.asm_104fdb
+ inc d
+ jr z, .asm_104fe5
+ ld a, [$ff00+c]
+ bit 1, a
+ jr z, .asm_104fdb
+ ld d, $0
+.asm_104fe5
+ inc d
+ jr z, .asm_104fed
+ ld a, [$ff00+c]
+ bit 1, a
+ jr nz, .asm_104fe5
+.asm_104fed
+ ld a, [hMoneyTemp + 2]
+ ld d, a
+ ld a, [rTIMA]
+ ld [hMoneyTemp + 2], a
+ sub d
+ cp $12
+ jr c, .asm_104ffd
+ set 0, e
+ jr .asm_104fff
+.asm_104ffd
+ res 0, e
+.asm_104fff
+ ld a, [$ffb6]
+ dec a
+ ld [$ffb6], a
+ jr z, .asm_10500b
+ ld a, e
+ rlca
+ ld e, a
+ jr .asm_104fd9
+.asm_10500b
+ ld a, e
+ ld [hli], a
+ ld a, [hDivisor]
+ add e
+ ld [hDivisor], a
+ ld a, [hMathBuffer]
+ adc $0
+ ld [hMathBuffer], a
+ jr .asm_104fd2
+.asm_10501a
+ call Function104d74
+ xor a
+ ld [rIF], a
+ ld d, $0
+ call Function104da9
+ jp z, Function104f42
+ ld d, $10
+ call Function104dd1
+ ret
+
+Function10502e: ; 10502e (41:502e)
+ ld b, $0
+ jp Function104e93
+
+Function105033: ; 105033 (41:5033)
+ ld b, $0
+ jp Function104f57
+
+Function105038: ; 105038 (41:5038)
+ ld a, $20
+ ld [rJOYP], a
+rept 2
+ ld a, [rJOYP]
+endr
+ cpl
+ and $f
+ swap a
+ ld b, a
+ ld a, $10
+ ld [rJOYP], a
+rept 6
+ ld a, [rJOYP]
+endr
+ cpl
+ and $f
+ or b
+ ld c, a
+ ld a, [hMoneyTemp]
+ xor c
+ and c
+ ld [hMoneyTemp + 1], a
+ ld a, c
+ ld [hMoneyTemp], a
+ ld a, $30
+ ld [rJOYP], a
+ ret
+
+Function105069: ; 105069 (41:5069)
+ call GetMysteryGiftBank
+ ld d, $0
+ ld b, CHECK_FLAG
+ ld hl, sMysteryGiftDecorationsReceived
+ predef_id FlagPredef
+ push hl
+ push bc
+ call Predef
+ call CloseSRAM
+ ld a, c
+ and a
+ pop bc
+ pop hl
+ ret nz
+ call GetMysteryGiftBank
+ ld b, SET_FLAG
+ predef FlagPredef
+ call CloseSRAM
+ xor a
+ ret
+
+Function105091: ; 105091 (41:5091)
+ call GetMysteryGiftBank
+ ld c, $0
+.loop
+ push bc
+ ld d, $0
+ ld b, CHECK_FLAG
+ ld hl, sMysteryGiftDecorationsReceived
+ predef FlagPredef
+ ld a, c
+ and a
+ pop bc
+ jr z, .skip
+ push bc
+ callab SetSpecificDecorationFlag
+ pop bc
+.skip
+ inc c
+ ld a, c
+ cp Trophys - DecorationIDs
+ jr c, .loop
+ jp CloseSRAM
+
+Special_UnlockMysteryGift: ; 1050b9
+ call GetMysteryGiftBank
+ ld hl, sMysteryGiftUnlocked
+ ld a, [hl]
+ inc a
+ jr nz, .ok
+ ld [hld], a
+ ld [hl], a
+.ok
+ jp CloseSRAM
+; 1050c8
+
+Function1050c8: ; 1050c8
+ call GetMysteryGiftBank
+ ld a, [sNumDailyMysteryGiftPartnerIDs]
+ cp $ff
+ jr z, .okay
+ xor a
+ ld [sNumDailyMysteryGiftPartnerIDs], a
+.okay
+ jp CloseSRAM
+; 1050d9
+
+
+BackupMysteryGift: ; 1050d9
+ call GetMysteryGiftBank
+ ld hl, sMysteryGiftItem
+ ld de, sBackupMysteryGiftItem
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ jp CloseSRAM
+; 1050ea
+
+
+RestoreMysteryGift: ; 1050ea (41:50ea)
+ call GetMysteryGiftBank
+ ld hl, sBackupMysteryGiftItem
+ ld de, sMysteryGiftItem
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ jp CloseSRAM
+
+Function1050fb: ; 1050fb (41:50fb)
+ ld hl, wMysteryGiftTrainerData
+ xor a
+ ld b, $26
+.asm_105101
+ ld [hli], a
+ dec b
+ jr nz, .asm_105101
+ ret
+
+
+GetMysteryGiftBank: ; 105106
+ ld a, BANK(sBackupMysteryGiftItem)
+ jp GetSRAMBank
+; 10510b
+
+
+Function10510b: ; 10510b (41:510b)
+ ld a, BANK(sPokemonData)
+ call GetSRAMBank
+ ld de, OverworldMap
+ ld bc, sPokemonData + PartyMons - wPokemonData
+ ld hl, sPokemonData + PartySpecies - wPokemonData
+.asm_105119
+ ld a, [hli]
+ cp $ff
+ jr z, .asm_105148
+ cp EGG
+ jr z, .asm_10513e
+ push hl
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ ld [de], a
+ inc de
+ ld hl, MON_SPECIES
+ add hl, bc
+ ld a, [hl]
+ ld [de], a
+ inc de
+ ld hl, MON_MOVES
+ add hl, bc
+ push bc
+ ld bc, NUM_MOVES
+ call CopyBytes
+ pop bc
+ pop hl
+.asm_10513e
+ push hl
+ ld hl, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ ld b, h
+ ld c, l
+ pop hl
+ jr .asm_105119
+.asm_105148
+ ld a, $ff
+ ld [de], a
+ ld a, $26
+ ld [wca00], a
+ jp CloseSRAM
+
+Function105153: ; 105153 (41:5153)
+ call ClearBGPalettes
+ call DisableLCD
+ ld hl, MysteryGiftGFX
+ ld de, VTiles2 tile $00
+ ld a, BANK(MysteryGiftGFX)
+ ld bc, Function105688 - MysteryGiftGFX
+ call FarCopyBytes
+ hlcoord 0, 0
+ ld a, $42
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ call ByteFill
+ hlcoord 3, 7
+ lb bc, 9, 15
+ call ClearBox
+ hlcoord 0, 0
+ ld a, $0
+ ld [hli], a
+ inc a
+ ld [hl], a
+ hlcoord 0, 1
+ inc a
+ ld [hli], a
+ inc a
+ ld [hl], a
+ hlcoord 7, 1
+ ld a, $12
+ call Function10522e
+ hlcoord 2, 2
+ ld a, $17
+ call Function105236
+ hlcoord 2, 3
+ ld a, $27
+ call Function105236
+ hlcoord 9, 4
+ ld a, $37
+ ld [hli], a
+ inc a
+ ld [hl], a
+ hlcoord 1, 2
+ ld [hl], $4
+ hlcoord 1, 3
+ ld a, $5
+ call Function105246
+ ld a, $9
+ hlcoord 18, 5
+ call Function105242
+ hlcoord 2, 5
+ ld a, $b
+ call Function105251
+ hlcoord 2, 16
+ ld a, $7
+ call Function105251
+ hlcoord 2, 5
+ ld a, $d
+ call Function10522e
+ hlcoord 7, 5
+ ld [hl], $c
+ hlcoord 18, 5
+ ld [hl], $a
+ hlcoord 18, 16
+ ld [hl], $8
+ hlcoord 1, 16
+ ld [hl], $6
+ hlcoord 2, 6
+ ld a, $3a
+ call Function105251
+ hlcoord 2, 15
+ ld a, $40
+ call Function105251
+ hlcoord 2, 6
+ ld a, $3c
+ call Function10523e
+ hlcoord 17, 6
+ ld a, $3e
+ call Function10523e
+ hlcoord 2, 6
+ ld [hl], $39
+ hlcoord 17, 6
+ ld [hl], $3b
+ hlcoord 2, 15
+ ld [hl], $3f
+ hlcoord 17, 15
+ ld [hl], $41
+ call EnableLCD
+ call WaitBGMap
+ ld b, SCGB_1D
+ call GetSGBLayout
+ call SetPalettes
+ ret
+
+Function10522e: ; 10522e (41:522e)
+ ld b, $5
+ jr asm_105238
+; 105232 (41:5232)
+
+Function105232: ; unreferenced
+ ld b, 6
+ jr asm_105238
+
+Function105236: ; 105236 (41:5236)
+ ld b, $10
+
+asm_105238: ; 105238 (41:5238)
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, asm_105238
+ ret
+
+Function10523e: ; 10523e (41:523e)
+ ld b, $9
+ jr asm_105248
+
+Function105242: ; 105242 (41:5242)
+ ld b, $b
+ jr asm_105248
+
+Function105246: ; 105246 (41:5246)
+ ld b, $e
+
+asm_105248: ; 105248 (41:5248)
+ ld [hl], a
+ ld de, $14
+ add hl, de
+ dec b
+ jr nz, asm_105248
+ ret
+
+Function105251: ; 105251 (41:5251)
+ ld b, $10
+.asm_105253
+ ld [hli], a
+ dec b
+ jr nz, .asm_105253
+ ret
+
+MysteryGiftGFX: ; 105258
+INCBIN "gfx/misc/mystery_gift.2bpp"
+
+
+Function105688: ; 105688 (41:5688)
+ call ClearTileMap
+ call ClearSprites
+ call WaitBGMap
+ call Function1057d7
+ hlcoord 3, 8
+ ld de, String_10572e
+ call PlaceString
+ call WaitBGMap
+ call Function10578c
+ call Function1050fb
+ ld a, $24
+ ld [wca02], a
+ ld a, [rIE]
+ push af
+ call Function104c2d
+ ld d, a
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ ld a, d
+ cp $10
+ jp z, Function105712
+ cp $6c
+ jp nz, Function10571a
+ call Function1056eb
+ ld c, 60
+ call DelayFrames
+ call Function105777
+ ld hl, Text_10575e
+ call PrintText
+ ld de, wMysteryGiftTrainerData
+ callba Function8ac70
+ ld a, c
+ ld [wd265], a
+ ld hl, Text_105768
+ jr c, asm_105726
+ ld hl, Text_105763
+ jr asm_105726
+
+Function1056eb: ; 1056eb (41:56eb)
+ ld c, $10
+.asm_1056ed
+ ld hl, Sprites
+ ld b, $8
+.asm_1056f2
+ dec [hl]
+rept 4
+ inc hl
+endr
+ dec b
+ jr nz, .asm_1056f2
+ ld hl, Sprites + $20
+ ld b, $8
+.asm_1056ff
+ inc [hl]
+rept 4
+ inc hl
+endr
+ dec b
+ jr nz, .asm_1056ff
+ dec c
+ ret z
+ push bc
+ ld c, 4
+ call DelayFrames
+ pop bc
+ jr .asm_1056ed
+
+Function105712: ; 105712 (41:5712)
+ call Function105777
+ ld hl, Text_10576d
+ jr asm_105726
+
+Function10571a: ; 10571a (41:571a)
+ call Function105777
+ ld hl, Text_105772
+ call PrintText
+ jp Function105688
+
+asm_105726: ; 105726 (41:5726)
+ call PrintText
+ ld a, $e3
+ ld [rLCDC], a
+ ret
+; 10572e (41:572e)
+
+String_10572e: ; 10572e
+ db "エーボタン¯おすと"
+ next "つうしん", $4a, "おこなわれるよ!"
+ next "ビーボタン¯おすと"
+ next "つうしん¯ちゅうし します"
+ db "@"
+
+; 10575e
+
+Text_10575e: ; 10575e
+ text_jump UnknownText_0x1c051a
+ db "@"
+
+Text_105763: ; 105763
+ text_jump UnknownText_0x1c0531
+ db "@"
+
+Text_105768: ; 105768
+ text_jump UnknownText_0x1c0555
+ db "@"
+
+Text_10576d: ; 10576d
+ text_jump UnknownText_0x1c0573
+ db "@"
+
+Text_105772: ; 105772
+ text_jump UnknownText_0x1c0591
+ db "@"
+; 105777
+
+Function105777: ; 105777 (41:5777)
+ call ClearSprites
+ call ClearTileMap
+ call EnableLCD
+ call WaitBGMap
+ ld b, SCGB_08
+ call GetSGBLayout
+ call SetPalettes
+ ret
+
+Function10578c: ; 10578c (41:578c)
+ ld de, OverworldMap
+ ld a, BANK(sPlayerData)
+ call GetSRAMBank
+ ld hl, sPlayerData + PlayerName - wPlayerData
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ld hl, sPlayerData + PlayerID - wPlayerData
+ ld bc, 2
+ call CopyBytes
+ ld hl, sPlayerData + wSecretID - wPlayerData
+ ld bc, 2
+ call CopyBytes
+ call CloseSRAM
+ ld a, BANK(sCrystalData)
+ call GetSRAMBank
+ ld a, [sCrystalData + 0]
+ ld [de], a
+ inc de
+ ld a, $4
+ call GetSRAMBank
+ ld hl, $a603
+ ld bc, $8
+ call CopyBytes
+ ld hl, $a007
+ ld bc, $c
+ call CopyBytes
+ call CloseSRAM
+ ret
+
+Function1057d7: ; 1057d7 (41:57d7)
+ call ClearBGPalettes
+ call DisableLCD
+ ld hl, MysteryGiftJP_GFX
+ ld de, VTiles2 tile $00
+ ld a, BANK(MysteryGiftJP_GFX)
+ lb bc, 4, 0
+ call FarCopyBytes
+ ld hl, MysteryGiftJP_GFX + $400
+ ld de, VTiles0 tile $00
+ ld a, BANK(MysteryGiftJP_GFX)
+ ld bc, $80
+ call FarCopyBytes
+ hlcoord 0, 0
+ ld a, $3f
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ call ByteFill
+ hlcoord 3, 7
+ lb bc, 9, 15
+ call ClearBox
+ hlcoord 0, 0
+ ld a, $0
+ ld [hli], a
+ inc a
+ ld [hl], a
+ hlcoord 0, 1
+ inc a
+ ld [hli], a
+ inc a
+ ld [hl], a
+ hlcoord 4, 2
+ ld a, $13
+ call Function1058ca
+ hlcoord 4, 3
+ ld a, $1e
+ call Function1058ce
+ hlcoord 4, 4
+ ld a, $2a
+ call Function1058ce
+ hlcoord 1, 2
+ ld [hl], $4
+ hlcoord 1, 3
+ ld a, $5
+ call Function1058de
+ ld a, $9
+ hlcoord 18, 5
+ call Function1058da
+ hlcoord 2, 5
+ ld a, $b
+ call Function1058e9
+ hlcoord 2, 16
+ ld a, $7
+ call Function1058e9
+ hlcoord 2, 5
+ ld a, $d
+ call Function1058c6
+ hlcoord 8, 5
+ ld [hl], $c
+ hlcoord 18, 5
+ ld [hl], $a
+ hlcoord 18, 16
+ ld [hl], $8
+ hlcoord 1, 16
+ ld [hl], $6
+ hlcoord 2, 6
+ ld a, $37
+ call Function1058e9
+ hlcoord 2, 15
+ ld a, $3d
+ call Function1058e9
+ hlcoord 2, 6
+ ld a, $39
+ call Function1058d6
+ hlcoord 17, 6
+ ld a, $3b
+ call Function1058d6
+ hlcoord 2, 6
+ ld [hl], $36
+ hlcoord 17, 6
+ ld [hl], $38
+ hlcoord 2, 15
+ ld [hl], $3c
+ hlcoord 17, 15
+ ld [hl], $3e
+ ld de, Sprites
+ ld hl, OAM_1058f0
+ ld bc, $40
+ call CopyBytes
+ call EnableLCD
+ call WaitBGMap
+ ld b, $2
+ callba Function4930f
+ jp SetPalettes
+
+Function1058c6: ; 1058c6 (41:58c6)
+ ld b, $6
+ jr asm_1058d0
+
+Function1058ca: ; 1058ca (41:58ca)
+ ld b, $b
+ jr asm_1058d0
+
+Function1058ce: ; 1058ce (41:58ce)
+ ld b, $c
+
+asm_1058d0: ; 1058d0 (41:58d0)
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, asm_1058d0
+ ret
+
+Function1058d6: ; 1058d6 (41:58d6)
+ ld b, $9
+ jr asm_1058e0
+
+Function1058da: ; 1058da (41:58da)
+ ld b, $b
+ jr asm_1058e0
+
+Function1058de: ; 1058de (41:58de)
+ ld b, $e
+
+asm_1058e0: ; 1058e0 (41:58e0)
+ ld [hl], a
+ ld de, SCREEN_WIDTH
+ add hl, de
+ dec b
+ jr nz, asm_1058e0
+ ret
+
+Function1058e9: ; 1058e9 (41:58e9)
+ ld b, $10
+.asm_1058eb
+ ld [hli], a
+ dec b
+ jr nz, .asm_1058eb
+ ret
+; 1058f0 (41:58f0)
+
+OAM_1058f0: ; 1058f0
+ db $11, $34, $00, $00
+ db $11, $3c, $01, $00
+ db $11, $44, $02, $00
+ db $11, $4c, $03, $00
+ db $19, $34, $04, $00
+ db $19, $3c, $05, $00
+ db $19, $44, $06, $00
+ db $19, $4c, $07, $00
+ db $01, $5c, $00, $00
+ db $01, $64, $01, $00
+ db $01, $6c, $02, $00
+ db $01, $74, $03, $00
+ db $09, $5c, $04, $00
+ db $09, $64, $05, $00
+ db $09, $6c, $06, $00
+ db $09, $74, $07, $00
+
+; japanese mystery gift gfx
+MysteryGiftJP_GFX: ; 105930
+INCBIN "gfx/misc/mystery_gift_jp.2bpp"
--- a/engine/npctrade.asm
+++ b/engine/npctrade.asm
@@ -18,10 +18,14 @@
TRADE_COMPLETE EQU 3
TRADE_AFTER EQU 4
+TRADE_EITHER_GENDER EQU 0
+TRADE_MALE_ONLY EQU 1
+TRADE_FEMALE_ONLY EQU 2
+
NPCTrade:: ; fcba8
ld a, e
ld [wJumptableIndex], a
- call Functionfcc59
+ call Trade_GetDialog
ld b, CHECK_FLAG
call TradeFlagAction
ld a, TRADE_AFTER
@@ -57,8 +61,8 @@
ld hl, ConnectLinkCableText
call PrintText
- call Functionfcc63
- call Functionfcc07
+ call DoNPCTrade
+ call .TradeAnimation
call GetTradeMonNames
ld hl, TradedForText
@@ -73,13 +77,13 @@
ret
; fcc07
-Functionfcc07: ; fcc07
+.TradeAnimation: ; fcc07
call DisableSpriteUpdates
ld a, [wJumptableIndex]
push af
ld a, [wcf64]
push af
- predef Function28f24
+ predef TradeAnimation
pop af
ld [wcf64], a
pop af
@@ -118,7 +122,7 @@
; fcc4a
TradeFlagAction: ; fcc4a
- ld hl, wd960
+ ld hl, wTradeFlags
ld a, [wJumptableIndex]
ld c, a
predef FlagPredef
@@ -127,7 +131,7 @@
ret
; fcc59
-Functionfcc59: ; fcc59
+Trade_GetDialog: ; fcc59
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
@@ -135,74 +139,74 @@
ret
; fcc63
-Functionfcc63: ; fcc63
+DoNPCTrade: ; fcc63
ld e, TRADE_GIVEMON
call GetTradeAttribute
ld a, [hl]
- ld [wc6d0], a
+ ld [wPlayerTrademonSpecies], a
ld e, TRADE_GETMON
call GetTradeAttribute
ld a, [hl]
- ld [wc702], a
+ ld [wOTTrademonSpecies], a
- ld a, [wc6d0]
- ld de, wc6d1
- call Functionfcde8
- call Functionfcdf4
+ ld a, [wPlayerTrademonSpecies]
+ ld de, wPlayerTrademonSpeciesName
+ call GetTradeMonName
+ call CopyTradeName
- ld a, [wc702]
- ld de, wc703
- call Functionfcde8
- call Functionfcdf4
+ ld a, [wOTTrademonSpecies]
+ ld de, wOTTrademonSpeciesName
+ call GetTradeMonName
+ call CopyTradeName
ld hl, PartyMonOT
ld bc, NAME_LENGTH
- call Functionfcdd7
- ld de, wc6f2
- call Functionfcdf4
+ call Trade_GetAttributeOfCurrentPartymon
+ ld de, wPlayerTrademonOTName
+ call CopyTradeName
ld hl, PlayerName
- ld de, wc6e7
- call Functionfcdf4
+ ld de, wPlayerTrademonSenderName
+ call CopyTradeName
ld hl, PartyMon1ID
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
- ld de, wc6ff
- call Functionfce0f
+ call Trade_GetAttributeOfCurrentPartymon
+ ld de, wPlayerTrademonID
+ call Trade_CopyTwoBytes
ld hl, PartyMon1DVs
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
- ld de, wc6fd
- call Functionfce0f
+ call Trade_GetAttributeOfCurrentPartymon
+ ld de, wPlayerTrademonDVs
+ call Trade_CopyTwoBytes
ld hl, PartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
+ call Trade_GetAttributeOfCurrentPartymon
ld b, h
ld c, l
callba GetCaughtGender
ld a, c
- ld [wc701], a
+ ld [wPlayerTrademonCaughtData], a
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
- cp TRADE_COMPLETE
+ cp 3
ld a, 1
- jr c, .asm_fcce6
+ jr c, .okay
ld a, 2
-.asm_fcce6
- ld [wEnemyCharging], a
+.okay
+ ld [wOTTrademonCaughtData], a
ld hl, PartyMon1Level
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
+ call Trade_GetAttributeOfCurrentPartymon
ld a, [hl]
ld [CurPartyLevel], a
- ld a, [wc702]
+ ld a, [wOTTrademonSpecies]
ld [CurPartySpecies], a
xor a
ld [MonType], a
@@ -214,59 +218,59 @@
call GetTradeAttribute
ld a, [hl]
cp TRADE_COMPLETE
- ld b, 0
+ ld b, RESET_FLAG
jr c, .asm_fcd1c
- ld b, 1
+ ld b, SET_FLAG
.asm_fcd1c
callba SetGiftPartyMonCaughtData
ld e, TRADE_NICK
call GetTradeAttribute
- ld de, wc70e
- call Functionfcdf4
+ ld de, wOTTrademonNickname
+ call CopyTradeName
ld hl, PartyMonNicknames
ld bc, PKMN_NAME_LENGTH
- call Functionfcdde
- ld hl, wc70e
- call Functionfcdf4
+ call Trade_GetAttributeOfLastPartymon
+ ld hl, wOTTrademonNickname
+ call CopyTradeName
ld e, TRADE_OT_NAME
call GetTradeAttribute
push hl
- ld de, wc724
- call Functionfcdf4
+ ld de, wOTTrademonOTName
+ call CopyTradeName
pop hl
- ld de, wc719
- call Functionfcdf4
+ ld de, wOTTrademonSenderName
+ call CopyTradeName
ld hl, PartyMonOT
ld bc, NAME_LENGTH
- call Functionfcdde
- ld hl, wc724
- call Functionfcdf4
+ call Trade_GetAttributeOfLastPartymon
+ ld hl, wOTTrademonOTName
+ call CopyTradeName
ld e, TRADE_DVS
call GetTradeAttribute
- ld de, wEnemyTrappingMove
- call Functionfce0f
+ ld de, wOTTrademonDVs
+ call Trade_CopyTwoBytes
ld hl, PartyMon1DVs
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdde
- ld hl, wEnemyTrappingMove
- call Functionfce0f
+ call Trade_GetAttributeOfLastPartymon
+ ld hl, wOTTrademonDVs
+ call Trade_CopyTwoBytes
ld e, TRADE_OT_ID
call GetTradeAttribute
- ld de, wPlayerCharging
- call Functionfce15
+ ld de, wOTTrademonID + 1
+ call Trade_CopyTwoBytesReverseEndian
ld hl, PartyMon1ID
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdde
- ld hl, wEnemyWrapCount
- call Functionfce0f
+ call Trade_GetAttributeOfLastPartymon
+ ld hl, wOTTrademonID
+ call Trade_CopyTwoBytes
ld e, TRADE_ITEM
call GetTradeAttribute
@@ -273,7 +277,7 @@
push hl
ld hl, PartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdde
+ call Trade_GetAttributeOfLastPartymon
pop hl
ld a, [hl]
ld [de], a
@@ -315,13 +319,13 @@
ret
; 0xfcdd7
-Functionfcdd7: ; fcdd7
+Trade_GetAttributeOfCurrentPartymon: ; fcdd7
ld a, [CurPartyMon]
call AddNTimes
ret
; fcdde
-Functionfcdde: ; fcdde
+Trade_GetAttributeOfLastPartymon: ; fcdde
ld a, [PartyCount]
dec a
call AddNTimes
@@ -330,7 +334,7 @@
ret
; fcde8
-Functionfcde8: ; fcde8
+GetTradeMonName: ; fcde8
push de
ld [wd265], a
call GetBasePokemonName
@@ -339,7 +343,7 @@
ret
; fcdf4
-Functionfcdf4: ; fcdf4
+CopyTradeName: ; fcdf4
ld bc, NAME_LENGTH
call CopyBytes
ret
@@ -346,22 +350,24 @@
; fcdfb
Functionfcdfb: ; fcdfb
+; unreferenced
ld bc, 4
call CopyBytes
- ld a, $50
+ ld a, "@"
ld [de], a
ret
; fce05
Functionfce05: ; fce05
+; unreferenced
ld bc, 3
call CopyBytes
- ld a, $50
+ ld a, "@"
ld [de], a
ret
; fce0f
-Functionfce0f: ; fce0f
+Trade_CopyTwoBytes: ; fce0f
ld a, [hli]
ld [de], a
inc de
@@ -370,7 +376,7 @@
ret
; fce15
-Functionfce15: ; fce15
+Trade_CopyTwoBytesReverseEndian: ; fce15
ld a, [hli]
ld [de], a
dec de
@@ -383,18 +389,18 @@
ld e, TRADE_GETMON
call GetTradeAttribute
ld a, [hl]
- call Functionfcde8
+ call GetTradeMonName
ld de, StringBuffer2
- call Functionfcdf4
+ call CopyTradeName
ld e, TRADE_GIVEMON
call GetTradeAttribute
ld a, [hl]
- call Functionfcde8
+ call GetTradeMonName
ld de, wd050
- call Functionfcdf4
+ call CopyTradeName
ld hl, StringBuffer1
.loop
@@ -423,13 +429,22 @@
NPCTrades: ; fce58
- db 0, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, $54, $92, "MIKE@@@@@@@", 0, 0
- db 0, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, $1e, $bf, "KYLE@@@@@@@", 0, 0
- db 1, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, $05, $72, "TIM@@@@@@@@", 0, 0
- db 3, DRAGONAIR, DODRIO, "DORIS@@@@@@", $77, $66, SMOKE_BALL, $1b, $01, "EMY@@@@@@@@", 2, 0
- db 2, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, $00, $3d, "CHRIS@@@@@@", 0, 0
- db 3, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, $7b, $67, "KIM@@@@@@@@", 0, 0
- db 0, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, $a2, $c3, "FOREST@@@@@", 0, 0
+npctrade: MACRO
+ db \1, \2, \3, \4
+ dw \5
+ db \6
+ dw \7
+ db \8, \9, 0
+ENDM
+
+
+ npctrade 0, ABRA, MACHOP, "MUSCLE@@@@@", $6637, GOLD_BERRY, $9254, "MIKE@@@@@@@", TRADE_EITHER_GENDER
+ npctrade 0, BELLSPROUT, ONIX, "ROCKY@@@@@@", $6696, BITTER_BERRY, $bf1e, "KYLE@@@@@@@", TRADE_EITHER_GENDER
+ npctrade 1, KRABBY, VOLTORB, "VOLTY@@@@@@", $8898, PRZCUREBERRY, $7205, "TIM@@@@@@@@", TRADE_EITHER_GENDER
+ npctrade 3, DRAGONAIR, DODRIO, "DORIS@@@@@@", $6677, SMOKE_BALL, $011b, "EMY@@@@@@@@", TRADE_FEMALE_ONLY
+ npctrade 2, HAUNTER, XATU, "PAUL@@@@@@@", $8696, MYSTERYBERRY, $3d00, "CHRIS@@@@@@", TRADE_EITHER_GENDER
+ npctrade 3, CHANSEY, AERODACTYL, "AEROY@@@@@@", $6696, GOLD_BERRY, $677b, "KIM@@@@@@@@", TRADE_EITHER_GENDER
+ npctrade 0, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $6696, METAL_COAT, $c3a2, "FOREST@@@@@", TRADE_EITHER_GENDER
; fcf38
--- a/engine/pokedex.asm
+++ b/engine/pokedex.asm
@@ -476,7 +476,7 @@
push af
ld a, [wJumptableIndex]
push af
- callba Function8442c
+ callba PrintDexEntry
pop af
ld [wJumptableIndex], a
pop af
--- a/engine/predef.asm
+++ b/engine/predef.asm
@@ -59,8 +59,8 @@
add_predef LearnLevelMoves
add_predef FillMoves
add_predef EvolveAfterBattle
- add_predef Function28f63
- add_predef Function28f24
+ add_predef TradeAnimationPlayer2
+ add_predef TradeAnimation
add_predef CopyPkmnToTempMon
add_predef ListMoves ; $20
add_predef PlaceNonFaintStatus
--- a/engine/printer.asm
+++ b/engine/printer.asm
@@ -653,7 +653,7 @@
ret
; 8442c
-Function8442c: ; 8442c
+PrintDexEntry: ; 8442c
ld a, [wcf65]
push af
ld hl, VTiles1
@@ -661,7 +661,7 @@
lb bc, BANK(FontInversed), $80
call Request1bpp
xor a
- ld [$ffac], a
+ ld [hPrinter], a
call Function8474c
ld a, [rIE]
push af
@@ -720,7 +720,7 @@
ret
; 844bc
-Function844bc: ; 844bc (21:44bc)
+PrintPCBox: ; 844bc (21:44bc)
ld a, [wcf65]
push af
ld a, $9
@@ -728,13 +728,13 @@
ld a, e
ld [wd004], a
ld a, d
- ld [StartFlypoint], a
+ ld [wd005], a
ld a, b
- ld [EndFlypoint], a
+ ld [wd006], a
ld a, c
- ld [MovementBuffer], a
+ ld [wd007], a
xor a
- ld [$ffac], a
+ ld [hPrinter], a
ld [wd003], a
call Function8474c
ld a, [rIE]
@@ -801,11 +801,11 @@
call Function843f0
ret
-Function84560: ; 84560
+PrintUnownStamp: ; 84560
ld a, [wcf65]
push af
xor a
- ld [$ffac], a
+ ld [hPrinter], a
call Function8474c
ld a, [rIE]
push af
@@ -861,7 +861,7 @@
ret
; 845d4
-Function845d4: ; 845d4
+PrintMail: ; 845d4
call Function845db
call Function84425
ret
@@ -871,7 +871,7 @@
ld a, [wcf65]
push af
xor a
- ld [$ffac], a
+ ld [hPrinter], a
call Function8474c
ld a, [rIE]
push af
@@ -903,11 +903,11 @@
ret
; 8461a
-Function8461a: ; 8461a
+PrintPartymon: ; 8461a
ld a, [wcf65]
push af
xor a
- ld [$ffac], a
+ ld [hPrinter], a
call Function8474c
ld a, [rIE]
push af
@@ -962,7 +962,7 @@
push af
callba Function1dd709
xor a
- ld [$ffac], a
+ ld [hPrinter], a
call Function8474c
ld a, [rIE]
push af
@@ -1040,7 +1040,7 @@
.asm_84722
ld a, $1
- ld [$ffac], a
+ ld [hPrinter], a
scf
ret
; 84728
@@ -1205,15 +1205,15 @@
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
- call Function84a0e
+ call Printer_PlaceEmptyBoxSlotString
hlcoord 0, 0
ld bc, 9 * SCREEN_WIDTH
ld a, " "
call ByteFill
- call Function849e9
- call Function849d7
+ call Printer_PlaceSideBorders
+ call Printer_PlaceTopBorder
hlcoord 4, 3
- ld de, String_84865
+ ld de, .String_PokemonList
call PlaceString
ld a, [wd007]
ld bc, BOX_NAME_LENGTH
@@ -1231,7 +1231,7 @@
ret
; 84865 (21:4865)
-String_84865:
+.String_PokemonList:
db "#MON LIST@"
; 8486f
@@ -1240,8 +1240,8 @@
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
- call Function84a0e
- call Function849e9
+ call Printer_PlaceEmptyBoxSlotString
+ call Printer_PlaceSideBorders
ld a, [wd003]
and a
ret nz
@@ -1257,8 +1257,8 @@
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
- call Function84a0e
- call Function849e9
+ call Printer_PlaceEmptyBoxSlotString
+ call Printer_PlaceSideBorders
ld a, [wd003]
and a
ret nz
@@ -1274,12 +1274,12 @@
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
- call Function84a0e
+ call Printer_PlaceEmptyBoxSlotString
hlcoord 1, 15
lb bc, 2, 18
call ClearBox
- call Function849e9
- call Function849fc
+ call Printer_PlaceSideBorders
+ call Printer_PlaceBottomBorders
ld a, [wd003]
and a
ret nz
@@ -1291,7 +1291,7 @@
ret
Function848e7: ; 848e7 (21:48e7)
- ld a, [EndFlypoint]
+ ld a, [wd006]
call GetSRAMBank
Function848ed: ; 848ed (21:48ed)
@@ -1318,7 +1318,7 @@
push hl
call PlaceString
ld a, [CurPartySpecies]
- cp $fd
+ cp EGG
pop hl
jr z, .ok2
ld bc, $b
@@ -1326,7 +1326,7 @@
call Function8498a
ld bc, $9
add hl, bc
- ld a, $f3
+ ld a, "/"
ld [hli], a
push hl
ld bc, $e
@@ -1336,7 +1336,7 @@
push hl
ld a, [wd004]
ld l, a
- ld a, [StartFlypoint]
+ ld a, [wd005]
ld h, a
ld bc, $372
add hl, bc
@@ -1354,7 +1354,7 @@
push hl
ld a, [wd004]
ld l, a
- ld a, [StartFlypoint]
+ ld a, [wd005]
ld h, a
ld bc, $35
add hl, bc
@@ -1387,7 +1387,7 @@
push hl
ld a, [wd004]
ld l, a
- ld a, [StartFlypoint]
+ ld a, [wd005]
ld h, a
ld bc, $2b
add hl, bc
@@ -1421,7 +1421,7 @@
ld d, $0
ld a, [wd004]
ld l, a
- ld a, [StartFlypoint]
+ ld a, [wd005]
ld h, a
add hl, de
ld e, l
@@ -1429,25 +1429,25 @@
pop hl
ret
-Function849d7: ; 849d7 (21:49d7)
+Printer_PlaceTopBorder: ; 849d7 (21:49d7)
hlcoord 0, 0
ld a, "┌"
ld [hli], a
ld a, "─"
ld c, SCREEN_WIDTH - 2
-.asm_849e1
+.loop
ld [hli], a
dec c
- jr nz, .asm_849e1
+ jr nz, .loop
ld a, "┐"
ld [hl], a
ret
-Function849e9: ; 849e9 (21:49e9)
+Printer_PlaceSideBorders: ; 849e9 (21:49e9)
hlcoord 0, 0
ld de, SCREEN_WIDTH - 1
ld c, SCREEN_HEIGHT
-.asm_849f1
+.loop
ld a, "│"
ld [hl], a
add hl, de
@@ -1454,37 +1454,37 @@
ld a, "│"
ld [hli], a
dec c
- jr nz, .asm_849f1
+ jr nz, .loop
ret
-Function849fc: ; 849fc (21:49fc)
+Printer_PlaceBottomBorders: ; 849fc (21:49fc)
hlcoord 0, 17
ld a, "└"
ld [hli], a
ld a, "─"
ld c, SCREEN_WIDTH - 2
-.asm_84a06
+.loop
ld [hli], a
dec c
- jr nz, .asm_84a06
+ jr nz, .loop
ld a, "┘"
ld [hl], a
ret
-Function84a0e: ; 84a0e (21:4a0e)
+Printer_PlaceEmptyBoxSlotString: ; 84a0e (21:4a0e)
hlcoord 2, 0
ld c, $6
-.asm_84a13
+.loop
push bc
push hl
ld de, String84a25
call PlaceString
pop hl
- ld bc, $3c
+ ld bc, 3 * SCREEN_WIDTH
add hl, bc
pop bc
dec c
- jr nz, .asm_84a13
+ jr nz, .loop
ret
; 84a25 (21:4a25)
--- /dev/null
+++ b/engine/trade/animation.asm
@@ -1,0 +1,1542 @@
+TradeAnimation: ; 28f24
+ xor a
+ ld [wcf66], a
+ ld hl, wPlayerTrademonSenderName
+ ld de, wOTTrademonSenderName
+ call Function297ff
+ ld hl, wPlayerTrademonSpecies
+ ld de, wOTTrademonSpecies
+ call Function29814
+ ld de, .data_28f3f
+ jr Function28fa1
+
+.data_28f3f
+ tradeanim_1b
+ tradeanim_01
+ tradeanim_1c
+ tradeanim_21
+ tradeanim_2d
+ tradeanim_27
+ tradeanim_23
+ tradeanim_03
+ tradeanim_25
+ tradeanim_28
+ tradeanim_25
+ tradeanim_1e
+ tradeanim_29
+ tradeanim_06
+ tradeanim_16
+ tradeanim_1f
+
+ tradeanim_19
+ tradeanim_17
+ tradeanim_22
+ tradeanim_1f
+ tradeanim_2a
+ tradeanim_0e
+ tradeanim_03
+ tradeanim_24
+ tradeanim_05
+ tradeanim_25
+ tradeanim_02
+ tradeanim_27
+ tradeanim_25
+ tradeanim_1d
+ tradeanim_2c
+ tradeanim_2e
+ tradeanim_1e
+ tradeanim_18
+ tradeanim_1f
+ tradeanim_end
+
+TradeAnimationPlayer2: ; 28f63
+ xor a
+ ld [wcf66], a
+ ld hl, wOTTrademonSenderName
+ ld de, wPlayerTrademonSenderName
+ call Function297ff
+ ld hl, wOTTrademonSpecies
+ ld de, wPlayerTrademonSpecies
+ call Function29814
+ ld de, .data_28f7e
+ jr Function28fa1
+
+.data_28f7e
+ tradeanim_1a
+ tradeanim_17
+ tradeanim_22
+ tradeanim_1f
+ tradeanim_2a
+ tradeanim_06
+ tradeanim_03
+ tradeanim_24
+ tradeanim_05
+ tradeanim_25
+ tradeanim_02
+ tradeanim_27
+ tradeanim_25
+ tradeanim_1d
+ tradeanim_2c
+ tradeanim_2f
+ tradeanim_1e
+ tradeanim_18
+ tradeanim_1f
+
+ tradeanim_1b
+ tradeanim_01
+ tradeanim_1c
+ tradeanim_22
+ tradeanim_27
+ tradeanim_23
+ tradeanim_03
+ tradeanim_25
+ tradeanim_28
+ tradeanim_25
+ tradeanim_1e
+ tradeanim_29
+ tradeanim_0e
+ tradeanim_16
+ tradeanim_1f
+ tradeanim_end
+
+Function28fa1: ; 28fa1
+ ld hl, wTradeAnimPointer
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ld a, [hMapAnims]
+ push af
+ xor a
+ ld [hMapAnims], a
+ ld hl, VramState
+ ld a, [hl]
+ push af
+ res 0, [hl]
+ ld hl, Options
+ ld a, [hl]
+ push af
+ set 4, [hl]
+ call Function28fdb
+ ld a, [wcf66]
+ and a
+ jr nz, .anim_loop
+ ld de, MUSIC_EVOLUTION
+ call PlayMusic2
+.anim_loop
+ call DoTradeAnimation
+ jr nc, .anim_loop
+ pop af
+ ld [Options], a
+ pop af
+ ld [VramState], a
+ pop af
+ ld [hMapAnims], a
+ ret
+; 28fdb
+
+Function28fdb: ; 28fdb
+ xor a
+ ld [wJumptableIndex], a
+ call ClearBGPalettes
+ call ClearSprites
+ call ClearTileMap
+ call DisableLCD
+ call LoadFontsBattleExtra
+ callab Function8cf53
+ ld a, [hCGB]
+ and a
+ jr z, .asm_2900b
+ ld a, $1
+ ld [rVBK], a
+ ld hl, VTiles0
+ ld bc, sScratch - VTiles0
+ xor a
+ call ByteFill
+ ld a, $0
+ ld [rVBK], a
+
+.asm_2900b
+ hlbgcoord 0, 0
+ ld bc, sScratch - VBGMap0
+ ld a, " "
+ call ByteFill
+ ld hl, TradeGameBoyLZ
+ ld de, VTiles2 tile $31
+ call Decompress
+ ld hl, TradeArrowGFX
+ ld de, VTiles1 tile $6d
+ ld bc, $10
+ ld a, BANK(TradeArrowGFX)
+ call FarCopyBytes
+ ld hl, TradeArrowGFX + $10
+ ld de, VTiles1 tile $6e
+ ld bc, $10
+ ld a, BANK(TradeArrowGFX)
+ call FarCopyBytes
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function4d7fd
+ call EnableLCD
+ call Function2982b
+ ld a, [wPlayerTrademonSpecies]
+ ld hl, wPlayerTrademonDVs
+ ld de, VTiles0
+ call Function29491
+ ld a, [wOTTrademonSpecies]
+ ld hl, wOTTrademonDVs
+ ld de, VTiles0 tile $31
+ call Function29491
+ ld a, [wPlayerTrademonSpecies]
+ ld de, wPlayerTrademonSpeciesName
+ call Function294a9
+ ld a, [wOTTrademonSpecies]
+ ld de, wOTTrademonSpeciesName
+ call Function294a9
+ call Function297ed
+ ret
+; 29082
+
+DoTradeAnimation: ; 29082
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .finished
+ call .DoTradeAnimCommand
+ callab Function8cf69
+ ld hl, wcf65
+ inc [hl]
+ call DelayFrame
+ and a
+ ret
+
+.finished
+ call LoadStandardFont
+ scf
+ ret
+; 290a0
+
+.DoTradeAnimCommand: ; 290a0
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, .JumpTable
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 290af
+
+.JumpTable: ; 290af
+ dw GetTradeAnimByte ; 00
+ dw TradeAnim_01 ; 01 get player mon frontpic
+ dw TradeAnim_02 ; 02
+ dw TradeAnim_03 ; 03 transition to link tube
+ dw TradeAnim_04 ; 04 slide in link tube
+ dw TradeAnim_05 ; 05
+ dw TradeAnim_06 ; 06 trademon navigates to OT system
+ dw TradeAnim_07 ; 07 pan bgmap
+ dw TradeAnim_08 ; 08 pan bgmap
+ dw TradeAnim_09 ; 09 pan bgmap
+ dw TradeAnim_0a ; 0a stop scroll
+ dw TradeAnim_0b ; 0b disappear mon icon
+ dw TradeAnim_0c ; 0c continue flashing OT screen
+ dw TradeAnim_0d ; 0d end scene
+ dw TradeAnim_0e ; 0e trademon navigates to player system
+ dw TradeAnim_0f ; 0f pan bgmap
+ dw TradeAnim_10 ; 10 pan bgmap
+ dw TradeAnim_11 ; 11 pan bgmap
+ dw TradeAnim_12 ; 12 stop scroll
+ dw TradeAnim_13 ; 13 disappear mon icon
+ dw TradeAnim_14 ; 14 continue flashing OT screen
+ dw TradeAnim_15 ; 15 end scene
+ dw TradeAnim_16 ; 16
+ dw TradeAnim_17 ; 17
+ dw TradeAnim_18 ; 18
+ dw TradeAnim_19 ; 19
+ dw TradeAnim_1a ; 1a
+ dw TradeAnim_1b ; 1b set up scroll for player mon
+ dw TradeAnim_1c ; 1c scroll across
+ dw TradeAnim_1d ; 1d
+ dw TradeAnim_1e ; 1e set up scroll for mon transfer
+ dw TradeAnim_1f ; 1f
+ dw TradeAnim_20 ; 20
+ dw TradeAnim_21 ; 21 wait 80 frames
+ dw TradeAnim_22 ; 22
+ dw TradeAnim_23 ; 23 ball appear anim
+ dw TradeAnim_24 ; 24 ball rises into tube
+ dw TradeAnim_25 ; 25 wait ball rise
+ dw TradeAnim_26 ; 26
+ dw TradeAnim_27 ; 27 ball return poof anim
+ dw TradeAnim_28 ; 28 ball travels through tube
+ dw TradeAnim_29 ; 29 give trademon sfx
+ dw TradeAnim_2a ; 2a get trademon sfx
+ dw EndTradeAnim ; 2b
+ dw TradeAnim_2c ; 2c
+ dw TradeAnim_2d ; 2d wait 96 frames
+ dw TradeAnim_2e ; 2e
+ dw TradeAnim_2f ; 2f
+; 2910f
+
+NextTradeAnim: ; 2910f
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+; 29114
+
+GetTradeAnimByte: ; 29114
+ ld hl, wTradeAnimPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld a, [de]
+ ld [wJumptableIndex], a
+ inc de
+ ld [hl], d
+ dec hl
+ ld [hl], e
+ ret
+; 29123
+
+EndTradeAnim: ; 29123
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+; 29129
+
+TradeAnim_06: ; 29129
+ ld a, $ed
+ call Function292f6
+ ld a, [wc74c]
+ ld [wd265], a
+ xor a
+ depixel 5, 11, 4, 0
+ ld b, $0
+ jr Function2914e
+
+TradeAnim_0e: ; 2913c
+ ld a, $ee
+ call Function292f6
+ ld a, [wc74d]
+ ld [wd265], a
+ ld a, $2
+ depixel 9, 18, 4, 4
+ ld b, $4
+
+Function2914e: ; 2914e
+ push bc
+ push de
+ push bc
+ push de
+ push af
+ call DisableLCD
+ callab Function8cf53
+ hlbgcoord 20, 3
+ ld bc, $c
+ ld a, $60
+ call ByteFill
+ pop af
+ call Function29281
+ xor a
+ ld [hSCX], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $70
+ ld [hWY], a
+ call EnableLCD
+ call Function2985a
+ pop de
+ ld a, SPRITE_ANIM_INDEX_11
+ call _InitSpriteAnimStruct
+ ld hl, $b
+ add hl, bc
+ pop bc
+ ld [hl], b
+ pop de
+ ld a, SPRITE_ANIM_INDEX_12
+ call _InitSpriteAnimStruct
+ ld hl, $b
+ add hl, bc
+ pop bc
+ ld [hl], b
+ call WaitBGMap
+ ld b, SCGB_1B
+ call GetSGBLayout
+ ld a, $e4
+ call DmgToCgbBGPals
+ ld a, $d0
+ call Functioncf8
+ call NextTradeAnim
+ ld a, $5c
+ ld [wcf64], a
+ ret
+; 291af
+
+TradeAnim_07: ; 291af
+ call Function2981d
+ ld a, [hSCX]
+ add $2
+ ld [hSCX], a
+ cp $50
+ ret nz
+ ld a, $1
+ call Function29281
+ call NextTradeAnim
+ ret
+; 291c4
+
+TradeAnim_08: ; 291c4
+ call Function2981d
+ ld a, [hSCX]
+ add $2
+ ld [hSCX], a
+ cp $a0
+ ret nz
+ ld a, $2
+ call Function29281
+ call NextTradeAnim
+ ret
+; 291d9
+
+TradeAnim_09: ; 291d9
+ call Function2981d
+ ld a, [hSCX]
+ add $2
+ ld [hSCX], a
+ and a
+ ret nz
+ call NextTradeAnim
+ ret
+; 291e8
+
+TradeAnim_10: ; 291e8
+ call Function2981d
+ ld a, [hSCX]
+ sub $2
+ ld [hSCX], a
+ cp $b0
+ ret nz
+ ld a, $1
+ call Function29281
+ call NextTradeAnim
+ ret
+; 291fd
+
+TradeAnim_11: ; 291fd
+ call Function2981d
+ ld a, [hSCX]
+ sub $2
+ ld [hSCX], a
+ cp $60
+ ret nz
+ xor a
+ call Function29281
+ call NextTradeAnim
+ ret
+; 29211
+
+TradeAnim_12: ; 29211
+ call Function2981d
+ ld a, [hSCX]
+ sub $2
+ ld [hSCX], a
+ and a
+ ret nz
+ call NextTradeAnim
+ ret
+; 29220
+
+TradeAnim_0b:
+TradeAnim_13: ; 29220
+ ld a, $80
+ ld [wcf64], a
+ call NextTradeAnim
+ ret
+; 29229
+
+TradeAnim_0d:
+TradeAnim_15: ; 29229
+ call ClearBGPalettes
+ call ClearTileMap
+ call ClearSprites
+ call DisableLCD
+ callab Function8cf53
+ hlbgcoord 0, 0
+ ld bc, sScratch - VBGMap0
+ ld a, " "
+ call ByteFill
+ xor a
+ ld [hSCX], a
+ ld a, $90
+ ld [hWY], a
+ call EnableLCD
+ call Function2982b
+ call WaitBGMap
+ call Function297ed
+ call GetTradeAnimByte
+ ret
+; 2925d
+
+TradeAnim_0a:
+TradeAnim_0c:
+TradeAnim_0f:
+TradeAnim_14: ; 2925d
+ call Function2981d
+ ld hl, wcf64
+ ld a, [hl]
+ and a
+ jr z, .done
+ dec [hl]
+ ret
+
+.done
+ call NextTradeAnim
+ ret
+; 2926d
+
+TradeAnim_29: ; 2926d
+ call GetTradeAnimByte
+ ld de, SFX_GIVE_TRADEMON
+ call PlaySFX
+ ret
+; 29277
+
+TradeAnim_2a: ; 29277
+ call GetTradeAnimByte
+ ld de, SFX_GET_TRADEMON
+ call PlaySFX
+ ret
+; 29281
+
+Function29281: ; 29281
+ and 3
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_2928f
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 2928f
+
+Jumptable_2928f: ; 2928f
+ dw Function29297
+ dw Function292af
+ dw Function292be
+ dw Function29297
+; 29297
+
+Function29297: ; 29297
+ call Function297cf
+ hlcoord 9, 3
+ ld [hl], $5b
+ inc hl
+ ld bc, $a
+ ld a, $60
+ call ByteFill
+ hlcoord 3, 2
+ call Function292ec
+ ret
+; 292af
+
+Function292af: ; 292af
+ call Function297cf
+ hlcoord 0, 3
+ ld bc, SCREEN_WIDTH
+ ld a, $60
+ call ByteFill
+ ret
+; 292be
+
+Function292be: ; 292be
+ call Function297cf
+ hlcoord 0, 3
+ ld bc, $11
+ ld a, $60
+ call ByteFill
+ hlcoord 17, 3
+ ld a, $5d
+ ld [hl], a
+ ld a, $61
+ ld de, SCREEN_WIDTH
+ ld c, $3
+.asm_292d9
+ add hl, de
+ ld [hl], a
+ dec c
+ jr nz, .asm_292d9
+ add hl, de
+ ld a, $5f
+ ld [hld], a
+ ld a, $5b
+ ld [hl], a
+ hlcoord 10, 6
+ call Function292ec
+ ret
+; 292ec
+
+Function292ec: ; 292ec
+ ld de, TradeGameBoyTilemap
+ lb bc, 8, 6
+ call Function297db
+ ret
+; 292f6
+
+Function292f6: ; 292f6
+ push af
+ call ClearBGPalettes
+ call WaitTop
+ ld a, VBGMap1 / $100
+ ld [hBGMapAddress + 1], a
+ call ClearTileMap
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH
+ ld a, "─"
+ call ByteFill
+ hlcoord 0, 1
+ ld de, wc736
+ call PlaceString
+ ld hl, wc741
+ ld de, 0
+.asm_2931e
+ ld a, [hli]
+ cp "@"
+ jr z, .asm_29326
+ dec de
+ jr .asm_2931e
+
+.asm_29326
+ hlcoord 0, 4
+ add hl, de
+ ld de, wc741
+ call PlaceString
+ hlcoord 7, 2
+ ld bc, 6
+ pop af
+ call ByteFill
+ call WaitBGMap
+ call WaitTop
+ ld a, VBGMap0 / $100
+ ld [hBGMapAddress + 1], a
+ call ClearTileMap
+ ret
+; 29348
+
+TradeAnim_03: ; 29348
+ call ClearTileMap
+ call WaitTop
+ ld a, $a0
+ ld [hSCX], a
+ call DelayFrame
+ hlcoord 8, 2
+ ld de, Tilemap_298f7
+ lb bc, 3, 12
+ call Function297db
+ call WaitBGMap
+ ld b, SCGB_1B
+ call GetSGBLayout
+ ld a, $e4
+ call DmgToCgbBGPals
+ ld de, $e4e4
+ call DmgToCgbObjPals
+ ld de, SFX_POTION
+ call PlaySFX
+ call NextTradeAnim
+ ret
+; 2937e
+
+TradeAnim_04: ; 2937e
+ ld a, [hSCX]
+ and a
+ jr z, .done
+ add $4
+ ld [hSCX], a
+ ret
+
+.done
+ ld c, 80
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+; 29391
+
+TradeAnim_05: ; 29391
+ ld a, [hSCX]
+ cp $a0
+ jr z, .asm_2939c
+ sub $4
+ ld [hSCX], a
+ ret
+
+.asm_2939c
+ call ClearTileMap
+ xor a
+ ld [hSCX], a
+ call GetTradeAnimByte
+ ret
+; 293a6
+
+TradeAnim_1b: ; 293a6
+ ld a, $8f
+ ld [hWX], a
+ ld a, $88
+ ld [hSCX], a
+ ld a, $50
+ ld [hWY], a
+ call GetTradeAnimByte
+ ret
+; 293b6
+
+TradeAnim_1c: ; 293b6
+ ld a, [hWX]
+ cp $7
+ jr z, .done
+ sub $4
+ ld [hWX], a
+ ld a, [hSCX]
+ sub $4
+ ld [hSCX], a
+ ret
+
+.done
+ ld a, $7
+ ld [hWX], a
+ xor a
+ ld [hSCX], a
+ call GetTradeAnimByte
+ ret
+; 293d2
+
+TradeAnim_1d: ; 293d2
+ ld a, $7
+ ld [hWX], a
+ ld a, $50
+ ld [hWY], a
+ call GetTradeAnimByte
+ ret
+; 293de
+
+TradeAnim_1e: ; 293de
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ call GetTradeAnimByte
+ ret
+; 293ea
+
+TradeAnim_1f: ; 293ea
+ call WaitTop
+ ld a, VBGMap1 / $100
+ ld [hBGMapAddress + 1], a
+ call WaitBGMap
+ ld a, $7
+ ld [hWX], a
+ xor a
+ ld [hWY], a
+ call DelayFrame
+ call WaitTop
+ ld a, VBGMap0 / $100
+ ld [hBGMapAddress + 1], a
+ call ClearTileMap
+ call NextTradeAnim
+ ret
+; 2940c
+
+TradeAnim_20: ; 2940c
+ ld a, [hWX]
+ cp $a1
+ jr nc, .asm_29417
+ add $4
+ ld [hWX], a
+ ret
+
+.asm_29417
+ ld a, VBGMap1 / $100
+ ld [hBGMapAddress + 1], a
+ call WaitBGMap
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ ld a, VBGMap0 / $100
+ ld [hBGMapAddress + 1], a
+ call GetTradeAnimByte
+ ret
+; 2942e
+
+TradeAnim_01: ; 2942e
+ call Function2951f
+ ld a, [wPlayerTrademonSpecies]
+ ld [CurPartySpecies], a
+ ld a, [wPlayerTrademonDVs]
+ ld [TempMonDVs], a
+ ld a, [wPlayerTrademonDVs + 1]
+ ld [TempMonDVs + 1], a
+ ld b, SCGB_1A
+ call GetSGBLayout
+ ld a, $e4
+ call DmgToCgbBGPals
+ call Function294bb
+
+ ld a, [wPlayerTrademonSpecies]
+ call GetCryIndex
+ jr c, .skip_cry
+ ld e, c
+ ld d, b
+ call PlayCryHeader
+.skip_cry
+
+ call GetTradeAnimByte
+ ret
+; 29461
+
+TradeAnim_02: ; 29461
+ call Function29549
+ ld a, [wOTTrademonSpecies]
+ ld [CurPartySpecies], a
+ ld a, [wOTTrademonDVs]
+ ld [TempMonDVs], a
+ ld a, [wOTTrademonDVs + 1]
+ ld [TempMonDVs + 1], a
+ ld b, SCGB_1A
+ call GetSGBLayout
+ ld a, $e4
+ call DmgToCgbBGPals
+ call Function294c0
+ call GetTradeAnimByte
+ ret
+; 29487
+
+TradeAnim_2c: ; 29487
+ callba Function4d81e
+ call GetTradeAnimByte
+ ret
+; 29491
+
+Function29491: ; 29491
+ push de
+ push af
+ predef GetUnownLetter
+ pop af
+ ld [CurPartySpecies], a
+ ld [CurSpecies], a
+ call GetBaseData
+ pop de
+ predef GetFrontpic
+ ret
+; 294a9
+
+Function294a9: ; 294a9
+ push de
+ ld [wd265], a
+ call GetPokemonName
+ ld hl, StringBuffer1
+ pop de
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ret
+; 294bb
+
+Function294bb: ; 294bb
+ ld de, VTiles0
+ jr Function294c3
+
+Function294c0: ; 294c0
+ ld de, VTiles0 tile $31
+
+Function294c3: ; 294c3
+ call DelayFrame
+ ld hl, VTiles2
+ lb bc, 10, $31
+ call Request2bpp
+ call WaitTop
+ call Function297cf
+ hlcoord 7, 2
+ xor a
+ ld [hFillBox], a
+ lb bc, 7, 7
+ predef FillBox
+ call WaitBGMap
+ ret
+; 294e7
+
+TradeAnim_21: ; 294e7
+ ld c, 80
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+; 294f0
+
+TradeAnim_22: ; 294f0
+ ld c, 40
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+; 294f9
+
+TradeAnim_2d: ; 294f9
+ ld c, 96
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+; 29502
+
+TradeAnim_2e: ; 29502
+ call Function29516
+ ret nz
+ ld c, 80
+ call DelayFrames
+ ret
+; 2950c
+
+TradeAnim_2f: ; 2950c
+ call Function29516
+ ret nz
+ ld c, 180
+ call DelayFrames
+ ret
+; 29516
+
+Function29516: ; 29516
+ call GetTradeAnimByte
+ ld a, [wOTTrademonSpecies]
+ cp $fd
+ ret
+; 2951f
+Function2951f: ; 2951f
+ ld de, wPlayerTrademonSpecies
+ ld a, [de]
+ cp $fd
+ jr z, Function295a1
+ call Function29573
+ ld de, wPlayerTrademonSpecies
+ call Function295e3
+ ld de, wPlayerTrademonSpeciesName
+ call Function295ef
+ ld a, [wPlayerTrademonCaughtData]
+ ld de, wPlayerTrademonOTName
+ call Function295f6
+ ld de, PlayerScreens
+ call Function29611
+ call Function295d8
+ ret
+; 29549
+
+Function29549: ; 29549
+ ld de, wOTTrademonSpecies
+ ld a, [de]
+ cp $fd
+ jr z, Function295a1
+ call Function29573
+ ld de, wOTTrademonSpecies
+ call Function295e3
+ ld de, wOTTrademonSpeciesName
+ call Function295ef
+ ld a, [wOTTrademonCaughtData]
+ ld de, wOTTrademonOTName
+ call Function295f6
+ ld de, wOTTrademonID
+ call Function29611
+ call Function295d8
+ ret
+; 29573
+
+Function29573: ; 29573
+ call WaitTop
+ call Function297cf
+ ld a, VBGMap1 / $100
+ ld [hBGMapAddress + 1], a
+ hlcoord 3, 0
+ ld b, $6
+ ld c, $d
+ call TextBox
+ hlcoord 4, 0
+ ld de, String29591
+ call PlaceString
+ ret
+; 29591
+
+String29591: ; 29591
+ db "─── №."
+ next ""
+ next "OT/"
+ next $73, "№.@"
+; 295a1
+
+Function295a1: ; 295a1
+ call WaitTop
+ call Function297cf
+ ld a, VBGMap1 / $100
+ ld [hBGMapAddress + 1], a
+ hlcoord 3, 0
+ ld b, $6
+ ld c, $d
+ call TextBox
+ hlcoord 4, 2
+ ld de, String295c2
+ call PlaceString
+ call Function295d8
+ ret
+; 295c2
+
+String295c2: ; 295c2
+ db "EGG"
+ next "OT/?????"
+ next "<ID>№.?????@"
+; 295d8
+
+Function295d8: ; 295d8
+ call WaitBGMap
+ call WaitTop
+ ld a, VBGMap0 / $100
+ ld [hBGMapAddress + 1], a
+ ret
+; 295e3
+
+Function295e3: ; 295e3
+ hlcoord 10, 0
+ lb bc, PRINTNUM_LEADINGZEROS | 1, 3
+ call PrintNum
+ ld [hl], " "
+ ret
+; 295ef
+
+Function295ef: ; 295ef
+ hlcoord 4, 2
+ call PlaceString
+ ret
+; 295f6
+
+Function295f6: ; 295f6
+ cp 3
+ jr c, .asm_295fb
+ xor a
+
+.asm_295fb
+ push af
+ hlcoord 7, 4
+ call PlaceString
+ inc bc
+ pop af
+ ld hl, Unknown_2960e
+ ld d, 0
+ ld e, a
+ add hl, de
+ ld a, [hl]
+ ld [bc], a
+ ret
+; 2960e
+
+Unknown_2960e: ; 2960e
+ db " ", "♂", "♀"
+; 29611
+
+Function29611: ; 29611
+ hlcoord 7, 6
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ ret
+; 2961b
+
+TradeAnim_23: ; 2961b
+ depixel 10, 11, 4, 0
+ ld a, SPRITE_ANIM_INDEX_0E
+ call _InitSpriteAnimStruct
+ call GetTradeAnimByte
+ ld a, $20
+ ld [wcf64], a
+ ret
+; 2962c
+
+TradeAnim_24: ; 2962c
+ depixel 10, 11, 4, 0
+ ld a, SPRITE_ANIM_INDEX_0E
+ call _InitSpriteAnimStruct
+ ld hl, $b
+ add hl, bc
+ ld [hl], $1
+ ld hl, $7
+ add hl, bc
+ ld [hl], $dc
+ call GetTradeAnimByte
+ ld a, $38
+ ld [wcf64], a
+ ret
+; 29649
+
+TradeAnim_27: ; 29649
+ depixel 10, 11, 4, 0
+ ld a, SPRITE_ANIM_INDEX_0F
+ call _InitSpriteAnimStruct
+ call GetTradeAnimByte
+ ld a, $10
+ ld [wcf64], a
+ ld de, SFX_BALL_POOF
+ call PlaySFX
+ ret
+; 29660
+
+TradeAnim_28: ; 29660
+ ld a, $e4
+ call Functioncf8
+ depixel 5, 11
+ ld a, SPRITE_ANIM_INDEX_10
+ call _InitSpriteAnimStruct
+ call GetTradeAnimByte
+ ld a, $40
+ ld [wcf64], a
+ ret
+; 29676
+
+Function29676: ; 29676 (a:5676)
+ ld hl, $b
+ add hl, bc
+ ld e, [hl]
+ ld d, 0
+ ld hl, Jumptable_29686
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 29686
+
+Jumptable_29686: ; 29686 (a:5686)
+ dw Function2969a
+ dw Function296a4
+ dw Function296af
+ dw Function296bd
+ dw Function296cf
+ dw Function296dd
+ dw Function296f2
+; 2969a
+
+Function29694: ; 29694 (a:5694)
+ ld hl, $b
+ add hl, bc
+ inc [hl]
+ ret
+
+Function2969a: ; 2969a (a:569a)
+ call Function29694
+ ld hl, $c
+ add hl, bc
+ ld [hl], $80
+ ret
+
+Function296a4: ; 296a4 (a:56a4)
+ ld hl, $c
+ add hl, bc
+ ld a, [hl]
+ dec [hl]
+ and a
+ ret nz
+ call Function29694
+
+Function296af: ; 296af (a:56af)
+ ld hl, $4
+ add hl, bc
+ ld a, [hl]
+ cp $94
+ jr nc, .asm_296ba
+ inc [hl]
+ ret
+.asm_296ba
+ call Function29694
+
+Function296bd: ; 296bd (a:56bd)
+ ld hl, $5
+ add hl, bc
+ ld a, [hl]
+ cp $4c
+ jr nc, .asm_296c8
+ inc [hl]
+ ret
+.asm_296c8
+ ld hl, $
+ add hl, bc
+ ld [hl], $0
+ ret
+
+Function296cf: ; 296cf (a:56cf)
+ ld hl, $5
+ add hl, bc
+ ld a, [hl]
+ cp $2c
+ jr z, .asm_296da
+ dec [hl]
+ ret
+.asm_296da
+ call Function29694
+
+Function296dd: ; 296dd (a:56dd)
+ ld hl, $4
+ add hl, bc
+ ld a, [hl]
+ cp $58
+ jr z, .asm_296e8
+ dec [hl]
+ ret
+.asm_296e8
+ call Function29694
+ ld hl, $c
+ add hl, bc
+ ld [hl], $80
+ ret
+
+Function296f2: ; 296f2 (a:56f2)
+ ld hl, $c
+ add hl, bc
+ ld a, [hl]
+ dec [hl]
+ and a
+ ret nz
+ ld hl, $
+ add hl, bc
+ ld [hl], $0
+ ret
+; 29701 (a:5701)
+
+TradeAnim_16: ; 29701
+ ld a, [wLinkMode]
+ cp LINK_TIMECAPSULE
+ jr z, .time_capsule
+ ld hl, UnknownText_0x29737
+ call PrintText
+ ld c, 189
+ call DelayFrames
+ ld hl, UnknownText_0x29732
+ call PrintText
+ call Function297c9
+ ld c, 128
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+
+.time_capsule
+ ld hl, UnknownText_0x29732
+ call PrintText
+ call Function297c9
+ call GetTradeAnimByte
+ ret
+; 29732
+
+UnknownText_0x29732: ; 0x29732
+ ; was sent to @ .
+ text_jump UnknownText_0x1bc6e9
+ db "@"
+; 0x29737
+
+UnknownText_0x29737: ; 0x29737
+ ;
+ text_jump UnknownText_0x1bc701
+ db "@"
+; 0x2973c
+
+TradeAnim_17: ; 2973c
+ ld hl, UnknownText_0x29752
+ call PrintText
+ call Function297c9
+ ld hl, UnknownText_0x29757
+ call PrintText
+ call Function297c9
+ call GetTradeAnimByte
+ ret
+; 29752
+
+UnknownText_0x29752: ; 0x29752
+ ; bids farewell to
+ text_jump UnknownText_0x1bc703
+ db "@"
+; 0x29757
+
+UnknownText_0x29757: ; 0x29757
+ ; .
+ text_jump UnknownText_0x1bc719
+ db "@"
+; 0x2975c
+
+TradeAnim_18: ; 2975c
+ call WaitTop
+ hlcoord 0, 10
+ ld bc, 8 * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ call WaitBGMap
+ ld hl, UnknownText_0x2977a
+ call PrintText
+ call Function297c9
+ call GetTradeAnimByte
+ ret
+; 2977a
+
+UnknownText_0x2977a: ; 0x2977a
+ ; Take good care of @ .
+ text_jump UnknownText_0x1bc71f
+ db "@"
+; 0x2977f
+
+TradeAnim_19: ; 2977f
+ ld hl, UnknownText_0x2979a
+ call PrintText
+ call Function297c9
+ ld hl, UnknownText_0x2979f
+ call PrintText
+ call Function297c9
+ ld c, 14
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+; 2979a
+
+UnknownText_0x2979a: ; 0x2979a
+ ; For @ 's @ ,
+ text_jump UnknownText_0x1bc739
+ db "@"
+; 0x2979f
+
+UnknownText_0x2979f: ; 0x2979f
+ ; sends @ .
+ text_jump UnknownText_0x1bc74c
+ db "@"
+; 0x297a4
+
+TradeAnim_1a: ; 297a4
+ ld hl, UnknownText_0x297bf
+ call PrintText
+ call Function297c9
+ ld hl, UnknownText_0x297c4
+ call PrintText
+ call Function297c9
+ ld c, 14
+ call DelayFrames
+ call GetTradeAnimByte
+ ret
+; 297bf
+
+UnknownText_0x297bf: ; 0x297bf
+ ; will trade @ @
+ text_jump UnknownText_0x1bc75e
+ db "@"
+; 0x297c4
+
+UnknownText_0x297c4: ; 0x297c4
+ ; for @ 's @ .
+ text_jump UnknownText_0x1bc774
+ db "@"
+; 0x297c9
+
+Function297c9: ; 297c9
+ ld c, 80
+ call DelayFrames
+ ret
+; 297cf
+
+Function297cf: ; 297cf
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill
+ ret
+; 297db
+
+Function297db: ; 297db
+.asm_297db
+ push bc
+ push hl
+.asm_297dd
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .asm_297dd
+ pop hl
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .asm_297db
+ ret
+; 297ed
+
+Function297ed: ; 297ed
+ ld a, [hSGB]
+ and a
+ ld a, $e4
+ jr z, .asm_297f6
+ ld a, $f0
+
+.asm_297f6
+ call Functioncf8
+ ld a, $e4
+ call DmgToCgbBGPals
+ ret
+; 297ff
+
+Function297ff: ; 297ff
+ push de
+ ld de, wc736
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ pop hl
+ ld de, wc741
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ret
+; 29814
+
+Function29814: ; 29814
+ ld a, [hl]
+ ld [wc74c], a
+ ld a, [de]
+ ld [wc74d], a
+ ret
+; 2981d
+
+Function2981d: ; 2981d
+ ld a, [wcf65]
+ and $7
+ ret nz
+ ld a, [rBGP]
+ xor $3c
+ call DmgToCgbBGPals
+ ret
+; 2982b
+
+Function2982b: ; 2982b
+ call DelayFrame
+ ld de, TradeBallGFX
+ ld hl, VTiles0 tile $62
+ lb bc, BANK(TradeBallGFX), $6
+ call Request2bpp
+ ld de, TradePoofGFX
+ ld hl, VTiles0 tile $68
+ lb bc, BANK(TradePoofGFX), $c
+ call Request2bpp
+ ld de, TradeCableGFX
+ ld hl, VTiles0 tile $74
+ lb bc, BANK(TradeCableGFX), $4
+ call Request2bpp
+ xor a
+ ld hl, wc300
+ ld [hli], a
+ ld [hl], $62
+ ret
+; 2985a
+
+Function2985a: ; 2985a
+ call DelayFrame
+ ld e, $3
+ callab Function8e83f
+ ld de, TradeBubbleGFX
+ ld hl, VTiles0 tile $72
+ lb bc, BANK(TradeBubbleGFX), $4
+ call Request2bpp
+ xor a
+ ld hl, wc300
+ ld [hli], a
+ ld [hl], $62
+ ret
+; 29879
+
+TradeAnim_25: ; 29879
+ ld hl, wcf64
+ ld a, [hl]
+ and a
+ jr z, .done
+ dec [hl]
+ ret
+
+.done
+ call GetTradeAnimByte
+ ret
+; 29886
+
+TradeAnim_26: ; 29886
+ ld hl, wcf64
+ ld a, [hl]
+ and a
+ jr z, .asm_2988f
+ dec [hl]
+ ret
+
+.asm_2988f
+ call GetTradeAnimByte
+ ret
+; 29893
+
+
+Function29893: ; 29893
+; This function is unreferenced.
+; It was meant for use in Japanese versions, so the
+; constant used for copy length was changed by accident.
+
+ ld hl, Unknown_298b5
+
+ ld a, [hli]
+ ld [wPlayerTrademonSpecies], a
+ ld de, wPlayerTrademonSenderName
+ ld c, 13 ; jp: 8
+.asm_2989f
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_2989f
+
+ ld a, [hli]
+ ld [wOTTrademonSpecies], a
+ ld de, wOTTrademonSenderName
+ ld c, 13 ; jp: 8
+.asm_298ae
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_298ae
+ ret
+; 298b5
+
+Unknown_298b5: ; 298b5
+ db $03, "ゲーフり@@", $23, $01 ; GAME FREAK
+ db $06, "クりーチャ@", $56, $04 ; Creatures Inc.
+; 298c7
+
+
+TradeGameBoyTilemap: ; 298c7
+; 6x8
+ db $31, $32, $32, $32, $32, $33
+ db $34, $35, $36, $36, $37, $38
+ db $34, $39, $3a, $3a, $3b, $38
+ db $3c, $3d, $3e, $3e, $3f, $40
+ db $41, $42, $43, $43, $44, $45
+ db $46, $47, $43, $48, $49, $4a
+ db $41, $43, $4b, $4c, $4d, $4e
+ db $4f, $50, $50, $50, $51, $52
+; 297f7
+
+Tilemap_298f7: ; 297f7
+; 12x3
+ db $43, $55, $56, $53, $53, $53, $53, $53, $53, $53, $53, $53
+ db $43, $57, $58, $54, $54, $54, $54, $54, $54, $54, $54, $54
+ db $43, $59, $5a, $43, $43, $43, $43, $43, $43, $43, $43, $43
+; 2991b
+
+TradeArrowGFX: INCBIN "gfx/trade/arrow.2bpp"
+TradeCableGFX: INCBIN "gfx/trade/cable.2bpp"
+TradeBubbleGFX: INCBIN "gfx/trade/bubble.2bpp"
+TradeGameBoyLZ: INCBIN "gfx/trade/game_boy.2bpp.lz"
+TradeBallGFX: INCBIN "gfx/trade/ball.2bpp"
+TradePoofGFX: INCBIN "gfx/trade/poof.2bpp"
--- a/event/photo.asm
+++ b/event/photo.asm
@@ -81,7 +81,7 @@
.pressed_a
ld a, [wJumptableIndex]
push af
- callba Function84560
+ callba PrintUnownStamp
call RestartMapMusic
pop af
ld [wJumptableIndex], a
@@ -248,9 +248,9 @@
ld hl, .Text_HoldStill
call PrintText
call DisableSpriteUpdates
- callba Function8461a
+ callba PrintPartymon
call Function2b74
- ld a, [$ffac]
+ ld a, [hPrinter]
and a
jr nz, .cancel
ld hl, .Text_Presto
--- a/gfx/mail.asm
+++ b/gfx/mail.asm
@@ -41,14 +41,12 @@
call SetPalettes
xor a
ld [hJoyPressed], a
- call Functionb929a
+ call .loop
call ClearBGPalettes
call DisableLCD
call LoadStandardFont
jp EnableLCD
-; b929a
-Functionb929a: ; b929a
.loop
call GetJoypad
ld a, [hJoyPressed]
@@ -61,7 +59,7 @@
.pressed_start
ld a, [wJumptableIndex]
push af
- callab Function845d4
+ callab PrintMail ; printer
pop af
ld [wJumptableIndex], a
jr .loop
--- a/hram.asm
+++ b/hram.asm
@@ -32,6 +32,7 @@
hJoyLast EQU $ffa9
hInMenu EQU $ffaa
+hPrinter EQU $ffac
hFillBox EQU $ffad
hMapObjectIndexBuffer EQU $ffaf
--- a/macros.asm
+++ b/macros.asm
@@ -14,7 +14,7 @@
INCLUDE "macros/rst.asm"
INCLUDE "macros/mobile.asm"
INCLUDE "macros/trainer.asm"
-
+INCLUDE "macros/trade_anim.asm"
RGB: MACRO
--- /dev/null
+++ b/macros/trade_anim.asm
@@ -1,0 +1,175 @@
+ enum_start
+ enum tradeanim_next_command
+tradeanim_next: macro
+ db tradeanim_next_command
+endm
+
+ enum tradeanim_01_command
+tradeanim_01: macro
+ db tradeanim_01_command
+endm
+
+ enum tradeanim_02_command
+tradeanim_02: macro
+ db tradeanim_02_command
+endm
+
+ enum tradeanim_03_command
+tradeanim_03: macro
+ db tradeanim_03_command
+endm
+
+ enum tradeanim_04_command
+tradeanim_04: macro
+ db tradeanim_04_command
+endm
+
+ enum tradeanim_05_command
+tradeanim_05: macro
+ db tradeanim_05_command
+endm
+
+ enum tradeanim_06_command
+tradeanim_06: macro
+ db tradeanim_06_command
+endm
+
+__enum__ set $e
+
+ enum tradeanim_0e_command
+tradeanim_0e: macro
+ db tradeanim_0e_command
+endm
+
+__enum__ set $16
+
+ enum tradeanim_16_command
+tradeanim_16: macro
+ db tradeanim_16_command
+endm
+
+ enum tradeanim_17_command
+tradeanim_17: macro
+ db tradeanim_17_command
+endm
+
+ enum tradeanim_18_command
+tradeanim_18: macro
+ db tradeanim_18_command
+endm
+
+ enum tradeanim_19_command
+tradeanim_19: macro
+ db tradeanim_19_command
+endm
+
+ enum tradeanim_1a_command
+tradeanim_1a: macro
+ db tradeanim_1a_command
+endm
+
+ enum tradeanim_1b_command
+tradeanim_1b: macro
+ db tradeanim_1b_command
+endm
+
+ enum tradeanim_1c_command
+tradeanim_1c: macro
+ db tradeanim_1c_command
+endm
+
+ enum tradeanim_1d_command
+tradeanim_1d: macro
+ db tradeanim_1d_command
+endm
+
+ enum tradeanim_1e_command
+tradeanim_1e: macro
+ db tradeanim_1e_command
+endm
+
+ enum tradeanim_1f_command
+tradeanim_1f: macro
+ db tradeanim_1f_command
+endm
+
+ enum tradeanim_20_command
+tradeanim_20: macro
+ db tradeanim_20_command
+endm
+
+ enum tradeanim_21_command
+tradeanim_21: macro
+ db tradeanim_21_command
+endm
+
+ enum tradeanim_22_command
+tradeanim_22: macro
+ db tradeanim_22_command
+endm
+
+ enum tradeanim_23_command
+tradeanim_23: macro
+ db tradeanim_23_command
+endm
+
+ enum tradeanim_24_command
+tradeanim_24: macro
+ db tradeanim_24_command
+endm
+
+ enum tradeanim_25_command
+tradeanim_25: macro
+ db tradeanim_25_command
+endm
+
+ enum tradeanim_26_command
+tradeanim_26: macro
+ db tradeanim_26_command
+endm
+
+ enum tradeanim_27_command
+tradeanim_27: macro
+ db tradeanim_27_command
+endm
+
+ enum tradeanim_28_command
+tradeanim_28: macro
+ db tradeanim_28_command
+endm
+
+ enum tradeanim_29_command
+tradeanim_29: macro
+ db tradeanim_29_command
+endm
+
+ enum tradeanim_2a_command
+tradeanim_2a: macro
+ db tradeanim_2a_command
+endm
+
+ enum tradeanim_end_command
+tradeanim_end: macro
+ db tradeanim_end_command
+endm
+
+ enum tradeanim_2c_command
+tradeanim_2c: macro
+ db tradeanim_2c_command
+endm
+
+ enum tradeanim_2d_command
+tradeanim_2d: macro
+ db tradeanim_2d_command
+endm
+
+ enum tradeanim_2e_command
+tradeanim_2e: macro
+ db tradeanim_2e_command
+endm
+
+ enum tradeanim_2f_command
+tradeanim_2f: macro
+ db tradeanim_2f_command
+endm
+
--- a/main.asm
+++ b/main.asm
@@ -7688,6 +7688,10 @@
callab GetPreEvolution
ld a, [CurPartySpecies]
dec a
+
+; TryAddMonToParty sets Seen and Caught flags
+; when it is successful. This routine will make
+; sure that we aren't newly setting flags.
push af
call CheckCaughtMon
pop af
@@ -7694,33 +7698,41 @@
push bc
call CheckSeenMon
push bc
+
call TryAddMonToParty
+
+; If we haven't caught this Pokemon before receiving
+; the Egg, reset the flag that was just set by
+; TryAddMonToParty.
pop bc
ld a, c
and a
- jr nz, .asm_dfc3
+ jr nz, .skip_caught_flag
ld a, [CurPartySpecies]
dec a
ld c, a
ld d, $0
ld hl, PokedexCaught
- ld b, $0
+ ld b, RESET_FLAG
predef FlagPredef
-.asm_dfc3
+.skip_caught_flag
+; If we haven't seen this Pokemon before receiving
+; the Egg, reset the flag that was just set by
+; TryAddMonToParty.
pop bc
ld a, c
and a
- jr nz, .asm_dfd9
+ jr nz, .skip_seen_flag
ld a, [CurPartySpecies]
dec a
ld c, a
ld d, $0
ld hl, PokedexSeen
- ld b, $0
+ ld b, RESET_FLAG
predef FlagPredef
-.asm_dfd9
+.skip_seen_flag
pop af
ld [CurPartySpecies], a
ld a, [PartyCount]
@@ -12286,7 +12298,7 @@
ld a, $0
call GetSRAMBank
ld d, $0
- ld b, $2
+ ld b, CHECK_FLAG
predef FlagPredef
call CloseSRAM
ld a, c
@@ -14356,7 +14368,7 @@
ld a, [hli]
ld [de], a
ld a, [hl]
- ld [wc652], a
+ ld [wEnemyTrainerBaseReward], a
ret
; 3959c
@@ -14437,7 +14449,7 @@
jp [hl]
.done
- jp Function3991b
+ jp ComputeTrainerReward
.cal2
ld a, BANK(sMysteryGiftTrainer)
@@ -14673,18 +14685,18 @@
jr .loop
; 3991b
-Function3991b: ; 3991b (e:591b)
- ld hl, hMultiplicand - 1
+ComputeTrainerReward: ; 3991b (e:591b)
+ ld hl, hProduct
xor a
rept 3
ld [hli], a
endr
- ld a, [wc652] ; base reward
+ ld a, [wEnemyTrainerBaseReward]
ld [hli], a
ld a, [CurPartyLevel]
ld [hl], a
call Multiply
- ld hl, wc686
+ ld hl, wBattleReward
xor a
ld [hli], a
ld a, [hProduct + 2]
@@ -14717,9 +14729,9 @@
call CloseSRAM
jr z, .not_cal2
- ld a, BANK(s0_abfe)
+ ld a, BANK(sMysteryGiftPartnerName)
call GetSRAMBank
- ld hl, s0_abfe
+ ld hl, sMysteryGiftPartnerName
call CopyTrainerName
jp CloseSRAM
@@ -24118,31 +24130,31 @@
Function1047a3: ; 1047a3 (41:47a3)
decoord 0, 0
- call Function1047b4
+ call .copy
ld a, [hCGB]
and a
ret z
+
decoord 0, 0, AttrMap
ld a, $1
ld [rVBK], a
-
-Function1047b4: ; 1047b4 (41:47b4)
+.copy:
hlbgcoord 0, 0
- ld c, $14
- ld b, $12
-.asm_1047bb
+ ld c, SCREEN_WIDTH
+ ld b, SCREEN_HEIGHT
+.row
push bc
-.asm_1047bc
+.column
ld a, [de]
inc de
ld [hli], a
dec c
- jr nz, .asm_1047bc
- ld bc, $c
+ jr nz, .column
+ ld bc, $20 - SCREEN_WIDTH
add hl, bc
pop bc
dec b
- jr nz, .asm_1047bb
+ jr nz, .row
ld a, $0
ld [rVBK], a
ret
@@ -24287,2061 +24299,10 @@
ret
; 1048ba
+INCLUDE "engine/mysterygift.asm"
-DoMysteryGift: ; 1048ba (41:48ba)
- call ClearTileMap
- call ClearSprites
- call WaitBGMap
- call Function105153
- hlcoord 3, 8
- ld de, String_1049cd
- call PlaceString
- call WaitBGMap
- callba Function2c642
- call Function1050fb
- ld a, $2
- ld [wca01], a
- ld a, $14
- ld [wca02], a
- ld a, [rIE]
- push af
- call Function104a95
- ld d, a
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- push de
- call ClearTileMap
- call EnableLCD
- call WaitBGMap
- ld b, SCGB_08
- call GetSGBLayout
- call SetPalettes
- pop de
- hlcoord 2, 8
- ld a, d
- ld de, UnknownText_0x1049fd
- cp $10
- jp z, Function1049af
- cp $6c
- jp nz, Function1049b4
- ld a, [wc900]
- cp $3
- jr z, .asm_10492f
- call Function104a25
- ld hl, UnknownText_0x104a11
- jp nc, Function1049c5
- call Function104a30
- ld hl, UnknownText_0x104a16
- jp c, Function1049c5
-.asm_10492f
- ld a, [wc962]
- and a
- jp nz, Function1049bd
- ld a, [wc912]
- and a
- jp nz, Function1049c2
- ld a, [wc900]
- cp $3
- jr z, .asm_104963
- call Function104a56
- ld a, [wc900]
- cp $4
- jr z, .asm_104963
- call Function104a71
- callba RestoreMobileEventIndex
- callba MobileFn_1060a9
- callba BackupMobileEventIndex
-.asm_104963
- ld a, [wc90f]
- and a
- jr z, .item
- ld a, [wc911]
- ld c, a
- callba MysteryGiftGetDecoration
- push bc
- call Function105069
- pop bc
- jr nz, .item
- callab GetDecorationName_c
- ld h, d
- ld l, e
- ld de, StringBuffer1
- ld bc, ITEM_NAME_LENGTH
- call CopyBytes
- ld hl, UnknownText_0x104a20
- jr Function1049c5
+INCLUDE "battle/used_move_text.asm"
-.item
- call GetMysteryGiftBank
- ld a, [wc910]
- ld c, a
- callba MysteryGiftGetItemHeldEffect
- ld a, c
- ld [sBackupMysteryGiftItem], a
- ld [wNamedObjectIndexBuffer], a
- call CloseSRAM
- call GetItemName
- ld hl, UnknownText_0x104a1b
- jr Function1049c5
-
-Function1049af: ; 1049af (41:49af)
- ld hl, UnknownText_0x1049fd
- jr Function1049c5
-
-Function1049b4: ; 1049b4 (41:49b4)
- ld hl, UnknownText_0x104a02
- call PrintText
- jp DoMysteryGift
-
-Function1049bd: ; 1049bd (41:49bd)
- ld hl, UnknownText_0x104a07
- jr Function1049c5
-
-Function1049c2: ; 1049c2 (41:49c2)
- ld hl, UnknownText_0x104a0c
-
-Function1049c5: ; 1049c5 (41:49c5)
- call PrintText
- ld a, $e3
- ld [rLCDC], a
- ret
-; 1049cd (41:49cd)
-
-String_1049cd: ; 1049cd
- db "Press A to"
- next "link IR-Device"
- next "Press B to"
- next "cancel it."
- db "@"
-; 1049fd
-
-UnknownText_0x1049fd: ; 1049fd
- text_jump UnknownText_0x1c0436
- db "@"
-; 104a02
-
-UnknownText_0x104a02: ; 104a02
- text_jump UnknownText_0x1c0454
- db "@"
-; 104a07
-
-UnknownText_0x104a07: ; 104a07
- text_jump UnknownText_0x1c046a
- db "@"
-; 104a0c
-
-UnknownText_0x104a0c: ; 104a0c
- text_jump UnknownText_0x1c048e
- db "@"
-; 104a11
-
-UnknownText_0x104a11: ; 104a11
- text_jump UnknownText_0x1c04a7
- db "@"
-; 104a16
-
-UnknownText_0x104a16: ; 104a16
- text_jump UnknownText_0x1c04c6
- db "@"
-; 104a1b
-
-UnknownText_0x104a1b: ; 104a1b
- text_jump UnknownText_0x1c04e9
- db "@"
-; 104a20
-
-UnknownText_0x104a20: ; 104a20
- text_jump UnknownText_0x1c04fa
- db "@"
-; 104a25
-
-Function104a25: ; 104a25 (41:4a25)
- call GetMysteryGiftBank
- ld a, [s0_abe5]
- cp $5
- jp CloseSRAM
-
-Function104a30: ; 104a30 (41:4a30)
- call GetMysteryGiftBank
- ld a, [wc901]
- ld b, a
- ld a, [wc902]
- ld c, a
- ld a, [s0_abe5]
- ld d, a
- ld hl, s0_abe6
-.asm_104a42
- ld a, d
- and a
- jr z, .asm_104a53
- ld a, [hli]
- cp b
- jr nz, .asm_104a4e
- ld a, [hl]
- cp c
- jr z, .asm_104a52
-.asm_104a4e
- inc hl
- dec d
- jr .asm_104a42
-.asm_104a52
- scf
-.asm_104a53
- jp CloseSRAM
-
-Function104a56: ; 104a56 (41:4a56)
- call GetMysteryGiftBank
- ld hl, s0_abe5
- ld a, [hl]
- inc [hl]
- ld hl, s0_abe6 ; inc hl
- ld e, a
- ld d, $0
-rept 2
- add hl, de
-endr
- ld a, [wc901]
- ld [hli], a
- ld a, [wc902]
- ld [hl], a
- jp CloseSRAM
-
-Function104a71: ; 104a71 (41:4a71)
- call GetMysteryGiftBank
- ld a, $1
- ld [sMysteryGiftTrainerHouseFlag], a
- ld hl, wc903
- ld de, s0_abfe
- ld bc, $b
- call CopyBytes
- ld a, $1
- ld [de], a
- inc de
- ld hl, wc850
- ld bc, $26
- call CopyBytes
- jp CloseSRAM
-
-Function104a95: ; 104a95 (41:4a95)
- di
- callba ClearChannels
- call Function104d5e
-.asm_104a9f
- call Function104d96
- call Function104ddd
- ld a, [hPrintNum10]
- cp $10
- jp z, Function104bd0
- cp $6c
- jr nz, .asm_104a9f
- ld a, [hPrintNum9]
- cp $2
- jr z, Function104b22
- ld hl, $ffb3
- ld b, $1
- call Function104d56
- jr nz, .asm_104ac8
- call Function104b49
- jp nz, Function104bd0
- jr asm_104b0a
-.asm_104ac8
- ld a, [rLY]
- cp $90
- jr c, .asm_104ac8
- ld c, rRP % $100
- ld a, $c0
- ld [$ff00+c], a
- ld b, $f0
-.asm_104ad5
- push bc
- call Function105038
- ld b, $2
- ld c, rRP % $100
-.asm_104add
- ld a, [$ff00+c]
- and b
- ld b, a
- ld a, [rLY]
- cp $90
- jr nc, .asm_104add
-.asm_104ae6
- ld a, [$ff00+c]
- and b
- ld b, a
- ld a, [rLY]
- cp $90
- jr c, .asm_104ae6
- ld a, b
- pop bc
- dec b
- jr z, .asm_104a9f
- or a
- jr nz, .asm_104a9f
- ld a, [hMoneyTemp + 1]
- bit 1, a
- jr z, .asm_104ad5
- ld a, $10
- ld [hPrintNum10], a
- jp Function104bd0
-
-Function104b04: ; 104b04 (41:4b04)
- call Function104b40
- jp nz, Function104bd0
-
-asm_104b0a: ; 104b0a (41:4b0a)
- call Function104d38
- jp nz, Function104bd0
- call Function104b88
- jp nz, Function104bd0
- call Function104d43
- jp nz, Function104bd0
- call Function105033
- jp Function104bd0
-
-Function104b22: ; 104b22 (41:4b22)
- call Function104b88
- jp nz, Function104bd0
- call Function104d43
- jp nz, Function104bd0
- call Function104b40
- jp nz, Function104bd0
- call Function104d38
- jp nz, Function104bd0
- call Function10502e
- jp Function104bd0
-
-Function104b40: ; 104b40 (41:4b40)
- ld hl, $ffb3
- ld b, $1
- call Function104d56
- ret nz
-
-Function104b49: ; 104b49 (41:4b49)
- call Function105033
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- ld a, [$ffb3]
- cp $96
- jp nz, Function104d32
- ld a, $90
- ld [$ffb3], a
- call Function104d38
- ret nz
- ld hl, $ffb3
- ld b, $1
- call Function104d4e
- ret nz
- call Function10502e
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- call Function104d43
- ret nz
- ld hl, wc850
- ld a, [wca02]
- ld b, a
- call Function104d56
- ret nz
- call Function105033
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104b88: ; 104b88 (41:4b88)
- ld a, $96
- ld [$ffb3], a
- ld hl, $ffb3
- ld b, $1
- call Function104d4e
- ret nz
- call Function10502e
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- call Function104d43
- ret nz
- ld hl, $ffb3
- ld b, $1
- call Function104d56
- ret nz
- call Function105033
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- ld a, [$ffb3]
- cp $90
- jp nz, Function104d32
- call Function104d38
- ret nz
- ld hl, OverworldMap
- ld a, [wca02]
- ld b, a
- call Function104d4e
- ret nz
- call Function10502e
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104bd0: ; 104bd0 (41:4bd0)
- nop
- ld a, [hPrintNum10]
- cp $10
- jr z, .asm_104c18
- cp $6c
- jr nz, .asm_104c18
- ld hl, wca01
- dec [hl]
- jr z, .asm_104c18
- ld hl, wc850
- ld de, wc900
- ld bc, $14
- call CopyBytes
- ld a, [wc850]
- cp $3
- jr nc, .asm_104c18
- callba Function10510b
- call Function1050fb
- ld a, $26
- ld [wca02], a
- ld a, [hPrintNum9]
- cp $2
- jr z, .asm_104c10
- call Function104d43
- jr nz, Function104bd0
- jp Function104b04
-.asm_104c10
- call Function104d38
- jr nz, Function104bd0
- jp Function104b22
-.asm_104c18
- ld a, [hPrintNum10]
- push af
- call Function104da0
- xor a
- ld [rIF], a
- ld a, [rIE]
- or $1
- ld [rIE], a
- ei
- call DelayFrame
- pop af
- ret
-
-Function104c2d: ; 104c2d (41:4c2d)
- di
- callba ClearChannels
- call Function104d5e
-.asm_104c37
- call Function104d96
- call Function104ddd
- ld a, [hPrintNum10]
- cp $10
- jp z, Function104d1c
- cp $6c
- jr nz, .asm_104c37
- ld a, [hPrintNum9]
- cp $2
- jr z, .asm_104c6c
- call Function104c8a
- jp nz, Function104d1c
- call Function104d38
- jp nz, Function104d1c
- call Function104cd2
- jp nz, Function104d1c
- call Function104d43
- jp nz, Function104d1c
- call Function105033
- jp Function104d1c
-.asm_104c6c
- call Function104cd2
- jp nz, Function104d1c
- call Function104d43
- jp nz, Function104d1c
- call Function104c8a
- jp nz, Function104d1c
- call Function104d38
- jp nz, Function104d1c
- call Function10502e
- jp Function104d1c
-
-Function104c8a: ; 104c8a (41:4c8a)
- ld hl, $ffb3
- ld b, $1
- call Function104d56
- ret nz
- call Function105033
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- ld a, [$ffb3]
- cp $3c
- jp nz, Function104d32
- swap a
- ld [$ffb3], a
- call Function104d38
- ret nz
- ld hl, $ffb3
- ld b, $1
- call Function104d4e
- ret nz
- call Function10502e
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- call Function104d43
- ret nz
- ld hl, wc850
- ld a, [wca02]
- ld b, a
- call Function104d56
- ret nz
- call Function105033
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104cd2: ; 104cd2 (41:4cd2)
- ld a, $3c
- ld [$ffb3], a
- ld hl, $ffb3
- ld b, $1
- call Function104d4e
- ret nz
- call Function10502e
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- call Function104d43
- ret nz
- ld hl, $ffb3
- ld b, $1
- call Function104d56
- ret nz
- call Function105033
- ld a, [hPrintNum10]
- cp $6c
- ret nz
- ld a, [$ffb3]
- swap a
- cp $3c
- jp nz, Function104d32
- call Function104d38
- ret nz
- ld hl, OverworldMap
- ld a, [wca02]
- ld b, a
- call Function104d4e
- ret nz
- call Function10502e
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104d1c: ; 104d1c (41:4d1c)
- nop
- ld a, [hPrintNum10]
- push af
- call Function104da0
- xor a
- ld [rIF], a
- ld a, [rIE]
- or $1
- ld [rIE], a
- ei
- call DelayFrame
- pop af
- ret
-
-Function104d32: ; 104d32 (41:4d32)
- ld a, $80
- ld [hPrintNum10], a
- and a
- ret
-
-Function104d38: ; 104d38 (41:4d38)
- call Function104d96
- call Function104e46
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104d43: ; 104d43 (41:4d43)
- call Function104d96
- call Function104dfe
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104d4e: ; 104d4e (41:4d4e)
- call Function104e93
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104d56: ; 104d56 (41:4d56)
- call Function104f57
- ld a, [hPrintNum10]
- cp $6c
- ret
-
-Function104d5e: ; 104d5e (41:4d5e)
- call Function104d74
- ld a, $4
- ld [rIE], a
- xor a
- ld [rIF], a
- call Function104d96
- xor a
- ld b, a
-.asm_104d6d
- inc a
- jr nz, .asm_104d6d
- inc b
- jr nz, .asm_104d6d
- ret
-
-Function104d74: ; 104d74 (41:4d74)
- xor a
- ld [rTAC], a
- ld a, $fe
- ld [rTMA], a
- ld [rTIMA], a
- ld a, $2
- ld [rTAC], a
- or $4
- ld [rTAC], a
- ret
-
-Function104d86: ; 104d86 (41:4d86)
- xor a
- ld [rTAC], a
- ld [rTMA], a
- ld [rTIMA], a
- ld a, $2
- ld [rTAC], a
- or $4
- ld [rTAC], a
- ret
-
-Function104d96: ; 104d96 (41:4d96)
- ld a, $c0
- call Function104e8c
- ld a, $1
- ld [hPrintNum9], a
- ret
-
-Function104da0: ; 104da0 (41:4da0)
- xor a
- call Function104e8c
- ld a, $2
- ld [rTAC], a
- ret
-
-Function104da9: ; 104da9 (41:4da9)
- inc d
- ret z
- xor a
- ld [rIF], a
- halt
- ld a, [$ff00+c]
- bit 1, a
- jr z, Function104da9
- or a
- ret
-
-Function104db7: ; 104db7 (41:4db7)
- inc d
- ret z
- xor a
- ld [rIF], a
- halt
- ld a, [$ff00+c]
- bit 1, a
- jr nz, Function104db7
- or a
- ret
-
-Function104dc5: ; 104dc5 (41:4dc5)
- ld a, $c1
- ld [$ff00+c], a
-.asm_104dc8
- dec d
- ret z
- xor a
- ld [rIF], a
- halt
- jr .asm_104dc8
-
-Function104dd1: ; 104dd1 (41:4dd1)
- ld a, $c0
- ld [$ff00+c], a
-.asm_104dd4
- dec d
- ret z
- xor a
- ld [rIF], a
- halt
- jr .asm_104dd4
-
-Function104ddd: ; 104ddd (41:4ddd)
- ld d, $0
- ld e, d
- ld a, $1
- ld [hPrintNum9], a
-.asm_104de4
- call Function105038
- ld b, $2
- ld c, rRP % $100
- ld a, [hMoneyTemp + 1]
- bit 1, a
- jr z, .asm_104df6
- ld a, $10
- ld [hPrintNum10], a
- ret
-.asm_104df6
- bit 0, a
- jr nz, asm_104e3a
- ld a, [$ff00+c]
- and b
- jr nz, .asm_104de4
-
-Function104dfe: ; 104dfe (41:4dfe)
- ld c, rRP % $100
- ld d, $0
- ld e, d
- call Function104db7
- jp z, Function104f42
- ld d, e
- call Function104da9
- jp z, Function104f42
- call Function104db7
- jp z, Function104f42
- call Function104da9
- jp z, Function104f42
- ld a, $6c
- ld [hPrintNum10], a
- ld d, $3d
- call Function104dd1
- ld d, $5
- call Function104dc5
- ld d, $15
- call Function104dd1
- ld d, $5
- call Function104dc5
- ld d, $5
- call Function104dd1
- ret
-
-asm_104e3a: ; 104e3a (41:4e3a)
- call Random
- ld e, a
- and $f
- ld d, a
-.asm_104e41
- dec de
- ld a, d
- or e
- jr nz, .asm_104e41
-
-Function104e46: ; 104e46 (41:4e46)
- ld a, $2
- ld [hPrintNum9], a
- ld c, $56
- ld d, $0
- ld e, d
- ld d, $3d
- call Function104dd1
- ld d, $5
- call Function104dc5
- ld d, $15
- call Function104dd1
- ld d, $5
- call Function104dc5
- ld d, $5
- call Function104dd1
- ld d, e
- call Function104db7
- jp z, Function104f42
- ld d, e
- call Function104da9
- jp z, Function104f42
- call Function104db7
- jp z, Function104f42
- call Function104da9
- jp z, Function104f42
- ld d, $3d
- call Function104dd1
- ld a, $6c
- ld [hPrintNum10], a
- ret
-
-Function104e8c: ; 104e8c (41:4e8c)
- ld [rRP], a
- ld a, $ff
- ld [hPrintNum10], a
- ret
-
-Function104e93: ; 104e93 (41:4e93)
- xor a
- ld [hDivisor], a
- ld [hMathBuffer], a
- push hl
- push bc
- ld c, $56
- ld d, $3d
- call Function104dd1
- ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
- ld a, $5a
- ld [hli], a
- ld [hl], b
- dec hl
- ld b, $2
- call Function104ed6
- pop bc
- pop hl
- call Function104ed6
- ld a, [hDivisor]
- ld [hQuotient], a
- ld a, [hMathBuffer]
- ld [$ffb5], a
- push hl
- ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
- ld b, $2
- call Function104ed6
- ld hl, hPrintNum10
- ld b, $1
- call Function104faf
- ld a, [hQuotient]
- ld [hDivisor], a
- ld a, [$ffb5]
- ld [hMathBuffer], a
- pop hl
- ret
-
-Function104ed6: ; 104ed6 (41:4ed6)
- ld c, $56
- ld d, $5
- call Function104dd1
- ld d, $5
- call Function104dc5
- ld d, $15
- call Function104dd1
- ld a, b
- cpl
- ld b, a
- ld a, $f4
- ld [rTMA], a
-.asm_104eee
- inc b
- jr z, .asm_104f2e
- ld a, $8
- ld [$ffb6], a
- ld a, [hli]
- ld e, a
- ld a, [hDivisor]
- add e
- ld [hDivisor], a
- ld a, [hMathBuffer]
- adc $0
- ld [hMathBuffer], a
-.asm_104f02
- xor a
- ld [rIF], a
- halt
- ld a, $c1
- ld [rRP], a
- ld d, $1
- ld a, e
- rlca
- ld e, a
- jr nc, .asm_104f13
- inc d
-.asm_104f13
- ld a, [rTIMA]
- cp $f8
- jr c, .asm_104f13
- ld a, $c0
- ld [rRP], a
- dec d
- jr z, .asm_104f25
- xor a
- ld [rIF], a
- halt
-.asm_104f25
- ld a, [$ffb6]
- dec a
- jr z, .asm_104eee
- ld [$ffb6], a
- jr .asm_104f02
-.asm_104f2e
- ld a, $fe
- ld [rTMA], a
- xor a
- ld [rIF], a
- halt
- ld d, $5
- call Function104dc5
- ld d, $11
- call Function104dd1
- ret
-
-Function104f42: ; 104f42 (41:4f42)
- ld a, [hPrintNum10]
- or $2
- ld [hPrintNum10], a
- ret
-
-Function104f49: ; 104f49 (41:4f49)
- ld a, [hPrintNum10]
- or $1
- ld [hPrintNum10], a
- ret
-
-Function104f50: ; 104f50 (41:4f50)
- ld a, [hPrintNum10]
- or $80
- ld [hPrintNum10], a
- ret
-
-Function104f57: ; 104f57 (41:4f57)
- xor a
- ld [hDivisor], a
- ld [hMathBuffer], a
- push bc
- push hl
- ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
- ld b, $2
- call Function104faf
- ld a, [$ffb5]
- ld [$ffba], a
- ld b, a
- pop hl
- pop af
- cp b
- jp c, Function104f50
- ld a, [hQuotient]
- cp $5a
- jp nz, Function104f50
- call Function104faf
- ld a, [hDivisor]
- ld d, a
- ld a, [hMathBuffer]
- ld e, a
- push hl
- push de
- ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
- ld b, $2
- call Function104faf
- pop de
- ld hl, hQuotient ; $ffb4 (aliases: hMultiplicand)
- ld a, [hli]
- xor d
- ld b, a
- ld a, [hl]
- xor e
- or b
- call nz, Function104f49
- push de
- ld d, $3d
- call Function104dd1
- ld hl, hPrintNum10
- ld b, $1
- call Function104ed6
- pop de
- pop hl
- ld a, d
- ld [hDivisor], a
- ld a, e
- ld [hMathBuffer], a
- ret
-
-Function104faf: ; 104faf (41:4faf)
- ld c, rRP % $100
- ld d, $0
- call Function104db7
- jp z, Function104f42
- ld d, $0
- call Function104da9
- jp z, Function104f42
- ld d, $0
- call Function104db7
- jp z, Function104f42
- ld a, b
- cpl
- ld b, a
- xor a
- ld [hMoneyTemp + 2], a
- call Function104d86
-.asm_104fd2
- inc b
- jr z, .asm_10501a
- ld a, $8
- ld [$ffb6], a
-.asm_104fd9
- ld d, $0
-.asm_104fdb
- inc d
- jr z, .asm_104fe5
- ld a, [$ff00+c]
- bit 1, a
- jr z, .asm_104fdb
- ld d, $0
-.asm_104fe5
- inc d
- jr z, .asm_104fed
- ld a, [$ff00+c]
- bit 1, a
- jr nz, .asm_104fe5
-.asm_104fed
- ld a, [hMoneyTemp + 2]
- ld d, a
- ld a, [rTIMA]
- ld [hMoneyTemp + 2], a
- sub d
- cp $12
- jr c, .asm_104ffd
- set 0, e
- jr .asm_104fff
-.asm_104ffd
- res 0, e
-.asm_104fff
- ld a, [$ffb6]
- dec a
- ld [$ffb6], a
- jr z, .asm_10500b
- ld a, e
- rlca
- ld e, a
- jr .asm_104fd9
-.asm_10500b
- ld a, e
- ld [hli], a
- ld a, [hDivisor]
- add e
- ld [hDivisor], a
- ld a, [hMathBuffer]
- adc $0
- ld [hMathBuffer], a
- jr .asm_104fd2
-.asm_10501a
- call Function104d74
- xor a
- ld [rIF], a
- ld d, $0
- call Function104da9
- jp z, Function104f42
- ld d, $10
- call Function104dd1
- ret
-
-Function10502e: ; 10502e (41:502e)
- ld b, $0
- jp Function104e93
-
-Function105033: ; 105033 (41:5033)
- ld b, $0
- jp Function104f57
-
-Function105038: ; 105038 (41:5038)
- ld a, $20
- ld [rJOYP], a
-rept 2
- ld a, [rJOYP]
-endr
- cpl
- and $f
- swap a
- ld b, a
- ld a, $10
- ld [rJOYP], a
-rept 6
- ld a, [rJOYP]
-endr
- cpl
- and $f
- or b
- ld c, a
- ld a, [hMoneyTemp]
- xor c
- and c
- ld [hMoneyTemp + 1], a
- ld a, c
- ld [hMoneyTemp], a
- ld a, $30
- ld [rJOYP], a
- ret
-
-Function105069: ; 105069 (41:5069)
- call GetMysteryGiftBank
- ld d, $0
- ld b, $2
- ld hl, sMysteryGiftDecorationsReceived
- predef_id FlagPredef
- push hl
- push bc
- call Predef
- call CloseSRAM
- ld a, c
- and a
- pop bc
- pop hl
- ret nz
- call GetMysteryGiftBank
- ld b, $1
- predef FlagPredef
- call CloseSRAM
- xor a
- ret
-
-Function105091: ; 105091 (41:5091)
- call GetMysteryGiftBank
- ld c, $0
-.loop
- push bc
- ld d, $0
- ld b, CHECK_FLAG
- ld hl, sMysteryGiftDecorationsReceived
- predef FlagPredef
- ld a, c
- and a
- pop bc
- jr z, .skip
- push bc
- callab SetSpecificDecorationFlag
- pop bc
-.skip
- inc c
- ld a, c
- cp Trophys - DecorationIDs
- jr c, .loop
- jp CloseSRAM
-
-Special_UnlockMysteryGift: ; 1050b9
- call GetMysteryGiftBank
- ld hl, sMysteryGiftUnlocked
- ld a, [hl]
- inc a
- jr nz, .ok
- ld [hld], a
- ld [hl], a
-.ok
- jp CloseSRAM
-; 1050c8
-
-Function1050c8: ; 1050c8
- call GetMysteryGiftBank
- ld a, [s0_abe5]
- cp $ff
- jr z, .okay
- xor a
- ld [s0_abe5], a
-.okay
- jp CloseSRAM
-; 1050d9
-
-
-BackupMysteryGift: ; 1050d9
- call GetMysteryGiftBank
- ld hl, sMysteryGiftItem
- ld de, sBackupMysteryGiftItem
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- jp CloseSRAM
-; 1050ea
-
-
-RestoreMysteryGift: ; 1050ea (41:50ea)
- call GetMysteryGiftBank
- ld hl, sBackupMysteryGiftItem
- ld de, sMysteryGiftItem
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- jp CloseSRAM
-
-Function1050fb: ; 1050fb (41:50fb)
- ld hl, wc850
- xor a
- ld b, $26
-.asm_105101
- ld [hli], a
- dec b
- jr nz, .asm_105101
- ret
-
-
-GetMysteryGiftBank: ; 105106
- ld a, BANK(sBackupMysteryGiftItem)
- jp GetSRAMBank
-; 10510b
-
-
-Function10510b: ; 10510b (41:510b)
- ld a, BANK(sPokemonData)
- call GetSRAMBank
- ld de, OverworldMap
- ld bc, sPokemonData + PartyMons - wPokemonData
- ld hl, sPokemonData + PartySpecies - wPokemonData
-.asm_105119
- ld a, [hli]
- cp $ff
- jr z, .asm_105148
- cp EGG
- jr z, .asm_10513e
- push hl
- ld hl, MON_LEVEL
- add hl, bc
- ld a, [hl]
- ld [de], a
- inc de
- ld hl, MON_SPECIES
- add hl, bc
- ld a, [hl]
- ld [de], a
- inc de
- ld hl, MON_MOVES
- add hl, bc
- push bc
- ld bc, NUM_MOVES
- call CopyBytes
- pop bc
- pop hl
-.asm_10513e
- push hl
- ld hl, PARTYMON_STRUCT_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- pop hl
- jr .asm_105119
-.asm_105148
- ld a, $ff
- ld [de], a
- ld a, $26
- ld [wca00], a
- jp CloseSRAM
-
-Function105153: ; 105153 (41:5153)
- call ClearBGPalettes
- call DisableLCD
- ld hl, MysteryGiftGFX
- ld de, VTiles2 tile $00
- ld a, BANK(MysteryGiftGFX)
- ld bc, Function105688 - MysteryGiftGFX
- call FarCopyBytes
- hlcoord 0, 0
- ld a, $42
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- call ByteFill
- hlcoord 3, 7
- lb bc, 9, 15
- call ClearBox
- hlcoord 0, 0
- ld a, $0
- ld [hli], a
- inc a
- ld [hl], a
- hlcoord 0, 1
- inc a
- ld [hli], a
- inc a
- ld [hl], a
- hlcoord 7, 1
- ld a, $12
- call Function10522e
- hlcoord 2, 2
- ld a, $17
- call Function105236
- hlcoord 2, 3
- ld a, $27
- call Function105236
- hlcoord 9, 4
- ld a, $37
- ld [hli], a
- inc a
- ld [hl], a
- hlcoord 1, 2
- ld [hl], $4
- hlcoord 1, 3
- ld a, $5
- call Function105246
- ld a, $9
- hlcoord 18, 5
- call Function105242
- hlcoord 2, 5
- ld a, $b
- call Function105251
- hlcoord 2, 16
- ld a, $7
- call Function105251
- hlcoord 2, 5
- ld a, $d
- call Function10522e
- hlcoord 7, 5
- ld [hl], $c
- hlcoord 18, 5
- ld [hl], $a
- hlcoord 18, 16
- ld [hl], $8
- hlcoord 1, 16
- ld [hl], $6
- hlcoord 2, 6
- ld a, $3a
- call Function105251
- hlcoord 2, 15
- ld a, $40
- call Function105251
- hlcoord 2, 6
- ld a, $3c
- call Function10523e
- hlcoord 17, 6
- ld a, $3e
- call Function10523e
- hlcoord 2, 6
- ld [hl], $39
- hlcoord 17, 6
- ld [hl], $3b
- hlcoord 2, 15
- ld [hl], $3f
- hlcoord 17, 15
- ld [hl], $41
- call EnableLCD
- call WaitBGMap
- ld b, SCGB_1D
- call GetSGBLayout
- call SetPalettes
- ret
-
-Function10522e: ; 10522e (41:522e)
- ld b, $5
- jr asm_105238
-; 105232 (41:5232)
-
-Function105232: ; unreferenced
- ld b, 6
- jr asm_105238
-
-Function105236: ; 105236 (41:5236)
- ld b, $10
-
-asm_105238: ; 105238 (41:5238)
- ld [hli], a
- inc a
- dec b
- jr nz, asm_105238
- ret
-
-Function10523e: ; 10523e (41:523e)
- ld b, $9
- jr asm_105248
-
-Function105242: ; 105242 (41:5242)
- ld b, $b
- jr asm_105248
-
-Function105246: ; 105246 (41:5246)
- ld b, $e
-
-asm_105248: ; 105248 (41:5248)
- ld [hl], a
- ld de, $14
- add hl, de
- dec b
- jr nz, asm_105248
- ret
-
-Function105251: ; 105251 (41:5251)
- ld b, $10
-.asm_105253
- ld [hli], a
- dec b
- jr nz, .asm_105253
- ret
-
-MysteryGiftGFX: ; 105258
-INCBIN "gfx/misc/mystery_gift.2bpp"
-
-
-Function105688: ; 105688 (41:5688)
- call ClearTileMap
- call ClearSprites
- call WaitBGMap
- call Function1057d7
- hlcoord 3, 8
- ld de, String_10572e
- call PlaceString
- call WaitBGMap
- call Function10578c
- call Function1050fb
- ld a, $24
- ld [wca02], a
- ld a, [rIE]
- push af
- call Function104c2d
- ld d, a
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- ld a, d
- cp $10
- jp z, Function105712
- cp $6c
- jp nz, Function10571a
- call Function1056eb
- ld c, 60
- call DelayFrames
- call Function105777
- ld hl, Text_10575e
- call PrintText
- ld de, wc850
- callba Function8ac70
- ld a, c
- ld [wd265], a
- ld hl, Text_105768
- jr c, asm_105726
- ld hl, Text_105763
- jr asm_105726
-
-Function1056eb: ; 1056eb (41:56eb)
- ld c, $10
-.asm_1056ed
- ld hl, Sprites
- ld b, $8
-.asm_1056f2
- dec [hl]
-rept 4
- inc hl
-endr
- dec b
- jr nz, .asm_1056f2
- ld hl, Sprites + $20
- ld b, $8
-.asm_1056ff
- inc [hl]
-rept 4
- inc hl
-endr
- dec b
- jr nz, .asm_1056ff
- dec c
- ret z
- push bc
- ld c, 4
- call DelayFrames
- pop bc
- jr .asm_1056ed
-
-Function105712: ; 105712 (41:5712)
- call Function105777
- ld hl, Text_10576d
- jr asm_105726
-
-Function10571a: ; 10571a (41:571a)
- call Function105777
- ld hl, Text_105772
- call PrintText
- jp Function105688
-
-asm_105726: ; 105726 (41:5726)
- call PrintText
- ld a, $e3
- ld [rLCDC], a
- ret
-; 10572e (41:572e)
-
-String_10572e: ; 10572e
- db "エーボタン¯おすと"
- next "つうしん", $4a, "おこなわれるよ!"
- next "ビーボタン¯おすと"
- next "つうしん¯ちゅうし します"
- db "@"
-
-; 10575e
-
-Text_10575e: ; 10575e
- text_jump UnknownText_0x1c051a
- db "@"
-
-Text_105763: ; 105763
- text_jump UnknownText_0x1c0531
- db "@"
-
-Text_105768: ; 105768
- text_jump UnknownText_0x1c0555
- db "@"
-
-Text_10576d: ; 10576d
- text_jump UnknownText_0x1c0573
- db "@"
-
-Text_105772: ; 105772
- text_jump UnknownText_0x1c0591
- db "@"
-; 105777
-
-Function105777: ; 105777 (41:5777)
- call ClearSprites
- call ClearTileMap
- call EnableLCD
- call WaitBGMap
- ld b, SCGB_08
- call GetSGBLayout
- call SetPalettes
- ret
-
-Function10578c: ; 10578c (41:578c)
- ld de, OverworldMap
- ld a, BANK(sPlayerData)
- call GetSRAMBank
- ld hl, sPlayerData + PlayerName - wPlayerData
- ld bc, NAME_LENGTH
- call CopyBytes
- ld hl, sPlayerData + PlayerID - wPlayerData
- ld bc, 2
- call CopyBytes
- ld hl, sPlayerData + wSecretID - wPlayerData
- ld bc, 2
- call CopyBytes
- call CloseSRAM
- ld a, BANK(sCrystalData)
- call GetSRAMBank
- ld a, [sCrystalData + 0]
- ld [de], a
- inc de
- ld a, $4
- call GetSRAMBank
- ld hl, $a603
- ld bc, $8
- call CopyBytes
- ld hl, $a007
- ld bc, $c
- call CopyBytes
- call CloseSRAM
- ret
-
-Function1057d7: ; 1057d7 (41:57d7)
- call ClearBGPalettes
- call DisableLCD
- ld hl, MysteryGiftJP_GFX
- ld de, VTiles2 tile $00
- ld a, BANK(MysteryGiftJP_GFX)
- lb bc, 4, 0
- call FarCopyBytes
- ld hl, MysteryGiftJP_GFX + $400
- ld de, VTiles0 tile $00
- ld a, BANK(MysteryGiftJP_GFX)
- ld bc, $80
- call FarCopyBytes
- hlcoord 0, 0
- ld a, $3f
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- call ByteFill
- hlcoord 3, 7
- lb bc, 9, 15
- call ClearBox
- hlcoord 0, 0
- ld a, $0
- ld [hli], a
- inc a
- ld [hl], a
- hlcoord 0, 1
- inc a
- ld [hli], a
- inc a
- ld [hl], a
- hlcoord 4, 2
- ld a, $13
- call Function1058ca
- hlcoord 4, 3
- ld a, $1e
- call Function1058ce
- hlcoord 4, 4
- ld a, $2a
- call Function1058ce
- hlcoord 1, 2
- ld [hl], $4
- hlcoord 1, 3
- ld a, $5
- call Function1058de
- ld a, $9
- hlcoord 18, 5
- call Function1058da
- hlcoord 2, 5
- ld a, $b
- call Function1058e9
- hlcoord 2, 16
- ld a, $7
- call Function1058e9
- hlcoord 2, 5
- ld a, $d
- call Function1058c6
- hlcoord 8, 5
- ld [hl], $c
- hlcoord 18, 5
- ld [hl], $a
- hlcoord 18, 16
- ld [hl], $8
- hlcoord 1, 16
- ld [hl], $6
- hlcoord 2, 6
- ld a, $37
- call Function1058e9
- hlcoord 2, 15
- ld a, $3d
- call Function1058e9
- hlcoord 2, 6
- ld a, $39
- call Function1058d6
- hlcoord 17, 6
- ld a, $3b
- call Function1058d6
- hlcoord 2, 6
- ld [hl], $36
- hlcoord 17, 6
- ld [hl], $38
- hlcoord 2, 15
- ld [hl], $3c
- hlcoord 17, 15
- ld [hl], $3e
- ld de, Sprites
- ld hl, OAM_1058f0
- ld bc, $40
- call CopyBytes
- call EnableLCD
- call WaitBGMap
- ld b, $2
- callba Function4930f
- jp SetPalettes
-
-Function1058c6: ; 1058c6 (41:58c6)
- ld b, $6
- jr asm_1058d0
-
-Function1058ca: ; 1058ca (41:58ca)
- ld b, $b
- jr asm_1058d0
-
-Function1058ce: ; 1058ce (41:58ce)
- ld b, $c
-
-asm_1058d0: ; 1058d0 (41:58d0)
- ld [hli], a
- inc a
- dec b
- jr nz, asm_1058d0
- ret
-
-Function1058d6: ; 1058d6 (41:58d6)
- ld b, $9
- jr asm_1058e0
-
-Function1058da: ; 1058da (41:58da)
- ld b, $b
- jr asm_1058e0
-
-Function1058de: ; 1058de (41:58de)
- ld b, $e
-
-asm_1058e0: ; 1058e0 (41:58e0)
- ld [hl], a
- ld de, $14
- add hl, de
- dec b
- jr nz, asm_1058e0
- ret
-
-Function1058e9: ; 1058e9 (41:58e9)
- ld b, $10
-.asm_1058eb
- ld [hli], a
- dec b
- jr nz, .asm_1058eb
- ret
-; 1058f0 (41:58f0)
-
-OAM_1058f0: ; 1058f0
- db $11, $34, $00, $00
- db $11, $3c, $01, $00
- db $11, $44, $02, $00
- db $11, $4c, $03, $00
- db $19, $34, $04, $00
- db $19, $3c, $05, $00
- db $19, $44, $06, $00
- db $19, $4c, $07, $00
- db $01, $5c, $00, $00
- db $01, $64, $01, $00
- db $01, $6c, $02, $00
- db $01, $74, $03, $00
- db $09, $5c, $04, $00
- db $09, $64, $05, $00
- db $09, $6c, $06, $00
- db $09, $74, $07, $00
-
-; japanese mystery gift gfx
-MysteryGiftJP_GFX: ; 105930
-INCBIN "gfx/misc/mystery_gift_jp.2bpp"
-
-
-DisplayUsedMoveText: ; 105db0
-; battle command 03
- ld hl, UsedMoveText
- call BattleTextBox
- jp WaitBGMap
-; 105db9
-
-
-UsedMoveText: ; 105db9
-; this is a stream of text and asm from 105db9 to 105ef6
-
- text_jump _ActorNameText
- start_asm
-
- ld a, [hBattleTurn]
- and a
- jr nz, .start
-
- ld a, [wPlayerMoveStruct + MOVE_ANIM]
- call UpdateUsedMoves
-
-.start
- ld a, BATTLE_VARS_LAST_MOVE
- call GetBattleVarAddr
- ld d, h
- ld e, l
-
- ld a, BATTLE_VARS_LAST_COUNTER_MOVE
- call GetBattleVarAddr
-
- ld a, BATTLE_VARS_MOVE_ANIM
- call GetBattleVar
- ld [wd265], a
-
- push hl
- callba CheckUserIsCharging
- pop hl
- jr nz, .grammar
-
- ; update last move
- ld a, [wd265]
- ld [hl], a
- ld [de], a
-
-.grammar
- call GetMoveGrammar
-; wd265 now contains MoveGrammar
-
-
-; everything except 'instead' made redundant in localization
-
- ; check obedience
- ld a, [AlreadyDisobeyed]
- and a
- ld hl, UsedMove2Text
- ret nz
-
- ; check move grammar
- ld a, [wd265]
- cp $3
- ld hl, UsedMove2Text
- ret c
- ld hl, UsedMove1Text
- ret
-; 105e04
-
-UsedMove1Text: ; 105e04
- text_jump _UsedMove1Text
- start_asm
- jr Function105e10
-; 105e0b
-
-UsedMove2Text: ; 105e0b
- text_jump _UsedMove2Text
- start_asm
-; 105e10
-
-Function105e10: ; 105e10
-; check obedience
- ld a, [AlreadyDisobeyed]
- and a
- jr z, GetMoveNameText
-; print "instead,"
- ld hl, UsedInsteadText
- ret
-; 105e1a
-
-UsedInsteadText: ; 105e1a
- text_jump _UsedInsteadText
- start_asm
-; 105e1f
-
-GetMoveNameText: ; 105e1f
- ld hl, MoveNameText
- ret
-; 105e23
-
-MoveNameText: ; 105e23
- text_jump _MoveNameText
- start_asm
-; 105e28
-
-GetUsedMoveTextEnder: ; 105e28
-; get start address
- ld hl, .endusedmovetexts
-
-; get move id
- ld a, [wd265]
-
-; 2-byte pointer
- add a
-
-; seek
- push bc
- ld b, $0
- ld c, a
- add hl, bc
- pop bc
-
-; get pointer to usedmovetext ender
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ret
-; 105e39
-
-.endusedmovetexts ; 105e39
- dw EndUsedMove1Text
- dw EndUsedMove2Text
- dw EndUsedMove3Text
- dw EndUsedMove4Text
- dw EndUsedMove5Text
-; 105e43
-
-EndUsedMove1Text: ; 105e43
- text_jump _EndUsedMove1Text
- db "@"
-; 105e48
-EndUsedMove2Text: ; 105e48
- text_jump _EndUsedMove2Text
- db "@"
-; 105e4d
-EndUsedMove3Text: ; 105e4d
- text_jump _EndUsedMove3Text
- db "@"
-; 105e52
-EndUsedMove4Text: ; 105e52
- text_jump _EndUsedMove4Text
- db "@"
-; 105e57
-EndUsedMove5Text: ; 105e57
- text_jump _EndUsedMove5Text
- db "@"
-; 105e5c
-
-
-GetMoveGrammar: ; 105e5c
-; store move grammar type in wd265
-
- push bc
-; c = move id
- ld a, [wd265]
- ld c, a
- ld b, $0
-
-; read grammar table
- ld hl, MoveGrammar
-.loop
- ld a, [hli]
-; end of table?
- cp $ff
- jr z, .end
-; match?
- cp c
- jr z, .end
-; advance grammar type at $00
- and a
- jr nz, .loop
-; next grammar type
- inc b
- jr .loop
-
-.end
-; wd265 now contains move grammar
- ld a, b
- ld [wd265], a
-
-; we're done
- pop bc
- ret
-; 105e7a
-
-MoveGrammar: ; 105e7a
-; made redundant in localization
-; each move is given an identifier for what usedmovetext to use (0-4):
-
-; 0
- db SWORDS_DANCE
- db GROWTH
- db STRENGTH
- db HARDEN
- db MINIMIZE
- db SMOKESCREEN
- db WITHDRAW
- db DEFENSE_CURL
- db EGG_BOMB
- db SMOG
- db BONE_CLUB
- db FLASH
- db SPLASH
- db ACID_ARMOR
- db BONEMERANG
- db REST
- db SHARPEN
- db SUBSTITUTE
- db MIND_READER
- db SNORE
- db PROTECT
- db SPIKES
- db ENDURE
- db ROLLOUT
- db SWAGGER
- db SLEEP_TALK
- db HIDDEN_POWER
- db PSYCH_UP
- db EXTREMESPEED
- db 0 ; end set
-
-; 1
- db RECOVER
- db TELEPORT
- db BIDE
- db SELFDESTRUCT
- db AMNESIA
- db FLAIL
- db 0 ; end set
-
-; 2
- db MEDITATE
- db AGILITY
- db MIMIC
- db DOUBLE_TEAM
- db BARRAGE
- db TRANSFORM
- db STRUGGLE
- db SCARY_FACE
- db 0 ; end set
-
-; 3
- db POUND
- db SCRATCH
- db VICEGRIP
- db WING_ATTACK
- db FLY
- db BIND
- db SLAM
- db HORN_ATTACK
- db WRAP
- db THRASH
- db TAIL_WHIP
- db LEER
- db BITE
- db GROWL
- db ROAR
- db SING
- db PECK
- db ABSORB
- db STRING_SHOT
- db EARTHQUAKE
- db FISSURE
- db DIG
- db TOXIC
- db SCREECH
- db METRONOME
- db LICK
- db CLAMP
- db CONSTRICT
- db POISON_GAS
- db BUBBLE
- db SLASH
- db SPIDER_WEB
- db NIGHTMARE
- db CURSE
- db FORESIGHT
- db CHARM
- db ATTRACT
- db ROCK_SMASH
- db 0 ; end set
-
-; all other moves = 4
- db $ff ; end
-; 105ed0
-
-
-UpdateUsedMoves: ; 105ed0
-; append move a to PlayerUsedMoves unless it has already been used
-
- push bc
-; start of list
- ld hl, PlayerUsedMoves
-; get move id
- ld b, a
-; next count
- ld c, NUM_MOVES
-
-.loop
-; get move from the list
- ld a, [hli]
-; not used yet?
- and a
- jr z, .add
-; already used?
- cp b
- jr z, .quit
-; next byte
- dec c
- jr nz, .loop
-
-; if the list is full and the move hasn't already been used
-; shift the list back one byte, deleting the first move used
-; this can occur with struggle or a new learned move
- ld hl, PlayerUsedMoves + 1
-; 1 = 2
- ld a, [hld]
- ld [hli], a
-; 2 = 3
- inc hl
- ld a, [hld]
- ld [hli], a
-; 3 = 4
- inc hl
- ld a, [hld]
- ld [hl], a
-; 4 = new move
- ld a, b
- ld [PlayerUsedMoves + 3], a
- jr .quit
-
-.add
-; go back to the byte we just inced from
- dec hl
-; add the new move
- ld [hl], b
-
-.quit
-; list updated
- pop bc
- ret
-; 105ef6
-
INCLUDE "misc/mobile_41.asm"
INCLUDE "misc/mobile_42.asm"
@@ -26477,7 +24438,7 @@
inc a
ld [hl], a
ld hl, wcb45
- ld a, $7f
+ ld a, " "
ld [hli], a
ld [hl], a
ld hl, wcb59
@@ -26962,7 +24923,7 @@
ld [hl], $50
ld a, $51
hlcoord 11, 1
- ld b, $f
+ ld b, SCREEN_HEIGHT - 3
call Function1de27f
ld [hl], $52
jr .asm_1de1d0
@@ -26971,7 +24932,7 @@
ld [hl], $66
ld a, $67
hlcoord 11, 1
- ld b, $f
+ ld b, SCREEN_HEIGHT - 3
call Function1de27f
ld [hl], $68
.asm_1de1d0
@@ -26994,7 +24955,7 @@
ld [hl], $66
ld a, $67
hlcoord 11, 1
- ld b, $9
+ ld b, SCREEN_HEIGHT / 2
call Function1de27f
ld [hl], $68
ld a, $34
@@ -27009,7 +24970,7 @@
ld [hl], $66
ld a, $67
hlcoord 11, 12
- ld b, $5
+ ld b, 5
call Function1de27f
ld [hl], $68
hlcoord 0, 12
@@ -27023,10 +24984,8 @@
String_1de23c: ; 1de23c
; At a glance, this is less coherent in the Japanese charset.
- db "ESULTS"
- db $4e
- db $4e
- db "D!@"
+ db "ESULTS<NEXT>"
+ next "D!@"
; 1de247
Function1de247: ; 1de247
@@ -27044,13 +25003,13 @@
ld [hl], $66
hlcoord 19, 1
ld a, $67
- ld b, $f
+ ld b, SCREEN_HEIGHT - 3
call Function1de27f
ld [hl], $68
hlcoord 19, 17
ld [hl], $3c
xor a
- ld b, $12
+ ld b, SCREEN_HEIGHT
hlcoord 19, 0, AttrMap
call Function1de27f
call Function3200
@@ -27065,11 +25024,11 @@
Function1de27f: ; 1de27f
push de
ld de, SCREEN_WIDTH
-.asm_1de283
+.loop
ld [hl], a
add hl, de
dec b
- jr nz, .asm_1de283
+ jr nz, .loop
pop de
ret
; 1de28a
@@ -27131,21 +25090,21 @@
Function1de2c5: ; 1de2c5
ld hl, StringBuffer1
-.asm_1de2c8
+.loop
ld a, [hl]
- cp $50
- jr z, .asm_1de2da
- cp $25
- jr z, .asm_1de2d8
- cp $1f
- jr z, .asm_1de2d8
+ cp "@"
+ jr z, .end
+ cp "%"
+ jr z, .line_break
+ cp "¯"
+ jr z, .line_break
inc hl
- jr .asm_1de2c8
+ jr .loop
-.asm_1de2d8
- ld [hl], $22
+.line_break
+ ld [hl], "<LNBRK>"
-.asm_1de2da
+.end
ld de, StringBuffer1
hlcoord 9, 0
call PlaceString
--- a/misc/gbc_only.asm
+++ b/misc/gbc_only.asm
@@ -10,7 +10,7 @@
call ClearTileMap
ld hl, GBCOnlyGFX
- ld de, $d000
+ ld de, wd000
ld a, [rSVBK]
push af
ld a, 0
@@ -19,7 +19,7 @@
pop af
ld [rSVBK], a
- ld de, $d000
+ ld de, wd000
ld hl, VTiles2
lb bc, BANK(GBCOnlyGFX), $54
call Get2bpp
--- a/sram.asm
+++ b/sram.asm
@@ -59,8 +59,8 @@
sMysteryGiftItem:: ds 1
sMysteryGiftUnlocked:: ds 1
sBackupMysteryGiftItem:: ds 1
-s0_abe5:: ds 1
-s0_abe6:: ds 10
+sNumDailyMysteryGiftPartnerIDs:: ds 1
+sDailyMysteryGiftPartnerIDs:: ds 5 * 2 ; maximum 5 per day, 2 bytes per ID
sMysteryGiftDecorationsReceived:: flag_array NUM_NON_TROPHY_DECOS
ds 4
sMysteryGiftTimer:: ds 1
@@ -67,9 +67,9 @@
sMysteryGiftTimerStartDay:: ds 1
ds 1
sMysteryGiftTrainerHouseFlag:: ds 1
-s0_abfe:: ds 12
-sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1
- ds 1
+sMysteryGiftPartnerName:: ds NAME_LENGTH
+s0_ac09:: ds 1
+sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2
sBackupMysteryGiftItemEnd::
ds $30
--- a/text/battle.asm
+++ b/text/battle.asm
@@ -194,7 +194,7 @@
GotMoneyForWinningText:
text "<PLAYER> got ¥@"
- deciram wc686, 3, 6
+ deciram wBattleReward, 3, 6
text ""
line "for winning!"
prompt
@@ -213,7 +213,7 @@
SentSomeToMomText:
text "<PLAYER> got ¥@"
- deciram wc686, 3, 6
+ deciram wBattleReward, 3, 6
text ""
line "for winning!"
cont "Sent some to MOM!"
--- a/text/common_3.asm
+++ b/text/common_3.asm
@@ -279,7 +279,7 @@
; 1c04e9
UnknownText_0x1c04e9: ; 1c04e9
- text_from_ram wc903
+ text_from_ram wMysteryGiftPartnerName
text " sent"
line "@"
text_from_ram StringBuffer1
@@ -288,7 +288,7 @@
; 1c04fa
UnknownText_0x1c04fa: ; 1c04fa
- text_from_ram wc903
+ text_from_ram wMysteryGiftPartnerName
text " sent"
line "@"
text_from_ram StringBuffer1
--- a/wram.asm
+++ b/wram.asm
@@ -152,9 +152,11 @@
\1AuthorNationality:: ds 2
\1AuthorID:: ds 2
\1Species:: ds 1
-\1MailType:: ds 1
+\1Type:: ds 1
+\1End::
endm
+
INCLUDE "vram.asm"
SECTION "Stack", WRAM0
@@ -542,7 +544,8 @@
ds 1
wEnemyTrainerItem1:: ds 1
wEnemyTrainerItem2:: ds 1
-wc652:: ds 4
+wEnemyTrainerBaseReward:: ds 1
+wEnemyTrainerAIFlags:: ds 3
wc656::
OTName:: ds NAME_LENGTH ; c656
@@ -688,8 +691,7 @@
EnemyDamageTaken:: ; c684
ds 2
-wc686:: ds 2
-wc688:: ds 1
+wBattleReward:: ds 3
wKickCounter::
wPresentPower:: ds 1
wc68a::
@@ -719,6 +721,24 @@
ds 1
PlayerSAtkLevel:: ; c6cf
ds 1
+
+trademon: MACRO
+\1Species:: ds 1 ; wc6d0 | wc702
+\1SpeciesName:: ds PKMN_NAME_LENGTH ; wc6d1 | wc703
+\1Nickname:: ds PKMN_NAME_LENGTH ; wc6dc | wc70e
+\1SenderName:: ds NAME_LENGTH ; wc6e7 | wc719
+\1OTName:: ds NAME_LENGTH ; wc6f2 | wc724
+\1DVs:: ds 2 ; wc6fd | wc72f
+\1ID:: ds 2 ; wc6ff | wc731
+\1CaughtData:: ds 1 ; wc701 | wc733
+\1End::
+ENDM
+
+wPlayerTrademon:: trademon wPlayerTrademon
+wOTTrademon:: trademon wOTTrademon
+
+ ds wPlayerTrademon - @
+
wc6d0::
wPokedexDataStart::
PlayerSDefLevel:: ; c6d0
@@ -920,12 +940,19 @@
wPlayerRageCounter:: ds 1
wEnemyRageCounter:: ds 1
wc72d:: ds 1 ; if 0 then PrintButItFailed
+wc72e::
wPlayerTrappingMove:: ds 1
+wc72f::
wEnemyTrappingMove:: ds 1
+wc730::
wPlayerWrapCount:: ds 1
+wc731::
wEnemyWrapCount:: ds 1
+wc732::
wPlayerCharging:: ds 1
-wEnemyCharging:: ds 1
+wEnemyCharging::
+wc733:: ds 1
+wTradeAnimPointer::
wc734::
BattleEnded:: ; c734
ds 1
@@ -935,7 +962,7 @@
wc736:: ds 3
wWildMonPP::
wc739:: ds 4
-wc73d:: ds 1
+wAmuletCoin:: ds 1
wc73e:: ds 1
wPlayerJustGotFrozen:: ds 1
wEnemyJustGotFrozen:: ds 1
@@ -1006,6 +1033,8 @@
wc821:: ds 15
wc830:: ds 16
wc840:: ds 16
+wMysteryGiftTrainerData:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2
+ ds wMysteryGiftTrainerData - @
wc850:: ds 16
wc860:: ds 16
wc870:: ds 16
@@ -1018,9 +1047,9 @@
wc8e0:: ds 16
wc8f0:: ds 16
wc900:: ds 1
-wc901:: ds 1
-wc902:: ds 1
-wc903:: ds 12
+wMysteryGiftPartnerID:: ds 2
+wMysteryGiftPartnerName:: ds NAME_LENGTH
+wc90e:: ds 1
wc90f:: ds 1
wc910:: ds 1
wc911:: ds 1
@@ -2432,7 +2461,7 @@
ds 1
wHallOfFameCount:: ds 2
-wd960:: ds 2
+wTradeFlags:: ds 2
MooMooBerries:: ; d962
ds 1 ; how many berries fed to MooMoo
UndergroundSwitchPositions:: ; d963