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
|
2018-10-11 09:37:19 +00:00
|
|
|
; hl: pointer to the flag array
|
2013-09-08 04:19:52 +00: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 20:53:45 +00:00
|
|
|
rept 3
|
2013-09-08 04:19:52 +00:00
|
|
|
srl d
|
|
|
|
rr e
|
2018-11-20 20:53:45 +00:00
|
|
|
endr
|
2013-09-08 04:19:52 +00: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-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
|
2020-02-21 22:48:51 +00:00
|
|
|
|
|
|
|
Unreferenced_CheckBPressedDebug::
|
|
|
|
; Used in debug ROMs to walk through walls and avoid encounters.
|
|
|
|
|
|
|
|
ld a, [wDebugFlags]
|
|
|
|
bit DEBUG_FIELD_F, a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ldh a, [hJoyDown]
|
|
|
|
bit B_BUTTON_F, a
|
|
|
|
ret
|
|
|
|
|
|
|
|
xor_a::
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
xor_a_dec_a::
|
|
|
|
xor a
|
|
|
|
dec a
|
|
|
|
ret
|
|
|
|
|
|
|
|
Unreferenced_CheckFieldDebug::
|
|
|
|
push hl
|
|
|
|
ld hl, wDebugFlags
|
|
|
|
bit DEBUG_FIELD_F, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|