add constants for volatile statuses and more battle labels/commentary/constants

This commit is contained in:
xCrystal 2015-02-03 20:51:53 +01:00 committed by yenatch
parent 97637e7ce7
commit 9de54645c8
14 changed files with 341 additions and 302 deletions

View file

@ -1,6 +1,32 @@
; status ailments
SLP EQU %111 ; mask
; non-volatile statuses
SLP EQU %111 ; sleep counter
PSN EQU 3
BRN EQU 4
FRZ EQU 5
PAR EQU 6
; volatile statuses 1
StoringEnergy EQU 0 ; Bide
ThrashingAbout EQU 1 ; e.g. Thrash
AttackingMultipleTimes EQU 2 ; e.g. Double Kick, Fury Attack
Flinched EQU 3
ChargingUp EQU 4 ; e.g. Solar Beam, Fly
UsingTrappingMove EQU 5 ; e.g. Wrap
Invulnerable EQU 6 ; charging up Fly/Dig
Confused EQU 7
; volatile statuses 2
UsingXAccuracy EQU 0
ProtectedByMist EQU 1
GettingPumped EQU 2 ; Focus Energy
; EQU 3 ; unused?
HasSubstituteUp EQU 4
NeedsToRecharge EQU 5 ; Hyper Beam
UsingRage EQU 6
Seeded EQU 7
; volatile statuses 3
BadlyPoisoned EQU 0
HasLightScreenUp EQU 1
HasReflectUp EQU 2
Transformed EQU 3

View file

@ -1,5 +1,5 @@
DrainHPEffect_: ; 783f (1:783f)
ld hl, W_DAMAGE ; W_DAMAGE
ld hl, W_DAMAGE
ld a, [hl]
srl a ; divide damage by 2
ld [hli], a
@ -16,8 +16,8 @@ DrainHPEffect_: ; 783f (1:783f)
ld a, [H_WHOSETURN] ; $fff3
and a
jp z, Func_7861
ld hl, wEnemyMonHP ; wEnemyMonHP
ld de, wEnemyMonMaxHP ; wEnemyMonMaxHP
ld hl, wEnemyMonHP
ld de, wEnemyMonMaxHP
Func_7861: ; 7861 (1:7861)
ld bc, wHPBarOldHP+1
@ -38,7 +38,7 @@ Func_7861: ; 7861 (1:7861)
add b
ld [hld], a
ld [wHPBarNewHP], a
ld a, [W_DAMAGE] ; W_DAMAGE
ld a, [W_DAMAGE]
ld b, [hl]
adc b
ld [hli], a
@ -83,7 +83,7 @@ Func_7861: ; 7861 (1:7861)
and a
ld a, [W_PLAYERMOVEEFFECT] ; wcfd3
jr z, .asm_78d2
ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT
ld a, [W_ENEMYMOVEEFFECT]
.asm_78d2
cp DREAM_EATER_EFFECT
jr nz, .asm_78d9

View file

@ -13,7 +13,7 @@ Func_525af: ; 525af (14:65af)
ld [wCriticalHitOrOHKO], a
ld [wBattleMonSpecies], a
ld [wPartyGainExpFlags], a
ld [wPlayerMonNumber], a ; wPlayerMonNumber
ld [wPlayerMonNumber], a
ld [wEscapedFromBattle], a
ld [wMapPalOffset], a
ld hl, wcf1d
@ -27,7 +27,7 @@ Func_525af: ; 525af (14:65af)
jr nz, .asm_525e1
inc a
ld [wccd9], a
ld a, [W_CURMAP] ; W_CURMAP
ld a, [W_CURMAP]
cp SAFARI_ZONE_EAST
jr c, .asm_525f9
cp SAFARI_ZONE_REST_HOUSE_1
@ -45,7 +45,7 @@ ParalyzeEffect_: ; 52601 (14:6601)
ld a, [H_WHOSETURN] ; $fff3
and a
jp z, .asm_52613
ld hl, wBattleMonStatus ; wBattleMonStatus
ld hl, wBattleMonStatus
ld de, W_ENEMYMOVETYPE ; wcfcf
.asm_52613
@ -69,10 +69,10 @@ ParalyzeEffect_: ; 52601 (14:6601)
push hl
callab MoveHitTest
pop hl
ld a, [W_MOVEMISSED] ; W_MOVEMISSED
ld a, [W_MOVEMISSED]
and a
jr nz, .asm_52659
set 6, [hl]
set PAR, [hl]
callab QuarterSpeedDueToParalysis
ld c, $1e
call DelayFrames

