ref: 48bab16ea4ef55d39a17ac190524e5e6ba5ce723
parent: 7cef3b76de65096e8f835d8780a110f88f8941c7
author: yenatch <[email protected]>
date: Wed Sep 18 17:04:16 EDT 2013
move dratini special into event/dratini.asm
--- /dev/null
+++ b/event/dratini.asm
@@ -1,0 +1,112 @@
+SpecialDratini: ; 0x8b170
+; if ScriptVar is 0 or 1, change the moveset of the last Dratini in the party.
+; 0: give it a special moveset with Extremespeed.
+; 1: give it the normal moveset of a level 15 Dratini.
+
+ ld a, [ScriptVar]
+ cp $2
+ ret nc
+ ld bc, PartyCount
+ ld a, [bc]
+ ld hl, 0
+ call GetNthPartyMon
+ ld a, [bc]
+ ld c, a
+ ld de, PartyMon2 - PartyMon1
+.CheckForDratini
+; start at the end of the party and search backwards for a Dratini
+ ld a, [hl]
+ cp DRATINI
+ jr z, .GiveMoveset
+ ld a, l
+ sub e
+ ld l, a
+ ld a, h
+ sbc d
+ ld h, a
+ dec c
+ jr nz, .CheckForDratini
+ ret
+
+.GiveMoveset
+ push hl
+ ld a, [ScriptVar]
+ ld hl, .Movesets
+ ld bc, .Moveset1 - .Moveset0
+ call AddNTimes
+
+ ; get address of mon's first move
+ pop de
+ inc de
+ inc de
+
+.GiveMoves
+ ld a, [hl]
+ and a ; is the move 00?
+ ret z ; if so, we're done here
+
+ push hl
+ push de
+ ld [de], a ; give the Pokémon the new move
+
+ ; get the PP of the new move
+ dec a
+ ld hl, Moves + PlayerMovePP - PlayerMoveStruct
+ ld bc, Move2 - Move1
+ call AddNTimes
+ ld a, BANK(Moves)
+ call GetFarByte
+
+ ; get the address of the move's PP and update the PP
+ ld hl, PartyMon1PP - PartyMon1Moves
+ add hl, de
+ ld [hl], a
+
+ pop de
+ pop hl
+ inc de
+ inc hl
+ jr .GiveMoves
+
+.Movesets
+.Moveset0
+; Dratini does not normally learn Extremespeed. This is a special gift.
+ db WRAP
+ db THUNDER_WAVE
+ db TWISTER
+ db EXTREMESPEED
+ db 0
+.Moveset1
+; This is the normal moveset of a level 15 Dratini
+ db WRAP
+ db LEER
+ db THUNDER_WAVE
+ db TWISTER
+ db 0
+
+GetNthPartyMon: ; 0x8b1ce
+; inputs:
+; hl must be set to 0 before calling this function.
+; a must be set to the number of Pokémon in the party.
+
+; outputs:
+; returns the address of the last Pokémon in the party in hl.
+; sets carry if a is 0.
+
+ ld de, PartyMon1
+ add hl, de
+ and a
+ jr z, .EmptyParty
+ dec a
+ ret z
+ ld de, PartyMon2 - PartyMon1
+.loop
+ add hl, de
+ dec a
+ jr nz, .loop
+ ret
+.EmptyParty
+ scf
+ ret
+; 8b1e1
+
--- a/main.asm
+++ b/main.asm
@@ -61400,116 +61400,7 @@
INCBIN "baserom.gbc", $8b15e, $8b170 - $8b15e
-SpecialDratini: ; 0x8b170
-; if ScriptVar is 0 or 1, change the moveset of the last Dratini in the party.
-; 0: give it a special moveset with Extremespeed.
-; 1: give it the normal moveset of a level 15 Dratini.
-
- ld a, [ScriptVar]
- cp $2
- ret nc
- ld bc, PartyCount
- ld a, [bc]
- ld hl, 0
- call GetNthPartyMon
- ld a, [bc]
- ld c, a
- ld de, PartyMon2 - PartyMon1
-.CheckForDratini
-; start at the end of the party and search backwards for a Dratini
- ld a, [hl]
- cp DRATINI
- jr z, .GiveMoveset
- ld a, l
- sub e
- ld l, a
- ld a, h
- sbc d
- ld h, a
- dec c
- jr nz, .CheckForDratini
- ret
-
-.GiveMoveset
- push hl
- ld a, [ScriptVar]
- ld hl, .Movesets
- ld bc, .Moveset1 - .Moveset0
- call AddNTimes
-
- ; get address of mon's first move
- pop de
- inc de
- inc de
-
-.GiveMoves
- ld a, [hl]
- and a ; is the move 00?
- ret z ; if so, we're done here
-
- push hl
- push de
- ld [de], a ; give the Pokémon the new move
-
- ; get the PP of the new move
- dec a
- ld hl, Moves + PlayerMovePP - PlayerMoveStruct
- ld bc, Move2 - Move1
- call AddNTimes
- ld a, BANK(Moves)
- call GetFarByte
-
- ; get the address of the move's PP and update the PP
- ld hl, PartyMon1PP - PartyMon1Moves
- add hl, de
- ld [hl], a
-
- pop de
- pop hl
- inc de
- inc hl
- jr .GiveMoves
-
-.Movesets
-.Moveset0
-; Dratini does not normally learn Extremespeed. This is a special gift.
- db WRAP
- db THUNDER_WAVE
- db TWISTER
- db EXTREMESPEED
- db 0
-.Moveset1
-; This is the normal moveset of a level 15 Dratini
- db WRAP
- db LEER
- db THUNDER_WAVE
- db TWISTER
- db 0
-
-GetNthPartyMon: ; 0x8b1ce
-; inputs:
-; hl must be set to 0 before calling this function.
-; a must be set to the number of Pokémon in the party.
-
-; outputs:
-; returns the address of the last Pokémon in the party in hl.
-; sets carry if a is 0.
-
- ld de, PartyMon1
- add hl, de
- and a
- jr z, .EmptyParty
- dec a
- ret z
- ld de, PartyMon2 - PartyMon1
-.loop
- add hl, de
- dec a
- jr nz, .loop
- ret
-.EmptyParty
- scf
- ret
+INCLUDE "event/dratini.asm"
Function8b1e1: ; 8b1e1
ld de, $71ed