Skip to content

Commit 8f1dcf0

Browse files
authored
Identify more flag bits (#464)
1 parent 21cfdbd commit 8f1dcf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+267
-193
lines changed

audio/engine_1.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Audio1_UpdateMusic::
1515
ld a, [wMuteAudioAndPauseMusic]
1616
and a
1717
jr z, .applyAffects
18-
bit 7, a
18+
bit BIT_MUTE_AUDIO, a
1919
jr nz, .nextChannel
20-
set 7, a
20+
set BIT_MUTE_AUDIO, a
2121
ld [wMuteAudioAndPauseMusic], a
2222
xor a ; disable all channels' output
2323
ldh [rNR51], a
@@ -197,7 +197,7 @@ Audio1_sound_ret:
197197
.dontDisable
198198
jr .afterDisable
199199
.returnFromCall
200-
res 1, [hl]
200+
res BIT_SOUND_CALL, [hl]
201201
ld d, $0
202202
ld a, c
203203
add a
@@ -377,8 +377,8 @@ Audio1_toggle_perfect_pitch:
377377
ld hl, wChannelFlags1
378378
add hl, bc
379379
ld a, [hl]
380-
xor $1
381-
ld [hl], a ; flip bit 0 of wChannelFlags1
380+
xor 1 << BIT_PERFECT_PITCH
381+
ld [hl], a
382382
jp Audio1_sound_ret
383383

384384
Audio1_vibrato:

audio/engine_2.asm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Audio2_UpdateMusic::
1717
ld a, [wMuteAudioAndPauseMusic]
1818
and a
1919
jr z, .applyAffects
20-
bit 7, a
20+
bit BIT_MUTE_AUDIO, a
2121
jr nz, .nextChannel
22-
set 7, a
22+
set BIT_MUTE_AUDIO, a
2323
ld [wMuteAudioAndPauseMusic], a
2424
xor a ; disable all channels' output
2525
ldh [rNR51], a
@@ -163,8 +163,8 @@ Audio2_PlayNextNote:
163163
ld a, c
164164
cp CHAN5
165165
jr nz, .beginChecks
166-
ld a, [wLowHealthAlarm] ; low health alarm enabled?
167-
bit 7, a
166+
ld a, [wLowHealthAlarm]
167+
bit BIT_LOW_HEALTH_ALARM, a
168168
ret nz
169169
.beginChecks
170170
; ---
@@ -208,7 +208,7 @@ Audio2_sound_ret:
208208
.dontDisable
209209
jr .afterDisable
210210
.returnFromCall
211-
res 1, [hl]
211+
res BIT_SOUND_CALL, [hl]
212212
ld d, $0
213213
ld a, c
214214
add a
@@ -388,8 +388,8 @@ Audio2_toggle_perfect_pitch:
388388
ld hl, wChannelFlags1
389389
add hl, bc
390390
ld a, [hl]
391-
xor $1
392-
ld [hl], a ; flip bit 0 of wChannelFlags1
391+
xor 1 << BIT_PERFECT_PITCH
392+
ld [hl], a
393393
jp Audio2_sound_ret
394394

395395
Audio2_vibrato:
@@ -978,7 +978,7 @@ Audio2_ResetCryModifiers:
978978
cp CHAN5
979979
jr nz, .skip
980980
ld a, [wLowHealthAlarm]
981-
bit 7, a
981+
bit BIT_LOW_HEALTH_ALARM, a
982982
jr z, .skip
983983
xor a
984984
ld [wFrequencyModifier], a

audio/engine_3.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Audio3_UpdateMusic::
1515
ld a, [wMuteAudioAndPauseMusic]
1616
and a
1717
jr z, .applyAffects
18-
bit 7, a
18+
bit BIT_MUTE_AUDIO, a
1919
jr nz, .nextChannel
20-
set 7, a
20+
set BIT_MUTE_AUDIO, a
2121
ld [wMuteAudioAndPauseMusic], a
2222
xor a ; disable all channels' output
2323
ldh [rNR51], a
@@ -197,7 +197,7 @@ Audio3_sound_ret:
197197
.dontDisable
198198
jr .afterDisable
199199
.returnFromCall
200-
res 1, [hl]
200+
res BIT_SOUND_CALL, [hl]
201201
ld d, $0
202202
ld a, c
203203
add a
@@ -377,8 +377,8 @@ Audio3_toggle_perfect_pitch:
377377
ld hl, wChannelFlags1
378378
add hl, bc
379379
ld a, [hl]
380-
xor $1
381-
ld [hl], a ; flip bit 0 of wChannelFlags1
380+
xor 1 << BIT_PERFECT_PITCH
381+
ld [hl], a
382382
jp Audio3_sound_ret
383383

384384
Audio3_vibrato:

audio/low_health_alarm.asm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Music_DoLowHealthAlarm::
22
ld a, [wLowHealthAlarm]
3-
cp $ff
3+
cp DISABLE_LOW_HEALTH_ALARM
44
jr z, .disableAlarm
55

6-
bit 7, a ;alarm enabled?
7-
ret z ;nope
6+
bit BIT_LOW_HEALTH_ALARM, a
7+
ret z
88

9-
and $7f ;low 7 bits are the timer.
9+
and LOW_HEALTH_TIMER_MASK
1010
jr nz, .notToneHi ;if timer > 0, play low tone.
1111

1212
call .playToneHi
@@ -19,15 +19,15 @@ Music_DoLowHealthAlarm::
1919
call .playToneLo ;actually set the sound registers.
2020

2121
.noTone
22-
ld a, $86
22+
ld a, CRY_SFX_END
2323
ld [wChannelSoundIDs + CHAN5], a ;disable sound channel?
2424
ld a, [wLowHealthAlarm]
25-
and $7f ;decrement alarm timer.
25+
and LOW_HEALTH_TIMER_MASK
2626
dec a
2727

2828
.resetTimer
2929
; reset the timer and enable flag.
30-
set 7, a
30+
set BIT_LOW_HEALTH_ALARM, a
3131
ld [wLowHealthAlarm], a
3232
ret
3333

constants/audio_constants.asm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ DEF HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff)
6666

