disp.c 22 KB

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