disp.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  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, ", (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("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() : "); 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_Flush(wonx_display);
  63. printf("return value = %u\n", (int)ret); 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, ",
  73. (int)number, (int)count, data); fflush(stdout);
  74. if (wonx_display == NULL) Wonx_Create();
  75. n = 0;
  76. d = (unsigned char *)data; /* ひとつのキャラクタデータは8バイト */
  77. f = WWDisplay_GetForegroundColor(WonxDisplay_GetWWDisplay(wonx_display));
  78. b = WWDisplay_GetBackgroundColor(WonxDisplay_GetWWDisplay(wonx_display));
  79. for (i = 0; i < count; i++) {
  80. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  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_display);
  91. printf("return value = none\n"); fflush(stdout);
  92. return;
  93. }
  94. void font_set_colordata(unsigned int number,
  95. unsigned int count, void * data)
  96. {
  97. WWCharacter c;
  98. int i, x, y, n, p;
  99. int f, b;
  100. unsigned char * d;
  101. printf("call : font_set_colordata() : number = %u, count = %u, data = %p, ",
  102. (int)number, (int)count, data); fflush(stdout);
  103. if (wonx_display == NULL) 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_display),
  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_display);
  120. printf("return value = none\n"); fflush(stdout);
  121. return;
  122. }
  123. void font_get_data(unsigned int number,
  124. unsigned int count, void * data)
  125. {
  126. /* 関数の仕様がわからんので適当に書くぞ */
  127. WWCharacter c;
  128. int i, x, y, n, p;
  129. int f, b;
  130. unsigned char * d;
  131. printf("call : font_get_data() : number = %u, count = %u, data = %p, ",
  132. (int)number, (int)count, data); fflush(stdout);
  133. if (wonx_display == NULL) 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_display),
  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_Flush(wonx_display);
  153. printf("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, ", (int)colors);
  160. fflush(stdout);
  161. if (wonx_display == NULL) Wonx_Create();
  162. dis = WonxDisplay_GetWWDisplay(wonx_display);
  163. WWDisplay_SetForegroundColor(dis, colors & 0x03);
  164. WWDisplay_SetBackgroundColor(dis, (colors >> 2) & 0x03);
  165. WonxDisplay_Flush(wonx_display);
  166. printf("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() : "); fflush(stdout);
  174. if (wonx_display == NULL) Wonx_Create();
  175. dis = WonxDisplay_GetWWDisplay(wonx_display);
  176. ret = 0;
  177. ret |= WWDisplay_GetForegroundColor(dis);
  178. ret |= WWDisplay_GetBackgroundColor(dis) << 2;
  179. WonxDisplay_Flush(wonx_display);
  180. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  181. return (ret);
  182. }
  183. void screen_set_char(int screen, int x, int y, int w, int h, void * data)
  184. {
  185. int i, j;
  186. int horizontal; /* 横方向反転フラグ */
  187. int vertical; /* 縦方向反転フラグ */
  188. int palette_num; /* パレット番号 */
  189. int character_num; /* 表示キャラクタ */
  190. unsigned short int * d;
  191. WWScreen s;
  192. WWPalette p;
  193. WWCharacter c;
  194. printf("call : screen_set_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p",
  195. screen, x, y, w, h, data); fflush(stdout);
  196. if (wonx_display == NULL) Wonx_Create();
  197. d = (unsigned short int *)data;
  198. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  199. for (j = 0; j < h; j++) {
  200. for (i = 0; i < w; i++) {
  201. horizontal = (*d & (1 << 15)) ? 1 : 0;
  202. vertical = (*d & (1 << 14)) ? 1 : 0;
  203. palette_num = (*d >> 9) & 0x0f;
  204. character_num = *d & 0x1ff;
  205. p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
  206. palette_num);
  207. c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
  208. character_num);
  209. WWScreen_SetHorizontal(s, x + i, y + j, horizontal);
  210. WWScreen_SetVertical( s, x + i, y + j, vertical);
  211. WWScreen_SetPalette( s, x + i, y + j, p);
  212. WWScreen_SetCharacter( s, x + i, y + j, c);
  213. d++;
  214. }
  215. }
  216. WonxDisplay_Flush(wonx_display);
  217. printf("return value = none\n"); fflush(stdout);
  218. return;
  219. }
  220. void screen_get_char(int screen, int x, int y, int w, int h, void * data)
  221. {
  222. int i, j;
  223. int horizontal; /* 横方向反転フラグ */
  224. int vertical; /* 縦方向反転フラグ */
  225. int palette_num; /* パレット番号 */
  226. int character_num; /* 表示キャラクタ */
  227. unsigned short int * d;
  228. WWScreen s;
  229. WWPalette p;
  230. WWCharacter c;
  231. printf("call : screen_get_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p",
  232. screen, x, y, w, h, data); fflush(stdout);
  233. if (wonx_display == NULL) Wonx_Create();
  234. d = (unsigned short int *)data;
  235. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  236. for (j = 0; j < h; j++) {
  237. for (i = 0; i < w; i++) {
  238. horizontal = WWScreen_GetHorizontal(s, x + i, y + j);
  239. vertical = WWScreen_GetVertical( s, x + i, y + j);
  240. p = WWScreen_GetPalette( s, x + i, y + j);
  241. c = WWScreen_GetCharacter( s, x + i, y + j);
  242. palette_num = WWPalette_GetNumber(p);
  243. character_num = WWCharacter_GetNumber(c);
  244. *d = 0;
  245. *d |= horizontal << 15;
  246. *d |= vertical << 14;
  247. *d |= palette_num << 9;
  248. *d |= character_num;
  249. d++;
  250. }
  251. }
  252. WonxDisplay_Flush(wonx_display);
  253. printf("return value = none\n"); fflush(stdout);
  254. return;
  255. }
  256. unsigned int screen_get_char1(int screen, int x, int y)
  257. {
  258. unsigned short int ret;
  259. printf("call : screen_get_char1() : screen = %d, x = %d, y = %d, ",
  260. screen, x, y);
  261. 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 = 0x%04x\n", (int)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("call : screen_fill_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x, ",
  280. screen, x, y, w, h, (int)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("call : screen_fill_attr() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x, mask = 0x%04x, ",
  309. screen, x, y, w, h, (int)data, (int)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("call : sprite_set_range() : start = %u, count = %u, ",
  326. (int)sprite_start, (int)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("call : sprite_set_char() : number = %u, data = 0x%04x, ",
  343. (int)sprite_num, (int)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),
  353. data & 0x1ff);
  354. WWSprite_SetPalette(s, p);
  355. WWSprite_SetCharacter(s, c);
  356. WonxDisplay_Flush(wonx_display);
  357. printf("return value = none\n"); fflush(stdout);
  358. return;
  359. }
  360. unsigned int sprite_get_char(unsigned int sprite_num)
  361. {
  362. WWSprite s;
  363. WWPalette p;
  364. WWCharacter c;
  365. unsigned short int ret;
  366. printf("call : sprite_get_char() : number = %u, ", (int)sprite_num);
  367. fflush(stdout);
  368. if (wonx_display == NULL) Wonx_Create();
  369. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  370. ret = 0;
  371. ret |= (WWSprite_GetHorizontal(s) ? 1 : 0) << 15;
  372. ret |= (WWSprite_GetVertical( s) ? 1 : 0) << 14;
  373. ret |= (WWSprite_GetPriority( s) ? 1 : 0) << 13;
  374. ret |= (WWSprite_GetClipping( s) ? 1 : 0) << 12;
  375. p = WWSprite_GetPalette(s);
  376. ret |= (WWPalette_GetNumber(p) & 0x07) << 9;
  377. c = WWSprite_GetCharacter(s);
  378. ret |= WWCharacter_GetNumber(c);
  379. WonxDisplay_Flush(wonx_display);
  380. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  381. return (ret);
  382. }
  383. void sprite_set_location(unsigned int sprite_num, int x, int y)
  384. {
  385. WWSprite s;
  386. printf("call : sprite_set_location() : number = %u, x = %d, y = %d, ",
  387. (int)sprite_num, x, y); fflush(stdout);
  388. if (wonx_display == NULL) Wonx_Create();
  389. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  390. WWSprite_SetPosition(s, x, y);
  391. WonxDisplay_Flush(wonx_display);
  392. printf("return value = none\n"); fflush(stdout);
  393. return;
  394. }
  395. unsigned int sprite_get_location(unsigned int sprite_num)
  396. {
  397. WWSprite s;
  398. unsigned short int ret;
  399. printf("call : sprite_get_location() : number = %u, ", (int)sprite_num);
  400. fflush(stdout);
  401. if (wonx_display == NULL) Wonx_Create();
  402. s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num);
  403. ret = 0;
  404. /* これは本当か? 逆では? */
  405. ret |= WWSprite_GetX(s) << 8;
  406. ret |= WWSprite_GetY(s);
  407. WonxDisplay_Flush(wonx_display);
  408. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  409. return (ret);
  410. }
  411. void sprite_set_char_location(unsigned int sprite_num,
  412. unsigned int data, int x, int y)
  413. {
  414. if (wonx_display == NULL) Wonx_Create();
  415. printf("call : sprite_set_char_location() : number = %u, data = 0x%04x, x = %d, y = %d, ",
  416. (int)sprite_num, (int)data, x, y); fflush(stdout);
  417. sprite_set_char(sprite_num, data);
  418. sprite_set_location(sprite_num, x, y);
  419. WonxDisplay_Flush(wonx_display);
  420. printf("return value = none\n"); fflush(stdout);
  421. return;
  422. }
  423. unsigned long int sprite_get_char_location(unsigned int sprite_num)
  424. {
  425. unsigned long int ret;
  426. printf("call : sprite_get_char_location() : number = %u, ", (int)sprite_num);
  427. fflush(stdout);
  428. if (wonx_display == NULL) Wonx_Create();
  429. ret = 0;
  430. /* これは本当か? 逆では? */
  431. ret |= sprite_get_char(sprite_num) << 16;
  432. ret |= sprite_get_location(sprite_num);
  433. WonxDisplay_Flush(wonx_display);
  434. printf("return value = 0x%08x\n", (int)ret); fflush(stdout);
  435. return (ret);
  436. }
  437. void sprite_set_data(unsigned int sprite_num, unsigned int count, void * data)
  438. {
  439. int i;
  440. char * d;
  441. unsigned long int * n;
  442. printf("call : sprite_set_data() : number = %u, count = %u, data = %p",
  443. (int)sprite_num, (int)count, data); fflush(stdout);
  444. if (wonx_display == NULL) Wonx_Create();
  445. n = (unsigned long int *)data;
  446. for (i = 0; i < count; i++) {
  447. sprite_set_char_location(sprite_num + i,
  448. n[i] >> 16,
  449. (n[i] >> 8) & 0xff,
  450. n[i] & 0xff);
  451. }
  452. WonxDisplay_Flush(wonx_display);
  453. printf("return value = none\n"); fflush(stdout);
  454. return;
  455. }
  456. void screen_set_scroll(int screen, int x, int y)
  457. {
  458. WWScreen s;
  459. printf("call : screen_set_scroll() : scsreen = %d, x = %d, y = %d, ",
  460. screen, x, y); fflush(stdout);
  461. if (wonx_display == NULL) Wonx_Create();
  462. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  463. WWScreen_SetRollX(s, x);
  464. WWScreen_SetRollY(s, y);
  465. WonxDisplay_Flush(wonx_display);
  466. printf("return value = none\n"); fflush(stdout);
  467. return;
  468. }
  469. unsigned int screen_get_scroll(int screen)
  470. {
  471. unsigned short int ret;
  472. WWScreen s;
  473. printf("call : screen_get_scroll() : screen = %d, ", screen); fflush(stdout);
  474. if (wonx_display == NULL) Wonx_Create();
  475. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen);
  476. ret = 0;
  477. ret |= WWScreen_GetRollX(s);
  478. ret |= WWScreen_GetRollY(s) << 8;
  479. WonxDisplay_Flush(wonx_display);
  480. printf("return value = %u\n", (int)ret); fflush(stdout);
  481. return (ret);
  482. }
  483. void screen2_set_window(int x, int y, int w, int h)
  484. {
  485. WWScreen s;
  486. printf("call : screen2_set_window() : x = %d, y = %d, width = %d, height = %d, ",
  487. x, y, w, h); fflush(stdout);
  488. if (wonx_display == NULL) Wonx_Create();
  489. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2);
  490. WWScreen_SetDrawX(s, x);
  491. WWScreen_SetDrawY(s, y);
  492. WWScreen_SetDrawWidth( s, w);
  493. WWScreen_SetDrawHeight(s, h);
  494. WonxDisplay_Flush(wonx_display);
  495. printf("return value = none\n"); fflush(stdout);
  496. return;
  497. }
  498. unsigned long int screen2_get_window(void)
  499. {
  500. WWScreen s;
  501. unsigned short int xy;
  502. unsigned short int wh;
  503. unsigned long int ret;
  504. if (wonx_display == NULL) Wonx_Create();
  505. printf("call : screen2_get_window() : "); fflush(stdout);
  506. s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2);
  507. xy =
  508. ((WWScreen_GetDrawY(s) << 8) & 0xff00) |
  509. (WWScreen_GetDrawX(s) & 0x00ff);
  510. wh =
  511. ((WWScreen_GetDrawHeight(s) << 8) & 0xff00) |
  512. (WWScreen_GetDrawWidth(s) & 0x00ff);
  513. ret = ((unsigned long int)wh) << 16 | xy;
  514. WonxDisplay_Flush(wonx_display);
  515. printf("return value = 0x%08x\n", (int)ret); fflush(stdout);
  516. return (ret);
  517. }
  518. void sprite_set_window(int x, int y, int w, int h)
  519. {
  520. if (wonx_display == NULL) Wonx_Create();
  521. /* あとで書くこと */
  522. WonxDisplay_Flush(wonx_display);
  523. }
  524. unsigned long int sprite_get_window(void)
  525. {
  526. if (wonx_display == NULL) Wonx_Create();
  527. /* あとで書くこと */
  528. WonxDisplay_Flush(wonx_display);
  529. }
  530. void palette_set_color(unsigned int palette_num,
  531. unsigned int colors)
  532. {
  533. int mapped_colors[4];
  534. WWPalette palette;
  535. printf("call : palette_set_color() : number = %u, colors = 0x%04x, ",
  536. (int)palette_num, (int)colors); fflush(stdout);
  537. if (wonx_display == NULL) Wonx_Create();
  538. mapped_colors[0] = colors & 0x07;
  539. mapped_colors[1] = (colors >> 4) & 0x07;
  540. mapped_colors[2] = (colors >> 8) & 0x07;
  541. mapped_colors[3] = (colors >> 12) & 0x07;
  542. palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), palette_num);
  543. WWPalette_SetMappedColors(palette, mapped_colors);
  544. WonxDisplay_Flush(wonx_display);
  545. printf("return value = none\n"); fflush(stdout);
  546. return;
  547. }
  548. unsigned int palette_get_color(unsigned int palette_num)
  549. {
  550. int mapped_colors[4];
  551. WWPalette palette;
  552. unsigned short int ret;
  553. printf("call : palette_get_color() : number = %u, ", (int)palette_num);
  554. fflush(stdout);
  555. if (wonx_display == NULL) Wonx_Create();
  556. palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
  557. palette_num);
  558. WWPalette_GetMappedColors(palette, mapped_colors);
  559. ret = 0;
  560. ret |= mapped_colors[0] & 0x07;
  561. ret |= (mapped_colors[1] & 0x07) << 4;
  562. ret |= (mapped_colors[2] & 0x07) << 8;
  563. ret |= (mapped_colors[3] & 0x07) << 12;
  564. WonxDisplay_Flush(wonx_display);
  565. printf("return value = %u\n", (int)ret); fflush(stdout);
  566. return (ret);
  567. }
  568. void lcd_set_color(unsigned int colors0, unsigned int colors1)
  569. {
  570. WWColorMap color_map;
  571. int lcd_colors[8];
  572. printf("call : lcd_set_color() : colors0 = 0x%04x, colors1 = 0x%04x, ",
  573. (int)colors0, (int)colors1); fflush(stdout);
  574. if (wonx_display == NULL) Wonx_Create();
  575. lcd_colors[0] = colors0 & 0x0f;
  576. lcd_colors[1] = (colors0 >> 4) & 0x0f;
  577. lcd_colors[2] = (colors0 >> 8) & 0x0f;
  578. lcd_colors[3] = (colors0 >> 12) & 0x0f;
  579. lcd_colors[4] = colors1 & 0x0f;
  580. lcd_colors[5] = (colors1 >> 4) & 0x0f;
  581. lcd_colors[6] = (colors1 >> 8) & 0x0f;
  582. lcd_colors[7] = (colors1 >> 12) & 0x0f;
  583. color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(wonx_display));
  584. WWColorMap_SetLCDColors(color_map, lcd_colors);
  585. WonxDisplay_Flush(wonx_display);
  586. printf("return value = none\n"); fflush(stdout);
  587. return;
  588. }
  589. unsigned long int lcd_get_color(void)
  590. {
  591. WWColorMap color_map;
  592. int lcd_colors[8];
  593. unsigned long int ret;
  594. printf("call : lcd_get_color() : "); fflush(stdout);
  595. if (wonx_display == NULL) Wonx_Create();
  596. color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(wonx_display));
  597. WWColorMap_GetLCDColors(color_map, lcd_colors);
  598. ret = 0;
  599. ret |= lcd_colors[0] & 0x0f;
  600. ret |= (lcd_colors[1] & 0x0f) << 4;
  601. ret |= (lcd_colors[2] & 0x0f) << 8;
  602. ret |= (lcd_colors[3] & 0x0f) << 12;
  603. ret |= lcd_colors[0] & 0x0f;
  604. ret |= (lcd_colors[1] & 0x0f) << 4;
  605. ret |= (lcd_colors[2] & 0x0f) << 8;
  606. ret |= (lcd_colors[3] & 0x0f) << 12;
  607. WonxDisplay_Flush(wonx_display);
  608. printf("return value = 0x%08x\n", (int)ret); fflush(stdout);
  609. return (ret);
  610. }
  611. void lcd_set_segments(unsigned segments)
  612. {
  613. if (wonx_display == NULL) Wonx_Create();
  614. /* セグメント表示は未サポートか? */
  615. WonxDisplay_Flush(wonx_display);
  616. }
  617. unsigned lcd_get_segments(void)
  618. {
  619. if (wonx_display == NULL) Wonx_Create();
  620. /* セグメント表示は未サポートか? */
  621. WonxDisplay_Flush(wonx_display);
  622. }
  623. void lcd_set_sleep(unsigned sleep)
  624. {
  625. if (wonx_display == NULL) Wonx_Create();
  626. /* ? */
  627. WonxDisplay_Flush(wonx_display);
  628. }
  629. unsigned lcd_get_sleep(void)
  630. {
  631. if (wonx_display == NULL) Wonx_Create();
  632. /* ? */
  633. WonxDisplay_Flush(wonx_display);
  634. }
  635. void screen_set_vram(int screen, int locationID)
  636. {
  637. if (wonx_display == NULL) Wonx_Create();
  638. WonxDisplay_Flush(wonx_display);
  639. }
  640. void sprite_set_vram(int locationID)
  641. {
  642. if (wonx_display == NULL) Wonx_Create();
  643. WonxDisplay_Flush(wonx_display);
  644. }
  645. /*****************************************************************************/
  646. /* ここまで */
  647. /*****************************************************************************/
  648. /*****************************************************************************/
  649. /* End of File. */
  650. /*****************************************************************************/