mirror of
https://github.com/pret/pokered.git
synced 2024-10-23 06:58:24 +00:00
Port _RemovePokemon documentation from pokeyellow
This commit is contained in:
parent
b0aa4cb14a
commit
7ab43f4d17
2 changed files with 34 additions and 33 deletions
|
@ -2,9 +2,9 @@ _RemovePokemon::
|
||||||
ld hl, wPartyCount
|
ld hl, wPartyCount
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7b74
|
jr z, .usePartyCount
|
||||||
ld hl, wNumInBox
|
ld hl, wNumInBox
|
||||||
.asm_7b74
|
.usePartyCount
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
dec a
|
dec a
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
|
@ -15,28 +15,28 @@ _RemovePokemon::
|
||||||
ld e, l
|
ld e, l
|
||||||
ld d, h
|
ld d, h
|
||||||
inc de
|
inc de
|
||||||
.asm_7b81
|
.shiftMonSpeciesLoop
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc de
|
inc de
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
inc a
|
inc a ; reached terminator?
|
||||||
jr nz, .asm_7b81
|
jr nz, .shiftMonSpeciesLoop ; if not, continue shifting species
|
||||||
ld hl, wPartyMonOT
|
ld hl, wPartyMonOT
|
||||||
ld d, $5
|
ld d, PARTY_LENGTH - 1 ; max number of pokemon to shift
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7b97
|
jr z, .usePartyMonOTs
|
||||||
ld hl, wBoxMonOT
|
ld hl, wBoxMonOT
|
||||||
ld d, $13
|
ld d, MONS_PER_BOX - 1
|
||||||
.asm_7b97
|
.usePartyMonOTs
|
||||||
ld a, [wWhichPokemon]
|
ld a, [wWhichPokemon]
|
||||||
call SkipFixedLengthTextEntries
|
call SkipFixedLengthTextEntries
|
||||||
ld a, [wWhichPokemon]
|
ld a, [wWhichPokemon]
|
||||||
cp d
|
cp d ; are we removing the last pokemon?
|
||||||
jr nz, .asm_7ba6
|
jr nz, .notRemovingLastMon ; if not, shift the pokemon below
|
||||||
ld [hl], $ff
|
ld [hl], $ff ; else, write the terminator and return
|
||||||
ret
|
ret
|
||||||
.asm_7ba6
|
.notRemovingLastMon
|
||||||
ld d, h
|
ld d, h
|
||||||
ld e, l
|
ld e, l
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
|
@ -44,41 +44,41 @@ _RemovePokemon::
|
||||||
ld bc, wPartyMonNicks
|
ld bc, wPartyMonNicks
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7bb8
|
jr z, .usePartyMonNicks
|
||||||
ld bc, wBoxMonNicks
|
ld bc, wBoxMonNicks
|
||||||
.asm_7bb8
|
.usePartyMonNicks
|
||||||
call CopyDataUntil
|
call CopyDataUntil
|
||||||
ld hl, wPartyMons
|
ld hl, wPartyMons
|
||||||
ld bc, wPartyMon2 - wPartyMon1
|
ld bc, wPartyMon2 - wPartyMon1
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7bcd
|
jr z, .usePartyMonStructs
|
||||||
ld hl, wBoxMons
|
ld hl, wBoxMons
|
||||||
ld bc, wBoxMon2 - wBoxMon1
|
ld bc, wBoxMon2 - wBoxMon1
|
||||||
.asm_7bcd
|
.usePartyMonStructs
|
||||||
ld a, [wWhichPokemon]
|
ld a, [wWhichPokemon]
|
||||||
call AddNTimes
|
call AddNTimes ; get address of the pokemon removed
|
||||||
ld d, h
|
ld d, h ; store in de for CopyDataUntil
|
||||||
ld e, l
|
ld e, l
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7be4
|
jr z, .copyUntilPartyMonOTs
|
||||||
ld bc, wBoxMon2 - wBoxMon1
|
ld bc, wBoxMon2 - wBoxMon1
|
||||||
add hl, bc
|
add hl, bc ; get address of pokemon after the pokemon removed
|
||||||
ld bc, wBoxMonOT
|
ld bc, wBoxMonOT ; address of when to stop copying
|
||||||
jr .asm_7beb
|
jr .continue
|
||||||
.asm_7be4
|
.copyUntilPartyMonOTs
|
||||||
ld bc, wPartyMon2 - wPartyMon1
|
ld bc, wPartyMon2 - wPartyMon1
|
||||||
add hl, bc
|
add hl, bc ; get address of pokemon after the pokemon removed
|
||||||
ld bc, wPartyMonOT
|
ld bc, wPartyMonOT ; address of when to stop copying
|
||||||
.asm_7beb
|
.continue
|
||||||
call CopyDataUntil
|
call CopyDataUntil ; shift all pokemon data after the removed mon to the removed mon's location
|
||||||
ld hl, wPartyMonNicks
|
ld hl, wPartyMonNicks
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7bfa
|
jr z, .usePartyMonNicks2
|
||||||
ld hl, wBoxMonNicks
|
ld hl, wBoxMonNicks
|
||||||
.asm_7bfa
|
.usePartyMonNicks2
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
ld a, [wWhichPokemon]
|
ld a, [wWhichPokemon]
|
||||||
call AddNTimes
|
call AddNTimes
|
||||||
|
@ -86,10 +86,10 @@ _RemovePokemon::
|
||||||
ld e, l
|
ld e, l
|
||||||
ld bc, NAME_LENGTH
|
ld bc, NAME_LENGTH
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld bc, wPokedexOwned
|
ld bc, wPartyMonNicksEnd
|
||||||
ld a, [wRemoveMonFromBox]
|
ld a, [wRemoveMonFromBox]
|
||||||
and a
|
and a
|
||||||
jr z, .asm_7c15
|
jr z, .copyUntilPartyMonNicksEnd
|
||||||
ld bc, wBoxMonNicksEnd
|
ld bc, wBoxMonNicksEnd
|
||||||
.asm_7c15
|
.copyUntilPartyMonNicksEnd
|
||||||
jp CopyDataUntil
|
jp CopyDataUntil
|
||||||
|
|
1
wram.asm
1
wram.asm
|
@ -2216,6 +2216,7 @@ wPartyMon6:: party_struct wPartyMon6
|
||||||
|
|
||||||
wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
|
wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
|
||||||
wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH
|
wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH
|
||||||
|
wPartyMonNicksEnd::
|
||||||
|
|
||||||
wPartyDataEnd::
|
wPartyDataEnd::
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue