ref: 125d51b3b2e91230b693406de153e172f752bf41
parent: f75bfbeac3aa826e1f402a649fa1389e889b5af9
author: Rangi <[email protected]>
date: Mon Jan 22 08:57:44 EST 2018
More engine bit flag constants
--- a/constants/engine_flags.asm
+++ b/constants/engine_flags.asm
@@ -13,7 +13,7 @@
const ENGINE_DAY_CARE_LADY_HAS_MON
; wMomSavingMoney
const ENGINE_MOM_SAVING_MONEY
- const ENGINE_DST
+ const ENGINE_MOM_ACTIVE
; wUnusedTwoDayTimerOn
const ENGINE_0A
; wStatusFlags
--- a/constants/pokemon_constants.asm
+++ b/constants/pokemon_constants.asm
@@ -276,5 +276,32 @@
const EGG ; fd
const MON_FE ; fe
-; number of Unown forms
-NUM_UNOWN EQU 26
+; Unown forms
+const_value set 1
+ const UNOWN_A ; 1
+ const UNOWN_B ; 2
+ const UNOWN_C ; 3
+ const UNOWN_D ; 4
+ const UNOWN_E ; 5
+ const UNOWN_F ; 6
+ const UNOWN_G ; 7
+ const UNOWN_H ; 8
+ const UNOWN_I ; 9
+ const UNOWN_J ; 10
+ const UNOWN_K ; 11
+ const UNOWN_L ; 12
+ const UNOWN_M ; 13
+ const UNOWN_N ; 14
+ const UNOWN_O ; 15
+ const UNOWN_P ; 16
+ const UNOWN_Q ; 17
+ const UNOWN_R ; 18
+ const UNOWN_S ; 19
+ const UNOWN_T ; 20
+ const UNOWN_U ; 21
+ const UNOWN_V ; 22
+ const UNOWN_W ; 23
+ const UNOWN_X ; 24
+ const UNOWN_Y ; 25
+ const UNOWN_Z ; 26
+NUM_UNOWN EQU const_value +- 1 ; 26
--- a/constants/wram_constants.asm
+++ b/constants/wram_constants.asm
@@ -132,6 +132,14 @@
PLAYER_OBJECT EQU 0
NUM_OBJECTS EQU $10
+; wMomSavingMoney:: ; d854
+MOM_SAVING_SOME_MONEY_F EQU 0
+MOM_SAVING_HALF_MONEY_F EQU 1
+MOM_SAVING_ALL_MONEY_F EQU 2
+MOM_ACTIVE_F EQU 7
+
+MOM_SAVING_MONEY_MASK EQU (1 << MOM_SAVING_SOME_MONEY_F) | (1 << MOM_SAVING_HALF_MONEY_F) | (1 << MOM_SAVING_ALL_MONEY_F)
+
; wJohtoBadges:: ; d857
const_def
const ZEPHYRBADGE
@@ -176,6 +184,12 @@
PLAYER_SKATE EQU 2
PLAYER_SURF EQU 4
PLAYER_SURF_PIKA EQU 8
+
+; wBikeFlags:: ; dbf5
+ const_def
+ const BIKEFLAGS_STRENGTH_ACTIVE_F ; 0
+ const BIKEFLAGS_ALWAYS_ON_BIKE_F ; 1
+ const BIKEFLAGS_DOWNHILL_F ; 2
; wDayCareMan:: ; def5
DAYCAREMAN_HAS_MON_F EQU 0
--- a/data/engine_flags.asm
+++ b/data/engine_flags.asm
@@ -19,8 +19,8 @@
engine_flag wDayCareMan, DAYCAREMAN_HAS_MON_F
engine_flag wDayCareLady, DAYCARELADY_HAS_MON_F
- engine_flag wMomSavingMoney, 0 ; mom saving money ; $8
- engine_flag wMomSavingMoney, 7 ; dst
+ engine_flag wMomSavingMoney, MOM_SAVING_SOME_MONEY_F ; $8
+ engine_flag wMomSavingMoney, MOM_ACTIVE_F
engine_flag wUnusedTwoDayTimerOn, 0 ; unused, possibly related to a 2-day timer
@@ -38,9 +38,9 @@
engine_flag wStatusFlags2, 6 ; berry -> berry juice when trading?
engine_flag wStatusFlags2, 7 ; rockets in mahogany
- engine_flag wBikeFlags, 0 ; strength active ; $18
- engine_flag wBikeFlags, 1 ; always on bike (cant surf)
- engine_flag wBikeFlags, 2 ; downhill (cycling road)
+ engine_flag wBikeFlags, BIKEFLAGS_STRENGTH_ACTIVE_F ; $18
+ engine_flag wBikeFlags, BIKEFLAGS_ALWAYS_ON_BIKE_F
+ engine_flag wBikeFlags, BIKEFLAGS_DOWNHILL_F
engine_flag wJohtoBadges, ZEPHYRBADGE
engine_flag wJohtoBadges, HIVEBADGE
@@ -60,15 +60,15 @@
engine_flag wKantoBadges, VOLCANOBADGE
engine_flag wKantoBadges, EARTHBADGE
- ; unown sets
+ ; unown sets (see data/wild/unlocked_unowns.asm)
engine_flag wUnlockedUnowns, 0 ; A-K
engine_flag wUnlockedUnowns, 1 ; L-R
engine_flag wUnlockedUnowns, 2 ; S-W
engine_flag wUnlockedUnowns, 3 ; X-Z
- engine_flag wUnlockedUnowns, 4 ; unused 5
- engine_flag wUnlockedUnowns, 5 ; unused 6 ; $30
- engine_flag wUnlockedUnowns, 6 ; unused 7
- engine_flag wUnlockedUnowns, 7 ; unused 8
+ engine_flag wUnlockedUnowns, 4 ; unused
+ engine_flag wUnlockedUnowns, 5 ; unused ; $30
+ engine_flag wUnlockedUnowns, 6 ; unused
+ engine_flag wUnlockedUnowns, 7 ; unused
; fly
engine_flag wVisitedSpawns, SPAWN_HOME
--- a/data/wild/unlocked_unowns.asm
+++ b/data/wild/unlocked_unowns.asm
@@ -1,20 +1,24 @@
+unown_set: MACRO
+rept _NARG
+ db UNOWN_\1
+ shift
+endr
+ db -1
+ENDM
+
UnlockedUnownLetterSets:
; entries correspond to wUnlockedUnowns bits
- dw .Set1 ; ENGINE_UNLOCKED_UNOWNS_A_TO_K
- dw .Set2 ; ENGINE_UNLOCKED_UNOWNS_L_TO_R
- dw .Set3 ; ENGINE_UNLOCKED_UNOWNS_S_TO_W
- dw .Set4 ; ENGINE_UNLOCKED_UNOWNS_X_TO_Z
+ dw .Set_A_K ; ENGINE_UNLOCKED_UNOWNS_A_TO_K
+ dw .Set_L_R ; ENGINE_UNLOCKED_UNOWNS_L_TO_R
+ dw .Set_S_W ; ENGINE_UNLOCKED_UNOWNS_S_TO_W
+ dw .Set_X_Z ; ENGINE_UNLOCKED_UNOWNS_X_TO_Z
.End
-.Set1:
- ; A B C D E F G H I J K
- db 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, -1
-.Set2:
- ; L M N O P Q R
- db 12, 13, 14, 15, 16, 17, 18, -1
-.Set3:
- ; S T U V W
- db 19, 20, 21, 22, 23, -1
-.Set4:
- ; X Y Z
- db 24, 25, 26, -1
+.Set_A_K:
+ unown_set A, B, C, D, E, F, G, H, I, J, K
+.Set_L_R:
+ unown_set L, M, N, O, P, Q, R
+.Set_S_W:
+ unown_set S, T, U, V, W
+.Set_X_Z:
+ unown_set X, Y, Z
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -2471,22 +2471,22 @@
call nz, .DoubleReward
call .CheckMaxedOutMomMoney
push af
- ld a, $0
+ ld a, FALSE
jr nc, .okay
ld a, [wMomSavingMoney]
- and $7
- cp $3
+ and MOM_SAVING_MONEY_MASK
+ cp (1 << MOM_SAVING_SOME_MONEY_F) | (1 << MOM_SAVING_HALF_MONEY_F)
jr nz, .okay
- inc a
+ inc a ; TRUE
.okay
ld b, a
- ld c, $4
+ ld c, 4
.loop
ld a, b
and a
jr z, .loop2
- call .SendMoneyToMom
+ call .AddMoneyToMom
dec c
dec b
jr .loop
@@ -2505,7 +2505,7 @@
pop af
jr nc, .KeepItAll
ld a, [wMomSavingMoney]
- and $7
+ and MOM_SAVING_MONEY_MASK
jr z, .KeepItAll
ld hl, .SentToMomTexts
dec a
@@ -2523,7 +2523,7 @@
jp StdBattleTextBox
; 3d081
-.SendMoneyToMom: ; 3d081
+.AddMoneyToMom: ; 3d081
push bc
ld hl, wBattleReward + 2
ld de, wMomsMoney + 2
@@ -2557,9 +2557,9 @@
; 3d0ab
.SentToMomTexts: ; 3d0ab
- dw SentSomeToMomText
- dw SentHalfToMomText
- dw SentAllToMomText
+ dw SentSomeToMomText ; MOM_SAVING_SOME_MONEY_F
+ dw SentHalfToMomText ; MOM_SAVING_HALF_MONEY_F
+ dw SentAllToMomText ; MOM_SAVING_ALL_MONEY_F
; 3d0b1
.CheckMaxedOutMomMoney: ; 3d0b1
@@ -2574,7 +2574,7 @@
; 3d0be
AddBattleMoneyToAccount: ; 3d0be
- ld c, $3
+ ld c, 3
and a
push de
push hl
@@ -2653,7 +2653,7 @@
IsGymLeaderCommon:
push de
ld a, [OtherTrainerClass]
- ld de, $1
+ ld de, 1
call IsInArray
pop de
ret
--- a/engine/events/mom.asm
+++ b/engine/events/mom.asm
@@ -46,9 +46,9 @@
.CheckIfBankInitialized: ; 16254
ld a, [wMomSavingMoney]
- bit 7, a
+ bit MOM_ACTIVE_F, a
jr nz, .savingmoneyalready
- set 7, a
+ set MOM_ACTIVE_F, a
ld [wMomSavingMoney], a
ld a, $1
jr .done_0
@@ -68,11 +68,11 @@
jr c, .DontSaveMoney
ld hl, UnknownText_0x1664e
call PrintText
- ld a, %10000001
+ ld a, (1 << MOM_ACTIVE_F) | (1 << MOM_SAVING_SOME_MONEY_F)
jr .done_1
.DontSaveMoney:
- ld a, %10000000
+ ld a, 1 << MOM_ACTIVE_F
.done_1
ld [wMomSavingMoney], a
@@ -145,7 +145,7 @@
ld [hli], a
ld [hli], a
ld [hl], a
- ld a, $5
+ ld a, 5
ld [wMomBankDigitCursorPosition], a
call LoadStandardMenuDataHeader
call Mom_SetUpDepositMenu
@@ -212,7 +212,7 @@
ld [hli], a
ld [hli], a
ld [hl], a
- ld a, $5
+ ld a, 5
ld [wMomBankDigitCursorPosition], a
call LoadStandardMenuDataHeader
call Mom_SetUpWithdrawMenu
@@ -276,7 +276,7 @@
call PrintText
call YesNoBox
jr c, .StopSavingMoney
- ld a, $81
+ ld a, (1 << MOM_ACTIVE_F) | (1 << MOM_SAVING_SOME_MONEY_F)
ld [wMomSavingMoney], a
ld hl, UnknownText_0x16685
call PrintText
@@ -285,7 +285,7 @@
ret
.StopSavingMoney:
- ld a, $80
+ ld a, 1 << MOM_ACTIVE_F
ld [wMomSavingMoney], a
ld a, $7
ld [wJumptableIndex], a
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -358,7 +358,7 @@
call CheckBadge
jr c, .asm_c956
ld hl, wBikeFlags
- bit 1, [hl] ; always on bike
+ bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
jr nz, .cannotsurf
ld a, [PlayerState]
cp PLAYER_SURF
@@ -520,7 +520,7 @@
jr c, .quit
ld hl, wBikeFlags
- bit 1, [hl] ; always on bike (can't surf)
+ bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
jr nz, .quit
call GetSurfType
@@ -1008,7 +1008,7 @@
SetStrengthFlag: ; cd12
ld hl, wBikeFlags
- set 0, [hl]
+ set BIKEFLAGS_STRENGTH_ACTIVE_F, [hl]
ld a, [CurPartyMon]
ld e, a
ld d, 0
@@ -1086,7 +1086,7 @@
jr c, .nope
ld hl, wBikeFlags
- bit 0, [hl]
+ bit BIKEFLAGS_STRENGTH_ACTIVE_F, [hl]
jr z, .already_using
ld a, 2
@@ -1683,7 +1683,7 @@
.GetOffBike:
ld hl, wBikeFlags
- bit 1, [hl]
+ bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
jr nz, .CantGetOffBike
ld hl, Script_GetOffBike
ld de, Script_GetOffBike_Register
--- a/engine/map_setup.asm
+++ b/engine/map_setup.asm
@@ -169,7 +169,7 @@
.CheckBiking: ; 1550c (5:550c)
and a
ld hl, wBikeFlags
- bit 1, [hl]
+ bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
ret z
ld a, PLAYER_BIKE
ld [PlayerState], a
--- a/engine/phone/phone_scripts.asm
+++ b/engine/phone/phone_scripts.asm
@@ -140,7 +140,7 @@
MomPhoneLectureScript: ; 0xbcfb1
setevent EVENT_TALKED_TO_MOM_AFTER_MYSTERY_EGG_QUEST
- setflag ENGINE_DST
+ setflag ENGINE_MOM_ACTIVE
specialphonecall SPECIALCALL_NONE
farwritetext MomPhoneLectureText
yesorno
--- a/engine/player_movement.asm
+++ b/engine/player_movement.asm
@@ -19,7 +19,7 @@
; Standing downhill instead moves down.
ld hl, wBikeFlags
- bit 2, [hl] ; downhill
+ bit BIKEFLAGS_DOWNHILL_F, [hl]
ret z
ld c, a
@@ -286,7 +286,7 @@
jr nz, .walk
ld hl, wBikeFlags
- bit 2, [hl] ; downhill
+ bit BIKEFLAGS_DOWNHILL_F, [hl]
jr z, .fast
ld a, [WalkingDirection]
@@ -673,7 +673,7 @@
.CheckStrengthBoulder: ; 8036f
ld hl, wBikeFlags
- bit 0, [hl] ; using strength
+ bit BIKEFLAGS_STRENGTH_ACTIVE_F, [hl]
jr z, .not_boulder
ld hl, OBJECT_DIRECTION_WALKING
--- a/wram.asm
+++ b/wram.asm
@@ -2338,7 +2338,9 @@
StartSecond:: db ; d4b9
wRTC:: ds 8 ; d4ba
-wDST:: db ; d4c2
+wDST:: ; d4c2
+; bit 7: dst
+ db
GameTime::
GameTimeCap:: db ; d4c3
@@ -2414,31 +2416,37 @@
wSecretID:: dw
wStatusFlags:: ; d84c
- ; 0 - pokedex
- ; 1 - unown dex
- ; 2 -
- ; 3 - pokerus
- ; 4 - rocket signal
- ; 5 - wild encounters on/off
- ; 6 - hall of fame
- ; 7 - bug contest on
+; bit 0: pokedex
+; bit 1: unown dex
+; bit 2: unused
+; bit 3: pokerus
+; bit 4: rocket signal
+; bit 5: wild encounters on/off
+; bit 6: hall of fame
+; bit 7: bug contest on
db
wStatusFlags2:: ; d84d
- ; 0 - rockets
- ; 1 -
- ; 2 - bug contest timer
- ; 3 -
- ; 4 - bike shop call
- ; 5 - pokerus
- ; 6 - berry juice?
- ; 7 - rockets in mahogany
+; bit 0: rockets
+; bit 1: unused
+; bit 2: bug contest timer
+; bit 3: unused
+; bit 4: bike shop call
+; bit 5: pokerus
+; bit 6: berry juice
+; bit 7: rockets in mahogany
db
Money:: ds 3 ; d84e
wMomsMoney:: ds 3 ; d851
-wMomSavingMoney:: db ; d854
+wMomSavingMoney:: ; d854
+; bit 0: saving some money
+; bit 1: saving half money (unused)
+; bit 2: saving all money (unused)
+; bit 7: active
+ db
+
Coins:: dw ; d855
Badges::
@@ -2627,8 +2635,7 @@
; bit 1: always on bike
; bit 2: downhill
db
-
- ds 1
+ ds 1 ; also cleared by ResetBikeFlags
wCurrMapSceneScriptPointer:: dw ; dbf7