pokecrystal/macros/coords.asm

60 lines
1.0 KiB
NASM
Raw Normal View History

; Coordinate macros
DEF hlcoord EQUS "coord hl,"
DEF bccoord EQUS "coord bc,"
DEF decoord EQUS "coord de,"
2017-12-14 05:36:24 +00:00
MACRO coord
2017-12-14 05:36:24 +00:00
; register, x, y[, origin]
if _NARG < 4
ld \1, (\3) * SCREEN_WIDTH + (\2) + wTilemap
2017-12-14 05:36:24 +00:00
else
ld \1, (\3) * SCREEN_WIDTH + (\2) + \4
endc
ENDM
DEF hlbgcoord EQUS "bgcoord hl,"
DEF bcbgcoord EQUS "bgcoord bc,"
DEF debgcoord EQUS "bgcoord de,"
MACRO bgcoord
; register, x, y[, origin]
if _NARG < 4
ld \1, (\3) * BG_MAP_WIDTH + (\2) + vBGMap0
else
ld \1, (\3) * BG_MAP_WIDTH + (\2) + \4
2017-12-14 05:36:24 +00:00
endc
2017-12-28 21:31:16 +00:00
ENDM
2017-12-14 05:36:24 +00:00
MACRO dwcoord
; x, y
rept _NARG / 2
dw (\2) * SCREEN_WIDTH + (\1) + wTilemap
shift 2
endr
2017-12-28 21:31:16 +00:00
ENDM
2017-12-14 05:36:24 +00:00
MACRO ldcoord_a
; x, y[, origin]
2017-12-14 05:36:24 +00:00
if _NARG < 3
ld [(\2) * SCREEN_WIDTH + (\1) + wTilemap], a
2017-12-14 05:36:24 +00:00
else
ld [(\2) * SCREEN_WIDTH + (\1) + \3], a
2017-12-14 05:36:24 +00:00
endc
2017-12-28 21:31:16 +00:00
ENDM
2017-12-14 05:36:24 +00:00
MACRO lda_coord
; x, y[, origin]
2017-12-14 05:36:24 +00:00
if _NARG < 3
ld a, [(\2) * SCREEN_WIDTH + (\1) + wTilemap]
else
ld a, [(\2) * SCREEN_WIDTH + (\1) + \3]
endc
2017-12-14 05:36:24 +00:00
ENDM
MACRO menu_coords
; x1, y1, x2, y2
db \2, \1 ; start coords
db \4, \3 ; end coords
ENDM