regs.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*******************************************************************************
  2. * Emu51
  3. * regs.cpp:
  4. * Created by mlt on 22/03/23.
  5. ******************************************************************************/
  6. #include <emu51.h>
  7. #include <regs.h>
  8. #include <gui.h>
  9. regs::regs(uint8_t *tmpB, BITMAP *tmpBMP)
  10. {
  11. red = makecol(255, 0, 0);
  12. white = makecol(255, 255, 255);
  13. lblue = makecol(0, 128, 255);
  14. green = makecol(0, 255, 0);
  15. lred = makecol(255, 64, 0);
  16. frame = 2;
  17. left = 12;
  18. changed = true;
  19. sfr = tmpB;
  20. buf = tmpBMP;
  21. surface = create_bitmap(400, 300);
  22. clear(surface);
  23. };
  24. regs::~regs()
  25. {};
  26. void regs::blit_it(int x, int y)
  27. {
  28. blit(surface, buf, 0, 0, x, y, surface->w, surface->h);
  29. };
  30. void regs::draw()
  31. {
  32. clear(surface);
  33. int c2 = 0, c;
  34. textprintf(surface, mainf, left, frame + 20, lblue, "nr label adress hex dec ascii SEG LED(bin)");
  35. for ( c = frame + 30 ; c < surface->h - 20 ; c += 10 )
  36. {
  37. textprintf(surface, mainf, left, c, white, "%2d: %9s (%2x) = %2x %3d %c", c2 + 1, reg_label[c2], reg[c2],
  38. sfr[reg[c2]], sfr[reg[c2]], sfr[reg[c2]]);
  39. draw_SEG_digit(surface, left + 288, c, green, 4, sfr[reg[c2]]);
  40. draw_LED_bin(surface, left + 314, c + 4, lred, sfr[reg[c2]]);
  41. c2++;
  42. if ( c2 == 25 )
  43. {
  44. break;
  45. }
  46. };
  47. hline(surface, frame, surface->h - frame, surface->w - frame, white);
  48. vline(surface, frame, frame, surface->h - frame, white);
  49. vline(surface, surface->w - frame, frame, surface->h - frame, white);
  50. for ( c = frame ; c <= frame + 10 ; c += 2 )
  51. {
  52. hline(surface, frame, c, surface->w - frame, white);
  53. }
  54. textprintf_centre(surface, mainf, surface->w / 2, frame + 2, white, " SFR Registers ");
  55. }
  56. void regs::hexoutB(int x, int y, int color, uint8_t numb)
  57. {
  58. if ( numb > 0x10 )
  59. {
  60. textprintf(surface, mainf, x, y, color, "%2x", numb);
  61. }
  62. else
  63. {
  64. textprintf(surface, mainf, x, y, color, "%2x", numb);
  65. textprintf(surface, mainf, x, y, color, "0");
  66. }
  67. }