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

📄 ggi.cpp

📁 著名SFC模拟器Snes9x的源代码。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      case 'm':      case 'e':      case 's':		byte1 = 64;	break; // X      case ',':      case 'r':      case 'x':		byte2 = 64;	break; // Y      case 'v':      case 'q':      case 'a':		byte1 = 32;	break; // TL      case 'b':      case 'w':      case 'z':		byte1 = 16;	break; // TR      case GGI_KEY_P4:	byte4 = 1;	break;      case GGI_KEY_P6:	byte4 = 2;	break;      case GGI_KEY_P2:	byte4 = 4;	break;      case GGI_KEY_P8:	byte4 = 8;	break;	          case GGI_KEY_PENTER:	byte4 = 16;	break; // Start      case GGI_KEY_PPLUS:     byte4 = 32;	break; // Select      case GGI_KEY_PGUP:	byte3 = 128;	break; // A      case GGI_KEY_PGDN:	byte4 = 128;	break; // B      case GGI_KEY_HOME:	byte3 = 64;	break; // X      case GGI_KEY_END:	        byte4 = 64;	break; // Y      case GGI_KEY_INSERT:	byte3 = 32;	break; // TL      case GGI_KEY_DELETE:	byte3 = 16;	break; // TR      case 27:	S9xExit ();	break;      case '0':	if (ev.any.type == evKeyPress)	  Settings.DisableHDMA = !Settings.DisableHDMA;	break;      case '1':	if (ev.any.type == evKeyPress)	  PPU.BG_Forced ^= 1;	break;      case '2':	if (ev.any.type == evKeyPress)	  PPU.BG_Forced ^= 2;	break;      case '3':	if (ev.any.type == evKeyPress)	  PPU.BG_Forced ^= 4;	break;      case '4':	if (ev.any.type == evKeyPress)	  PPU.BG_Forced ^= 8;	break;      case '5':	if (ev.any.type == evKeyPress)	  PPU.BG_Forced ^= 16;	break;      case '6':	if (ev.any.type == evKeyPress)	  Settings.SwapJoypads = !Settings.SwapJoypads;	break;      case '9':	if (ev.any.type == evKeyPress)	  if (Settings.SixteenBit)	    Settings.Transparency = !Settings.Transparency;	break;      case '8':	if (ev.any.type == evKeyPress)	  Settings.BGLayering = !Settings.BGLayering;	break;      case '7':	if (ev.any.type == evKeyPress)	  S9xNextController ();	break;      case '-':	if (ev.any.type == evKeyPress) {	  if (Settings.SkipFrames <= 1)	    Settings.SkipFrames = AUTO_FRAMERATE;	  else	    if (Settings.SkipFrames != AUTO_FRAMERATE)	      Settings.SkipFrames--;	}	break;      case '=':      case '+':	if (ev.any.type == evKeyPress) {	  if (Settings.SkipFrames == AUTO_FRAMERATE)	    Settings.SkipFrames = 1;	  else	    if (Settings.SkipFrames < 10)	      Settings.SkipFrames++;	}	break;	      case GGI_KEY_BACKSPACE:	if (ev.any.type == evKeyPress) {	  Settings.DisableGraphicWindows = !Settings.DisableGraphicWindows;	}	break;	//case GGI_KEY_SCROLL_LOCK:      case GGI_KEY_BREAK:	if (ev.any.type == evKeyPress)	  Settings.Paused ^= 1;	break;      case GGI_KEY_TAB:	if (ev.any.type == evKeyPress)	  superscope_turbo = !superscope_turbo;	break;      case GGI_KEY_DGRAVE: /* XK_grave? what's this for key? (alex) */	superscope_pause = ev.any.type == evKeyPress;	break;      case GGI_KEY_F1:#ifdef DEBUGGER	if (ev.any.type == evKeyPress && (ev.key.effect & (1<<mkAlt)))	{	  CPU.Flags |= DEBUG_MODE_FLAG;	  break;	}#endif	// Fall...      case GGI_KEY_F2:	if (ev.any.type == evKeyPress && (ev.key.effect & (1<<mkAlt)))	{	  S9xLoadSnapshot (S9xChooseFilename (TRUE));	  break;	}	// Fall...      case GGI_KEY_F3:	if (ev.any.type == evKeyPress && (ev.key.effect & (1<<mkAlt)))	{	  Snapshot (S9xChooseFilename (FALSE));	  break;	}	// Fall...      case GGI_KEY_F4:      case GGI_KEY_F5:      case GGI_KEY_F6:      case GGI_KEY_F7:      case GGI_KEY_F8:      case GGI_KEY_F9:      case GGI_KEY_F10:      case GGI_KEY_F11:      case GGI_KEY_F12:	if (ev.any.type == evKeyPress)	{	  if (!(ev.key.effect & ((1<<mkShift) | (1<<mkAlt)))) {	    if (keysym == GGI_KEY_F11) {	      S9xLoadSnapshot (S9xChooseFilename (TRUE));	      break;	    }  else if (keysym == GGI_KEY_F12) {	      Snapshot (S9xChooseFilename (FALSE));	      break;	    }	    char def [PATH_MAX];	    char filename [PATH_MAX];	    char drive [_MAX_DRIVE];	    char dir [_MAX_DIR];	    char ext [_MAX_EXT];	    	    _splitpath (Memory.ROMFilename, drive, dir, def, ext);	    sprintf (filename, "%s%s%s.%03d",		     S9xGetSnapshotDirectory (), SLASH_STR, def,		     keysym - GGI_KEY_F1);	    S9xLoadSnapshot (filename);	  }  else	    if (ev.key.effect & (1<<mkAlt)) {	      if (keysym >= GGI_KEY_F4)		S9xToggleSoundChannel (keysym - GGI_KEY_F4);	    } else {	      char def [PATH_MAX];	      char filename [PATH_MAX];	      char drive [_MAX_DRIVE];	      char dir [_MAX_DIR];	      char ext [_MAX_EXT];	      	      _splitpath (Memory.ROMFilename, drive, dir, def, ext);	      sprintf (filename, "%s%s%s.%03d",		       S9xGetSnapshotDirectory (), SLASH_STR, def,		       keysym - GGI_KEY_F1);	      Snapshot (filename);	    }	}	break;      }      if (ev.any.type == evKeyPress) {	joypads [0] |= byte1;	joypads [0] |= (byte2 << 8);	joypads [1] |= byte3;	joypads [1] |= (byte4 << 8);      } else {	joypads [0] &= ~byte1;	joypads [0] &= ~(byte2 << 8);	joypads [1] &= ~byte3;	joypads [1] &= ~(byte4 << 8);      }      break;    case evPtrRelative:      mouse_x += ev.pmove.x;      mouse_y += ev.pmove.y;      break;    case evPtrAbsolute:      mouse_x = ev.pmove.x;      mouse_y = ev.pmove.y;      break;    case evPtrButtonPress:      mouse_buttons |= ev.pbutton.button;      break;    case evPtrButtonRelease:      mouse_buttons &= ~ev.pbutton.button;      break;    case evPtrState:      /* What kind of event do i get here? */      /* Check it up, should resynchronize if relative ptr maybe.. */      break;   default:      break;    }  }  while (ggiEventPoll(vis, emAll, &tv)!=0);}void S9xSetPalette (){  int i;  uint16 Brightness = (IPPU.MaxBrightness) * 140;  static ggi_color cmap[256];	      for (i = 0; i < 256; i++) {    cmap[i].r = ((PPU.CGDATA[i] >> 0) & 0x1F) * Brightness;    cmap[i].g = ((PPU.CGDATA[i] >> 5) & 0x1F) * Brightness;    cmap[i].b = ((PPU.CGDATA[i] >> 10) & 0x1F) * Brightness;  }  ggiSetPaletteVec(vis, 0, 256, cmap);  }const char *S9xSelectFilename (const char *def, const char *dir1,			    const char *ext1, const char *title){    static char path [PATH_MAX];    char buffer [PATH_MAX];        printf ("\n%s (default: %s): ", title, def);    fflush (stdout);    if (fgets (buffer, sizeof (buffer) - 1, stdin))    {	char *p = buffer;	while (isspace (*p))	    p++;	if (!*p)	{	    strcpy (buffer, def);	    p = buffer;	}	char *q = strrchr (p, '\n');	if (q)	    *q = 0;	char fname [PATH_MAX];	char drive [_MAX_DRIVE];	char dir [_MAX_DIR];	char ext [_MAX_EXT];	_splitpath (p, drive, dir, fname, ext);	_makepath (path, drive, *dir ? dir : dir1, fname, *ext ? ext : ext1);	return (path);    }    return (NULL);}void S9xTextMode (){}void S9xGraphicsMode (){}void S9xParseDisplayArg (char **, int &, int){    S9xUsage ();}void S9xExtraUsage (){}int S9xMinCommandLineArgs (){    return (2);}void S9xMessage (int type, int number, const char *message){    fprintf (stdout, "%s\n", message);}static void Convert16to8(int width, int height){  fprintf(stderr, "16 -> 8 bit conversion not implemented yet.\n");}static void Convert16to15(int width, int height){  for (register y = 0; y < SNES_HEIGHT_EXTENDED; y++) {    register uint16 *d = (uint16 *) ((uint8 *)plb->write + y * plb->stride);    register uint16 *s = (uint16 *) (GFX.Screen + y * GFX.RealPitch);        for (register x = 0; x < SNES_WIDTH; x++) {      register uint16 pixel = *s++;      *d++ = (pixel&0x1F) | ((pixel&0xFFC0)>>1);    }  }}static void Convert16to16(int width, int height){  for (register y = 0; y < SNES_HEIGHT_EXTENDED; y++) {    register uint16 *d = (uint16 *) ((uint8 *)plb->write + y * plb->stride);    register uint16 *s = (uint16 *) (GFX.Screen + y * GFX.RealPitch);        for (register x = 0; x < SNES_WIDTH; x++)      *d++ = *s++;  }}static void Convert16to24(int width, int height){  for (register y = 0; y < SNES_HEIGHT_EXTENDED; y++) {    register uint8 *d = (uint8 *) ((uint8 *)plb->write + y * plb->stride);    register uint16 *s = (uint16 *) (GFX.Screen + y * GFX.RealPitch);        for (register x = 0; x < SNES_WIDTH; x++) {      register uint32 pixel = *s++;            *d++ = (pixel & 0x1f) << 3;      *d++ = ((pixel >> 5) & 0x3f) << 2;      *d++ = ((pixel >> 11) & 0x1f) << 3;    }  }}static void Convert16to32(int width, int height){  for (register y = 0; y < SNES_HEIGHT_EXTENDED; y++) {    register uint32 *d = (uint32 *) ((uint8 *)plb->write + y * plb->stride);    register uint16 *s = (uint16 *) (GFX.Screen + y * GFX.RealPitch);        for (register x = 0; x < SNES_WIDTH; x++) {      register uint32 pixel = *s++;            *d++ = (((pixel & 0x1f) << 3) << 16) |	((((pixel >> 5) & 0x3f) << 2) << 8) |	((((pixel >> 11) & 0x1f) << 3) << 0);    }  }}static void Convert8to8(int width, int height){  for (register y = 0; y < SNES_HEIGHT_EXTENDED; y++) {    register uint8 *d = (uint8 *) ((uint8 *)plb->write + y * plb->stride);    register uint8 *s = (uint8 *) (GFX.Screen + y * GFX.RealPitch);        for (register x = 0; x < SNES_WIDTH; x++)      *d++ = *s++;  }}

⌨️ 快捷键说明

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