コード例 #1
0
// Call this function from the game thread
void LogDebugger_Draw(MDFN_Surface *surface, const MDFN_Rect *rect, const MDFN_Rect *screen_rect)
{
 if(!IsActive)
  return;

 //
 //
 //
 const MDFN_PixelFormat pf_cache = surface->format;
 const uint32 lifecolors[4] = {	 pf_cache.MakeColor(0xe0, 0xd0, 0xd0, 0xFF), pf_cache.MakeColor(0xd0, 0xe0, 0xd0, 0xFF),
				 pf_cache.MakeColor(0xd0, 0xd0, 0xEF, 0xFF), pf_cache.MakeColor(0xd4, 0xd4, 0xd4, 0xFF) };
 int32 y = 0;
 char logmessage[256];
 
 trio_snprintf(logmessage, sizeof(logmessage), "%s (%d messages)", LoggingActive ? "Logging Enabled" : "Logging Disabled", (int)WhichLog->entries.size());
 DrawText(surface, 0, y, logmessage, pf_cache.MakeColor(0x20, 0xFF, 0x20, 0xFF), MDFN_FONT_6x13_12x13, rect->w);
 y += 13;

 std::map<std::string, LogInstance>::iterator dl_iter;
 int32 groups_x = 0;

 for(dl_iter = NeoDeathLog.begin(); dl_iter != NeoDeathLog.end(); dl_iter++)
 {
  uint32 group_color = pf_cache.MakeColor(0x80, 0x80, 0x80, 0xFF);
  char group_string[256];

  trio_snprintf(group_string, 256, "%s(%d)", dl_iter->first.c_str(), (int)dl_iter->second.entries.size());

  if(&dl_iter->second == WhichLog)
   group_color = pf_cache.MakeColor(0xFF, 0x80, 0x80, 0xFF);

  groups_x += 6 + DrawText(surface, groups_x, y, group_string, group_color, MDFN_FONT_6x13_12x13);
 }

 y += 13;

 for(uint32 i = WhichLog->LogScroll; i < (WhichLog->LogScroll + 32) && i < WhichLog->entries.size(); i++)
 {
  int32 type_x = 0;
  char tmpbuf[64];

  trio_snprintf(tmpbuf, 64, "%d", i);
  type_x = DrawText(surface, type_x, y, tmpbuf, pf_cache.MakeColor(0x80, 0x80, 0xD0, 0xFF), MDFN_FONT_5x7);
  type_x += 1;
  type_x += DrawText(surface, type_x, y, WhichLog->entries[i].type, pf_cache.MakeColor(0xFF, 0x40, 0x40, 0xFF), MDFN_FONT_6x13_12x13);
  type_x += 5;
  DrawText(surface, type_x, y, WhichLog->entries[i].text, lifecolors[i & 3], MDFN_FONT_6x13_12x13);
  y += 13;
 }
}
コード例 #2
0
ファイル: gfx.cpp プロジェクト: IcooN/OpenEmu
void NGPGFX_CLASS::set_pixel_format(const MDFN_PixelFormat &format)
{
 for(int x = 0; x < 4096; x++)
 {
  int r = (x & 0xF) * 17;
  int g = ((x >> 4) & 0xF) * 17;
  int b = ((x >> 8) & 0xF) * 17;

  ColorMap[x] = format.MakeColor(r, g, b);
 }
}
コード例 #3
0
ファイル: interface.cpp プロジェクト: gameblabla/mednafen-gcw
static void BuildColorMap(MDFN_PixelFormat &format, uint8* CustomColorMap)
{
 for(int x = 0; x < 32768; x++) 
 {
  int r, g, b;

  r = (x & (0x1F <<  0)) << 3;
  g = (x & (0x1F <<  5)) >> (5 - 3);
  b = (x & (0x1F << 10)) >> (5 * 2 - 3);

  //r = ((((x >> 0) & 0x1F) * 255 + 15) / 31);
  //g = ((((x >> 5) & 0x1F) * 255 + 15) / 31);
  //b = ((((x >> 10) & 0x1F) * 255 + 15) / 31);

  if(CustomColorMap)
  {
   r = CustomColorMap[x * 3 + 0];
   g = CustomColorMap[x * 3 + 1];
   b = CustomColorMap[x * 3 + 2];
  }

  ColorMap[x] = format.MakeColor(r, g, b);
 }
}
コード例 #4
0
// When we're converting, only convert the w*h area(AKA leave the last part of the line, pitch32 - w, alone),
// for places where we store auxillary information there(graphics viewer in the debugger), and it'll be faster
// to boot.
void MDFN_Surface::SetFormat(const MDFN_PixelFormat &nf, bool convert)
{
 assert(format.bpp == 16 || format.bpp == 32);
 assert(nf.bpp == 16 || nf.bpp == 32);

 if(nf.bpp == 16)
 {

 }
 else
 {
  assert((nf.Rshift + nf.Gshift + nf.Bshift + nf.Ashift) == 48);
  assert(!((nf.Rshift | nf.Gshift | nf.Bshift | nf.Ashift) & 0x7));
 }
 
#ifdef CONFIG_SUPPORT_32BPP
 if(nf.bpp != format.bpp)
 {
  void *rpix = calloc(1, pitchinpix * h * (nf.bpp / 8));
  void *oldpix;

  if(nf.bpp == 16)	// 32bpp to 16bpp
  {
   pixels16 = (uint16 *)rpix;

   if(convert)
   {
	   MDFN_printf("32bpp to 16bpp convert");
    for(int y = 0; y < h; y++)
    {
     uint32 *srow = &pixels[y * pitchinpix];
     uint16 *drow = &pixels16[y * pitchinpix];

     for(int x = 0; x < w; x++)
     {
      uint32 c = srow[x];
      int r, g, b, a;

      DecodeColor(c, r, g, b, a);
      drow[x] = nf.MakeColor(r, g, b, a);
     }
    }
   }

   oldpix = pixels;
   pixels = NULL;
  }
  else			// 16bpp to 32bpp
  {
   pixels = (uint32 *)rpix;

   if(convert)
   {
	   MDFN_printf("16bpp to 32bpp convert");
    for(int y = 0; y < h; y++)
    {
     uint16 *srow = &pixels16[y * pitchinpix];
     uint32 *drow = &pixels[y * pitchinpix];

     for(int x = 0; x < w; x++)
     {
      uint32 c = srow[x];
      int r, g, b, a;

      DecodeColor(c, r, g, b, a);
      drow[x] = nf.MakeColor(r, g, b, a);
     }
    }
   }

   oldpix = pixels16;
   pixels16 = NULL;
  }
  if(oldpix && !pixels_is_external)
   free(oldpix);

  pixels_is_external = false;

  // We already handled surface conversion above.
  convert = false;
 }
#endif

 if(convert)
 {
  if(format.bpp == 16)
  {
   // We should assert that surface->pixels is non-NULL even if we don't need to convert the surface, to catch more insidious bugs.
   assert(pixels16);

   if(memcmp(&format, &nf, sizeof(MDFN_PixelFormat)))
   {
    //puts("Converting");
    for(int y = 0; y < h; y++)
    {
     uint16 *row = &pixels16[y * pitchinpix];

     for(int x = 0; x < w; x++)
     {
      uint32 c = row[x];
      int r, g, b, a;

      DecodeColor(c, r, g, b, a);
      row[x] = nf.MakeColor(r, g, b, a);
     }
    }
   }
  }
#ifdef CONFIG_SUPPORT_32BPP
  else
  {
   // We should assert that surface->pixels is non-NULL even if we don't need to convert the surface, to catch more insidious bugs.
   assert(pixels);

   if(memcmp(&format, &nf, sizeof(MDFN_PixelFormat)))
   {
    //puts("Converting");
    for(int y = 0; y < h; y++)
    {
     uint32 *row = &pixels[y * pitchinpix];

     for(int x = 0; x < w; x++)
     {
      uint32 c = row[x];
      int r, g, b, a;

      DecodeColor(c, r, g, b, a);
      row[x] = nf.MakeColor(r, g, b, a);
     }
    }
   }
  }
#endif
 }
 format = nf;
}