123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- /*****************************************************************************/
- /* ここから */
- /*****************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "wonx_include/text.h"
- #include "Wonx.h"
- #include "WWText.h"
- /*****************************************************************************/
- /* 互換関数の定義 */
- /*****************************************************************************/
- /*
- * Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので,
- * 互換関数の内部は UNIXTimer_Pause(), UNIXTimer_Unpause() でくくり,
- * タイマ割り込みを一時停止して処理を行う.また,unpause するまえに,
- * かならず sync するようにする.
- */
- /*
- * タイマの一時停止の2重解除の問題が出てくるので,
- * 互換関数から互換関数を呼んではいけない.
- * (一時停止はネストされるが,いちおう)
- * 似たような処理をする関数の場合は,必ず static な別関数に処理をまとめ,
- * そっちを呼び出すようにすること.
- * 引数の表示の問題もあるしね.
- */
- static void _text_window_init(int x, int y, int w, int h, unsigned int base)
- {
- WWText ww_text;
- WWDisplay ww_display;
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- WWText_SetTextWindow(ww_text, x, y, w, h, base, ww_display);
- WWScreen_SetRollX(WWText_GetScreen(ww_text), 0);
- WWScreen_SetRollY(WWText_GetScreen(ww_text), 0);
- return;
- }
- void text_screen_init(void)
- {
- WWDisplay ww_display;
- WWLCDPanel ww_lcd_panel;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_screen_init() : \n");
- fflush(stdout);
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
- _text_window_init(0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT, 8);
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_screen_init() : return value = none\n"); fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- void text_window_init(int x, int y, int w, int h, unsigned int base)
- {
- WWDisplay ww_display;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_window_init() : x = %d, y = %d, width = %d, height = %d, base = %u\n", x, y, w, h, (int)base);
- fflush(stdout);
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- _text_window_init(x, y, w, h, base);
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_window_init() : return value = none\n"); fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- void text_set_mode(int mode)
- {
- }
- int text_get_mode(void)
- {
- return (0);
- }
- static void _text_put_char(int x, int y, unsigned int c)
- {
- WWText ww_text;
- WWDisplay ww_display;
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- WWText_PutCharacter(ww_text, x, y, c, ww_display);
- return;
- }
- void text_put_char(int x, int y, unsigned int c)
- {
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_put_char() : x = %d, y = %d, character = %u\n", x, y, (int)c);
- fflush(stdout);
- _text_put_char(x, y, c);
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_put_char() : return value = none\n"); fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- static int _text_put_string(int x, int y, char * string)
- {
- int i, len, ret;
- WWText ww_text;
- WWDisplay ww_display;
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- len = strlen(string);
- ret = 0;
- for (i = 0; i < len; i++) {
- if (WWText_PutCharacter(ww_text, x + i, y, string[i], ww_display) >= 0)
- ret++;
- }
- return (ret);
- }
- int text_put_string(int x, int y, char * string)
- {
- int ret;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_put_string() : x = %d, y = %d, string = %s\n", x, y, string);
- fflush(stdout);
- ret = _text_put_string(x, y, string);
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_put_string() : return value = %d\n", ret);
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return (ret);
- }
- int text_put_substring(int x, int y, char * s, int length)
- {
- int i, ret;
- WWText ww_text;
- WWDisplay ww_display;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_put_substring() : x = %d, y = %d, string = %s, length = %d\n", x, y, s, length);
- fflush(stdout);
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- ret = 0;
- for (i = 0; i < length; i++) {
- if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0)
- ret++;
- }
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_put_substring() : return value = %d\n", ret);
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return (ret);
- }
- void text_put_numeric(int x, int y, int length, int format, int number)
- {
- char buf[20];
- char f[20];
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_put_numeric() : x = %d, y = %d, length = %d, format = %04x, number = %d\n", x, y, length, format, number);
- fflush(stdout);
- strcpy(f, "%");
- if (format & NUM_PADZERO) strcat(f, "0");
- sprintf(f + strlen(f), "%d", length);
- if (format & NUM_HEXA) strcat(f, "x");
- else if (format & NUM_SIGNED) strcat(f, "d");
- else strcat(f, "u");
- if (format & NUM_ALIGN_LEFT) { /* 未実装 */ }
- sprintf(buf, f, number);
- _text_put_string(x, y, buf);
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_put_numeric() : return value = none\n");
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- void text_store_numeric(char * buffer, int length, int format, int number)
- {
- }
- void text_fill_char(int x, int y, int length, int c)
- {
- int i;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_fill_char() : x = %d, y = %d, length = %d, character = %d\n", x, y, length, c);
- fflush(stdout);
- for (i = 0; i < length; i++) {
- _text_put_char(x + i, y, c);
- }
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_fill_char() : return value = none\n");
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- void text_set_palette(int palette_num)
- {
- WWText ww_text;
- WWDisplay ww_display;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_set_palette() : palette = %d\n", palette_num);
- fflush(stdout);
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- WWText_SetPalette(ww_text, WWDisplay_GetPalette(ww_display, palette_num));
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_set_palette() : return value = none\n");
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- int text_get_palette(void)
- {
- WWText ww_text;
- int num;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_get_palette() : \n");
- fflush(stdout);
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- num = WWPalette_GetNumber(WWText_GetPalette(ww_text));
- WonxDisplay_Sync(Wonx_GetWonxDisplay());
- printf("call : text_get_palette() : return value = %d\n", num);
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return (num);
- }
- void text_set_ank_font(int base, int color, int count, void * font)
- {
- }
- void text_set_sjis_font(void * p)
- {
- }
- void text_get_fontdata(int c, void * buffer)
- {
- }
- void text_set_screen(int screen)
- {
- WWText ww_text;
- WWDisplay ww_display;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_set_screen() : screen = %d\n", screen);
- fflush(stdout);
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
- WWText_SetScreen(ww_text, WWDisplay_GetScreen(ww_display, screen));
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_set_screen() : return value = none\n");
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return;
- }
- int text_get_screen(void)
- {
- WWText ww_text;
- int n;
- if (!Wonx_IsCreated()) Wonx_Create();
- /* タイマを一時停止する */
- UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- printf("call : text_get_screen() : \n");
- fflush(stdout);
- ww_text = WonxText_GetWWText(Wonx_GetWonxText());
- n = WWScreen_GetNumber(WWText_GetScreen(ww_text));
- WonxDisplay_Flush(Wonx_GetWonxDisplay());
- printf("call : text_set_screen() : return value = %d\n", n);
- fflush(stdout);
- /* タイマをもとに戻す */
- UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
- return (n);
- }
- void cursor_display(int flag)
- {
- }
- int cursor_status(void)
- {
- return (0);
- }
- void cursor_set_location(int x, int y, int w, int h)
- {
- }
- unsigned long int cursor_get_location(void)
- {
- return (0);
- }
- void cursor_set_type(int palette_num, int interval)
- {
- }
- unsigned long int cursor_get_type(void)
- {
- return (0);
- }
- int text_printf(int x, int y, const char *format, ...)
- {
- return (0);
- }
- /*****************************************************************************/
- /* ここまで */
- /*****************************************************************************/
- /*****************************************************************************/
- /* End of File. */
- /*****************************************************************************/
|