ApuResource *APU; 声明
#define APU_WRITEFUNC(name, evtype) \
void ApuWrite##name(WORD addr, BYTE value) \
{ \
ApuEventQueue[APU->cur_event].time = APU->entertime - CPU->g_wPassedClocks; \
ApuEventQueue[APU->cur_event].type = APUET_W_##evtype; \
ApuEventQueue[APU->cur_event].data = value; \
APU->cur_event++; \
}
APU_WRITEFUNC(C1a, C1A);
APU_WRITEFUNC(C1b, C1B);
APU_WRITEFUNC(C1c, C1C);
APU_WRITEFUNC(C1d, C1D);
APU_WRITEFUNC(C2a, C2A);
APU_WRITEFUNC(C2b, C2B);
APU_WRITEFUNC(C2c, C2C);
APU_WRITEFUNC(C2d, C2D);
APU_WRITEFUNC(C3a, C3A);
APU_WRITEFUNC(C3b, C3B);
APU_WRITEFUNC(C3c, C3C);
APU_WRITEFUNC(C3d, C3D);
APU_WRITEFUNC(C4a, C4A);
APU_WRITEFUNC(C4b, C4B);
APU_WRITEFUNC(C4c, C4C);
APU_WRITEFUNC(C4d, C4D);
APU_WRITEFUNC(C5a, C5A);
APU_WRITEFUNC(C5b, C5B);
APU_WRITEFUNC(C5c, C5C);
APU_WRITEFUNC(C5d, C5D);
APU_WRITEFUNC(Control, CTRL);
const ApuWritefunc pAPUSoundRegs[20] =
{
ApuWriteC1a,
ApuWriteC1b,
ApuWriteC1c,
ApuWriteC1d,
ApuWriteC2a,
ApuWriteC2b,
ApuWriteC2c,
ApuWriteC2d,
ApuWriteC3a,
ApuWriteC3b,
ApuWriteC3c,
ApuWriteC3d,
ApuWriteC4a,
ApuWriteC4b,
ApuWriteC4c,
ApuWriteC4d,
ApuWriteC5a,
ApuWriteC5b,
ApuWriteC5c,
ApuWriteC5d,
};
调用语句
pAPUSoundRegs[ wAddr & 0x1f ]( wAddr, byData );
结构体
typedef struct
{
int cur_event;
WORD entertime;
BYTE ApuCtrl;
}ApuResource;
typedef struct
{
long time;
BYTE type;
BYTE data;
}ApuEvent;
问题:这种结构的执行流程?在确定 wAddr & 0x1f的值后怎么展开单独调用
pAPUSoundRegs[ wAddr & 0x1f ]( wAddr, byData )改成xxxx( wAddr, byData )该怎么改?真心请教,谢谢
|