summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rwxr-xr-xengine/evos_moves.asm66
-rwxr-xr-xengine/items/items.asm12
-rwxr-xr-xengine/menu/party_menu.asm91
-rwxr-xr-xengine/menu/start_sub_menus.asm1
4 files changed, 160 insertions, 10 deletions
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 056c125e..384d6bf6 100755
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -1,3 +1,38 @@
+DevolvePokemon:
+ ld a, [hTilesetType]
+ push af
+ push hl
+ push bc
+ push de
+ ld a, [wWhichPokemon]
+ ld hl, wPartySpecies
+ ld c, a
+ ld b, 0
+ add hl, bc
+ push hl
+ ld a, [hl]
+ ld [wBuffer], a
+ ld a, [wWhichPokemon]
+ ld hl, wDevolveMons
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr nz, .devolve
+ pop hl
+ pop de
+ pop bc
+ pop hl
+ pop af
+ xor a
+ ld [wEvolutionOccurred], a
+ ret
+.devolve
+ ld [wBuffer + 1], a
+ ld a, 2
+ jp ForceDevolve
+
; try to evolve the mon in [wWhichPokemon]
TryEvolvingMon: ; 3ad0e (e:6d0e)
ld hl, wCanEvolveFlags
@@ -30,7 +65,7 @@ Evolution_PartyMonLoop: ; loop over party mons
inc hl
ld a, [hl]
cp $ff ; have we reached the end of the party?
- jp z, .done
+ jp z, Evolution_done
ld [wEvoOldSpecies], a
push hl
ld a, [wWhichPokemon]
@@ -62,7 +97,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld [wcf91], a
pop hl
-.evoEntryLoop ; loop over evolution entries
+evoEntryLoop: ; loop over evolution entries
ld a, [hli]
and a ; have we reached the end of the evolution data?
jr z, Evolution_PartyMonLoop
@@ -85,7 +120,7 @@ Evolution_PartyMonLoop: ; loop over party mons
.checkTradeEvo
ld a, [wLinkState]
cp LINK_STATE_TRADING
- jp nz, .nextEvoEntry1 ; if not trading, go to the next evolution entry
+ jp nz, nextEvoEntry1 ; if not trading, go to the next evolution entry
ld a, [hli] ; level requirement
ld b, a
ld a, [wLoadedMonLevel]
@@ -97,16 +132,17 @@ Evolution_PartyMonLoop: ; loop over party mons
ld b, a ; evolution item
ld a, [wcf91] ; this is supposed to be the last item used, but it is also used to hold species numbers
cp b ; was the evolution item in this entry used?
- jp nz, .nextEvoEntry1 ; if not, go to the next evolution entry
+ jp nz, nextEvoEntry1 ; if not, go to the next evolution entry
.checkLevel
ld a, [hli] ; level requirement
ld b, a
ld a, [wLoadedMonLevel]
cp b ; is the mon's level greater than the evolution requirement?
- jp c, .nextEvoEntry2 ; if so, go the next evolution entry
+ jp c, nextEvoEntry2 ; if so, go the next evolution entry
.doEvolution
ld [W_CURENEMYLVL], a
ld a, 1
+ForceDevolve:
ld [wEvolutionOccurred], a
push hl
ld a, [hl]
@@ -180,6 +216,9 @@ Evolution_PartyMonLoop: ; loop over party mons
ld e, l
ld d, h
push hl
+ ld a, [wEvolutionOccurred]
+ cp 2
+ jr z, .skipStatChanges
push bc
ld bc, wPartyMon1MaxHP - wPartyMon1
add hl, bc
@@ -203,6 +242,13 @@ Evolution_PartyMonLoop: ; loop over party mons
dec hl
pop bc
call CopyData
+ jr .statChangesDone
+.skipStatChanges
+ ld a, [wLoadedMon]
+ ld [wPartyMon1], a
+ ld a, 1
+ ld [wEvolutionOccurred], a
+.statChangesDone
ld a, [wd0b5]
ld [wd11e], a
xor a
@@ -231,16 +277,16 @@ Evolution_PartyMonLoop: ; loop over party mons
push hl
ld l, e
ld h, d
- jr .nextEvoEntry2
+ jr nextEvoEntry2
-.nextEvoEntry1
+nextEvoEntry1:
inc hl
-.nextEvoEntry2
+nextEvoEntry2:
inc hl
- jp .evoEntryLoop
+ jp evoEntryLoop
-.done
+Evolution_done:
pop de
pop bc
pop hl
diff --git a/engine/items/items.asm b/engine/items/items.asm
index c996ba96..334eea67 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -114,6 +114,7 @@ ItemUsePtrTable: ; d5e1 (3:55e1)
dw UnusableItem ; FLOOR_11F
dw UnusableItem ; FLOOR_B4F
dw ItemUseEvoStone ; ICE_STONE
+ dw ItemUseEvoStone ; DEVOLVE_STONE
ItemUseBall: ; d687 (3:5687)
ld a,[W_ISINBATTLE]
@@ -643,9 +644,13 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
+ cp DEVOLVE_STONE
ld [wEvoStoneItemID],a
push af
+ ld a,DEVO_STONE_PARTY_MENU
+ jr z, .devolveMenu
ld a,EVO_STONE_PARTY_MENU
+.devolveMenu
ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
@@ -659,7 +664,14 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,SFX_HEAL_AILMENT
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
+ ld a, [wPartyMenuTypeOrMessageID]
+ cp DEVO_STONE_PARTY_MENU
+ jr z, .devolvePokemon
callab TryEvolvingMon ; try to evolve pokemon
+ jr .doneEvolving
+.devolvePokemon
+ callab DevolvePokemon
+.doneEvolving
ld a,[wEvolutionOccurred]
and a
jr z,.noEffect
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index fb07766d..059d25d2 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -7,6 +7,7 @@
; 03: learn TM/HM menu
; 04: swap pokemon positions menu
; 05: use evolution stone on pokemon menu
+; 06: use devolution stone on pokemon menu
; otherwise, it is a message ID
; f0: poison healed
; f1: burn healed
@@ -36,6 +37,16 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld c,a
ld [hPartyMonIndex],a
ld [wWhichPartyMenuHPBar],a
+ push hl
+ push bc
+ ld hl, wEvolutionData
+ ld b, 6
+.clearDevolveMons
+ ld [hli], a
+ dec b
+ jr nz, .clearDevolveMons
+ pop bc
+ pop hl
.loop
ld a,[de]
cp a,$FF ; reached the terminator?
@@ -80,6 +91,8 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
jr z,.teachMoveMenu
cp a,EVO_STONE_PARTY_MENU
jr z,.evolutionStoneMenu
+ cp a,DEVO_STONE_PARTY_MENU
+ jp z,.devolutionStoneMenu
push hl
ld bc,14 ; 14 columns to the right
add hl,bc
@@ -187,6 +200,83 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
db "ABLE@"
.notAbleToEvolveText
db "NOT ABLE@"
+
+.devolutionStoneMenu
+ push hl
+ xor a
+.loadEvolutionDataLoop
+ push af
+ ld hl, EvosMovesPointerTable
+ ld b, 0
+ add a
+ rl b
+ ld c, a
+ add hl, bc
+ ld de, wcd6d
+ ld a, BANK(EvosMovesPointerTable)
+ ld bc, 2
+ call FarCopyData
+ ld hl, wcd6d
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wEvolutionData
+ ld a, BANK(EvosMovesPointerTable)
+ ld bc, Mon133_EvosEnd - Mon133_EvosMoves
+ call FarCopyData
+ ld hl, wEvolutionData
+; loop through the pokemon's evolution entries
+.checkDevolutionsLoop
+ ld a, [hli]
+ and a ; reached terminator?
+ jr nz, .keepChecking
+ pop af
+ inc a
+ cp VICTREEBEL
+ ld de, .notAbleToDevolveText
+ jr z, .placeDevolutionStoneString
+ jr .loadEvolutionDataLoop
+.keepChecking
+ inc hl
+ cp a, EV_ITEM
+ jr nz, .skipinc
+ inc hl
+.skipinc
+ ld a, [wWhichPokemon] ; pokemon number
+ ld c, a
+ ld b, 0
+ ld a, [hli] ; evolved mon id
+ push hl
+ ld hl, wPartySpecies
+ add hl, bc
+ ld b, a
+ ld a, [hl]
+ pop hl
+ cp b ; does the player's pokemon match this evolution entry's evolution?
+ jr nz, .checkDevolutionsLoop
+; if it does match
+ ld hl, wDevolveMons
+ ld a, [wWhichPokemon]
+ ld e, a
+ ld d, 0
+ add hl, de
+ pop af
+ inc a
+ ld [hl], a
+ ld de, .ableToDevolveText
+.placeDevolutionStoneString
+ ld bc, SCREEN_WIDTH + 9 ; down 1 row and right 9 columns
+ pop hl
+ push hl
+ add hl, bc
+ call PlaceString
+ pop hl
+ jp .printLevel
+.ableToDevolveText
+ db "ABLE@"
+.notAbleToDevolveText
+ db "NOT ABLE@"
+
.afterDrawingMonEntries
ld b, SET_PAL_PARTY_MENU
call RunPaletteCommand
@@ -252,6 +342,7 @@ PartyMenuMessagePointers: ; 12e73 (4:6e73)
dw PartyMenuUseTMText
dw PartyMenuSwapMonText
dw PartyMenuItemUseText
+ dw PartyMenuItemUseText
PartyMenuNormalText: ; 12e7f (4:6e7f)
TX_FAR _PartyMenuNormalText
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index e1dc5d98..9f5f97e0 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -485,6 +485,7 @@ UsableItems_PartyMenu: ; 13434 (4:7434)
db ELIXER
db MAX_ELIXER
db ICE_STONE
+ db DEVOLVE_STONE
db $ff
; items which close the item menu when used