Skip to content

Commit

Permalink
Merge pull request #6 from huderlem/master
Browse files Browse the repository at this point in the history
Move Deleter (and small bugfix for move relearner)
  • Loading branch information
JustRegularLuna committed Mar 23, 2016
2 parents 5ecbb0f + 6b9446d commit 4d70995
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 2 deletions.
169 changes: 169 additions & 0 deletions scripts/move_deleter.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
MoveDeleterText1:
db 8 ; asm
ld hl, MoveDeleterGreetingText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jp nz, .exit
ld hl, MoveDeleterSaidYesText
call PrintText
; Select pokemon from party.
call SaveScreenTilesToBuffer2
xor a
ld [wListScrollOffset], a
ld [wd07d], a
ld [wUpdateSpritesEnabled], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
push af
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
call LoadGBPal
pop af
jp c, .exit
ld a, [wWhichPokemon]
ld b, a
push bc
call PrepareDeletableMoveList
pop bc
ld a, [wDeletableMoves]
cp 2
jr nc, .chooseMove
pop bc
ld hl, MoveDeleterOneMoveText
call PrintText
jp TextScriptEnd
.chooseMove
push bc
xor a
ld [wListScrollOffset], a
ld [wCurrentMenuItem], a
ld hl, MoveDeleterWhichMoveText
call PrintText
ld a, MOVESLISTMENU
ld [wListMenuID], a
ld de, wRelearnableMoves
ld hl, wList
ld [hl], e
inc hl
ld [hl], d
xor a
ld [wcf93], a ; don't print prices
call DisplayListMenuID
pop bc
jr c, .exit ; exit if player chose cancel
; Save the selected move id.
ld a, [wcf91]
ld d, a
push de
push bc
ld [wMoveNum], a
ld [wd11e],a
call GetMoveName
call CopyStringToCF4B ; copy name to wcf4b
ld hl, MoveDeleterConfirmText
call PrintText
call YesNoChoice
pop bc
pop de
ld a, [wCurrentMenuItem]
and a
jr nz, .chooseMove
push de
ld a, b ; a = mon index
ld hl, wPartyMon1Moves
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
; hl = pointer to mon's moves
; Search for the move, and set it to 0.
pop de ; d = move id
call DeleteMove
ld hl, MoveDeleterForgotText
call PrintText
.exit
ld hl, MoveDeleterByeText
call PrintText
jp TextScriptEnd

DeleteMove:
; d = move id
ld b, 0
.searchLoop
ld a, [hli]
cp d
jr z, .foundMoveLoop
inc b
jr .searchLoop
.foundMoveLoop
ld a, b
cp 3
jr z, .zeroLastMove
ld a, [hl]
dec hl
ld [hli], a
inc hl
inc b
jr .foundMoveLoop
.zeroLastMove
dec hl
xor a
ld [hl], a
ret

PrepareDeletableMoveList:
; Places a list of the selected pokemon's moves at wDeletableMoves.
; First byte is count, and last byte is $ff.
; Input: party mon index = [wWhichPokemon]
ld a, [wWhichPokemon]
ld hl, wPartyMon1Moves
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
; hl = pointer to mon's 4 moves
ld b, 0 ; count of moves
ld c, 4 + 1 ; 4 moves
ld de, wDeletableMoves + 1
.loop
dec c
jr z, .done
ld a, [hli]
and a
jr z, .loop
ld [de], a
inc de
inc b
jr .loop
.done
ld a, $ff ; terminate the list
ld [de], a
ld a, b ; store number of moves
ld [wDeletableMoves], a
ret

MoveDeleterGreetingText:
TX_FAR _MoveDeleterGreetingText
db "@"

MoveDeleterSaidYesText:
TX_FAR _MoveDeleterSaidYesText
db "@"

MoveDeleterWhichMoveText:
TX_FAR _MoveDeleterWhichMoveText
db "@"

MoveDeleterConfirmText:
TX_FAR _MoveDeleterConfirmText
db "@"

MoveDeleterForgotText:
TX_FAR _MoveDeleterForgotText
db "@"

MoveDeleterByeText:
TX_FAR _MoveDeleterByeText
db "@"

MoveDeleterOneMoveText:
TX_FAR _MoveDeleterOneMoveText
db "@"
2 changes: 2 additions & 0 deletions scripts/move_relearner.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ MoveRelearnerText1:
ld [hl], e
inc hl
ld [hl], d
xor a
ld [wcf93], a ; don't print prices
call DisplayListMenuID
pop bc
jr c, .exit ; exit if player chose cancel
Expand Down
1 change: 1 addition & 0 deletions text.asm
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ INCLUDE "text/maps/seafoam_islands_b2f.asm"
INCLUDE "text/maps/seafoam_islands_b3f.asm"
INCLUDE "text/maps/seafoam_islands_b4f.asm"
INCLUDE "text/maps/move_relearner.asm"
INCLUDE "text/maps/move_deleter.asm"

_AIBattleWithdrawText:: ; 880be (22:40be)
TX_RAM W_TRAINERNAME
Expand Down
49 changes: 49 additions & 0 deletions text/maps/move_deleter.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
_MoveDeleterGreetingText::
text "Umm..."

para "Oh, yes, I'm the"
line "MOVE DELETER."

para "I can make"
line "#MON forget"
cont "moves."

para "Shall I make a"
line "#MON forget?"
done

_MoveDeleterSaidYesText::
text "Which #MON"
line "should forget a"
cont "move?"
prompt

_MoveDeleterWhichMoveText::
text "Which move should"
line "it forget, then?"
done

_MoveDeleterConfirmText::
text "Make it forget"
line "@"
TX_RAM wcf4b
text "?"
prompt

_MoveDeleterForgotText::
text "@"
TX_RAM wcf4b
text " was"
line "forgotten!"
prompt

_MoveDeleterByeText::
text "Come visit me"
line "again!"
done

_MoveDeleterOneMoveText::
text "That #MON"
line "knows only one"
cont "move."
done
6 changes: 4 additions & 2 deletions wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,10 @@ wRelearnableMoves::
; List of move ids that can be re-learend (Move Relearner)
; First byte is the number of moves in this list.
; List is terminated with $ff
wMoveRelearnerFlags::
; Bit 0 is set if a move was replaced. Reset if player canceled.
wDeletableMoves::
; List of move ids that can be deleted (Move Deleter)
; First byte is the number of moves in this list.
; List is terminated with $ff
ds 10

wcca1:: ds 49
Expand Down

0 comments on commit 4d70995

Please sign in to comment.