wonx.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "wonx/wonx.h"
  4. #include "WonX.h"
  5. #include "WonXDisplay.h"
  6. #include "WWDisplay.h"
  7. #include "XDisplay.h"
  8. #include "WWColorMap.h"
  9. #include "WWPalette.h"
  10. #include "WWCharacter.h"
  11. #include "WWSprite.h"
  12. /*****************************************************************************/
  13. /* 外部に公開する WonX のサービス関数 */
  14. /*****************************************************************************/
  15. /*
  16. * Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので,
  17. * 互換関数の内部は UNIXTimer_Pause(), UNIXTimer_Unpause() でくくり,
  18. * タイマ割り込みを一時停止して処理を行う.また,unpause するまえに,
  19. * かならず sync するようにする.
  20. */
  21. /*
  22. * タイマの一時停止の2重解除の問題が出てくるので,
  23. * 互換関数から互換関数を呼んではいけない.
  24. * (一時停止はネストされるが,いちおう)
  25. * 似たような処理をする関数の場合は,必ず static な別関数に処理をまとめ,
  26. * そっちを呼び出すようにすること.
  27. * 引数の表示の問題もあるしね.
  28. */
  29. /* カラーマップ情報の出力 */
  30. void wonx_print_colormap_data(void)
  31. {
  32. WWDisplay ww_display;
  33. if (!WonX_IsCreated()) WonX_Create();
  34. /* タイマを一時停止する */
  35. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  36. printf("call : wonx_print_colormap_data() : \n");
  37. fflush(stdout);
  38. ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
  39. WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
  40. WonXDisplay_Sync(WonX_GetWonXDisplay());
  41. printf("call : wonx_print_colormap_data() : return value = none\n");
  42. fflush(stdout);
  43. /* タイマをもとに戻す */
  44. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  45. return;
  46. }
  47. /* パレット情報の出力用内部関数 */
  48. static void _print_palette_data(int n)
  49. {
  50. WWDisplay ww_display;
  51. WWPalette ww_palette;
  52. ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
  53. ww_palette = WWDisplay_GetPalette(ww_display, n);
  54. WWPalette_PrintData(ww_palette, ww_display, stdout);
  55. return;
  56. }
  57. /* パレット情報の出力 */
  58. void wonx_print_palette_data(int n)
  59. {
  60. if (!WonX_IsCreated()) WonX_Create();
  61. /* タイマを一時停止する */
  62. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  63. printf("call : wonx_print_palette_data() : number = %d\n", n);
  64. fflush(stdout);
  65. if ((n < 0) || (n > 16 - 1))
  66. WonX_Error("wonx_print_palette_data", "number is out of range.");
  67. _print_palette_data(n);
  68. WonXDisplay_Sync(WonX_GetWonXDisplay());
  69. printf("call : wonx_print_palette_data() : return value = none\n");
  70. fflush(stdout);
  71. /* タイマをもとに戻す */
  72. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  73. return;
  74. }
  75. /* すべてのパレット情報を出力 */
  76. void wonx_print_all_palette_data(void)
  77. {
  78. int n;
  79. if (!WonX_IsCreated()) WonX_Create();
  80. /* タイマを一時停止する */
  81. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  82. printf("call : wonx_print_all_palette_data() : \n");
  83. fflush(stdout);
  84. for (n = 0; n < 16; n++) _print_palette_data(n);
  85. WonXDisplay_Sync(WonX_GetWonXDisplay());
  86. printf("call : wonx_print_all_palette_data() : return value = none\n");
  87. fflush(stdout);
  88. /* タイマをもとに戻す */
  89. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  90. return;
  91. }
  92. /* キャラクタ情報の出力用内部関数 */
  93. static void _print_character_data(int n)
  94. {
  95. WWDisplay ww_display;
  96. WWCharacter ww_character;
  97. ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
  98. ww_character = WWDisplay_GetCharacter(ww_display, n);
  99. WWCharacter_PrintData(ww_character, ww_display, stdout);
  100. return;
  101. }
  102. /* キャラクタ情報の出力 */
  103. void wonx_print_character_data(int n)
  104. {
  105. if (!WonX_IsCreated()) WonX_Create();
  106. /* タイマを一時停止する */
  107. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  108. printf("call : wonx_print_character_data() : number = %d\n", n);
  109. fflush(stdout);
  110. if ((n < 0) || (n > 512 - 1))
  111. WonX_Error("wonx_print_character_data", "number is out of range.");
  112. _print_character_data(n);
  113. WonXDisplay_Sync(WonX_GetWonXDisplay());
  114. printf("call : wonx_print_character_data() : return value = none\n");
  115. fflush(stdout);
  116. /* タイマをもとに戻す */
  117. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  118. return;
  119. }
  120. /* すべてのキャラクタ情報を出力 */
  121. void wonx_print_all_character_data(void)
  122. {
  123. int n;
  124. if (!WonX_IsCreated()) WonX_Create();
  125. /* タイマを一時停止する */
  126. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  127. printf("call : wonx_print_all_character_data() : \n");
  128. fflush(stdout);
  129. for (n = 0; n < 512; n++) _print_character_data(n);
  130. WonXDisplay_Sync(WonX_GetWonXDisplay());
  131. printf("call : wonx_print_all_character_data() : return value = none\n");
  132. fflush(stdout);
  133. /* タイマをもとに戻す */
  134. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  135. return;
  136. }
  137. /* スプライト情報の出力用内部関数 */
  138. static void _print_sprite_data(int n)
  139. {
  140. WWDisplay ww_display;
  141. WWSprite ww_sprite;
  142. ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
  143. ww_sprite = WWDisplay_GetSprite(ww_display, n);
  144. WWSprite_PrintData(ww_sprite, stdout);
  145. return;
  146. }
  147. /* スプライト情報の出力 */
  148. void wonx_print_sprite_data(int n)
  149. {
  150. if (!WonX_IsCreated()) WonX_Create();
  151. /* タイマを一時停止する */
  152. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  153. printf("call : wonx_print_sprite_data() : number = %d\n", n);
  154. fflush(stdout);
  155. if ((n < 0) || (n > 128 - 1))
  156. WonX_Error("wonx_print_sprite_data", "number is out of range.");
  157. _print_sprite_data(n);
  158. WonXDisplay_Sync(WonX_GetWonXDisplay());
  159. printf("call : wonx_print_sprite_data() : return value = none\n");
  160. fflush(stdout);
  161. /* タイマをもとに戻す */
  162. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  163. return;
  164. }
  165. /* すべてのスプライト情報を出力 */
  166. void wonx_print_all_sprite_data(void)
  167. {
  168. int n;
  169. if (!WonX_IsCreated()) WonX_Create();
  170. /* タイマを一時停止する */
  171. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  172. printf("call : wonx_print_all_sprite_data() : \n");
  173. fflush(stdout);
  174. for (n = 0; n < 128; n++) _print_sprite_data(n);
  175. WonXDisplay_Sync(WonX_GetWonXDisplay());
  176. printf("call : wonx_print_all_sprite_data() : return value = none\n");
  177. fflush(stdout);
  178. /* タイマをもとに戻す */
  179. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  180. return;
  181. }
  182. /* 現在の表示/非表示のレベルの取得.(1以上で表示,0以下で非表示) */
  183. int wonx_get_lcddraw_level(void)
  184. {
  185. XDisplay x_display;
  186. int ret;
  187. if (!WonX_IsCreated()) WonX_Create();
  188. /* タイマを一時停止する */
  189. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  190. printf("call : wonx_get_lcddraw_level() : \n");
  191. fflush(stdout);
  192. x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
  193. ret = XDisplay_GetLCDDrawLevel(x_display);
  194. WonXDisplay_Sync(WonX_GetWonXDisplay());
  195. printf("call : wonx_get_lcddraw_level() : return value = %d\n", ret);
  196. fflush(stdout);
  197. /* タイマをもとに戻す */
  198. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  199. return (ret);
  200. }
  201. /* 現在の表示/非表示のレベルの設定 */
  202. int wonx_set_lcddraw_level(int level)
  203. {
  204. XDisplay x_display;
  205. int ret;
  206. if (!WonX_IsCreated()) WonX_Create();
  207. /* タイマを一時停止する */
  208. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  209. printf("call : wonx_set_lcddraw_level() : level = %d\n", level);
  210. fflush(stdout);
  211. x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
  212. ret = XDisplay_SetLCDDrawLevel(x_display, level);
  213. WonXDisplay_Flush(WonX_GetWonXDisplay());
  214. printf("call : wonx_set_lcddraw_level() : return value = %d\n", ret);
  215. fflush(stdout);
  216. /* タイマをもとに戻す */
  217. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  218. return (ret);
  219. }
  220. /* 表示レベルを下げる */
  221. int wonx_lcddraw_level_down(void)
  222. {
  223. XDisplay x_display;
  224. int ret;
  225. if (!WonX_IsCreated()) WonX_Create();
  226. /* タイマを一時停止する */
  227. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  228. printf("call : wonx_lcddraw_level_down() : \n");
  229. fflush(stdout);
  230. x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
  231. ret = XDisplay_LCDDrawLevelDown(x_display);
  232. WonXDisplay_Flush(WonX_GetWonXDisplay());
  233. printf("call : wonx_lcddraw_level_down() : return value = %d\n", ret);
  234. fflush(stdout);
  235. /* タイマをもとに戻す */
  236. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  237. return (ret);
  238. }
  239. /* 表示レベルを上げる */
  240. int wonx_lcddraw_level_up(void)
  241. {
  242. XDisplay x_display;
  243. int ret;
  244. if (!WonX_IsCreated()) WonX_Create();
  245. /* タイマを一時停止する */
  246. UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  247. printf("call : wonx_lcddraw_level_up() : \n");
  248. fflush(stdout);
  249. x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
  250. ret = XDisplay_LCDDrawLevelUp(x_display);
  251. WonXDisplay_Flush(WonX_GetWonXDisplay());
  252. printf("call : wonx_lcddraw_level_up() : return value = %d\n", ret);
  253. fflush(stdout);
  254. /* タイマをもとに戻す */
  255. UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
  256. return (ret);
  257. }
  258. /*****************************************************************************/
  259. /* End of File. */
  260. /*****************************************************************************/