ref: 3203ad7d50f6558cba8494a4e93d095d16c5e0d2
parent: a1951cefc09035e11077a433b28ec8c66b3b03db
author: luckytyphlosion <[email protected]>
date: Tue Jan 30 09:05:25 EST 2018
Fix comment/style issues caused from w-izing.
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -21,7 +21,7 @@
jr nz, DontSwitch
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
- ld a, [wInBattleTowerBattle] ; Load always the first wTrainerClass for BattleTower-Trainers
+ ld a, [wInBattleTowerBattle] ; always load the first trainer class in wTrainerClass for BattleTower-Trainers
and a
jr nz, .ok
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -66,7 +66,7 @@
.ApplyLayers:
ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS
- ; If we have a battle in BattleTower just load the Attributes of the first wTrainerClass (Falkner)
+ ; If we have a battle in BattleTower just load the Attributes of the first trainer class in wTrainerClass (Falkner)
; so we have always the same AI, regardless of the loaded class of trainer
ld a, [wInBattleTowerBattle]
bit 0, a
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6133,7 +6133,7 @@
; Notes:
; BattleRandom is used to ensure sync between Game Boys
-; Clear the whole wEnemyMon struct
+; Clear the whole enemy mon struct (wEnemyMon)
xor a
ld hl, wEnemyMonSpecies
ld bc, wEnemyMonEnd - wEnemyMon
@@ -6989,7 +6989,8 @@
; 3ed45
BadgeStatBoosts: ; 3ed45
-; Raise wBattleMon stats depending on which badges have been obtained.
+; Raise the stats of the battle mon in wBattleMon
+; depending on which badges have been obtained.
; Every other badge boosts a stat, starting from the first.
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -602,7 +602,7 @@
ld hl, wBGPals1
ld de, wBGPals2
ld bc, 16 palettes
- ld a, BANK(wPals)
+ ld a, BANK(wGBCPalettes)
call FarCopyWRAM
ret
--- a/engine/credits.asm
+++ b/engine/credits.asm
@@ -13,7 +13,7 @@
ld a, [rSVBK]
push af
- ld a, BANK(wPals)
+ ld a, BANK(wGBCPalettes)
ld [rSVBK], a
call ClearBGPalettes
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -352,7 +352,7 @@
CrystalIntro: ; e48ac
ld a, [rSVBK]
push af
- ld a, BANK(wPals)
+ ld a, BANK(wGBCPalettes)
ld [rSVBK], a
ld a, [hInMenu]
push af
--- a/engine/pic_animation.asm
+++ b/engine/pic_animation.asm
@@ -326,7 +326,7 @@
ld [wPokeAnimPointer], a
ld a, b
ld [wPokeAnimPointer + 1], a
-; hl contains wTileMap coords
+; hl contains tilemap coords
ld a, l
ld [wPokeAnimCoord], a
ld a, h
--- a/engine/pokegear.asm
+++ b/engine/pokegear.asm
@@ -247,7 +247,7 @@
xor a
ld [hBGMapMode], a
hlcoord 0, 0
- ld bc, wTileMapEnd - wTileMap
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, $4f
call ByteFill
ld a, [wPokegearCard]
--- a/engine/variables.asm
+++ b/engine/variables.asm
@@ -39,26 +39,26 @@
; RETVAR_STRBUF2: copy [de] to wStringBuffer2
; RETVAR_ADDR_DE: return address in de
; RETVAR_EXECUTE: call function
- dwb wStringBuffer2, RETVAR_STRBUF2
- dwb wPartyCount, RETVAR_STRBUF2
+ dwb wStringBuffer2, RETVAR_STRBUF2
+ dwb wPartyCount, RETVAR_STRBUF2
dwb .BattleResult, RETVAR_EXECUTE
- dwb wBattleType, RETVAR_ADDR_DE
- dwb wTimeOfDay, RETVAR_STRBUF2
+ dwb wBattleType, RETVAR_ADDR_DE
+ dwb wTimeOfDay, RETVAR_STRBUF2
dwb .CountCaughtMons, RETVAR_EXECUTE
dwb .CountSeenMons, RETVAR_EXECUTE
dwb .CountBadges, RETVAR_EXECUTE
- dwb wPlayerState, RETVAR_ADDR_DE
- dwb .wPlayerFacing, RETVAR_EXECUTE
+ dwb wPlayerState, RETVAR_ADDR_DE
+ dwb .PlayerFacing, RETVAR_EXECUTE
dwb hHours, RETVAR_STRBUF2
dwb .DayOfWeek, RETVAR_EXECUTE
- dwb wMapGroup, RETVAR_STRBUF2
- dwb wMapNumber, RETVAR_STRBUF2
+ dwb wMapGroup, RETVAR_STRBUF2
+ dwb wMapNumber, RETVAR_STRBUF2
dwb .UnownCaught, RETVAR_EXECUTE
- dwb wEnvironment, RETVAR_STRBUF2
+ dwb wEnvironment, RETVAR_STRBUF2
dwb .BoxFreeSpace, RETVAR_EXECUTE
dwb wBugContestMinsRemaining, RETVAR_STRBUF2
- dwb wXCoord, RETVAR_STRBUF2
- dwb wYCoord, RETVAR_STRBUF2
+ dwb wXCoord, RETVAR_STRBUF2
+ dwb wYCoord, RETVAR_STRBUF2
dwb wSpecialPhoneCallID, RETVAR_STRBUF2
dwb wNrOfBeatenBattleTowerTrainers, RETVAR_STRBUF2
dwb wKurtApricornQuantity, RETVAR_STRBUF2
@@ -96,7 +96,7 @@
jp .loadstringbuffer2
; 806ef
-.wPlayerFacing: ; 806ef
+.PlayerFacing: ; 806ef
; The direction the player is facing.
ld a, [wPlayerDirection]
and $c
--- a/home/battle.asm
+++ b/home/battle.asm
@@ -25,7 +25,7 @@
BattlePartyAttr:: ; 395d
-; Get attribute a from the active wBattleMon's party struct.
+; Get attribute a from the party struct of the active battle mon.
push bc
ld c, a
ld b, 0
@@ -39,7 +39,7 @@
OTPartyAttr:: ; 396d
-; Get attribute a from the active wEnemyMon's party struct.
+; Get attribute a from the party struct of the active enemy mon.
push bc
ld c, a
ld b, 0
@@ -136,102 +136,9 @@
; 39e1
-GetBattleVar:: ; 39e1
-; Preserves hl.
- push hl
- call GetBattleVarAddr
- pop hl
- ret
-; 39e7
+INCLUDE "home/battle_vars.asm"
-GetBattleVarAddr:: ; 39e7
-; Get variable from pair a, depending on whose turn it is.
-; There are 21 variable pairs.
- push bc
-
- ld hl, .battlevarpairs
- ld c, a
- ld b, 0
- add hl, bc
- add hl, bc
-
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
-; Enemy turn uses the second byte instead.
-; This lets battle variable calls be side-neutral.
- ld a, [hBattleTurn]
- and a
- jr z, .getvar
- inc hl
-
-.getvar
-; var id
- ld a, [hl]
- ld c, a
- ld b, 0
-
- ld hl, .vars
- add hl, bc
- add hl, bc
-
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
- ld a, [hl]
-
- pop bc
- ret
-
-.battlevarpairs
- dw .substatus1, .substatus2, .substatus3, .substatus4, .substatus5
- dw .substatus1opp, .substatus2opp, .substatus3opp, .substatus4opp, .substatus5opp
- dw .status, .statusopp, .animation, .effect, .power, .type
- dw .curmove, .lastcounter, .lastcounteropp, .lastmove, .lastmoveopp
-
-; player enemy
-.substatus1 db PLAYER_SUBSTATUS_1, ENEMY_SUBSTATUS_1
-.substatus1opp db ENEMY_SUBSTATUS_1, PLAYER_SUBSTATUS_1
-.substatus2 db PLAYER_SUBSTATUS_2, ENEMY_SUBSTATUS_2
-.substatus2opp db ENEMY_SUBSTATUS_2, PLAYER_SUBSTATUS_2
-.substatus3 db PLAYER_SUBSTATUS_3, ENEMY_SUBSTATUS_3
-.substatus3opp db ENEMY_SUBSTATUS_3, PLAYER_SUBSTATUS_3
-.substatus4 db PLAYER_SUBSTATUS_4, ENEMY_SUBSTATUS_4
-.substatus4opp db ENEMY_SUBSTATUS_4, PLAYER_SUBSTATUS_4
-.substatus5 db PLAYER_SUBSTATUS_5, ENEMY_SUBSTATUS_5
-.substatus5opp db ENEMY_SUBSTATUS_5, PLAYER_SUBSTATUS_5
-.status db PLAYER_STATUS, ENEMY_STATUS
-.statusopp db ENEMY_STATUS, PLAYER_STATUS
-.animation db PLAYER_MOVE_ANIMATION, ENEMY_MOVE_ANIMATION
-.effect db PLAYER_MOVE_EFFECT, ENEMY_MOVE_EFFECT
-.power db PLAYER_MOVE_POWER, ENEMY_MOVE_POWER
-.type db PLAYER_MOVE_TYPE, ENEMY_MOVE_TYPE
-.curmove db PLAYER_CUR_MOVE, ENEMY_CUR_MOVE
-.lastcounter db PLAYER_COUNTER_MOVE, ENEMY_COUNTER_MOVE
-.lastcounteropp db ENEMY_COUNTER_MOVE, PLAYER_COUNTER_MOVE
-.lastmove db PLAYER_LAST_MOVE, ENEMY_LAST_MOVE
-.lastmoveopp db ENEMY_LAST_MOVE, PLAYER_LAST_MOVE
-
-.vars
- dw wPlayerSubStatus1, wEnemySubStatus1
- dw wPlayerSubStatus2, wEnemySubStatus2
- dw wPlayerSubStatus3, wEnemySubStatus3
- dw wPlayerSubStatus4, wEnemySubStatus4
- dw wPlayerSubStatus5, wEnemySubStatus5
- dw wBattleMonStatus, wEnemyMonStatus
- dw wPlayerMoveStructAnimation, wEnemyMoveStructAnimation
- dw wPlayerMoveStructEffect, wEnemyMoveStructEffect
- dw wPlayerMoveStructPower, wEnemyMoveStructPower
- dw wPlayerMoveStructType, wEnemyMoveStructType
- dw wCurPlayerMove, wCurEnemyMove
- dw wLastPlayerCounterMove, wLastEnemyCounterMove
- dw wLastPlayerMove, wLastEnemyMove
-; 3a90
-
-
FarCopyRadioText:: ; 3a90
inc hl
ld a, [hROMBank]
@@ -293,8 +200,6 @@
StdBattleTextBox:: ; 3ad5
; Open a textbox and print battle text at 20:hl.
-GLOBAL BattleText
-
ld a, [hROMBank]
push af
@@ -309,9 +214,6 @@
; 3ae1
GetBattleAnimPointer:: ; 3ae1
-
-GLOBAL BattleAnimations
-GLOBAL BattleAnimCommands
ld a, BANK(BattleAnimations)
rst Bankswitch
--- /dev/null
+++ b/home/battle_vars.asm
@@ -1,0 +1,111 @@
+GetBattleVar:: ; 39e1
+; Preserves hl.
+ push hl
+ call GetBattleVarAddr
+ pop hl
+ ret
+; 39e7
+
+GetBattleVarAddr:: ; 39e7
+; Get variable from pair a, depending on whose turn it is.
+; There are 21 variable pairs.
+
+ push bc
+
+ ld hl, .BattleVarPairs
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+; Enemy turn uses the second byte instead.
+; This lets battle variable calls be side-neutral.
+ ld a, [hBattleTurn]
+ and a
+ jr z, .get_var
+ inc hl
+
+.get_var
+; var id
+ ld a, [hl]
+ ld c, a
+ ld b, 0
+
+ ld hl, .BattleVarPointers
+ add hl, bc
+ add hl, bc
+
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ld a, [hl]
+
+ pop bc
+ ret
+
+.BattleVarPairs:
+ dw .Substatus1
+ dw .Substatus2
+ dw .Substatus3
+ dw .Substatus4
+ dw .Substatus5
+ dw .Substatus1Opp
+ dw .Substatus2Opp
+ dw .Substatus3Opp
+ dw .Substatus4Opp
+ dw .Substatus5Opp
+ dw .Status
+ dw .StatusOpp
+ dw .MoveAnim
+ dw .MoveEffect
+ dw .MovePower
+ dw .MoveType
+ dw .CurMove
+ dw .LastCounter
+ dw .LastCounterOpp
+ dw .LastMove
+ dw .LastMoveOpp
+
+; player enemy
+.Substatus1: db PLAYER_SUBSTATUS_1, ENEMY_SUBSTATUS_1
+.Substatus1Opp: db ENEMY_SUBSTATUS_1, PLAYER_SUBSTATUS_1
+.Substatus2: db PLAYER_SUBSTATUS_2, ENEMY_SUBSTATUS_2
+.Substatus2Opp: db ENEMY_SUBSTATUS_2, PLAYER_SUBSTATUS_2
+.Substatus3: db PLAYER_SUBSTATUS_3, ENEMY_SUBSTATUS_3
+.Substatus3Opp: db ENEMY_SUBSTATUS_3, PLAYER_SUBSTATUS_3
+.Substatus4: db PLAYER_SUBSTATUS_4, ENEMY_SUBSTATUS_4
+.Substatus4Opp: db ENEMY_SUBSTATUS_4, PLAYER_SUBSTATUS_4
+.Substatus5: db PLAYER_SUBSTATUS_5, ENEMY_SUBSTATUS_5
+.Substatus5Opp: db ENEMY_SUBSTATUS_5, PLAYER_SUBSTATUS_5
+.Status: db PLAYER_STATUS, ENEMY_STATUS
+.StatusOpp: db ENEMY_STATUS, PLAYER_STATUS
+.MoveAnim: db PLAYER_MOVE_ANIMATION, ENEMY_MOVE_ANIMATION
+.MoveEffect: db PLAYER_MOVE_EFFECT, ENEMY_MOVE_EFFECT
+.MovePower: db PLAYER_MOVE_POWER, ENEMY_MOVE_POWER
+.MoveType: db PLAYER_MOVE_TYPE, ENEMY_MOVE_TYPE
+.CurMove: db PLAYER_CUR_MOVE, ENEMY_CUR_MOVE
+.LastCounter: db PLAYER_COUNTER_MOVE, ENEMY_COUNTER_MOVE
+.LastCounterOpp: db ENEMY_COUNTER_MOVE, PLAYER_COUNTER_MOVE
+.LastMove: db PLAYER_LAST_MOVE, ENEMY_LAST_MOVE
+.LastMoveOpp: db ENEMY_LAST_MOVE, PLAYER_LAST_MOVE
+
+.BattleVarPointers:
+ dw wPlayerSubStatus1, wEnemySubStatus1
+ dw wPlayerSubStatus2, wEnemySubStatus2
+ dw wPlayerSubStatus3, wEnemySubStatus3
+ dw wPlayerSubStatus4, wEnemySubStatus4
+ dw wPlayerSubStatus5, wEnemySubStatus5
+ dw wBattleMonStatus, wEnemyMonStatus
+ dw wPlayerMoveStructAnimation, wEnemyMoveStructAnimation
+ dw wPlayerMoveStructEffect, wEnemyMoveStructEffect
+ dw wPlayerMoveStructPower, wEnemyMoveStructPower
+ dw wPlayerMoveStructType, wEnemyMoveStructType
+ dw wCurPlayerMove, wCurEnemyMove
+ dw wLastPlayerCounterMove, wLastEnemyCounterMove
+ dw wLastPlayerMove, wLastEnemyMove
+; 3a90
--- a/home/tilemap.asm
+++ b/home/tilemap.asm
@@ -117,7 +117,7 @@
inc hl
ld d, [hl]
call GetMenuTextStartCoord
- call Coord2Tile ; hl now contains the wTileMap address where we will start printing text.
+ call Coord2Tile ; hl now contains the tilemap address where we will start printing text.
inc de
ld a, [de] ; Number of items
inc de
--- a/wram.asm
+++ b/wram.asm
@@ -2943,7 +2943,7 @@
SECTION "GBC Video", WRAMX
; eight 4-color palettes each
-wPals::
+wGBCPalettes::
wBGPals1:: ds 8 palettes ; d000
wOBPals1:: ds 8 palettes ; d040
wBGPals2:: ds 8 palettes ; d080