pokecrystal/engine/pokemon/caught_data.asm

247 lines
4.3 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
CheckPartyFullAfterContest:
ld a, [wContestMonSpecies]
and a
jp z, .DidntCatchAnything
2018-01-23 22:39:09 +00:00
ld [wCurPartySpecies], a
ld [wCurSpecies], a
call GetBaseData
2018-01-23 22:39:09 +00:00
ld hl, wPartyCount
ld a, [hl]
2018-01-11 17:00:01 +00:00
cp PARTY_LENGTH
jp nc, .TryAddToBox
inc a
ld [hl], a
ld c, a
2018-01-11 17:00:01 +00:00
ld b, 0
add hl, bc
ld a, [wContestMonSpecies]
ld [hli], a
2018-01-23 22:39:09 +00:00
ld [wCurSpecies], a
2018-01-11 17:00:01 +00:00
ld a, -1
ld [hl], a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMon1Species
ld a, [wPartyCount]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
ld hl, wContestMon
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMonOT
call SkipNames
ld d, h
ld e, l
2018-01-23 22:39:09 +00:00
ld hl, wPlayerName
call CopyBytes
2018-01-23 22:39:09 +00:00
ld a, [wCurPartySpecies]
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
2018-01-23 22:39:09 +00:00
ld hl, wStringBuffer1
ld de, wMonOrItemNameBuffer
2018-01-20 17:25:55 +00:00
ld bc, MON_NAME_LENGTH
call CopyBytes
call GiveANickname_YesNo
jr c, .Party_SkipNickname
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld [wCurPartyMon], a
xor a
2018-01-23 22:39:09 +00:00
ld [wMonType], a
ld de, wMonOrItemNameBuffer
2017-12-24 17:47:30 +00:00
callfar InitNickname
.Party_SkipNickname:
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMonNicknames
call SkipNames
ld d, h
ld e, l
ld hl, wMonOrItemNameBuffer
call CopyBytes
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMon1Level
call GetPartyLocation
ld a, [hl]
2018-01-23 22:39:09 +00:00
ld [wCurPartyLevel], a
call SetCaughtData
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMon1CaughtLocation
call GetPartyLocation
ld a, [hl]
2018-01-11 17:00:01 +00:00
and CAUGHT_GENDER_MASK
ld b, LANDMARK_NATIONAL_PARK
or b
ld [hl], a
xor a
ld [wContestMonSpecies], a
2018-01-12 06:40:20 +00:00
and a ; BUGCONTEST_CAUGHT_MON
2018-01-23 22:39:09 +00:00
ld [wScriptVar], a
ret
2018-06-24 14:09:41 +00:00
.TryAddToBox:
ld a, BANK(sBoxCount)
call OpenSRAM
ld hl, sBoxCount
ld a, [hl]
cp MONS_PER_BOX
call CloseSRAM
jr nc, .BoxFull
xor a
2018-01-23 22:39:09 +00:00
ld [wCurPartyMon], a
ld hl, wContestMon
ld de, wBufferMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
2018-01-23 22:39:09 +00:00
ld hl, wPlayerName
ld de, wBufferMonOT
ld bc, NAME_LENGTH
call CopyBytes
2017-12-24 17:47:30 +00:00
callfar InsertPokemonIntoBox
2018-01-23 22:39:09 +00:00
ld a, [wCurPartySpecies]
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
call GiveANickname_YesNo
2018-01-23 22:39:09 +00:00
ld hl, wStringBuffer1
jr c, .Box_SkipNickname
ld a, BOXMON
2018-01-23 22:39:09 +00:00
ld [wMonType], a
ld de, wMonOrItemNameBuffer
2017-12-24 17:47:30 +00:00
callfar InitNickname
ld hl, wMonOrItemNameBuffer
.Box_SkipNickname:
ld a, BANK(sBoxMonNicknames)
call OpenSRAM
ld de, sBoxMonNicknames
2018-01-20 17:25:55 +00:00
ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
.BoxFull:
ld a, BANK(sBoxMon1Level)
call OpenSRAM
ld a, [sBoxMon1Level]
2018-01-23 22:39:09 +00:00
ld [wCurPartyLevel], a
call CloseSRAM
call SetBoxMonCaughtData
ld a, BANK(sBoxMon1CaughtLocation)
call OpenSRAM
ld hl, sBoxMon1CaughtLocation
ld a, [hl]
2018-01-11 17:00:01 +00:00
and CAUGHT_GENDER_MASK
ld b, LANDMARK_NATIONAL_PARK
or b
ld [hl], a
call CloseSRAM
xor a
ld [wContestMon], a
2018-01-12 06:40:20 +00:00
ld a, BUGCONTEST_BOXED_MON
2018-01-23 22:39:09 +00:00
ld [wScriptVar], a
ret
2018-06-24 14:09:41 +00:00
.DidntCatchAnything:
2018-01-12 06:40:20 +00:00
ld a, BUGCONTEST_NO_CATCH
2018-01-23 22:39:09 +00:00
ld [wScriptVar], a
ret
2018-06-24 14:09:41 +00:00
GiveANickname_YesNo:
ld hl, CaughtAskNicknameText
call PrintText
jp YesNoBox
CaughtAskNicknameText:
text_far _CaughtAskNicknameText
text_end
2018-06-24 14:09:41 +00:00
SetCaughtData:
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMon1CaughtLevel
call GetPartyLocation
2018-06-24 14:09:41 +00:00
SetBoxmonOrEggmonCaughtData:
2018-01-23 22:39:09 +00:00
ld a, [wTimeOfDay]
inc a
rrca
rrca
ld b, a
2018-01-23 22:39:09 +00:00
ld a, [wCurPartyLevel]
or b
ld [hli], a
2018-01-23 22:39:09 +00:00
ld a, [wMapGroup]
ld b, a
2018-01-23 22:39:09 +00:00
ld a, [wMapNumber]
ld c, a
cp MAP_POKECENTER_2F
jr nz, .NotPokecenter2F
ld a, b
cp GROUP_POKECENTER_2F
jr nz, .NotPokecenter2F
2018-01-23 22:39:09 +00:00
ld a, [wBackupMapGroup]
ld b, a
2018-01-23 22:39:09 +00:00
ld a, [wBackupMapNumber]
ld c, a
.NotPokecenter2F:
call GetWorldMapLocation
ld b, a
ld a, [wPlayerGender]
2018-01-22 19:34:55 +00:00
rrca ; shift bit 0 (PLAYERGENDER_FEMALE_F) to bit 7 (CAUGHT_GENDER_MASK)
or b
ld [hl], a
ret
2018-06-24 14:09:41 +00:00
SetBoxMonCaughtData:
ld a, BANK(sBoxMon1CaughtLevel)
call OpenSRAM
ld hl, sBoxMon1CaughtLevel
call SetBoxmonOrEggmonCaughtData
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SetGiftBoxMonCaughtData:
push bc
ld a, BANK(sBoxMon1CaughtLevel)
call OpenSRAM
ld hl, sBoxMon1CaughtLevel
pop bc
call SetGiftMonCaughtData
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SetGiftPartyMonCaughtData:
2018-01-23 22:39:09 +00:00
ld a, [wPartyCount]
dec a
2018-01-23 22:39:09 +00:00
ld hl, wPartyMon1CaughtLevel
push bc
call GetPartyLocation
pop bc
2018-06-24 14:09:41 +00:00
SetGiftMonCaughtData:
xor a
ld [hli], a
ld a, LANDMARK_GIFT
rrc b
or b
ld [hl], a
ret
2018-06-24 14:09:41 +00:00
SetEggMonCaughtData:
2018-01-23 22:39:09 +00:00
ld a, [wCurPartyMon]
ld hl, wPartyMon1CaughtLevel
call GetPartyLocation
2018-01-23 22:39:09 +00:00
ld a, [wCurPartyLevel]
push af
2018-01-11 17:00:01 +00:00
ld a, CAUGHT_EGG_LEVEL
2018-01-23 22:39:09 +00:00
ld [wCurPartyLevel], a
call SetBoxmonOrEggmonCaughtData
pop af
2018-01-23 22:39:09 +00:00
ld [wCurPartyLevel], a
ret