ref: e16dec874a239c162680b169391d3c0c7ee1fc70
parent: 2a4b8b5a248065d2ef80b9960228750112f30da5
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Thu Nov 5 11:55:39 EST 2020
Sync more with pokeyellow
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -133,7 +133,7 @@
.afterDrawingTiles
ld a, [wFBMode]
cp FRAMEBLOCKMODE_02
- jr z, .advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
+ jr z, .advanceFrameBlockDestAddr ; skip delay and don't clean OAM buffer
ld a, [wSubAnimFrameDelay]
ld c, a
call DelayFrames
@@ -2410,7 +2410,7 @@
ret
FallingObjects_InitialXCoords:
- db $38,$40,$50,$60,$70,$88,$90,$56,$67,$4A,$77,$84,$98,$32,$22,$5C,$6C,$7D,$8E,$99
+ db $38, $40, $50, $60, $70, $88, $90, $56, $67, $4A, $77, $84, $98, $32, $22, $5C, $6C, $7D, $8E, $99
FallingObjects_InitMovementData:
ld hl, wFallingObjectsMovementData
@@ -2426,7 +2426,7 @@
ret
FallingObjects_InitialMovementData:
- db $00,$84,$06,$81,$02,$88,$01,$83,$05,$89,$09,$80,$07,$87,$03,$82,$04,$85,$08,$86
+ db $00, $84, $06, $81, $02, $88, $01, $83, $05, $89, $09, $80, $07, $87, $03, $82, $04, $85, $08, $86
AnimationShakeEnemyHUD:
; Shakes the enemy HUD.
@@ -2583,7 +2583,7 @@
.PokeBallAnimations:
; sequence of animations that make up the Poké Ball toss
- db POOF_ANIM,HIDEPIC_ANIM,SHAKE_ANIM,POOF_ANIM,SHOWPIC_ANIM
+ db POOF_ANIM, HIDEPIC_ANIM, SHAKE_ANIM, POOF_ANIM, SHOWPIC_ANIM
.BlockBall
ld a, TOSS_ANIM
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -1098,7 +1098,7 @@
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr nz, .notLinkBattle
- inc a
+ inc a ; 1
ld [wActionResultOrTookBattleTurn], a
call LinkBattleExchangeData
.notLinkBattle
@@ -1724,7 +1724,7 @@
ld hl, wEnemyMonHP
ld a, [hli]
or [hl] ; is enemy mon HP zero?
- jp z, .skipDrawingEnemyHUDAndHPBar; if HP is zero, skip drawing the HUD and HP bar
+ jp z, .skipDrawingEnemyHUDAndHPBar ; if HP is zero, skip drawing the HUD and HP bar
call DrawEnemyHUDAndHPBar
.skipDrawingEnemyHUDAndHPBar
call DrawPlayerHUDAndHPBar
@@ -2017,14 +2017,16 @@
dec a
jp nz, .handleBattleMenuInput ; handle menu input if it's not the old man tutorial
; the following happens for the old man tutorial
+ ; Temporarily save the player name in wGrassRate,
+ ; which is supposed to get overwritten when entering a
+ ; map with wild Pokémon.
+ ; Due to an oversight, the data may not get
+ ; overwritten (on Cinnabar and Route 21) and the infamous
+ ; Missingno. glitch can show up.
ld hl, wPlayerName
ld de, wGrassRate
ld bc, NAME_LENGTH
- call CopyData ; temporarily save the player name in unused space,
- ; which is supposed to get overwritten when entering a
- ; map with wild Pokémon. Due to an oversight, the data
- ; may not get overwritten (cinnabar) and the infamous
- ; Missingno. glitch can show up.
+ call CopyData
ld hl, .oldManName
ld de, wPlayerName
ld bc, NAME_LENGTH
@@ -2206,7 +2208,7 @@
OldManItemList:
db 1 ; # items
db POKE_BALL, 50
- db -1
+ db -1 ; end
DisplayPlayerBag:
; get the pointer to player's bag when in a normal battle
@@ -4101,7 +4103,7 @@
call GetCurrentMove
.canUseMove
ld a, $1
- and a; clear Z flag
+ and a ; clear Z flag
ret
.cannotUseMove
xor a ; set Z flag
@@ -4574,7 +4576,7 @@
INCLUDE "data/battle/unused_critical_hit_moves.asm"
; determines if attack is a critical hit
-; azure heights claims "the fastest pokémon (who are,not coincidentally,
+; Azure Heights claims "the fastest pokémon (who are, not coincidentally,
; among the most popular) tend to CH about 20 to 25% of the time."
CriticalHitTest:
xor a
--- a/engine/battle/decrement_pp.asm
+++ b/engine/battle/decrement_pp.asm
@@ -37,7 +37,7 @@
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
+ add hl, bc ; calculate the address in memory of the PP we need to decrement
; based on the move chosen.
dec [hl] ; Decrement PP
ret
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -198,7 +198,7 @@
ret nz ; return if they have a substitute, can't effect them
ldh a, [hWhoseTurn]
and a
- jp nz, opponentAttacker
+ jp nz, .opponentAttacker
ld a, [wEnemyMonStatus]
and a
jp nz, CheckDefrost ; can't inflict status if opponent is already statused
@@ -224,10 +224,10 @@
ret nc ; do nothing if random value is >= 1A or 4D [no status applied]
ld a, b ; what type of effect is this?
cp BURN_SIDE_EFFECT1
- jr z, .burn
+ jr z, .burn1
cp FREEZE_SIDE_EFFECT
- jr z, .freeze
-; .paralyze
+ jr z, .freeze1
+; .paralyze1
ld a, 1 << PAR
ld [wEnemyMonStatus], a
call QuarterSpeedDueToParalysis ; quarter speed of affected mon
@@ -234,7 +234,7 @@
ld a, ANIM_A9
call PlayBattleAnimation
jp PrintMayNotAttackText ; print paralysis text
-.burn
+.burn1
ld a, 1 << BRN
ld [wEnemyMonStatus], a
call HalveAttackDueToBurn ; halve attack of affected mon
@@ -242,7 +242,7 @@
call PlayBattleAnimation
ld hl, BurnedText
jp PrintText
-.freeze
+.freeze1
call ClearHyperBeam ; resets hyper beam (recharge) condition from target
ld a, 1 << FRZ
ld [wEnemyMonStatus], a
@@ -250,7 +250,7 @@
call PlayBattleAnimation
ld hl, FrozenText
jp PrintText
-opponentAttacker:
+.opponentAttacker
ld a, [wBattleMonStatus] ; mostly same as above with addresses swapped for opponent
and a
jp nz, CheckDefrost
@@ -265,10 +265,10 @@
ld a, [wEnemyMoveEffect]
cp PARALYZE_SIDE_EFFECT1 + 1
ld b, $1a
- jr c, .next1
+ jr c, .next2
ld b, $4d
sub $1e
-.next1
+.next2
push af
call BattleRandom
cp b
@@ -276,20 +276,21 @@
ret nc
ld a, b
cp BURN_SIDE_EFFECT1
- jr z, .burn
+ jr z, .burn2
cp FREEZE_SIDE_EFFECT
- jr z, .freeze
+ jr z, .freeze2
+; .paralyze2
ld a, 1 << PAR
ld [wBattleMonStatus], a
call QuarterSpeedDueToParalysis
jp PrintMayNotAttackText
-.burn
+.burn2
ld a, 1 << BRN
ld [wBattleMonStatus], a
call HalveAttackDueToBurn
ld hl, BurnedText
jp PrintText
-.freeze
+.freeze2
; hyper beam bits aren't reseted for opponent's side
ld a, 1 << FRZ
ld [wBattleMonStatus], a
@@ -458,14 +459,14 @@
ld bc, wPlayerMonMinimized
ldh a, [hWhoseTurn]
and a
- jr z, .asm_3f4e6
+ jr z, .playerTurn
ld hl, wEnemyBattleStatus2
ld de, wEnemyMoveNum
ld bc, wEnemyMonMinimized
-.asm_3f4e6
+.playerTurn
ld a, [de]
cp MINIMIZE
- jr nz, .asm_3f4f9
+ jr nz, .notMinimize
; if a substitute is up, slide off the substitute and show the mon pic before
; playing the minimize animation
bit HAS_SUBSTITUTE_UP, [hl]
@@ -476,7 +477,7 @@
push de
call nz, Bankswitch
pop de
-.asm_3f4f9
+.notMinimize
call PlayCurrentMoveAnimation
ld a, [de]
cp MINIMIZE
--- a/engine/battle/ghost_marowak_anim.asm
+++ b/engine/battle/ghost_marowak_anim.asm
@@ -74,7 +74,7 @@
ld [hli], a
ld a, d
ld [hli], a
- ld a, $10 ; use OBP1
+ ld a, OAM_OBP1
ld [hli], a
inc d
dec c
--- a/engine/battle/move_effects/heal.asm
+++ b/engine/battle/move_effects/heal.asm
@@ -86,7 +86,7 @@
ld [wHPBarNewHP], a
.playAnim
ld hl, PlayCurrentMoveAnimation
- call BankswitchEtoF
+ call EffectCallBattleCore
ldh a, [hWhoseTurn]
and a
hlcoord 10, 9
@@ -98,7 +98,7 @@
ld [wHPBarType], a
predef UpdateHPBar2
ld hl, DrawHUDsAndHPBars
- call BankswitchEtoF
+ call EffectCallBattleCore
ld hl, RegainedHealthText
jp PrintText
.failed
@@ -105,7 +105,7 @@
ld c, 50
call DelayFrames
ld hl, PrintButItFailedText_
- jp BankswitchEtoF
+ jp EffectCallBattleCore
StartedSleepingEffect:
text_far _StartedSleepingEffect
--- a/engine/battle/move_effects/reflect_light_screen.asm
+++ b/engine/battle/move_effects/reflect_light_screen.asm
@@ -23,7 +23,7 @@
.playAnim
push hl
ld hl, PlayCurrentMoveAnimation
- call BankswitchEtoF
+ call EffectCallBattleCore
pop hl
jp PrintText
.moveFailed
@@ -30,7 +30,7 @@
ld c, 50
call DelayFrames
ld hl, PrintButItFailedText_
- jp BankswitchEtoF
+ jp EffectCallBattleCore
LightScreenProtectedText:
text_far _LightScreenProtectedText
@@ -40,6 +40,6 @@
text_far _ReflectGainedArmorText
text_end
-BankswitchEtoF:
+EffectCallBattleCore:
ld b, BANK(BattleCore)
jp Bankswitch
--- a/engine/battle/move_effects/transform.asm
+++ b/engine/battle/move_effects/transform.asm
@@ -141,7 +141,7 @@
.failed
ld hl, PrintButItFailedText_
- jp BankswitchEtoF
+ jp EffectCallBattleCore
TransformedText:
text_far _TransformedText
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -16,7 +16,7 @@
; get the pointer to trainer data for this class
ld a, [wCurOpponent]
- sub $C9 ; convert value from pokemon to trainer
+ sub OPP_ID_OFFSET + 1 ; convert value from pokemon to trainer
add a
ld hl, TrainerDataPointers
ld c, a
@@ -79,7 +79,7 @@
pop hl
jr .SpecialTrainer
.AddLoneMove
-; does the trainer have a single monster with a different move
+; does the trainer have a single monster with a different move?
ld a, [wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
and a
jr z, .AddTeamMove
--- a/engine/battle/safari_zone.asm
+++ b/engine/battle/safari_zone.asm
@@ -2,11 +2,11 @@
ld hl, wSafariBaitFactor
ld a, [hl]
and a
- jr z, .asm_4284
+ jr z, .no_bait
dec [hl]
ld hl, SafariZoneEatingText
- jr .asm_429f
-.asm_4284
+ jr .done
+.no_bait
dec hl
ld a, [hl]
and a
@@ -13,7 +13,7 @@
ret z
dec [hl]
ld hl, SafariZoneAngryText
- jr nz, .asm_429f
+ jr nz, .done
push hl
ld a, [wEnemyMonSpecies]
ld [wd0b5], a
@@ -21,7 +21,7 @@
ld a, [wMonHCatchRate]
ld [wEnemyMonActualCatchRate], a
pop hl
-.asm_429f
+.done
push hl
call LoadScreenTilesFromBuffer1
pop hl
--- a/engine/battle/scale_sprites.asm
+++ b/engine/battle/scale_sprites.asm
@@ -4,11 +4,11 @@
ScaleSpriteByTwo:
ld de, sSpriteBuffer1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
ld hl, sSpriteBuffer0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
- call ScaleLastSpriteColumnByTwo ; last tile column is special case
- call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns
+ call ScaleLastSpriteColumnByTwo ; last tile column is special case
+ call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns
ld de, sSpriteBuffer2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
ld hl, sSpriteBuffer1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
- call ScaleLastSpriteColumnByTwo ; last tile column is special case
+ call ScaleLastSpriteColumnByTwo ; last tile column is special case
ScaleFirstThreeSpriteColumnsByTwo:
ld b, $3 ; 3 tile columns
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -294,7 +294,7 @@
ret z ; if not a trainer, we're done here
ld a, [wLinkState]
cp LINK_STATE_BATTLING
- ret z
+ ret z ; if in a link battle, we're done as well
ld a, [wTrainerClass] ; what trainer class is this?
dec a
ld c, a
--- a/engine/gfx/palettes.asm
+++ b/engine/gfx/palettes.asm
@@ -353,10 +353,10 @@
ld d, a
.nextBit0
bit 0, d
-; if 0th bit is not zero set P14=HIGH,P15=LOW (send bit 1)
+; if 0th bit is not zero set P14=HIGH, P15=LOW (send bit 1)
ld a, $10
jr nz, .next0
-; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0)
+; else (if 0th bit is zero) set P14=LOW, P15=HIGH (send bit 0)
ld a, $20
.next0
ldh [rJOYP], a
@@ -364,7 +364,7 @@
ld a, $30
ldh [rJOYP], a
; rotation will put next bit in 0th position (so we can always use command
-; "bit 0,d" to fetch the bit that has to be sent)
+; "bit 0, d" to fetch the bit that has to be sent)
rr d
; decrease bit counter so we know when we have sent all 8 bits of current byte
dec e
@@ -608,9 +608,7 @@
; This function converts 2BPP planar data into this format by mapping
; 2BPP colors 0-3 to 4BPP colors 0-3. 4BPP colors 4-15 are not used.
ld b, 128
-
.tileLoop
-
; Copy bit planes 1 and 2 of the tile data.
ld c, 16
.copyLoop
--- a/engine/gfx/screen_effects.asm
+++ b/engine/gfx/screen_effects.asm
@@ -1,4 +1,4 @@
-; b = new colour for BG colour 0 (usually white) for 4 frames
+; b = new color for BG color 0 (usually white) for 4 frames
ChangeBGPalColor0_4Frames:
call GetPredefRegisters
ldh a, [rBGP]
--- a/home/clear_sprites.asm
+++ b/home/clear_sprites.asm
@@ -1,7 +1,7 @@
ClearSprites::
xor a
ld hl, wOAMBuffer
- ld b, 40 * 4
+ ld b, wOAMBufferEnd - wOAMBuffer
.loop
ld [hli], a
dec b
--- a/home/uncompress.asm
+++ b/home/uncompress.asm
@@ -561,7 +561,7 @@
; maps each nybble to its reverse
NybbleReverseTable::
- db $0, $8, $4, $c, $2, $a, $6 ,$e, $1, $9, $5, $d, $3, $b, $7 ,$f
+ db $0, $8, $4, $c, $2, $a, $6, $e, $1, $9, $5, $d, $3, $b, $7, $f
; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differeintial decoded beforehand.
UnpackSpriteMode2::
--- a/hram.asm
+++ b/hram.asm
@@ -96,8 +96,8 @@
hSpritePriority:: db
UNION
-;; Multiplication and division variables are meant
-;; to overlap for back-to-back usage. Big endian.
+; Multiplication and division variables are meant
+; to overlap for back-to-back usage. Big endian.
UNION
ds 1
hMultiplicand:: ds 3
--- a/wram.asm
+++ b/wram.asm
@@ -239,32 +239,40 @@
wOAMBuffer::
; buffer for OAM data. Copied to OAM by DMA
ds 4 * 40
+wOAMBufferEnd::
wTileMap::
; buffer for tiles that are visible on screen (20 columns by 18 rows)
- ds 20 * 18
+ ds SCREEN_WIDTH * SCREEN_HEIGHT
-wSerialPartyMonsPatchList::
-; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer
-
+UNION
wTileMapBackup::
; buffer for temporarily saving and restoring current screen's tiles
; (e.g. if menus are drawn on top)
-; ds 20 * 18
+ ds SCREEN_WIDTH * SCREEN_HEIGHT
+NEXTU
+wSerialPartyMonsPatchList::
+; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer
ds 200
wSerialEnemyMonsPatchList::
; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer
ds 200
+ENDU
ds 80
-wTempPic::
+UNION
wOverworldMap::
ds 1300
wOverworldMapEnd::
+NEXTU
+wTempPic::
+ ds 7 * 7 tiles
+ENDU
+
wRedrawRowOrColumnSrcTiles::
; the tiles of the row or column to be redrawn by RedrawRowOrColumn
ds SCREEN_WIDTH * 2
@@ -399,10 +407,9 @@
; 2 bytes
wEnteringCableClub::
- ds 1
+; 1 byte
+ ds 2
- ds 1
-
wWhichTradeMonSelectionMenu::
; $00 = player mons
; $01 = enemy mons
@@ -509,16 +516,25 @@
ds 29
+UNION
wNPCMovementDirections2::
+ ds 10
+NEXTU
wSwitchPartyMonTempBuffer::
; temporary buffer when swapping party mon data
+ ds 49
+
+NEXTU
ds 10
wNumStepsToTake::
; used in Pallet Town scripted movement
- ds 49
+ ds 1
+ENDU
+ ds 10
+
wRLEByteCount::
ds 1
@@ -595,7 +611,7 @@
wSafariEscapeFactor::
ds 1
wSafariBaitFactor::
- ds 1;
+ ds 1
ds 1
@@ -823,8 +839,6 @@
wOptionsTextSpeedCursorX::
-wBoxNumString::
-
wTrainerInfoTextBoxWidthPlus1::
wSwappedMenuItem::
@@ -861,6 +875,8 @@
wPlayerSpinWhileMovingUpOrDownAnimDeltaY::
+wBoxNumString::
+
wHiddenObjectFunctionArgument::
wWhichTrade::
@@ -1350,7 +1366,9 @@
; 2-byte big-endian number
; the total amount of exp a mon gained
-wcf4b:: ds 2 ; storage buffer for various strings
+wcf4b::
+; storage buffer for various strings
+ ds 2
wGainBoostedExp::
ds 1
@@ -1987,7 +2005,6 @@
ds 2
-
wDamage::
ds 2
@@ -2725,7 +2742,8 @@
wVictoryRoad2FCurScript::
ds 1
wVictoryRoad3FCurScript::
- ds 2
+ ds 1
+ ds 1
wFightingDojoCurScript::
ds 1
wSilphCo2FCurScript::
@@ -2972,8 +2990,10 @@
wBeatLorelei::
; bit 1: set when you beat Lorelei and reset in Indigo Plateau lobby
; the game uses this to tell when Elite 4 events need to be reset
- ds 2
+ ds 1
+ ds 1
+
wd736::
; bit 0: check if the player is standing on a door and make him walk down a step if so
; bit 1: the player is currently stepping down from a door
@@ -3010,6 +3030,7 @@
ds 1
ds 2
+
wEventFlags::
flag_array NUM_EVENTS
@@ -3020,7 +3041,7 @@
ds 1
wGrassMons::
- ;ds 20
+; ds 20
ds 11
; Overload wGrassMons
@@ -3119,6 +3140,7 @@
SECTION "Stack", WRAM0
+
wStack::