Skip to content

Commit b5d2540

Browse files
authored
Identify more bit flags (#465)
* Identify more bit flags * Space
1 parent c3f297e commit b5d2540

File tree

13 files changed

+40
-27
lines changed

13 files changed

+40
-27
lines changed

engine/events/hidden_objects/indigo_plateau_statues.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ IndigoPlateauStatues::
33
ld hl, IndigoPlateauStatuesText1
44
call PrintText
55
ld a, [wXCoord]
6-
bit 0, a
6+
bit 0, a ; even or odd?
77
ld hl, IndigoPlateauStatuesText2
88
jr nz, .ok
99
ld hl, IndigoPlateauStatuesText3

engine/gfx/mon_icons.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ GetPartyMonSpriteID:
269269
ld d, 0
270270
add hl, de
271271
ld a, [hl]
272-
bit 0, c
272+
bit 0, c ; even or odd?
273273
jr nz, .skipSwap
274274
swap a ; use lower nybble if pokedex num is even
275275
.skipSwap

engine/gfx/screen_effects.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ PredefShakeScreenHorizontally:
6161
ldh a, [hMutateWX]
6262
xor b
6363
ldh [hMutateWX], a
64-
bit 7, a
64+
bit 7, a ; negative?
6565
jr z, .skipZeroing
6666
xor a ; zero a if it's negative
6767
.skipZeroing

engine/movie/oak_speech/oak_speech.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PrepareOakSpeech:
44
ld a, [wOptions]
55
push af
66
; Retrieve BIT_DEBUG_MODE set in DebugMenu for StartNewGameDebug.
7-
; BUG: StartNewGame carries over bit 5 from previous save files,
7+
; BUG: StartNewGame carries over BIT_ALWAYS_ON_BIKE from previous save files,
88
; which causes CheckForceBikeOrSurf to not return.
9-
; To fix this in debug builds, reset bit 5 here or in StartNewGame.
9+
; To fix this in debug builds, reset BIT_ALWAYS_ON_BIKE here or in StartNewGame.
1010
; In non-debug builds, the instructions can be removed.
1111
ld a, [wStatusFlags6]
1212
push af

engine/overworld/map_sprites.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ LoadMapSpriteTilePatterns:
187187
jr nz, .loadWhileLCDOn
188188
pop af
189189
pop hl
190-
set 3, h ; add $80 tiles to hl
190+
set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8)
191191
push hl
192192
ld h, d
193193
ld l, e
@@ -200,7 +200,7 @@ LoadMapSpriteTilePatterns:
200200
.loadWhileLCDOn
201201
pop af
202202
pop hl
203-
set 3, h ; add $80 tiles to hl
203+
set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8)
204204
ld b, a
205205
swap c
206206
call CopyVideoData ; load tile pattern data for sprite when walking

engine/overworld/movement.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ CanWalkOntoTile:
641641
add SPRITESTATEDATA2_YDISPLACEMENT
642642
ld l, a
643643
ld a, [hli] ; x#SPRITESTATEDATA2_YDISPLACEMENT (initialized at $8, keep track of where a sprite did go)
644-
bit 7, d ; check if going upwards (d=$ff)
644+
bit 7, d ; check if going upwards (d == -1)
645645
jr nz, .upwards
646646
add d
647647
; bug: these tests against $5 probably were supposed to prevent
@@ -658,7 +658,7 @@ CanWalkOntoTile:
658658
.checkHorizontal
659659
ld d, a
660660
ld a, [hl] ; x#SPRITESTATEDATA2_XDISPLACEMENT (initialized at $8, keep track of where a sprite did go)
661-
bit 7, e ; check if going left (e=$ff)
661+
bit 7, e ; check if going left (e == -1)
662662
jr nz, .left
663663
add e
664664
cp $5 ; compare, but no conditional jump like in the vertical check above (bug?)

engine/overworld/player_state.asm

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ _GetTileAndCoordsInFrontOfPlayer:
294294
ld [wTileInFrontOfPlayer], a
295295
ret
296296

