400h bytes transfer loop?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: 400h bytes transfer loop?

Post by tepples » Sun Sep 11, 2016 4:43 am

In [url=http://forums.nesdev.com/viewtopic.php?p=179341#p179341]this post[/url], rainwarrior wrote:Striped tables are really good for things like looking up a 16 bit value (e.g. pointer tables, jump tables), where the table is in a fixed location. There's little drawback in cases like that, especially if you have a tool that makes them convenient. I wish ca65 had such a feature, and I sometimes use macros to work around this. I think it's cool that you added it to your own assembler.
I can think of how I might make this sort of thing in a preprocessor written in Python. Would that be a good idea to add to my list of things to make for the community once The Curse of Possum Hollow wraps?

zzo38
Posts: 1050
Joined: Mon Feb 07, 2011 12:46 pm

Re: 400h bytes transfer loop?

Post by zzo38 » Sun Sep 11, 2016 11:25 am

rainwarrior wrote:Striped tables are really good for things like looking up a 16 bit value (e.g. pointer tables, jump tables), where the table is in a fixed location. There's little drawback in cases like that, especially if you have a tool that makes them convenient. I wish ca65 had such a feature, and I sometimes use macros to work around this. I think it's cool that you added it to your own assembler.
That is true, and is what I mainly used striped tables for; it is for 16-bit values and not for nametables. You are correct and it is really much better for such thing as pointer tables and jump tables. (Example of Unofficial-MagicKit macro which does this are available on wiki.)
tepples wrote:I can think of how I might make this sort of thing in a preprocessor written in Python. Would that be a good idea to add to my list of things to make for the community once The Curse of Possum Hollow wraps?
I suppose it might help those who use ca65. I think this is a good idea, but since I do not use ca65 perhaps see what others say.

(I myself prefer JavaScript as scripting language of choice, but that is just my opinion and you can use Python if you prefer to.)
[url=gopher://zzo38computer.org/].[/url]

User avatar
gauauu
Posts: 660
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: 400h bytes transfer loop?

Post by gauauu » Thu Sep 15, 2016 10:44 am

tepples wrote:
In [url=http://forums.nesdev.com/viewtopic.php?p=179341#p179341]this post[/url], rainwarrior wrote: I wish ca65 had such a feature, and I sometimes use macros to work around this. I think it's cool that you added it to your own assembler.
I can think of how I might make this sort of thing in a preprocessor written in Python. Would that be a good idea to add to my list of things to make for the community once The Curse of Possum Hollow wraps?
Yes please. Better tooling helps everyone, and this would be a welcome improvement.

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: 400h bytes transfer loop?

Post by tepples » Thu Sep 15, 2016 11:55 am

zzo38 wrote:
tepples wrote:I can think of how I might make [a striped table generator] in a preprocessor written in Python. Would that be a good idea to add to my list of things to make for the community once The Curse of Possum Hollow wraps?
I suppose it might help those who use ca65. I think this is a good idea, but since I do not use ca65 perhaps see what others say.
I can make it general enough to cover NESASM, ASM6, and ca65. It needs only whatever operators go in the definition of each table entry.

Our Python vs. JavaScript debate is in another castle.

User avatar
NovaSquirrel
Posts: 374
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: 400h bytes transfer loop?

Post by NovaSquirrel » Fri Sep 16, 2016 6:37 pm

I wrote a striped table generator in C for my game but it's not very user friendly and instead of being a preprocessor it just generates a file to .include (and automatically creates an enum if you ask it to, because it's meant for metatile information and similar tables rather than small 16-bit value tables).

Would it be useful to make a more general purpose version of this tool? With what syntax and features?

User avatar
rainwarrior
Posts: 7680
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: 400h bytes transfer loop?

Post by rainwarrior » Fri Sep 16, 2016 11:03 pm

Myself I'm not particularly interested in any external tools to do it (they are trivial to make); I was just musing that it would nice if it were a language feature rather than something you had to set up externally.

After poking around in the ca65 source and documentation a bit, I noticed there does exist a semi-reasonable method for generating striped tables:

Code: Select all

; 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
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).

I find this useful, so I'm going to start a new thread about it instead of trying to discuss it further here:
https://forums.nesdev.com/viewtopic.php?f=2&t=14838

Post Reply