Add space between arguments in assembly instructions and remove redundant a in instructions like add a, x

This commit is contained in:
xCrystal 2017-12-30 01:54:27 +01:00
parent 94b9a86c8b
commit 237aeb8fbd
50 changed files with 7221 additions and 7221 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
DecrementPP:
; after using a move, decrement pp in battle and (if not transformed?) in party
ld a, [de]
cp a, STRUGGLE
cp STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle"
ld hl, wPlayerBattleStatus1
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
; wPlayerBattleStatus2 status flags later
and a, (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
and (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
ret nz ; if any of these statuses are true, don't decrement PP
bit USING_RAGE, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage

View file

@ -1,7 +1,7 @@
DisplayEffectiveness:
ld a, [wDamageMultipliers]
and a, $7F
cp a, $0A
and $7F
cp $0A
ret z
ld hl, SuperEffectiveText
jr nc, .done

View file

@ -1,43 +1,43 @@
ReadTrainer:
; don't change any moves in a link battle
ld a,[wLinkState]
ld a, [wLinkState]
and a
ret nz
; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF
; XXX first is total enemy pokemon?
; XXX second is species of first pokemon?
ld hl,wEnemyPartyCount
ld hl, wEnemyPartyCount
xor a
ld [hli],a
ld [hli], a
dec a
ld [hl],a
ld [hl], a
; get the pointer to trainer data for this class
ld a,[wCurOpponent]
ld a, [wCurOpponent]
sub $C9 ; convert value from pokemon to trainer
add a,a
ld hl,TrainerDataPointers
ld c,a
ld b,0
add hl,bc ; hl points to trainer class
ld a,[hli]
ld h,[hl]
ld l,a
ld a,[wTrainerNo]
ld b,a
add a
ld hl, TrainerDataPointers
ld c, a
ld b, 0
add hl, bc ; hl points to trainer class
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wTrainerNo]
ld b, a
; At this point b contains the trainer number,
; and hl points to the trainer class.
; Our next task is to iterate through the trainers,
; decrementing b each time, until we get to the right one.
.outer
dec b
jr z,.IterateTrainer
jr z, .IterateTrainer
.inner
ld a,[hli]
ld a, [hli]
and a
jr nz,.inner
jr nz, .inner
jr .outer
; if the first byte of trainer data is FF,
@ -46,17 +46,17 @@ ReadTrainer:
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
; else the first byte is the level of every pokemon on the team
.IterateTrainer
ld a,[hli]
ld a, [hli]
cp $FF ; is the trainer special?
jr z,.SpecialTrainer ; if so, check for special moves
ld [wCurEnemyLVL],a
jr z, .SpecialTrainer ; if so, check for special moves
ld [wCurEnemyLVL], a
.LoopTrainerData
ld a,[hli]
ld a, [hli]
and a ; have we reached the end of the trainer data?
jr z,.FinishUp
ld [wcf91],a ; write species somewhere (XXX why?)
ld a,ENEMY_PARTY_DATA
ld [wMonDataLocation],a
jr z, .FinishUp
ld [wcf91], a ; write species somewhere (XXX why?)
ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
@ -66,101 +66,101 @@ ReadTrainer:
; - each pokemon has a specific level
; (as opposed to the whole team being of the same level)
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
ld a,[hli]
ld a, [hli]
and a ; have we reached the end of the trainer data?
jr z,.AddLoneMove
ld [wCurEnemyLVL],a
ld a,[hli]
ld [wcf91],a
ld a,ENEMY_PARTY_DATA
ld [wMonDataLocation],a
jr z, .AddLoneMove
ld [wCurEnemyLVL], a
ld a, [hli]
ld [wcf91], a
ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
jr .SpecialTrainer
.AddLoneMove
; does the trainer have a single monster with a different move
ld a,[wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
ld a, [wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
and a
jr z,.AddTeamMove
jr z, .AddTeamMove
dec a
add a,a
ld c,a
ld b,0
ld hl,LoneMoves
add hl,bc
ld a,[hli]
ld d,[hl]
ld hl,wEnemyMon1Moves + 2
ld bc,wEnemyMon2 - wEnemyMon1
add a
ld c, a
ld b, 0
ld hl, LoneMoves
add hl, bc
ld a, [hli]
ld d, [hl]
ld hl, wEnemyMon1Moves + 2
ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
ld [hl],d
ld [hl], d
jr .FinishUp
.AddTeamMove
; check if our trainer's team has special moves
; get trainer class number
ld a,[wCurOpponent]
ld a, [wCurOpponent]
sub 200
ld b,a
ld hl,TeamMoves
ld b, a
ld hl, TeamMoves
; iterate through entries in TeamMoves, checking each for our trainer class
.IterateTeamMoves
ld a,[hli]
ld a, [hli]
cp b
jr z,.GiveTeamMoves ; is there a match?
jr z, .GiveTeamMoves ; is there a match?
inc hl ; if not, go to the next entry
inc a
jr nz,.IterateTeamMoves
jr nz, .IterateTeamMoves
; no matches found. is this trainer champion rival?
ld a,b
ld a, b
cp SONY3
jr z,.ChampionRival
jr z, .ChampionRival
jr .FinishUp ; nope
.GiveTeamMoves
ld a,[hl]
ld [wEnemyMon5Moves + 2],a
ld a, [hl]
ld [wEnemyMon5Moves + 2], a
jr .FinishUp
.ChampionRival ; give moves to his team
; pidgeot
ld a,SKY_ATTACK
ld [wEnemyMon1Moves + 2],a
ld a, SKY_ATTACK
ld [wEnemyMon1Moves + 2], a
; starter
ld a,[wRivalStarter]
ld a, [wRivalStarter]
cp STARTER3
ld b,MEGA_DRAIN
jr z,.GiveStarterMove
ld b, MEGA_DRAIN
jr z, .GiveStarterMove
cp STARTER1
ld b,FIRE_BLAST
jr z,.GiveStarterMove
ld b,BLIZZARD ; must be squirtle
ld b, FIRE_BLAST
jr z, .GiveStarterMove
ld b, BLIZZARD ; must be squirtle
.GiveStarterMove
ld a,b
ld [wEnemyMon6Moves + 2],a
ld a, b
ld [wEnemyMon6Moves + 2], a
.FinishUp
; clear wAmountMoneyWon addresses
xor a
ld de,wAmountMoneyWon
ld [de],a
ld de, wAmountMoneyWon
ld [de], a
inc de
ld [de],a
ld [de], a
inc de
ld [de],a
ld a,[wCurEnemyLVL]
ld b,a
ld [de], a
ld a, [wCurEnemyLVL]
ld b, a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
ld hl,wTrainerBaseMoney + 1
ld c,2 ; wAmountMoneyWon is a 3-byte number
ld hl, wTrainerBaseMoney + 1
ld c, 2 ; wAmountMoneyWon is a 3-byte number
push bc
predef AddBCDPredef
pop bc
inc de
inc de
dec b
jr nz,.LastLoop ; repeat wCurEnemyLVL times
jr nz, .LastLoop ; repeat wCurEnemyLVL times
ret

View file

@ -1,21 +1,21 @@
SaveTrainerName:
ld hl,TrainerNamePointers
ld a,[wTrainerClass]
ld hl, TrainerNamePointers
ld a, [wTrainerClass]
dec a
ld c,a
ld b,0
add hl,bc
add hl,bc
ld a,[hli]
ld h,[hl]
ld l,a
ld de,wcd6d
ld c, a
ld b, 0
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wcd6d
.CopyCharacter
ld a,[hli]
ld [de],a
ld a, [hli]
ld [de], a
inc de
cp "@"
jr nz,.CopyCharacter
jr nz, .CopyCharacter
ret
TrainerNamePointers:

View file

@ -263,10 +263,10 @@ ReadMove:
push de
push bc
dec a
ld hl,Moves
ld bc,MoveEnd - Moves
ld hl, Moves
ld bc, MoveEnd - Moves
call AddNTimes
ld de,wEnemyMoveNum
ld de, wEnemyMoveNum
call CopyData
pop bc
pop de
@ -338,33 +338,33 @@ INCLUDE "data/trainer_parties.asm"
TrainerAI:
and a
ld a,[wIsInBattle]
ld a, [wIsInBattle]
dec a
ret z ; if not a trainer, we're done here
ld a,[wLinkState]
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
ld a,[wTrainerClass] ; what trainer class is this?
ld a, [wTrainerClass] ; what trainer class is this?
dec a
ld c,a
ld b,0
ld hl,TrainerAIPointers
add hl,bc
add hl,bc
add hl,bc
ld a,[wAICount]
ld c, a
ld b, 0
ld hl, TrainerAIPointers
add hl, bc
add hl, bc
add hl, bc
ld a, [wAICount]
and a
ret z ; if no AI uses left, we're done here
inc hl
inc a
jr nz,.getpointer
jr nz, .getpointer
dec hl
ld a,[hli]
ld [wAICount],a
ld a, [hli]
ld [wAICount], a
.getpointer
ld a,[hli]
ld h,[hl]
ld l,a
ld a, [hli]
ld h, [hl]
ld l, a
call Random
jp hl
@ -442,17 +442,17 @@ CooltrainerMAI:
CooltrainerFAI:
cp $40
ld a,$A
ld a, $A
call AICheckIfHPBelowFraction
jp c,AIUseHyperPotion
ld a,5
jp c, AIUseHyperPotion
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AISwitchIfEnoughMons
BrockAI:
; if his active monster has a status condition, use a full heal
ld a,[wEnemyMonStatus]
ld a, [wEnemyMonStatus]
and a
ret z
jp AIUseFullHeal
@ -470,7 +470,7 @@ LtSurgeAI:
ErikaAI:
cp $80
ret nc
ld a,$A
ld a, $A
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@ -488,7 +488,7 @@ BlaineAI:
SabrinaAI:
cp $40
ret nc
ld a,$A
ld a, $A
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
@ -496,7 +496,7 @@ SabrinaAI:
Sony2AI:
cp $20
ret nc
ld a,5
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUsePotion
@ -504,7 +504,7 @@ Sony2AI:
Sony3AI:
cp $20
ret nc
ld a,5
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseFullRestore
@ -512,7 +512,7 @@ Sony3AI:
LoreleiAI:
cp $80
ret nc
ld a,5
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@ -524,10 +524,10 @@ BrunoAI:
AgathaAI:
cp $14
jp c,AISwitchIfEnoughMons
jp c, AISwitchIfEnoughMons
cp $80
ret nc
ld a,4
ld a, 4
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@ -535,7 +535,7 @@ AgathaAI:
LanceAI:
cp $80
ret nc
ld a,5
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
@ -547,133 +547,133 @@ GenericAI:
; end of individual trainer AI routines
DecrementAICount:
ld hl,wAICount
ld hl, wAICount
dec [hl]
scf
ret
AIPlayRestoringSFX:
ld a,SFX_HEAL_AILMENT
ld a, SFX_HEAL_AILMENT
jp PlaySoundWaitForCurrent
AIUseFullRestore:
call AICureStatus
ld a,FULL_RESTORE
ld [wAIItem],a
ld de,wHPBarOldHP
ld hl,wEnemyMonHP + 1
ld a,[hld]
ld [de],a
ld a, FULL_RESTORE
ld [wAIItem], a
ld de, wHPBarOldHP
ld hl, wEnemyMonHP + 1
ld a, [hld]
ld [de], a
inc de
ld a,[hl]
ld [de],a
ld a, [hl]
ld [de], a
inc de
ld hl,wEnemyMonMaxHP + 1
ld a,[hld]
ld [de],a
ld hl, wEnemyMonMaxHP + 1
ld a, [hld]
ld [de], a
inc de
ld [wHPBarMaxHP],a
ld [wEnemyMonHP + 1],a
ld a,[hl]
ld [de],a
ld [wHPBarMaxHP+1],a
ld [wEnemyMonHP],a
ld [wHPBarMaxHP], a
ld [wEnemyMonHP + 1], a
ld a, [hl]
ld [de], a
ld [wHPBarMaxHP+1], a
ld [wEnemyMonHP], a
jr AIPrintItemUseAndUpdateHPBar
AIUsePotion:
; enemy trainer heals his monster with a potion
ld a,POTION
ld b,20
ld a, POTION
ld b, 20
jr AIRecoverHP
AIUseSuperPotion:
; enemy trainer heals his monster with a super potion
ld a,SUPER_POTION
ld b,50
ld a, SUPER_POTION
ld b, 50
jr AIRecoverHP
AIUseHyperPotion:
; enemy trainer heals his monster with a hyper potion
ld a,HYPER_POTION
ld b,200
ld a, HYPER_POTION
ld b, 200
; fallthrough
AIRecoverHP:
; heal b HP and print "trainer used $(a) on pokemon!"
ld [wAIItem],a
ld hl,wEnemyMonHP + 1
ld a,[hl]
ld [wHPBarOldHP],a
ld [wAIItem], a
ld hl, wEnemyMonHP + 1
ld a, [hl]
ld [wHPBarOldHP], a
add b
ld [hld],a
ld [wHPBarNewHP],a
ld a,[hl]
ld [wHPBarOldHP+1],a
ld [wHPBarNewHP+1],a
jr nc,.next
ld [hld], a
ld [wHPBarNewHP], a
ld a, [hl]
ld [wHPBarOldHP+1], a
ld [wHPBarNewHP+1], a
jr nc, .next
inc a
ld [hl],a
ld [wHPBarNewHP+1],a
ld [hl], a
ld [wHPBarNewHP+1], a
.next
inc hl
ld a,[hld]
ld b,a
ld de,wEnemyMonMaxHP + 1
ld a,[de]
ld a, [hld]
ld b, a
ld de, wEnemyMonMaxHP + 1
ld a, [de]
dec de
ld [wHPBarMaxHP],a
ld [wHPBarMaxHP], a
sub b
ld a,[hli]
ld b,a
ld a,[de]
ld [wHPBarMaxHP+1],a
ld a, [hli]
ld b, a
ld a, [de]
ld [wHPBarMaxHP+1], a
sbc b
jr nc,AIPrintItemUseAndUpdateHPBar
jr nc, AIPrintItemUseAndUpdateHPBar
inc de
ld a,[de]
ld a, [de]
dec de
ld [hld],a
ld [wHPBarNewHP],a
ld a,[de]
ld [hl],a
ld [wHPBarNewHP+1],a
ld [hld], a
ld [wHPBarNewHP], a
ld a, [de]
ld [hl], a
ld [wHPBarNewHP+1], a
; fallthrough
AIPrintItemUseAndUpdateHPBar:
call AIPrintItemUse_
coord hl, 2, 2
xor a
ld [wHPBarType],a
ld [wHPBarType], a
predef UpdateHPBar2
jp DecrementAICount
AISwitchIfEnoughMons:
; enemy trainer switches if there are 3 or more unfainted mons in party
ld a,[wEnemyPartyCount]
ld c,a
ld hl,wEnemyMon1HP
ld a, [wEnemyPartyCount]
ld c, a
ld hl, wEnemyMon1HP
ld d,0 ; keep count of unfainted monsters
ld d, 0 ; keep count of unfainted monsters
; count how many monsters haven't fainted yet
.loop
ld a,[hli]
ld b,a
ld a,[hld]
ld a, [hli]
ld b, a
ld a, [hld]
or b
jr z,.Fainted ; has monster fainted?
jr z, .Fainted ; has monster fainted?
inc d
.Fainted
push bc
ld bc, wEnemyMon2 - wEnemyMon1
add hl,bc
add hl, bc
pop bc
dec c
jr nz,.loop
jr nz, .loop
ld a,d ; how many available monsters are there?
ld a, d ; how many available monsters are there?
cp 2 ; don't bother if only 1 or 2
jp nc,SwitchEnemyMon
jp nc, SwitchEnemyMon
and a
ret
@ -681,14 +681,14 @@ SwitchEnemyMon:
; prepare to withdraw the active monster: copy hp, number, and status to roster
ld a,[wEnemyMonPartyPos]
ld hl,wEnemyMon1HP
ld bc,wEnemyMon2 - wEnemyMon1
ld a, [wEnemyMonPartyPos]
ld hl, wEnemyMon1HP
ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
ld d,h
ld e,l
ld hl,wEnemyMonHP
ld bc,4
ld d, h
ld e, l
ld hl, wEnemyMonHP
ld bc, 4
call CopyData
ld hl, AIBattleWithdrawText
@ -696,13 +696,13 @@ SwitchEnemyMon:
; This wFirstMonsNotOutYet variable is abused to prevent the player from
; switching in a new mon in response to this switch.
ld a,1
ld [wFirstMonsNotOutYet],a
ld a, 1
ld [wFirstMonsNotOutYet], a
callab EnemySendOut
xor a
ld [wFirstMonsNotOutYet],a
ld [wFirstMonsNotOutYet], a
ld a,[wLinkState]
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
scf
@ -715,120 +715,120 @@ AIBattleWithdrawText:
AIUseFullHeal:
call AIPlayRestoringSFX
call AICureStatus
ld a,FULL_HEAL
ld a, FULL_HEAL
jp AIPrintItemUse
AICureStatus:
; cures the status of enemy's active pokemon
ld a,[wEnemyMonPartyPos]
ld hl,wEnemyMon1Status
ld bc,wEnemyMon2 - wEnemyMon1
ld a, [wEnemyMonPartyPos]
ld hl, wEnemyMon1Status
ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
xor a
ld [hl],a ; clear status in enemy team roster
ld [wEnemyMonStatus],a ; clear status of active enemy
ld hl,wEnemyBattleStatus3
res 0,[hl]
ld [hl], a ; clear status in enemy team roster
ld [wEnemyMonStatus], a ; clear status of active enemy
ld hl, wEnemyBattleStatus3
res 0, [hl]
ret
AIUseXAccuracy: ; unused
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 0,[hl]
ld a,X_ACCURACY
ld hl, wEnemyBattleStatus2
set 0, [hl]
ld a, X_ACCURACY
jp AIPrintItemUse
AIUseGuardSpec:
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 1,[hl]
ld a,GUARD_SPEC
ld hl, wEnemyBattleStatus2
set 1, [hl]
ld a, GUARD_SPEC
jp AIPrintItemUse
AIUseDireHit: ; unused
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 2,[hl]
ld a,DIRE_HIT
ld hl, wEnemyBattleStatus2
set 2, [hl]
ld a, DIRE_HIT
jp AIPrintItemUse
AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum
ld [H_DIVISOR],a
ld hl,wEnemyMonMaxHP
ld a,[hli]
ld [H_DIVIDEND],a
ld a,[hl]
ld [H_DIVIDEND + 1],a
ld b,2
ld [H_DIVISOR], a
ld hl, wEnemyMonMaxHP
ld a, [hli]
ld [H_DIVIDEND], a
ld a, [hl]
ld [H_DIVIDEND + 1], a
ld b, 2
call Divide
ld a,[H_QUOTIENT + 3]
ld c,a
ld a,[H_QUOTIENT + 2]
ld b,a
ld hl,wEnemyMonHP + 1
ld a,[hld]
ld e,a
ld a,[hl]
ld d,a
ld a,d
ld a, [H_QUOTIENT + 3]
ld c, a
ld a, [H_QUOTIENT + 2]
ld b, a
ld hl, wEnemyMonHP + 1
ld a, [hld]
ld e, a
ld a, [hl]
ld d, a
ld a, d
sub b
ret nz
ld a,e
ld a, e
sub c
ret
AIUseXAttack:
ld b,$A
ld a,X_ATTACK
ld b, $A
ld a, X_ATTACK
jr AIIncreaseStat
AIUseXDefend:
ld b,$B
ld a,X_DEFEND
ld b, $B
ld a, X_DEFEND
jr AIIncreaseStat
AIUseXSpeed:
ld b,$C
ld a,X_SPEED
ld b, $C
ld a, X_SPEED
jr AIIncreaseStat
AIUseXSpecial:
ld b,$D
ld a,X_SPECIAL
ld b, $D
ld a, X_SPECIAL
; fallthrough
AIIncreaseStat:
ld [wAIItem],a
ld [wAIItem], a
push bc
call AIPrintItemUse_
pop bc
ld hl,wEnemyMoveEffect
ld a,[hld]
ld hl, wEnemyMoveEffect
ld a, [hld]
push af
ld a,[hl]
ld a, [hl]
push af
push hl
ld a,ANIM_AF
ld [hli],a
ld [hl],b
ld a, ANIM_AF
ld [hli], a
ld [hl], b
callab StatModifierUpEffect
pop hl
pop af
ld [hli],a
ld [hli], a
pop af
ld [hl],a
ld [hl], a
jp DecrementAICount
AIPrintItemUse:
ld [wAIItem],a
ld [wAIItem], a
call AIPrintItemUse_
jp DecrementAICount
AIPrintItemUse_:
; print "x used [wAIItem] on z!"
ld a,[wAIItem]
ld [wd11e],a
ld a, [wAIItem]
ld [wd11e], a
call GetItemName
ld hl, AIBattleUseItemText
jp PrintText