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

📄 guifuncs.c

📁 linux下的任天堂模拟器代码。供大家参考。
💻 C
📖 第 1 页 / 共 5 页
字号:
}unsigned char gui_key;unsigned char gui_key_extended;int GUILoadKeysNavigate(){#ifdef __UNIXSDL__  extern unsigned int numlockptr;#endif  int *currentviewloc, *currentcursloc, *entries;  if (GUIcurrentfilewin == 1)  {    currentviewloc = &GUIcurrentdirviewloc;    currentcursloc = &GUIcurrentdircursloc;    entries = &GUIdirentries;  }  else  {    currentviewloc = &GUIcurrentviewloc;    currentcursloc = &GUIcurrentcursloc;    entries = &GUIfileentries;  }  //Handle left and right  if(GUIfileentries && GUIdirentries)  {    #ifdef __UNIXSDL__    if ((gui_key_extended == 92) || ((numlockptr != 1) && (gui_key_extended == 75)))    #else    if (gui_key_extended == 75)    #endif    {      GUILoadPos = 0;      GUIcurrentfilewin ^= 1;      return(1);    }    #ifdef __UNIXSDL__    if ((gui_key_extended == 94) || ((numlockptr != 1) && (gui_key_extended == 77)))    #else    if(gui_key_extended == 77)    #endif    {      GUILoadPos = 0;      GUIcurrentfilewin ^= 1;      return(1);    }  }  //Enter press  if (gui_key_extended == 13)  {    GUILoadPos = 0;    GUILoadManualDir();    return(1);  }  //Home key  #ifdef __UNIXSDL__  if ((gui_key_extended == 89)||((numlockptr != 1) && (gui_key_extended == 71)))  #else  if (gui_key_extended == 71)  #endif  {    GUILoadPos = 0;    *currentcursloc = 0;    *currentviewloc = 0;    return(1);  }  //End key  #ifdef __UNIXSDL__  if ((gui_key_extended == 95)||((numlockptr != 1) && (gui_key_extended == 79)))  #else  if (gui_key_extended == 79)  #endif  {    GUILoadPos = 0;    *currentcursloc = (*entries)-1;    *currentviewloc = (*entries)-15;    if (*currentviewloc < 0)    {      *currentviewloc = 0;    }    return(1);  }  //Up arrow key  #ifdef __UNIXSDL__  if ((gui_key_extended == 90)||((numlockptr != 1) && (gui_key_extended == 72)))  #else  if (gui_key_extended == 72)  #endif  {    GUILoadPos = 0;    if (*currentcursloc)    {      if (*currentviewloc == *currentcursloc)      {        (*currentviewloc)--;      }      (*currentcursloc)--;    }    return(1);  }  //Down arrow key  #ifdef __UNIXSDL__  if ((gui_key_extended == 96)||((numlockptr != 1) && (gui_key_extended == 80)))  #else  if (gui_key_extended == 80)  #endif  {    GUILoadPos = 0;    if ((*currentcursloc)+1 != *entries)    {      (*currentcursloc)++;      if ((*currentcursloc)-15 == *currentviewloc)      {        (*currentviewloc)++;      }    }    return(1);  }  //Page up key  #ifdef __UNIXSDL__  if ((gui_key_extended == 91)||((numlockptr != 1) && (gui_key_extended == 73)))  #else  if (gui_key_extended == 73)  #endif  {    GUILoadPos = 0;    *currentviewloc -= 15;    *currentcursloc -= 15;    if (*currentviewloc < 0)    {      *currentviewloc = 0;    }    if (*currentcursloc < 0)    {      *currentcursloc = 0;    }    return(1);  }  //Page down key  #ifdef __UNIXSDL__  if ((gui_key_extended == 97)||((numlockptr != 1) && (gui_key_extended == 81)))  #else  if (gui_key_extended == 81)  #endif  {    GUILoadPos = 0;    *currentviewloc += 15;    *currentcursloc += 15;    if (*currentcursloc >= (*entries)-1)    {      *currentcursloc = (*entries)-1;    }    if (*currentviewloc >= (*entries)-15)    {      *currentviewloc = ((*entries)-15)>0 ? (*entries)-15 : 0;    }   return(1);  }  return(0);}#ifdef __UNIXSDL__#define DriveCount() 0#elsestatic unsigned int DriveCount(){  unsigned int drives = GetLogicalDrives(), count = 0, i = 0;  while (i < 26)  {    if (drives&BIT(i))    {      count++;    }    i++;  }  return(count);}#endifint *GUIJT_currentviewloc, *GUIJT_currentcursloc, GUIJT_entries, GUIJT_offset, GUIJT_viewable;void GUIGenericJumpTo(){  int mid = GUIJT_viewable>>1;  *GUIJT_currentviewloc = (GUIJT_offset < GUIJT_entries-mid) ? GUIJT_offset-mid : GUIJT_entries-GUIJT_viewable;  if (*GUIJT_currentviewloc < 0) { *GUIJT_currentviewloc = 0; }  *GUIJT_currentcursloc = GUIJT_offset;}void GUILoadKeysJumpTo(){  char **base;  int start, end;  GUILoadTextA[GUILoadPos] = 0;  if (GUIcurrentfilewin == 1)  {    GUIJT_currentviewloc = &GUIcurrentdirviewloc;    GUIJT_currentcursloc = &GUIcurrentdircursloc;    GUIJT_entries = GUIdirentries;    base = d_names+2;    if (!strcmp(*base, ".."))    {      base++;      GUIJT_entries--;    }    GUIJT_entries -= DriveCount();  }  else  {    GUIJT_currentviewloc = &GUIcurrentviewloc;    GUIJT_currentcursloc = &GUIcurrentcursloc;    GUIJT_entries = GUIfileentries;    base = selected_names;  }  start = 0;  end = GUIJT_entries-1;  GUIJT_offset = GUIJT_entries;  if (!strcmp(GUILoadTextA, " ")) //Exactly a space picks a game randomely  {    GUIJT_offset = rand()%GUIJT_entries;  }  else  {    while (start <= end)    {      int mid = (start+end)>>1;      int pos = strncasecmp(base[mid], GUILoadTextA, GUILoadPos);      if (!pos)      {        do        {          GUIJT_offset = mid--;        } while ((mid >= 0) && !strncasecmp(base[mid], GUILoadTextA, GUILoadPos));        break;      }      if (pos > 0)      {        end = mid-1;      }      else      {        start = mid+1;      }    }  }  if (GUIJT_offset < GUIJT_entries)  {    if (GUIcurrentfilewin == 1)    {      GUIJT_entries += DriveCount();      if (base > d_names+2)      {        GUIJT_offset++;        GUIJT_entries++;      }    }    GUIJT_viewable = 15;    GUIGenericJumpTo();  }}//Not entirely accurate pow, but good for most needs and very faststatic unsigned int npow(register unsigned int base, register unsigned int exponent){  register unsigned int total = 1;  if (exponent)  {    register unsigned int i;    for (i = 2, total = base; i < exponent; i += i)    {      total *= total;    }    for (i >>= 1; i < exponent; i++)    {      total *= base;    }  }  return(total);}static void int_to_str(char *dest, unsigned int len, unsigned int num){  *dest = 0;  if (len && (num < npow(10, len)))  {    int i;    for (i = 1; num; i++)    {      memmove(dest+1, dest, i);      *dest = (num%10)+'0';      num /= 10;    }  }}#ifndef __MSDOS__char GUICustomX[5], GUICustomY[5];void GetCustomXY(){  static bool first_time = true;  if (first_time)  {    int_to_str(GUICustomX, 4, CustomResX);    int_to_str(GUICustomY, 4, CustomResY);    first_time = false;  }}void SetCustomXY(){  if(!((atoi(GUICustomX) < 256) || (atoi(GUICustomX) > 2048) || (atoi(GUICustomY) < 224) || (atoi(GUICustomY) > 1536)))  {    CustomResX = atoi(GUICustomX);    CustomResY = atoi(GUICustomY);    if(CustomResX < 298)      Keep4_3Ratio = 0;  }}extern char ShowKeep43;void Keep43Check(){  if((CustomResX*3) == (CustomResY*4))    ShowKeep43 = 0;  else    ShowKeep43 = 1;}#endifextern unsigned int MovieForcedLength;char GUIMovieForcedText[11];void GetMovieForcedLength(){  static bool first_time = true;  if (first_time)  {    int_to_str(GUIMovieForcedText, 10, MovieForcedLength);    first_time = false;  }}void SetMovieForcedLength(){  MovieForcedLength = atoi(GUIMovieForcedText);}

⌨️ 快捷键说明

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