2018-06-24 07:09:41 -07:00
|
|
|
ResetMapBufferEventFlags::
|
2013-09-07 21:19:52 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEventFlags
|
2013-09-07 21:19:52 -07:00
|
|
|
ld [hli], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetBikeFlags::
|
2013-09-07 21:19:52 -07:00
|
|
|
xor a
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, wBikeFlags
|
2013-09-07 21:19:52 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetFlashIfOutOfCave::
|
2017-12-24 10:08:38 -08:00
|
|
|
ld a, [wEnvironment]
|
2023-08-04 09:45:50 -07:00
|
|
|
cp INDOOR_ENVIRONMENT
|
|
|
|
jr c, .outdoors
|
2013-09-07 21:19:52 -07:00
|
|
|
ret
|
|
|
|
|
2018-01-22 12:40:43 -08:00
|
|
|
.outdoors
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, wStatusFlags
|
2018-01-22 12:40:43 -08:00
|
|
|
res STATUSFLAGS_FLASH_F, [hl]
|
2013-09-07 21:19:52 -07:00
|
|
|
ret
|
|
|
|
|
2023-08-20 16:45:06 -07:00
|
|
|
UnlockedLevelsFlagAction::
|
2023-08-22 03:08:52 -07:00
|
|
|
; Perform action b on bit e in flag array wUnlockedLevels.
|
2023-08-20 16:45:06 -07:00
|
|
|
ld hl, wUnlockedLevels
|
2023-08-22 03:08:52 -07:00
|
|
|
ld d, 0
|
2023-08-20 16:45:06 -07:00
|
|
|
jr FlagAction
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
EventFlagAction::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEventFlags
|
2023-08-20 16:45:06 -07:00
|
|
|
; fallthrough
|
2013-09-07 21:19:52 -07:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
FlagAction::
|
2013-09-07 21:19:52 -07:00
|
|
|
; Perform action b on bit de in flag array hl.
|
|
|
|
|
|
|
|
; inputs:
|
|
|
|
; b: function
|
2017-12-08 21:50:59 -08:00
|
|
|
; 0 RESET_FLAG clear bit
|
|
|
|
; 1 SET_FLAG set bit
|
|
|
|
; 2 CHECK_FLAG check bit
|
2013-09-07 21:19:52 -07:00
|
|
|
; de: bit number
|
2018-10-11 02:37:19 -07:00
|
|
|
; hl: pointer to the flag array
|
2013-09-07 21:19:52 -07:00
|
|
|
|
|
|
|
; get index within the byte
|
|
|
|
ld a, e
|
|
|
|
and 7
|
|
|
|
|
|
|
|
; shift de right by three bits (get the index within memory)
|
2018-11-20 12:53:45 -08:00
|
|
|
rept 3
|
2013-09-07 21:19:52 -07:00
|
|
|
srl d
|
|
|
|
rr e
|
2018-11-20 12:53:45 -08:00
|
|
|
endr
|
2013-09-07 21:19:52 -07:00
|
|
|
add hl, de
|
|
|
|
|
|
|
|
; implement a decoder
|
|
|
|
ld c, 1
|
|
|
|
rrca
|
|
|
|
jr nc, .one
|
|
|
|
rlc c
|
|
|
|
.one
|
|
|
|
rrca
|
|
|
|
jr nc, .two
|
|
|
|
rlc c
|
|
|
|
rlc c
|
|
|
|
.two
|
|
|
|
rrca
|
|
|
|
jr nc, .three
|
|
|
|
swap c
|
|
|
|
.three
|
|
|
|
|
|
|
|
; check b's value: 0, 1, 2
|
|
|
|
ld a, b
|
2017-12-08 21:50:59 -08:00
|
|
|
cp SET_FLAG
|
|
|
|
jr c, .clearbit ; RESET_FLAG
|
|
|
|
jr z, .setbit ; SET_FLAG
|
2013-09-07 21:19:52 -07:00
|
|
|
|
|
|
|
; check bit
|
|
|
|
ld a, [hl]
|
|
|
|
and c
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.setbit
|
|
|
|
; set bit
|
|
|
|
ld a, [hl]
|
|
|
|
or c
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.clearbit
|
|
|
|
; clear bit
|
|
|
|
ld a, c
|
|
|
|
cpl
|
|
|
|
and [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckReceivedDex::
|
2013-09-07 21:19:52 -07:00
|
|
|
ld de, ENGINE_POKEDEX
|
|
|
|
ld b, CHECK_FLAG
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall EngineFlagAction
|
2013-09-07 21:19:52 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret
|