shithub: pokecrystal

Download patch

ref: 7d3ad2136aac8483fa89a4ad0ac7608cd45658a9
parent: dcc0ca9b8396505455b5ca6c8ff36440bef8de7e
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Thu Jan 25 13:10:41 EST 2018

Separate home/battle_vars.asm for easy data editing, same as home/hm_moves.asm

--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -96,7 +96,7 @@
 	const BATTLETYPE_CELEBI
 	const BATTLETYPE_SUICUNE
 
-; GetBattleVar and GetBattleVarAddr arguments (see home/battle.asm)
+; BattleVarPairs indexes (see home/battle.asm)
 	const_def
 	const BATTLE_VARS_SUBSTATUS1
 	const BATTLE_VARS_SUBSTATUS2
@@ -120,7 +120,7 @@
 	const BATTLE_VARS_LAST_MOVE
 	const BATTLE_VARS_LAST_MOVE_OPP
 
-; GetBattleVar and GetBattleVarAddr internal indexes (see home/battle.asm)
+; BattleVarLocations indexes (see home/battle.asm)
 	const_def
 	const PLAYER_SUBSTATUS_1
 	const ENEMY_SUBSTATUS_1
--- a/home/battle.asm
+++ b/home/battle.asm
@@ -136,100 +136,7 @@
 ; 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 PlayerSubStatus1,             EnemySubStatus1
-	dw PlayerSubStatus2,             EnemySubStatus2
-	dw PlayerSubStatus3,             EnemySubStatus3
-	dw PlayerSubStatus4,             EnemySubStatus4
-	dw PlayerSubStatus5,             EnemySubStatus5
-	dw BattleMonStatus,              EnemyMonStatus
-	dw wPlayerMoveStructAnimation,   wEnemyMoveStructAnimation
-	dw wPlayerMoveStructEffect,      wEnemyMoveStructEffect
-	dw wPlayerMoveStructPower,       wEnemyMoveStructPower
-	dw wPlayerMoveStructType,        wEnemyMoveStructType
-	dw CurPlayerMove,                CurEnemyMove
-	dw LastPlayerCounterMove,        LastEnemyCounterMove
-	dw LastPlayerMove,               LastEnemyMove
-; 3a90
+INCLUDE "home/battle_vars.asm"
 
 
 FarCopyRadioText:: ; 3a90
--- /dev/null
+++ b/home/battle_vars.asm
@@ -1,0 +1,113 @@
+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, BattleVarLocations
+	add hl, bc
+	add hl, bc
+
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+
+	ld a, [hl]
+
+	pop bc
+	ret
+
+BattleVarPairs:
+; entries correspond to BATTLE_VARS_* constants
+	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 .animation
+	dw .effect
+	dw .power
+	dw .type
+	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
+.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
+
+BattleVarLocations:
+; entries correspond to PLAYER_* and ENEMY_* constants
+	dw PlayerSubStatus1,           EnemySubStatus1
+	dw PlayerSubStatus2,           EnemySubStatus2
+	dw PlayerSubStatus3,           EnemySubStatus3
+	dw PlayerSubStatus4,           EnemySubStatus4
+	dw PlayerSubStatus5,           EnemySubStatus5
+	dw BattleMonStatus,            EnemyMonStatus
+	dw wPlayerMoveStructAnimation, wEnemyMoveStructAnimation
+	dw wPlayerMoveStructEffect,    wEnemyMoveStructEffect
+	dw wPlayerMoveStructPower,     wEnemyMoveStructPower
+	dw wPlayerMoveStructType,      wEnemyMoveStructType
+	dw CurPlayerMove,              CurEnemyMove
+	dw LastPlayerCounterMove,      LastEnemyCounterMove
+	dw LastPlayerMove,             LastEnemyMove
+; 3a90
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -276,7 +276,10 @@
 	ret
 
 .TimeOfDayValues_191e:
-	db MORN, DAY, NITE
+; entries correspond to TimeOfDay values
+	db MORN
+	db DAY
+	db NITE
 
 .check_hour
 	ld hl, MAPOBJECT_HOUR