ret
; loads a collision point into bc
+ ; point must be in hram
; inputs:
; $1: point name
; returns:
; b/c: y/x tile position
#macro _act_col_load_pt
- ld a, [$1]
+ ldh a, [$1]
ld b, a
- ld a, [$1+1]
+ ldh a, [$1+1]
ld c, a
#endmacro
#define HRAM 0xFF80
; 0x80 - 0x90 are used by dma routines
-.org 0x90
+.org 0xFF90
- ; shadow registers
-a2: .adv 1
-b2: .adv 1
-c2: .adv 1
-d2: .adv 1
-e2: .adv 1
-h2: .adv 1
-l2: .adv 1
+ ; corner points
+ ; used for actor -> actor center collision
+ ; should form a rectangle
+ ; also used for tile collision
+ ;
+ ; top left, top right
+ ; bottom left, bottom right
+col_point_tl: .adv 2
+col_point_tr: .adv 2
+col_point_bl: .adv 2
+col_point_br: .adv 2
+
+ ; mid points
+ ; top, bottom, left, right center
+ ; used for tile collision
+col_point_tc: .adv 2
+col_point_bc: .adv 2
+col_point_lc: .adv 2
+col_point_rc: .adv 2
+ ; center point of the actor
+ ; this is used to check for actor -> actor collision
+col_point_ct: .adv 2
+
+
+ ; direction the movement is happening
+ ; in. this is required so that the collision code
+ ; can handle pushbacks in case of wall collision
+col_direction: .adv 2
+ ; holds tile collision direction result
+col_tile_collided_with: .adv 1
+
+ ; y/x previous position
+col_prev_pos: .adv 2
; top left point
ld a, b
add a, 2
- ld [col_point_tl], a
+ ldh [col_point_tl], a
ld a, c
add a, 2
- ld [col_point_tl+1], a
+ ldh [col_point_tl+1], a
; top right point
ld a, b
add a, 2
- ld [col_point_tr], a
+ ldh [col_point_tr], a
ld a, c
add a, 12
- ld [col_point_tr+1], a
+ ldh [col_point_tr+1], a
; bottom left point
ld a, b
add a, 14
- ld [col_point_bl], a
+ ldh [col_point_bl], a
ld a, c
add a, 2
- ld [col_point_bl+1], a
+ ldh [col_point_bl+1], a
; bottom right points
ld a, b
add a, 14
- ld [col_point_br], a
+ ldh [col_point_br], a
ld a, c
add a, 12
- ld [col_point_br+1], a
+ ldh [col_point_br+1], a
; center point
ld a, b
add a, 8
- ld [col_point_ct], a
+ ldh [col_point_ct], a
ld a, c
add a, 7
- ld [col_point_ct+1], a
+ ldh [col_point_ct+1], a
; top center point
ld a, b
add a, 2
- ld [col_point_tc], a
+ ldh [col_point_tc], a
ld a, c
add a, 7
- ld [col_point_tc+1], a
+ ldh [col_point_tc+1], a
; bottom center point
ld a, b
add a, 14
- ld [col_point_bc], a
+ ldh [col_point_bc], a
ld a, c
add a, 7
- ld [col_point_bc+1], a
+ ldh [col_point_bc+1], a
; left center point
ld a, b
add a, 8
- ld [col_point_lc], a
+ ldh [col_point_lc], a
ld a, c
add a, 2
- ld [col_point_lc+1], a
+ ldh [col_point_lc+1], a
; right center point
ld a, b
add a, 8
- ld [col_point_rc], a
+ ldh [col_point_rc], a
ld a, c
add a, 12
- ld [col_point_rc+1], a
+ ldh [col_point_rc+1], a
ret
; collision related data
; y/x positions
-
- ; corner points
- ; used for actor -> actor center collision
- ; should form a rectangle
- ; also used for tile collision
- ;
- ; top left, top right
- ; bottom left, bottom right
-col_point_tl: .adv 2
-col_point_tr: .adv 2
-col_point_bl: .adv 2
-col_point_br: .adv 2
-
- ; mid points
- ; top, bottom, left, right center
- ; used for tile collision
-col_point_tc: .adv 2
-col_point_bc: .adv 2
-col_point_lc: .adv 2
-col_point_rc: .adv 2
-
- ; center point of the actor
- ; this is used to check for actor -> actor collision
-col_point_ct: .adv 2
-
-
- ; direction the movement is happening
- ; in. this is required so that the collision code
- ; can handle pushbacks in case of wall collision
-col_direction: .adv 2
- ; holds tile collision direction result
-col_tile_collided_with: .adv 1
-
- ; y/x previous position
-col_prev_pos: .adv 2
; space for 1 tile id