mirror of
https://github.com/pret/pokeyellow.git
synced 2024-11-23 14:00:03 +00:00
73 lines
696 B
NASM
73 lines
696 B
NASM
FlagActionPredef: ; f4ec (3:74ec)
|
|
call GetPredefRegisters
|
|
|
|
FlagAction: ; f4ef (3:74ef)
|
|
; Perform action b on bit c
|
|
; in the bitfield at hl.
|
|
; 0: reset
|
|
; 1: set
|
|
; 2: read
|
|
; Return the result in c.
|
|
|
|
push hl
|
|
push de
|
|
push bc
|
|
|
|
; bit
|
|
ld a, c
|
|
ld d, a
|
|
and 7
|
|
ld e, a
|
|
|
|
; byte
|
|
ld a, d
|
|
srl a
|
|
srl a
|
|
srl a
|
|
add l
|
|
ld l, a
|
|
jr nc, .ok
|
|
inc h
|
|
.ok
|
|
|
|
; d = 1 << e (bitmask)
|
|
inc e
|
|
ld d, 1
|
|
.shift
|
|
dec e
|
|
jr z, .shifted
|
|
sla d
|
|
jr .shift
|
|
.shifted
|
|
|
|
ld a, b
|
|
and a
|
|
jr z, .reset
|
|
cp 2
|
|
jr z, .read
|
|
|
|
.set
|
|
ld b, [hl]
|
|
ld a, d
|
|
or b
|
|
ld [hl], a
|
|
jr .done
|
|
|
|
.reset
|
|
ld b, [hl]
|
|
ld a, d
|
|
xor $ff
|
|
and b
|
|
ld [hl], a
|
|
jr .done
|
|
|
|
.read
|
|
ld b, [hl]
|
|
ld a, d
|
|
and b
|
|
.done
|
|
pop bc
|
|
pop de
|
|
pop hl
|
|
ld c, a
|
|
ret |