collision_tile_lut:
.rep cti, ROOM_H, 1, .db cti * ROOM_W
- ; collision-tile call
- ; but using static
- ; params in wram:
- ; inputs:
- ; ct_pty/ct_ptx: collision tile y/x
- ; ct_pox/ct_poy: position y/x
-collision_tile_stat:
- ld a, [ct_pty]
- ld b, a ; b = pty
-
- ld a, [ct_ptx]
- ld c, a ; c = ptx
+ ; checks an entire collision table based on an original point
+ ; and a ptr to a collision point table
+ ; inputs:
+ ; hl: ptr to y/x position
+ ; de: collision point table
+ ; returns:
+ ; a = 0 -> no collision
+ ; a = 1 -> collision
+collision_tile_table_check:
+ ld a, [hl+]
+ ld [ct_poy], a ; y buffer
+ ld a, [hl]
+ ld [ct_pox], a ; x buffer
- ld a, [ct_poy]
- ld d, a ; d = poy
+ ld a, [de] ; load loop counter
+ inc de ; de + 1 = first point y coordinate
+@loop:
+ push af
+ push de
+ push hl
+ ld a, [de]
+ ld l, a
ld a, [ct_poy]
- ld e, a ; e = pox
+ add a, l ; a = y + collision y offset
+ inc de
+
+ ld a, [de]
+ ld h, a
+ ld a, [ct_pox]
+ add a, h ; a = x + collision x offset
+
+ ld d, l
+ ld e, h
+
+ call collision_tile
+
+ pop af
+ pop de
+ pop hl
+
+ dec a ; a--
+ cp a, 0 ; again if not 0
+ jp nz, @loop
+
+ ret
- ; checks a collision ptr
+ ; checks a point
; with a map's meta tile
; if the tile has collision flag set
; returns 1 otherwise 0
; inputs:
- ; b/c: collision point (y/x)
; d : y pos
; e : x pos
; returns:
; a = 0 -> no collision
; a = 1 -> collision
- ; hl += 2
collision_tile:
; y pos / 16 -> tile pos
sra d ; / 2