diff options
| author | dannye <33dannye@gmail.com> | 2020-11-04 00:06:44 -0600 |
|---|---|---|
| committer | dannye <33dannye@gmail.com> | 2020-11-04 00:06:44 -0600 |
| commit | 5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch) | |
| tree | dde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/pokemon/learn_move.asm | |
| parent | Merge pull request #55 from Deokishisu/patch-1 (diff) | |
| download | pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip | |
Sync with pokered
Diffstat (limited to 'engine/pokemon/learn_move.asm')
| -rwxr-xr-x | engine/pokemon/learn_move.asm | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm new file mode 100755 index 00000000..d365acd4 --- /dev/null +++ b/engine/pokemon/learn_move.asm @@ -0,0 +1,250 @@ +LearnMove: + call SaveScreenTilesToBuffer1 + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks + call GetPartyMonName + ld hl, wcd6d + ld de, wLearnMoveMonName + ld bc, NAME_LENGTH + call CopyData + +DontAbandonLearning: + ld hl, wPartyMon1Moves + ld bc, wPartyMon2Moves - wPartyMon1Moves + ld a, [wWhichPokemon] + call AddNTimes + ld d, h + ld e, l + ld b, NUM_MOVES +.findEmptyMoveSlotLoop + ld a, [hl] + and a + jr z, .next + inc hl + dec b + jr nz, .findEmptyMoveSlotLoop + push de + call TryingToLearn + pop de + jp c, AbandonLearning + push hl + push de + ld [wd11e], a + call GetMoveName + ld hl, OneTwoAndText + call PrintText + pop de + pop hl +.next + ld a, [wMoveNum] + ld [hl], a + ld bc, wPartyMon1PP - wPartyMon1Moves + add hl, bc + push hl + push de + dec a + ld hl, Moves + ld bc, MoveEnd - Moves + call AddNTimes + ld de, wBuffer + ld a, BANK(Moves) + call FarCopyData + ld a, [wBuffer + 5] ; a = move's max PP + pop de + pop hl + ld [hl], a + ld a, [wIsInBattle] + and a + jp z, PrintLearnedMove + ld a, [wWhichPokemon] + ld b, a + ld a, [wPlayerMonNumber] + cp b + jp nz, PrintLearnedMove + ld h, d + ld l, e + ld de, wBattleMonMoves + ld bc, NUM_MOVES + call CopyData + ld bc, wPartyMon1PP - wPartyMon1OTID + add hl, bc + ld de, wBattleMonPP + ld bc, NUM_MOVES + call CopyData + jp PrintLearnedMove + +AbandonLearning: + ld hl, AbandonLearningText + call PrintText + hlcoord 14, 7 + lb bc, 8, 15 + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a + call DisplayTextBoxID ; yes/no menu + ld a, [wCurrentMenuItem] + and a + jp nz, DontAbandonLearning + ld hl, DidNotLearnText + call PrintText + ld b, 0 + ret + +PrintLearnedMove: + ld hl, LearnedMove1Text + call PrintText + ld b, 1 + ret + +TryingToLearn: + push hl + ld hl, TryingToLearnText + call PrintText + hlcoord 14, 7 + lb bc, 8, 15 + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a + call DisplayTextBoxID ; yes/no menu + pop hl + ld a, [wCurrentMenuItem] + rra + ret c + ld bc, -NUM_MOVES + add hl, bc + push hl + ld de, wMoves + ld bc, NUM_MOVES + call CopyData + callfar FormatMovesString + pop hl +.loop + push hl + ld hl, WhichMoveToForgetText + call PrintText + hlcoord 4, 7 + lb bc, 4, 14 + call TextBoxBorder + hlcoord 6, 8 + ld de, wMovesString + ldh a, [hFlagsFFFA] + set 2, a + ldh [hFlagsFFFA], a + call PlaceString + ldh a, [hFlagsFFFA] + res 2, a + ldh [hFlagsFFFA], a + ld hl, wTopMenuItemY + ld a, 8 + ld [hli], a ; wTopMenuItemY + ld a, 5 + ld [hli], a ; wTopMenuItemX + xor a + ld [hli], a ; wCurrentMenuItem + inc hl + ld a, [wNumMovesMinusOne] + ld [hli], a ; wMaxMenuItem + ld a, A_BUTTON | B_BUTTON + ld [hli], a ; wMenuWatchedKeys + ld [hl], 0 ; wLastMenuItem + ld hl, hFlagsFFFA + set 1, [hl] + call HandleMenuInput + ld hl, hFlagsFFFA + res 1, [hl] + push af + call LoadScreenTilesFromBuffer1 + pop af + pop hl + bit 1, a ; pressed b + jr nz, .cancel + push hl + ld a, [wCurrentMenuItem] + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + push af + push bc + call IsMoveHM + pop bc + pop de + ld a, d + jr c, .hm + pop hl + add hl, bc + and a + ret +.hm + ld hl, HMCantDeleteText + call PrintText + pop hl + jr .loop +.cancel + scf + ret + +LearnedMove1Text: + text_far _LearnedMove1Text + sound_get_item_1 ; plays SFX_GET_ITEM_1 in the party menu (rare candy) and plays SFX_LEVEL_UP in battle + text_promptbutton + text_end + +WhichMoveToForgetText: + text_far _WhichMoveToForgetText + text_end + +AbandonLearningText: + text_far _AbandonLearningText + text_end + +DidNotLearnText: + text_far _DidNotLearnText + text_end + +TryingToLearnText: + text_far _TryingToLearnText + text_end + +OneTwoAndText: +; bugfix: In Red/Blue, the SFX_SWAP sound was played in the wrong bank, which played an incorrect sound +; Yellow has fixed this by swapping to the correct bank + text_far _OneTwoAndText + text_pause + text_asm + push af + push bc + push de + push hl + ld a, $1 + ld [wMuteAudioAndPauseMusic], a + call DelayFrame + ld a, [wAudioROMBank] + push af + ld a, BANK(SFX_Swap_1) + ld [wAudioROMBank], a + ld [wAudioSavedROMBank], a + call WaitForSoundToFinish + ld a, SFX_SWAP + call PlaySound + call WaitForSoundToFinish + pop af + ld [wAudioROMBank], a + ld [wAudioSavedROMBank], a + xor a + ld [wMuteAudioAndPauseMusic], a + pop hl + pop de + pop bc + pop af + ld hl, PoofText + ret + +PoofText: + text_far _PoofText + text_pause +ForgotAndText: + text_far _ForgotAndText + text_end + +HMCantDeleteText: + text_far _HMCantDeleteText + text_end |
