Move, comment, and simplify some macro definitions

This commit is contained in:
Rangi 2020-04-04 15:19:43 -04:00
parent 0ee9d7a48b
commit 3cdfac7994
6 changed files with 36 additions and 44 deletions

View File

@ -202,8 +202,7 @@ if !DEF(TM01)
TM01 EQU const_value
enum_start 1
endc
define _\@_1, "TM_\1"
const _\@_1
const TM_\1
enum \1_TMNUM
ENDM
@ -266,8 +265,7 @@ add_hm: MACRO
if !DEF(HM01)
HM01 EQU const_value
endc
define _\@_1, "HM_\1"
const _\@_1
const HM_\1
enum \1_TMNUM
ENDM

View File

@ -8,17 +8,6 @@ ln: MACRO ; r, hi, lo
ld \1, ((\2) & $f) << 4 | ((\3) & $f)
ENDM
ldpixel: MACRO
if _NARG >= 5
lb \1, \2 * 8 + \4, \3 * 8 + \5
else
lb \1, \2 * 8, \3 * 8
endc
ENDM
depixel EQUS "ldpixel de,"
bcpixel EQUS "ldpixel bc,"
; Design patterns
jumptable: MACRO

View File

@ -49,3 +49,9 @@ lda_coord: MACRO
ld a, [(\2) * SCREEN_WIDTH + (\1) + \3]
endc
ENDM
menu_coords: MACRO
; x1, y1, x2, y2
db \2, \1 ; start coords
db \4, \3 ; end coords
ENDM

View File

@ -82,27 +82,6 @@ dba_pic: MACRO ; dbw bank, address
dw \1
ENDM
dbpixel: MACRO
if _NARG >= 4
; x tile, x pxl, y tile, y pxl
db \1 * 8 + \3, \2 * 8 + \4
else
; x, y
db \1 * 8, \2 * 8
endc
ENDM
dsprite: MACRO
; y tile, y pxl, x tile, x pxl, vtile offset, attributes
db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5, \6
ENDM
menu_coords: MACRO
; x1, y1, x2, y2
db \2, \1 ; start coords
db \4, \3 ; end coords
ENDM
bcd: MACRO
rept _NARG
dn ((\1) % 100) / 10, (\1) % 10

View File

@ -41,11 +41,3 @@ shift_const: MACRO
\1 EQU (1 << const_value)
const_value = const_value + 1
ENDM
; Enumerate strings
define: MACRO
if !DEF(\1)
\1 EQUS \2
endc
ENDM

View File

@ -20,3 +20,31 @@ tile EQUS "+ LEN_2BPP_TILE *"
; example usage:
; INCBIN "foo.gbcpal", middle_colors
middle_colors EQUS "PAL_COLOR_SIZE, PAL_COLOR_SIZE * 2"
dbpixel: MACRO
if _NARG >= 4
; x tile, y tile, x pixel, y pixel
db \1 * TILE_WIDTH + \3, \2 * TILE_WIDTH + \4
else
; x tile, y tile
db \1 * TILE_WIDTH, \2 * TILE_WIDTH
endc
ENDM
ldpixel: MACRO
if _NARG >= 5
; register, x tile, y tile, x pixel, y pixel
lb \1, \2 * TILE_WIDTH + \4, \3 * TILE_WIDTH + \5
else
; register, x tile, y tile
lb \1, \2 * TILE_WIDTH, \3 * TILE_WIDTH
endc
ENDM
depixel EQUS "ldpixel de,"
bcpixel EQUS "ldpixel bc,"
dsprite: MACRO
; y tile, y pixel, x tile, x pixel, vtile offset, attributes
db (\1 * TILE_WIDTH) % $100 + \2, (\3 * TILE_WIDTH) % $100 + \4, \5, \6
ENDM