shithub: pokered

Download patch

ref: f658aff5383fa1e22343efc17e4551c6e7685a39
parent: 525f1b96f390a7b7625574405cad56277f200ef3
author: YamaArashi <shadow962@live.com>
date: Fri Aug 7 01:20:37 EDT 2015

named wram variables

--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -2956,7 +2956,7 @@
 	ld a,[W_ISINBATTLE]
 	cp a,2
 	jr z,.BlockBall ; if in trainer battle, play different animation
-	ld a,[wd11e]
+	ld a,[wPokeBallAnimData]
 	ld b,a
 
 	; upper nybble: how many animations (from PokeBallAnimations) to play
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -2962,7 +2962,7 @@
 	lb bc, 1, 2
 	call PrintNumber
 	coord hl, 8, 11
-	ld de, wd11e
+	ld de, wMaxPP
 	lb bc, 1, 2
 	call PrintNumber
 	call GetCurrentMove
@@ -5287,7 +5287,7 @@
 	ld d,a    ; d = type 1 of defender
 	ld e,[hl] ; e = type 2 of defender
 	ld a,[W_PLAYERMOVETYPE]
-	ld [wd11e],a
+	ld [wMoveType],a
 	ld a,[H_WHOSETURN]
 	and a
 	jr z,.next
@@ -5301,9 +5301,9 @@
 	ld d,a    ; d = type 1 of defender
 	ld e,[hl] ; e = type 2 of defender
 	ld a,[W_ENEMYMOVETYPE]
-	ld [wd11e],a
+	ld [wMoveType],a
 .next
-	ld a,[wd11e] ; move type
+	ld a,[wMoveType]
 	cp b ; does the move type match type 1 of the attacker?
 	jr z,.sameTypeAttackBonus
 	cp c ; does the move type match type 2 of the attacker?
@@ -5328,8 +5328,8 @@
 	ld hl,wDamageMultipliers
 	set 7,[hl]
 .skipSameTypeAttackBonus
-	ld a,[wd11e]
-	ld b,a ; b = move type
+	ld a,[wMoveType]
+	ld b,a
 	ld hl,TypeEffects
 .loop
 	ld a,[hli] ; a = "attacking type" of the current type pair
@@ -5392,29 +5392,29 @@
 ; function to tell how effective the type of an enemy attack is on the player's current pokemon
 ; this doesn't take into account the effects that dual types can have
 ; (e.g. 4x weakness / resistance, weaknesses and resistances canceling)
-; the result is stored in [wd11e]
+; the result is stored in [wTypeEffectiveness]
 ; ($05 is not very effective, $10 is neutral, $14 is super effective)
 ; as far is can tell, this is only used once in some AI code to help decide which move to use
 AIGetTypeEffectiveness: ; 3e449 (f:6449)
 	ld a,[W_ENEMYMOVETYPE]
-	ld d,a                 ; d = type of enemy move
+	ld d,a                    ; d = type of enemy move
 	ld hl,wBattleMonType
-	ld b,[hl]              ; b = type 1 of player's pokemon
+	ld b,[hl]                 ; b = type 1 of player's pokemon
 	inc hl
-	ld c,[hl]              ; c = type 2 of player's pokemon
+	ld c,[hl]                 ; c = type 2 of player's pokemon
 	ld a,$10
-	ld [wd11e],a           ; initialize [wd11e] to neutral effectiveness
+	ld [wTypeEffectiveness],a ; initialize to neutral effectiveness
 	ld hl,TypeEffects
 .loop
 	ld a,[hli]
 	cp a,$ff
 	ret z
-	cp d                   ; match the type of the move
+	cp d                      ; match the type of the move
 	jr nz,.nextTypePair1
 	ld a,[hli]
-	cp b                   ; match with type 1 of pokemon
+	cp b                      ; match with type 1 of pokemon
 	jr z,.done
-	cp c                   ; or match with type 2 of pokemon
+	cp c                      ; or match with type 2 of pokemon
 	jr z,.done
 	jr .nextTypePair2
 .nextTypePair1
@@ -5424,7 +5424,7 @@
 	jr .loop
 .done
 	ld a,[hl]
-	ld [wd11e],a           ; store damage multiplier
+	ld [wTypeEffectiveness],a ; store damage multiplier
 	ret
 
 INCLUDE "data/type_effects.asm"
@@ -6577,12 +6577,12 @@
 CalculateModifiedStat: ; 3eda5 (f:6da5)
 	push bc
 	push bc
-	ld a, [wd11e]
+	ld a, [wCalculateWhoseStats]
 	and a
 	ld a, c
 	ld hl, wBattleMonAttack
 	ld de, wPlayerMonUnmodifiedAttack
-	ld bc, wPlayerMonAttackMod
+	ld bc, wPlayerMonStatMods
 	jr z, .next
 	ld hl, wEnemyMonAttack
 	ld de, wEnemyMonUnmodifiedAttack
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -231,8 +231,8 @@
 	ld bc, 1 + NUM_STATS * 2
 	call CopyData
 .recalcStatChanges
-	xor a
-	ld [wd11e], a
+	xor a ; battle mon
+	ld [wCalculateWhoseStats], a
 	callab CalculateModifiedStats
 	callab ApplyBurnAndParalysisPenaltiesToPlayer
 	callab ApplyBadgeStatBoosts
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -312,7 +312,7 @@
 	ld b,$63
 .next12
 	ld a,b
-	ld [wd11e],a
+	ld [wPokeBallAnimData],a
 .BallSuccess2
 	ld c,20
 	call DelayFrames
@@ -331,7 +331,7 @@
 	ld [wcf91],a
 	pop af
 	ld [wWhichPokemon],a