297+
; hPlayerFacing
298+
const_def
299+
const BIT_FACING_DOWN ; 0
300+
const BIT_FACING_UP ; 1
301+
const BIT_FACING_LEFT ; 2
302+
const BIT_FACING_RIGHT ; 3
303+
297304
GetTileTwoStepsInFrontOfPlayer:
298305
xor a
299306
ldh [hPlayerFacing], a
@@ -306,7 +313,7 @@ GetTileTwoStepsInFrontOfPlayer:
306313
jr nz, .notFacingDown
307314
; facing down
308315
ld hl, hPlayerFacing
309-
set 0, [hl]
316+
set BIT_FACING_DOWN, [hl]
310317
lda_coord 8, 13
311318
inc d
312319
jr .storeTile
@@ -315,7 +322,7 @@ GetTileTwoStepsInFrontOfPlayer:
315322
jr nz, .notFacingUp
316323
; facing up
317324
ld hl, hPlayerFacing
318-
set 1, [hl]
325+
set BIT_FACING_UP, [hl]
319326
lda_coord 8, 5
320327
dec d
321328
jr .storeTile
@@ -324,7 +331,7 @@ GetTileTwoStepsInFrontOfPlayer:
324331
jr nz, .notFacingLeft
325332
; facing left
326333
ld hl, hPlayerFacing
327-
set 2, [hl]
334+
set BIT_FACING_LEFT, [hl]
328335
lda_coord 4, 9
329336
dec e
330337
jr .storeTile
@@ -333,7 +340,7 @@ GetTileTwoStepsInFrontOfPlayer:
333340
jr nz, .storeTile
334341
; facing right
335342
ld hl, hPlayerFacing
336-
set 3, [hl]
343+
set BIT_FACING_RIGHT, [hl]
337344
lda_coord 12, 9
338345
inc e
339346
.storeTile
@@ -385,7 +392,7 @@ CheckForBoulderCollisionWithSprites:
385392
ld de, $f
386393
ld hl, wSprite01StateData2MapY
387394
ldh a, [hPlayerFacing]
388-
and $3 ; facing up or down?
395+
and (1 << BIT_FACING_UP) | (1 << BIT_FACING_DOWN)
389396
jr z, .pushingHorizontallyLoop
390397
.pushingVerticallyLoop
391398
inc hl
@@ -396,6 +403,7 @@ CheckForBoulderCollisionWithSprites:
396403
ld a, [hli]
397404
ld b, a
398405
ldh a, [hPlayerFacing]
406+
assert BIT_FACING_DOWN == 0
399407
rrca
400408
jr c, .pushingDown
401409
; pushing up
@@ -421,7 +429,7 @@ CheckForBoulderCollisionWithSprites:
421429
jr nz, .nextSprite2
422430
ld b, [hl]
423431
ldh a, [hPlayerFacing]
424-
bit 2, a
432+
bit BIT_FACING_LEFT, a
425433
jr nz, .pushingLeft
426434
; pushing right
427435
ldh a, [hPlayerXCoord]

engine/overworld/spinners.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LoadSpinnerArrowTiles::
1515
ld hl, GymSpinnerArrows
1616
.gotSpinnerArrows
1717
ld a, [wSimulatedJoypadStatesIndex]
18-
bit 0, a
18+
bit 0, a ; even or odd?
1919
jr nz, .alternateGraphics
2020
ld de, 6 * 4
2121
add hl, de

home/overworld.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ LoadPlayerSpriteGraphicsCommon::
20022002
jr nc, .noCarry
20032003
inc d
20042004
.noCarry
2005-
set 3, h
2005+
set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8)
20062006
lb bc, BANK(RedSprite), $0c
20072007
jp CopyVideoData
20082008

home/pokemon.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ HandlePartyMenuInput::
252252
jp nz, .swappingPokemon
253253
pop af
254254
ldh [hTileAnimations], a
255-
bit 1, b
255+
bit BIT_B_BUTTON, b
256256
jr nz, .noPokemonChosen
257257
ld a, [wPartyCount]
258258
and a

0 commit comments

Comments
 (0)