⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 uCos-II 打字练习游戏 源代码, 欢迎各位进行二次开发
💻 C
📖 第 1 页 / 共 2 页
字号:
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y6
#undef tx
#define tx 10
#undef tchar
#define tchar *(str+5)
void  task7 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y7
#undef tx
#define tx 12
#undef tchar
#define tchar *(str+6)
void  task8 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y8
#undef tx
#define tx 14
#undef tchar
#define tchar *(str+7)
void  task9 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y9
#undef tx
#define tx 16
#undef tchar
#define tchar *(str+8)
void  task10 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y10
#undef tx
#define tx 18
#undef tchar
#define tchar *(str+9)
void  task11 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y11
#undef tx
#define tx 20
#undef tchar
#define tchar *(str+10)
void  task12 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
#undef ty
#define ty y12
#undef tx
#define tx 22
#undef tchar
#define tchar *(str+11)
void  task13 (void *data)
{
#if OS_CRITICAL_METHOD == 3
    OS_CPU_SR  cpu_sr;
#endif
    data = data;
    OS_ENTER_CRITICAL();
    PC_VectSet(0×08,OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);
    OS_EXIT_CRITICAL();
    OSStatInit();
    for (;;)
    {
             
              PC_DispChar(taskx+tx,ty,tchar,tcolor);
              if (ty==tasky) PC_DispChar(taskx+tx,endy,’ ‘,tcolor);
              else PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
              ty++;
              if (ty==endy+1) {ty=tasky;err++;}
              OSTimeDlyHMSM(0,0,0,100);
              if ((char)key==tchar+32||(char)key==tchar)
              {
                    if (ty!=tasky) PC_DispChar(taskx+tx,ty-1,’ ‘,tcolor);
                    ty=tasky;right++;
                    tchar=random(26)+’A';
              }
    }
}
void task14(void *data)
{
    data=data;
    PC_DispStr(showx1,showy,”Right:00000″,tcolor);
    PC_DispStr(showx2,showy,”Error:00000″,tcolor);
    for(;;)
    {
        showint(showx1+6,showy,right);
        showint(showx2+6,showy,err);
    }
}
void write(char *mat,int x,int y)
{
  int i,j,k,n;
  n=(16-1)/8+1;
  for(j=0;j<16;j++)
    for(i=0;i<n;i++)
      for(k=0;k<8;k++)
        if(mat[j*n+i]&(0×80>>k))  /*测试为1的位则显示*/
          {PC_DispChar((x+i*8+k)+1,y+j,’*',tcolor);}
}
void showint(int x,int y,unsigned int num)
{
    int tmp=x+4; 
    int p;
    do
    {
        p=num%10;
        num/=10;
        PC_DispChar(tmp,y,(char)(p+’0′),tcolor);
        tmp–;
    }while(num!=0);
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -