2018-06-24 14:09:41 +00:00
|
|
|
InsertPokemonIntoBox:
|
2016-05-04 15:46:23 +00:00
|
|
|
ld a, BANK(sBoxCount)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2016-05-04 15:46:23 +00:00
|
|
|
ld hl, sBoxCount
|
|
|
|
call InsertSpeciesIntoBoxOrParty
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2016-05-04 15:46:23 +00:00
|
|
|
ld hl, sBoxMonNicknames
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2021-03-17 20:16:02 +00:00
|
|
|
ld de, wBufferMonNickname
|
2016-05-04 15:46:23 +00:00
|
|
|
call InsertDataIntoBoxOrParty
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2021-03-17 20:16:02 +00:00
|
|
|
ld hl, sBoxMonOTs
|
2016-05-04 15:46:23 +00:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
ld de, wBufferMonOT
|
|
|
|
call InsertDataIntoBoxOrParty
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2016-05-04 15:46:23 +00:00
|
|
|
ld hl, sBoxMons
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
ld de, wBufferMon
|
|
|
|
call InsertDataIntoBoxOrParty
|
|
|
|
ld hl, wBufferMonMoves
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wTempMonMoves
|
2016-05-04 15:46:23 +00:00
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
|
|
|
ld hl, wBufferMonPP
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wTempMonPP
|
2016-05-04 15:46:23 +00:00
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2016-05-04 15:46:23 +00:00
|
|
|
ld b, a
|
2018-08-06 15:20:59 +00:00
|
|
|
farcall RestorePPOfDepositedPokemon
|
2016-05-04 15:46:23 +00:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
InsertPokemonIntoParty:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyCount
|
2016-05-04 15:46:23 +00:00
|
|
|
call InsertSpeciesIntoBoxOrParty
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2016-05-04 15:46:23 +00:00
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMonNicknames
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2021-03-17 20:16:02 +00:00
|
|
|
ld de, wBufferMonNickname
|
2016-05-04 15:46:23 +00:00
|
|
|
call InsertDataIntoBoxOrParty
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2016-05-04 15:46:23 +00:00
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2021-03-17 20:16:02 +00:00
|
|
|
ld hl, wPartyMonOTs
|
2016-05-04 15:46:23 +00:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
ld de, wBufferMonOT
|
|
|
|
call InsertDataIntoBoxOrParty
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2016-05-04 15:46:23 +00:00
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMons
|
2016-05-04 15:46:23 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
ld de, wBufferMon
|
|
|
|
call InsertDataIntoBoxOrParty
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
InsertSpeciesIntoBoxOrParty:
|
2016-05-04 15:46:23 +00:00
|
|
|
inc [hl]
|
|
|
|
inc hl
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2016-05-04 15:46:23 +00:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartySpecies]
|
2016-05-04 15:46:23 +00:00
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hl], c
|
|
|
|
inc hl
|
|
|
|
inc c
|
|
|
|
ld c, a
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
InsertDataIntoBoxOrParty:
|
2016-05-04 15:46:23 +00:00
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
push bc
|
2018-07-28 23:27:34 +00:00
|
|
|
ld a, [wNextBoxOrPartyIndex]
|
2016-05-04 15:46:23 +00:00
|
|
|
dec a
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
.loop
|
|
|
|
push bc
|
2018-07-28 23:27:34 +00:00
|
|
|
ld a, [wNextBoxOrPartyIndex]
|
2016-05-04 15:46:23 +00:00
|
|
|
ld b, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2016-05-04 15:46:23 +00:00
|
|
|
cp b
|
|
|
|
pop bc
|
|
|
|
jr z, .insert
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
call CopyBytes
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
push hl
|
|
|
|
ld a, l
|
|
|
|
sub c
|
|
|
|
ld l, a
|
|
|
|
ld a, h
|
|
|
|
sbc b
|
|
|
|
ld h, a
|
|
|
|
pop de
|
2018-07-28 23:27:34 +00:00
|
|
|
ld a, [wNextBoxOrPartyIndex]
|
2016-05-04 15:46:23 +00:00
|
|
|
dec a
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNextBoxOrPartyIndex], a
|
2016-05-04 15:46:23 +00:00
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.insert
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2016-05-04 15:46:23 +00:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
call CopyBytes
|
|
|
|
ret
|