graphics_dummy.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Graphic Manager - The peTI-NESulator Project
  3. * os/macos/graphics.c
  4. *
  5. * Created by Manoël Trapier on 08/05/08.
  6. * Copyright (c) 2002-2019 986-Studio.
  7. *
  8. */
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdint.h>
  13. #include <sys/time.h>
  14. #include <time.h>
  15. #include <os_dependent.h>
  16. #include <GLFW/glfw3.h>
  17. //#include <OpenGL/glext.h>
  18. #include <palette.h>
  19. typedef struct GLWindow_t GLWindow;
  20. struct KeyArray
  21. {
  22. uint8_t lastState;
  23. uint8_t curState;
  24. uint8_t debounced;
  25. };
  26. struct GLWindow_t
  27. {
  28. struct KeyArray keyArray[512];
  29. GLFWwindow *windows;
  30. uint8_t *videoMemory;
  31. GLint videoTexture;
  32. int WIDTH;
  33. int HEIGHT;
  34. };
  35. #ifndef GL_TEXTURE_RECTANGLE_EXT
  36. #define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV
  37. #endif
  38. void GLWindowInitEx(GLWindow *g, int w, int h)
  39. {
  40. }
  41. void GLWindowInit(GLWindow *g)
  42. {
  43. }
  44. void ShowScreen(GLWindow *g, int w, int h)
  45. {
  46. }
  47. void setupGL(GLWindow *g, int w, int h)
  48. {
  49. }
  50. void restoreGL(GLWindow *g, int w, int h)
  51. {
  52. }
  53. void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
  54. {
  55. }
  56. void sizeHandler(GLFWwindow *window, int xs, int ys)
  57. {
  58. }
  59. void initDisplay(GLWindow *g)
  60. {
  61. }
  62. void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
  63. {
  64. }
  65. void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
  66. {
  67. }
  68. void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
  69. {
  70. }
  71. void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
  72. {
  73. }
  74. void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
  75. {
  76. }
  77. void clearScreen(GLWindow *g)
  78. {
  79. }
  80. void updateScreen(GLWindow *g)
  81. {
  82. }
  83. void updateScreenAndWait(GLWindow *g)
  84. {
  85. }
  86. int graphics_init()
  87. {
  88. return 0;
  89. }
  90. int graphics_drawpixel(long x, long y, long color)
  91. {
  92. return 0;
  93. }
  94. int graphics_drawline(long x, long y, long x1, long y1, long color)
  95. {
  96. return 0;
  97. }
  98. int graphics_blit(long x, long y, long w, long h)
  99. {
  100. return 0;
  101. }
  102. int getKeyStatus(int key)
  103. {
  104. return 0;
  105. }
  106. /* Sync with 60Hz (or try to) */
  107. void vsync(void)
  108. {
  109. long WaitTime;
  110. static long delta = 0;
  111. /* Try to sync at 60FPS */
  112. /* Get current time in microseconds */
  113. gettimeofday(&timeEnd, NULL);
  114. WaitTime = (timeEnd.tv_sec) - (timeStart.tv_sec);
  115. WaitTime *= 1000000;
  116. WaitTime += (timeEnd.tv_usec - timeStart.tv_usec);
  117. #if !ISPAL && ISNTSC
  118. /* Calculate the waiting time, 16666 is the time of one frame in microseconds at a 60Hz rate) */
  119. WaitTime = 16666 - WaitTime + delta;
  120. #elif ISPAL && !ISNTSC
  121. WaitTime = 20000 - WaitTime + delta;
  122. #endif
  123. #ifndef RUN_COVERAGE
  124. if ((WaitTime >= 0) && (WaitTime < 100000))
  125. {
  126. usleep(WaitTime);
  127. }
  128. #endif
  129. /* Now get the time after sleep */
  130. gettimeofday(&timeStart, NULL);
  131. /* Now calculate How many microseconds we really spend in sleep and
  132. calculate a delta for next iteration */
  133. delta = (timeStart.tv_sec) - (timeEnd.tv_sec);
  134. delta *= 1000000;
  135. delta += (timeStart.tv_usec - timeEnd.tv_usec);
  136. delta = WaitTime - delta;
  137. console_printf(Console_Default, "Delta:%d\n", delta);
  138. /* To avoid strange time warp when stopping emulation or using acceleration a lot */
  139. if ((delta > 10000) || (delta < -10000))
  140. {
  141. delta = 0;
  142. }
  143. }