disp.c 25 KB

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