ramv.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*******************************************************************************
  2. * Emu51
  3. * ramv.cpp:
  4. * Created by mlt on 22/03/23.
  5. ******************************************************************************/
  6. #include <emu51.h>
  7. #include <ramv.h>
  8. #include <gui.h>
  9. ramv::ramv(BITMAP *tmpBMP) // extram, screen
  10. {
  11. frame = 2;
  12. left = 12;
  13. changed = true;
  14. buf = tmpBMP;
  15. surface = create_bitmap(500, 200);
  16. clear(surface);
  17. }
  18. ramv::~ramv()
  19. {
  20. }
  21. void ramv::blit_it(int x, int y)
  22. {
  23. blit(surface, buf, 0, 0, x, y, surface->w, surface->h);
  24. }
  25. void ramv::draw(uint16_t cur)
  26. {
  27. int red = makecol(255, 0, 0);
  28. int white = makecol(255, 255, 255);
  29. int lgreen = makecol(128, 255, 128);
  30. int green = makecol(0, 255, 0);
  31. int lblue = makecol(0, 128, 255);
  32. int yellow = makecol(255, 255, 0);
  33. clear(surface);
  34. int c2 = 0, c;
  35. int y;
  36. y = frame + 20;
  37. int curcol = white;
  38. for ( c = cur ; true ; c += 8 )
  39. {
  40. if ( !( y < surface->h - 10 ))
  41. {
  42. break;
  43. }
  44. textprintf(surface, mainf, left, y, lblue, "%4X: ", (uint16_t) ( c ));
  45. for ( c2 = 0 ; c2 < 8 ; c2++ )
  46. {
  47. if ( PC == (uint16_t) ( c + c2 ))
  48. {
  49. curcol = red;
  50. draw_SEG_digit(surface, left + 326 + c2 * 8, y, yellow, 3, ram[(uint16_t) ( c + c2 )]);
  51. }
  52. else if ( *DPTR == (uint16_t) ( c + c2 ))
  53. {
  54. curcol = lgreen;
  55. draw_SEG_digit(surface, left + 326 + c2 * 8, y, yellow, 3, ram[(uint16_t) ( c + c2 )]);
  56. }
  57. else
  58. {
  59. curcol = white;
  60. draw_SEG_digit(surface, left + 326 + c2 * 8, y, green, 3, ram[(uint16_t) ( c + c2 )]);
  61. }
  62. hexoutB(left + 48 + c2 * 24, y, curcol, ram[(uint16_t) ( c + c2 )]);
  63. textprintf(surface, font, left + 252 + c2 * 8, y, curcol, "%c", ram[(uint16_t) ( c + c2 )]);
  64. }
  65. y += 10;
  66. }
  67. hline(surface, frame, surface->h - frame, surface->w - frame, white);
  68. vline(surface, frame, frame, surface->h - frame, white);
  69. vline(surface, surface->w - frame, frame, surface->h - frame, white);
  70. for ( c = frame ; c <= frame + 10 ; c += 2 )
  71. {
  72. hline(surface, frame, c, surface->w - frame, white);
  73. }
  74. textprintf_centre(surface, mainf, surface->w / 2, frame + 2, white, " RAM Monitor ");
  75. }
  76. void ramv::hexoutB(int x, int y, int color, uint8_t numb)
  77. {
  78. if ( numb > 0x10 )
  79. {
  80. textprintf(surface, mainf, x, y, color, "%2x", numb);
  81. }
  82. else
  83. {
  84. textprintf(surface, mainf, x, y, color, "%2x", numb);
  85. textprintf(surface, mainf, x, y, color, "0");
  86. }
  87. }