View file

@ -7,16 +7,19 @@ DecrementPP: ; 68000 (1a:4000)
ld hl, W_PLAYERBATTSTATUS1
ld a, [hli] ; load the W_PLAYERBATTSTATUS1 pokemon status flags and increment hl to load the
; W_PLAYERBATTSTATUS2 status flags later
and a, 7 ; check to see if bits 0, 1, or 2 are set
and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes)
ret nz ; if any of these statuses are true, don't decrement PP
bit 6, [hl] ; check 6th bit status flag on W_PLAYERBATTSTATUS2
ret nz ; and return if it is set
bit UsingRage, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage
ld hl, wBattleMonPP ; PP of first move (in battle)
call .DecrementPP
ld a, [W_PLAYERBATTSTATUS3] ; load pokemon status bits?
bit 3, a ; XXX transform status?
ret nz ; If it is, return. Pokemon Red stores the "current pokemon's" PP
; decrement PP in the battle struct
call .DecrementPP
; decrement PP in the party struct
ld a, [W_PLAYERBATTSTATUS3]
bit Transformed, a
ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP
; separately from the "Pokemon in your party's" PP. This is
; duplication -- in all cases *other* than Pokemon with Transform.
; Normally, this means we have to go on and make the same
@ -26,12 +29,12 @@ DecrementPP: ; 68000 (1a:4000)
; its opponent, which is *not* the same as its real PP as part of your
; party. So we return, and don't do that part.
ld hl, wPartyMon1PP ; PP of first move (in party)
ld a, [wPlayerMonNumber] ; which mon in party is active
ld bc, $2C ; XXX probably size of party pokemon's data structure
ld hl, wPartyMon1PP ; PP of first move (in party)
ld a, [wPlayerMonNumber] ; which mon in party is active
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes ; calculate address of the mon to modify
.DecrementPP
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
ld c, a
ld b, 0
add hl ,bc ; calculate the address in memory of the PP we need to decrement

View file

