ref: db7d941d22d89cf8d6d13cbf768208c5cf2ac2c2
parent: 1d86932cc9c38815434409f07d14c2bfe4e7a836
author: YamaArashi <shadow962@live.com>
date: Sun Jul 19 16:45:34 EDT 2015
constants for flag actions
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -133,6 +133,12 @@
PLAYER_DIR_DOWN EQU (1 << PLAYER_DIR_BIT_DOWN)
PLAYER_DIR_UP EQU (1 << PLAYER_DIR_BIT_UP)
+; flag operations
+
+FLAG_RESET EQU 0
+FLAG_SET EQU 1
+FLAG_TEST EQU 2
+
; serial
ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -328,7 +328,7 @@
call SaveScreenTilesToBuffer1
ld a, [wWhichPokemon]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
push bc
ld hl, wPartyGainExpFlags
predef FlagActionPredef
@@ -1081,7 +1081,7 @@
ld a, [wPlayerMonNumber]
ld c, a
ld hl, wPartyGainExpFlags
- ld b, $0
+ ld b, FLAG_RESET
predef FlagActionPredef ; clear gain exp flag for fainted mon
ld hl, W_ENEMYBATTSTATUS1
res 2, [hl] ; reset "attacking multiple times" flag
@@ -1181,7 +1181,7 @@
ld [wPlayerMonNumber], a
ld c, a
ld hl, wPartyGainExpFlags
- ld b, $1
+ ld b, FLAG_SET
push bc
predef FlagActionPredef
pop bc
@@ -1350,7 +1350,7 @@
ld [hl],a
ld a,[wPlayerMonNumber]
ld c,a
- ld b,1
+ ld b,FLAG_SET
push bc
predef FlagActionPredef
ld hl,wPartyFoughtCurrentEnemyFlags
@@ -2490,7 +2490,7 @@
ld a, [wWhichPokemon]
ld [wPlayerMonNumber], a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
push bc
ld hl, wPartyGainExpFlags
predef FlagActionPredef
@@ -6326,7 +6326,7 @@
ld a, [wd11e]
dec a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wPokedexSeen
predef FlagActionPredef ; mark this mon as seen in the pokedex
ld hl, wEnemyMonLevel
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -15,7 +15,7 @@
ld hl, wPartyGainExpFlags
ld a, [wWhichPokemon]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
and a ; is mon's gain exp flag set?
@@ -257,7 +257,7 @@
ld hl, wCanEvolveFlags
ld a, [wWhichPokemon]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
predef FlagActionPredef
pop hl
pop af
@@ -281,7 +281,7 @@
ld [hl], a ; clear gain exp flags
ld a, [wPlayerMonNumber]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
push bc
predef FlagActionPredef ; set the gain exp flag for the mon that is currently out
ld hl, wPartyFoughtCurrentEnemyFlags
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -5,7 +5,7 @@
ld [hl], a
ld a, [wWhichPokemon]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
call Evolution_FlagAction
; this is only called after battle
@@ -36,7 +36,7 @@
ld a, [wWhichPokemon]
ld c, a
ld hl, wCanEvolveFlags
- ld b, $2
+ ld b, FLAG_TEST
call Evolution_FlagAction
ld a, c
and a ; is the mon's bit set?
@@ -217,7 +217,7 @@
ld a, [wd11e]
dec a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wPokedexOwned
push bc
call Evolution_FlagAction
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -60,7 +60,7 @@
dec a
ld c, a
ld hl, wPokedexOwned
- ld b, $1
+ ld b, FLAG_SET
predef FlagActionPredef
pop af
ld [wd11e], a
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -209,7 +209,7 @@
call PrintText
ld a, [$ffe0]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
call CinnabarGymQuiz_1ea8a
jp CinnabarGymQuiz_1eb0a
.asm_1eab8
@@ -222,7 +222,7 @@
ld a, [$ffdb]
add $2
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
ld hl, wd79a
predef FlagActionPredef
ld a, c
@@ -241,7 +241,7 @@
ld a, [$ffe0]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
call CinnabarGymQuiz_1ea8a
ld a, c
and a
@@ -278,7 +278,7 @@
ld a, [$ffdb]
ld [$ffe0], a
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
call CinnabarGymQuiz_1ea8a
ld a, c
and a
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -38,7 +38,7 @@
ld hl,wCompletedInGameTradeFlags
ld a,[wWhichTrade]
ld c,a
- ld b,$2
+ ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
and a
@@ -112,7 +112,7 @@
ld hl,wCompletedInGameTradeFlags
ld a,[wWhichTrade]
ld c,a
- ld b,$1
+ ld b,FLAG_SET
predef FlagActionPredef
ld hl, ConnectCableText
call PrintText
--- a/engine/items/itemfinder.asm
+++ b/engine/items/itemfinder.asm
@@ -10,7 +10,7 @@
push hl
ld hl, wObtainedHiddenItemsFlags
ld c, b
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
pop hl
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -400,8 +400,8 @@
ld a,[wd11e]
dec a
ld c,a
- ld b,2
- ld hl,wPokedexOwned ;Dex_own_flags (pokemon)
+ ld b,FLAG_TEST
+ ld hl,wPokedexOwned
predef FlagActionPredef
ld a,c
push af
@@ -408,7 +408,7 @@
ld a,[wd11e]
dec a
ld c,a
- ld b,1
+ ld b,FLAG_SET
predef FlagActionPredef
pop af
and a
@@ -804,7 +804,7 @@
ld a,[wUsedItemOnWhichPokemon]
ld c,a
ld hl,wPartyFoughtCurrentEnemyFlags
- ld b,$02
+ ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
and a
@@ -812,7 +812,7 @@
ld a,[wUsedItemOnWhichPokemon]
ld c,a
ld hl,wPartyGainExpFlags
- ld b,$01
+ ld b,FLAG_SET
predef FlagActionPredef
.next
pop bc
@@ -2550,8 +2550,8 @@
dec a
ld c,a
ld hl,wHPBarMaxHP
- ld b,$02 ; test bit
- predef FlagActionPredef ; bitfield operation function
+ ld b,FLAG_TEST
+ predef FlagActionPredef
ld a,c
and a
ret nz
--- a/engine/items/tms.asm
+++ b/engine/items/tms.asm
@@ -17,7 +17,7 @@
jr .findTMloop
.TMfoundLoop
pop hl
- ld b, $2 ; read corresponding bit from TM compatibility array
+ ld b, FLAG_TEST
predef_jump FlagActionPredef
; converts TM/HM number in wd11e into move number
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -379,7 +379,7 @@
ld a,[wd11e]
dec a
ld c,a
- ld b,2
+ ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
and a
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -5,7 +5,7 @@
ld hl, wObtainedHiddenItemsFlags
ld a, [wHiddenItemOrCoinsIndex]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
and a
@@ -31,7 +31,7 @@
ld hl, wObtainedHiddenItemsFlags
ld a, [wTrainerScreenX]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
predef FlagActionPredef
ld a, SFX_GET_ITEM_2
call PlaySoundWaitForCurrent
@@ -61,7 +61,7 @@
ld hl, wObtainedHiddenCoinsFlags
ld a, [wHiddenItemOrCoinsIndex]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
and a
@@ -102,7 +102,7 @@
ld hl, wObtainedHiddenCoinsFlags
ld a, [wTrainerScreenX]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
predef FlagActionPredef
call EnableAutoTextBoxDrawing
ld a, [wPlayerCoins]
--- a/home.asm
+++ b/home.asm
@@ -2297,7 +2297,7 @@
call ReadTrainerHeaderInfo ; read flag's byte ptr
ld a, [wTrainerHeaderFlagBit]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
call TrainerFlagAction ; read trainer's flag
ld a, c
and a
@@ -2392,7 +2392,7 @@
call ReadTrainerHeaderInfo
ld a, [wTrainerHeaderFlagBit]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
call TrainerFlagAction ; flag trainer as fought
ld a, [W_ENEMYMONORTRAINERCLASS]
cp $c8
@@ -2470,7 +2470,7 @@
ret z
ld a, $2
call ReadTrainerHeaderInfo ; read trainer flag's byte ptr
- ld b, $2
+ ld b, FLAG_TEST
ld a, [wTrainerHeaderFlagBit]
ld c, a
call TrainerFlagAction ; read trainer flag
--- a/main.asm
+++ b/main.asm
@@ -2038,7 +2038,7 @@
ld a, [wd11e]
dec a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wPokedexSeen
predef FlagActionPredef
ld a, $1
@@ -3235,7 +3235,7 @@
cp ROUTE_1
jr nc, .notInTown
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, W_TOWNVISITEDFLAG ; mark town as visited (for flying)
predef FlagActionPredef
.notInTown
@@ -3319,7 +3319,7 @@
ld hl, W_MISSABLEOBJECTFLAGS
ld a, [wd048]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
call MissableObjectFlagAction ; set flag iff Item is hidden
.asm_f19d
ld hl, wd048
@@ -3343,7 +3343,7 @@
ld a, [hli]
jr nz, .loop
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
ld hl, W_MISSABLEOBJECTFLAGS
call MissableObjectFlagAction
ld a, c
@@ -3362,7 +3362,7 @@
ld hl, W_MISSABLEOBJECTFLAGS
ld a, [wcc4d]
ld c, a
- ld b, $0
+ ld b, FLAG_RESET
call MissableObjectFlagAction ; reset "removed" flag
jp UpdateSprites
@@ -3372,7 +3372,7 @@
ld hl, W_MISSABLEOBJECTFLAGS
ld a, [wcc4d]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
call MissableObjectFlagAction ; set "removed" flag
jp UpdateSprites
@@ -3642,7 +3642,7 @@
ld a, [wd11e]
dec a
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
ld hl, wPokedexOwned
call FlagAction
ld a, c
@@ -3650,7 +3650,7 @@
ld a, [wd11e]
dec a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
push bc
call FlagAction
pop bc
@@ -3882,7 +3882,7 @@
ld a, [wd11e]
dec a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wPokedexOwned
push bc
call FlagAction ; add to owned pokemon
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -99,7 +99,7 @@
ld a, [wTrainerHeaderFlagBit]
ld [$ffdb], a
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
ld hl, wd79a
call CinnabarGymScript_757f1
ld a, c
@@ -113,13 +113,13 @@
ld a, [wTrainerHeaderFlagBit]
ld [$ffdb], a
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wd79a
call CinnabarGymScript_757f1
ld a, [wTrainerHeaderFlagBit]
sub $2
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wd79c
call CinnabarGymScript_757f1
call Func_3ead
--- a/scripts/route23.asm
+++ b/scripts/route23.asm
@@ -52,7 +52,7 @@
ld [hSpriteIndexOrTextID], a
ld a, c
ld [wWhichBadge], a
- ld b, $2
+ ld b, FLAG_TEST
ld hl, wd7ed
predef FlagActionPredef
ld a, c
@@ -193,7 +193,7 @@
ld a, [wWhichBadge]
inc a
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
ld hl, W_OBTAINEDBADGES
predef FlagActionPredef
ld a, c
@@ -210,7 +210,7 @@
call PrintText
ld a, [wWhichBadge]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
ld hl, wd7ed
predef FlagActionPredef
ld a, $2