6767
; wChannelFlags2 constant (only has one flag)
6868
DEF BIT_EXECUTE_MUSIC EQU 0 ; if in execute music
69+
70+
; wMuteAudioAndPauseMusic
71+
DEF BIT_MUTE_AUDIO EQU 7
72+
73+
; wLowHealthAlarm
74+
DEF BIT_LOW_HEALTH_ALARM EQU 7
75+
DEF LOW_HEALTH_TIMER_MASK EQU %01111111
76+
DEF DISABLE_LOW_HEALTH_ALARM EQU $ff

constants/battle_constants.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ DEF MAX_STAT_VALUE EQU 999
7272
DEF ATKDEFDV_TRAINER EQU $98
7373
DEF SPDSPCDV_TRAINER EQU $88
7474

75+
; wDamageMultipliers
76+
DEF BIT_STAB_DAMAGE EQU 7
77+
DEF EFFECTIVENESS_MASK EQU %01111111
78+
7579
; wPlayerBattleStatus1 or wEnemyBattleStatus1 bit flags
7680
const_def
7781
const STORING_ENERGY ; 0 ; Bide

constants/gfx_constants.asm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ DEF TRANSFERBOTTOM EQU 2
2929
DEF REDRAW_COL EQU 1
3030
DEF REDRAW_ROW EQU 2
3131

32+
; hUILayoutFlags
33+
const_def
34+
const BIT_PARTY_MENU_HP_BAR ; 0
35+
const BIT_DOUBLE_SPACED_MENU ; 1
36+
const BIT_SINGLE_SPACED_LINES ; 2
37+
3238
; tile list ids
3339
; TileIDListPointerTable indexes (see data/tilemaps.asm)
3440
const_def

constants/map_object_constants.asm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ DEF SPRITESTATEDATA2_LENGTH EQU const_value
4040

4141
DEF NUM_SPRITESTATEDATA_STRUCTS EQU 16
4242

43+
const_def 6
44+
const BIT_TRAINER ; 6
45+
const BIT_ITEM ; 7
46+
4347
; different kinds of people events
44-
DEF ITEM EQU $80
45-
DEF TRAINER EQU $40
48+
DEF TRAINER EQU 1 << BIT_TRAINER
49+
DEF ITEM EQU 1 << BIT_ITEM
50+
51+
; movement status
52+
DEF BIT_FACE_PLAYER EQU 7
4653

4754
DEF WALK EQU $FE
4855
DEF STAY EQU $FF

constants/menu_constants.asm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ DEF PC_ITEM_CAPACITY EQU 50
4444
const NO_YES_MENU ; 7
4545
DEF NUM_TWO_OPTION_MENUS EQU const_value
4646

47+
; wTwoOptionMenuID
48+
DEF BIT_SECOND_MENU_OPTION_DEFAULT EQU 7
49+
4750
; menu exit method constants for list menus and the buy/sell/quit menu
4851
DEF CHOSE_MENU_ITEM EQU 1 ; pressed A
4952
DEF CANCELLED_MENU EQU 2 ; pressed B

constants/oam_constants.asm

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
; OAM flags used by this game
2-
DEF OAMFLAG_ENDOFDATA EQU %00000001 ; pseudo OAM flag, only used by game logic
3-
DEF OAMFLAG_CANBEMASKED EQU %00000010 ; pseudo OAM flag, only used by game logic
1+
; Pseudo-OAM flags used by game logic
2+
const_def
3+
const BIT_END_OF_OAM_DATA ; 0
4+
const BIT_SPRITE_UNDER_GRASS ; 1
5+
6+
; Used in SpriteFacingAndAnimationTable (see data/sprites/facings.asm)
7+
DEF FACING_END EQU 1 << BIT_END_OF_OAM_DATA
8+
DEF UNDER_GRASS EQU 1 << BIT_SPRITE_UNDER_GRASS
49

510
; OAM attribute flags
6-
DEF OAM_PALETTE EQU %111
7-
DEF OAM_TILE_BANK EQU 3
8-
DEF OAM_OBP_NUM EQU 4 ; Non CGB Mode Only
9-
DEF OAM_X_FLIP EQU 5
10-
DEF OAM_Y_FLIP EQU 6
11-
DEF OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3)
11+
DEF OAM_PALETTE EQU %111
12+
const_def 3
13+
const OAM_TILE_BANK ; 3
14+
const OAM_OBP_NUM ; 4 ; Non CGB Mode Only
15+
const OAM_X_FLIP ; 5
16+
const OAM_Y_FLIP ; 6
17+
const OAM_PRIORITY ; 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3)
1218

1319
; OAM attribute masks
1420
DEF OAM_OBP1 EQU 1 << OAM_OBP_NUM ; OBJ palette 1

0 commit comments

Comments
 (0)