From 3cdfac7994f501cb1d8fbcdf9c64e9ce258afe30 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 4 Apr 2020 15:19:43 -0400 Subject: [PATCH] Move, comment, and simplify some macro definitions --- constants/item_constants.asm | 6 ++---- macros/code.asm | 11 ----------- macros/coords.asm | 6 ++++++ macros/data.asm | 21 --------------------- macros/enum.asm | 8 -------- macros/gfx.asm | 28 ++++++++++++++++++++++++++++ 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/constants/item_constants.asm b/constants/item_constants.asm index 06ad1dc14..98493a5a0 100644 --- a/constants/item_constants.asm +++ b/constants/item_constants.asm @@ -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 diff --git a/macros/code.asm b/macros/code.asm index 9429884ca..58d39aa00 100644 --- a/macros/code.asm +++ b/macros/code.asm @@ -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 diff --git a/macros/coords.asm b/macros/coords.asm index 3ea6e4154..5a87e1d3d 100644 --- a/macros/coords.asm +++ b/macros/coords.asm @@ -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 diff --git a/macros/data.asm b/macros/data.asm index 009683213..e9052f6b2 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -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 diff --git a/macros/enum.asm b/macros/enum.asm index 41d1da167..8fe5b5343 100644 --- a/macros/enum.asm +++ b/macros/enum.asm @@ -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 diff --git a/macros/gfx.asm b/macros/gfx.asm index 24c79e1f1..e9851501a 100644 --- a/macros/gfx.asm +++ b/macros/gfx.asm @@ -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