From 3203ad7d50f6558cba8494a4e93d095d16c5e0d2 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 30 Jan 2018 14:05:25 -0500 Subject: [PATCH] Fix comment/style issues caused from w-izing. --- engine/battle/ai/items.asm | 2 +- engine/battle/ai/move.asm | 2 +- engine/battle/core.asm | 5 +- engine/color.asm | 2 +- engine/credits.asm | 2 +- engine/crystal_intro.asm | 2 +- engine/pic_animation.asm | 2 +- engine/pokegear.asm | 2 +- engine/variables.asm | 24 ++++---- home/battle.asm | 104 +--------------------------------- home/battle_vars.asm | 111 +++++++++++++++++++++++++++++++++++++ home/tilemap.asm | 2 +- wram.asm | 2 +- 13 files changed, 138 insertions(+), 124 deletions(-) create mode 100644 home/battle_vars.asm diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index 6ec490b71..4d1eea2e8 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -21,7 +21,7 @@ AI_SwitchOrTryItem: ; 38000 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 diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm index c3e9bed27..b5ac966f8 100755 --- a/engine/battle/ai/move.asm +++ b/engine/battle/ai/move.asm @@ -66,7 +66,7 @@ AIChooseMove: ; 440ce .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 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 4cdd7f226..3742f00c9 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -6133,7 +6133,7 @@ LoadEnemyMon: ; 3e8eb ; 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 @@ ApplyStatLevelMultiplier: ; 3ecb7 ; 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. diff --git a/engine/color.asm b/engine/color.asm index 88dd8e8d6..21842b7b3 100644 --- a/engine/color.asm +++ b/engine/color.asm @@ -602,7 +602,7 @@ ApplyPals: ld hl, wBGPals1 ld de, wBGPals2 ld bc, 16 palettes - ld a, BANK(wPals) + ld a, BANK(wGBCPalettes) call FarCopyWRAM ret diff --git a/engine/credits.asm b/engine/credits.asm index eb5347f26..1aaecf64a 100644 --- a/engine/credits.asm +++ b/engine/credits.asm @@ -13,7 +13,7 @@ Credits:: ; 109847 ld a, [rSVBK] push af - ld a, BANK(wPals) + ld a, BANK(wGBCPalettes) ld [rSVBK], a call ClearBGPalettes diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm index d482c3cfa..d6c467867 100755 --- a/engine/crystal_intro.asm +++ b/engine/crystal_intro.asm @@ -352,7 +352,7 @@ INCBIN "gfx/splash/logo2.1bpp" CrystalIntro: ; e48ac ld a, [rSVBK] push af - ld a, BANK(wPals) + ld a, BANK(wGBCPalettes) ld [rSVBK], a ld a, [hInMenu] push af diff --git a/engine/pic_animation.asm b/engine/pic_animation.asm index b93a10dd2..a84c3f449 100644 --- a/engine/pic_animation.asm +++ b/engine/pic_animation.asm @@ -326,7 +326,7 @@ PokeAnim_InitPicAttributes: ; d01d6 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 diff --git a/engine/pokegear.asm b/engine/pokegear.asm index a782b31b6..affe9d6bd 100755 --- a/engine/pokegear.asm +++ b/engine/pokegear.asm @@ -247,7 +247,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8) 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] diff --git a/engine/variables.asm b/engine/variables.asm index 25870a967..89026fdba 100755 --- a/engine/variables.asm +++ b/engine/variables.asm @@ -39,26 +39,26 @@ _GetVarAction:: ; 80648 (20:4648) ; 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 @@ _GetVarAction:: ; 80648 (20:4648) jp .loadstringbuffer2 ; 806ef -.wPlayerFacing: ; 806ef +.PlayerFacing: ; 806ef ; The direction the player is facing. ld a, [wPlayerDirection] and $c diff --git a/home/battle.asm b/home/battle.asm index b4b7cf844..e59b1e3b4 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -25,7 +25,7 @@ OpponentPartyAttr:: ; 3951 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 @@ BattlePartyAttr:: ; 395d 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,100 +136,7 @@ UpdateBattleHuds:: ; 39d4 ; 39e1 -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, .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 +INCLUDE "home/battle_vars.asm" FarCopyRadioText:: ; 3a90 @@ -293,8 +200,6 @@ BattleTextBox:: ; 3ac3 StdBattleTextBox:: ; 3ad5 ; Open a textbox and print battle text at 20:hl. -GLOBAL BattleText - ld a, [hROMBank] push af @@ -310,9 +215,6 @@ GLOBAL BattleText GetBattleAnimPointer:: ; 3ae1 -GLOBAL BattleAnimations -GLOBAL BattleAnimCommands - ld a, BANK(BattleAnimations) rst Bankswitch diff --git a/home/battle_vars.asm b/home/battle_vars.asm new file mode 100644 index 000000000..44fc21d6d --- /dev/null +++ b/home/battle_vars.asm @@ -0,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 diff --git a/home/tilemap.asm b/home/tilemap.asm index 00317e53b..4bbd16102 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -117,7 +117,7 @@ PlaceVerticalMenuItems:: ; 1c89 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 diff --git a/wram.asm b/wram.asm index ea50bf943..42088db6f 100644 --- a/wram.asm +++ b/wram.asm @@ -2943,7 +2943,7 @@ w3_dffc:: ds 4 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