ref: 04a6c306dce136873fd33d27aa3d5b90d9eeba5a
parent: c34156c5fb333864c1ae85036ea587c9f615a65a
author: YamaArashi <shadow962@live.com>
date: Thu Jul 23 02:07:12 EDT 2015
clean up wram aliases
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -1,5 +1,5 @@
BattleTransition: ; 7096d (1c:496d)
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
xor a
@@ -7,10 +7,13 @@
dec a
ld [wUpdateSpritesEnabled], a
call DelayFrame
+
+; Determine which OAM block is being used by the enemy trainer sprite (if there
+; is one).
ld hl, wSpriteStateData1 + 2
- ld a, [H_DOWNARROWBLINKCNT2]
+ ld a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
ld c, a
- ld b, $0
+ ld b, 0
ld de, $10
.loop1
ld a, [hl]
@@ -21,13 +24,15 @@
add hl, de
dec c
jr nz, .loop1
+
+; Clear OAM except for the blocks used by the player and enemy trainer sprites.
ld hl, wOAMBuffer + $10
- ld c, $9
+ ld c, 9
.loop2
ld a, b
swap a
cp l
- jr z, .skip2
+ jr z, .skip2 ; skip clearing the block if the enemy trainer is using it
push hl
push bc
ld bc, $10
@@ -40,9 +45,10 @@
add hl, de
dec c
jr nz, .loop2
+
call Delay3
call LoadBattleTransitionTile
- ld bc, $0
+ ld bc, 0
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .linkBattle
@@ -103,7 +109,7 @@
sub e
jr nc, .highLevelEnemy
res 1, c
- ld a, $1
+ ld a, 1
ld [wBattleTransitionSpiralDirection], a
ret
.highLevelEnemy
@@ -229,10 +235,10 @@
ret
BattleTransition_InwardSpiral: ; 70aaa (1c:4aaa)
- ld a, $7
- ld [wWhichTrade], a
+ ld a, 7
+ ld [wInwardSpiralUpdateScreenCounter], a
coord hl, 0, 0
- ld c, $11
+ ld c, SCREEN_HEIGHT - 1
ld de, SCREEN_WIDTH
call BattleTransition_InwardSpiral_
inc c
@@ -242,7 +248,7 @@
call BattleTransition_InwardSpiral_
.skip
inc c
- ld de, $1
+ ld de, 1
call BattleTransition_InwardSpiral_
dec c
dec c
@@ -264,13 +270,13 @@
ld [hl], $ff
add hl, de
push bc
- ld a, [wWhichTrade]
+ ld a, [wInwardSpiralUpdateScreenCounter]
dec a
jr nz, .skip
call BattleTransition_TransferDelay3
- ld a, $7
+ ld a, 7
.skip
- ld [wWhichTrade], a
+ ld [wInwardSpiralUpdateScreenCounter], a
pop bc
dec c
jr nz, .loop
@@ -385,7 +391,7 @@
call BattleTransition_CopyTiles2
coord hl, 11, 0
coord de, 10, 0
- ld bc, $2
+ ld bc, 2
call BattleTransition_CopyTiles2
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
@@ -419,7 +425,7 @@
call BattleTransition_CopyTiles2
coord hl, 1, 0
coord de, 0, 0
- ld bc, $2
+ ld bc, 2
call BattleTransition_CopyTiles2
call BattleTransition_TransferDelay3
call Delay3
@@ -432,10 +438,10 @@
BattleTransition_CopyTiles1: ; 70c12 (1c:4c12)
ld a, c
- ld [wWhichTrade], a
+ ld [wBattleTransitionCopyTilesOffset], a
ld a, b
- ld [wTrainerEngageDistance], a
- ld c, $8
+ ld [wBattleTransitionCopyTilesOffset + 1], a
+ ld c, 8
.loop1
push bc
push hl
@@ -444,9 +450,9 @@
call CopyData
pop hl
pop de
- ld a, [wWhichTrade]
+ ld a, [wBattleTransitionCopyTilesOffset]
ld c, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCopyTilesOffset + 1]
ld b, a
add hl, bc
pop bc
@@ -464,9 +470,9 @@
BattleTransition_CopyTiles2: ; 70c3f (1c:4c3f)
ld a, c
- ld [wWhichTrade], a
+ ld [wBattleTransitionCopyTilesOffset], a
ld a, b
- ld [wTrainerEngageDistance], a
+ ld [wBattleTransitionCopyTilesOffset + 1], a
ld c, SCREEN_HEIGHT / 2
.loop1
push bc
@@ -492,9 +498,9 @@
jr nz, .loop2
pop hl
pop de
- ld a, [wWhichTrade]
+ ld a, [wBattleTransitionCopyTilesOffset]
ld c, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCopyTilesOffset + 1]
ld b, a
add hl, bc
pop bc
@@ -590,11 +596,11 @@
; by animating each half circle one at a time
BattleTransition_Circle: ; 70ce4 (1c:4ce4)
call BattleTransition_FlashScreen
- ld bc, SCREEN_WIDTH / 2
+ lb bc, 0, SCREEN_WIDTH / 2
ld hl, BattleTransition_HalfCircle1
call BattleTransition_Circle_Sub1
ld c, SCREEN_WIDTH / 2
- ld b, $1
+ ld b, 1
ld hl, BattleTransition_HalfCircle2
call BattleTransition_Circle_Sub1
jp BattleTransition_BlackScreen
@@ -612,7 +618,7 @@
ld a, b
call BattleTransition_Circle_Sub2
pop hl
- ld bc, $0005
+ ld bc, 5
add hl, bc
call BattleTransition_TransferDelay3
pop bc
@@ -621,7 +627,7 @@
ret
BattleTransition_TransferDelay3: ; 70d19 (1c:4d19)
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
xor a
@@ -647,7 +653,7 @@
ld a, $1
call BattleTransition_Circle_Sub2
pop hl
- ld bc, $5
+ ld bc, 5
add hl, bc
ld e, l
ld d, h
@@ -660,9 +666,9 @@
jp BattleTransition_BlackScreen
BattleTransition_Circle_Sub2: ; 70d50 (1c:4d50)
- ld [wWhichTrade], a
+ ld [wBattleTransitionCircleScreenQuadrantY], a
ld a, [hli]
- ld [wTrainerEngageDistance], a
+ ld [wBattleTransitionCircleScreenQuadrantX], a
ld a, [hli]
ld e, a
ld a, [hli]
@@ -761,7 +767,7 @@
inc de
.loop1
ld [hl], $ff
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCircleScreenQuadrantX]
and a
jr z, .skip1
inc hl
@@ -772,7 +778,7 @@
dec c
jr nz, .loop1
pop hl
- ld a, [wWhichTrade]
+ ld a, [wBattleTransitionCircleScreenQuadrantY]
and a
ld bc, SCREEN_WIDTH
jr z, .skip3
@@ -787,7 +793,7 @@
jr z, BattleTransition_Circle_Sub3
ld c, a
.loop2
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCircleScreenQuadrantX]
and a
jr z, .skip4
dec hl
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -6,7 +6,7 @@
ret z ; return if wild pokémon
jp SetupEnemyPartyPokeballs
-DrawEnemyPokeballs: ; 0x3a857
+DrawEnemyPokeballs: ; 3a857 (e:6857)
call LoadPartyPokeballGfx
jp SetupEnemyPartyPokeballs
@@ -25,8 +25,8 @@
ld hl, W_BASECOORDX
ld [hli], a
ld [hl], a
- ld a, $8
- ld [wTrainerEngageDistance], a
+ ld a, 8
+ ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
jp WritePokeballOAMData
@@ -39,8 +39,8 @@
ld a, $48
ld [hli], a
ld [hl], $20
- ld a, $f8
- ld [wTrainerEngageDistance], a
+ ld a, -8
+ ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer + PARTY_LENGTH * 4
jp WritePokeballOAMData
@@ -90,8 +90,8 @@
.done
ld a, b
ld [de], a
- ld bc, $0028 ; rest of mon struct
- add hl, bc
+ ld bc, wPartyMon2 - wPartyMon1Status
+ add hl, bc ; next mon struct
ret
WritePokeballOAMData: ; 3a8e1 (e:68e1)
@@ -108,7 +108,7 @@
ld [hli], a
ld a, [W_BASECOORDX]
ld b, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wHUDPokeballGfxOffsetX]
add b
ld [W_BASECOORDX], a
inc de
@@ -118,11 +118,11 @@
PlacePlayerHUDTiles: ; 3a902 (e:6902)
ld hl, PlayerBattleHUDGraphicsTiles
- ld de, wTrainerFacingDirection
+ ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 18, 10
- ld de, rIE
+ ld de, -1
jr PlaceHUDTiles
PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916)
@@ -133,7 +133,7 @@
PlaceEnemyHUDTiles: ; 3a919 (e:6919)
ld hl, EnemyBattleHUDGraphicsTiles
- ld de, wTrainerFacingDirection
+ ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 1, 2
@@ -150,16 +150,16 @@
ld [hl], $73
ld bc, SCREEN_WIDTH
add hl, bc
- ld a, [wTrainerScreenY]
+ ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
ld [hl], a
- ld a, $8
-.asm_3a93c
+ ld a, 8
+.loop
add hl, de
ld [hl], $76
dec a
- jr nz, .asm_3a93c
+ jr nz, .loop
add hl, de
- ld a, [wTrainerScreenX]
+ ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
ld [hl], a
ret
@@ -172,8 +172,8 @@
ld a, $50
ld [hli], a
ld [hl], $40
- ld a, $8
- ld [wTrainerEngageDistance], a
+ ld a, 8
+ ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
call WritePokeballOAMData
ld hl, wEnemyMons
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -455,7 +455,7 @@
ld [wLastMenuItem],a
inc a
ld [wLetterPrintingDelayFlags],a
- ld [wTrainerScreenY],a
+ ld [wUnusedCD40],a
ld a,3 ; text speed cursor Y coordinate
ld [wTopMenuItemY],a
call SetCursorPositionsFromOptions
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -29,7 +29,7 @@
call GiveItem
jr nc, .BagFull
ld hl, wObtainedHiddenItemsFlags
- ld a, [wTrainerScreenX]
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
ld b, FLAG_SET
predef FlagActionPredef
@@ -100,7 +100,7 @@
ld c, $2
predef AddBCDPredef
ld hl, wObtainedHiddenCoinsFlags
- ld a, [wTrainerScreenX]
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
ld b, FLAG_SET
predef FlagActionPredef
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -256,7 +256,7 @@
; a: distance player to sprite
CheckSpriteCanSeePlayer: ; 569af (15:69af)
ld b, a
- ld a, [wTrainerEngageDistance] ; sprite line of sight (engage distance)
+ ld a, [wTrainerEngageDistance] ; how far the trainer can see
cp b
jr nc, .checkIfLinedUp
jr .notInLine ; player too far away
--- a/main.asm
+++ b/main.asm
@@ -2052,7 +2052,7 @@
INCLUDE "data/map_header_banks.asm"
ClearVariablesAfterLoadingMapData: ; c335 (3:4335)
- ld a, $90
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
ld [rWY], a
xor a
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -103,13 +103,13 @@
ld a, [wPartyCount]
cp PARTY_LENGTH
ld hl, DayCareNoRoomForMonText
- jp z, .asm_56403
- ld de, wTrainerFacingDirection
+ jp z, .leaveMonInDayCare
+ ld de, wDayCareTotalCost
xor a
ld [de], a
inc de
ld [de], a
- ld hl, wTrainerScreenX
+ ld hl, wDayCarePerLevelCost
ld a, $1
ld [hli], a
ld [hl], $0
@@ -116,8 +116,8 @@
ld a, [wDayCareNumLevelsGrown]
inc a
ld b, a
- ld c, $2
-.asm_56357
+ ld c, 2
+.calcPriceLoop
push hl
push de
push bc
@@ -126,10 +126,10 @@
pop de
pop hl
dec b
- jr nz, .asm_56357
+ jr nz, .calcPriceLoop
ld hl, DayCareOweMoneyText
call PrintText
- ld a, $13
+ ld a, MONEY_BOX
ld [wTextBoxID], a
call DisplayTextBoxID
call YesNoChoice
@@ -136,8 +136,8 @@
ld hl, DayCareAllRightThenText
ld a, [wCurrentMenuItem]
and a
- jp nz, .asm_56403
- ld hl, wTrainerFacingDirection
+ jp nz, .leaveMonInDayCare
+ ld hl, wDayCareTotalCost
ld [hMoney], a
ld a, [hli]
ld [hMoney + 1], a
@@ -144,11 +144,11 @@
ld a, [hl]
ld [hMoney + 2], a
call HasEnoughMoney
- jr nc, .asm_56396
+ jr nc, .enoughMoney
ld hl, DayCareNotEnoughMoneyText
- jp .asm_56403
+ jp .leaveMonInDayCare
-.asm_56396
+.enoughMoney
xor a
ld [W_DAYCARE_IN_USE], a
ld hl, wDayCareNumLevelsGrown
@@ -202,7 +202,7 @@
ld hl, DayCareGotMonBackText
jr .done
-.asm_56403
+.leaveMonInDayCare
ld a, [wDayCareStartLevel]
ld [wDayCareMonBoxLevel], a
--- a/scripts/safarizoneentrance-yellow.asm
+++ b/scripts/safarizoneentrance-yellow.asm
@@ -1,7 +1,7 @@
.xf1f77
ld hl,.ForJust500Text
call PrintText
- ld a,$13
+ ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
call YesNoChoice
@@ -21,11 +21,11 @@
.xf1f9f
xor a
- ld [$ff9f],a
+ ld [hMoney],a
ld a,$05
- ld [$ffa0],a
+ ld [hMoney + 1],a
ld a,$00
- ld [$ffa1],a
+ ld [hMoney + 2],a
call HasEnoughMoney
jr nc,.success
ld hl,.NotEnoughMoneyText
@@ -36,12 +36,12 @@
.success
xor a
- ld [wSubtrahend],a
+ ld [wPriceTemp],a
ld a,$05
- ld [wSubtrahend+1],a
+ ld [wPriceTemp + 1],a
ld a,$00
- ld [wSubtrahend+2],a
- ld hl,wTrainerFacingDirection
+ ld [wPriceTemp + 2],a
+ ld hl,wPriceTemp + 2
ld de,wPlayerMoney + 2
ld c,3
predef SubBCDPredef
@@ -48,7 +48,7 @@
ld a,$b2
call $3736
call $373e
- ld a,$13
+ ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
ld hl,.MakePaymentText
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -145,7 +145,7 @@
.SafariZoneEntranceText4
TX_FAR SafariZoneEntranceText_9e6e4
TX_ASM
- ld a, $13
+ ld a, MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
call YesNoChoice
@@ -166,16 +166,16 @@
.success
xor a
- ld [wSubtrahend],a
+ ld [wPriceTemp],a
ld a,$05
- ld [wSubtrahend+1],a
+ ld [wPriceTemp + 1],a
ld a,$00
- ld [wSubtrahend+2],a
- ld hl,wTrainerFacingDirection
+ ld [wPriceTemp + 2],a
+ ld hl,wPriceTemp + 2
ld de,wPlayerMoney + 2
ld c,3
predef SubBCDPredef
- ld a,$13
+ ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
ld hl,.MakePaymentText
--- a/text/maps/daycare_1.asm
+++ b/text/maps/daycare_1.asm
@@ -39,7 +39,7 @@
_DayCareOweMoneyText:: ; 8ac7d (22:6c7d)
text "You owe me ¥@"
- TX_BCD wcd3f, $c2
+ TX_BCD wDayCareTotalCost, $c2
db $0
line "for the return"
cont "of this #MON."
--- a/wram.asm
+++ b/wram.asm
@@ -644,6 +644,18 @@
ds 1
+wBattleTransitionCircleScreenQuadrantY:: ; cd3d
+; 0 = upper half (Y < 9)
+; 1 = lower half (Y >= 9)
+
+wBattleTransitionCopyTilesOffset:: ; cd3d
+; 2 bytes
+; after 1 row/column has been copied, the offset to the next one to copy from
+
+wInwardSpiralUpdateScreenCounter:: ; cd3d
+; counts down from 7 so that every time 7 more tiles of the spiral have been
+; placed, the tile map buffer is copied to VRAM so that progress is visible
+
wHoFTeamIndex:: ; cd3d
wSSAnneSmokeDriftAmount:: ; cd3d
@@ -726,9 +738,6 @@
wHiddenObjectFunctionArgument:: ; cd3d
-wSubtrahend:: ; cd3d
-; subtract (BCD) wSubtrahend, wSubtrahend+1, wSubtrahend+2
-
wWhichTrade:: ; cd3d
; which entry from TradeMons to select
@@ -737,6 +746,13 @@
wUnusedCD3D:: ; cd3d
ds 1
+wHUDPokeballGfxOffsetX:: ; cd3e
+; difference in X between the next ball and the current one
+
+wBattleTransitionCircleScreenQuadrantX:: ; cd3e
+; 0 = left half (X < 10)
+; 1 = right half (X >= 10)
+
wSSAnneSmokeX:: ; cd3e
wRivalStarterBallSpriteIndex:: ; cd3e
@@ -775,6 +791,12 @@
wTrainerEngageDistance:: ; cd3e
ds 1
+wHUDGraphicsTiles:: ; cd3f
+; 3 bytes
+
+wDayCareTotalCost:: ; cd3f
+; 2-byte BCD number
+
wJigglypuffFacingDirections:: ; cd3f
wOptionsBattleStyleCursorX:: ; cd3f
@@ -801,7 +823,6 @@
wHiddenObjectIndex:: ; cd3f
wTrainerFacingDirection:: ; cd3f
-wcd3f:: ; used with daycare text for money amount
ds 1
wHoFMonOrPlayer:: ; cd40
@@ -816,8 +837,13 @@
wHiddenObjectY:: ; cd40
wTrainerScreenY:: ; cd40
+
+wUnusedCD40:: ; cd40
ds 1
+wDayCarePerLevelCost:: ; cd41
+; 2-byte BCD number (always set to $0100)
+
wHoFTeamIndex2:: ; cd41
wHiddenItemOrCoinsIndex:: ; cd41
@@ -842,8 +868,7 @@
wSlotMachineWheel1MiddleTile:: ; cd42
wFieldMovesLeftmostXCoord:: ; cd42
-
-wcd42:: ds 1 ; used in pewter center script, printing field mon moves, slot machines and HoF PC
+ ds 1
wLastFieldMoveID:: ; cd43
; unused