ref: fd2235e678c58cebd6255b5e658e704ee5138591
parent: a51037eeeedb03e29d8675626018cf02750882fa
author: YamaArashi <shadow962@live.com>
date: Sat Jun 11 17:30:05 EDT 2016
sync engine code with pokeyellow
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -18,7 +18,7 @@
call FillFourRowsWithBlack
coord hl, 0, 14
call FillFourRowsWithBlack
- ld a, $c0
+ ld a, %11000000
ld [rBGP], a
call EnableLCD
ld a, $ff
@@ -36,13 +36,13 @@
FadeInCreditsText:
ld hl, HoFGBPalettes
ld b, 4
-.asm_740bf
+.loop
ld a, [hli]
ld [rBGP], a
ld c, 5
call DelayFrames
dec b
- jr nz, .asm_740bf
+ jr nz, .loop
ret
DisplayCreditsMon:
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -383,29 +383,29 @@
call SetAnimationPalette
ld a,[wAnimationID]
and a
- jr z,.AnimationFinished
+ jr z, .animationFinished
; if throwing a Poké Ball, skip the regular animation code
cp a,TOSS_ANIM
- jr nz,.MoveAnimation
- ld de,.AnimationFinished
+ jr nz, .moveAnimation
+ ld de, .animationFinished
push de
jp TossBallAnimation
-.MoveAnimation
+.moveAnimation
; check if battle animations are disabled in the options
ld a,[wOptions]
bit 7,a
- jr nz,.AnimationsDisabled
+ jr nz, .animationsDisabled
call ShareMoveAnimations
call PlayAnimation
jr .next4
-.AnimationsDisabled
+.animationsDisabled
ld c,30
call DelayFrames
.next4
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
-.AnimationFinished
+.animationFinished
call WaitForSoundToFinish
xor a
ld [wSubAnimSubEntryAddr],a
@@ -431,13 +431,13 @@
cp a,AMNESIA
ld b,CONF_ANIM
- jr z,.Replace
+ jr z, .replaceAnim
cp a,REST
ld b,SLP_ANIM
ret nz
-.Replace
+.replaceAnim
ld a,b
ld [wAnimationID],a
ret
@@ -1845,13 +1845,13 @@
ld hl, wTempPic
push hl
xor a
- ld bc, $310
+ ld bc, 7 * 7 * $10
call FillMemory
pop hl
ld de, $194
add hl, de
ld de, MinimizedMonSprite
- ld c, $5
+ ld c, MinimizedMonSpriteEnd - MinimizedMonSprite
.loop
ld a, [de]
ld [hli], a
@@ -1865,6 +1865,7 @@
MinimizedMonSprite:
INCBIN "gfx/minimized_mon_sprite.1bpp"
+MinimizedMonSpriteEnd:
AnimationSlideMonDownAndHide:
; Slides the mon's sprite down and disappears. Used in Acid Armor.
@@ -2308,7 +2309,6 @@
ld b, a
ret
-; get the sound of the (move id - 1) in a
GetMoveSound:
ld hl,MoveSoundTable
ld e,a
@@ -2363,6 +2363,7 @@
ret
MoveSoundTable:
+ ; ID, pitch mod, tempo mod
db SFX_POUND, $00,$80 ; POUND
db SFX_BATTLE_0C, $10,$80 ; KARATE_CHOP
db SFX_DOUBLESLAP, $00,$80 ; DOUBLESLAP
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -443,7 +443,7 @@
; the link battle enemy has switched mons
ld a, [wPlayerBattleStatus1]
bit UsingTrappingMove, a ; check if using multi-turn move like Wrap
- jr z, .asm_3c2dd
+ jr z, .specialMoveNotUsed
ld a, [wPlayerMoveListIndex]
ld hl, wBattleMonMoves
ld c, a
@@ -452,9 +452,9 @@
ld a, [hl]
cp METRONOME ; a MIRROR MOVE check is missing, might lead to a desync in link battles
; when combined with multi-turn moves
- jr nz, .asm_3c2dd
+ jr nz, .specialMoveNotUsed
ld [wPlayerSelectedMove], a
-.asm_3c2dd
+.specialMoveNotUsed
callab SwitchEnemyMon
.noLinkBattle
ld a, [wPlayerSelectedMove]
@@ -665,7 +665,7 @@
and a
jr z, .playersTurn
ld hl, wEnemyBattleStatus3
- ld de, wEnemyToxcCounter
+ ld de, wEnemyToxicCounter
.playersTurn
bit BadlyPoisoned, [hl]
jr z, .noToxic
@@ -884,6 +884,8 @@
ld a, MUSIC_DEFEATED_WILD_MON
call PlayBattleVictoryMusic
.sfxplayed
+; bug: win sfx is played for wild battles before checking for player mon HP
+; this can lead to odd scenarios where both player and enemy faint, as the win sfx plays yet the player never won the battle
ld hl, wBattleMonHP
ld a, [hli]
or [hl]
@@ -1285,7 +1287,7 @@
call CopyData
pop de
pop hl
- ld bc, -20
+ ld bc, -SCREEN_WIDTH
add hl, bc
push hl
ld h, d
@@ -1297,7 +1299,7 @@
pop bc
dec b
jr nz, .rowLoop
- ld bc, 20
+ ld bc, SCREEN_WIDTH
add hl, bc
ld de, SevenSpacesText
call PlaceString
@@ -1925,9 +1927,9 @@
ld de, wLoadedMonStatus
call PrintStatusConditionNotFainted
pop hl
- jr nz, .asm_3cdae
+ jr nz, .doNotPrintLevel
call PrintLevel
-.asm_3cdae
+.doNotPrintLevel
ld a, [wLoadedMonSpecies]
ld [wcf91], a
coord hl, 10, 9
@@ -1939,14 +1941,14 @@
ld hl, wBattleMonHP
ld a, [hli]
or [hl]
- jr z, .asm_3cdd9
+ jr z, .fainted
ld a, [wLowHealthAlarmDisabled]
and a ; has the alarm been disabled because the player has already won?
ret nz ; if so, return
ld a, [wPlayerHPBarColor]
cp HP_BAR_RED
- jr z, .asm_3cde6
-.asm_3cdd9
+ jr z, .setLowHealthAlarm
+.fainted
ld hl, wLowHealthAlarm
bit 7, [hl] ;low health alarm enabled?
ld [hl], $0
@@ -1954,7 +1956,7 @@
xor a
ld [wChannelSoundIDs + CH4], a
ret
-.asm_3cde6
+.setLowHealthAlarm
ld hl, wLowHealthAlarm
set 7, [hl] ;enable low health alarm
ret
@@ -2572,9 +2574,10 @@
ld hl, wBattleMonMoves
call .loadmoves
coord hl, 4, 12
- ld b, $4
- ld c, $e
- di
+ ld b, 4
+ ld c, 14
+ di ; out of pure coincidence, it is possible for vblank to occur between the di and ei
+ ; so it is necessary to put the di ei block to not cause tearing
call TextBoxBorder
coord hl, 4, 12
ld [hl], $7a
@@ -2590,8 +2593,8 @@
ld hl, wEnemyMonMoves
call .loadmoves
coord hl, 0, 7
- ld b, $4
- ld c, $e
+ ld b, 4
+ ld c, 14
call TextBoxBorder
coord hl, 2, 8
call .writemoves
@@ -2605,8 +2608,8 @@
call AddNTimes
call .loadmoves
coord hl, 4, 7
- ld b, $4
- ld c, $e
+ ld b, 4
+ ld c, 14
call TextBoxBorder
coord hl, 6, 8
call .writemoves
@@ -2688,9 +2691,9 @@
ld hl, hFlags_0xFFF6
res 1, [hl]
bit 6, a
- jp nz, CursorUp ; up
+ jp nz, SelectMenuItem_CursorUp ; up
bit 7, a
- jp nz, CursorDown ; down
+ jp nz, SelectMenuItem_CursorDown ; down
bit 2, a
jp nz, SwapMovesInMenu ; select
bit 1, a ; B, but was it reset above?
@@ -2703,10 +2706,10 @@
ld b, a
ld a, [wMoveMenuType]
dec a ; if not mimic
- jr nz, .nob
+ jr nz, .notB
pop af
ret
-.nob
+.notB
dec a
ld a, b
ld [wPlayerMoveListIndex], a
@@ -2723,7 +2726,7 @@
add hl, bc
ld a, [hl]
and $3f
- jr z, .nopp
+ jr z, .noPP
ld a, [wPlayerDisabledMove]
swap a
and $f
@@ -2746,7 +2749,7 @@
.disabled
ld hl, MoveDisabledText
jr .print
-.nopp
+.noPP
ld hl, MoveNoPPText
call PrintText
@@ -2764,7 +2767,7 @@
WhichTechniqueString:
db "WHICH TECHNIQUE?@"
-CursorUp:
+SelectMenuItem_CursorUp:
ld a, [wCurrentMenuItem]
and a
jp nz, SelectMenuItem
@@ -2774,7 +2777,7 @@
ld [wCurrentMenuItem], a
jp SelectMenuItem
-CursorDown:
+SelectMenuItem_CursorDown:
ld a, [wCurrentMenuItem]
ld b, a
ld a, [wNumMovesMinusOne]
@@ -2794,7 +2797,7 @@
ld a, [wPlayerDisabledMove]
and a
ld hl, wBattleMonPP
- jr nz, .asm_3d40e
+ jr nz, .handleDisabledMove
ld a, [hli]
or [hl]
inc hl
@@ -2803,26 +2806,26 @@
or [hl]
and $3f
ret nz
- jr .asm_3d423
-.asm_3d40e
+ jr .noMovesLeft
+.handleDisabledMove
swap a
- and $f
+ and $f ; get disabled move
ld b, a
- ld d, $5
+ ld d, NUM_MOVES + 1
xor a
-.asm_3d416
+.handleDisabledMovePPLoop
dec d
- jr z, .asm_3d421
- ld c, [hl]
+ jr z, .allMovesChecked
+ ld c, [hl] ; get move PP
inc hl
- dec b
- jr z, .asm_3d416
+ dec b ; is this the disabled move?
+ jr z, .handleDisabledMovePPLoop ; if so, ignore its PP value
or c
- jr .asm_3d416
-.asm_3d421
- and a
- ret nz
-.asm_3d423
+ jr .handleDisabledMovePPLoop
+.allMovesChecked
+ and a ; any PP left?
+ ret nz ; return if a move has PP left
+.noMovesLeft
ld hl, NoMovesLeftText
call PrintText
ld c, 60
@@ -2914,8 +2917,8 @@
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 0, 8
- ld b, $3
- ld c, $9
+ ld b, 3
+ ld c, 9
call TextBoxBorder
ld a, [wPlayerDisabledMove]
and a
@@ -2997,7 +3000,7 @@
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
cp $e
- jp z, .asm_3d601
+ jp z, .linkedOpponentUsedStruggle
cp $d
jr z, .unableToSelectMove
cp $4
@@ -3075,7 +3078,7 @@
.done
ld [wEnemySelectedMove], a
ret
-.asm_3d601
+.linkedOpponentUsedStruggle
ld a, STRUGGLE
jr .done
@@ -3205,7 +3208,7 @@
call RandomizeDamage
.moveHitTest
call MoveHitTest
-handleIfPlayerMoveMissed
+handleIfPlayerMoveMissed:
ld a,[wMoveMissed]
and a
jr z,getPlayerAnimationType
@@ -3213,13 +3216,13 @@
sub a,EXPLODE_EFFECT
jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr playerCheckIfFlyOrChargeEffect
-getPlayerAnimationType
+getPlayerAnimationType:
ld a,[wPlayerMoveEffect]
and a
ld a,4 ; move has no effect other than dealing damage
jr z,playPlayerMoveAnimation
ld a,5 ; move has effect
-playPlayerMoveAnimation
+playPlayerMoveAnimation:
push af
ld a,[wPlayerBattleStatus2]
bit HasSubstituteUp,a
@@ -3238,7 +3241,7 @@
ld b,BANK(ReshowSubstituteAnim)
call nz,Bankswitch
jr MirrorMoveCheck
-playerCheckIfFlyOrChargeEffect
+playerCheckIfFlyOrChargeEffect:
ld c,30
call DelayFrames
ld a,[wPlayerMoveEffect]
@@ -3252,7 +3255,7 @@
ld [wAnimationType],a
ld a,STATUS_AFFECTED_ANIM
call PlayMoveAnimation
-MirrorMoveCheck
+MirrorMoveCheck:
ld a,[wPlayerMoveEffect]
cp a,MIRROR_MOVE_EFFECT
jr nz,.metronomeCheck
@@ -3785,10 +3788,10 @@
and a
ld a, [wPlayerMoveNum]
ld hl, wPlayerUsedMove
- jr z, .asm_3db11
+ jr z, .playerTurn
ld a, [wEnemyMoveNum]
ld hl, wEnemyUsedMove
-.asm_3db11
+.playerTurn
ld [hl], a
ld [wd11e], a
call DetermineExclamationPointTextNum
@@ -4682,9 +4685,9 @@
ld a, [H_WHOSETURN]
and a
ld a, [wEnemyMonSpecies]
- jr nz, .asm_3e032
+ jr nz, .handleEnemy
ld a, [wBattleMonSpecies]
-.asm_3e032
+.handleEnemy
ld [wd0b5], a
call GetMonHeader
ld a, [wMonHBaseSpeed]
@@ -5051,7 +5054,7 @@
ld a,$01
ld [wHPBarType],a
predef UpdateHPBar2 ; animate the HP bar shortening
-ApplyAttackToPlayerPokemonDone
+ApplyAttackToPlayerPokemonDone:
jp DrawHUDsAndHPBars
AttackSubstitute:
@@ -5751,12 +5754,12 @@
handleIfEnemyMoveMissed:
ld a, [wMoveMissed]
and a
- jr z, .asm_3e791
+ jr z, .moveDidNotMiss
ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
- jr z, asm_3e7a0
+ jr z, handleExplosionMiss
jr EnemyCheckIfFlyOrChargeEffect
-.asm_3e791
+.moveDidNotMiss
call SwapPlayerAndEnemyLevels
GetEnemyAnimationType:
@@ -5766,7 +5769,7 @@
jr z, playEnemyMoveAnimation
ld a, $2
jr playEnemyMoveAnimation
-asm_3e7a0:
+handleExplosionMiss:
call SwapPlayerAndEnemyLevels
xor a
playEnemyMoveAnimation:
@@ -5824,19 +5827,19 @@
jp c, JumpMoveEffect
ld a, [wMoveMissed]
and a
- jr z, .asm_3e82b
+ jr z, .moveDidNotMiss
call PrintMoveFailureText
ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
- jr z, .asm_3e83e
+ jr z, .handleExplosionMiss
jp ExecuteEnemyMoveDone
-.asm_3e82b
+.moveDidNotMiss
call ApplyAttackToPlayerPokemon
call PrintCriticalOHKOText
callab DisplayEffectiveness
ld a, 1
ld [wMoveDidntMiss], a
-.asm_3e83e
+.handleExplosionMiss
ld a, [wEnemyMoveEffect]
ld hl, AlwaysHappenSideEffects
ld de, $1
@@ -5850,7 +5853,7 @@
call HandleBuildingRage
ld hl, wEnemyBattleStatus1
bit AttackingMultipleTimes, [hl] ; is mon hitting multiple times? (example: double kick)
- jr z, .asm_3e873
+ jr z, .notMultiHitMove
push hl
ld hl, wEnemyNumAttacksLeft
dec [hl]
@@ -5861,7 +5864,7 @@
call PrintText
xor a
ld [wEnemyNumHits], a
-.asm_3e873
+.notMultiHitMove
ld a, [wEnemyMoveEffect]
and a
jr z, ExecuteEnemyMoveDone
@@ -6801,16 +6804,16 @@
ld hl, wEnemyMonType1
ld de, wEnemyBattleStatus1
ld a, [wPlayerMoveNum]
- jr z, .asm_3eeea
+ jr z, .player
ld hl, wBattleMonType1
ld de, wEnemyBattleStatus1
ld a, [wEnemyMoveNum]
-.asm_3eeea
+.player
cp SELFDESTRUCT
- jr z, .asm_3eef1
+ jr z, .isExplodingMove
cp EXPLOSION
ret nz
-.asm_3eef1
+.isExplodingMove
ld a, [de]
bit Invulnerable, a ; fly/dig
ret nz
@@ -7333,7 +7336,7 @@
jr nz, .ok
ld b, ANIM_A9
ld hl, wEnemyBattleStatus3
- ld de, wEnemyToxcCounter
+ ld de, wEnemyToxicCounter
.ok
cp TOXIC
jr nz, .normalPoison ; done if move is not Toxic
@@ -7341,18 +7344,18 @@
xor a
ld [de], a
ld hl, BadlyPoisonedText
- jr .asm_3f2c0
+ jr .continue
.normalPoison
ld hl, PoisonedText
-.asm_3f2c0
+.continue
pop de
ld a, [de]
cp POISON_EFFECT
- jr z, .asm_3f2cd
+ jr z, .regularPoisonEffect
ld a, b
call PlayBattleAnimation2
jp PrintText
-.asm_3f2cd
+.regularPoisonEffect
call PlayCurrentMoveAnimation2
jp PrintText
.noEffect
@@ -7717,9 +7720,9 @@
ld a, [H_WHOSETURN]
and a
ld a, [wPlayerMoveEffect]
- jr z, .asm_3f53b
+ jr z, .playerTurn
ld a, [wEnemyMoveEffect]
-.asm_3f53b
+.playerTurn
cp ATTACK_DOWN1_EFFECT
ret nc
ld hl, RoseText
@@ -7728,7 +7731,7 @@
GreatlyRoseText:
db $0a
TX_FAR _GreatlyRoseText
-
+; fallthrough
RoseText:
TX_FAR _RoseText
db "@"
@@ -7817,9 +7820,9 @@
ld a, c
add e
ld e, a
- jr nc, .asm_3f5e4
+ jr nc, .noCarry
inc d ; de = unmodified stat
-.asm_3f5e4
+.noCarry
pop bc
ld a, [hld]
sub $1 ; can't lower stat below 1 (-6)
@@ -7919,12 +7922,13 @@
ld a, [H_WHOSETURN]
and a
ld a, [wPlayerMoveEffect]
- jr z, .asm_3f674
+ jr z, .playerTurn
ld a, [wEnemyMoveEffect]
-.asm_3f674
- cp $1a
+.playerTurn
+; check if the move's effect decreases a stat by 2
+ cp BIDE_EFFECT
ret c
- cp $44
+ cp ATTACK_DOWN_SIDE_EFFECT
ret nc
ld hl, GreatlyFellText
ret
@@ -7932,7 +7936,7 @@
GreatlyFellText:
db $0a
TX_FAR _GreatlyFellText
-
+; fallthrough
FellText:
TX_FAR _FellText
db "@"
@@ -7940,15 +7944,15 @@
PrintStatText:
ld hl, StatsTextStrings
ld c, "@"
-.asm_3f68d
+.findStatName_outer
dec b
- jr z, .asm_3f696
-.asm_3f690
+ jr z, .foundStatName
+.findStatName_inner
ld a, [hli]
cp c
- jr z, .asm_3f68d
- jr .asm_3f690
-.asm_3f696
+ jr z, .findStatName_outer
+ jr .findStatName_inner
+.foundStatName
ld de, wcf4b
ld bc, $a
jp CopyData
@@ -8026,26 +8030,27 @@
SwitchAndTeleportEffect:
ld a, [H_WHOSETURN]
and a
- jr nz, .asm_3f791
+ jr nz, .handleEnemy
ld a, [wIsInBattle]
dec a
- jr nz, .asm_3f77e
+ jr nz, .notWildBattle1
ld a, [wCurEnemyLVL]
ld b, a
ld a, [wBattleMonLevel]
- cp b
- jr nc, .asm_3f76e
+ cp b ; is the player's level greater than the enemy's level?
+ jr nc, .playerMoveWasSuccessful ; if so, teleport will always succeed
add b
ld c, a
- inc c
-.asm_3f751
+ inc c ; c = sum of player level and enemy level
+.rejectionSampleLoop1
call BattleRandom
- cp c
- jr nc, .asm_3f751
+ cp c ; get a random number between 0 and c
+ jr nc, .rejectionSampleLoop1
srl b
- srl b
- cp b
- jr nc, .asm_3f76e
+ srl b ; b = enemy level * 4
+; bug: does not account for overflow, so levels above 63 can lead to erroneousness results
+ cp b ; is rand[0, playerLevel + enemyLevel] > enemyLevel?
+ jr nc, .playerMoveWasSuccessful ; if so, allow teleporting
ld c, 50
call DelayFrames
ld a, [wPlayerMoveNum]
@@ -8052,7 +8057,7 @@
cp TELEPORT
jp nz, PrintDidntAffectText
jp PrintButItFailedText_
-.asm_3f76e
+.playerMoveWasSuccessful
call ReadPlayerMonCurHPAndStatus
xor a
ld [wAnimationType], a
@@ -8059,8 +8064,8 @@
inc a
ld [wEscapedFromBattle], a
ld a, [wPlayerMoveNum]
- jr .asm_3f7e4
-.asm_3f77e
+ jr .playAnimAndPrintText
+.notWildBattle1
ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
@@ -8068,26 +8073,26 @@
cp TELEPORT
jp nz, PrintText
jp PrintButItFailedText_
-.asm_3f791
+.handleEnemy
ld a, [wIsInBattle]
dec a
- jr nz, .asm_3f7d1
+ jr nz, .notWildBattle2
ld a, [wBattleMonLevel]
ld b, a
ld a, [wCurEnemyLVL]
cp b
- jr nc, .asm_3f7c1
+ jr nc, .enemyMoveWasSuccessful
add b
ld c, a
inc c
-.asm_3f7a4
+.rejectionSampleLoop2
call BattleRandom
cp c
- jr nc, .asm_3f7a4
+ jr nc, .rejectionSampleLoop2
srl b
srl b
cp b
- jr nc, .asm_3f7c1
+ jr nc, .enemyMoveWasSuccessful
ld c, 50
call DelayFrames
ld a, [wEnemyMoveNum]
@@ -8094,7 +8099,7 @@
cp TELEPORT
jp nz, PrintDidntAffectText
jp PrintButItFailedText_
-.asm_3f7c1
+.enemyMoveWasSuccessful
call ReadPlayerMonCurHPAndStatus
xor a
ld [wAnimationType], a
@@ -8101,8 +8106,8 @@
inc a
ld [wEscapedFromBattle], a
ld a, [wEnemyMoveNum]
- jr .asm_3f7e4
-.asm_3f7d1
+ jr .playAnimAndPrintText
+.notWildBattle2
ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
@@ -8110,7 +8115,7 @@
cp TELEPORT
jp nz, PrintText
jp ConditionalPrintButItFailed
-.asm_3f7e4
+.playAnimAndPrintText
push af
call PlayBattleAnimation
ld c, 20
@@ -8118,12 +8123,12 @@
pop af
ld hl, RanFromBattleText
cp TELEPORT
- jr z, .asm_3f7ff
+ jr z, .printText
ld hl, RanAwayScaredText
cp ROAR
- jr z, .asm_3f7ff
+ jr z, .printText
ld hl, WasBlownAwayText
-.asm_3f7ff
+.printText
jp PrintText
RanFromBattleText:
@@ -8168,10 +8173,11 @@
call BattleRandom
and $3
cp $2
- jr c, .asm_3f851
+ jr c, .gotNumHits
+; if the number of hits was greater than 2, re-roll again for a lower chance
call BattleRandom
and $3
-.asm_3f851
+.gotNumHits
inc a
inc a
.saveNumberOfHits
@@ -8250,22 +8256,22 @@
ld a, [wChargeMoveNum]
cp RAZOR_WIND
ld hl, MadeWhirlwindText
- jr z, .asm_3f8f8
+ jr z, .gotText
cp SOLARBEAM
ld hl, TookInSunlightText
- jr z, .asm_3f8f8
+ jr z, .gotText
cp SKULL_BASH
ld hl, LoweredItsHeadText
- jr z, .asm_3f8f8
+ jr z, .gotText
cp SKY_ATTACK
ld hl, SkyAttackGlowingText
- jr z, .asm_3f8f8
+ jr z, .gotText
cp FLY
ld hl, FlewUpHighText
- jr z, .asm_3f8f8
+ jr z, .gotText
cp DIG
ld hl, DugAHoleText
-.asm_3f8f8
+.gotText
ret
MadeWhirlwindText:
@@ -8328,7 +8334,7 @@
ConfusionSideEffect:
call BattleRandom
- cp $19
+ cp $19 ; ~10% chance
ret nc
jr ConfusionSideEffectSuccess
@@ -8398,9 +8404,9 @@
ld hl, wEnemyBattleStatus2
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3f9db
+ jr z, .playerTurn
ld hl, wPlayerBattleStatus2
-.asm_3f9db
+.playerTurn
res NeedsToRecharge, [hl] ; mon no longer needs to recharge
pop hl
ret
@@ -8421,21 +8427,21 @@
call MoveHitTest
ld a, [wMoveMissed]
and a
- jr nz, .asm_3fa74
+ jr nz, .mimicMissed
ld a, [H_WHOSETURN]
and a
ld hl, wBattleMonMoves
ld a, [wPlayerBattleStatus1]
- jr nz, .asm_3fa13
+ jr nz, .enemyTurn
ld a, [wLinkState]
cp LINK_STATE_BATTLING
- jr nz, .asm_3fa3a
+ jr nz, .letPlayerChooseMove
ld hl, wEnemyMonMoves
ld a, [wEnemyBattleStatus1]
-.asm_3fa13
+.enemyTurn
bit Invulnerable, a
- jr nz, .asm_3fa74
-.asm_3fa17
+ jr nz, .mimicMissed
+.getRandomMove
push hl
call BattleRandom
and $3
@@ -8445,20 +8451,20 @@
ld a, [hl]
pop hl
and a
- jr z, .asm_3fa17
+ jr z, .getRandomMove
ld d, a
ld a, [H_WHOSETURN]
and a
ld hl, wBattleMonMoves
ld a, [wPlayerMoveListIndex]
- jr z, .asm_3fa5f
+ jr z, .playerTurn
ld hl, wEnemyMonMoves
ld a, [wEnemyMoveListIndex]
- jr .asm_3fa5f
-.asm_3fa3a
+ jr .playerTurn
+.letPlayerChooseMove
ld a, [wEnemyBattleStatus1]
bit Invulnerable, a
- jr nz, .asm_3fa74
+ jr nz, .mimicMissed
ld a, [wCurrentMenuItem]
push af
ld a, $1
@@ -8473,7 +8479,7 @@
ld d, [hl]
pop af
ld hl, wBattleMonMoves
-.asm_3fa5f
+.playerTurn
ld c, a
ld b, $0
add hl, bc
@@ -8484,7 +8490,7 @@
call PlayCurrentMoveAnimation
ld hl, MimicLearnedMoveText
jp PrintText
-.asm_3fa74
+.mimicMissed
jp PrintButItFailedText_
MimicLearnedMoveText:
--- a/engine/battle/decrement_pp.asm
+++ b/engine/battle/decrement_pp.asm
@@ -33,7 +33,7 @@
ld a, [wPlayerMonNumber] ; which mon in party is active
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes ; calculate address of the mon to modify
-.DecrementPP
+.DecrementPP:
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
ld c, a
ld b, 0
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -49,11 +49,11 @@
ld [de], a
.nextBaseStat
dec c
- jr z, .asm_552a1
+ jr z, .statExpDone
inc de
inc de
jr .gainStatExpLoop
-.asm_552a1
+.statExpDone
xor a
ld [H_MULTIPLICAND], a
ld [H_MULTIPLICAND + 1], a
--- a/engine/battle/get_trainer_name.asm
+++ b/engine/battle/get_trainer_name.asm
@@ -2,15 +2,15 @@
ld hl, wGrassRate
ld a, [wLinkState]
and a
- jr nz, .rival
+ jr nz, .foundName
ld hl, wRivalName
ld a, [wTrainerClass]
cp SONY1
- jr z, .rival
+ jr z, .foundName
cp SONY2
- jr z, .rival
+ jr z, .foundName
cp SONY3
- jr z, .rival
+ jr z, .foundName
ld [wd0b5], a
ld a, TRAINER_NAME
ld [wNameListType], a
@@ -18,7 +18,7 @@
ld [wPredefBank], a
call GetName
ld hl, wcd6d
-.rival
+.foundName
ld de, wTrainerName
ld bc, $d
jp CopyData
--- a/engine/battle/link_battle_versus_text.asm
+++ b/engine/battle/link_battle_versus_text.asm
@@ -2,8 +2,8 @@
DisplayLinkBattleVersusTextBox:
call LoadTextBoxTilePatterns
coord hl, 3, 4
- ld b, $7
- ld c, $c
+ ld b, 7
+ ld c, 12
call TextBoxBorder
coord hl, 4, 5
ld de, wPlayerName
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -182,7 +182,7 @@
jr c, .preferMove
jr .nextMove
.preferMove
- dec [hl] ; sligthly encourage this move
+ dec [hl] ; slightly encourage this move
jr .nextMove
; encourages moves that are effective against the player's mon (even if non-damaging).
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -27,10 +27,10 @@
ld hl, wSerialPlayerDataBlock
ld a, SERIAL_PREAMBLE_BYTE
ld b, 6
-.writePlayeDataBlockPreambleLoop
+.writePlayerDataBlockPreambleLoop
ld [hli], a
dec b
- jr nz, .writePlayeDataBlockPreambleLoop
+ jr nz, .writePlayerDataBlockPreambleLoop
ld hl, wSerialRandomNumberListBlock
ld a, SERIAL_PREAMBLE_BYTE
ld b, 7
@@ -271,7 +271,7 @@
cp LINK_STATE_START_BATTLE
ld a, LINK_STATE_TRADING
ld [wLinkState], a
- jr nz, .asm_5506
+ jr nz, .trading
ld a, LINK_STATE_BATTLING
ld [wLinkState], a
ld a, OPP_SONY1
@@ -283,7 +283,7 @@
predef InitOpponent
predef HealParty
jp ReturnToCableClubRoom
-.asm_5506
+.trading
ld c, BANK(Music_GameCorner)
ld a, MUSIC_GAME_CORNER
call PlayMusic
@@ -964,8 +964,8 @@
; c = width
CableClub_DrawHorizontalLine:
ld d, c
-.asm_5ae1
+.loop
ld [hli], a
dec d
- jr nz, .asm_5ae1
+ jr nz, .loop
ret
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -210,12 +210,12 @@
SetEvent EVENT_HALL_OF_FAME_DEX_RATING
predef DisplayDexRating
coord hl, 0, 4
- ld b, $6
- ld c, $a
+ ld b, 6
+ ld c, 10
call TextBoxBorder
coord hl, 5, 0
- ld b, $2
- ld c, $9
+ ld b, 2
+ ld c, 9
call TextBoxBorder
coord hl, 7, 2
ld de, wPlayerName
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -66,18 +66,18 @@
PrintFightingDojoText2:
call EnableAutoTextBoxDrawing
- tx_pre_jump FightingDojoText_52a10
+ tx_pre_jump EnemiesOnEverySideText
-FightingDojoText_52a10:
- TX_FAR _FightingDojoText_52a10
+EnemiesOnEverySideText:
+ TX_FAR _EnemiesOnEverySideText
db "@"
PrintFightingDojoText3:
call EnableAutoTextBoxDrawing
- tx_pre_jump FightingDojoText_52a1d
+ tx_pre_jump WhatGoesAroundComesAroundText
-FightingDojoText_52a1d:
- TX_FAR _FightingDojoText_52a1d
+WhatGoesAroundComesAroundText:
+ TX_FAR _WhatGoesAroundComesAroundText
db "@"
PrintFightingDojoText:
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -81,9 +81,9 @@
ld a, [wXCoord]
bit 0, a
ld hl, IndigoPlateauStatuesText2
- jr nz, .asm_fbd3
+ jr nz, .ok
ld hl, IndigoPlateauStatuesText3
-.asm_fbd3
+.ok
call PrintText
jp TextScriptEnd
@@ -104,12 +104,12 @@
ld hl, PokemonBooksText
ld a, [wCurMapTileset]
cp MANSION ; Celadon Mansion tileset
- jr nz, .asm_fbfd
+ jr nz, .ok
aCoord 8, 6
cp $38
- jr nz, .asm_fbfd
+ jr nz, .ok
ld hl, DiglettSculptureText
-.asm_fbfd
+.ok
call PrintText
jp TextScriptEnd
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -70,10 +70,10 @@
ld c, BANK(SFX_Safari_Zone_PA)
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
-.asm_1e9c2
+.waitForMusicToPlay
ld a, [wChannelSoundIDs + CH4]
- cp $b9
- jr nz, .asm_1e9c2
+ cp SFX_SAFARI_ZONE_PA
+ jr nz, .waitForMusicToPlay
ld a, TEXT_SAFARI_GAME_OVER
ld [hSpriteIndexOrTextID], a
call DisplayTextID
@@ -100,10 +100,10 @@
TX_ASM
ld a, [wNumSafariBalls]
and a
- jr z, .asm_1ea04
+ jr z, .noMoreSafariBalls
ld hl, TimesUpText
call PrintText
-.asm_1ea04
+.noMoreSafariBalls
ld hl, GameOverText
call PrintText
jp TextScriptEnd
@@ -326,14 +326,14 @@
cp SPRITE_FACING_UP
ret nz
CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING
- jr nz, .asm_1ebd2
+ jr nz, .displayBillsHousePokemonList
CheckEventReuseA EVENT_USED_CELL_SEPARATOR_ON_BILL
- jr nz, .asm_1eb86
+ jr nz, .displayBillsHouseMonitorText
CheckEventReuseA EVENT_BILL_SAID_USE_CELL_SEPARATOR
- jr nz, .asm_1eb8b
-.asm_1eb86
+ jr nz, .doCellSeparator
+.displayBillsHouseMonitorText
tx_pre_jump BillsHouseMonitorText
-.asm_1eb8b
+.doCellSeparator
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
tx_pre BillsHouseInitiatedText
@@ -360,7 +360,7 @@
call PlayDefaultMusic
SetEvent EVENT_USED_CELL_SEPARATOR_ON_BILL
ret
-.asm_1ebd2
+.displayBillsHousePokemonList
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
tx_pre BillsHousePokemonList
--- a/engine/hp_bar.asm
+++ b/engine/hp_bar.asm
@@ -87,6 +87,7 @@
call UpdateHPBar_CompareNewHPToOldHP
jr z, .animateHPBarDone
jr nc, .HPIncrease
+; HP decrease
dec bc ; subtract 1 HP
ld a, c
ld [wHPBarNewHP], a
@@ -95,7 +96,7 @@
call UpdateHPBar_CalcOldNewHPBarPixels
ld a, e
sub d ; calc pixel difference
- jr .asm_fa7e
+ jr .ok
.HPIncrease
inc bc ; add 1 HP
ld a, c
@@ -105,7 +106,7 @@
call UpdateHPBar_CalcOldNewHPBarPixels
ld a, d
sub e ; calc pixel difference
-.asm_fa7e
+.ok
call UpdateHPBar_PrintHPNumber
and a
jr z, .noPixelDifference
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -21,7 +21,7 @@
call CopyData
pop af
ld l,a
- ld h,$0
+ ld h,0
ld de,InGameTradeTextPointers
add hl,hl
add hl,de
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -305,7 +305,7 @@
ld b, SET_PAL_GAME_FREAK_INTRO
call RunPaletteCommand
callba LoadCopyrightAndTextBoxTiles
- ld a, $e4
+ ld a, %11100100
ld [rBGP], a
ld c, 180
call DelayFrames
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -248,7 +248,7 @@
add "1"
.next
ld [hli], a
- ld [hl], $50
+ ld [hl], "@"
ld hl, MonWasStoredText
call PrintText
jp BillsPCMenu
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -7,7 +7,7 @@
coord hl, 0, 0
ld b, 4
ld c, 11
- call z, ClearScreenArea ; only if in wild batle
+ call z, ClearScreenArea ; only if in wild battle
ld a, [wcf91]
ld [wd11e], a
call GetMonName
@@ -40,7 +40,7 @@
pop af
ld [wUpdateSpritesEnabled], a
ld a, [wcf4b]
- cp $50
+ cp "@"
ret nz
.declinedNickname
ld d, h
@@ -108,7 +108,7 @@
ld [wMenuWatchedKeys], a
ld a, 7
ld [wMaxMenuItem], a
- ld a, $50
+ ld a, "@"
ld [wcf4b], a
xor a
ld hl, wNamingScreenSubmitName
@@ -153,7 +153,7 @@
ld h, [hl]
ld l, a
push de
- jp [hl]
+ jp hl
.submitNickname
pop de
@@ -259,7 +259,7 @@
.addLetter
ld a, [wNamingScreenLetter]
ld [hli], a
- ld [hl], $50
+ ld [hl], "@"
ld a, SFX_PRESS_AB
call PlaySound
ret
--- a/engine/menu/oaks_pc.asm
+++ b/engine/menu/oaks_pc.asm
@@ -7,9 +7,9 @@
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_1e932
+ jr nz, .closePC
predef DisplayDexRating
-.asm_1e932
+.closePC
ld hl, ClosedOaksPCText
call PrintText
jp LoadScreenTilesFromBuffer2
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -121,18 +121,18 @@
ld b, a
xor a
ld [hItemToRemoveIndex], a
-.asm_17f40
+.loop
ld a, [hli]
- cp $ff
+ cp -1 ; reached terminator?
ret z
cp b
- jr z, .asm_17f4f
+ jr z, .foundItem
inc hl
ld a, [hItemToRemoveIndex]
inc a
ld [hItemToRemoveIndex], a
- jr .asm_17f40
-.asm_17f4f
+ jr .loop
+.foundItem
ld a, $1
ld [wItemQuantity], a
ld a, [hItemToRemoveIndex]
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -125,6 +125,7 @@
call DrawTileLine ; cover up the menu cursor in the pokemon list
pop bc
ret
+
.buttonBPressed
push bc
coord hl, 15, 10
@@ -133,10 +134,12 @@
call DrawTileLine ; cover up the menu cursor in the side menu
pop bc
jr .exitSideMenu
+
.choseData
call ShowPokedexDataInternal
ld b,0
jr .exitSideMenu
+
; play pokemon cry
.choseCry
ld a,[wd11e]
@@ -143,6 +146,7 @@
call GetCryData
call PlaySound
jr .handleMenuInput
+
.choseArea
predef LoadTownMap_Nest ; display pokemon areas
ld b,0
@@ -206,6 +210,7 @@
dec c
jr nz,.maxSeenPokemonInnerLoop
jr .maxSeenPokemonLoop
+
.storeMaxSeenPokemon
ld a,b
ld [wDexMaxSeenMon],a
@@ -409,20 +414,25 @@
push af
xor a
ld [hTilesetType],a
+
coord hl, 0, 0
ld de,1
lb bc, $64, SCREEN_WIDTH
call DrawTileLine ; draw top border
+
coord hl, 0, 17
ld b, $6f
call DrawTileLine ; draw bottom border
+
coord hl, 0, 1
ld de,20
lb bc, $66, $10
call DrawTileLine ; draw left border
+
coord hl, 19, 1
ld b,$67
call DrawTileLine ; draw right border
+
ld a,$63 ; upper left corner tile
Coorda 0, 0
ld a,$65 ; upper right corner tile
@@ -431,15 +441,19 @@
Coorda 0, 17
ld a,$6e ; lower right corner tile
Coorda 19, 17
+
coord hl, 0, 9
ld de,PokedexDataDividerLine
call PlaceString ; draw horizontal divider line
+
coord hl, 9, 6
ld de,HeightWeightText
call PlaceString
+
call GetMonName
coord hl, 9, 2
call PlaceString
+
ld hl,PokedexEntryPointers
ld a,[wd11e]
dec a
@@ -450,8 +464,10 @@
ld a,[hli]
ld e,a
ld d,[hl] ; de = address of pokedex entry
+
coord hl, 9, 4
call PlaceString ; print species name
+
ld h,b
ld l,c
push de
@@ -458,6 +474,7 @@
ld a,[wd11e]
push af
call IndexToPokedex
+
coord hl, 2, 8
ld a, "№"
ld [hli],a
@@ -466,6 +483,7 @@
ld de,wd11e
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print pokedex number
+
ld hl,wPokedexOwned
call IsPokemonBitSet
pop af
@@ -473,10 +491,12 @@
ld a,[wcf91]
ld [wd0b5],a
pop de
+
push af
push bc
push de
push hl
+
call Delay3
call GBPalNormal
call GetMonHeader ; load pokemon picture location
@@ -484,10 +504,12 @@
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
ld a,[wcf91]
call PlayCry ; play pokemon cry
+
pop hl
pop de
pop bc
pop af
+
ld a,c
and a
jp z,.waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -23,8 +23,8 @@
ld [wTopMenuItemX],a
call PrintPrizePrice
coord hl, 0, 2
- ld b,$08
- ld c,$10
+ ld b, 8
+ ld c, 16
call TextBoxBorder
call GetPrizeMenuId
call UpdateSprites
@@ -32,12 +32,12 @@
call PrintText
call HandleMenuInput ; menu choice handler
bit 1,a ; keypress = B (Cancel)
- jr nz,.NoChoice
+ jr nz, .noChoice
ld a,[wCurrentMenuItem]
- cp a,$03 ; "NO,THANKS" choice
- jr z,.NoChoice
+ cp 3 ; "NO,THANKS" choice
+ jr z, .noChoice
call HandlePrizeChoice
-.NoChoice
+.noChoice
ld hl,wd730
res 6,[hl]
ret
@@ -65,7 +65,7 @@
; (distinguishing between Pokemon names
; and Items (specifically TMs) names)
ld a,[hSpriteIndexOrTextID]
- sub a,3 ; prize-texts' id are 3, 4 and 5
+ sub 3 ; prize-texts' id are 3, 4 and 5
ld [wWhichPrizeWindow],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
add a
add a
@@ -88,7 +88,7 @@
ld bc,6
call CopyData
ld a,[wWhichPrizeWindow]
- cp a,$02 ;is TM_menu?
+ cp 2 ;is TM_menu?
jr nz,.putMonName
ld a,[wPrize1]
ld [wd11e],a
@@ -138,7 +138,7 @@
call PrintBCDNumber
ld de,wPrize2Price
coord hl, 13, 7
- ld c,(%1 << 7 | 2)
+ ld c,(1 << 7 | 2)
call PrintBCDNumber
ld de,wPrize3Price
coord hl, 13, 9
@@ -149,15 +149,15 @@
PrintPrizePrice:
coord hl, 11, 0
- ld b,$01
- ld c,$07
+ ld b, 1
+ ld c, 7
call TextBoxBorder
call UpdateSprites
coord hl, 12, 0
- ld de,.CoinText
+ ld de, .CoinString
call PlaceString
coord hl, 13, 1
- ld de,.SixSpacesText
+ ld de, .SixSpacesString
call PlaceString
coord hl, 13, 1
ld de,wPlayerCoins
@@ -165,10 +165,10 @@
call PrintBCDNumber
ret
-.CoinText
+.CoinString:
db "COIN@"
-.SixSpacesText
+.SixSpacesString:
db " @"
LoadCoinsToSubtract:
@@ -196,33 +196,33 @@
ld a,[hl]
ld [wd11e],a
ld a,[wWhichPrizeWindow]
- cp a,$02 ; is prize a TM?
- jr nz,.GetMonName
+ cp 2 ; is prize a TM?
+ jr nz, .getMonName
call GetItemName
- jr .GivePrize
-.GetMonName
+ jr .givePrize
+.getMonName
call GetMonName
-.GivePrize
+.givePrize
ld hl,SoYouWantPrizeTextPtr
call PrintText
call YesNoChoice
ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
and a
- jr nz,.PrintOhFineThen
+ jr nz, .printOhFineThen
call LoadCoinsToSubtract
call HasEnoughCoins
- jr c,.NotEnoughCoins
+ jr c, .notEnoughCoins
ld a,[wWhichPrizeWindow]
- cp a,$02
- jr nz,.GiveMon
+ cp $02
+ jr nz, .giveMon
ld a,[wd11e]
ld b,a
ld a,1
ld c,a
call GiveItem
- jr nc,.BagFull
- jr .SubtractCoins
-.GiveMon
+ jr nc, .bagFull
+ jr .subtractCoins
+.giveMon
ld a,[wd11e]
ld [wcf91],a
push af
@@ -243,7 +243,7 @@
; were full), return without subtracting coins.
ret nc
-.SubtractCoins
+.subtractCoins
call LoadCoinsToSubtract
ld hl,hCoins + 1
ld de,wPlayerCoins + 1
@@ -250,17 +250,17 @@
ld c,$02 ; how many bytes
predef SubBCDPredef
jp PrintPrizePrice
-.BagFull
+.bagFull
ld hl,PrizeRoomBagIsFullTextPtr
jp PrintText
-.NotEnoughCoins
+.notEnoughCoins
ld hl,SorryNeedMoreCoinsText
jp PrintText
-.PrintOhFineThen
+.printOhFineThen
ld hl,OhFineThenTextPtr
jp PrintText
-UnknownData52951:
+UnknownPrizeData:
; XXX what's this?
db $00,$01,$00,$01,$00,$01,$00,$00,$01
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -34,7 +34,7 @@
ld [wTextBoxID],a
call DisplayTextBoxID ; display pokemon menu options
ld hl,wFieldMoves
- lb bc, $02, $0c ; max menu item ID, top menu item Y
+ lb bc, 2, 12 ; max menu item ID, top menu item Y
ld e,5
.adjustMenuVariablesLoop
dec e
@@ -222,7 +222,7 @@
res 4,[hl]
ld c,60
call DelayFrames
- call GBPalWhiteOutWithDelay3 ; zero all three palettes and wait 3 V-blanks
+ call GBPalWhiteOutWithDelay3
jp .goBackToMap
.warpToLastPokemonCenterText
TX_FAR _WarpToLastPokemonCenterText
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -249,8 +249,8 @@
and a ; a is 0 from the status screen
jr nz, .DifferentBox
coord hl, 0, 8
- ld b, $8
- ld c, $8
+ ld b, 8
+ ld c, 8
call TextBoxBorder ; Draws the box
coord hl, 1, 9 ; Start printing stats from here
ld bc, $0019 ; Number offset
@@ -257,8 +257,8 @@
jr .PrintStats
.DifferentBox
coord hl, 9, 2
- ld b, $8
- ld c, $9
+ ld b, 8
+ ld c, 9
call TextBoxBorder
coord hl, 11, 3
ld bc, $0018
@@ -279,7 +279,7 @@
call PrintStat
ld de, wLoadedMonSpecial
jp PrintNumber
-PrintStat
+PrintStat:
push hl
call PrintNumber
pop hl
--- a/engine/menu/vending_machine.asm
+++ b/engine/menu/vending_machine.asm
@@ -130,6 +130,9 @@
ret
VendingPrices:
- db FRESH_WATER,$00,$02,$00
- db SODA_POP, $00,$03,$00
- db LEMONADE, $00,$03,$50
+ db FRESH_WATER
+ money 200
+ db SODA_POP
+ money 300
+ db LEMONADE
+ money 350
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -132,7 +132,7 @@
ld hl, MonPartySpritePointers
ld a, $1c
ld bc, $0
-.asm_7179c
+.loop
push af
push bc
push hl
@@ -159,7 +159,7 @@
ld c, a
pop af
dec a
- jr nz, .asm_7179c
+ jr nz, .loop
jp EnableLCD
MonPartySpritePointers:
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -6,7 +6,7 @@
ld a, [wd732]
push af
ld hl, wPlayerName
- ld bc, $d8a
+ ld bc, wBoxDataEnd - wPlayerName
xor a
call FillMemory
ld hl, wSpriteStateData1
@@ -195,7 +195,7 @@
ld [rWX],a
call DelayFrame
- ld a,$E4
+ ld a,%11100100
ld [rBGP],a
.next
call DelayFrame
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -73,7 +73,7 @@
CardKeySuccessText:
TX_FAR _CardKeySuccessText1
- db $0b
+ TX_SFX_ITEM
TX_FAR _CardKeySuccessText2
db "@"
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -74,7 +74,7 @@
InitCutAnimOAM:
xor a
ld [wWhichAnimationOffsets], a
- ld a, $e4
+ ld a, %11100100
ld [rOBP1], a
ld a, [wCutTile]
cp $52
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -34,7 +34,7 @@
call PlayMusic
.musicLoop
ld a, [wChannelSoundIDs + CH4]
- cp $b9
+ cp SFX_SAFARI_ZONE_PA
jr z, .musicLoop
call UpdateSprites
jp PlayDefaultMusic
@@ -56,7 +56,7 @@
add hl, de
ld a, h
and $3
- or $98
+ or vBGMap0 / $100
ld d, a
ld a, l
pop hl
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -17,11 +17,11 @@
ld [wUpdateSpritesEnabled], a
ld a, [wd736]
bit 6, a ; are the last 4 OAM entries reserved for a shadow or fishing rod?
- ld hl, wOAMBuffer + $8f
- ld de, wOAMBuffer + $9f
+ ld hl, wOAMBuffer + 4 * 35 + $3 ; $8f
+ ld de, wOAMBuffer + 4 * 39 + $3 ; $9f
jr z, .next
- ld hl, wOAMBuffer + $7f
- ld de, wOAMBuffer + $8f
+ ld hl, wOAMBuffer + 4 * 31 + $3 ; $7f
+ ld de, wOAMBuffer + 4 * 35 + $3 ; $8f
; Copy OAM data 16 bytes forward to make room for emotion bubble OAM data at the
; start of the OAM buffer.
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -27,7 +27,7 @@
ld b, a
ld c, 1
call GiveItem
- jr nc, .BagFull
+ jr nc, .bagFull
ld hl, wObtainedHiddenItemsFlags
ld a, [wHiddenItemOrCoinsIndex]
ld c, a
@@ -37,7 +37,7 @@
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
jp TextScriptEnd
-.BagFull
+.bagFull
call WaitForTextScrollButtonPress ; wait for button press
xor a
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
@@ -77,24 +77,24 @@
cp 20
jr z, .bcd20
cp 40
- jr z, .bcd20
+ jr z, .bcd20 ; should be bcd40
jr .bcd100
.bcd10
ld a, $10
ld [hCoins + 1], a
- jr .bcddone
+ jr .bcdDone
.bcd20
ld a, $20
ld [hCoins + 1], a
- jr .bcddone
+ jr .bcdDone
.bcd40 ; due to a typo, this is never used
ld a, $40
ld [hCoins + 1], a
- jr .bcddone
+ jr .bcdDone
.bcd100
ld a, $1
ld [hCoins], a
-.bcddone
+.bcdDone
ld de, wPlayerCoins + 1
ld hl, hCoins + 1
ld c, $2
@@ -107,13 +107,13 @@
call EnableAutoTextBoxDrawing
ld a, [wPlayerCoins]
cp $99
- jr nz, .RoomInCoinCase
+ jr nz, .roomInCoinCase
ld a, [wPlayerCoins + 1]
cp $99
- jr nz, .RoomInCoinCase
+ jr nz, .roomInCoinCase
tx_pre_id DroppedHiddenCoinsText
jr .done
-.RoomInCoinCase
+.roomInCoinCase
tx_pre_id FoundHiddenCoinsText
.done
jp PrintPredefTextID
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -393,7 +393,7 @@
ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving:
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $8
ld l, a
@@ -408,7 +408,6 @@
ld a, [wd72d]
bit 5, a
jr nz, notYetMoving
-
res 7, [hl]
ld a, [wPlayerDirection]
bit PLAYER_DIR_BIT_UP, a
@@ -449,7 +448,7 @@
; calculates the spprite's scrren position form its map position and the player position
InitializeSpriteScreenPosition:
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
@@ -477,7 +476,7 @@
ld a, [$ffe5]
and a
jp nz, .spriteInvisible
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $6
ld l, a
@@ -525,7 +524,7 @@
cp d
jr c, .spriteVisible ; standing on tile with ID >=$60 (top right tile)
.spriteInvisible
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $2
ld l, a
@@ -579,7 +578,7 @@
; e: X movement delta (-1, 0 or 1)
; set carry on failure, clears carry on success
CanWalkOntoTile:
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $6
ld l, a
@@ -607,7 +606,7 @@
ld a, [hl] ; $c2x6 (movement byte 1)
inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
@@ -626,7 +625,7 @@
call DetectCollisionBetweenSprites
pop bc
pop de
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $c
ld l, a
@@ -633,7 +632,7 @@
ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $2
ld l, a
@@ -690,7 +689,7 @@
; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to
; hl: output pointer
GetTileSpriteStandsOn:
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
--- a/engine/overworld/oam.asm
+++ b/engine/overworld/oam.asm
@@ -6,7 +6,7 @@
dec a
jr z, .updateEnabled
- cp 0 - 1
+ cp -1
ret nz
ld [wUpdateSpritesEnabled], a
jp HideSprites
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -388,7 +388,7 @@
set 6, [hl] ; reserve the last 4 OAM entries
ld de, RedSprite
ld hl, vNPCSprites
- lb bc, BANK(RedSprite), $0c
+ lb bc, BANK(RedSprite), $c
call CopyVideoData
ld a, $4
ld hl, RedFishingTiles
--- a/engine/overworld/pokemart.asm
+++ b/engine/overworld/pokemart.asm
@@ -85,7 +85,7 @@
lb bc, 14, 1 ; location that PrintText always prints to, this is useless
call PrintText
coord hl, 14, 7
- lb bc, 08, 15
+ lb bc, 8, 15
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -4,16 +4,16 @@
ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
- ld a, [hli]
+ ld a, [hli] ; c1x4 (screen Y pos)
ld [$ffeb], a
inc hl
- ld a, [hl]
+ ld a, [hl] ; c1x6 (screen X pos)
ld [$ffec], a
- ld de, $fe
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
- ld a, [hli]
+ ld a, [hli] ; c2x4 (map Y pos)
ld [$ffed], a
- ld a, [hl]
+ ld a, [hl] ; c2x5 (map X pos)
ld [$ffee], a
ret
@@ -28,7 +28,7 @@
inc hl
ld a, [hl] ; c1x6 (screen X pos)
ld [wSavedSpriteScreenX], a
- ld de, $104 - $6
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
ld [wSavedSpriteMapY], a
@@ -47,7 +47,7 @@
inc hl
ld a, [$ffec] ; c1x6 (screen X pos)
ld [hl], a
- ld de, $104 - $6
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [$ffed] ; c2x4 (map Y pos)
ld [hli], a
@@ -57,21 +57,21 @@
_SetSpritePosition2:
ld hl, wSpriteStateData1
- ld de, $0004
+ ld de, 4
ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [wSavedSpriteScreenY]
- ld [hli], a
+ ld [hli], a ; c1x4 (screen Y pos)
inc hl
ld a, [wSavedSpriteScreenX]
- ld [hl], a
- ld de, $00fe
+ ld [hl], a ; c1x6 (screen X pos)
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [wSavedSpriteMapY]
- ld [hli], a
+ ld [hli], a ; c2x4 (map Y pos)
ld a, [wSavedSpriteMapX]
- ld [hl], a
+ ld [hl], a ; c2x5 (map X pos)
ret
TrainerWalkUpToPlayer:
@@ -80,11 +80,11 @@
ld [wTrainerSpriteOffset], a
call ReadTrainerScreenPosition
ld a, [wTrainerFacingDirection]
- and a
+ and a ; SPRITE_FACING_DOWN
jr z, .facingDown
- cp $4
+ cp SPRITE_FACING_UP
jr z, .facingUp
- cp $8
+ cp SPRITE_FACING_LEFT
jr z, .facingLeft
jr .facingRight
.facingDown
@@ -148,7 +148,7 @@
jp MoveSprite_
; input: de = offset within sprite entry
-; output: de = pointer to sprite data
+; output: hl = pointer to sprite data
GetSpriteDataPointer:
push de
add hl, de
@@ -225,7 +225,7 @@
set 0, [hl]
call EngageMapTrainer
ld a, $ff
-.noEngage:
+.noEngage
ld [wTrainerSpriteOffset], a
pop de
pop hl
@@ -239,7 +239,7 @@
ld e, a
ld hl, wSpriteStateData1
add hl, de
- ld a, [hl]
+ ld a, [hl] ; c1x4 (sprite Y pos)
ld [wTrainerScreenY], a
ld a, [wTrainerSpriteOffset]
add $6
@@ -247,7 +247,7 @@
ld e, a
ld hl, wSpriteStateData1
add hl, de
- ld a, [hl]
+ ld a, [hl] ; c1x6 (sprite X pos)
ld [wTrainerScreenX], a
ret
@@ -262,13 +262,13 @@
jr .notInLine ; player too far away
.checkIfLinedUp
ld a, [wTrainerFacingDirection] ; sprite facing direction
- cp $0 ; down
+ cp SPRITE_FACING_DOWN
jr z, .checkXCoord
- cp $4 ; up
+ cp SPRITE_FACING_UP
jr z, .checkXCoord
- cp $8 ; left
+ cp SPRITE_FACING_LEFT
jr z, .checkYCoord
- cp $c ; right
+ cp SPRITE_FACING_RIGHT
jr z, .checkYCoord
jr .notInLine
.checkXCoord
@@ -315,7 +315,7 @@
ld a, [hl] ; c1x6 (sprite screen X pos)
ld [wTrainerScreenX], a
ld a, [wTrainerFacingDirection] ; facing direction
- cp $0
+ cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
ld a, [wTrainerScreenY] ; sprite screen Y pos
cp $3c
@@ -322,7 +322,7 @@
jr c, .engage ; sprite above player
jr .noEngage ; sprite below player
.notFacingDown
- cp $4
+ cp SPRITE_FACING_UP
jr nz, .notFacingUp
ld a, [wTrainerScreenY] ; sprite screen Y pos
cp $3c
@@ -329,7 +329,7 @@
jr nc, .engage ; sprite below player
jr .noEngage ; sprite above player
.notFacingUp
- cp $8
+ cp SPRITE_FACING_LEFT
jr nz, .notFacingLeft
ld a, [wTrainerScreenX] ; sprite screen X pos
cp $40
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -27,10 +27,10 @@
add a
add e
ld e,a
- jr nc,.next
+ jr nc, .nocarry
inc d
-.next
+.nocarry
add hl,de
ld d,h
ld e,l
@@ -60,7 +60,7 @@
add_predef CopyDownscaledMonTiles
add_predef LoadMissableObjects
add_predef HealParty
- add_predef MoveAnimation; 08 play move animation
+ add_predef MoveAnimation
add_predef DivideBCDPredef
add_predef DivideBCDPredef2
add_predef AddBCDPredef
@@ -81,8 +81,8 @@
add_predef LearnMoveFromLevelUp
add_predef LearnMove
add_predef GetQuantityOfItemInBag
- dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0
- dbw $03,GiveItem
+ dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; home bank
+ dbw $03,GiveItem ; home bank
add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
add_predef PredefShakeScreenVertically
@@ -122,7 +122,7 @@
add_predef CanLearnTM
add_predef TMToMove
add_predef _RunPaletteCommand
- add_predef StarterDex ; 46
+ add_predef StarterDex
add_predef _AddPartyMon
add_predef UpdateHPBar2
add_predef DrawEnemyHUDAndHPBar
@@ -147,7 +147,7 @@
add_predef PickUpItem
add_predef PrintMoveType
add_predef LoadMovePPs
- add_predef DrawHP ; 5F
+ add_predef DrawHP
add_predef DrawHP2
add_predef DisplayElevatorFloorMenu
add_predef OaksAideScript
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -638,7 +638,7 @@
ld a, [wNumHoFTeams]
dec a
cp HOF_TEAM_CAPACITY
- jr nc, .asm_73b28
+ jr nc, .shiftHOFTeams
ld hl, sHallOfFame
ld bc, HOF_TEAM
call AddNTimes
@@ -648,7 +648,9 @@
ld bc, HOF_TEAM
jr HallOfFame_Copy
-.asm_73b28
+.shiftHOFTeams
+; if the space designated for HOF teams is full, then shift all HOF teams to the next slot, making space for the new HOF team
+; this deletes the last HOF team though
ld hl, sHallOfFame + HOF_TEAM
ld de, sHallOfFame
ld bc, HOF_TEAM * (HOF_TEAM_CAPACITY - 1)
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -864,7 +864,7 @@
call FarCopyData2
ld hl, SlotMachineMap
coord de, 0, 0
- ld bc, $00f0
+ ld bc, SlotMachineMapEnd - SlotMachineMap
call CopyData
call EnableLCD
ld hl, wSlotMachineWheel1Offset
@@ -878,6 +878,7 @@
SlotMachineMap:
INCBIN "gfx/tilemaps/slotmachine.map"
+SlotMachineMapEnd:
INCLUDE "data/slot_machine_wheels.asm"
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -169,7 +169,7 @@
db -1,2
db 0 ; terminate list with 0
-.ScrollTitleScreenPokemonLogo
+.ScrollTitleScreenPokemonLogo:
; Scrolls the Pokemon logo on the title screen to create the bouncing effect
; Scrolls d pixels e times
call DelayFrame
--- a/engine/titlescreen2.asm
+++ b/engine/titlescreen2.asm
@@ -67,7 +67,7 @@
pop bc
jr _TitleScroll
-.ScrollBetween
+.ScrollBetween:
.wait
ld a, [rLY] ; rLY
cp l
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -141,7 +141,7 @@
call LoadFontTilePatterns
ld de, BirdSprite
ld hl, vSprites + $40
- lb bc, BANK(BirdSprite), $0c
+ lb bc, BANK(BirdSprite), $c
call CopyVideoData
ld de, TownMapUpArrow
ld hl, vChars1 + $6d0
@@ -179,7 +179,7 @@
ld c, 15
call DelayFrames
coord hl, 18, 0
- ld [hl], $ed
+ ld [hl], "▶"
coord hl, 19, 0
ld [hl], $ee
pop hl
@@ -355,12 +355,12 @@
call WritePlayerOrBirdSpriteOAM
pop hl
ld de, wcd6d
-.asm_711dc
+.loop
ld a, [hli]
ld [de], a
inc de
- cp $50
- jr nz, .asm_711dc
+ cp "@"
+ jr nz, .loop
ld hl, wOAMBuffer
ld de, wTileMapBackup
ld bc, $a0
@@ -397,8 +397,8 @@
jr nz, .drawPlayerSprite
; if no OAM entries were written, print area unknown text
coord hl, 1, 7
- ld b, $2
- ld c, $f
+ ld b, 2
+ ld c, 15
call TextBoxBorder
coord hl, 2, 9
ld de, AreaUnknownText
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -305,7 +305,7 @@
ld [rOBP0], a
xor a
ld [wLinkCableAnimBulgeToggle], a
- ld bc, $2060
+ lb bc, $20, $60
.moveBallInsideLinkCableLoop
push bc
xor a
@@ -380,7 +380,7 @@
call Trade_InitGameboyTransferGfx
ld a, $1
ld [wTradedMonMovingRight], a
- ld a, $e4
+ ld a, %11100100
ld [rOBP0], a
ld a, $54
ld [wBaseCoordX], a
@@ -466,7 +466,7 @@
ld a, $5d
ld [hli], a
ld a, $5e
- ld c, $8
+ ld c, 8
.loop
ld [hli], a
dec c
@@ -526,8 +526,8 @@
; draw text box with enemy name above link cable
coord hl, 6, 0
- ld b, $2
- ld c, $7
+ ld b, 2
+ ld c, 7
call TextBoxBorder
coord hl, 7, 2
ld de, wLinkEnemyTrainerName
--- a/home.asm
+++ b/home.asm
@@ -4710,8 +4710,8 @@
add_tx_pre LinkCableHelp ; 34
add_tx_pre TMNotebook ; 35
add_tx_pre FightingDojoText ; 36
- add_tx_pre FightingDojoText_52a10 ; 37
- add_tx_pre FightingDojoText_52a1d ; 38
+ add_tx_pre EnemiesOnEverySideText ; 37
+ add_tx_pre WhatGoesAroundComesAroundText ; 38
add_tx_pre NewBicycleText ; 39
add_tx_pre IndigoPlateauStatues ; 3A
add_tx_pre VermilionGymTrashSuccessText1 ; 3B
--- a/text.asm
+++ b/text.asm
@@ -781,12 +781,12 @@
line "#MON LEAGUE!"
prompt
-_FightingDojoText_52a10::
+_EnemiesOnEverySideText::
text "Enemies on every"
line "side!"
done
-_FightingDojoText_52a1d::
+_WhatGoesAroundComesAroundText::
text "What goes around"
line "comes around!"
done
--- a/wram.asm
+++ b/wram.asm
@@ -1778,7 +1778,7 @@
wEnemyConfusedCounter:: ; d070
ds 1
-wEnemyToxcCounter:: ; d071
+wEnemyToxicCounter:: ; d071
ds 1
wEnemyDisabledMove:: ; d072