pokecrystal-board/engine/search2.asm
Rangi 32ed487a47 Merge branch 'master' of https://github.com/pret/pokecrystal
# Conflicts:
#	audio/engine.asm
#	constants/gfx_constants.asm
#	constants/map_data_constants.asm
#	constants/pokemon_data_constants.asm
#	constants/sprite_constants.asm
#	constants/wram_constants.asm
#	data/maps/data.asm
#	engine/battle/ai/scoring.asm
#	engine/battle/core.asm
#	engine/battle/effect_commands.asm
#	engine/battle/misc.asm
#	engine/battle_anims/getpokeballwobble.asm
#	engine/breeding.asm
#	engine/buy_sell_toss.asm
#	engine/decorations.asm
#	engine/events/battle_tower/battle_tower.asm
#	engine/events/battle_tower/rules.asm
#	engine/events/buena.asm
#	engine/events/bug_contest/contest_2.asm
#	engine/events/daycare.asm
#	engine/events/dratini.asm
#	engine/events/halloffame.asm
#	engine/events/happiness_egg.asm
#	engine/events/kurt.asm
#	engine/events/lucky_number.asm
#	engine/events/magnet_train.asm
#	engine/events/overworld.asm
#	engine/events/pokerus/pokerus.asm
#	engine/events/print_unown.asm
#	engine/events/print_unown_2.asm
#	engine/events/unown_walls.asm
#	engine/item_effects.asm
#	engine/link.asm
#	engine/mon_menu.asm
#	engine/player_object.asm
#	engine/routines/playslowcry.asm
#	engine/scripting.asm
#	engine/search.asm
#	engine/search2.asm
#	engine/specials.asm
#	engine/start_menu.asm
#	engine/timeset.asm
#	home/battle_vars.asm
#	home/map.asm
#	maps/GoldenrodUndergroundSwitchRoomEntrances.asm
#	maps/IlexForest.asm
#	maps/KrissHouse2F.asm
#	maps/Route39Barn.asm
#	mobile/mobile_12_2.asm
#	mobile/mobile_40.asm
#	mobile/mobile_5f.asm
#	wram.asm
2018-02-03 19:42:56 -05:00

135 lines
1.9 KiB
NASM
Executable File

_FindPartyMonGreaterThanThatLevel: ; 4dbd2
ld hl, wPartyMon1Level
call FindGreaterThanThatLevel
ret
_FindPartyMonAtLeastThatHappy: ; 4dbd9
ld hl, wPartyMon1Happiness
call FindAtLeastThatHappy
ret
_FindPartyMonThatSpecies: ; 4dbe0
ld hl, wPartyMon1Species
jp FindThatSpecies
_FindPartyMonThatSpeciesYourTrainerID: ; 4dbe6
ld hl, wPartyMon1Species
call FindThatSpecies
ret z
ld a, c
ld hl, wPartyMon1ID
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [wPlayerID]
cp [hl]
jr nz, .nope
inc hl
ld a, [wPlayerID + 1]
cp [hl]
jr nz, .nope
ld a, $1
and a
ret
.nope
xor a
ret
FindAtLeastThatHappy: ; 4dc0a
; Sets the bits for the Pokemon that have a happiness greater than or equal to b.
; The lowest bits are used. Sets z if no Pokemon in your party is at least that happy.
ld c, $0
ld a, [wPartyCount]
ld d, a
.loop
ld a, d
dec a
push hl
push bc
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
ld a, b
cp [hl]
pop hl
jr z, .greater_equal
jr nc, .lower
.greater_equal
ld a, c
or $1
ld c, a
.lower
sla c
dec d
jr nz, .loop
call RetroactivelyIgnoreEggs
ld a, c
and a
ret
FindGreaterThanThatLevel: ; 4dc31
ld c, $0
ld a, [wPartyCount]
ld d, a
.loop
ld a, d
dec a
push hl
push bc
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
ld a, b
cp [hl]
pop hl
jr c, .greater
ld a, c
or $1
ld c, a
.greater
sla c
dec d
jr nz, .loop
call RetroactivelyIgnoreEggs
ld a, c
and a
ret
FindThatSpecies: ; 4dc56
; Find species b in your party.
; If you have no Pokemon, returns c = -1 and z.
; If that species is in your party, returns its location in c, and nz.
; Otherwise, returns z.
ld c, -1
ld hl, wPartySpecies
.loop
ld a, [hli]
cp -1
ret z
inc c
cp b
jr nz, .loop
ld a, $1
and a
ret
RetroactivelyIgnoreEggs: ; 4dc67
ld e, -2
ld hl, wPartySpecies
.loop
ld a, [hli]
cp -1
ret z
cp EGG
jr nz, .skip_notegg
ld a, c
and e
ld c, a
.skip_notegg
rlc e
jr .loop