~ubuntu-branches/debian/experimental/mednafen/experimental

« back to all changes in this revision

Viewing changes to src/drivers/memdebugger.cpp

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-11-19 07:00:37 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20121119070037-jvknrm13zvim88oc
Tags: 0.9.26-1
* New upstream WIP version.
* Change priority to "extra" to match libvorbisidec1's.
* Drop "DM-Upload-Allowed" since it is no longer appropriate.
* Refresh patches, replacing MPC_STATUS_FAIL constant from older mpcdec
  versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
499
499
 }
500
500
}
501
501
 
502
 
#define MK_COLOR_A(r,g,b,a) ( ((a)<<surface->format->Ashift) | ((r)<<surface->format->Rshift) | ((g) << surface->format->Gshift) | ((b) << surface->format->Bshift))
 
502
#define MK_COLOR_A(r,g,b,a) (pf_cache.MakeColor(r, g, b, a))
503
503
 
504
504
// Call this function from the main thread
505
 
void MemDebugger_Draw(SDL_Surface *surface, const SDL_Rect *rect, const SDL_Rect *screen_rect)
 
505
void MemDebugger_Draw(MDFN_Surface *surface, const MDFN_Rect *rect, const MDFN_Rect *screen_rect)
506
506
{
507
507
 if(!IsActive) return;
508
508
 
509
 
 uint32 * pixels = (uint32 *)surface->pixels;
510
 
 uint32 pitch32 = surface->pitch >> 2;
 
509
 const MDFN_PixelFormat pf_cache = surface->format;
 
510
 uint32 *pixels = surface->pixels;
 
511
 uint32 pitch32 = surface->pitchinpix;
511
512
 const uint64 zemod = SizeCache[CurASpace];
512
513
 
513
514
 LockGameMutex(1);
514
515
 
515
 
 DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)ASpace->long_name, MK_COLOR_A(0x20, 0xFF, 0x20, 0xFF), 1, 1);
 
516
 DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)ASpace->long_name, MK_COLOR_A(0x20, 0xFF, 0x20, 0xFF), 1, 1);
516
517
 pixels += 10 * pitch32;
517
518
 
518
519
 uint32 A;
554
555
  if(Ameow == (ASpacePos[CurASpace] & ~0xF))
555
556
   addr_color = MK_COLOR_A(0x80, 0xB0, 0xFF, 0xFF);
556
557
 
557
 
  alen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)abuf, addr_color, 0, 1);
 
558
  alen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)abuf, addr_color, 0, 1);
558
559
  alen += 3;
559
560
 
560
561
  for(int x = 0; x < 16; x++)
604
605
      else
605
606
       pix_offset += (LowNib ? 5 : 0) + x * 12;
606
607
 
607
 
      DrawTextTrans(pixels + pix_offset, surface->pitch, rect->w, (UTF8*)"▉", MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
608
      DrawTextTrans(pixels + pix_offset, surface->pitchinpix << 2, rect->w, (UTF8*)"▉", MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
608
609
     }
609
610
    if(InTextArea)
610
611
    {
619
620
   }
620
621
 
621
622
   // hex display
622
 
   DrawTextTrans(pixels + alen + x * 12, surface->pitch, rect->w, (UTF8*)quickbuf, bcolor, 0, 1);
 
623
   DrawTextTrans(pixels + alen + x * 12, surface->pitchinpix << 2, rect->w, (UTF8*)quickbuf, bcolor, 0, 1);
623
624
 
624
625
   // ASCII display
625
 
   DrawTextTrans(pixels + alen + 16 * 12 + x * 5, surface->pitch, rect->w, (UTF8 *)ascii_str, acolor, 0, 1);
 
626
   DrawTextTrans(pixels + alen + 16 * 12 + x * 5, surface->pitchinpix << 2, rect->w, (UTF8 *)ascii_str, acolor, 0, 1);
626
627
   Ameow++;
627
628
  }
628
629
  pixels += 9 * pitch32;
650
651
  uint32 cpplen;
651
652
  uint32 cplen;
652
653
 
653
 
  cpplen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)"Cursor position: ", MK_COLOR_A(0xa0, 0xa0, 0xFF, 0xFF), 0, 1);
654
 
  cplen = DrawTextTrans(pixels + cpplen, surface->pitch, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
654
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"Cursor position: ", MK_COLOR_A(0xa0, 0xa0, 0xFF, 0xFF), 0, 1);
 
655
  cplen = DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
655
656
  if(GoGoPowerDD[CurASpace])
656
657
  {
657
658
   char ggddstr[32];
663
664
   else
664
665
    trio_snprintf(ggddstr, 32, "%08X", curpos - GoGoPowerDD[CurASpace]);
665
666
 
666
 
   DrawTextTrans(pixels + cpplen + cplen + 8, surface->pitch, rect->w, (UTF8*)ggddstr, MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF), 0, 1);
 
667
   DrawTextTrans(pixels + cpplen + cplen + 8, surface->pitchinpix << 2, rect->w, (UTF8*)ggddstr, MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF), 0, 1);
667
668
  }
668
669
  pixels += 5 + 10 * pitch32;
669
670
 
670
671
  tmpval = zebytes[0];
