text.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <sys/text.h>
  4. #include "Wonx.h"
  5. #include "WWText.h"
  6. static void _text_window_init(int x, int y, int w, int h, unsigned font_base)
  7. {
  8. WWText ww_text;
  9. WWDisplay ww_display;
  10. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  11. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  12. WWText_SetTextWindow(ww_text, x, y, w, h, font_base, ww_display);
  13. WWScreen_SetRollX(WWText_GetScreen(ww_text), 0);
  14. WWScreen_SetRollY(WWText_GetScreen(ww_text), 0);
  15. return;
  16. }
  17. void text_screen_init(void)
  18. {
  19. WWDisplay ww_display;
  20. WWLCDPanel ww_lcd_panel;
  21. printf("call : text_screen_init() : \n");
  22. fflush(stdout);
  23. if (!Wonx_IsCreated()) Wonx_Create();
  24. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  25. ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
  26. _text_window_init(0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT, 8);
  27. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  28. printf("call : text_screen_init() : return value = none\n"); fflush(stdout);
  29. return;
  30. }
  31. void text_window_init(int x, int y, int w, int h, unsigned int font_base)
  32. {
  33. WWDisplay ww_display;
  34. printf("call : text_window_init() : x = %d, y = %d, width = %d, height = %d, base = %u\n", x, y, w, h, (int)font_base);
  35. fflush(stdout);
  36. if (!Wonx_IsCreated()) Wonx_Create();
  37. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  38. _text_window_init(x, y, w, h, font_base);
  39. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  40. printf("call : text_screen_init() : return value = none\n"); fflush(stdout);
  41. return;
  42. }
  43. void text_set_mode(int mode)
  44. {
  45. }
  46. int text_get_mode(void)
  47. {
  48. return (0);
  49. }
  50. void _text_put_char(int x, int y, unsigned int c)
  51. {
  52. WWText ww_text;
  53. WWDisplay ww_display;
  54. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  55. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  56. WWText_PutCharacter(ww_text, x, y, c, ww_display);
  57. return;
  58. }
  59. void text_put_char(int x, int y, unsigned int c)
  60. {
  61. printf("call : text_put_char() : x = %d, y = %d, character = %u\n", x, y, (int)c);
  62. fflush(stdout);
  63. if (!Wonx_IsCreated()) Wonx_Create();
  64. _text_put_char(x, y, c);
  65. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  66. printf("call : text_put_char() : return value = none\n"); fflush(stdout);
  67. return;
  68. }
  69. static int _text_put_string(int x, int y, char * s)
  70. {
  71. int i, len, ret;
  72. WWText ww_text;
  73. WWDisplay ww_display;
  74. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  75. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  76. len = strlen(s);
  77. ret = 0;
  78. for (i = 0; i < len; i++) {
  79. if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0)
  80. ret++;
  81. }
  82. return (ret);
  83. }
  84. int text_put_string(int x, int y, char * s)
  85. {
  86. int ret;
  87. printf("call : text_put_string() : x = %d, y = %d, string = %s\n", x, y, s);
  88. fflush(stdout);
  89. if (!Wonx_IsCreated()) Wonx_Create();
  90. ret = _text_put_string(x, y, s);
  91. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  92. printf("call : text_put_string() : return value = %d\n", ret);
  93. fflush(stdout);
  94. return (ret);
  95. }
  96. int text_put_substring(int x, int y, char * s, int len)
  97. {
  98. int i, ret;
  99. WWText ww_text;
  100. WWDisplay ww_display;
  101. printf("call : text_put_substring() : x = %d, y = %d, string = %s, length = %d\n", x, y, s, len);
  102. fflush(stdout);
  103. if (!Wonx_IsCreated()) Wonx_Create();
  104. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  105. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  106. ret = 0;
  107. for (i = 0; i < len; i++) {
  108. if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0)
  109. ret++;
  110. }
  111. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  112. printf("call : text_put_substring() : return value = %d\n", ret);
  113. fflush(stdout);
  114. return (ret);
  115. }
  116. void text_put_numeric(int x, int y, int len, int format, int number)
  117. {
  118. char buf[20];
  119. char f[20];
  120. printf("call : text_put_numeric() : x = %d, y = %d, len = %d, format = %04x, number = %d\n", x, y, len, format, number);
  121. fflush(stdout);
  122. if (!Wonx_IsCreated()) Wonx_Create();
  123. strcpy(f, "%");
  124. if (format & NUM_PADZERO) strcat(f, "0");
  125. sprintf(f + strlen(f), "%d", len);
  126. if (format & NUM_HEXA) strcat(f, "x");
  127. else if (format & NUM_SIGNED) strcat(f, "d");
  128. else strcat(f, "u");
  129. if (format & NUM_ALIGN_LEFT) { /* ̤¼ÂÁõ */ }
  130. sprintf(buf, f, number);
  131. _text_put_string(x, y, buf);
  132. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  133. printf("call : text_put_numeric() : return value = none\n");
  134. fflush(stdout);
  135. return;
  136. }
  137. void text_store_numeric(char * buffer, int len, int format, int number)
  138. {
  139. }
  140. void text_fill_char(int x, int y, int len, int code)
  141. {
  142. int i;
  143. printf("call : text_fill_char() : x = %d, y = %d, length = %d, code = %d\n", x, y, len, code);
  144. fflush(stdout);
  145. if (!Wonx_IsCreated()) Wonx_Create();
  146. for (i = 0; i < len; i++) {
  147. _text_put_char(x + i, y, code);
  148. }
  149. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  150. printf("call : text_fill_char() : return value = none\n");
  151. fflush(stdout);
  152. return;
  153. }
  154. void text_set_palette(int palette_num)
  155. {
  156. WWText ww_text;
  157. WWDisplay ww_display;
  158. printf("call : text_set_palette() : palette = %d\n", palette_num);
  159. fflush(stdout);
  160. if (!Wonx_IsCreated()) Wonx_Create();
  161. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  162. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  163. WWText_SetPalette(ww_text, WWDisplay_GetPalette(ww_display, palette_num));
  164. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  165. printf("call : text_set_palette() : return value = none\n");
  166. fflush(stdout);
  167. return;
  168. }
  169. int text_get_palette(void)
  170. {
  171. WWText ww_text;
  172. int num;
  173. printf("call : text_get_palette() : \n");
  174. fflush(stdout);
  175. if (!Wonx_IsCreated()) Wonx_Create();
  176. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  177. num = WWPalette_GetNumber(WWText_GetPalette(ww_text));
  178. WonxDisplay_Sync(Wonx_GetWonxDisplay());
  179. printf("call : text_get_palette() : return value = %d\n", num);
  180. fflush(stdout);
  181. return (num);
  182. }
  183. void text_set_ank_font(int font_base_num, int is_color, int font_count,
  184. void * font)
  185. {
  186. }
  187. void text_set_sjis_font(void * font_address)
  188. {
  189. }
  190. void text_get_fontdata(int char_code, void * fontdata_buffer)
  191. {
  192. }
  193. void text_set_screen(int screen)
  194. {
  195. WWText ww_text;
  196. WWDisplay ww_display;
  197. printf("call : text_set_screen() : screen = %d\n", screen);
  198. fflush(stdout);
  199. if (!Wonx_IsCreated()) Wonx_Create();
  200. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  201. ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
  202. WWText_SetScreen(ww_text, WWDisplay_GetScreen(ww_display, screen));
  203. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  204. printf("call : text_set_screen() : return value = none\n");
  205. fflush(stdout);
  206. return;
  207. }
  208. int text_get_screen(void)
  209. {
  210. WWText ww_text;
  211. int n;
  212. printf("call : text_get_screen() : \n");
  213. fflush(stdout);
  214. if (!Wonx_IsCreated()) Wonx_Create();
  215. ww_text = WonxText_GetWWText(Wonx_GetWonxText());
  216. n = WWScreen_GetNumber(WWText_GetScreen(ww_text));
  217. WonxDisplay_Flush(Wonx_GetWonxDisplay());
  218. printf("call : text_set_screen() : return value = %d\n", n);
  219. fflush(stdout);
  220. return (n);
  221. }
  222. void cursor_display(int cursor_enable)
  223. {
  224. }
  225. int cursor_status(void)
  226. {
  227. return (0);
  228. }
  229. void cursor_set_location(int x, int y, int w, int h)
  230. {
  231. }
  232. unsigned long cursor_get_location(void)
  233. {
  234. return (0);
  235. }
  236. void cursor_set_type(int palette_num, int blink_interval)
  237. {
  238. }
  239. unsigned long cursor_get_type(void)
  240. {
  241. return (0);
  242. }
  243. int text_printf(int x, int y, const char *format, ...)
  244. {
  245. return (0);
  246. }