Skip to content

Commit 99551ea

Browse files
committed
Add new array define
1 parent f99fff1 commit 99551ea

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

structs.asm

+19-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ENDM
4747
; Call with the expected version string to ensure you're using a compatible version
4848
; Example: rgbds_structs_version 1.0.0
4949
rgbds_structs_version: MACRO
50-
CURRENT_VERSION equs "1,1,0"
50+
CURRENT_VERSION equs "1,2,0"
5151
EXPECTED_VERSION equs "\1"
5252
strreplace EXPECTED_VERSION, ".", "\,"
5353
check_ver: MACRO
@@ -233,3 +233,21 @@ sizeof_\2 = sizeof_\1
233233
PURGE VAR_NAME
234234
PURGE FIELD_ID
235235
ENDM
236+
237+
238+
; dstructs struct_type, var_name
239+
; Allocates space for an array of structs in memory
240+
; Each struct will have the index appended to its name **as hex**
241+
; (for example: `dstructs 32, NPC, wNPC` will define wNPC0, wNPC1, and so on until wNPC1F)
242+
; This is a limitation because RGBASM does not provide an easy way to get the decimal representation of a number
243+
; Does not support data declarations because I think each struct should be defined individually for that purpose
244+
dstructs: MACRO
245+
STRUCT_ID = 0
246+
REPT \1
247+
STRUCT_DEF equs STRCAT("dstruct \2, \3", STRSUB("{STRUCT_ID}", 2, STRLEN("{STRUCT_ID}") - 1))
248+
STRUCT_DEF
249+
PURGE STRUCT_DEF
250+
STRUCT_ID = STRUCT_ID + 1
251+
ENDR
252+
PURGE STRUCT_ID
253+
ENDM

0 commit comments

Comments
 (0)