You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ISSOtm's structs.asm is a thing of beauty, but I'd like to have some of that functionality in the base language as well.
Syntax Proposal:
StructIdentifier: STRUCT starts a struct declaration with the name StructIdentifier.
fieldIdentifier SB number defines a field with a size of number bytes; number is 1 if omitted.
fieldIdentifier SW number defines a field with a size of number * 2 bytes; number is 1 if omitted.
fieldIdentifier SL number defines a field with a size of number * 4 bytes; number is 1 if omitted.
fieldIdentifier SSTRUCT StructIdentifier defines a matching field for each field in the struct named StructIdentifier, prefixed with fieldIdentifier.
ENDS ends the current struct declaration.
DSTRUCT StructIdentifier defines a padded label for each field in the struct named StructIdentifier, as if with DS.
NEW StructIdentifier starts a struct instantiation of the struct named StructIdentifier. Fields can be specified in any order but will be emitted in the order defined in the struct. If any fields are omitted, their value will be undefined. For each field instantiation, fieldIdentifier must exactly match an existing field in the struct, and the total size of the arguments must not exceed the size of the field.
fieldIdentifier SB arg0, arg1, argN defines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed to DB.
fieldIdentifier SW arg0, arg1, argN defines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed to DW.
fieldIdentifier SL arg0, arg1, argN defines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed to DL.
ENDN ends the current struct instantiation.
SIZEOF(StructIdentifier) returns the total size of the struct named StructIdentifier in bytes.
Example:
Character: STRUCT
name SB 8
xPosition SW
yPosition SW
spriteAddresses SW 4
somethingLong SL
ENDS
Section "RAM", wram0
wPlayerCharacter: DSTRUCT Character
; if we wanted to reserve the space but not define the field labels:
wPlayerBuffer: DS SIZEOF(Character)
Section "ROM", rom0
SlimeMonster: NEW Character
name SB "Slime", 0
spriteAddresses SW SlimeSprite0, SlimeSprite1, SlimeSprite2, SlimeSprite3
xPosition SB $F0, $40
yPosition SW $3A1F
ENDN
The text was updated successfully, but these errors were encountered:
ISSOtm's structs.asm is a thing of beauty, but I'd like to have some of that functionality in the base language as well.
Syntax Proposal:
StructIdentifier: STRUCT
starts a struct declaration with the name StructIdentifier.fieldIdentifier SB number
defines a field with a size of number bytes; number is 1 if omitted.fieldIdentifier SW number
defines a field with a size of number * 2 bytes; number is 1 if omitted.fieldIdentifier SL number
defines a field with a size of number * 4 bytes; number is 1 if omitted.fieldIdentifier SSTRUCT StructIdentifier
defines a matching field for each field in the struct named StructIdentifier, prefixed with fieldIdentifier.ENDS
ends the current struct declaration.DSTRUCT StructIdentifier
defines a padded label for each field in the struct named StructIdentifier, as if withDS
.NEW StructIdentifier
starts a struct instantiation of the struct named StructIdentifier. Fields can be specified in any order but will be emitted in the order defined in the struct. If any fields are omitted, their value will be undefined. For each field instantiation, fieldIdentifier must exactly match an existing field in the struct, and the total size of the arguments must not exceed the size of the field.fieldIdentifier SB arg0, arg1, argN
defines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed toDB
.fieldIdentifier SW arg0, arg1, argN
defines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed toDW
.fieldIdentifier SL arg0, arg1, argN
defines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed toDL
.ENDN
ends the current struct instantiation.SIZEOF(StructIdentifier)
returns the total size of the struct named StructIdentifier in bytes.Example:
The text was updated successfully, but these errors were encountered: