diff --git a/HISTORY b/HISTORY index b770828..ddfe1f8 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,25 @@ +2000/10/8(日) + +wonx-a08 未公開 + +テキスト表示機能の追加.(0〜127のASCII文字のみで,漢字は未対応) + +Wonx クラスを作成し,すべてのリソースを Wonx クラスで管理するように変更. +(Wonx.x WonxP.h 参照) + +p を押して画面の表示/非表示を切替えたときに,LCDパネルの再描画を行うように +改良. + +コンパイルオプションに -Wall を追加. + +disp.c で重複した処理をしている関数の処理部分をまとめた. + + + + 2000/10/5(木) -wonx-a07 公開 +wonx-a07 未公開 WWLCDPanel にビットマップデータを2枚持たせ,一度描画したビットマップは 描画しないように修正.Xサーバの負荷を減らした. @@ -17,7 +36,7 @@ wonx-a05 2000/10/4(水) -wonx-a06 公開 +wonx-a06 未公開 WWDisplay_DrawScreen() のアルゴリズムを大幅に修正. たいして高速にならなかった.X サーバの描画がホットスポットになっていると @@ -28,7 +47,7 @@ WWDisplay_DrawScreen() 2000/10/3(火) -wonx-a05 公開 +wonx-a05 未公開 XDisplay_DrawLCDWindow() を修正.無駄な計算をループ外に出した. diff --git a/Makefile b/Makefile index d7c953e..0c9f223 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ XINCLUDEDIR = /usr/X11R6/include INCLUDEDIR = . XLIBDIR = /usr/X11R6/lib -VERSION = Wonx-a07 -PKGNAME = wonx-a07 +VERSION = Wonx-b01 +PKGNAME = wonx-b01 -OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WonxDisplay.o XDisplay.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o etc.o wonx.o +OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWText.o Wonx.o WonxDisplay.o WonxText.o XDisplay.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o etc.o .SUFFIXES: .c .o @@ -16,7 +16,7 @@ libwonx.a : $(OBJS) # ranlib libwonx.a .c.o : $*.c - gcc -c $*.c -O -I$(INCLUDEDIR) -I$(XINCLUDEDIR) + gcc -c $*.c -O -Wall -I$(INCLUDEDIR) -I$(XINCLUDEDIR) clean : rm -f libwonx.a *.o diff --git a/WWCharacter.c b/WWCharacter.c index 527f5af..00a3290 100644 --- a/WWCharacter.c +++ b/WWCharacter.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWCharacterP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ @@ -103,6 +104,11 @@ int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel) return (pixel); } +int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src) +{ + return (WWCharacter_SetBitmap(dst, src->bitmap)); +} + int WWCharacter_PrintData(WWCharacter character, FILE * f) { int x, y, n; diff --git a/WWCharacter.h b/WWCharacter.h index 6e82ac5..15c1f81 100644 --- a/WWCharacter.h +++ b/WWCharacter.h @@ -25,6 +25,7 @@ WWCharacter WWCharacter_Destroy(WWCharacter character); int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap); int WWCharacter_GetPixel(WWCharacter character, int x, int y); int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel); +int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src); int WWCharacter_PrintData(WWCharacter character, FILE * f); /*****************************************************************************/ diff --git a/WWColorMap.c b/WWColorMap.c index 8dad4f4..7e5b4d4 100644 --- a/WWColorMap.c +++ b/WWColorMap.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWColorMapP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ @@ -65,7 +66,7 @@ int WWColorMap_SetLCDColor(WWColorMap color_map, int color, int lcd_color) int WWColorMap_PrintData(WWColorMap c, FILE * f) { - int i, n; + int i; fprintf(f, "\n"); diff --git a/WWDisplay.c b/WWDisplay.c index 5791fc4..d0d8573 100644 --- a/WWDisplay.c +++ b/WWDisplay.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWDisplayP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ @@ -203,7 +204,7 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen) int pixel; int x, y, px, py; - int sx, sy, ex, ey; + int sx = 0, sy = 0, ex = 0, ey = 0; int mode; if (!WWScreen_GetEnable(screen)) return (0); @@ -330,7 +331,6 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite) int WWDisplay_DrawLCDPanel(WWDisplay display) { WWLCDPanel lcd_panel; - WWScreen screen; int x, y, i; int lcd_panel_width; int lcd_panel_height; diff --git a/WWLCDPanel.c b/WWLCDPanel.c index 1b89954..6d5d3ea 100644 --- a/WWLCDPanel.c +++ b/WWLCDPanel.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWLCDPanelP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/WWPalette.c b/WWPalette.c index 793a6e1..bbbc7b8 100644 --- a/WWPalette.c +++ b/WWPalette.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWPaletteP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/WWScreen.c b/WWScreen.c index e904c3c..0d8d183 100644 --- a/WWScreen.c +++ b/WWScreen.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWScreenP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ @@ -74,22 +75,60 @@ static WWScreenCharacter WWScreen_SetScreenCharacter(WWScreen s, int x, int y, /*===========================================================================*/ int WWScreen_GetHorizontal(WWScreen s, int x, int y) -{ return (WWScreen_GetScreenCharacter(s, x, y)->horizontal); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_GetHorizontal(sc)); +} + int WWScreen_GetVertical(WWScreen s, int x, int y) -{ return (WWScreen_GetScreenCharacter(s, x, y)->vertical); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_GetVertical(sc)); +} + WWPalette WWScreen_GetPalette(WWScreen s, int x, int y) -{ return (WWScreen_GetScreenCharacter(s, x, y)->palette); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_GetPalette(sc)); +} + WWCharacter WWScreen_GetCharacter(WWScreen s, int x, int y) -{ return (WWScreen_GetScreenCharacter(s, x, y)->character); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_GetCharacter(sc)); +} int WWScreen_SetHorizontal(WWScreen s, int x, int y, int f) -{ return (WWScreen_GetScreenCharacter(s, x, y)->horizontal = f); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_SetHorizontal(sc, f)); +} + int WWScreen_SetVertical(WWScreen s, int x, int y, int f) -{ return (WWScreen_GetScreenCharacter(s, x, y)->vertical = f); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_SetVertical(sc, f)); +} + WWPalette WWScreen_SetPalette(WWScreen s, int x, int y, WWPalette palette) -{ return (WWScreen_GetScreenCharacter(s, x, y)->palette = palette); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_SetPalette(sc, palette)); +} + WWCharacter WWScreen_SetCharacter(WWScreen s, int x, int y, WWCharacter c) -{ return (WWScreen_GetScreenCharacter(s, x, y)->character = c); } +{ + WWScreenCharacter sc; + sc = WWScreen_GetScreenCharacter(s, x, y); + return (WWScreenCharacter_SetCharacter(sc, c)); +} int WWScreen_GetNumber(WWScreen s) { return (s->number); } int WWScreen_GetWidth( WWScreen s) { return (s->width ); } diff --git a/WWSprite.c b/WWSprite.c index 293291d..4adfca5 100644 --- a/WWSprite.c +++ b/WWSprite.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WWSpriteP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/WWSprite.h b/WWSprite.h index e828040..9f32160 100644 --- a/WWSprite.h +++ b/WWSprite.h @@ -39,6 +39,7 @@ WWCharacter WWSprite_SetCharacter(WWSprite s, WWCharacter c); int WWSprite_GetX(WWSprite sprite); int WWSprite_GetY(WWSprite sprite); int WWSprite_SetPosition(WWSprite sprite, int x, int y); +int WWSprite_GetPixel(WWSprite sprite, int x, int y); WWSprite WWSprite_Create(int number, int x, int y, int horizontal, int vertical, diff --git a/WWText.c b/WWText.c new file mode 100644 index 0000000..b21c52a --- /dev/null +++ b/WWText.c @@ -0,0 +1,161 @@ +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "WWTextP.h" +#include "etc.h" + +/* フォントのビットマップデータ */ +#include "WWTextFonts.c" + +/*****************************************************************************/ +/* メンバ関数の定義 */ +/*****************************************************************************/ + +/*===========================================================================*/ +/* メンバの取得 */ +/*===========================================================================*/ + +WWScreen WWText_GetScreen(WWText t) { return (t->screen); } +int WWText_GetX(WWText t) { return (t->x); } +int WWText_GetY(WWText t) { return (t->y); } +int WWText_GetWidth( WWText t) { return (t->width ); } +int WWText_GetHeight(WWText t) { return (t->height); } +int WWText_GetBase(WWText t) { return (t->base); } +WWPalette WWText_GetPalette(WWText t) { return (t->palette); } +static WWCharacter WWText_GetFont(WWText t, int n) { return (t->font[n]); } + +/*===========================================================================*/ +/* メンバの設定 */ +/*===========================================================================*/ + +WWScreen WWText_SetScreen(WWText t, WWScreen s) { return (t->screen = s); } +int WWText_SetX(WWText t, int n) { return (t->x = n); } +int WWText_SetY(WWText t, int n) { return (t->y = n); } +int WWText_SetWidth( WWText t, int n) { return (t->width = n); } +int WWText_SetHeight(WWText t, int n) { return (t->height = n); } +int WWText_SetBase(WWText t, int n) { return (t->base = n); } +WWPalette WWText_SetPalette(WWText t, WWPalette p) { return (t->palette = p); } +static WWCharacter WWText_SetFont(WWText t, int n, WWCharacter c) +{ return (t->font[n] = c); } + +int WWText_SetTextWindow(WWText ww_text, int x, int y, + int width, int height, int base, + WWDisplay ww_display) +{ + int tx, ty, c; + WWCharacter ww_character; + + WWText_SetX(ww_text, x); + WWText_SetY(ww_text, y); + WWText_SetWidth(ww_text, width); + WWText_SetHeight(ww_text, height); + WWText_SetBase(ww_text, base); + + c = WWText_GetBase(ww_text); + for (ty = 0; ty < WWText_GetHeight(ww_text); ty++) { + for (tx = 0; tx < WWText_GetWidth(ww_text); tx++) { + if (c >= 512) Error("WWText_SetTextWindow", "Over character."); + ww_character = WWDisplay_GetCharacter(ww_display, c); + WWCharacter_SetBitmap(ww_character, NULL); + WWScreen_SetCharacter(WWText_GetScreen(ww_text), + WWText_GetX(ww_text) + tx, + WWText_GetY(ww_text) + ty, + ww_character); + c++; + } + } + return (0); +} + +int WWText_PutCharacter(WWText ww_text, int x, int y, int character, + WWDisplay ww_display) +{ + WWCharacter ww_character; + + if ((character < 0) || (character > 127)) + Error("WWText_PutCharacter", "Character number is out of range."); + + /* + * テキスト表示は,text_window_init() で指定したテキストウインドウの + * 座標系で行う(らしい).(ウインドウ内の左上が(0,0)になる) + */ + + if ( (x < 0) || (x > WWText_GetWidth( ww_text) - 1) || + (y < 0) || (y > WWText_GetHeight(ww_text) - 1) ) + Error("WWText_PutCharacter", "Position is out of range."); + +#if 0 + n = WWText_GetBase(ww_text) + + (x - WWText_GetX(ww_text)) + + (y - WWText_GetY(ww_text)) * WWText_GetWidth(ww_text); + ww_character = WWDisplay_GetCharacter(ww_display, n); +#else + ww_character = WWScreen_GetCharacter(WWText_GetScreen(ww_text), + WWText_GetX(ww_text) + x, + WWText_GetY(ww_text) + y); +#endif + + WWCharacter_CopyBitmap(ww_character, WWText_GetFont(ww_text, character)); + + /* 表示時にパレットを設定するのでいいのか? 不明 */ + WWScreen_SetPalette(WWText_GetScreen(ww_text), + WWText_GetX(ww_text) + x, + WWText_GetY(ww_text) + y, + WWText_GetPalette(ww_text)); + + return (character); +} + +/*===========================================================================*/ +/* オブジェクトの生成と消去 */ +/*===========================================================================*/ + +WWText WWText_Create(WWScreen screen, + int x, int y, int width, int height, + WWPalette palette) +{ + WWText ww_text; + int i; + + ww_text = (WWText)malloc(sizeof(_WWText)); + if (ww_text == NULL) Error("WWText_Create", "Cannot allocate memory."); + + WWText_SetScreen(ww_text, screen); + WWText_SetX(ww_text, 0); + WWText_SetY(ww_text, 0); + WWText_SetWidth( ww_text, width ); + WWText_SetHeight(ww_text, height); + WWText_SetPalette(ww_text, palette); + + for (i = 0; i < 128; i++) { + WWText_SetFont(ww_text, i, WWCharacter_Create(i, &(fonts[i * 16]))); + } + + return (ww_text); +} + +WWText WWText_Destroy(WWText ww_text) +{ + int i; + + if (ww_text == NULL) Error("WWText_Destroy", "Object is not created."); + + for (i = 0; i < 128; i++) { + if (WWText_GetFont(ww_text, i)) + WWText_SetFont(ww_text, i, + WWCharacter_Destroy(WWText_GetFont(ww_text, i))); + } + + free(ww_text); + + return (NULL); +} + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/WWText.h b/WWText.h new file mode 100644 index 0000000..566afc0 --- /dev/null +++ b/WWText.h @@ -0,0 +1,79 @@ +#ifndef _WWText_h_INCLUDED_ +#define _WWText_h_INCLUDED_ + +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "WWDisplay.h" +#include "WWScreen.h" +#include "WWPalette.h" + +/*****************************************************************************/ +/* クラスの定義 */ +/*****************************************************************************/ + +typedef struct _WWText * WWText; + +/*===========================================================================*/ +/* メンバの取得 */ +/*===========================================================================*/ + +WWScreen WWText_GetScreen(WWText t); +int WWText_GetX(WWText t); +int WWText_GetY(WWText t); +int WWText_GetWidth( WWText t); +int WWText_GetHeight(WWText t); +int WWText_GetBase(WWText t); +WWPalette WWText_GetPalette(WWText t); + +/*===========================================================================*/ +/* メンバの設定 */ +/*===========================================================================*/ + +WWScreen WWText_SetScreen(WWText t, WWScreen s); +int WWText_SetX(WWText t, int n); +int WWText_SetY(WWText t, int n); +int WWText_SetWidth( WWText t, int n); +int WWText_SetHeight(WWText t, int n); +int WWText_SetBase(WWText t, int n); +WWPalette WWText_SetPalette(WWText t, WWPalette p); + +int WWText_SetTextWindow(WWText ww_text, int x, int y, + int width, int height, int base, + WWDisplay ww_display); +int WWText_PutCharacter(WWText ww_text, int x, int y, int character, + WWDisplay ww_display); + +/*===========================================================================*/ +/* オブジェクトの生成と消去 */ +/*===========================================================================*/ + +WWText WWText_Create(WWScreen screen, int x, int y, int width, int height, + WWPalette palette); +WWText WWText_Destroy(WWText text); + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ + + + + + + + + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +#endif + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/WWTextFonts.c b/WWTextFonts.c new file mode 100644 index 0000000..69d283c --- /dev/null +++ b/WWTextFonts.c @@ -0,0 +1,130 @@ +static unsigned char fonts[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0 空白文字 */ + 0x00,0x00,0x00,0x00,0xc0,0x0c,0x00,0x00,0x30,0x30,0xc0,0x0f,0x00,0x00,0x00,0x00, /* 1 笑顔 */ + 0x00,0x00,0xf0,0x3f,0x3c,0xf3,0xfc,0xff,0xcc,0xcf,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 2 笑顔 */ + 0x30,0x30,0xfc,0xfc,0xfc,0xff,0xfc,0xff,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 3 ハート */ + 0x00,0x03,0xc0,0x0f,0xf0,0x3f,0xfc,0xff,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 4 ダイヤ */ + 0x00,0x03,0xc0,0x0f,0xc0,0x0f,0xfc,0xfc,0xfc,0xfc,0x00,0x03,0xc0,0x0f,0x00,0x00, /* 5 クローバー */ + 0x00,0x03,0xc0,0x0f,0xf0,0x3f,0xfc,0xff,0xf0,0x3f,0x00,0x03,0xc0,0x0f,0x00,0x00, /* 6 スペード */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 7 点 */ + 0x00,0x00,0x00,0x00,0xf0,0x0f,0x30,0x0c,0x30,0x0c,0xf0,0x0f,0x00,0x00,0x00,0x00, /* 8 小さい□ */ + 0x00,0x00,0x00,0x00,0xc0,0x03,0x30,0x0c,0x30,0x0c,0xc0,0x03,0x00,0x00,0x00,0x00, /* 9 小さい○ */ + 0x00,0x00,0xfc,0x3f,0x0c,0x30,0xcc,0x33,0xcc,0x33,0x0c,0x30,0xfc,0x3f,0x00,0x00, /* 10 2重四角 */ + 0x00,0xff,0x00,0xf0,0x00,0xcc,0xf0,0xc3,0x0c,0x03,0x0c,0x03,0xf0,0x00,0x00,0x00, /* 11 ♂ */ + 0xc0,0x0f,0x30,0x30,0x30,0x30,0xc0,0x0f,0x00,0x03,0xf0,0x3f,0x00,0x03,0x00,0x00, /* 12 ♀ */ + 0xc0,0x03,0xc0,0x0f,0xc0,0x3c,0xc0,0x30,0xc0,0x30,0xfc,0x00,0x3c,0x00,0x00,0x00, /* 13 ♪ */ + 0xc0,0x03,0xc0,0x3f,0xc0,0x3c,0xc0,0x30,0x3c,0x30,0x3c,0x3f,0x00,0x0f,0x00,0x00, /* 14 音符 */ + 0x00,0x03,0x30,0x33,0xc0,0x0f,0xfc,0xfc,0xc0,0x0f,0x30,0x33,0x00,0x03,0x00,0x00, /* 15 爆発? */ + 0xc0,0x00,0xc0,0x03,0xc0,0x0f,0xc0,0x3f,0xc0,0x0f,0xc0,0x03,0xc0,0x00,0x00,0x00, /* 16 右向き▲ */ + 0x00,0x0c,0x00,0x0f,0xc0,0x0f,0xf0,0x0f,0xc0,0x0f,0x00,0x0f,0x00,0x0c,0x00,0x00, /* 17 左向き▲ */ + 0x00,0x03,0xc0,0x0f,0xf0,0x3f,0x00,0x03,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 18 上下矢印 */ + 0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0x00,0x00,0xf0,0x3c,0x00,0x00, /* 19 !! */ + 0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x3c,0x30,0x0f,0xf0,0x03,0xc0,0x00,0x00,0x00, /* 20 チェック */ + 0x00,0x00,0x00,0x00,0xc0,0x03,0xf0,0x0f,0xf0,0x0f,0xc0,0x03,0x00,0x00,0x00,0x00, /* 21 小さい● */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00, /* 22 ・・ */ + 0x00,0x03,0xc0,0x0f,0xf0,0x3f,0x00,0x03,0xf0,0x3f,0xc0,0x0f,0xf0,0x3f,0x00,0x00, /* 23 矢印? */ + 0x00,0x03,0xc0,0x0f,0xf0,0x3f,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00, /* 24 ↑ */ + 0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 25 ↓ */ + 0x00,0x00,0x00,0x0c,0x00,0x3c,0xfc,0xff,0x00,0x3c,0x00,0x0c,0x00,0x00,0x00,0x00, /* 26 → */ + 0x00,0x00,0xc0,0x00,0xf0,0x00,0xfc,0xff,0xf0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00, /* 27 ← */ + 0xf0,0x0f,0x0c,0x30,0xc3,0xcf,0x33,0xc0,0x33,0xc0,0xc3,0xcf,0x0c,0x30,0xf0,0x0f, /* 28 (C) */ + 0x00,0x00,0xc0,0x0c,0xf0,0x3c,0xfc,0xff,0xf0,0x3c,0xc0,0x0c,0x00,0x00,0x00,0x00, /* 29 ←→ */ + 0x00,0x00,0x00,0x03,0xc0,0x0f,0xf0,0x3f,0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00, /* 30 上向き▲ */ + 0x00,0x00,0x00,0x00,0xfc,0xff,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00,0x00,0x00, /* 31 下向き▲ */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 32 空白 */ + 0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0x00,0x00, /* 33 ! */ + 0xf0,0x3c,0xf0,0x3c,0xc0,0x30,0x30,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 34 " */ + 0xc0,0x0c,0xc0,0x0c,0xfc,0xff,0xc0,0x0c,0xfc,0xff,0xc0,0x0c,0xc0,0x0c,0x00,0x00, /* 35 # */ + 0x00,0x03,0xf0,0x3f,0x3c,0x03,0xf0,0x3f,0x00,0xf3,0xf0,0x3f,0x00,0x03,0x00,0x00, /* 36 $ */ + 0x30,0xc0,0xcc,0x30,0x30,0x0c,0x00,0x03,0xc0,0x30,0x30,0xcc,0x0c,0x30,0x00,0x00, /* 37 % */ + 0xc0,0x03,0x30,0x0c,0x30,0x0c,0xf0,0xc3,0x0c,0x3f,0x0c,0x0c,0xf0,0xf3,0x00,0x00, /* 38 & */ + 0x00,0x0f,0x00,0x0f,0x00,0x0c,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 39 ' */ + 0x00,0x0c,0x00,0x03,0xc0,0x00,0xc0,0x00,0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x00, /* 40 ( */ + 0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x03,0xc0,0x00,0x00,0x00, /* 41 ) */ + 0x00,0x00,0x00,0x03,0x30,0x33,0xc0,0x0f,0x30,0x33,0x00,0x03,0x00,0x00,0x00,0x00, /* 42 * */ + 0x00,0x03,0x00,0x03,0x00,0x03,0xfc,0xff,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00, /* 43 + */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x3c,0x00,0x30,0x00,0x0c,0x00, /* 44 , */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 45 - */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 46 . */ + 0x00,0xc0,0x00,0x30,0x00,0x0c,0x00,0x03,0xc0,0x00,0x30,0x00,0x0c,0x00,0x00,0x00, /* 47 / */ + 0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 48 0 */ + 0x00,0x0f,0xf0,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x00, /* 49 1 */ + 0xf0,0x0f,0x3c,0x3c,0x00,0x3c,0x00,0x0f,0xc0,0x03,0xf0,0x00,0xfc,0x3f,0x00,0x00, /* 50 2 */ + 0xf0,0x0f,0x3c,0x3c,0x00,0x3c,0xf0,0x0f,0x00,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 51 3 */ + 0x00,0x3f,0xc0,0x3f,0xf0,0x3c,0x3c,0x3c,0x3c,0x3c,0xfc,0xff,0x00,0x3c,0x00,0x00, /* 52 4 */ + 0xfc,0x3f,0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x00,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 53 5 */ + 0xf0,0x0f,0x3c,0x3c,0x3c,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 54 6 */ + 0xfc,0x3f,0x3c,0x3c,0x00,0x3c,0x00,0x0f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 55 7 */ + 0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 56 8 */ + 0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x3f,0x00,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 57 9 */ + 0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0x00,0x00, /* 58 : */ + 0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x03,0xc0,0x00, /* 59 ; */ + 0x00,0x0c,0x00,0x03,0xc0,0x00,0x30,0x00,0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x00, /* 60 < */ + 0x00,0x00,0x00,0x00,0xfc,0xff,0x00,0x00,0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00, /* 61 = */ + 0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x30,0x00,0x0c,0x00,0x03,0xc0,0x00,0x00,0x00, /* 62 > */ + 0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0x00,0x0f,0xc0,0x03,0x00,0x00,0xc0,0x03,0x00,0x00, /* 63 ? */ + 0xf0,0x3f,0x0c,0xcc,0xcc,0xcf,0xcc,0xcc,0xcc,0xff,0x0c,0x00,0xf0,0x3f,0x00,0x00, /* 64 @ */ + 0xc0,0x0f,0xf0,0x3c,0x3c,0xf0,0x3c,0xf0,0xfc,0xff,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 65 A */ + 0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x00,0x00, /* 66 B */ + 0xf0,0x3f,0x3c,0xf0,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 67 C */ + 0xfc,0x0f,0x3c,0x3c,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0x3c,0xfc,0x0f,0x00,0x00, /* 68 D */ + 0xfc,0x3f,0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x00,0x3c,0x00,0xfc,0x3f,0x00,0x00, /* 69 E */ + 0xfc,0x3f,0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 70 F */ + 0xf0,0x3f,0x3c,0xf0,0x3c,0x00,0x3c,0xfc,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 71 G */ + 0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xfc,0xff,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 72 H */ + 0xf0,0x0f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xf0,0x0f,0x00,0x00, /* 73 I */ + 0x00,0xff,0x00,0xf0,0x00,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 74 J */ + 0x3c,0xf0,0x3c,0x3c,0x3c,0x0f,0xfc,0x03,0x3c,0x0f,0x3c,0x3c,0x3c,0xf0,0x00,0x00, /* 75 K */ + 0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0xfc,0xff,0x00,0x00, /* 76 L */ + 0x3c,0xf0,0xfc,0xfc,0xfc,0xff,0x3c,0xf3,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 77 M */ + 0x3c,0xf0,0xfc,0xf0,0xfc,0xf3,0x3c,0xff,0x3c,0xfc,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 78 N */ + 0xf0,0x3f,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 79 O */ + 0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 80 P */ + 0xf0,0x3f,0x3c,0xf0,0x3c,0xf0,0x3c,0xf3,0x3c,0xff,0x3c,0xfc,0xf0,0x3f,0x00,0x00, /* 81 Q */ + 0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x3c,0x0f,0x3c,0x3c,0x3c,0xf0,0x00,0x00, /* 82 R */ + 0xf0,0x3f,0x3c,0xf0,0x3c,0x00,0xf0,0x3f,0x00,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 83 S */ + 0xfc,0x3f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 84 T */ + 0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 85 U */ + 0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3c,0xf0,0x3c,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 86 V */ + 0x3c,0xf0,0x3c,0xf3,0x3c,0xf3,0x3c,0xf3,0xfc,0xff,0xf0,0x3c,0x30,0x30,0x00,0x00, /* 87 W */ + 0x3c,0xf0,0x3c,0xf0,0xf0,0x3c,0xc0,0x0f,0xf0,0x3c,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 88 X */ + 0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 89 Y */ + 0xfc,0xff,0x00,0xf0,0x00,0x3c,0x00,0x0f,0xc0,0x03,0xf0,0x00,0xfc,0xff,0x00,0x00, /* 90 Z */ + 0xc0,0x0f,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x0f,0x00,0x00, /* 91 [ */ + 0x0c,0x00,0x30,0x00,0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x30,0x00,0xc0,0x00,0x00, /* 92 \ */ + 0xc0,0x0f,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0xc0,0x0f,0x00,0x00, /* 93 ] */ + 0x00,0x03,0xc0,0x0f,0xf0,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 94 ^ */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0x00,0x00, /* 95 _ */ + 0xc0,0x03,0xc0,0x03,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 96 ` */ + 0x00,0x00,0x00,0x00,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0xff,0x00,0x00, /* 97 a */ + 0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xfc,0x0f,0x00,0x00, /* 98 b */ + 0x00,0x00,0x00,0x00,0xf0,0x0f,0x3c,0x3c,0x3c,0x00,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 99 c */ + 0x00,0x3c,0x00,0x3c,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x3f,0x00,0x00, /* 100 d */ + 0x00,0x00,0x00,0x00,0xf0,0x0f,0x3c,0x3c,0xfc,0x3f,0x3c,0x00,0xf0,0x0f,0x00,0x00, /* 101 e */ + 0xc0,0x0f,0xf0,0x30,0xf0,0x00,0xfc,0x0f,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00,0x00, /* 102 f */ + 0x00,0x00,0x00,0x00,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0xc0,0x3f,0x3c,0x3c,0xf0,0x0f, /* 103 g */ + 0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x00,0x00, /* 104 h */ + 0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 105 i */ + 0x00,0x3c,0x00,0x00,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x3c,0x3c,0xf0,0x0f, /* 106 j */ + 0x3c,0x00,0x3c,0x00,0x3c,0x3c,0x3c,0x0f,0xfc,0x00,0x3c,0x0f,0x3c,0x3c,0x00,0x00, /* 107 k */ + 0xf0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xf0,0x0f,0x00,0x00, /* 108 l */ + 0x00,0x00,0x00,0x00,0xfc,0x3c,0x3c,0xf3,0x3c,0xf3,0x3c,0xf3,0x3c,0xf3,0x00,0x00, /* 109 m */ + 0x00,0x00,0x00,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x00,0x00, /* 110 n */ + 0x00,0x00,0x00,0x00,0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 111 o */ + 0x00,0x00,0x00,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0xfc,0x0f,0x3c,0x00,0x3c,0x00, /* 112 p */ + 0x00,0x00,0x00,0x00,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0xc0,0x3f,0x00,0x3c,0x00,0x3c, /* 113 q */ + 0x00,0x00,0x00,0x00,0x3c,0x3f,0xfc,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 114 r */ + 0x00,0x00,0x00,0x00,0xf0,0x3f,0xfc,0x00,0xf0,0x0f,0x00,0x3f,0xfc,0x0f,0x00,0x00, /* 115 s */ + 0xc0,0x03,0xc0,0x03,0xf0,0x3f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x3f,0x00,0x00, /* 116 t */ + 0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0xff,0x00,0x00, /* 117 u */ + 0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x30,0x0c,0xf0,0x0f,0xc0,0x03,0x00,0x00, /* 118 v */ + 0x00,0x00,0x00,0x00,0x3c,0xf0,0x3c,0xf3,0x30,0x33,0xf0,0x3f,0xc0,0x0c,0x00,0x00, /* 119 w */ + 0x00,0x00,0x00,0x00,0x3c,0x3c,0xf0,0x0f,0xc0,0x03,0xf0,0x0f,0x3c,0x3c,0x00,0x00, /* 120 x */ + 0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0xc0,0x03,0xf0,0x00,0x3c,0x00, /* 121 y */ + 0x00,0x00,0x00,0x00,0xfc,0x3f,0x00,0x0f,0xc0,0x03,0xf0,0x00,0xfc,0x3f,0x00,0x00, /* 122 z */ + 0x00,0x0f,0xc0,0x03,0xc0,0x03,0xf0,0x00,0xc0,0x03,0xc0,0x03,0x00,0x0f,0x00,0x00, /* 123 { */ + 0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 124 | */ + 0xc0,0x03,0x00,0x0f,0x00,0x0f,0x00,0x3c,0x00,0x0f,0x00,0x0f,0xc0,0x03,0x00,0x00, /* 125 } */ + 0xf0,0x30,0xf0,0x0f,0x0c,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 126 ~ */ + 0x00,0x03,0x00,0x03,0xc0,0x0c,0xc0,0x0c,0x30,0x30,0x30,0x30,0xf0,0x3f,0x00,0x00 /* 127 △ */ +}; diff --git a/WWTextP.h b/WWTextP.h new file mode 100644 index 0000000..841e8dc --- /dev/null +++ b/WWTextP.h @@ -0,0 +1,36 @@ +#ifndef _WWTextP_h_INCLUDED_ +#define _WWTextP_h_INCLUDED_ + +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "WWText.h" +#include "WWCharacter.h" + +/*****************************************************************************/ +/* クラスの定義 */ +/*****************************************************************************/ + +typedef struct _WWText { + + /* テキストの描画情報 */ + + WWScreen screen; /* テキストスクリーン */ + int x, y, width, height; /* テキストウインドウの領域 */ + int base; /* 使用するキャラクタのベース */ + + WWPalette palette; + WWCharacter font[128]; /* フォント */ + +} _WWText; + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +#endif + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/Wonx.c b/Wonx.c new file mode 100644 index 0000000..4ce9e27 --- /dev/null +++ b/Wonx.c @@ -0,0 +1,52 @@ +#include "WonxP.h" +#include "etc.h" + +#include +#include + +/*****************************************************************************/ +/* ディスプレイの確保 */ +/*****************************************************************************/ + +static Wonx wonx = NULL; + +int Wonx_IsCreated(void) +{ + return (wonx != NULL); +} + +void Wonx_Create(void) +{ + WWScreen screen; + WWPalette palette; + + wonx = (Wonx)malloc(sizeof(_Wonx)); + if (wonx == NULL) Error("Wonx_Create", "Cannot allocate memory."); + + wonx->wonx_display = + WonxDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2, + LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, + SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT); + screen = + WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx->wonx_display), SCREEN2); + /* デフォルトのテキスト表示用パレットは0 */ + palette = + WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx->wonx_display), 0); + + wonx->wonx_text = + WonxText_Create(screen, 0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT, + palette); + + return; +} + +WonxDisplay Wonx_GetWonxDisplay(void) +{ + return (wonx->wonx_display); +} + +WonxText Wonx_GetWonxText(void) +{ + return (wonx->wonx_text); +} + diff --git a/wonx.h b/Wonx.h similarity index 74% rename from wonx.h rename to Wonx.h index ce4ba0e..e2ff7c9 100644 --- a/wonx.h +++ b/Wonx.h @@ -1,16 +1,16 @@ #ifndef _wonx_h_INCLUDED_ #define _wonx_h_INCLUDED_ -#include - #include "WonxDisplay.h" +#include "WonxText.h" /*****************************************************************************/ /* ディスプレイの確保 */ /*****************************************************************************/ -extern WonxDisplay wonx_display; - +int Wonx_IsCreated(void); void Wonx_Create(void); +WonxDisplay Wonx_GetWonxDisplay(void); +WonxText Wonx_GetWonxText(void); #endif diff --git a/WonxDisplay.c b/WonxDisplay.c index 4a2f3a0..3ddfd02 100644 --- a/WonxDisplay.c +++ b/WonxDisplay.c @@ -3,6 +3,7 @@ /*****************************************************************************/ #include "WonxDisplayP.h" +#include "etc.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/WonxP.h b/WonxP.h new file mode 100644 index 0000000..aa555b3 --- /dev/null +++ b/WonxP.h @@ -0,0 +1,29 @@ +#ifndef _WonxP_h_INCLUDED_ +#define _WonxP_h_INCLUDED_ + +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "Wonx.h" + +/*****************************************************************************/ +/* クラスの定義 */ +/*****************************************************************************/ + +typedef struct _Wonx { + WonxDisplay wonx_display; + WonxText wonx_text; +} _Wonx; + +typedef struct _Wonx * Wonx; + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +#endif + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/WonxText.c b/WonxText.c new file mode 100644 index 0000000..641a640 --- /dev/null +++ b/WonxText.c @@ -0,0 +1,55 @@ +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "WonxTextP.h" +#include "etc.h" + +/*****************************************************************************/ +/* メンバ関数の定義 */ +/*****************************************************************************/ + +WWText WonxText_GetWWText(WonxText wonx_text) +{ return (wonx_text->ww_text); } +WWText WonxText_SetWWText(WonxText wonx_text, WWText ww_text) +{ return (wonx_text->ww_text = ww_text); } + +WonxText WonxText_Create(WWScreen screen, int x, int y, int width, int height, + WWPalette palette) +{ + WonxText wonx_text; + WWText ww_text; + + wonx_text = (WonxText)malloc(sizeof(_WonxText)); + if (wonx_text == NULL) + Error("WonxText_Create", "Cannot allocate memory."); + + ww_text = WWText_Create(screen, x, y, width, height, palette); + if (ww_text == NULL) + Error("WonxText_Create", "Cannot create WonderWitch text."); + WonxText_SetWWText(wonx_text, ww_text); + + return (wonx_text); +} + +WonxText WonxText_Destroy(WonxText wonx_text) +{ + if (wonx_text == NULL) + Error("WonxText_Destroy", "Object is not created."); + + if (WonxText_GetWWText(wonx_text)) + WonxText_SetWWText(wonx_text, + WWText_Destroy(WonxText_GetWWText(wonx_text))); + + free(wonx_text); + + return (NULL); +} + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/WonxText.h b/WonxText.h new file mode 100644 index 0000000..26873bc --- /dev/null +++ b/WonxText.h @@ -0,0 +1,32 @@ +#ifndef _WonxText_h_INCLUDED_ +#define _WonxText_h_INCLUDED_ + +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "WWText.h" +#include "WWScreen.h" +#include "WWPalette.h" + +/*****************************************************************************/ +/* クラスの定義 */ +/*****************************************************************************/ + +typedef struct _WonxText * WonxText; + +WWText WonxText_GetWWText(WonxText wonx_text); +WWText WonxText_SetWWText(WonxText wonx_text, WWText ww_text); +WonxText WonxText_Create(WWScreen screen, int x, int y, int width, int height, + WWPalette palette); +WonxText WonxText_Destroy(WonxText wonx_text); + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +#endif + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/WonxTextP.h b/WonxTextP.h new file mode 100644 index 0000000..92659a3 --- /dev/null +++ b/WonxTextP.h @@ -0,0 +1,26 @@ +#ifndef _WonxTextP_h_INCLUDED_ +#define _WonxTextP_h_INCLUDED_ + +/*****************************************************************************/ +/* ここから */ +/*****************************************************************************/ + +#include "WonxText.h" + +/*****************************************************************************/ +/* クラスの定義 */ +/*****************************************************************************/ + +typedef struct _WonxText { + WWText ww_text; +} _WonxText; + +/*****************************************************************************/ +/* ここまで */ +/*****************************************************************************/ + +#endif + +/*****************************************************************************/ +/* End of File. */ +/*****************************************************************************/ diff --git a/XDisplay.c b/XDisplay.c index 8fef3de..8b3dbcf 100644 --- a/XDisplay.c +++ b/XDisplay.c @@ -1,10 +1,14 @@ -#include - /*****************************************************************************/ /* ここから */ /*****************************************************************************/ #include "XDisplayP.h" +#include "Wonx.h" +#include "etc.h" + +#include +#include +#include /*****************************************************************************/ /* メンバ関数の定義 */ @@ -31,7 +35,10 @@ int XDisplay_SetSpritePrint(XDisplay d, int f) /* 内部で使用する関数などの定義 */ /*****************************************************************************/ +#if 0 static XrmOptionDescRec options[] = {}; +#endif + static Atom wm_delete_window; static void die(Widget w) @@ -60,7 +67,7 @@ static void iconify(Widget w, XEvent * event, String * params, Cardinal * num) XIconifyWindow(XtDisplay(w), XtWindow(w), DefaultScreen(XtDisplay(w))); } -static void pause(Widget w, XEvent * event, String * params, Cardinal * num) +static void sleep_3(Widget w, XEvent * event, String * params, Cardinal * num) { sleep(3); } @@ -69,7 +76,7 @@ static XtActionsRec actions[] = { {"quit", quit}, {"wm_protocols_proc", wm_protocols_proc}, {"iconify", iconify}, - {"pause", pause} + {"pause", sleep_3} }; static char * translations = @@ -134,7 +141,11 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event, switch (key_sym) { /* 表示モード変更 */ - case XK_p : x_display->lcd_draw = !(x_display->lcd_draw); break; + case XK_p : + x_display->lcd_draw = !(x_display->lcd_draw); + if (x_display->lcd_draw) + WonxDisplay_Flush(Wonx_GetWonxDisplay()); + break; /* データのダンプ操作 */ case XK_F1 : x_display->color_map_print = 1; break; diff --git a/bank.c b/bank.c index 2640f8e..626d87f 100644 --- a/bank.c +++ b/bank.c @@ -7,7 +7,7 @@ #include -#include "wonx.h" +#include "Wonx.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/comm.c b/comm.c index 3abe1bd..6c18b02 100644 --- a/comm.c +++ b/comm.c @@ -7,7 +7,7 @@ #include -#include "wonx.h" +#include "Wonx.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/disp.c b/disp.c index 0332987..6f1853c 100644 --- a/disp.c +++ b/disp.c @@ -7,9 +7,7 @@ #include -#include "wonx.h" - -#include "WonxDisplay.h" +#include "Wonx.h" /*****************************************************************************/ /* メンバ関数の定義 */ @@ -22,9 +20,9 @@ void display_control(unsigned int flags) printf("call : display_control() : flags = 0x%04x\n", (int)flags); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - ww_display = WonxDisplay_GetWWDisplay(wonx_display); + ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); WWScreen_SetEnable(WWDisplay_GetScreen(ww_display, SCREEN1), (flags & DCM_SCR1) ? 1 : 0); @@ -45,7 +43,7 @@ void display_control(unsigned int flags) WWDisplay_SetBorder(ww_display, (flags & DCM_BORDER_COLOR) >> 7); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : display_control() : return value = none\n"); fflush(stdout); @@ -59,9 +57,9 @@ unsigned int display_status() printf("call : display_status() : \n"); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - ww_display = WonxDisplay_GetWWDisplay(wonx_display); + ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); ret = 0; @@ -71,10 +69,10 @@ unsigned int display_status() if (WWScreen_GetEnable(WWDisplay_GetScreen(ww_display, SCREEN2))) ret |= DCM_SCR2; - if (WWDisplay_GetSpriteEnable(WonxDisplay_GetWWDisplay(wonx_display))) + if (WWDisplay_GetSpriteEnable(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()))) ret |= DCM_SPR; - if (WWDisplay_GetSpriteWindowEnable(WonxDisplay_GetWWDisplay(wonx_display))) + if (WWDisplay_GetSpriteWindowEnable(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()))) ret |= DCM_SPR_WIN; switch (WWScreen_GetMode(WWDisplay_GetScreen(ww_display, SCREEN2))) { @@ -87,9 +85,9 @@ unsigned int display_status() default: } - ret |= WWDisplay_GetBorder(WonxDisplay_GetWWDisplay(wonx_display)) << 7; + ret |= WWDisplay_GetBorder(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay())) << 7; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : display_status() : return value = %u\n", (int)ret); fflush(stdout); @@ -107,15 +105,15 @@ void font_set_monodata(unsigned int number, unsigned int count, void * data) printf("call : font_set_monodata() : number = %u, count = %u, data = %p\n", (int)number, (int)count, data); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); n = 0; d = (unsigned char *)data; /* ひとつのキャラクタデータは8バイト */ - f = WWDisplay_GetForegroundColor(WonxDisplay_GetWWDisplay(wonx_display)); - b = WWDisplay_GetBackgroundColor(WonxDisplay_GetWWDisplay(wonx_display)); + f = WWDisplay_GetForegroundColor(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay())); + b = WWDisplay_GetBackgroundColor(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay())); for (i = 0; i < count; i++) { - c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), + c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), number + i); for (y = 0; y < 8; y++) { for (x = 0; x < 8; x++) { @@ -126,7 +124,7 @@ void font_set_monodata(unsigned int number, unsigned int count, void * data) } } - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : font_set_monodata() : return value = none\n"); fflush(stdout); @@ -139,19 +137,18 @@ void font_set_colordata(unsigned int number, { WWCharacter c; int i, x, y, n, p; - int f, b; unsigned char * d; printf("call : font_set_colordata() : number = %u, count = %u, data = %p\n", (int)number, (int)count, data); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); n = 0; d = (unsigned char *)data; /* ひとつのキャラクタデータは16バイト */ for (i = 0; i < count; i++) { - c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), + c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), number + i); for (y = 0; y < 8; y++) { for (x = 0; x < 8; x++) { @@ -166,7 +163,7 @@ void font_set_colordata(unsigned int number, } } - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : font_set_colordata() : return value = none\n"); fflush(stdout); @@ -180,19 +177,18 @@ void font_get_data(unsigned int number, /* 関数の仕様がわからんので適当に書くぞ */ WWCharacter c; int i, x, y, n, p; - int f, b; unsigned char * d; printf("call : font_get_data() : number = %u, count = %u, data = %p\n", (int)number, (int)count, data); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); n = 0; d = (unsigned char *)data; /* ひとつのキャラクタデータは16バイト? */ for (i = 0; i < count; i++) { - c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), + c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), number + i); for (y = 0; y < 8; y++) { d[n ] = 0; @@ -208,7 +204,7 @@ void font_get_data(unsigned int number, } } - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : font_get_data() : return value = none\n"); fflush(stdout); @@ -222,13 +218,13 @@ void font_set_color(unsigned int colors) printf("call : font_set_color() : colors = 0x%04x\n", (int)colors); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - dis = WonxDisplay_GetWWDisplay(wonx_display); + dis = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); WWDisplay_SetForegroundColor(dis, colors & 0x03); WWDisplay_SetBackgroundColor(dis, (colors >> 2) & 0x03); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : font_set_color() : return value = none\n"); fflush(stdout); @@ -242,14 +238,14 @@ unsigned int font_get_color(void) printf("call : font_get_color() : \n"); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - dis = WonxDisplay_GetWWDisplay(wonx_display); + dis = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); ret = 0; ret |= WWDisplay_GetForegroundColor(dis); ret |= WWDisplay_GetBackgroundColor(dis) << 2; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : font_get_color() : return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -257,98 +253,66 @@ unsigned int font_get_color(void) return (ret); } -void screen_set_char(int screen, int x, int y, int w, int h, void * data) +static void _screen_set_char1(int screen, int x, int y, + unsigned short int data) { - int i, j; int horizontal; /* 横方向反転フラグ */ int vertical; /* 縦方向反転フラグ */ int palette_num; /* パレット番号 */ int character_num; /* 表示キャラクタ */ - unsigned short int * d; + WWDisplay display; WWScreen s; WWPalette p; WWCharacter c; - printf("call : screen_set_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p\n", - screen, x, y, w, h, data); fflush(stdout); + display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); - if (wonx_display == NULL) Wonx_Create(); + s = WWDisplay_GetScreen(display, screen); + + horizontal = (data & (1 << 15)) ? 1 : 0; + vertical = (data & (1 << 14)) ? 1 : 0; + palette_num = (data >> 9) & 0x0f; + character_num = data & 0x1ff; + + p = WWDisplay_GetPalette(display, palette_num); + c = WWDisplay_GetCharacter(display, character_num); + + WWScreen_SetHorizontal(s, x, y, horizontal); + WWScreen_SetVertical( s, x, y, vertical); + WWScreen_SetPalette( s, x, y, p); + WWScreen_SetCharacter( s, x, y, c); + + return; +} + +void screen_set_char(int screen, int x, int y, int w, int h, void * data) +{ + int i, j; + unsigned short int * d; + + printf("call : screen_set_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p\n", + screen, x, y, w, h, data); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); d = (unsigned short int *)data; - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen); for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { - horizontal = (*d & (1 << 15)) ? 1 : 0; - vertical = (*d & (1 << 14)) ? 1 : 0; - palette_num = (*d >> 9) & 0x0f; - character_num = *d & 0x1ff; - p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), - palette_num); - c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), - character_num); - WWScreen_SetHorizontal(s, x + i, y + j, horizontal); - WWScreen_SetVertical( s, x + i, y + j, vertical); - WWScreen_SetPalette( s, x + i, y + j, p); - WWScreen_SetCharacter( s, x + i, y + j, c); - + _screen_set_char1(screen, x + i, y + j, *d); d++; } } - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : screen_set_char() : return value = none\n"); fflush(stdout); return; } -void screen_get_char(int screen, int x, int y, int w, int h, void * data) -{ - int i, j; - int horizontal; /* 横方向反転フラグ */ - int vertical; /* 縦方向反転フラグ */ - int palette_num; /* パレット番号 */ - int character_num; /* 表示キャラクタ */ - unsigned short int * d; - WWScreen s; - WWPalette p; - WWCharacter c; - - printf("call : screen_get_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p\n", - screen, x, y, w, h, data); fflush(stdout); - - if (wonx_display == NULL) Wonx_Create(); - - d = (unsigned short int *)data; - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen); - - for (j = 0; j < h; j++) { - for (i = 0; i < w; i++) { - horizontal = WWScreen_GetHorizontal(s, x + i, y + j); - vertical = WWScreen_GetVertical( s, x + i, y + j); - p = WWScreen_GetPalette( s, x + i, y + j); - c = WWScreen_GetCharacter( s, x + i, y + j); - palette_num = WWPalette_GetNumber(p); - character_num = WWCharacter_GetNumber(c); - - *d = 0; - *d |= horizontal << 15; - *d |= vertical << 14; - *d |= palette_num << 9; - *d |= character_num; - d++; - } - } - - WonxDisplay_Sync(wonx_display); - - printf("call : screen_get_char() : return value = none\n"); fflush(stdout); - - return; -} - -unsigned int screen_get_char1(int screen, int x, int y) +static unsigned int _screen_get_char1(int screen, int x, int y) { int horizontal; /* 横方向反転フラグ */ int vertical; /* 縦方向反転フラグ */ @@ -359,19 +323,14 @@ unsigned int screen_get_char1(int screen, int x, int y) WWCharacter c; unsigned short int ret; - printf("call : screen_get_char1() : screen = %d, x = %d, y = %d\n", - screen, x, y); - fflush(stdout); + s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + screen); - if (wonx_display == NULL) Wonx_Create(); - - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen); - - horizontal = WWScreen_GetHorizontal(s, x, y); - vertical = WWScreen_GetVertical( s, x, y); - p = WWScreen_GetPalette( s, x, y); - c = WWScreen_GetCharacter( s, x, y); - palette_num = WWPalette_GetNumber(p); + horizontal = WWScreen_GetHorizontal(s, x, y); + vertical = WWScreen_GetVertical( s, x, y); + p = WWScreen_GetPalette( s, x, y); + c = WWScreen_GetCharacter( s, x, y); + palette_num = WWPalette_GetNumber(p); character_num = WWCharacter_GetNumber(c); ret = 0; @@ -380,7 +339,49 @@ unsigned int screen_get_char1(int screen, int x, int y) ret |= palette_num << 9; ret |= character_num; - WonxDisplay_Sync(wonx_display); + return (ret); +} + +void screen_get_char(int screen, int x, int y, int w, int h, void * data) +{ + int i, j; + unsigned short int * d; + + printf("call : screen_get_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p\n", + screen, x, y, w, h, data); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + d = (unsigned short int *)data; + + for (j = 0; j < h; j++) { + for (i = 0; i < w; i++) { + *d = _screen_get_char1(screen, x, y); + d++; + } + } + + WonxDisplay_Sync(Wonx_GetWonxDisplay()); + + printf("call : screen_get_char() : return value = none\n"); fflush(stdout); + + return; +} + +unsigned int screen_get_char1(int screen, int x, int y) +{ + unsigned short int ret; + + printf("call : screen_get_char1() : screen = %d, x = %d, y = %d\n", + screen, x, y); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + ret = _screen_get_char1(screen, x, y); + + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : screen_get_char1() : return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -392,41 +393,20 @@ void screen_fill_char(int screen, int x, int y, int w, int h, unsigned int data) { int i, j; - int horizontal; /* 横方向反転フラグ */ - int vertical; /* 縦方向反転フラグ */ - int palette_num; /* パレット番号 */ - int character_num; /* 表示キャラクタ */ - WWScreen s; - WWPalette p; - WWCharacter c; printf("call : screen_fill_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x\n", - screen, x, y, w, h, (int)data); fflush(stdout); + screen, x, y, w, h, (int)data); + fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); - - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen); - - horizontal = (data & (1 << 15)) ? 1 : 0; - vertical = (data & (1 << 14)) ? 1 : 0; - palette_num = (data >> 9) & 0x0f; - character_num = data & 0x1ff; - - p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), - palette_num); - c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), - character_num); + if (!Wonx_IsCreated()) Wonx_Create(); for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { - WWScreen_SetHorizontal(s, x + i, y + j, horizontal); - WWScreen_SetVertical( s, x + i, y + j, vertical); - WWScreen_SetPalette( s, x + i, y + j, p); - WWScreen_SetCharacter( s, x + i, y + j, c); + _screen_set_char1(screen, x + i, y + j, data); } } - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : screen_fill_char() : return value = none\n"); fflush(stdout); @@ -442,18 +422,18 @@ void screen_fill_attr(int screen, int x, int y, int w, int h, printf("call : screen_fill_attr() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x, mask = 0x%04x\n", screen, x, y, w, h, (int)data, (int)mask); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { - c = screen_get_char1(screen, x + i, y + j); + c = _screen_get_char1(screen, x + i, y + j); c &= mask; c |= data; - screen_fill_char(screen, x + i, y + j, 1, 1, c); + _screen_set_char1(screen, x + i, y + j, c); } } - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : screen_fill_attr() : return value = none\n"); fflush(stdout); @@ -465,66 +445,70 @@ void sprite_set_range(unsigned int sprite_start, unsigned int sprite_count) printf("call : sprite_set_range() : start = %u, count = %u\n", (int)sprite_start, (int)sprite_count); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - WWDisplay_SetSpriteStart(WonxDisplay_GetWWDisplay(wonx_display), + WWDisplay_SetSpriteStart(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), sprite_start); - WWDisplay_SetSpriteCount(WonxDisplay_GetWWDisplay(wonx_display), + WWDisplay_SetSpriteCount(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), sprite_count); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : sprite_set_range() : return value = none\n"); fflush(stdout); return; } -void sprite_set_char(unsigned int sprite_num, unsigned int data) +static void _sprite_set_char(unsigned int sprite_num, unsigned int data) { WWSprite s; WWPalette p; WWCharacter c; - printf("call : sprite_set_char() : number = %u, data = 0x%04x\n", - (int)sprite_num, (int)data); fflush(stdout); - - if (wonx_display == NULL) Wonx_Create(); - - s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num); + s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + sprite_num); WWSprite_SetHorizontal(s, (data >> 15) ? 1 : 0); WWSprite_SetVertical( s, (data >> 14) ? 1 : 0); WWSprite_SetPriority( s, (data >> 13) ? 1 : 0); WWSprite_SetClipping( s, (data >> 12) ? 1 : 0); - p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), + p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), (data >> 9) & 0x07); - c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), + c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), data & 0x1ff); WWSprite_SetPalette(s, p); WWSprite_SetCharacter(s, c); - WonxDisplay_Flush(wonx_display); + return; +} + +void sprite_set_char(unsigned int sprite_num, unsigned int data) +{ + printf("call : sprite_set_char() : number = %u, data = 0x%04x\n", + (int)sprite_num, (int)data); fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + _sprite_set_char(sprite_num, data); + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : sprite_set_char() : return value = none\n"); fflush(stdout); return; } -unsigned int sprite_get_char(unsigned int sprite_num) +static unsigned int _sprite_get_char(unsigned int sprite_num) { WWSprite s; WWPalette p; WWCharacter c; unsigned short int ret; - printf("call : sprite_get_char() : number = %u\n", (int)sprite_num); - fflush(stdout); - - if (wonx_display == NULL) Wonx_Create(); - - s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num); + s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + sprite_num); ret = 0; @@ -534,13 +518,25 @@ unsigned int sprite_get_char(unsigned int sprite_num) ret |= (WWSprite_GetClipping( s) ? 1 : 0) << 12; p = WWSprite_GetPalette(s); - - ret |= (WWPalette_GetNumber(p) & 0x07) << 9; - c = WWSprite_GetCharacter(s); + ret |= (WWPalette_GetNumber(p) & 0x07) << 9; ret |= WWCharacter_GetNumber(c); - WonxDisplay_Sync(wonx_display); + return (ret); +} + +unsigned int sprite_get_char(unsigned int sprite_num) +{ + unsigned short int ret; + + printf("call : sprite_get_char() : number = %u\n", (int)sprite_num); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + ret = _sprite_get_char(sprite_num); + + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : sprite_get_char() : return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -548,19 +544,28 @@ unsigned int sprite_get_char(unsigned int sprite_num) return (ret); } -void sprite_set_location(unsigned int sprite_num, int x, int y) +static void _sprite_set_location(unsigned int sprite_num, int x, int y) { WWSprite s; - printf("call : sprite_set_location() : number = %u, x = %d, y = %d\n", - (int)sprite_num, x, y); fflush(stdout); - - if (wonx_display == NULL) Wonx_Create(); - - s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num); + s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + sprite_num); WWSprite_SetPosition(s, x, y); - WonxDisplay_Flush(wonx_display); + return; +} + +void sprite_set_location(unsigned int sprite_num, int x, int y) +{ + printf("call : sprite_set_location() : number = %u, x = %d, y = %d\n", + (int)sprite_num, x, y); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + _sprite_set_location(sprite_num, x, y); + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : sprite_set_location() : return value = none\n"); fflush(stdout); @@ -568,21 +573,31 @@ void sprite_set_location(unsigned int sprite_num, int x, int y) return; } -unsigned int sprite_get_location(unsigned int sprite_num) +static unsigned int _sprite_get_location(unsigned int sprite_num) { WWSprite s; unsigned short int ret; + s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + sprite_num); + + ret = (WWSprite_GetY(s) << 8) | WWSprite_GetX(s); + + return (ret); +} + +unsigned int sprite_get_location(unsigned int sprite_num) +{ + unsigned short int ret; + printf("call : sprite_get_location() : number = %u\n", (int)sprite_num); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - s = WWDisplay_GetSprite(WonxDisplay_GetWWDisplay(wonx_display), sprite_num); + ret = _sprite_get_location(sprite_num); - ret = (WWSprite_GetY(s) << 8) | WWSprite_GetX(s); - - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : sprite_get_location() : return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -590,18 +605,27 @@ unsigned int sprite_get_location(unsigned int sprite_num) return (ret); } +static void _sprite_set_char_location(unsigned int sprite_num, + unsigned int data, int x, int y) +{ + _sprite_set_char(sprite_num, data); + _sprite_set_location(sprite_num, x, y); + + return; +} + void sprite_set_char_location(unsigned int sprite_num, unsigned int data, int x, int y) { - if (wonx_display == NULL) Wonx_Create(); - printf("call : sprite_set_char_location() : number = %u, data = 0x%04x, x = %d, y = %d\n", - (int)sprite_num, (int)data, x, y); fflush(stdout); + (int)sprite_num, (int)data, x, y); + fflush(stdout); - sprite_set_char(sprite_num, data); - sprite_set_location(sprite_num, x, y); + if (!Wonx_IsCreated()) Wonx_Create(); - WonxDisplay_Flush(wonx_display); + _sprite_set_char_location(sprite_num, data, x, y); + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : sprite_set_char_location() : return value = none\n"); fflush(stdout); @@ -616,13 +640,13 @@ unsigned long int sprite_get_char_location(unsigned int sprite_num) printf("call : sprite_get_char_location() : number = %u\n", (int)sprite_num); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); ret = 0; - ret |= ((unsigned long int)sprite_get_char(sprite_num)); - ret |= (unsigned long int)sprite_get_location(sprite_num) << 16; + ret |= ((unsigned long int)_sprite_get_char(sprite_num)); + ret |= (unsigned long int)_sprite_get_location(sprite_num) << 16; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : sprite_get_char_location() : return value = 0x%08x\n", (int)ret); @@ -634,23 +658,23 @@ unsigned long int sprite_get_char_location(unsigned int sprite_num) void sprite_set_data(unsigned int sprite_num, unsigned int count, void * data) { int i; - char * d; unsigned long int * n; printf("call : sprite_set_data() : number = %u, count = %u, data = %p\n", - (int)sprite_num, (int)count, data); fflush(stdout); + (int)sprite_num, (int)count, data); + fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); n = (unsigned long int *)data; for (i = 0; i < count; i++) { - sprite_set_char_location(sprite_num + i, - n[i] >> 16, - (n[i] >> 8) & 0xff, - n[i] & 0xff); + _sprite_set_char_location(sprite_num + i, + n[i] >> 16, + (n[i] >> 8) & 0xff, + n[i] & 0xff); } - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : sprite_set_data() : return value = none\n"); fflush(stdout); @@ -662,15 +686,17 @@ void screen_set_scroll(int screen, int x, int y) WWScreen s; printf("call : screen_set_scroll() : screen = %d, x = %d, y = %d\n", - screen, x, y); fflush(stdout); + screen, x, y); + fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen); + s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + screen); WWScreen_SetRollX(s, x); WWScreen_SetRollY(s, y); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : screen_set_scroll() : return value = none\n"); fflush(stdout); @@ -684,15 +710,16 @@ unsigned int screen_get_scroll(int screen) printf("call : screen_get_scroll() : screen = %d\n", screen); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), screen); + s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + screen); ret = 0; ret |= WWScreen_GetRollX(s); ret |= WWScreen_GetRollY(s) << 8; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : screen_get_scroll() : return value = %u\n", (int)ret); fflush(stdout); @@ -707,15 +734,16 @@ void screen2_set_window(int x, int y, int w, int h) printf("call : screen2_set_window() : x = %d, y = %d, width = %d, height = %d\n", x, y, w, h); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2); + s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + SCREEN2); WWScreen_SetDrawX(s, x); WWScreen_SetDrawY(s, y); WWScreen_SetDrawWidth( s, w); WWScreen_SetDrawHeight(s, h); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : screen2_set_window() : return value = none\n"); fflush(stdout); @@ -730,11 +758,12 @@ unsigned long int screen2_get_window(void) unsigned short int wh; unsigned long int ret; - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); printf("call : screen2_get_window() : \n"); fflush(stdout); - s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2); + s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), + SCREEN2); xy = (((unsigned short int)WWScreen_GetDrawY(s) << 8) & 0xff00) | @@ -744,7 +773,7 @@ unsigned long int screen2_get_window(void) ((unsigned short int)WWScreen_GetDrawWidth(s) & 0x00ff); ret = ((unsigned long int)wh) << 16 | xy; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : screen2_get_window() : return value = 0x%08x\n", (int)ret); fflush(stdout); @@ -760,16 +789,16 @@ void sprite_set_window(int x, int y, int w, int h) x, y, w, h); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - d = WonxDisplay_GetWWDisplay(wonx_display); + d = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); WWDisplay_SetSpriteWindowX(d, x); WWDisplay_SetSpriteWindowY(d, y); WWDisplay_SetSpriteWindowWidth(d, w); WWDisplay_SetSpriteWindowHeight(d, h); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : sprite_set_window() : return value = none\n"); fflush(stdout); @@ -787,9 +816,9 @@ unsigned long int sprite_get_window(void) printf("call : sprite_get_window() : \n"); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - d = WonxDisplay_GetWWDisplay(wonx_display); + d = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); xy = (((unsigned short int)WWDisplay_GetSpriteWindowY(d) << 8) & 0xff00) | @@ -799,7 +828,7 @@ unsigned long int sprite_get_window(void) ((unsigned short int)WWDisplay_GetSpriteWindowWidth(d) & 0x00ff); ret = ((unsigned long int)wh) << 16 | xy; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : sprite_get_window() : return value = 0x%08x\n", (int)ret); fflush(stdout); @@ -816,18 +845,18 @@ void palette_set_color(unsigned int palette_num, printf("call : palette_set_color() : number = %u, colors = 0x%04x\n", (int)palette_num, (int)colors); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); mapped_colors[0] = colors & 0x07; mapped_colors[1] = (colors >> 4) & 0x07; mapped_colors[2] = (colors >> 8) & 0x07; mapped_colors[3] = (colors >> 12) & 0x07; - palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), palette_num); + palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), palette_num); WWPalette_SetMappedColors(palette, mapped_colors); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : palette_set_color() : return value = none\n"); fflush(stdout); @@ -843,9 +872,9 @@ unsigned int palette_get_color(unsigned int palette_num) printf("call : palette_get_color() : number = %u\n", (int)palette_num); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), + palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()), palette_num); WWPalette_GetMappedColors(palette, mapped_colors); @@ -855,7 +884,7 @@ unsigned int palette_get_color(unsigned int palette_num) ret |= (mapped_colors[2] & 0x07) << 8; ret |= (mapped_colors[3] & 0x07) << 12; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : palette_get_color() : return value = %u\n", (int)ret); fflush(stdout); @@ -871,7 +900,7 @@ void lcd_set_color(unsigned int colors0, unsigned int colors1) printf("call : lcd_set_color() : colors0 = 0x%04x, colors1 = 0x%04x\n", (int)colors0, (int)colors1); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); lcd_colors[0] = colors0 & 0x0f; lcd_colors[1] = (colors0 >> 4) & 0x0f; @@ -882,10 +911,10 @@ void lcd_set_color(unsigned int colors0, unsigned int colors1) lcd_colors[6] = (colors1 >> 8) & 0x0f; lcd_colors[7] = (colors1 >> 12) & 0x0f; - color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(wonx_display)); + color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay())); WWColorMap_SetLCDColors(color_map, lcd_colors); - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); printf("call : lcd_set_color() : return value = none\n"); fflush(stdout); @@ -900,9 +929,9 @@ unsigned long int lcd_get_color(void) printf("call : lcd_get_color() : \n"); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(wonx_display)); + color_map = WWDisplay_GetColorMap(WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay())); WWColorMap_GetLCDColors(color_map, lcd_colors); ret = 0; @@ -915,7 +944,7 @@ unsigned long int lcd_get_color(void) ret |= ((unsigned long int)lcd_colors[2] & 0x0f) << 8; ret |= ((unsigned long int)lcd_colors[3] & 0x0f) << 12; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("call : lcd_get_color() : return value = 0x%08x\n", (int)ret); fflush(stdout); @@ -925,48 +954,52 @@ unsigned long int lcd_get_color(void) void lcd_set_segments(unsigned segments) { - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); /* セグメント表示は未サポートか? */ - WonxDisplay_Flush(wonx_display); + WonxDisplay_Flush(Wonx_GetWonxDisplay()); } -unsigned lcd_get_segments(void) +unsigned int lcd_get_segments(void) { - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); /* セグメント表示は未サポートか? */ - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); + + return (0); } void lcd_set_sleep(unsigned sleep) { - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); /* ? */ - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); } -unsigned lcd_get_sleep(void) +unsigned int lcd_get_sleep(void) { - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); /* ? */ - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); + + return (0); } void screen_set_vram(int screen, int locationID) { - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); } void sprite_set_vram(int locationID) { - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); } /*****************************************************************************/ diff --git a/key.c b/key.c index c0d1dff..de3eab3 100644 --- a/key.c +++ b/key.c @@ -3,9 +3,7 @@ #include -#include "wonx.h" - -#include "WonxDisplay.h" +#include "Wonx.h" int key_press_check(void) { @@ -14,14 +12,14 @@ int key_press_check(void) printf("call : key_press_check() : "); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - x_display = WonxDisplay_GetXDisplay(wonx_display); + x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); XDisplay_Sync(x_display); ret = XDisplay_GetKeyPress(x_display); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -35,14 +33,14 @@ int key_hit_check(void) printf("call : key_hit_check() : "); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - x_display = WonxDisplay_GetXDisplay(wonx_display); + x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); XDisplay_Sync(x_display); ret = XDisplay_GetKeyPress(x_display); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -56,9 +54,9 @@ int key_wait(void) printf("call : key_wait() : "); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - x_display = WonxDisplay_GetXDisplay(wonx_display); + x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); ret = 0; do { @@ -66,7 +64,7 @@ int key_wait(void) ret = XDisplay_GetKeyPress(x_display); } while (ret == 0); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -78,9 +76,9 @@ void key_set_repeat(int rate, int delay) printf("call : key_set_repeat() : rate = %d, delay = %d, ", rate, delay); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("return value = none\n"); fflush(stdout); @@ -93,11 +91,11 @@ int key_get_repeat(void) printf("call : key_get_repeat() : "); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); ret = 0; - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("return value = 0x%04x\n", (int)ret); fflush(stdout); @@ -111,14 +109,14 @@ int key_hit_check_with_repeat(void) printf("call : key_hit_check_with_repeat() : "); fflush(stdout); - if (wonx_display == NULL) Wonx_Create(); + if (!Wonx_IsCreated()) Wonx_Create(); - x_display = WonxDisplay_GetXDisplay(wonx_display); + x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); XDisplay_Sync(x_display); ret = XDisplay_GetKeyPress(x_display); - WonxDisplay_Sync(wonx_display); + WonxDisplay_Sync(Wonx_GetWonxDisplay()); printf("return value = 0x%04x\n", (int)ret); fflush(stdout); diff --git a/sound.c b/sound.c index e4cb5b3..9e1b7da 100644 --- a/sound.c +++ b/sound.c @@ -7,7 +7,7 @@ #include -#include "wonx.h" +#include "Wonx.h" /*****************************************************************************/ /* メンバ関数の定義 */ diff --git a/system.c b/system.c index 661e519..c05489b 100644 --- a/system.c +++ b/system.c @@ -2,9 +2,7 @@ #include -#include "wonx.h" - -#include "WonxDisplay.h" +#include "Wonx.h" void sys_interrupt_set_hook(int type, intvector_t * intvector, intvector_t * last_intvector) @@ -71,13 +69,16 @@ unsigned int sys_get_remote(void) } void * sys_alloc_iram(void *pointer, unsigned size) -{} +{ + return (NULL); +} void sys_free_iram(void * p) {} void * sys_get_my_iram(void) { + return (NULL); } unsigned int sys_get_version(void) diff --git a/text.c b/text.c index 9f8219e..fd88e76 100644 --- a/text.c +++ b/text.c @@ -1,147 +1,360 @@ #include +#include #include -#include "wonx.h" +#include "Wonx.h" +#include "WWText.h" -#include "WonxDisplay.h" +static void _text_window_init(int x, int y, int w, int h, unsigned font_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, font_base, ww_display); + + WWScreen_SetRollX(WWText_GetScreen(ww_text), 0); + WWScreen_SetRollY(WWText_GetScreen(ww_text), 0); + + return; +} void text_screen_init(void) { - if (wonx_display == NULL) Wonx_Create(); + WWDisplay ww_display; + WWLCDPanel ww_lcd_panel; + + printf("call : text_screen_init() : \n"); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + 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); + + return; } -void text_window_init(int x, int y, int w, int h, unsigned font_base) +void text_window_init(int x, int y, int w, int h, unsigned int font_base) { - if (wonx_display == NULL) Wonx_Create(); + WWDisplay ww_display; + + printf("call : text_window_init() : x = %d, y = %d, width = %d, height = %d, base = %u\n", x, y, w, h, (int)font_base); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); + + _text_window_init(x, y, w, h, font_base); + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); + + printf("call : text_screen_init() : return value = none\n"); fflush(stdout); + + return; } void text_set_mode(int mode) { - if (wonx_display == NULL) Wonx_Create(); } int text_get_mode(void) { - if (wonx_display == NULL) Wonx_Create(); return (0); } +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_display == NULL) Wonx_Create(); - printf("%c", (unsigned char)c); + printf("call : text_put_char() : x = %d, y = %d, character = %u\n", x, y, (int)c); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + _text_put_char(x, y, c); + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); + + printf("call : text_put_char() : return value = none\n"); fflush(stdout); + + return; +} + +static int _text_put_string(int x, int y, char * s) +{ + int i, len, ret; + WWText ww_text; + WWDisplay ww_display; + + ww_text = WonxText_GetWWText(Wonx_GetWonxText()); + ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); + + len = strlen(s); + ret = 0; + for (i = 0; i < len; i++) { + if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0) + ret++; + } + + return (ret); } int text_put_string(int x, int y, char * s) { - if (wonx_display == NULL) Wonx_Create(); - printf("%s\n", s); - return (0); + int ret; + + printf("call : text_put_string() : x = %d, y = %d, string = %s\n", x, y, s); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + ret = _text_put_string(x, y, s); + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); + + printf("call : text_put_string() : return value = %d\n", ret); + fflush(stdout); + + return (ret); } int text_put_substring(int x, int y, char * s, int len) { - int i; - if (wonx_display == NULL) Wonx_Create(); - for (i = 0; i < len; i++) - printf("%c", s[i]); - printf("\n"); - return (0); + int i, ret; + WWText ww_text; + WWDisplay ww_display; + + printf("call : text_put_substring() : x = %d, y = %d, string = %s, length = %d\n", x, y, s, len); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + ww_text = WonxText_GetWWText(Wonx_GetWonxText()); + ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); + + ret = 0; + for (i = 0; i < len; 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); + + return (ret); } void text_put_numeric(int x, int y, int len, int format, int number) { - if (wonx_display == NULL) Wonx_Create(); - printf("%d\n", number); + char buf[20]; + char f[20]; + + printf("call : text_put_numeric() : x = %d, y = %d, len = %d, format = %04x, number = %d\n", x, y, len, format, number); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + strcpy(f, "%"); + + if (format & NUM_PADZERO) strcat(f, "0"); + sprintf(f + strlen(f), "%d", len); + 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); + + return; } void text_store_numeric(char * buffer, int len, int format, int number) { - if (wonx_display == NULL) Wonx_Create(); - sprintf(buffer, "%d", number); } void text_fill_char(int x, int y, int len, int code) { - if (wonx_display == NULL) Wonx_Create(); - printf("%c\n", (unsigned char)code); + int i; + + printf("call : text_fill_char() : x = %d, y = %d, length = %d, code = %d\n", x, y, len, code); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + for (i = 0; i < len; i++) { + _text_put_char(x + i, y, code); + } + + WonxDisplay_Flush(Wonx_GetWonxDisplay()); + + printf("call : text_fill_char() : return value = none\n"); + fflush(stdout); + + return; } void text_set_palette(int palette_num) { - if (wonx_display == NULL) Wonx_Create(); + WWText ww_text; + WWDisplay ww_display; + + printf("call : text_set_palette() : palette = %d\n", palette_num); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + 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); + + return; } int text_get_palette(void) { - if (wonx_display == NULL) Wonx_Create(); - return (0); + WWText ww_text; + int num; + + printf("call : text_get_palette() : \n"); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + 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); + + return (num); } void text_set_ank_font(int font_base_num, int is_color, int font_count, void * font) { - if (wonx_display == NULL) Wonx_Create(); } void text_set_sjis_font(void * font_address) { - if (wonx_display == NULL) Wonx_Create(); } void text_get_fontdata(int char_code, void * fontdata_buffer) { - if (wonx_display == NULL) Wonx_Create(); } void text_set_screen(int screen) { - if (wonx_display == NULL) Wonx_Create(); + WWText ww_text; + WWDisplay ww_display; + + printf("call : text_set_screen() : screen = %d\n", screen); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + 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); + + return; } int text_get_screen(void) { - if (wonx_display == NULL) Wonx_Create(); - return (0); + WWText ww_text; + int n; + + printf("call : text_get_screen() : \n"); + fflush(stdout); + + if (!Wonx_IsCreated()) Wonx_Create(); + + 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); + + return (n); } void cursor_display(int cursor_enable) { - if (wonx_display == NULL) Wonx_Create(); } int cursor_status(void) { - if (wonx_display == NULL) Wonx_Create(); return (0); } void cursor_set_location(int x, int y, int w, int h) { - if (wonx_display == NULL) Wonx_Create(); } unsigned long cursor_get_location(void) { - if (wonx_display == NULL) Wonx_Create(); return (0); } void cursor_set_type(int palette_num, int blink_interval) { - if (wonx_display == NULL) Wonx_Create(); } unsigned long cursor_get_type(void) { - if (wonx_display == NULL) Wonx_Create(); return (0); } int text_printf(int x, int y, const char *format, ...) { - if (wonx_display == NULL) Wonx_Create(); return (0); } diff --git a/timer.c b/timer.c index d834731..dc84747 100644 --- a/timer.c +++ b/timer.c @@ -3,9 +3,8 @@ #include -#include "wonx.h" - -#include "WonxDisplay.h" +#include "Wonx.h" +#include "etc.h" typedef struct { unsigned char year; @@ -49,7 +48,7 @@ void rtc_set_datetime(int field, unsigned int value) unsigned int rtc_get_datetime(int field) { - unsigned int ret; + unsigned int ret = 0; time_t timer; struct tm * tblock; @@ -67,6 +66,7 @@ unsigned int rtc_get_datetime(int field) case RTC_HOUR : ret = get_hour( tblock); break; case RTC_MIN : ret = get_minute(tblock); break; case RTC_SEC : ret = get_second(tblock); break; + default : Error("rtc_get_datetime", "Unknown parameter."); } printf("call : rtc_get_datetime() : return value = %d\n", (int)ret); @@ -187,5 +187,5 @@ unsigned int timer_get_count(int type) printf("call : timer_get_count() : return value = %u\n", ret); fflush(stdout); - return; + return (ret); } diff --git a/wonx.c b/wonx.c deleted file mode 100644 index 73ced6d..0000000 --- a/wonx.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "wonx.h" - -/*****************************************************************************/ -/* ディスプレイの確保 */ -/*****************************************************************************/ - -WonxDisplay wonx_display = NULL; - -void Wonx_Create(void) -{ - wonx_display = - WonxDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2, - LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, - SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT); - return; -}