; a = 0 -> no collision
; a = 1 -> collision
collision_tile:
- call room_get_flag_ptr
- ; hl = current tile flags
-
- ld a, [hl] ; load flags
- ld d, a
ld a, [ct_mask]
- and a, d
-
- ret
+ jp room_get_flag_masked
; a: the flag to set (flags | a)
; de: y/x
room_set_flag:
+ ld b, a
+ call room_get_flag_ptr
+ ld a, [hl]
+ or a, b
+ ld [hl], a
+
ret
; unsets a tile position flag
; a: the flag to set (flags ^ a)
; de: y/x
room_unset_flag:
- ret
+ ld b, a
+ call room_get_flag_ptr
+ ld a, [hl]
+ xor a, b
+ ld [hl], a
+ ret
+
+ ; gets flags at a certain position
+ ; applies a mask
+ ; inputs:
+ ; d : y pos
+ ; e : x pos
+ ; a: mask
+ ; ct_mask: bit mask for flag to check (tile & mask)
+ ; returns:
+ ; a: masked flag
+room_get_flag_masked:
+ ld b, a ; b = mask
+ call room_get_flag_ptr
+ ; hl = current tile flags
+
+ ld a, [hl] ; load flags
+ ld d, a
+ ld a, b ; a= mask
+ ; ld a, [ct_mask]
+ and a, d
+ ret
; base room
; this can be copied and modified