-	ld a,[wd11e]
+	ld a,[wPokeBallAnimData]
 	cp a,$10
 	ld hl,ItemUseBallText00
 	jp z,.printText0
@@ -1895,7 +1895,7 @@
 	ld [wPlayerMoveListIndex],a
 	jr nz,.chooseMon
 	ld hl,wPartyMon1Moves
-	ld bc,44
+	ld bc, wPartyMon2 - wPartyMon1
 	call GetSelectedMoveOffset
 	push hl
 	ld a,[hl]
@@ -1937,7 +1937,7 @@
 	cp b ; is the pokemon whose PP was restored active in battle?
 	jr nz,.skipUpdatingInBattleData
 	ld hl,wPartyMon1PP
-	ld bc,44
+	ld bc, wPartyMon2 - wPartyMon1
 	call AddNTimes
 	ld de,wBattleMonPP
 	ld bc,4
@@ -1959,12 +1959,12 @@
 	ld [wMonDataLocation],a
 	call GetMaxPP
 	ld hl,wPartyMon1Moves
-	ld bc,44
+	ld bc, wPartyMon2 - wPartyMon1
 	call GetSelectedMoveOffset
-	ld bc,21
+	ld bc, wPartyMon1PP - wPartyMon1Moves
 	add hl,bc ; hl now points to move's PP
-	ld a,[wd11e]
-	ld b,a ; b = max PP
+	ld a,[wMaxPP]
+	ld b,a
 	ld a,[wPPRestoreItem]
 	cp a,MAX_ETHER
 	jr z,.fullyRestorePP
@@ -2009,7 +2009,7 @@
 .elixirLoop
 	push bc
 	ld hl,wPartyMon1Moves
-	ld bc,44
+	ld bc, wPartyMon2 - wPartyMon1
 	call GetSelectedMoveOffset
 	ld a,[hl]
 	and a ; does the current slot have a move?
@@ -2283,13 +2283,10 @@
 ; also, when a PP Up is used, it increases the current PP by one PP Up bonus
 ; INPUT:
 ; [wWhichPokemon] = index of pokemon in party
-; [wd11e] = mode
-; 0: Pokemon Center healing
-; 1: using a PP Up
 ; [wCurrentMenuItem] = index of move (when using a PP Up)
 RestoreBonusPP: ; e606 (3:6606)
 	ld hl,wPartyMon1Moves
-	ld bc,44
+	ld bc, wPartyMon2 - wPartyMon1
 	ld a,[wWhichPokemon]
 	call AddNTimes
 	push hl
@@ -2296,7 +2293,7 @@
 	ld de,wNormalMaxPPList - 1
 	predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList
 	pop hl
-	ld c,21
+	ld c, wPartyMon1PP - wPartyMon1Moves
 	ld b,0
 	add hl,bc ; hl now points to move 1 PP
 	ld de,wNormalMaxPPList
@@ -2307,7 +2304,7 @@
 	ld a,b
 	cp a,5 ; reached the end of the pokemon's moves?
 	ret z ; if so, return
-	ld a,[wd11e]
+	ld a,[wUsingPPUp]
 	dec a ; using a PP Up?
 	jr nz,.skipMenuItemIDCheck
 ; if using a PP Up, check if this is the move it's being used on
@@ -2329,8 +2326,6 @@
 ; INPUT:
 ; [de] = normal max PP
 ; [hl] = move PP
-; [wd11e] = max number of times to add bonus
-; set to 1 when using a PP Up, set to 255 otherwise
 AddBonusPP: ; e642 (3:6642)
 	push bc
 	ld a,[de] ; normal max PP of move
@@ -2358,9 +2353,9 @@
 .addAmount
 	add b
 	ld b,a
-	ld a,[wd11e]
-	dec a
-	jr z,.done
+	ld a,[wUsingPPUp]
+	dec a ; is the player using a PP Up right now?
+	jr z,.done ; if so, only add the bonus once
 	dec c
 	jr nz,.loop
 .done
@@ -2379,7 +2374,7 @@
 ; 04: player's in-battle pokemon
 ; [wCurrentMenuItem] = move index
 ; OUTPUT:
-; [wd11e] = max PP
+; [wMaxPP] = max PP
 GetMaxPP: ; e677 (3:6677)
 	ld a,[wMonDataLocation]
 	and a
@@ -2432,12 +2427,12 @@
 	ld l,e
 	inc hl ; hl = wcd73
 	ld [hl],a
-	xor a
-	ld [wd11e],a ; no limit on PP Up amount
+	xor a ; add the bonus for the existing PP Up count
+	ld [wUsingPPUp],a
 	call AddBonusPP ; add bonus PP from PP Ups
 	ld a,[hl]
 	and a,%00111111 ; mask out the PP Up count
-	ld [wd11e],a ; store max PP
+	ld [wMaxPP],a ; store max PP
 	ret
 
 GetSelectedMoveOffset: ; e6e3 (3:66e3)
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -371,7 +371,7 @@
 	call PrintNumber
 	ld a, "/"
 	ld [hli], a
-	ld de, wd11e
+	ld de, wMaxPP
 	lb bc, 1, 2
 	call PrintNumber
 	pop hl
--- a/wram.asm
+++ b/wram.asm
@@ -1882,6 +1882,21 @@
 ; which will be the first mon sent out.
 	ds 1
 
+; lower nybble: number of shakes
+; upper nybble: number of animations to play
+wPokeBallAnimData:: ; d11e
+
+wUsingPPUp:: ; d11e
+
+wMaxPP:: ; d11e
+
+; 0 for player, non-zero for enemy
+wCalculateWhoseStats:: ; d11e
+
+wTypeEffectiveness:: ; d11e
+
+wMoveType:: ; d11e
+
 wNumSetBits:: ; d11e
 
 wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits