graphics_dummy.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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(uint32_t x, uint32_t y, uint32_t x1, uint32_t y1, uint32_t colour)
  95. {
  96. return 0;
  97. }
  98. int graphics_drawRect(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour)
  99. {
  100. return 0;
  101. }
  102. int graphics_drawFillrect(int x0, int y0, int w, int h, uint32_t colour)
  103. {
  104. return 0;
  105. }
  106. int graphics_getScreenSize(int *w, int *h)
  107. {
  108. *w = 640;
  109. *h = 320;
  110. return 0;
  111. }
  112. int graphics_blit(long x, long y, long w, long h)
  113. {
  114. return 0;
  115. }
  116. int getKeyStatus(int key)
  117. {
  118. return 0;
  119. }
  120. /* Sync with 60Hz (or try to) */
  121. void vsync(void)
  122. {
  123. #if 0
  124. /* For now don't do anything there */
  125. long WaitTime;
  126. static long delta = 0;
  127. /* Try to sync at 60FPS */
  128. /* Get current time in microseconds */
  129. gettimeofday(&timeEnd, NULL);
  130. WaitTime = (timeEnd.tv_sec) - (timeStart.tv_sec);
  131. WaitTime *= 1000000;
  132. WaitTime += (timeEnd.tv_usec - timeStart.tv_usec);
  133. #if !ISPAL && ISNTSC
  134. /* Calculate the waiting time, 16666 is the time of one frame in microseconds at a 60Hz rate) */
  135. WaitTime = 16666 - WaitTime + delta;
  136. #elif ISPAL && !ISNTSC
  137. WaitTime = 20000 - WaitTime + delta;
  138. #endif
  139. #ifndef RUN_COVERAGE
  140. if ((WaitTime >= 0) && (WaitTime < 100000))
  141. {
  142. usleep(WaitTime);
  143. }
  144. #endif
  145. /* Now get the time after sleep */
  146. gettimeofday(&timeStart, NULL);
  147. /* Now calculate How many microseconds we really spend in sleep and
  148. calculate a delta for next iteration */
  149. delta = (timeStart.tv_sec) - (timeEnd.tv_sec);
  150. delta *= 1000000;
  151. delta += (timeStart.tv_usec - timeEnd.tv_usec);
  152. delta = WaitTime - delta;
  153. console_printf(Console_Default, "Delta:%d\n", delta);
  154. /* To avoid strange time warp when stopping emulation or using acceleration a lot */
  155. if ((delta > 10000) || (delta < -10000))
  156. {
  157. delta = 0;
  158. }
  159. #endif
  160. }