A discussion began in another thread (link) discussing how it's useful to break up tables into stripes; i.e. instead of a table of 16-bit values, create 2 tables of 8-bit values, so you don't have to multiply your index by 2, etc.
zzo38 mentioned that he'd implemented it in his Unofficial-MagicKit assembler, and I lamented that it wasn't doable in ca65. However, after digging around in the documentation and/or source code, I have noticed a somewhat reasonable method for doing this in ca65, and I thought I'd share it here in a new thread rather than leave it buried in the other thread (link).
Here's what it looks like:
Maybe the line continuations with a define isn't the prettiest look, but it does seem to do the job. Labels or other expressions seem just as good as literals, too, and there doesn't seem to be any inherent size limit on the number of entries (the .define is stored as a linked list of tokens). You can put multiple expressions on a line if desired (the whole .define is being treated as if it were one long line).
zzo38 mentioned that he'd implemented it in his Unofficial-MagicKit assembler, and I lamented that it wasn't doable in ca65. However, after digging around in the documentation and/or source code, I have noticed a somewhat reasonable method for doing this in ca65, and I thought I'd share it here in a new thread rather than leave it buried in the other thread (link).
Here's what it looks like:
Code:
; allow line continuation feature
.linecont +
; create the table as a multi-line define
.define MyTable \
$1234, \
$5678, \
$9ABC
; emit the striped tables
mytable_lo: .lobytes MyTable
mytable_hi: .hibytes MyTable
.linecont +
; create the table as a multi-line define
.define MyTable \
$1234, \
$5678, \
$9ABC
; emit the striped tables
mytable_lo: .lobytes MyTable
mytable_hi: .hibytes MyTable
Maybe the line continuations with a define isn't the prettiest look, but it does seem to do the job. Labels or other expressions seem just as good as literals, too, and there doesn't seem to be any inherent size limit on the number of entries (the .define is stored as a linked list of tokens). You can put multiple expressions on a line if desired (the whole .define is being treated as if it were one long line).