pokered/engine/evolution.asm
2015-07-18 15:52:03 -05:00

159 lines
2.5 KiB
NASM
Executable file

EvolveMon: ; 7bde9 (1e:7de9)
push hl
push de
push bc
ld a, [wcf91]
push af
ld a, [wd0b5]
push af
xor a
ld [wLowHealthAlarm], a
ld [wc02a], a
dec a
ld [wc0ee], a
call PlaySound
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, (SFX_08_3c - SFX_Headers_08) / 3
call PlaySound
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld [hTilesetType], a
ld a, [wHPBarMaxHP]
ld [wcf1d], a
ld c, $0
call EvolutionSetWholeScreenPalette
ld a, [wHPBarMaxHP + 1]
ld [wcf91], a
ld [wd0b5], a
call Evolution_LoadPic
ld de, vFrontPic
ld hl, vBackPic
ld bc, 7 * 7
call CopyVideoData
ld a, [wHPBarMaxHP]
ld [wcf91], a
ld [wd0b5], a
call Evolution_LoadPic
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, [wHPBarMaxHP]
call PlayCry
call WaitForSoundToFinish
ld c, BANK(Music_SafariZone)
ld a, MUSIC_SAFARI_ZONE
call PlayMusic
ld c, 80
call DelayFrames
ld c, $1
call EvolutionSetWholeScreenPalette
ld bc, $110
.asm_7be63
push bc
call Evolution_CheckForCancel
jr c, .evolutionCancelled
call Func_7bec2
pop bc
inc b
dec c
dec c
jr nz, .asm_7be63
xor a
ld [wHPBarOldHP + 1], a
ld a, $31
ld [wHPBarOldHP], a
call Func_7bed6
ld a, [wHPBarMaxHP + 1]
.afterCancellation
ld [wcf1d], a
ld a, $ff
ld [wc0ee], a
call PlaySound
ld a, [wcf1d]
call PlayCry
ld c, $0
call EvolutionSetWholeScreenPalette
pop af
ld [wd0b5], a
pop af
ld [wcf91], a
pop bc
pop de
pop hl
ld a, [wHPBarOldHP + 1]
and a
ret z
scf
ret
.evolutionCancelled
pop bc
ld a, $1
ld [wHPBarOldHP + 1], a
ld a, [wHPBarMaxHP]
jr .afterCancellation
EvolutionSetWholeScreenPalette: ; 7beb4 (1e:7eb4)
ld b, $b
jp GoPAL_SET
Evolution_LoadPic: ; 7beb9 (1e:7eb9)
call GetMonHeader
coord hl, 7, 2
jp LoadFlippedFrontSpriteByMonIndex
Func_7bec2: ; 7bec2 (1e:7ec2)
ld a, $31
ld [wHPBarOldHP], a
call Func_7bed6
ld a, $cf
ld [wHPBarOldHP], a
call Func_7bed6
dec b
jr nz, Func_7bec2
ret
Func_7bed6: ; 7bed6 (1e:7ed6)
push bc
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 7, 2
ld bc, $707
ld de, $d
.asm_7bee3
push bc
.asm_7bee4
ld a, [wHPBarOldHP]
add [hl]
ld [hli], a
dec c
jr nz, .asm_7bee4
pop bc
add hl, de
dec b
jr nz, .asm_7bee3
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
pop bc
ret
Evolution_CheckForCancel: ; 7befa (1e:7efa)
call DelayFrame
push bc
call JoypadLowSensitivity
ld a, [hJoy5]
pop bc
and B_BUTTON
jr nz, .pressedB
.notAllowedToCancel
dec c
jr nz, Evolution_CheckForCancel
and a
ret
.pressedB
ld a, [wForceEvolution]
and a
jr nz, .notAllowedToCancel
scf
ret