pokecrystal-board/engine/mystery_gift_2.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

153 lines
2.3 KiB
NASM
Executable File

PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
ld de, wMysteryGiftStaging
ld a, $1
ld [de], a
inc de ; wc801
ld a, BANK(sGameData)
call GetSRAMBank
ld hl, sPlayerData + wPlayerID - wPlayerData
ld a, [hli]
ld [de], a
ld b, a
inc de ; wc802
ld a, [hl]
ld [de], a
ld c, a
inc de ; wc803
push bc
ld hl, sPlayerData + wPlayerName - wPlayerData
ld bc, NAME_LENGTH
call CopyBytes
push de ; wc80e
ld hl, sPokemonData + wPokedexCaught - wPokemonData
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
pop de
pop bc
ld a, [wd265]
ld [de], a
inc de ; wc80f
call CloseSRAM
call Random
and 1
ld [de], a
inc de ; wc810
call .RandomSample
ld [de], a
inc de ; wc811
ld a, c
ld c, b
ld b, a
call .RandomSample
ld [de], a
inc de ; wc812
ld a, BANK(sBackupMysteryGiftItem)
call GetSRAMBank
ld a, [sBackupMysteryGiftItem]
ld [de], a
inc de
ld a, [sBackupMysteryGiftItem + 1]
ld [de], a
ld a, $14
ld [wca00], a
call CloseSRAM
ld hl, wMysteryGiftStaging
ld de, wMysteryGiftPlayerData
ld bc, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
jp CopyBytes
.RandomSample: ; 2c6ac (b:46ac)
push de
call Random
cp 10 percent
jr c, .tenpercent
call Random
and %111
ld d, a
rl d
ld e, $80
.loop
rlc e
dec a
jr nz, .loop
ld a, e
and c
jr z, .skip
ld a, $1
.skip
add d
jr .done
.tenpercent
call Random
cp 20 percent - 1
jr c, .twopercent
call Random
and %011
ld d, a
rl d
ld e, $80
.loop2
rlc e
dec a
jr nz, .loop2
ld a, e
and b
jr z, .skip2
ld a, $1
.skip2
add d
add $10
jr .done
.twopercent
call Random
cp 20 percent - 1
jr c, .pointfourpercent
ld a, b
swap a
and $7
add $18
jr .done
.pointfourpercent
ld a, b
and $80
ld a, $20
jr z, .done
ld a, $21
.done
pop de
ret
MysteryGiftGetItemHeldEffect: ; 2c708 (b:4708)
ld a, c
cp MysteryGiftItems.End - MysteryGiftItems
jr nc, MysteryGiftFallbackItem
ld hl, MysteryGiftItems
ld b, 0
add hl, bc
ld c, [hl]
ret
MysteryGiftGetDecoration: ; 2c715 (b:4715)
ld a, c
cp MysteryGiftDecos.End - MysteryGiftDecos
jr nc, MysteryGiftFallbackItem
ld hl, MysteryGiftDecos
ld b, 0
add hl, bc
ld c, [hl]
ret
MysteryGiftFallbackItem: ; 2c722 (b:4722)
ld c, DECO_POLKADOT_BED ; GREAT_BALL
ret
; 2c725 (b:4725)
INCLUDE "data/items/mystery_gift_items.asm"
INCLUDE "data/decorations/mystery_gift_decos.asm"