#include #include #include "action.h" extern void VSfunc( void ); volatile long VScnt=0; volatile u_char *bb0,*bb1; volatile short pad1[60],pad2[60]; volatile short *P1ptr,*P2ptr; /*---------------------------------------------------------------------- マクロ ----------------------------------------------------------------------*/ /* 基本設定 */ #define OT_LENGTH 1 /* オーダリングテーブルの数 */ #define MAXOBJ 600 /* スプライト(ボール)数の上限 */ /* 表示領域関連マクロ */ #define FRAME_X 320 /* 表示領域サイズ(横) */ #define FRAME_Y 240 /* 表示領域サイズ(縦) */ #define WALL_X (FRAME_X-16) /* ボールパタン可動領域サイズ(横) */ #define WALL_Y (FRAME_Y-16) /* ボールパタン可動領域サイズ(縦) */ /* 範囲チェックマクロ */ #define limitRange(x, l, h) ((x)=((x)<(l)?(l):(x)>(h)?(h):(x))) /* オーダリングテーブル関連変数 */ GsOT WorldOT[2]; GsOT_TAG OTTags[2][1<attribute = 0x00000000; sp->x = 0; sp->y = 0; sp->w = 16; sp->h = 16; sp->tpage = tpage; sp->u = 0; sp->v = 0; sp->cx = 0; sp->cy = 480+(i%32); sp->r = sp->g = sp->b = 0x80; sp->mx = 0; sp->my = 0; sp->scalex = ONE; sp->scaley = ONE; sp->rotate = 0; } } /*---------------------------------------------------------------------- このへんがタスク(笑) ----------------------------------------------------------------------*/ void testfunc0( void ){ GsSortFastSprite(&sprt[0], &WorldOT[activeBuff], 0); } void testfunc1( void ){ sprt[1].x += 2; if ( sprt[1].x > 300 ) sprt[1].x = 0; GsSortFastSprite(&sprt[1], &WorldOT[activeBuff], 0); } /*---------------------------------------------------------------------- めいん ----------------------------------------------------------------------*/ void main( void ){ GsOT *ot; /* 描画対象OTへのポインタ */ int i, cnt, x, y; /* 作業変数 */ GetPadBuf( &bb0,&bb1); P1ptr = pad1; P2ptr = pad2; VSyncCallback( VSfunc ); ExitCriticalSection(); GsInitGraph(320, 240, 4, 0, 0); /* 描画・表示環境の設定 */ GsDefDispBuff(0, 0, 0, 240); /* 同上 */ /* オーダリングテーブル情報の設定 */ for (i = 0; i < 2; i++) { WorldOT[i].length = OT_LENGTH; WorldOT[i].org = OTTags[i]; } init_prim(); InitAct(); SetAction( testfunc0, &ChrWork[0] ); SetAction( testfunc1, &ChrWork[1] ); /* ダブルバッファの切り替え */ activeBuff = GsGetActiveBuff(); GsSetWorkBase((PACKET *)GpuPacketArea[activeBuff]); while( VScnt < 600 ) { // printf( "%d,%x\r", (short)VScnt,(short)*P1ptr ); /* オーダリングテーブルのクリア */ GsClearOt(0, 0, &WorldOT[activeBuff]); GoAction(); /* 画面クリアプリミティブのオーダリングテーブルへの登録 */ GsSortClear(0, 0, 0, &WorldOT[activeBuff]); /* OTに登録されたプリミティブの描画開始 */ GsDrawOt(&WorldOT[activeBuff]); VSync(0); /* GPU Timeout防止(爆笑) */ } EnterCriticalSection(); VSyncCallback( NULL ); }