2018-06-24 14:09:41 +00:00
|
|
|
ResetMapBufferEventFlags::
|
2013-09-08 04:19:52 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wEventFlags
|
2013-09-08 04:19:52 +00:00
|
|
|
ld [hli], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ResetBikeFlags::
|
2013-09-08 04:19:52 +00:00
|
|
|
xor a
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wBikeFlags
|
2013-09-08 04:19:52 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ResetFlashIfOutOfCave::
|
2017-12-24 18:08:38 +00:00
|
|
|
ld a, [wEnvironment]
|
2018-01-22 20:40:43 +00:00
|
|
|
cp ROUTE
|
|
|
|
jr z, .outdoors
|
|
|
|
cp TOWN
|
|
|
|
jr z, .outdoors
|
2013-09-08 04:19:52 +00:00
|
|
|
ret
|
|
|
|
|
2018-01-22 20:40:43 +00:00
|
|
|
.outdoors
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags
|
2018-01-22 20:40:43 +00:00
|
|
|
res STATUSFLAGS_FLASH_F, [hl]
|
2013-09-08 04:19:52 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
EventFlagAction::
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wEventFlags
|
2013-09-08 04:19:52 +00:00
|
|
|
call FlagAction
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
FlagAction::
|
2013-09-08 04:19:52 +00:00
|
|
|
; Perform action b on bit de in flag array hl.
|
|
|
|
|
|
|
|
; inputs:
|
|
|
|
; b: function
|
2017-12-09 05:50:59 +00:00
|
|
|
; 0 RESET_FLAG clear bit
|
|
|
|
; 1 SET_FLAG set bit
|
|
|
|
; 2 CHECK_FLAG check bit
|
2013-09-08 04:19:52 +00: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-09 05:50:59 +00:00
|
|
|
cp SET_FLAG
|
|
|
|
jr c, .clearbit ; RESET_FLAG
|
|
|
|
jr z, .setbit ; SET_FLAG
|
2013-09-08 04:19:52 +00: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 14:09:41 +00:00
|
|
|
CheckReceivedDex::
|
2013-09-08 04:19:52 +00:00
|
|
|
ld de, ENGINE_POKEDEX
|
|
|
|
ld b, CHECK_FLAG
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall EngineFlagAction
|
2013-09-08 04:19:52 +00:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret
|