Dear LynxFan:
Thank you for your comment.
Sorry, this sound-driver doesn't have the satisfactory performance to play them(Dragon Spirit & Valkyre NO DENSETSU).
But, I made this for the substitute.
Enjoy!
一応、英検3級なんだが・・・(笑)
cc65
BLL 内蔵の cc65 は、関数ポインタに対応していないらしい。
static char g_now_func;
static void (*func_table[])() = {
Func00,
Func01,
Func02,
};void foo()
{
void (*func)();g_now_func = 0; /* 0,1 or 2 */
func = *func_table[g_now_func];
func();
}void Func00()
{
}
void Func01()
{
}
void Func02()
{
}
↑本当はこんなことをしたかったのだが、止むを得ず、アセンブラで再現することにする。6502 は、参照サブルーチンコール命令が存在しないため、リターンアドレスを無理矢理ポインタに積んで、参照ジャンプすることで再現する。
static char g_now_func;
#asm
func_table:
dc.w _Func00
dc.w _Func01
dc.w _Func02
#endasmvoid foo()
{
g_now_func = 0; /* 0,1 or 2 */#asm
pha
phxldax #return_addr
phx ; サブルーチンから戻るアドレスをスタックへ
pha ;
lda _g_now_proc
asl A
tax
ldy #0 ; 引数がない関数を呼ぶために必要
jmp (func_table,x)return_addr:
plx
pla#endasm
}
void Func00()
{
}
void Func01()
{
}
void Func02()
{
}