pokered/engine/learn_move.asm

227 lines
3.5 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
LearnMove:
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer1
2015-02-07 20:27:36 +00:00
ld a, [wWhichPokemon]
ld hl, wPartyMonNicks
2014-05-22 22:13:20 +00:00
call GetPartyMonName
ld hl, wcd6d
2015-08-14 07:36:06 +00:00
ld de, wLearnMoveMonName
ld bc, NAME_LENGTH
2014-05-22 22:13:20 +00:00
call CopyData
2016-06-12 00:24:04 +00:00
DontAbandonLearning:
2015-02-07 20:27:36 +00:00
ld hl, wPartyMon1Moves
ld bc, wPartyMon2Moves - wPartyMon1Moves
2015-02-07 20:27:36 +00:00
ld a, [wWhichPokemon]
2014-05-22 22:13:20 +00:00
call AddNTimes
ld d, h
ld e, l
ld b, NUM_MOVES
2015-08-14 07:36:06 +00:00
.findEmptyMoveSlotLoop
2014-05-22 22:13:20 +00:00
ld a, [hl]
and a
2015-08-14 07:36:06 +00:00
jr z, .next
2014-05-22 22:13:20 +00:00
inc hl
dec b
2015-08-14 07:36:06 +00:00
jr nz, .findEmptyMoveSlotLoop
2014-05-22 22:13:20 +00:00
push de
call TryingToLearn
pop de
jp c, AbandonLearning
push hl
push de
ld [wd11e], a
2014-05-22 22:13:20 +00:00
call GetMoveName
ld hl, OneTwoAndText
call PrintText
pop de
pop hl
2015-08-14 07:36:06 +00:00
.next
2015-02-08 08:17:03 +00:00
ld a, [wMoveNum]
2014-05-22 22:13:20 +00:00
ld [hl], a
ld bc, wPartyMon1PP - wPartyMon1Moves
2014-05-22 22:13:20 +00:00
add hl, bc
push hl
push de
dec a
2015-02-07 20:27:36 +00:00
ld hl, Moves
2015-08-10 04:56:20 +00:00
ld bc, MoveEnd - Moves
2014-05-22 22:13:20 +00:00
call AddNTimes
2015-07-25 03:27:59 +00:00
ld de, wBuffer
2014-05-22 22:13:20 +00:00
ld a, BANK(Moves)
call FarCopyData
2015-07-25 03:27:59 +00:00
ld a, [wBuffer + 5] ; a = move's max PP
2014-05-22 22:13:20 +00:00
pop de
pop hl
ld [hl], a
2015-08-31 02:38:41 +00:00
ld a, [wIsInBattle]
2014-05-22 22:13:20 +00:00
and a
jp z, PrintLearnedMove
2015-02-07 20:27:36 +00:00
ld a, [wWhichPokemon]
2014-05-22 22:13:20 +00:00
ld b, a
2015-02-07 20:27:36 +00:00
ld a, [wPlayerMonNumber]
2014-05-22 22:13:20 +00:00
cp b
jp nz, PrintLearnedMove
ld h, d
ld l, e
ld de, wBattleMonMoves
2015-02-08 08:17:03 +00:00
ld bc, NUM_MOVES
2014-05-22 22:13:20 +00:00
call CopyData
ld bc, wPartyMon1PP - wPartyMon1OTID
2014-05-22 22:13:20 +00:00
add hl, bc
2015-02-07 20:27:36 +00:00
ld de, wBattleMonPP
ld bc, NUM_MOVES
2014-05-22 22:13:20 +00:00
call CopyData
jp PrintLearnedMove
2016-06-12 00:24:04 +00:00
AbandonLearning:
2014-05-22 22:13:20 +00:00
ld hl, AbandonLearningText
call PrintText
2015-07-18 20:52:03 +00:00
coord hl, 14, 7
2015-08-05 21:20:29 +00:00
lb bc, 8, 15
2015-02-07 20:27:36 +00:00
ld a, TWO_OPTION_MENU
2015-02-07 10:43:08 +00:00
ld [wTextBoxID], a
2015-02-07 20:27:36 +00:00
call DisplayTextBoxID ; yes/no menu
ld a, [wCurrentMenuItem]
2014-05-22 22:13:20 +00:00
and a
jp nz, DontAbandonLearning
ld hl, DidNotLearnText
call PrintText
2015-08-14 07:36:06 +00:00
ld b, 0
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
PrintLearnedMove:
2014-05-22 22:13:20 +00:00
ld hl, LearnedMove1Text
call PrintText
2015-08-14 07:36:06 +00:00
ld b, 1
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
TryingToLearn:
2014-05-22 22:13:20 +00:00
push hl
ld hl, TryingToLearnText
call PrintText
2015-07-18 20:52:03 +00:00
coord hl, 14, 7
2015-08-05 21:20:29 +00:00
lb bc, 8, 15
2015-02-07 20:27:36 +00:00
ld a, TWO_OPTION_MENU
2015-02-07 10:43:08 +00:00
ld [wTextBoxID], a
2015-02-07 20:27:36 +00:00
call DisplayTextBoxID ; yes/no menu
2014-05-22 22:13:20 +00:00
pop hl
2015-02-07 20:27:36 +00:00
ld a, [wCurrentMenuItem]
2014-05-22 22:13:20 +00:00
rra
ret c
2015-08-14 07:36:06 +00:00
ld bc, -NUM_MOVES
2014-05-22 22:13:20 +00:00
add hl, bc
push hl
2015-02-08 08:17:03 +00:00
ld de, wMoves
ld bc, NUM_MOVES
2014-05-22 22:13:20 +00:00
call CopyData
2015-02-08 08:17:03 +00:00
callab FormatMovesString
2014-05-22 22:13:20 +00:00
pop hl
2015-08-11 05:34:32 +00:00
.loop
2014-05-22 22:13:20 +00:00
push hl
ld hl, WhichMoveToForgetText
call PrintText
2015-07-18 20:52:03 +00:00
coord hl, 4, 7
2015-08-14 07:36:06 +00:00
ld b, 4
ld c, 14
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 6, 8
2015-02-08 08:17:03 +00:00
ld de, wMovesString
2015-02-08 00:24:16 +00:00
ld a, [hFlags_0xFFF6]
2014-05-22 22:13:20 +00:00
set 2, a
2015-02-08 00:24:16 +00:00
ld [hFlags_0xFFF6], a
2014-05-22 22:13:20 +00:00
call PlaceString
2015-02-08 00:24:16 +00:00
ld a, [hFlags_0xFFF6]
2014-05-22 22:13:20 +00:00
res 2, a
2015-02-08 00:24:16 +00:00
ld [hFlags_0xFFF6], a
2015-02-07 20:27:36 +00:00
ld hl, wTopMenuItemY
2015-07-15 06:16:06 +00:00
ld a, 8
ld [hli], a ; wTopMenuItemY
ld a, 5
ld [hli], a ; wTopMenuItemX
2014-05-22 22:13:20 +00:00
xor a
2015-07-15 06:16:06 +00:00
ld [hli], a ; wCurrentMenuItem
2014-05-22 22:13:20 +00:00
inc hl
2015-07-15 06:16:06 +00:00
ld a, [wNumMovesMinusOne]
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
ld [hl], 0 ; wLastMenuItem
2015-02-08 00:24:16 +00:00
ld hl, hFlags_0xFFF6
2014-05-22 22:13:20 +00:00
set 1, [hl]
call HandleMenuInput
2015-02-08 00:24:16 +00:00
ld hl, hFlags_0xFFF6
2014-05-22 22:13:20 +00:00
res 1, [hl]
push af
call LoadScreenTilesFromBuffer1
pop af
pop hl
2015-08-11 05:34:32 +00:00
bit 1, a ; pressed b
jr nz, .cancel
2014-05-22 22:13:20 +00:00
push hl
2015-02-07 20:27:36 +00:00
ld a, [wCurrentMenuItem]
2014-05-22 22:13:20 +00:00
ld c, a
2015-08-14 07:36:06 +00:00
ld b, 0
2014-05-22 22:13:20 +00:00
add hl, bc
ld a, [hl]
push af
push bc
call IsMoveHM
pop bc
pop de
ld a, d
2015-08-11 05:34:32 +00:00
jr c, .hm
2014-05-22 22:13:20 +00:00
pop hl
add hl, bc
and a
ret
2015-08-11 05:34:32 +00:00
.hm
2014-05-22 22:13:20 +00:00
ld hl, HMCantDeleteText
call PrintText
pop hl
2015-08-11 05:34:32 +00:00
jr .loop
.cancel
2014-05-22 22:13:20 +00:00
scf
ret
2016-06-12 00:24:04 +00:00
LearnedMove1Text:
2014-05-22 22:13:20 +00:00
TX_FAR _LearnedMove1Text
2016-07-18 06:17:03 +00:00
TX_SFX_ITEM_1 ; plays SFX_GET_ITEM_1 in the pary menu (rare candy) and plays SFX_LEVEL_UP in battle
TX_BLINK
db "@"
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
WhichMoveToForgetText:
2014-05-22 22:13:20 +00:00
TX_FAR _WhichMoveToForgetText
db "@"
2016-06-12 00:24:04 +00:00
AbandonLearningText:
2014-05-22 22:13:20 +00:00
TX_FAR _AbandonLearningText
db "@"
2016-06-12 00:24:04 +00:00
DidNotLearnText:
2014-05-22 22:13:20 +00:00
TX_FAR _DidNotLearnText
db "@"
2016-06-12 00:24:04 +00:00
TryingToLearnText:
2014-05-22 22:13:20 +00:00
TX_FAR _TryingToLearnText
db "@"
2016-06-12 00:24:04 +00:00
OneTwoAndText:
2014-05-22 22:13:20 +00:00
TX_FAR _OneTwoAndText
2016-07-18 06:17:03 +00:00
TX_DELAY
2015-07-03 19:58:50 +00:00
TX_ASM
2015-07-19 08:46:12 +00:00
ld a, SFX_SWAP
2014-05-22 22:13:20 +00:00
call PlaySoundWaitForCurrent
ld hl, PoofText
ret
2016-06-12 00:24:04 +00:00
PoofText:
2014-05-22 22:13:20 +00:00
TX_FAR _PoofText
2016-07-18 06:17:03 +00:00
TX_DELAY
2016-06-12 00:24:04 +00:00
ForgotAndText:
2014-05-22 22:13:20 +00:00
TX_FAR _ForgotAndText
db "@"
2016-06-12 00:24:04 +00:00
HMCantDeleteText:
2014-05-22 22:13:20 +00:00
TX_FAR _HMCantDeleteText
db "@"