671
672
  trio_snprintf(cpstr, 32, "%02x(%u, %d)", tmpval, (uint8)tmpval, (int8)tmpval);
672
 
  cpplen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)"1-byte value: ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
673
 
  DrawTextTrans(pixels + cpplen, surface->pitch, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
673
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"1-byte value: ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
 
674
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
674
675
 
675
676
  pixels += 10 * pitch32;
676
677
 
681
682
   uint8 waveform[wf_size];
682
683
   const int32 pcm_max = (1 << ASpace->WaveBits) - 1;
683
684
 
684
 
   DrawTextTrans(pixels - 5, surface->pitch, rect->w, (UTF8 *)"Full waveform:", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
 
685
   DrawTextTrans(pixels - 5, surface->pitchinpix << 2, rect->w, (UTF8 *)"Full waveform:", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
685
686
   pixels += 9 * pitch32;
686
 
   MDFN_DrawRectangleFill(pixels, surface->pitch >> 2, 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);
 
687
   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);
687
688
 
688
689
   ASpace->GetAddressSpaceBytes(ASpace->name, 0, wf_size, waveform);
689
690
 
699
700
    delta = current - previous;
700
701
 
701
702
    for(int y = previous; y != current; y += delta / abs(delta))
702
 
     pixels[2 + i * 2 + 0 + (2 + (pcm_max - y)) * (surface->pitch >> 2)] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
 
703
     pixels[2 + i * 2 + 0 + (2 + (pcm_max - y)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
703
704
 
704
 
    pixels[2 + i * 2 + 0 + (2 + (pcm_max - current)) * (surface->pitch >> 2)] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
705
 
    pixels[2 + i * 2 + 1 + (2 + (pcm_max - current)) * (surface->pitch >> 2)] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
 
705
    pixels[2 + i * 2 + 0 + (2 + (pcm_max - current)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
 
706
    pixels[2 + i * 2 + 1 + (2 + (pcm_max - current)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF);
706
707
   }
707
708
  }
708
709
  else
709
710
  {
710
711
  tmpval = zebytes[0] | (zebytes[1] << 8);
711
712
  trio_snprintf(cpstr, 32, "%04x(%u, %d)", tmpval, (uint16)tmpval, (int16)tmpval);
712
 
  cpplen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)"2-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
713
 
  DrawTextTrans(pixels + cpplen, surface->pitch, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
713
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"2-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
 
714
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
714
715
 
715
716
  pixels += 10 * pitch32;
716
717
  tmpval = zebytes[0] | (zebytes[1] << 8) | (zebytes[2] << 16) | (zebytes[3] << 24);
717
718
  trio_snprintf(cpstr, 32, "%08x(%u, %d)", tmpval, (uint32)tmpval, (int32)tmpval);
718
 
  cpplen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)"4-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
719
 
  DrawTextTrans(pixels + cpplen, surface->pitch, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
719
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"4-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
 
720
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
720
721
 
721
722
  pixels += 10 * pitch32;
722
723
  tmpval = zebytes[1] | (zebytes[0] << 8);
723
724
  trio_snprintf(cpstr, 32, "%04x(%u, %d)", tmpval, (uint16)tmpval, (int16)tmpval);
724
 
  cpplen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)"2-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
725
 
  DrawTextTrans(pixels + cpplen, surface->pitch, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
725
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"2-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
 
726
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
726
727
 
727
728
  pixels += 10 * pitch32;
728
729
  tmpval = zebytes[3] | (zebytes[2] << 8) | (zebytes[1] << 16) | (zebytes[0] << 24);
729
730
  trio_snprintf(cpstr, 32, "%08x(%u, %d)", tmpval, (uint32)tmpval, (int32)tmpval);
730
 
  cpplen = DrawTextTrans(pixels, surface->pitch, rect->w, (UTF8*)"4-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
731
 
  DrawTextTrans(pixels + cpplen, surface->pitch, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
 
731
  cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"4-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1);
 
732
  DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1);
732
733
 
733
734
  trio_snprintf(cpstr, 32, "%s text: ", GameCode);
734
 
  cpplen = DrawTextTrans(pixels + 10 * pitch32, surface->pitch, rect->w, (UTF8*)cpstr, MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, MDFN_FONT_5x7);
 
735
  cpplen = DrawTextTrans(pixels + 10 * pitch32, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr, MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, MDFN_FONT_5x7);
735
736
 
736
737
  {
737
738
   char rawbuf[64];
749
750
   iconv(ict_to_utf8, (ICONV_CONST char **)&inbuf, &ibl, &outbuf, &obl);
750
751
   textbuf[obl_start - obl] = 0;
751
752
 
752
 
   DrawTextTrans(pixels + 8 * pitch32 + cpplen, surface->pitch, rect->w - cpplen - 13, (UTF8*)textbuf, MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, MDFN_FONT_9x18_18x18);
 
753
   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);
753
754
  }
754
755
 
755
756
 }
774
775
  }
775
776
  else
776
777
  {
777
 
   DrawTextTrans((uint32*)surface->pixels + (rect->h - 7) * pitch32, surface->pitch, rect->w, (UTF8*)error_string, MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF), 1, 1);
 
778
   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);
778
779
  }
779
780
 }
780
781
}