@ -103,15 +103,15 @@ Func_13870: ; 13870 (4:7870)
.asm_13888
callab Func_128d8
jr z, .asm_13884
ld a, [wd0db]
ld a, [wRepelRemainingSteps]
and a
jr z, .asm_1389e
dec a
jr z, .asm_13905
ld [wd0db], a
jr z, .lastRepelStep
ld [wRepelRemainingSteps], a
.asm_1389e
; determine if wild pokémon can appear where were standing.
; are we standing in grass/water?
; determine if wild pokémon can appear in the half-block were standing
; is the bottom right tile (9,9) of the half-block are we standing a grass/water tile?
hlCoord 9, 9
ld c, [hl]
ld a, [W_GRASSTILE]
@ -133,6 +133,7 @@ Func_13870: ; 13870 (4:7870)
jr z, .CantEncounter
ld a, [W_GRASSRATE]
.CanEncounter
; weigh encounter chance to a random number to determine if there will be an encounter
ld b, a
ld a, [hRandomAdd]
cp b
@ -140,20 +141,23 @@ Func_13870: ; 13870 (4:7870)
ld a, [hRandomSub]
ld b, a
ld hl, WildMonEncounterSlotChances
.asm_138d0
.determineEncounterSlot
ld a, [hli]
cp b
jr nc, .asm_138d7
jr nc, .gotEncounterSlot
inc hl
jr .asm_138d0
.asm_138d7
jr .determineEncounterSlot
.gotEncounterSlot
; determine which wild pokémon (grass or water) can appear in the half-block were standing
ld c, [hl]
ld hl, W_GRASSMONS
aCoord 8, 9
cp $14
jr nz, .asm_138e5
aCoord 8, 9
cp $14 ; is the bottom left tile (8,9) of the half-block are we standing a water tile?
jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default
ld hl, W_WATERMONS
.asm_138e5
; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not,
; "left shore" half-blocks (such as the one in the east coast of Cinnabar), load grass encounters.
.gotWildEncounterType
ld b, $0
add hl, bc
ld a, [hli]
@ -161,17 +165,17 @@ Func_13870: ; 13870 (4:7870)
ld a, [hl]
ld [wcf91], a
ld [wEnemyMonSpecies2], a
ld a, [wd0db]
ld a, [wRepelRemainingSteps]
and a
jr z, .asm_13916
jr z, .willEncounter
ld a, [wPartyMon1Level]
ld b, a
ld a, [W_CURENEMYLVL]
cp b
jr c, .CantEncounter
jr .asm_13916
.asm_13905
ld [wd0db], a
jr .willEncounter
.lastRepelStep
ld [wRepelRemainingSteps], a
ld a, $d2
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call EnableAutoTextBoxDrawing
@ -180,7 +184,7 @@ Func_13870: ; 13870 (4:7870)
ld a, $1
and a
ret
.asm_13916
.willEncounter
xor a
ret
@ -282,7 +286,7 @@ ConversionEffect_: ; 139a3 (4:79a3)
pop de
ld a, [W_PLAYERBATTSTATUS1]
.asm_139b8
bit 6, a ; is mon immune to typical attacks (dig/fly)
bit Invulnerable, a ; is mon immune to typical attacks (dig/fly)
jr nz, PrintButItFailedText
ld a, [hli]
ld [de], a
@ -340,22 +344,22 @@ HazeEffect_: ; 139da (4:79da)
ld [hli], a
ld [hl], a
ld hl, W_PLAYERBATTSTATUS1
call Func_13a37
call CureStatuses
ld hl, W_ENEMYBATTSTATUS1
call Func_13a37
call CureStatuses
ld hl, Func_3fba8
call Func_139d5
ld hl, StatusChangesEliminatedText
jp PrintText
Func_13a37: ; 13a37 (4:7a37)
res 7, [hl]
inc hl
CureStatuses: ; 13a37 (4:7a37)
res Confused, [hl]
inc hl ; BATTSTATUS2
ld a, [hl]
and $78
ld [hli], a
and (1 << UsingRage) | (1 << NeedsToRecharge) | (1 << HasSubstituteUp) | (1 << 3) ; clear all but these from BATTSTATUS2
ld [hli], a ; BATTSTATUS3
ld a, [hl]
and $f8
and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses
ld [hl], a
ret
@ -382,8 +386,8 @@ StatusChangesEliminatedText: ; 13a53 (4:7a53)
db "@"
GetTrainerName_: ; 13a58 (4:7a58)
ld hl, W_GRASSRATE ; W_GRASSRATE
ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE
ld hl, W_GRASSRATE
ld a, [W_ISLINKBATTLE]
and a
jr nz, .rival
ld hl, W_RIVALNAME ; wd34a

View file

@ -12,7 +12,7 @@ SubstituteEffectHandler: ; 17dad (5:7dad)
ld bc, W_ENEMYBATTSTATUS2
.notEnemy
ld a, [bc] ;load flags
bit 4, a ;user already has substitute?
bit HasSubstituteUp, a ;user already has substitute?
jr nz, .alreadyHasSubstitute ;skip this code if so
;user doesn't have a substitute [yet]
push bc
@ -41,13 +41,13 @@ SubstituteEffectHandler: ; 17dad (5:7dad)
ld [hl], d ;store low byte HP
ld h, b
ld l, c
set 4, [hl] ;set bit 4 of flags, user now has substitute
ld a, [W_OPTIONS] ;load options
bit 7, a ;battle animation is enabled?
ld hl, Func_3fba8 ; $7ba8 ;animation enabled: 0F:7BA8
set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute
ld a, [W_OPTIONS] ;load options
bit 7, a ;battle animation is enabled?
ld hl, Func_3fba8 ;animation enabled: 0F:7BA8
ld b, BANK(Func_3fba8)
jr z, .animationEnabled
ld hl, AnimationSubstitute ;animation disabled: 1E:56E0
ld hl, AnimationSubstitute ;animation disabled: 1E:56E0
ld b, BANK(AnimationSubstitute)
.animationEnabled
call Bankswitch ;jump to routine depending on animation setting

