-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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: STRUCTstarts a struct declaration with the name StructIdentifier.fieldIdentifier SB numberdefines a field with a size of number bytes; number is 1 if omitted.fieldIdentifier SW numberdefines a field with a size of number * 2 bytes; number is 1 if omitted.fieldIdentifier SL numberdefines a field with a size of number * 4 bytes; number is 1 if omitted.
fieldIdentifier SSTRUCT StructIdentifierdefines a matching field for each field in the struct named StructIdentifier, prefixed with fieldIdentifier.ENDSends the current struct declaration.DSTRUCT StructIdentifierdefines a padded label for each field in the struct named StructIdentifier, as if withDS.NEW StructIdentifierstarts 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, argNdefines 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, argNdefines 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, argNdefines a label named fieldIdentifier and prefixed with the current label whose contents are equal to the provided arguments, as if they were passed toDL.
ENDNends 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request