disp.c 21 KB

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