pokecrystal/unknown/013a47.asm

230 lines
2.9 KiB
NASM
Raw Normal View History

CorrectErrorsInPlayerParty: ; unreferenced
2015-11-11 21:11:08 +00:00
ld hl, PartyCount
ld a, [hl]
and a
ret z
cp PARTY_LENGTH + 1
jr c, .party_length_okay
2015-11-11 21:11:08 +00:00
ld a, PARTY_LENGTH
ld [hl], a
.party_length_okay
2015-11-11 21:11:08 +00:00
inc hl
ld b, a
ld c, 0
.loop1
2015-11-11 21:11:08 +00:00
ld a, [hl]
and a
jr z, .invalid_species
cp NUM_POKEMON + 1
jr z, .invalid_species
cp EGG + 1
jr c, .next_species
2015-11-11 21:11:08 +00:00
.invalid_species
2015-11-11 21:11:08 +00:00
ld [hl], SMEARGLE
push hl
push bc
ld a, c
ld hl, PartyMon1Species
call GetPartyLocation
ld [hl], SMEARGLE
pop bc
pop hl
.next_species
2015-11-11 21:11:08 +00:00
inc hl
inc c
dec b
jr nz, .loop1
2015-11-11 21:11:08 +00:00
ld [hl], $ff
ld hl, PartyMon1
ld a, [PartyCount]
ld d, a
ld e, 0
.loop2
2015-11-11 21:11:08 +00:00
push de
push hl
ld b, h
ld c, l
ld a, [hl]
and a
jr z, .invalid_species_2
2015-11-11 21:11:08 +00:00
cp NUM_POKEMON + 1
jr c, .check_level
2015-11-11 21:11:08 +00:00
.invalid_species_2
2015-11-11 21:11:08 +00:00
ld [hl], SMEARGLE
push de
ld d, 0
ld hl, PartySpecies
add hl, de
pop de
ld a, SMEARGLE
ld [hl], a
.check_level
2015-11-11 21:11:08 +00:00
ld [CurSpecies], a
call GetBaseData
ld hl, MON_LEVEL
add hl, bc
ld a, [hl]
cp MIN_LEVEL
ld a, MIN_LEVEL
jr c, .invalid_level
2015-11-11 21:11:08 +00:00
ld a, [hl]
cp MAX_LEVEL
jr c, .load_level
2015-11-11 21:11:08 +00:00
ld a, MAX_LEVEL
.invalid_level
2015-11-11 21:11:08 +00:00
ld [hl], a
.load_level
2015-11-11 21:11:08 +00:00
ld [CurPartyLevel], a
ld hl, MON_MAXHP
add hl, bc
ld d, h
ld e, l
2015-12-21 19:10:16 +00:00
ld hl, MON_STAT_EXP - 1
2015-11-11 21:11:08 +00:00
add hl, bc
ld b, $1
predef CalcPkmnStats
pop hl
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop de
inc e
dec d
jr nz, .loop2
2015-11-11 21:11:08 +00:00
ld de, PartyMonNicknames
ld a, [PartyCount]
ld b, a
ld c, 0
.loop3
2015-11-11 21:11:08 +00:00
push bc
call .GetLengthOfStringWith6CharCap
2015-11-11 21:11:08 +00:00
push de
callba CheckStringForErrors
pop hl
pop bc
jr nc, .valid_nickname
2015-11-11 21:11:08 +00:00
push bc
push hl
ld hl, PartySpecies
push bc
ld b, 0
add hl, bc
pop bc
ld a, [hl]
cp EGG
ld hl, .TAMAGO
jr z, .got_nickname
2015-11-11 21:11:08 +00:00
ld [wd265], a
call GetPokemonName
ld hl, StringBuffer1
.got_nickname
2015-11-11 21:11:08 +00:00
pop de
ld bc, PKMN_NAME_LENGTH
call CopyBytes
pop bc
.valid_nickname
2015-11-11 21:11:08 +00:00
inc c
dec b
jr nz, .loop3
2015-11-11 21:11:08 +00:00
ld de, PartyMonOT
ld a, [PartyCount]
ld b, a
ld c, 0
.loop4
2015-11-11 21:11:08 +00:00
push bc
call .GetLengthOfStringWith6CharCap
2015-11-11 21:11:08 +00:00
push de
callba CheckStringForErrors
pop hl
jr nc, .valid_ot_name
2015-11-11 21:11:08 +00:00
ld d, h
ld e, l
ld hl, PlayerName
ld bc, NAME_LENGTH
call CopyBytes
.valid_ot_name
2015-11-11 21:11:08 +00:00
pop bc
inc c
dec b
jr nz, .loop4
2015-11-11 21:11:08 +00:00
ld hl, PartyMon1Moves
ld a, [PartyCount]
ld b, a
.loop5
2015-11-11 21:11:08 +00:00
push hl
ld c, NUM_MOVES
ld a, [hl]
and a
jr z, .invalid_move
2015-11-11 21:11:08 +00:00
cp NUM_ATTACKS + 1
jr c, .moves_loop
.invalid_move
2015-11-11 21:11:08 +00:00
ld [hl], POUND
.moves_loop
2015-11-11 21:11:08 +00:00
ld a, [hl]
and a
jr z, .fill_invalid_moves
2015-11-11 21:11:08 +00:00
cp NUM_ATTACKS + 1
jr c, .next_move
2015-11-11 21:11:08 +00:00
.fill_invalid_moves
2015-11-11 21:11:08 +00:00
xor a
ld [hli], a
dec c
jr nz, .fill_invalid_moves
jr .next_pokemon
2015-11-11 21:11:08 +00:00
.next_move
2015-11-11 21:11:08 +00:00
inc hl
dec c
jr nz, .moves_loop
2015-11-11 21:11:08 +00:00
.next_pokemon
2015-11-11 21:11:08 +00:00
pop hl
push bc
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop bc
dec b
jr nz, .loop5
2015-11-11 21:11:08 +00:00
ret
; 13b6b
.TAMAGO: ; 13b6b
db "タマゴ@@@"
; 13b71
.GetLengthOfStringWith6CharCap: ; 13b71
2015-11-11 21:11:08 +00:00
push de
ld c, 1
ld b, 6
.search_loop
2015-11-11 21:11:08 +00:00
ld a, [de]
cp "@"
jr z, .done
inc de
inc c
dec b
jr nz, .search_loop
2015-11-11 21:11:08 +00:00
dec c
dec de
ld a, "@"
ld [de], a
.done
pop de
ret
; 13b87