pokered/engine/give_pokemon.asm

83 lines
1.3 KiB
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
_GivePokemon: ; 4fda5 (13:7da5)
2015-07-19 03:49:52 +00:00
; returns success in carry
; and whether the mon was added to the party in [wAddedToParty]
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
xor a
2015-07-19 03:49:52 +00:00
ld [wAddedToParty], a
ld a, [wPartyCount]
cp PARTY_LENGTH
2015-07-19 03:49:52 +00:00
jr c, .addToParty
ld a, [W_NUMINBOX]
cp MONS_PER_BOX
2015-07-19 03:49:52 +00:00
jr nc, .boxFull
; add to box
2014-05-22 22:13:20 +00:00
xor a
ld [W_ENEMYBATTSTATUS3], a
ld a, [wcf91]
ld [wEnemyMonSpecies2], a
2014-08-09 05:39:13 +00:00
callab LoadEnemyMonData
2014-05-22 22:13:20 +00:00
call SetPokedexOwnedFlag
2015-02-08 06:18:42 +00:00
callab SendNewMonToBox
ld hl, wcf4b
2015-07-16 03:04:58 +00:00
ld a, [wCurrentBoxNum]
2014-05-22 22:13:20 +00:00
and $7f
cp 9
2015-07-19 03:49:52 +00:00
jr c, .singleDigitBoxNum
sub 9
ld [hl], "1"
2014-05-22 22:13:20 +00:00
inc hl
add "0"
2015-07-19 03:49:52 +00:00
jr .next
.singleDigitBoxNum
add "1"
2015-07-19 03:49:52 +00:00
.next
2014-05-22 22:13:20 +00:00
ld [hli], a
ld [hl], "@"
2014-05-22 22:13:20 +00:00
ld hl, SetToBoxText
call PrintText
scf
ret
2015-07-19 03:49:52 +00:00
.boxFull
2014-05-22 22:13:20 +00:00
ld hl, BoxIsFullText
call PrintText
and a
ret
2015-07-19 03:49:52 +00:00
.addToParty
2014-05-22 22:13:20 +00:00
call SetPokedexOwnedFlag
call AddPartyMon
2015-07-19 03:49:52 +00:00
ld a, 1
2014-09-13 07:50:56 +00:00
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
2015-07-19 03:49:52 +00:00
ld [wAddedToParty], a
2014-05-22 22:13:20 +00:00
scf
ret
SetPokedexOwnedFlag: ; 4fe11 (13:7e11)
ld a, [wcf91]
2014-05-22 22:13:20 +00:00
push af
ld [wd11e], a
predef IndexToPokedex
ld a, [wd11e]
2014-05-22 22:13:20 +00:00
dec a
ld c, a
ld hl, wPokedexOwned
2015-07-20 03:45:34 +00:00
ld b, FLAG_SET
predef FlagActionPredef
2014-05-22 22:13:20 +00:00
pop af
ld [wd11e], a
2014-05-22 22:13:20 +00:00
call GetMonName
ld hl, GotMonText
jp PrintText
GotMonText: ; 4fe39 (13:7e39)
TX_FAR _GotMonText
db $0b
db "@"
SetToBoxText: ; 4fe3f (13:7e3f)
TX_FAR _SetToBoxText
db "@"
BoxIsFullText: ; 4fe44 (13:7e44)
TX_FAR _BoxIsFullText
db "@"