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 [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetFlashIfOutOfCave::
|
2017-12-24 10:08:38 -08:00
|
|
|
ld a, [wEnvironment]
|
2018-01-22 12:40:43 -08:00
|
|
|
cp ROUTE
|
|
|
|
jr z, .outdoors
|
|
|
|
cp TOWN
|
|
|
|
jr z, .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
|
|
|
|
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
EventFlagAction::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEventFlags
|
2013-09-07 21:19:52 -07:00
|
|
|
call FlagAction
|
|
|
|
ret
|
|
|
|
|
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
|
|
|
|
; hl: index within bit table
|
|
|
|
|
|
|
|
; get index within the byte
|
|
|
|
ld a, e
|
|
|
|
and 7
|
|
|
|
|
|
|
|
; shift de right by three bits (get the index within memory)
|
|
|
|
srl d
|
|
|
|
rr e
|
|
|
|
srl d
|
|
|
|
rr e
|
|
|
|
srl d
|
|
|
|
rr e
|
|
|
|
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
|