Browse Source

Declare items with macros

master
Forest Belton 3 years ago
parent
commit
05293d7392
2 changed files with 29 additions and 0 deletions
  1. BIN
      png/sprite/item/coin.png
  2. +29
    -0
      src/item.s

BIN
png/sprite/item/coin.png View File

Before After
Width: 8  |  Height: 8  |  Size: 228 B

+ 29
- 0
src/item.s View File

@ -0,0 +1,29 @@
DEF NEXT_ITEM_ID SET 1
; Declare a new item
; \1 Display name
; \2 Sprite data filename
MACRO Item
ASSERT STRLEN("\1") < 16
; Define item ID symbol
DEF ID_NAME EQUS "\1_ID"
DEF {ID_NAME} EQU NEXT_ITEM_ID
EXPORT {ID_NAME}
REDEF NEXT_ITEM_ID SET NEXT_ITEM_ID + 1
; Display name
DB "\1"
REPT 16 - STRLEN("\1")
DB 0
ENDR
; Sprite data
INCBIN \2
ENDM
SECTION "Item Data", ROM0
; NOTE: Macro invocation MUST be indented in order to be expanded correctly
Items::
Item COIN, "png/sprite/item/coin.2bpp"

Loading…
Cancel
Save