View file

@ -163,9 +163,9 @@ FocusEnergyEffect_: ; 27f86 (9:7f86)
jr z, .asm_27f91
ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2
.asm_27f91
bit 2, [hl] ; is mon already using focus energy?
bit GettingPumped, [hl] ; is mon already using focus energy?
jr nz, .asm_27fa5
set 2, [hl] ; mon is now using focus energy
set GettingPumped, [hl] ; mon is now using focus energy
callab Func_3fba8
ld hl, GettingPumpedText ; $7fb2
jp PrintText

View file

@ -18,9 +18,9 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9)
ld a, [de]
cp GRASS
jr z, .asm_2bee7
bit 7, [hl]
bit Seeded, [hl]
jr nz, .asm_2bee7
set 7, [hl]
set Seeded, [hl]
callab Func_3fba8
ld hl, WasSeededText ; $7ef2
jp PrintText

View file

@ -95,27 +95,27 @@ PayDayEffect_ ; 2feb8 (b:7eb8)
ld a, [wEnemyMonLevel]
.asm_2fec8
add a
ld [$ff98], a
ld [H_DIVIDEND + 3], a
xor a
ld [$ff95], a
ld [$ff96], a
ld [$ff97], a
ld [H_DIVIDEND], a
ld [H_DIVIDEND + 1], a
ld [H_DIVIDEND + 2], a
ld a, $64
ld [$ff99], a
ld [H_DIVISOR], a
ld b, $4
call Divide
ld a, [$ff98]
ld a, [H_QUOTIENT + 3]
ld [hli], a
ld a, [$ff99]
ld [$ff98], a
ld a, [H_REMAINDER]
ld [H_DIVIDEND + 3], a
ld a, $a
ld [$ff99], a
ld [H_DIVISOR], a
ld b, $4
call Divide
ld a, [$ff98]
ld a, [H_QUOTIENT + 3]
swap a
ld b, a
ld a, [$ff99]
ld a, [H_REMAINDER]
add b
ld [hl], a
ld de, wTotalPayDayMoney + 2

View file

@ -5,9 +5,9 @@ MistEffect_: ; 33f2b (c:7f2b)
jr z, .asm_33f36
ld hl, W_ENEMYBATTSTATUS2
.asm_33f36
bit 1, [hl] ; is mon protected by mist?
bit ProtectedByMist, [hl] ; is mon protected by mist?
jr nz, .asm_33f4a
set 1, [hl] ; mon is now protected by mist
set ProtectedByMist, [hl] ; mon is now protected by mist
callab Func_3fba8
ld hl, ShroudedInMistText
jp PrintText
@ -21,7 +21,7 @@ ShroudedInMistText: ; 33f52 (c:7f52)
db "@"
OneHitKOEffect_: ; 33f57 (c:7f57)
ld hl, W_DAMAGE ; W_DAMAGE
ld hl, W_DAMAGE
xor a
ld [hli], a
ld [hl], a ; set the damage output to zero
@ -45,7 +45,7 @@ OneHitKOEffect_: ; 33f57 (c:7f57)
ld a, [hl]
sbc b
jr c, .asm_33f8a
ld hl, W_DAMAGE ; W_DAMAGE
ld hl, W_DAMAGE
ld a, $ff
ld [hli], a
ld [hl], a
@ -54,5 +54,5 @@ OneHitKOEffect_: ; 33f57 (c:7f57)
ret
.asm_33f8a
ld a, $1
ld [W_MOVEMISSED], a ; W_MOVEMISSED
ld [W_MOVEMISSED], a
ret

File diff suppressed because it is too large Load diff

View file

