So.. what are the dynamics at play in this design? Speed and memory size? Is the routine going to be an automatic thing? As in, it only takes a rate argument for fade in/out? If so, does it have complete control of the main code until it's finished? Or is it a lighter process, that only does up to 64 sets of colors per call and is divided into prep and update functions, allowing game code to run at the same time (or at least same frame)? How much memory are you going to require (important for hucard projects)? Is the work buffer user defined and passed along as a pointer (so if can be reused for something else in the project)? Or is it an internal static defined size, that takes away from ram regardless?
Good questions!
Taking control of the system would be impolite.
The goal would be to provide function calls that the HuC user can use to provide fast alternatives to writing their own code.
For example ...
void __fastcall get_colors( int *pbuffer<__td> );
void __fastcall get_colors( int index<color_reg>, int *pbuffer<__td>, unsigned char count<__tl> );
void __fastcall set_colors( int *pbuffer<__ts> );
void __fastcall set_colors( int index<color_reg>, int *pbuffer<__ts>, unsigned char count<__tl> );
void __fastcall fade_colors( int *psource<__si>, int *pdestination<__di>, unsigned char count<__al>, unsigned char fade<acc> );
Those make up a simple set of functions that do everything that DK wanted in Catastrophy, and ended up writing in either slow C code, or fast inline-assembly.
They do it fast, and they keep things flexible enough that you can use as-much or as-little resources as you need.
The "get" and "set" functions use TAI & TIA instructions for fast processing.
"count" is limited to a maximum of 128 for fast indexing
"fade" is a value 0-7.
I *think* that's enough basic functionality for the end-user to build pretty much whatever they want.
Can you think of a better *practical* design?
I never really liked this trying to make one size fits all thing when designing libs/stuff for HuC. It'd be nice if it was something they directly included into the main source file (different small libs), than trying to attach it exiting library (in startup). Though I think doing that would require restructuring the main lib bank, and having support for bank directive directly in HuC.
Making the libraries modular would be great ... but it's going to take a significant time-investment from whoever wants to do it.
Since there's no linker phase and dead-code elimination, so from what I'm seeing, HuC is pretty-much a behemoth right now.
But ... there is some argument for providing common functionality within the library itself, especially since the code that HuC generates to do the same stuff if you do it in C (like DK did for catastrophy) is going to be much larger and slower than the same code hand-written in assembly.
I don't think this needs to be in the core of HuC. It would serve better as example code, which someone could work to their needs.
It's not like a "fade" routine is an uncommon requirement.
1) Your C code is big and slow, and generates a lot of Hu6280 code that a hand-written assembly function doesn't. That's not you ... that's just HuC.
2) Have you got a fade-up working, yet?