disp.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. /*****************************************************************************/
  2. /* ここから */
  3. /*****************************************************************************/
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <sys/disp.h>
  7. #include "wonx.h"
  8. #include "WonxDisplay.h"
  9. /*****************************************************************************/
  10. /* メンバ関数の定義 */
  11. /*****************************************************************************/
  12. void display_control(unsigned int flags)
  13. {
  14. WWDisplay ww_display;
  15. printf("call : display_control() : flags = 0x%04x\n", (int)flags);
  16. fflush(stdout);
  17. if (wonx_display == NULL) Wonx_Create();
  18. ww_display = WonxDisplay_GetWWDisplay(wonx_display);
  19. WWScreen_SetEnable(WWDisplay_GetScreen(ww_display, SCREEN1),
  20. (flags & DCM_SCR1) ? 1 : 0);
  21. WWScreen_SetEnable(WWDisplay_GetScreen(ww_display, SCREEN2),
  22. (flags & DCM_SCR2) ? 1 : 0);
  23. WWDisplay_SetSpriteEnable(ww_display, (flags & DCM_SPR) ? 1 : 0);
  24. WWDisplay_SetSpriteWindowEnable(ww_display, (flags & DCM_SPR_WIN) ? 1 : 0);
  25. if ((flags & 0x0030) == DCM_SCR2_WIN_INSIDE)
  26. WWScreen_SetMode(WWDisplay_GetScreen(ww_display, SCREEN2),
  27. WWSCREEN_INSIDE_ONLY);
  28. else if ((flags & 0x0030) == DCM_SCR2_WIN_OUTSIDE)
  29. WWScreen_SetMode(WWDisplay_GetScreen(ww_display, SCREEN2),
  30. WWSCREEN_OUTSIDE_ONLY);
  31. WWDisplay_SetBorder(ww_display, (flags & DCM_BORDER_COLOR) >> 7);
  32. WonxDisplay_Flush(wonx_display);
  33. printf("call : display_control() : return value = none\n"); fflush(stdout);
  34. return;
  35. }
  36. unsigned int display_status()
  37. {
  38. WWDisplay ww_display;
  39. unsigned short int ret;
  40. printf("call : display_status() : \n"); fflush(stdout);
  41. if (wonx_display == NULL) Wonx_Create();
  42. ww_display = WonxDisplay_GetWWDisplay(wonx_display);
  43. ret = 0;
  44. if (WWScreen_GetEnable(WWDisplay_GetScreen(ww_display, SCREEN1)))
  45. ret |= DCM_SCR1;
  46. if (WWScreen_GetEnable(WWDisplay_GetScreen(ww_display, SCREEN2)))
  47. ret |= DCM_SCR2;
  48. if (WWDisplay_GetSpriteEnable(WonxDisplay_GetWWDisplay(wonx_display)))
  49. ret |= DCM_SPR;
  50. if (WWDisplay_GetSpriteWindowEnable(WonxDisplay_GetWWDisplay(wonx_display)))
  51. ret |= DCM_SPR_WIN;
  52. switch (WWScreen_GetMode(WWDisplay_GetScreen(ww_display, SCREEN2))) {
  53. case WWSCREEN_INSIDE_ONLY:
  54. ret |= DCM_SCR2_WIN_INSIDE;
  55. break;
  56. case WWSCREEN_OUTSIDE_ONLY:
  57. ret |= DCM_SCR2_WIN_OUTSIDE;
  58. break;
  59. default:
  60. }
  61. ret |= WWDisplay_GetBorder(WonxDisplay_GetWWDisplay(wonx_display)) << 7;
  62. WonxDisplay_Sync(wonx_display);
  63. printf("call : display_status() : return value = %u\n", (int)ret);
  64. fflush(stdout);
  65. return (ret);
  66. }
  67. void font_set_monodata(unsigned int number, unsigned int count, void * data)
  68. {
  69. WWCharacter c;
  70. int i, x, y, n, p;
  71. int f, b;
  72. unsigned char * d;
  73. printf("call : font_set_monodata() : number = %u, count = %u, data = %p\n",
  74. (int)number, (int)count, data); fflush(stdout);
  75. if (wonx_display == NULL) Wonx_Create();
  76. n = 0;
  77. d = (unsigned char *)data; /* ひとつのキャラクタデータは8バイト */
  78. f = WWDisplay_GetForegroundColor(WonxDisplay_GetWWDisplay(wonx_display));
  79. b = WWDisplay_GetBackgroundColor(WonxDisplay_GetWWDisplay(wonx_display));
  80. for (i = 0; i < count; i++) {
  81. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  82. number + i);
  83. for (y = 0; y < 8; y++) {
  84. for (x = 0; x < 8; x++) {
  85. p = (d[n] & (1 << (7 - x))) ? f : b; /*これでよいのか?*/
  86. WWCharacter_SetPixel(c, x, y, p);
  87. }
  88. n++;
  89. }
  90. }
  91. WonxDisplay_Flush(wonx_display);
  92. printf("call : font_set_monodata() : return value = none\n");
  93. fflush(stdout);
  94. return;
  95. }
  96. void font_set_colordata(unsigned int number,
  97. unsigned int count, void * data)
  98. {
  99. WWCharacter c;
  100. int i, x, y, n, p;
  101. int f, b;
  102. unsigned char * d;
  103. printf("call : font_set_colordata() : number = %u, count = %u, data = %p\n",
  104. (int)number, (int)count, data); fflush(stdout);
  105. if (wonx_display == NULL) Wonx_Create();
  106. n = 0;
  107. d = (unsigned char *)data; /* ひとつのキャラクタデータは16バイト */
  108. for (i = 0; i < count; i++) {
  109. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  110. number + i);
  111. for (y = 0; y < 8; y++) {
  112. for (x = 0; x < 8; x++) {
  113. /*これでよいのか?*/
  114. p = ((d[n] & (1 << (7-x))) ? 2 : 0) + ((d[n + 1] & (1 << (7-x))) ? 1 : 0);
  115. WWCharacter_SetPixel(c, x, y, p);
  116. }
  117. n++;
  118. n++;
  119. }
  120. }
  121. WonxDisplay_Flush(wonx_display);
  122. printf("call : font_set_colordata() : return value = none\n");
  123. fflush(stdout);
  124. return;
  125. }
  126. void font_get_data(unsigned int number,
  127. unsigned int count, void * data)
  128. {
  129. /* 関数の仕様がわからんので適当に書くぞ */
  130. WWCharacter c;
  131. int i, x, y, n, p;
  132. int f, b;
  133. unsigned char * d;
  134. printf("call : font_get_data() : number = %u, count = %u, data = %p\n",
  135. (int)number, (int)count, data); fflush(stdout);
  136. if (wonx_display == NULL) Wonx_Create();
  137. n = 0;
  138. d = (unsigned char *)data; /* ひとつのキャラクタデータは16バイト? */
  139. for (i = 0; i < count; i++) {
  140. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  141. number + i);
  142. for (y = 0; y < 8; y++) {
  143. d[n ] = 0;
  144. d[n+1] = 0;
  145. for (x = 0; x < 8; x++) {
  146. p = WWCharacter_GetPixel(c, x, y);
  147. /* これでよいのか? */
  148. d[n ] |= (((unsigned char)p & 0x02) ? 1 : 0) << (7-x);
  149. d[n+1] |= (((unsigned char)p & 0x01) ? 1 : 0) << (7-x);
  150. }
  151. n++;
  152. n++;
  153. }
  154. }
  155. WonxDisplay_Sync(wonx_display);
  156. printf("call : font_get_data() : return value = none\n"); fflush(stdout);
  157. return;
  158. }
  159. void font_set_color(unsigned int colors)
  160. {
  161. WWDisplay dis;
  162. printf("call : font_set_color() : colors = 0x%04x\n", (int)colors);
  163. fflush(stdout);
  164. if (wonx_display == NULL) Wonx_Create();
  165. dis = WonxDisplay_GetWWDisplay(wonx_display);
  166. WWDisplay_SetForegroundColor(dis, colors & 0x03);
  167. WWDisplay_SetBackgroundColor(dis, (colors >> 2) & 0x03);
  168. WonxDisplay_Flush(wonx_display);
  169. printf("call : font_set_color() : return value = none\n"); fflush(stdout);
  170. return;
  171. }
  172. unsigned int font_get_color(void)
  173. {
  174. unsigned short int ret;
  175. WWDisplay dis;
  176. printf("call : font_get_color() : \n"); fflush(stdout);
  177. if (wonx_display == NULL) Wonx_Create();
  178. dis = WonxDisplay_GetWWDisplay(wonx_display);
  179. ret = 0;
  180. ret |= WWDisplay_GetForegroundColor(dis);
  181. ret |= WWDisplay_GetBackgroundColor(dis) << 2;
  182. WonxDisplay_Sync(wonx_display);
  183. printf("call : font_get_color() : return value = 0x%04x\n", (int)ret);
  184. fflush(stdout);
  185. return (ret);
  186. }
  187. void screen_set_char(int screen, int x, int y, int w, int h, void * data)
  188. {
  189. int i, j;
  190. int horizontal; /* 横方向反転フラグ */
  191. int vertical; /* 縦方向反転フラグ */
  192. int palette_num; /* パレット番号 */
  193. int character_num; /* 表示キャラクタ */
  194. unsigned short int * d;
  195. WWScreen s;
  196. WWPalette p;
  197. WWCharacter c;
  198. printf("call : screen_set_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p\n",
  199. screen, x, y, w, h, data); fflush(stdout);
  200. if (wonx_display == NULL) Wonx_Create();
  201. d = (unsigned short int *)data;
  202. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  203. for (j = 0; j < h; j++) {
  204. for (i = 0; i < w; i++) {
  205. horizontal = (*d & (1 << 15)) ? 1 : 0;
  206. vertical = (*d & (1 << 14)) ? 1 : 0;
  207. palette_num = (*d >> 9) & 0x0f;
  208. character_num = *d & 0x1ff;
  209. p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
  210. palette_num);
  211. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  212. character_num);
  213. WWScreen_SetHorizontal(s, x + i, y + j, horizontal);
  214. WWScreen_SetVertical( s, x + i, y + j, vertical);
  215. WWScreen_SetPalette( s, x + i, y + j, p);
  216. WWScreen_SetCharacter( s, x + i, y + j, c);
  217. d++;
  218. }
  219. }
  220. WonxDisplay_Flush(wonx_display);
  221. printf("call : screen_set_char() : return value = none\n"); fflush(stdout);
  222. return;
  223. }
  224. void screen_get_char(int screen, int x, int y, int w, int h, void * data)
  225. {
  226. int i, j;
  227. int horizontal; /* 横方向反転フラグ */
  228. int vertical; /* 縦方向反転フラグ */
  229. int palette_num; /* パレット番号 */
  230. int character_num; /* 表示キャラクタ */
  231. unsigned short int * d;
  232. WWScreen s;
  233. WWPalette p;
  234. WWCharacter c;
  235. printf("call : screen_get_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p\n",
  236. screen, x, y, w, h, data); fflush(stdout);
  237. if (wonx_display == NULL) Wonx_Create();
  238. d = (unsigned short int *)data;
  239. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  240. for (j = 0; j < h; j++) {
  241. for (i = 0; i < w; i++) {
  242. horizontal = WWScreen_GetHorizontal(s, x + i, y + j);
  243. vertical = WWScreen_GetVertical( s, x + i, y + j);
  244. p = WWScreen_GetPalette( s, x + i, y + j);
  245. c = WWScreen_GetCharacter( s, x + i, y + j);
  246. palette_num = WWPalette_GetNumber(p);
  247. character_num = WWCharacter_GetNumber(c);
  248. *d = 0;
  249. *d |= horizontal << 15;
  250. *d |= vertical << 14;
  251. *d |= palette_num << 9;
  252. *d |= character_num;
  253. d++;
  254. }
  255. }
  256. WonxDisplay_Sync(wonx_display);
  257. printf("call : screen_get_char() : return value = none\n"); fflush(stdout);
  258. return;
  259. }
  260. unsigned int screen_get_char1(int screen, int x, int y)
  261. {
  262. int horizontal; /* 横方向反転フラグ */
  263. int vertical; /* 縦方向反転フラグ */
  264. int palette_num; /* パレット番号 */
  265. int character_num; /* 表示キャラクタ */
  266. WWScreen s;
  267. WWPalette p;
  268. WWCharacter c;
  269. unsigned short int ret;
  270. printf("call : screen_get_char1() : screen = %d, x = %d, y = %d\n",
  271. screen, x, y);
  272. fflush(stdout);
  273. if (wonx_display == NULL) Wonx_Create();
  274. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  275. horizontal = WWScreen_GetHorizontal(s, x, y);
  276. vertical = WWScreen_GetVertical( s, x, y);
  277. p = WWScreen_GetPalette( s, x, y);
  278. c = WWScreen_GetCharacter( s, x, y);
  279. palette_num = WWPalette_GetNumber(p);
  280. character_num = WWCharacter_GetNumber(c);
  281. ret = 0;
  282. ret |= horizontal << 15;
  283. ret |= vertical << 14;
  284. ret |= palette_num << 9;
  285. ret |= character_num;
  286. WonxDisplay_Sync(wonx_display);
  287. printf("call : screen_get_char1() : return value = 0x%04x\n", (int)ret);
  288. fflush(stdout);
  289. return (ret);
  290. }
  291. void screen_fill_char(int screen, int x, int y, int w, int h,
  292. unsigned int data)
  293. {
  294. int i, j;
  295. int horizontal; /* 横方向反転フラグ */
  296. int vertical; /* 縦方向反転フラグ */
  297. int palette_num; /* パレット番号 */
  298. int character_num; /* 表示キャラクタ */
  299. WWScreen s;
  300. WWPalette p;
  301. WWCharacter c;
  302. printf("call : screen_fill_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x\n",
  303. screen, x, y, w, h, (int)data); fflush(stdout);
  304. if (wonx_display == NULL) Wonx_Create();
  305. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  306. horizontal = (data & (1 << 15)) ? 1 : 0;
  307. vertical = (data & (1 << 14)) ? 1 : 0;
  308. palette_num = (data >> 9) & 0x0f;
  309. character_num = data & 0x1ff;
  310. p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
  311. palette_num);
  312. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  313. character_num);
  314. for (j = 0; j < h; j++) {
  315. for (i = 0; i < w; i++) {
  316. WWScreen_SetHorizontal(s, x + i, y + j, horizontal);
  317. WWScreen_SetVertical( s, x + i, y + j, vertical);
  318. WWScreen_SetPalette( s, x + i, y + j, p);
  319. WWScreen_SetCharacter( s, x + i, y + j, c);
  320. }
  321. }
  322. WonxDisplay_Flush(wonx_display);
  323. printf("call : screen_fill_char() : return value = none\n"); fflush(stdout);
  324. return;
  325. }
  326. void screen_fill_attr(int screen, int x, int y, int w, int h,
  327. unsigned int data, unsigned int mask)
  328. {
  329. int i, j;
  330. unsigned short int c;
  331. printf("call : screen_fill_attr() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x, mask = 0x%04x\n",
  332. screen, x, y, w, h, (int)data, (int)mask); fflush(stdout);
  333. if (wonx_display == NULL) Wonx_Create();
  334. for (j = 0; j < h; j++) {
  335. for (i = 0; i < w; i++) {
  336. c = screen_get_char1(screen, x + i, y + j);
  337. c &= mask;
  338. c |= data;
  339. screen_fill_char(screen, x + i, y + j, 1, 1, c);
  340. }
  341. }
  342. WonxDisplay_Flush(wonx_display);
  343. printf("call : screen_fill_attr() : return value = none\n"); fflush(stdout);
  344. return;
  345. }
  346. void sprite_set_range(unsigned int sprite_start, unsigned int sprite_count)
  347. {
  348. printf("call : sprite_set_range() : start = %u, count = %u\n",
  349. (int)sprite_start, (int)sprite_count); fflush(stdout);
  350. if (wonx_display == NULL) Wonx_Create();
  351. WWDisplay_SetSpriteStart(WonxDisplay_GetWWDisplay(wonx_display),
  352. sprite_start);
  353. WWDisplay_SetSpriteCount(WonxDisplay_GetWWDisplay(wonx_display),
  354. sprite_count);
  355. WonxDisplay_Flush(wonx_display);
  356. printf("call : sprite_set_range() : return value = none\n"); fflush(stdout);
  357. return;
  358. }
  359. void sprite_set_char(unsigned int sprite_num, unsigned int data)
  360. {
  361. WWSprite s;
  362. WWPalette p;
  363. WWCharacter c;
  364. printf("call : sprite_set_char() : number = %u, data = 0x%04x\n",
  365. (int)sprite_num, (int)data); fflush(stdout);
  366. if (wonx_display == NULL) Wonx_Create();
  367. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  368. WWSprite_SetHorizontal(s, (data >> 15) ? 1 : 0);
  369. WWSprite_SetVertical( s, (data >> 14) ? 1 : 0);
  370. WWSprite_SetPriority( s, (data >> 13) ? 1 : 0);
  371. WWSprite_SetClipping( s, (data >> 12) ? 1 : 0);
  372. p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
  373. (data >> 9) & 0x07);
  374. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  375. data & 0x1ff);
  376. WWSprite_SetPalette(s, p);
  377. WWSprite_SetCharacter(s, c);
  378. WonxDisplay_Flush(wonx_display);
  379. printf("call : sprite_set_char() : return value = none\n"); fflush(stdout);
  380. return;
  381. }
  382. unsigned int sprite_get_char(unsigned int sprite_num)
  383. {
  384. WWSprite s;
  385. WWPalette p;
  386. WWCharacter c;
  387. unsigned short int ret;
  388. printf("call : sprite_get_char() : number = %u\n", (int)sprite_num);
  389. fflush(stdout);
  390. if (wonx_display == NULL) Wonx_Create();
  391. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  392. ret = 0;
  393. ret |= (WWSprite_GetHorizontal(s) ? 1 : 0) << 15;
  394. ret |= (WWSprite_GetVertical( s) ? 1 : 0) << 14;
  395. ret |= (WWSprite_GetPriority( s) ? 1 : 0) << 13;
  396. ret |= (WWSprite_GetClipping( s) ? 1 : 0) << 12;
  397. p = WWSprite_GetPalette(s);
  398. ret |= (WWPalette_GetNumber(p) & 0x07) << 9;
  399. c = WWSprite_GetCharacter(s);
  400. ret |= WWCharacter_GetNumber(c);
  401. WonxDisplay_Sync(wonx_display);
  402. printf("call : sprite_get_char() : return value = 0x%04x\n", (int)ret);
  403. fflush(stdout);
  404. return (ret);
  405. }
  406. void sprite_set_location(unsigned int sprite_num, int x, int y)
  407. {
  408. WWSprite s;
  409. printf("call : sprite_set_location() : number = %u, x = %d, y = %d\n",
  410. (int)sprite_num, x, y); fflush(stdout);
  411. if (wonx_display == NULL) Wonx_Create();
  412. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  413. WWSprite_SetPosition(s, x, y);
  414. WonxDisplay_Flush(wonx_display);
  415. printf("call : sprite_set_location() : return value = none\n");
  416. fflush(stdout);
  417. return;
  418. }
  419. unsigned int sprite_get_location(unsigned int sprite_num)
  420. {
  421. WWSprite s;
  422. unsigned short int ret;
  423. printf("call : sprite_get_location() : number = %u\n", (int)sprite_num);
  424. fflush(stdout);
  425. if (wonx_display == NULL) Wonx_Create();
  426. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  427. ret = (WWSprite_GetY(s) << 8) | WWSprite_GetX(s);
  428. WonxDisplay_Sync(wonx_display);
  429. printf("call : sprite_get_location() : return value = 0x%04x\n", (int)ret);
  430. fflush(stdout);
  431. return (ret);
  432. }
  433. void sprite_set_char_location(unsigned int sprite_num,
  434. unsigned int data, int x, int y)
  435. {
  436. if (wonx_display == NULL) Wonx_Create();
  437. printf("call : sprite_set_char_location() : number = %u, data = 0x%04x, x = %d, y = %d\n",
  438. (int)sprite_num, (int)data, x, y); fflush(stdout);
  439. sprite_set_char(sprite_num, data);
  440. sprite_set_location(sprite_num, x, y);
  441. WonxDisplay_Flush(wonx_display);
  442. printf("call : sprite_set_char_location() : return value = none\n");
  443. fflush(stdout);
  444. return;
  445. }
  446. unsigned long int sprite_get_char_location(unsigned int sprite_num)
  447. {
  448. unsigned long int ret;
  449. printf("call : sprite_get_char_location() : number = %u\n", (int)sprite_num);
  450. fflush(stdout);
  451. if (wonx_display == NULL) Wonx_Create();
  452. ret = 0;
  453. ret |= ((unsigned long int)sprite_get_char(sprite_num));
  454. ret |= (unsigned long int)sprite_get_location(sprite_num) << 16;
  455. WonxDisplay_Sync(wonx_display);
  456. printf("call : sprite_get_char_location() : return value = 0x%08x\n",
  457. (int)ret);
  458. fflush(stdout);
  459. return (ret);
  460. }
  461. void sprite_set_data(unsigned int sprite_num, unsigned int count, void * data)
  462. {
  463. int i;
  464. char * d;
  465. unsigned long int * n;
  466. printf("call : sprite_set_data() : number = %u, count = %u, data = %p\n",
  467. (int)sprite_num, (int)count, data); fflush(stdout);
  468. if (wonx_display == NULL) Wonx_Create();
  469. n = (unsigned long int *)data;
  470. for (i = 0; i < count; i++) {
  471. sprite_set_char_location(sprite_num + i,
  472. n[i] >> 16,
  473. (n[i] >> 8) & 0xff,
  474. n[i] & 0xff);
  475. }
  476. WonxDisplay_Flush(wonx_display);
  477. printf("call : sprite_set_data() : return value = none\n"); fflush(stdout);
  478. return;
  479. }
  480. void screen_set_scroll(int screen, int x, int y)
  481. {
  482. WWScreen s;
  483. printf("call : screen_set_scroll() : screen = %d, x = %d, y = %d\n",
  484. screen, x, y); fflush(stdout);
  485. if (wonx_display == NULL) Wonx_Create();
  486. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  487. WWScreen_SetRollX(s, x);
  488. WWScreen_SetRollY(s, y);
  489. WonxDisplay_Flush(wonx_display);
  490. printf("call : screen_set_scroll() : return value = none\n"); fflush(stdout);
  491. return;
  492. }
  493. unsigned int screen_get_scroll(int screen)
  494. {
  495. unsigned short int ret;
  496. WWScreen s;
  497. printf("call : screen_get_scroll() : screen = %d\n", screen); fflush(stdout);
  498. if (wonx_display == NULL) Wonx_Create();
  499. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  500. ret = 0;
  501. ret |= WWScreen_GetRollX(s);
  502. ret |= WWScreen_GetRollY(s) << 8;
  503. WonxDisplay_Sync(wonx_display);
  504. printf("call : screen_get_scroll() : return value = %u\n", (int)ret);
  505. fflush(stdout);
  506. return (ret);
  507. }
  508. void screen2_set_window(int x, int y, int w, int h)
  509. {
  510. WWScreen s;
  511. printf("call : screen2_set_window() : x = %d, y = %d, width = %d, height = %d\n",
  512. x, y, w, h); fflush(stdout);
  513. if (wonx_display == NULL) Wonx_Create();
  514. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2);
  515. WWScreen_SetDrawX(s, x);
  516. WWScreen_SetDrawY(s, y);
  517. WWScreen_SetDrawWidth( s, w);
  518. WWScreen_SetDrawHeight(s, h);
  519. WonxDisplay_Flush(wonx_display);
  520. printf("call : screen2_set_window() : return value = none\n");
  521. fflush(stdout);
  522. return;
  523. }
  524. unsigned long int screen2_get_window(void)
  525. {
  526. WWScreen s;
  527. unsigned short int xy;
  528. unsigned short int wh;
  529. unsigned long int ret;
  530. if (wonx_display == NULL) Wonx_Create();
  531. printf("call : screen2_get_window() : \n"); fflush(stdout);
  532. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2);
  533. xy =
  534. (((unsigned short int)WWScreen_GetDrawY(s) << 8) & 0xff00) |
  535. ((unsigned short int)WWScreen_GetDrawX(s) & 0x00ff);
  536. wh =
  537. (((unsigned short int)WWScreen_GetDrawHeight(s) << 8) & 0xff00) |
  538. ((unsigned short int)WWScreen_GetDrawWidth(s) & 0x00ff);
  539. ret = ((unsigned long int)wh) << 16 | xy;
  540. WonxDisplay_Sync(wonx_display);
  541. printf("call : screen2_get_window() : return value = 0x%08x\n", (int)ret);
  542. fflush(stdout);
  543. return (ret);
  544. }
  545. void sprite_set_window(int x, int y, int w, int h)
  546. {
  547. WWDisplay d;
  548. printf("call : sprite_set_window() : x = %d, y = %d, w = %d, h = %d\n",
  549. x, y, w, h);
  550. fflush(stdout);
  551. if (wonx_display == NULL) Wonx_Create();
  552. d = WonxDisplay_GetWWDisplay(wonx_display);
  553. WWDisplay_SetSpriteWindowX(d, x);
  554. WWDisplay_SetSpriteWindowY(d, y);
  555. WWDisplay_SetSpriteWindowWidth(d, w);
  556. WWDisplay_SetSpriteWindowHeight(d, h);
  557. WonxDisplay_Flush(wonx_display);
  558. printf("call : sprite_set_window() : return value = none\n");
  559. fflush(stdout);
  560. return;
  561. }
  562. unsigned long int sprite_get_window(void)
  563. {
  564. WWDisplay d;
  565. unsigned short int xy;
  566. unsigned short int wh;
  567. unsigned long int ret;
  568. printf("call : sprite_get_window() : \n");
  569. fflush(stdout);
  570. if (wonx_display == NULL) Wonx_Create();
  571. d = WonxDisplay_GetWWDisplay(wonx_display);
  572. xy =
  573. (((unsigned short int)WWDisplay_GetSpriteWindowY(d) << 8) & 0xff00) |
  574. ((unsigned short int)WWDisplay_GetSpriteWindowX(d) & 0x00ff);
  575. wh =
  576. (((unsigned short int)WWDisplay_GetSpriteWindowHeight(d) << 8) & 0xff00) |
  577. ((unsigned short int)WWDisplay_GetSpriteWindowWidth(d) & 0x00ff);
  578. ret = ((unsigned long int)wh) << 16 | xy;
  579. WonxDisplay_Sync(wonx_display);
  580. printf("call : sprite_get_window() : return value = 0x%08x\n", (int)ret);
  581. fflush(stdout);
  582. return (ret);
  583. }
  584. void palette_set_color(unsigned int palette_num,
  585. unsigned int colors)
  586. {
  587. int mapped_colors[4];
  588. WWPalette palette;
  589. printf("call : palette_set_color() : number = %u, colors = 0x%04x\n",
  590. (int)palette_num, (int)colors); fflush(stdout);
  591. if (wonx_display == NULL) Wonx_Create();
  592. mapped_colors[0] = colors & 0x07;
  593. mapped_colors[1] = (colors >> 4) & 0x07;
  594. mapped_colors[2] = (colors >> 8) & 0x07;
  595. mapped_colors[3] = (colors >> 12) & 0x07;
  596. palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), palette_num);
  597. WWPalette_SetMappedColors(palette, mapped_colors);
  598. WonxDisplay_Flush(wonx_display);
  599. printf("call : palette_set_color() : return value = none\n"); fflush(stdout);
  600. return;
  601. }
  602. unsigned int palette_get_color(unsigned int palette_num)
  603. {
  604. int mapped_colors[4];
  605. WWPalette palette;
  606. unsigned short int ret;
  607. printf("call : palette_get_color() : number = %u\n", (int)palette_num);
  608. fflush(stdout);
  609. if (wonx_display == NULL) Wonx_Create();
  610. palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
  611. palette_num);
  612. WWPalette_GetMappedColors(palette, mapped_colors);
  613. ret = 0;
  614. ret |= mapped_colors[0] & 0x07;
  615. ret |= (mapped_colors[1] & 0x07) << 4;
  616. ret |= (mapped_colors[2] & 0x07) << 8;
  617. ret |= (mapped_colors[3] & 0x07) << 12;
  618. WonxDisplay_Sync(wonx_display);
  619. printf("call : palette_get_color() : return value = %u\n", (int)ret);
  620. fflush(stdout);
  621. return (ret);
  622. }
  623. void lcd_set_color(unsigned int colors0, unsigned int colors1)
  624. {
  625. WWColorMap color_map;
  626. int lcd_colors[8];
  627. printf("call : lcd_set_color() : colors0 = 0x%04x, colors1 = 0x%04x\n",
  628. (int)colors0, (int)colors1); fflush(stdout);
  629. if (wonx_display == NULL) Wonx_Create();
  630. lcd_colors[0] = colors0 & 0x0f;
  631. lcd_colors[1] = (colors0 >> 4) & 0x0f;
  632. lcd_colors[2] = (colors0 >> 8) & 0x0f;
  633. lcd_colors[3] = (colors0 >> 12) & 0x0f;
  634. lcd_colors[4] = colors1 & 0x0f;
  635. lcd_colors[5] = (colors1 >> 4) & 0x0f;
  636. lcd_colors[6] = (colors1 >> 8) & 0x0f;
  637. lcd_colors[7] = (colors1 >> 12) & 0x0f;
  638. color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(wonx_display));
  639. WWColorMap_SetLCDColors(color_map, lcd_colors);
  640. WonxDisplay_Flush(wonx_display);
  641. printf("call : lcd_set_color() : return value = none\n"); fflush(stdout);
  642. return;
  643. }
  644. unsigned long int lcd_get_color(void)
  645. {
  646. WWColorMap color_map;
  647. int lcd_colors[8];
  648. unsigned long int ret;
  649. printf("call : lcd_get_color() : \n"); fflush(stdout);
  650. if (wonx_display == NULL) Wonx_Create();
  651. color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(wonx_display));
  652. WWColorMap_GetLCDColors(color_map, lcd_colors);
  653. ret = 0;
  654. ret |= (unsigned long int)lcd_colors[0] & 0x0f;
  655. ret |= ((unsigned long int)lcd_colors[1] & 0x0f) << 4;
  656. ret |= ((unsigned long int)lcd_colors[2] & 0x0f) << 8;
  657. ret |= ((unsigned long int)lcd_colors[3] & 0x0f) << 12;
  658. ret |= (unsigned long int)lcd_colors[0] & 0x0f;
  659. ret |= ((unsigned long int)lcd_colors[1] & 0x0f) << 4;
  660. ret |= ((unsigned long int)lcd_colors[2] & 0x0f) << 8;
  661. ret |= ((unsigned long int)lcd_colors[3] & 0x0f) << 12;
  662. WonxDisplay_Sync(wonx_display);
  663. printf("call : lcd_get_color() : return value = 0x%08x\n", (int)ret);
  664. fflush(stdout);
  665. return (ret);
  666. }
  667. void lcd_set_segments(unsigned segments)
  668. {
  669. if (wonx_display == NULL) Wonx_Create();
  670. /* セグメント表示は未サポートか? */
  671. WonxDisplay_Flush(wonx_display);
  672. }
  673. unsigned lcd_get_segments(void)
  674. {
  675. if (wonx_display == NULL) Wonx_Create();
  676. /* セグメント表示は未サポートか? */
  677. WonxDisplay_Sync(wonx_display);
  678. }
  679. void lcd_set_sleep(unsigned sleep)
  680. {
  681. if (wonx_display == NULL) Wonx_Create();
  682. /* ? */
  683. WonxDisplay_Sync(wonx_display);
  684. }
  685. unsigned lcd_get_sleep(void)
  686. {
  687. if (wonx_display == NULL) Wonx_Create();
  688. /* ? */
  689. WonxDisplay_Sync(wonx_display);
  690. }
  691. void screen_set_vram(int screen, int locationID)
  692. {
  693. if (wonx_display == NULL) Wonx_Create();
  694. WonxDisplay_Sync(wonx_display);
  695. }
  696. void sprite_set_vram(int locationID)
  697. {
  698. if (wonx_display == NULL) Wonx_Create();
  699. WonxDisplay_Sync(wonx_display);
  700. }
  701. /*****************************************************************************/
  702. /* ここまで */
  703. /*****************************************************************************/
  704. /*****************************************************************************/
  705. /* End of File. */
  706. /*****************************************************************************/