I thought about a music engine where commands read from music data are rather idexes in a pointer-to-subroutines table ( no, I know there's no indirect jsr, but using this technique will just do the job ). Of course using 8-bit indexes will limit the number of pointers to 128, yet it's a lot. There is alway the possibility to reduce the number of possible pointers and use upper bits of this index as special flags (note on/off, portamento on/off ?? anyway), and using table of commands for each group of channels, and maybe for te ease of the programmer, using a routine like this:
... so the table looks like this:
Index 0 would be prohibited, so that could be used for a special command instead... I lke the idea here, because there will be not a lot of branches, so the routine will be faster than a regular one if using lot of different commands, but selecting the command will cause a bit of overhead of course... expanding it is easy, too, as you have to update the table and add a routine, and for switch channels, you just have to prepare the pointer in routine(s) that specify how much NMI to wait before fetching other commands...
What do you think? Will this technique be efficient?
Am I stupid?
Code:
select_command:
asl
tay
dey
lda (PTR_COMMAND_TABLE),y
pha
dey
lda (PTR_COMMAND_TABLE),y
pha
rts
asl
tay
dey
lda (PTR_COMMAND_TABLE),y
pha
dey
lda (PTR_COMMAND_TABLE),y
pha
rts
... so the table looks like this:
Code:
.dw routine1-1, routine2-1, routine3-1, etc
Index 0 would be prohibited, so that could be used for a special command instead... I lke the idea here, because there will be not a lot of branches, so the routine will be faster than a regular one if using lot of different commands, but selecting the command will cause a bit of overhead of course... expanding it is easy, too, as you have to update the table and add a routine, and for switch channels, you just have to prepare the pointer in routine(s) that specify how much NMI to wait before fetching other commands...
What do you think? Will this technique be efficient?
Am I stupid?