2018-06-24 14:09:41 +00:00
|
|
|
SmallFarFlagAction:
|
2018-01-07 10:53:20 +00:00
|
|
|
; Perform action b on bit c in flag array hl.
|
2017-12-16 17:49:43 +00:00
|
|
|
; If checking a flag, check flag array d:hl unless d is 0.
|
|
|
|
|
|
|
|
; For longer flag arrays, see FlagAction.
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
|
|
|
|
; Divide by 8 to get the byte we want.
|
|
|
|
push bc
|
|
|
|
srl c
|
|
|
|
srl c
|
|
|
|
srl c
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
; Which bit we want from the byte
|
|
|
|
ld a, c
|
|
|
|
and 7
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
; Shift left until we can mask the bit
|
|
|
|
ld a, 1
|
|
|
|
jr z, .shifted
|
|
|
|
.shift
|
|
|
|
add a
|
|
|
|
dec c
|
|
|
|
jr nz, .shift
|
|
|
|
.shifted
|
|
|
|
ld c, a
|
|
|
|
|
|
|
|
; What are we doing to this flag?
|
|
|
|
dec b
|
|
|
|
jr z, .set ; 1
|
|
|
|
dec b
|
|
|
|
jr z, .check ; 2
|
|
|
|
|
|
|
|
.reset
|
|
|
|
ld a, c
|
|
|
|
cpl
|
|
|
|
and [hl]
|
|
|
|
ld [hl], a
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.set
|
|
|
|
ld a, [hl]
|
|
|
|
or c
|
|
|
|
ld [hl], a
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.check
|
|
|
|
ld a, d
|
|
|
|
cp 0
|
|
|
|
jr nz, .farcheck
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
and c
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.farcheck
|
|
|
|
call GetFarByte
|
|
|
|
and c
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ld c, a
|
|
|
|
ret
|