flags.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*******************************************************************************
  2. * Emu51
  3. * flags.cpp:
  4. * Created by mlt on 22/03/23.
  5. ******************************************************************************/
  6. #include <emu51.h>
  7. #include <flags.h>
  8. #include <code_51.h>
  9. flags::flags(BITMAP *tmp_buf)
  10. {
  11. buf = tmp_buf;
  12. surface = create_bitmap(100, 300);
  13. frame = 2;
  14. left = 12;
  15. changed = false;
  16. }
  17. flags::~flags()
  18. {
  19. }
  20. void flags::draw()
  21. {
  22. int red = makecol(255, 0, 0);
  23. int white = makecol(255, 255, 255);
  24. int lblue = makecol(0, 128, 255);
  25. clear(surface);
  26. textprintf(surface, mainf, left, frame + 20, white, "C : %d", check_C());
  27. textprintf(surface, mainf, left, frame + 30, white, "AC : %d", check_AC());
  28. textprintf(surface, mainf, left, frame + 40, white, "OV : %d", check_OV());
  29. textprintf(surface, mainf, left, frame + 50, white, "P : %d", check_P());
  30. textprintf(surface, mainf, left, frame + 60, red, "PC : %4x", PC);
  31. textprintf(surface, mainf, left, frame + 70, lblue, "SP : %2x", *SP);
  32. textprintf(surface, mainf, left, frame + 80, lblue, "Acc: %2x", *Acc);
  33. textprintf(surface, mainf, left, frame + 90, lblue, "B : %2x", *B);
  34. textprintf(surface, mainf, left, frame + 100, lblue, "R0 : %2x", R[0]);
  35. textprintf(surface, mainf, left, frame + 110, lblue, "R1 : %2x", R[1]);
  36. textprintf(surface, mainf, left, frame + 120, lblue, "R2 : %2x", R[2]);
  37. textprintf(surface, mainf, left, frame + 130, lblue, "R3 : %2x", R[3]);
  38. textprintf(surface, mainf, left, frame + 140, lblue, "R4 : %2x", R[4]);
  39. textprintf(surface, mainf, left, frame + 150, lblue, "R5 : %2x", R[5]);
  40. textprintf(surface, mainf, left, frame + 160, lblue, "R6 : %2x", R[6]);
  41. textprintf(surface, mainf, left, frame + 170, lblue, "R7 : %2x", R[7]);
  42. textprintf(surface, mainf, left, frame + 180, lblue, "DPTR: %4x", *DPTR);
  43. textprintf(surface, mainf, left, frame + 270, red, "cycles :");
  44. textprintf(surface, mainf, left, frame + 280, red, "%lld", c_time);
  45. hline(surface, frame, surface->h - frame, surface->w - frame, white);
  46. vline(surface, frame, frame, surface->h - frame, white);
  47. vline(surface, surface->w - frame, frame, surface->h - frame, white);
  48. for ( int c = frame ; c <= frame + 10 ; c += 2 )
  49. {
  50. hline(surface, frame, c, surface->w - frame, white);
  51. }
  52. textprintf_centre(surface, mainf, surface->w / 2, frame + 2, white, " RegFlag ");
  53. }
  54. void flags::blit_it(int x, int y)
  55. {
  56. blit(surface, buf, 0, 0, x, y, surface->w, surface->h);
  57. }