I'm writing a SNES program using wla-dx
(wla-65816
specifically), and I'm including some binary data in the ROM:
data: .INCBIN "datafile.bin"
I can get the size of this data using _sizeof_data
, which can be used in e.g. macro arguments. However, I'm having trouble reserving a region of RAM with the same size as this. Perhaps this is because of the clunky way I've fond to reserve longer ram sections. For a known-in-advance size, I currently do something like:
; This struct is used as a workaround for me not finding a way
; to indicate how big a ram section should be
.STRUCT array
dummy: db
.ENDST
.RAMSECTION "Work" SLOT 1 ORG $100 SEMIFREE
work_data instanceof array size $1000
.ENDS
This works, but it appears a variable size is not accepted for the size argument here. Replacing $1000
with _sizeof_data
, I get DIRECTIVE_ERROR: Unexpected symbol "_sizeof_data" in .RAMSECTION.
What is the right way to do this? I could just hardcode a size, but I don't think what I'm doing here should be unusual. There's probably a better way to do this that I'm not seeing.
I found it after spending some more time trawling through the manual.
Firstly, the size hack with the struct can be avoided by using ds [size]
. For the fixed-size example above, that would be
.RAMSECTION "Work" SLOT 1 ORG $100 SEMIFREE
work_data ds $1000
.ENDS
Secondly, use FSIZE
with .INCBIN
to get the size. The result can be used with ds
. Perhaps the _sizeof_
stuff never worked - at least it doesn't work with ds
. So one would do: data: .INCBIN "datafile.bin" FSIZE data_size
, and then work_data ds data_size
.