@ -130,7 +130,7 @@ TransformEffect_: ; 3bab1 (e:7ab1)
ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex
ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1
.asm_3bad1
bit 6, a ; is mon invulnerable to typical attacks? (fly/dig)
bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig)
jp nz, Func_3bb8c
push hl
push de
@ -141,7 +141,7 @@ TransformEffect_: ; 3bab1 (e:7ab1)
jr z, .asm_3bae4
ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2
.asm_3bae4
bit 4, [hl]
bit HasSubstituteUp, [hl]
push af
ld hl, Func_79747
ld b, BANK(Func_79747)
@ -161,7 +161,7 @@ TransformEffect_: ; 3bab1 (e:7ab1)
call nz, Bankswitch
pop bc
ld a, [bc]
set 3, a
set Transformed, a
ld [bc], a
pop de
pop hl
@ -267,15 +267,15 @@ ReflectLightScreenEffect_: ; 3bb97 (e:7b97)
ld a, [de]
cp LIGHT_SCREEN_EFFECT
jr nz, .reflect
bit 1, [hl] ; is mon already protected by light screen?
bit HasLightScreenUp, [hl] ; is mon already protected by light screen?
jr nz, .moveFailed
set 1, [hl] ; mon is now protected by light screen
set HasLightScreenUp, [hl] ; mon is now protected by light screen
ld hl, LightScreenProtectedText ; $7bd7
jr .asm_3bbc1
.reflect
bit 2, [hl] ; is mon already protected by reflect?
bit HasReflectUp, [hl] ; is mon already protected by reflect?
jr nz, .moveFailed
set 2, [hl] ; mon is now protected by reflect
set HasReflectUp, [hl] ; mon is now protected by reflect
ld hl, ReflectGainedArmorText ; $7bdc
.asm_3bbc1
push hl

View file

@ -357,13 +357,13 @@ ItemUseBall: ; d687 (3:5687)
push af ;...and status ailments
push hl
ld hl,W_ENEMYBATTSTATUS3
bit 3,[hl]
bit Transformed,[hl]
jr z,.next15
ld a,$4c
ld [wEnemyMonSpecies2],a
jr .next16
.next15 ;$5871
set 3,[hl]
set Transformed,[hl]
ld hl,wcceb
ld a,[wEnemyMonDVs]
ld [hli],a
@ -770,7 +770,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
push hl
ld hl,W_PLAYERBATTSTATUS3
res 0,[hl] ; heal Toxic status
res BadlyPoisoned,[hl] ; heal Toxic status
pop hl
ld bc,30
add hl,bc ; hl now points to party stats
@ -1407,7 +1407,7 @@ ItemUseRepelCommon: ; e005 (3:6005)
and a
jp nz,ItemUseNotTime
ld a,b
ld [wd0db],a
ld [wRepelRemainingSteps],a
jp PrintItemUseTextAndRemoveItem
; handles X Accuracy item
@ -1416,7 +1416,7 @@ ItemUseXAccuracy: ; e013 (3:6013)
and a
jp z,ItemUseNotTime
ld hl,W_PLAYERBATTSTATUS2
set 0,[hl] ; X Accuracy bit
set UsingXAccuracy,[hl] ; X Accuracy bit
jp PrintItemUseTextAndRemoveItem
; This function is bugged and never works. It always jumps to ItemUseNotTime.
@ -1525,7 +1525,7 @@ ItemUseGuardSpec: ; e0dc (3:60dc)
and a
jp z,ItemUseNotTime
ld hl,W_PLAYERBATTSTATUS2
set 1,[hl] ; Mist bit
set ProtectedByMist,[hl] ; Mist bit
jp PrintItemUseTextAndRemoveItem
ItemUseSuperRepel: ; e0eb (3:60eb)
@ -1541,7 +1541,7 @@ ItemUseDireHit: ; e0f5 (3:60f5)
and a
jp z,ItemUseNotTime
ld hl,W_PLAYERBATTSTATUS2
set 2,[hl] ; Focus Energy bit
set GettingPumped,[hl] ; Focus Energy bit
jp PrintItemUseTextAndRemoveItem
ItemUseXStat: ; e104 (3:6104)

View file

@ -348,7 +348,8 @@ wPlayerSelectedMove:: ; ccdc
wEnemySelectedMove:: ; ccdd
ds 1
wccde:: ds 1
wLinkBattleRNCount:: ; ccde
ds 1
wAICount:: ; ccdf
; number of times remaining that AI action can occur
@ -1178,7 +1179,10 @@ W_DAMAGE:: ; d0d7
ds 1
wd0d8:: ds 3
wd0db:: ds 1
wRepelRemainingSteps:: ; wd0db
ds 1
wd0dc:: ds 4
wd0e0:: ds 1
wd0e1:: ds 56