ld [dbg_delay], a
ret
+ ; gets rectangle point and loads it into de
+ ; preserves all other registers
+ ; inputs:
+ ; $1: rect_br/bl/tr/tl
+ ; de: rectangle ptr
+#macro dbg_rect_draw_get
+ push hl
+ push de
+
+ push de
+ pop hl ; hl = rectangle
+ call $1
+ push de
+ pop bc ; bc = point
+
+ pop de
+ pop hl
+#endmacro
+
; draws a marker obj at
; the edge of a rectangle
; keys:
pop de
; hl = oam
- inc de ; de = y position
-
- ld a, [de]
- add a, OBJ_OFF_Y
- ld b, a ; b = y
-
- inc de
- ld a, [de]
- add a, OBJ_OFF_X
- ld c, a ; c = x
- inc de ; de = height
+ dbg_rect_draw_get rect_tl
+ ; bc = top left
; write top left y
ld a, b
+ add a, OBJ_OFF_Y
ld [hl+], a
; write top left x
ld a, c
+ add a, OBJ_OFF_X
ld [hl+], a
; write tile
; write flags
xor a, a
ld [hl+], a
-
- ; write top left y
- ld a, [de] ; a = heigth
- push bc
- ld c, a
- ld a, b
- sub a, c ; height - y
- pop bc
+ ; bottom left
+ dbg_rect_draw_get rect_bl
+
+ ; write bottom left y
+ ld a, b
+ add a, OBJ_OFF_Y
ld [hl+], a
- ; write top left x
+ ; write bottom left x
ld a, c
+ add a, OBJ_OFF_X
ld [hl+], a
; write tile
xor a, a
ld [hl+], a
+
+
+ ; bottom right
+ dbg_rect_draw_get rect_br
+
; write bottom right y
- inc de ; de = width
- ld a, b ; a = y
+ ld a, b
+ add a, OBJ_OFF_Y
ld [hl+], a
; write bottomt right x
ld a, [de]
- add a, c ; width + x
+ add a, OBJ_OFF_X
ld [hl+], a
; write tile
xor a, a
ld [hl+], a
- dec de ; de = height
- ; write top right y
- ld a, [de] ; a = height
- push bc
- ld c, a
- ld a, b
- sub a, c ; height - y
- pop bc
+ ; top right
+ dbg_rect_draw_get rect_tr
+ ld a, b
+ add a, OBJ_OFF_X
ld [hl+], a
; write top left x
- inc de ; de = width
- ld a, [de]
- add a, c ; width + x
+ add a, c
+ add a, OBJ_OFF_X
ld [hl+], a
; write tile