Exemple #1
0
void FCEU_DrawNTSCControlBars(uint8 *XBuf)
{
 uint8 *XBaf;
 int which=0;
 int x,x2;

 if(!controllength) return;
 controllength--;
 if(!XBuf) return;

 if(controlselect==1)
 {
  DrawTextTrans(XBuf+128-12+180*256, 256, (uint8 *)"Hue", 0x85);
  which=ntschue<<1;
 }
 else if(controlselect==2)
 {
  DrawTextTrans(XBuf+128-16+180*256, 256, (uint8 *)"Tint", 0x85);
  which=ntsctint<<1;
 }

 XBaf=XBuf+200*256;
 for(x=0;x<which;x+=2)
 {
  for(x2=6;x2>=-6;x2--)
  {
   XBaf[x-256*x2]=0x85;
  }
 }
 for(;x<256;x+=2)
 {
  for(x2=2;x2>=-2;x2--)
   XBaf[x-256*x2]=0x85;
 }
}
Exemple #2
0
void FPS_Draw(MDFN_Surface *target, const int xpos, const int ypos)
{
  if(!isactive)
    return;

  const uint32 bg_color = target->MakeColor(0, 0, 0);
  const uint32 text_color = target->MakeColor(0xFF, 0xFF, 0xFF);
  char virtfps[64], drawnfps[64], blitfps[64];

  CalcFramerates(virtfps, drawnfps, blitfps, 64);

  MDFN_DrawRectangleFill(target->pixels, target->pitch32, xpos, ypos, bg_color, bg_color, box_width, box_height);

  DrawTextTrans(target->pixels + xpos + ypos * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)virtfps, text_color, FALSE, TRUE);
  DrawTextTrans(target->pixels + xpos + (ypos + 7) * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)drawnfps, text_color, FALSE, TRUE);
  DrawTextTrans(target->pixels + xpos + (ypos + 7 * 2) * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)blitfps, text_color, FALSE, TRUE);
}
Exemple #3
0
void FPS_DrawToScreen(SDL_Surface *screen, int rs, int gs, int bs, int as)
{
  if(!isactive) 
  {
    if(FPSSurface)
    {
      SDL_FreeSurface(FPSSurface);
      FPSSurface = NULL;
    }
    return;
  }

  if(!FPSSurface)
  {
    FPSSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, box_width, box_height, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as);
    FPSRect.w = box_width;
    FPSRect.h = box_height;
    FPSRect.x = FPSRect.y = 0;
  }

  char virtfps[64], drawnfps[64], blitfps[64];

  CalcFramerates(virtfps, drawnfps, blitfps, 64);

  SDL_FillRect(FPSSurface, NULL, MK_COLOR_A(FPSSurface, 0, 0, 0, 0x80));
  DrawTextTrans((uint32 *)FPSSurface->pixels, FPSSurface->pitch, FPSSurface->w, (UTF8*)virtfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
  DrawTextTrans((uint32 *)FPSSurface->pixels + 7 * (FPSSurface->pitch >> 2), FPSSurface->pitch, FPSSurface->w, (UTF8*)drawnfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);
  DrawTextTrans((uint32 *)FPSSurface->pixels + 7 * 2 * (FPSSurface->pitch >> 2), FPSSurface->pitch, FPSSurface->w, (UTF8*)blitfps, MK_COLOR_A(FPSSurface, 0xFF, 0xFF, 0xFF, 0xFF), FALSE, TRUE);

  SDL_Rect drect;
  drect.x = 0;
  drect.y = 0;
  drect.w = FPSRect.w;
  drect.h = FPSRect.h;

  BlitRaw(FPSSurface, &FPSRect, &drect);
}
// Call this function from the main thread
void MemDebugger_Draw(MDFN_Surface *surface, const MDFN_Rect *rect, const MDFN_Rect *screen_rect)
{
 if(!IsActive) return;

 const MDFN_PixelFormat pf_cache = surface->format;
 uint32 *pixels = surface->pixels;
 uint32 pitch32 = surface->pitchinpix;
 const uint64 zemod = SizeCache[CurASpace];

 LockGameMutex(1);

 DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)ASpace->long_name, MK_COLOR_A(0x20, 0xFF, 0x20, 0xFF), 1, 1);
 pixels += 10 * pitch32;

 uint32 A;
 uint32 Ameow; // A meow for a cat

 if(ASpacePos[CurASpace] < 128)
  A = (SizeCache[CurASpace] - 128 + ASpacePos[CurASpace]) % SizeCache[CurASpace];
 else
  A = ASpacePos[CurASpace] - 128;

 Ameow = A &~ 0xF;

 int numrows = zemod / 16;

 if(numrows > 16)
  numrows = 16;
 else if(numrows < 4)
  numrows = 4;

 for(int y = 0; y < numrows; y++)
 {
  uint8 byte_buffer[16];
  char abuf[32];

  Ameow %= zemod;

  ASpace->GetAddressSpaceBytes(ASpace->name, Ameow, 16, byte_buffer);

  if(zemod <= (1 << 16))
   trio_snprintf(abuf, 32, "%04X:", Ameow);
  else if(zemod <= (1 << 24))
   trio_snprintf(abuf, 32, "%06X:", Ameow);
  else
   trio_snprintf(abuf, 32, "%08X:", Ameow);

  uint32 alen;
  uint32 addr_color = MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF);

  if(Ameow == (ASpacePos[CurASpace] & ~0xF))
   addr_color = MK_COLOR_A(0x80, 0xB0, 0xFF, 0xFF);

  alen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)abuf, addr_color, 0, 1);
  alen += 3;

  for(int x = 0; x < 16; x++)
  {
   uint32 bcolor = MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF);
   uint32 acolor = MK_COLOR_A(0xA0, 0xA0, 0xA0, 0xFF);

   char quickbuf[16];
   uint32 test_match_pos;
   uint8 ascii_str[2];

   ascii_str[1] = 0;
   ascii_str[0] = byte_buffer[x];

   if(ascii_str[0] < 0x20 || ascii_str[0] >= 128)
    ascii_str[0] = '.';

   trio_snprintf(quickbuf, 16, "%02X", byte_buffer[x]);

   test_match_pos = ASpacePos[CurASpace] % zemod;

   if(InMarkMode)
   {
    if(MarkModeBegin < test_match_pos && Ameow < test_match_pos && Ameow >= MarkModeBegin)
    {
     if(InTextArea)
     {
      acolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF);
      bcolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF);
     }
     else
     { 
      acolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF);
      bcolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF);
     }
    }
   }
   if(Ameow == test_match_pos)
   {
    if(InEditMode)
     if(SDL_GetTicks() & 0x80)
     {
      int pix_offset = alen;

      if(InTextArea)
       pix_offset += 16 * 12 + x * 5;
      else
       pix_offset += (LowNib ? 5 : 0) + x * 12;

      DrawTextTrans(pixels + pix_offset, surface->pitchinpix << 2, rect->w, (UTF8*)"▉", MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
     }
    if(InTextArea)
    {
     acolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF);
     bcolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF);
    }
    else
    {
     acolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF);
     bcolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF);
    }
   }

   // hex display
   DrawTextTrans(pixels + alen + x * 12, surface->pitchinpix << 2, rect->w, (UTF8*)quickbuf, bcolor, 0, 1);

   // ASCII display
   DrawTextTrans(pixels + alen + 16 * 12 + x * 5, surface->pitchinpix << 2, rect->w, (UTF8 *)ascii_str, acolor, 0, 1);
   Ameow++;
  }
  pixels += 9 * pitch32;
 }

 {
  char cpstr[32];
  uint32 curpos = ASpacePos[CurASpace];
  uint8 zebytes[4];
  uint32 tmpval;

  curpos %= zemod;

  ASpace->GetAddressSpaceBytes(ASpace->name, curpos, 4, zebytes);

  pixels += 8 + 5 * pitch32;

  if(zemod <= (1 << 16))
   trio_snprintf(cpstr, 32, "%04X", curpos);
  else if(zemod <= (1 << 24))
   trio_snprintf(cpstr, 32, "%06X", curpos);
  else
   trio_snprintf(cpstr, 32, "%08X", curpos);

  uint32 cpplen;
  uint32 cplen;

  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"Cursor position: ", MK_COLOR_A(0xa0, 0xa0, 0xFF, 0xFF), 0, 1);
  cplen = DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
  if(GoGoPowerDD[CurASpace])
  {
   char ggddstr[32];

   if(zemod <= (1 << 16))
    trio_snprintf(ggddstr, 32, "%04X", curpos - GoGoPowerDD[CurASpace]);
   else if(zemod <= (1 << 24))
    trio_snprintf(ggddstr, 32, "%06X", curpos - GoGoPowerDD[CurASpace]);
   else
    trio_snprintf(ggddstr, 32, "%08X", curpos - GoGoPowerDD[CurASpace]);

   DrawTextTrans(pixels + cpplen + cplen + 8, surface->pitchinpix << 2, rect->w, (UTF8*)ggddstr, MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF), 0, 1);
  }
  pixels += 5 + 10 * pitch32;

  tmpval = zebytes[0];
  trio_snprintf(cpstr, 32, "%02x(%u, %d)", tmpval, (uint8)tmpval, (int8)tmpval);
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"1-byte value: ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);

  pixels += 10 * pitch32;


  if(ASpace->IsWave && SizeCache[CurASpace] <= 128 && ASpace->WaveBits <= 6)
  {
   const int32 wf_size = SizeCache[CurASpace];
   uint8 waveform[wf_size];
   const int32 pcm_max = (1 << ASpace->WaveBits) - 1;

   DrawTextTrans(pixels - 5, surface->pitchinpix << 2, rect->w, (UTF8 *)"Full waveform:", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
   pixels += 9 * pitch32;
   MDFN_DrawRectangleFill(pixels, surface->pitchinpix, 0, 0, MK_COLOR_A(0xA0,0xA0,0xA0,0xFF), MK_COLOR_A(0,0,0,0xFF), 2 + wf_size * 2 + 2, 2 + (pcm_max + 1) + 2);

   ASpace->GetAddressSpaceBytes(ASpace->name, 0, wf_size, waveform);

   for(int i = 0; i < wf_size; i++)
   {
    int32 delta;
    int32 current;
    int32 previous;

    current = waveform[i];
    previous = waveform[(i + wf_size - 1) % wf_size];

    delta = current - previous;

    for(int y = previous; y != current; y += delta / abs(delta))
     pixels[2 + i * 2 + 0 + (2 + (pcm_max - y)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);

    pixels[2 + i * 2 + 0 + (2 + (pcm_max - current)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
    pixels[2 + i * 2 + 1 + (2 + (pcm_max - current)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
   }
  }
  else
  {
  tmpval = zebytes[0] | (zebytes[1] << 8);
  trio_snprintf(cpstr, 32, "%04x(%u, %d)", tmpval, (uint16)tmpval, (int16)tmpval);
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"2-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);

  pixels += 10 * pitch32;
  tmpval = zebytes[0] | (zebytes[1] << 8) | (zebytes[2] << 16) | (zebytes[3] << 24);
  trio_snprintf(cpstr, 32, "%08x(%u, %d)", tmpval, (uint32)tmpval, (int32)tmpval);
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"4-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);

  pixels += 10 * pitch32;
  tmpval = zebytes[1] | (zebytes[0] << 8);
  trio_snprintf(cpstr, 32, "%04x(%u, %d)", tmpval, (uint16)tmpval, (int16)tmpval);
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"2-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);

  pixels += 10 * pitch32;
  tmpval = zebytes[3] | (zebytes[2] << 8) | (zebytes[1] << 16) | (zebytes[0] << 24);
  trio_snprintf(cpstr, 32, "%08x(%u, %d)", tmpval, (uint32)tmpval, (int32)tmpval);
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"4-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);

  trio_snprintf(cpstr, 32, "%s text: ", GameCode);
  cpplen = DrawTextTrans(pixels + 10 * pitch32, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr, MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, MDFN_FONT_5x7);

  {
   char rawbuf[64];
   char textbuf[256];

   ASpace->GetAddressSpaceBytes(ASpace->name, curpos, 64, (uint8*)rawbuf);

   size_t ibl, obl, obl_start;
   char *inbuf, *outbuf;
   ibl = 64;
   obl_start = obl = 255; // Hehe, ugly maximum estimation!
   inbuf = rawbuf;
   outbuf = textbuf;

   iconv(ict_to_utf8, (ICONV_CONST char **)&inbuf, &ibl, &outbuf, &obl);
   textbuf[obl_start - obl] = 0;

   DrawTextTrans(pixels + 8 * pitch32 + cpplen, surface->pitchinpix << 2, rect->w - cpplen - 13, (UTF8*)textbuf, MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, MDFN_FONT_9x18_18x18);
  }

 }

 }
 LockGameMutex(0);

 if(InPrompt)
  myprompt->Draw(surface, rect);
 else if(myprompt)
 {
  delete myprompt;
  myprompt = NULL;
 }

 if(error_string)
 {
  if(SDL_GetTicks() >= (error_time + 4000))
  {
   free(error_string);
   error_string = NULL;
  }
  else
  {
   DrawTextTrans((uint32*)surface->pixels + (rect->h - 7) * pitch32, surface->pitchinpix << 2, rect->w, (UTF8*)error_string, MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF), 1, 1);
  }
 }
}