Browse Source

Corresponding to colorization. Added XColorGC class for GC management. (It diverted from XFireworks)

Corresponding to colorization, transparent (transparent color) judgment processing from the WWPalette class
I moved to the WWDisplay class.

Changed the pixel of WWLCDPanel to unsigned short int *.  (Color correspondence)

Change the storage format of text fonts.  (WWTextFonts.c)

In text display, when displaying WWDisplay_GetForegroundColor (),
Fix to copy by looking at WWDisplay_GetBackgroundColor ().  (WWText.c)
(It is no longer necessary to reserve an array of WWCharacter in the WWText class,
Which to delete)

Added palette of border color to WWDisplay class.

We made correspondence to colorization, and added other various corrections.
(Character data storage method, text display, border color processing etc)

With display_control (), display_status (), the bit shift of the border color
Fixed a bug that was 7.  (Fixed to 8)

Key input such as F1 is also accepted during loop waiting for interrupt in while (1) {/ * none * /}
Fixed as.  (WonXSystem.c's timer interrupt callback function
Add WonXDisplay_PrintData () to WonXTimer_Callback ())

Added fcntl_attention.h, filesys.h, indirect.h, oswork.h, process.h.
(Just include the contents or include appropriate files)

In wonx_configure.h,
Fixed a bug that was supposed to be.

Version 2.0 - from wonx-2.0.tar.gz
Hiroaki Sakai 23 years ago
parent
commit
d3f3c6903d
47 changed files with 2875 additions and 409 deletions
  1. 1 1
      COPYRIGHT
  2. 39 0
      HISTORY
  3. 4 3
      Makefile
  4. 396 0
      Obj.c
  5. 76 0
      Obj.h
  6. 28 0
      ObjP.h
  7. 89 61
      WWCharacter.c
  8. 14 7
      WWCharacter.h
  9. 2 3
      WWCharacterP.h
  10. 121 14
      WWDisplay.c
  11. 14 2
      WWDisplay.h
  12. 6 2
      WWDisplayP.h
  13. 25 20
      WWLCDPanel.c
  14. 4 3
      WWLCDPanel.h
  15. 10 8
      WWLCDPanelP.h
  16. 67 4
      WWPalette.c
  17. 26 1
      WWPalette.h
  18. 18 2
      WWPaletteP.h
  19. 28 3
      WWScreen.c
  20. 3 1
      WWScreen.h
  21. 31 7
      WWSprite.c
  22. 2 1
      WWSprite.h
  23. 65 8
      WWText.c
  24. 0 15
      WWText.h
  25. 128 128
      WWTextFonts.c
  26. 11 0
      WWTextP.h
  27. 21 4
      WonXDisplay.c
  28. 1 0
      WonXDisplay.h
  29. 2 0
      WonXSystem.c
  30. 743 0
      XColorGC.c
  31. 98 0
      XColorGC.h
  32. 148 0
      XColorGCP.h
  33. 161 53
      XDisplay.c
  34. 23 1
      XDisplay.h
  35. 4 2
      XDisplayP.h
  36. 51 45
      disp.c
  37. 6 6
      key.c
  38. 317 0
      libwwc.c
  39. 1 1
      sample1.c
  40. 2 2
      text.c
  41. 6 1
      wonx_configure.h
  42. 16 0
      wonx_include/fcntl_attention.h
  43. 8 0
      wonx_include/filesys.h
  44. 9 0
      wonx_include/indirect.h
  45. 31 0
      wonx_include/libwwc.h
  46. 9 0
      wonx_include/oswork.h
  47. 10 0
      wonx_include/process.h

+ 1 - 1
COPYRIGHT

@@ -1,7 +1,7 @@
 /*****************************************************************************/
 /* WonX - WonderWitch on X.                                                  */
 /*                                                                           */
-/* WonX Copyright (c) 2000 Sakai Hiroaki.                                    */
+/* WonX Copyright (c) 2000-2001 Sakai Hiroaki.                               */
 /* All Rights Reserved.                                                      */
 /*===========================================================================*/
 /* This program is free software; you can redistribute it and/or modify      */

+ 39 - 0
HISTORY

@@ -1,3 +1,42 @@
+2001/1/3(水)
+
+カラー化対応.GCの管理用に,XColorGC クラスを追加.(XFireworks から流用した)
+
+カラー化に対応させて,transparent(透過色)の判定処理を WWPalette クラスから
+WWDisplay クラスに移動した.
+
+WWLCDPanel の pixel を,unsigned short int * に変更.(カラー対応)
+
+テキストフォントの格納フォーマットを変更.(WWTextFonts.c)
+
+テキスト表示で,表示時に WWDisplay_GetForegroundColor(),
+WWDisplay_GetBackgroundColor() を見てコピーするように修正.(WWText.c)
+(WWText クラス中で WWCharacter の配列を確保しているのが不要になったので,
+ いずれ削除すること)
+
+WWDisplay クラスにボーダーカラーのパレット追加.
+
+カラー化に対応させて,その他もろもろの修正を加えた.
+(キャラクタデータの格納方法,テキスト表示,ボーダーカラーの処理など)
+
+display_control(), display_status() で,ボーダーカラーのビットシフトが
+7 になっていたバグを修正.(8 に修正)
+
+while(1){/*none*/} での割り込み待ちループ中にも,F1 などのキー入力を受け付ける
+ように修正.(WonXSystem.c のタイマ割り込みのコールバック関数
+WonXTimer_Callback() に,WonXDisplay_PrintData() を追加)
+
+fcntl_attention.h, filesys.h, indirect.h, oswork.h, process.h を追加.
+(中身はカラ,もしくは適当なファイルをインクルードするだけ)
+
+wonx_configure.h で,
+#ifndef _WONX_winx_configure_h_INCLUDED_
+#define _WONX_wonx_configure_h_INCLUDED_
+になっていたバグを修正.
+
+
+
+
 2000/12/28(木)
 
 wonx-1.1 公開

+ 4 - 3
Makefile

@@ -2,13 +2,13 @@ XINCLUDEDIR = /usr/X11R6/include
 INCLUDEDIR = .
 XLIBDIR = /usr/X11R6/lib
 
-VERSION = WonX-1.1
-PKGNAME = wonx-1.1
+VERSION = WonX-2.0
+PKGNAME = wonx-2.0
 
 SMAC = smac-b02
 WWTERM = wwterm-b05
 
-OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWCursor.o WWText.o WWInterrupt.o WWTimer.o WWSerialPort.o WonX.o WonXDisplay.o WonXSystem.o WonXSerialPort.o XDisplay.o UNIXTimer.o UNIXSerialPort.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o service.o etc.o
+OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWCursor.o WWText.o WWInterrupt.o WWTimer.o WWSerialPort.o WonX.o WonXDisplay.o WonXSystem.o WonXSerialPort.o XDisplay.o XColorGC.o UNIXTimer.o UNIXSerialPort.o Obj.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o libwwc.o service.o etc.o
 
 CC = gcc
 
@@ -25,6 +25,7 @@ libwonx.a :	$(OBJS)
 
 clean :
 		rm -f libwonx.a sample1 sample2 *.o
+		rm -fR $(SMAC) $(WWTERM)
 
 sample1 :	libwonx.a sample1.o
 		$(CC) sample1.o -o sample1 \

+ 396 - 0
Obj.c

@@ -0,0 +1,396 @@
+/*****************************************************************************/
+/* Obj.c - A library for object list.                                        */
+/*                                                                           */
+/* Obj.c Copyright (c) 2000 Sakai Hiroaki.                                   */
+/* All Rights Reserved.                                                      */
+/*****************************************************************************/
+
+#include "ObjP.h"
+
+/*****************************************************************************/
+/* ObjListData 型の操作                                                      */
+/*****************************************************************************/
+
+static ObjListData ObjListData_Create(Obj obj, Obj (*destructor)())
+{
+  ObjListData list_data;
+
+  list_data = (ObjListData)malloc(sizeof(_ObjListData));
+
+  list_data->obj = obj;
+  list_data->destructor = destructor;
+
+  return (list_data);
+}
+
+static ObjListData ObjListData_Destroy(ObjListData list_data)
+{
+  if (list_data == NULL) return (NULL);
+
+  /* デストラクタの実行 */
+  if (list_data->destructor)
+    (*(list_data->destructor))(list_data->obj);
+
+  free(list_data);
+
+  return (NULL);
+}
+
+/*****************************************************************************/
+/* ObjList 型オブジェクトの操作                                              */
+/*****************************************************************************/
+
+Obj ObjListData_GetObj(ObjListData data)
+{
+  if (data == NULL) return (NULL);
+  return (data->obj);
+}
+
+Obj ObjListData_GetPrev(ObjListData data)
+{
+  if (data == NULL) return (NULL);
+  return (data->prev);
+}
+
+Obj ObjListData_GetNext(ObjListData data)
+{
+  if (data == NULL) return (NULL);
+  return (data->next);
+}
+
+int ObjList_GetLength(ObjList list)
+{
+  if (list == NULL) return (-1);
+  return (list->length);
+}
+
+ObjListData ObjList_GetStartEdge(ObjList list)
+{
+  if (list == NULL) return (NULL);
+  return (list->start_edge);
+}
+
+ObjListData ObjList_GetEndEdge(ObjList list)
+{
+  if (list == NULL) return (NULL);
+  return (list->end_edge);
+}
+
+ObjListData ObjList_GetStart(ObjList list)
+{
+  if (list == NULL) return (NULL);
+  return (list->start_edge->next);
+}
+
+ObjListData ObjList_GetEnd(ObjList list)
+{
+  if (list == NULL) return (NULL);
+  return (list->end_edge->prev);
+}
+
+int ObjList_IsEmpty(ObjList list)
+{
+  if (list == NULL) return (1);
+  return (list->start_edge->next == list->end_edge);
+}
+
+int ObjList_IsStartEdge(ObjList list, ObjListData data)
+{
+  if (list == NULL) return (0);
+  return (data == list->start_edge);
+}
+
+int ObjList_IsEndEdge(ObjList list, ObjListData data)
+{
+  if (list == NULL) return (0);
+  return (data == list->end_edge);
+}
+
+int ObjList_IsStart(ObjList list, ObjListData data)
+{
+  if (list == NULL) return (0);
+  return (data == list->start_edge->next);
+}
+
+int ObjList_IsEnd(ObjList list, ObjListData data)
+{
+  if (list == NULL) return (0);
+  return (data == list->end_edge->prev);
+}
+
+ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
+				    Obj obj, Obj (*destructor)())
+{
+  ObjListData data;
+
+  if (list == NULL) return (NULL);
+  if (ObjList_IsStartEdge(list, current)) return (NULL);
+
+  data = ObjListData_Create(obj, destructor);
+  if (data == NULL) return (NULL);
+
+  data->prev = current->prev;
+  data->next = current;
+  current->prev->next = data;
+  current->prev = data;
+  (list->length)++;
+
+  return (data);
+}
+
+ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
+				    Obj obj, Obj (*destructor)())
+{
+  ObjListData data;
+
+  if (list == NULL) return (NULL);
+  if (ObjList_IsEndEdge(list, current)) return (NULL);
+
+  data = ObjListData_Create(obj, destructor);
+  if (data == NULL) return (NULL);
+
+  data->next = current->next;
+  data->prev = current;
+  current->next->prev = data;
+  current->next = data;
+  (list->length)++;
+
+  return (data);
+}
+
+ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
+				     Obj (*destructor)())
+{
+  ObjListData current;
+  current = ObjList_GetStart(list);
+  return (ObjList_InsertObjToPrev(list, current, obj, destructor));
+}
+
+ObjListData ObjList_InsertObjToEnd(ObjList list, Obj obj,
+				   Obj (*destructor)())
+{
+  ObjListData current;
+  current = ObjList_GetEnd(list);
+  return (ObjList_InsertObjToNext(list, current, obj, destructor));
+}
+
+ObjListData ObjList_DeleteObjToPrev(ObjList list, ObjListData current)
+{
+  ObjListData ret;
+
+  if (list == NULL) return (NULL);
+  if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
+    return (NULL);
+
+  current->prev->next = current->next;
+  current->next->prev = current->prev;
+
+  ret = current->prev;
+  ObjListData_Destroy(current);
+  (list->length)--;
+
+  return (ret);
+}
+
+ObjListData ObjList_DeleteObjToNext(ObjList list, ObjListData current)
+{
+  ObjListData ret;
+
+  if (list == NULL) return (NULL);
+  if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
+    return (NULL);
+
+  current->prev->next = current->next;
+  current->next->prev = current->prev;
+
+  ret = current->next;
+  ObjListData_Destroy(current);
+  (list->length)--;
+
+  return (ret);
+}
+
+ObjListData ObjList_DeleteObjFromStart(ObjList list)
+{
+  ObjListData current;
+  if (list == NULL) return (NULL);
+  current = ObjList_GetStart(list);
+  return (ObjList_DeleteObjToNext(list, current));
+}
+
+ObjListData ObjList_DeleteObjFromEnd(ObjList list)
+{
+  ObjListData current;
+  if (list == NULL) return (NULL);
+  current = ObjList_GetEnd(list);
+  return (ObjList_DeleteObjToPrev(list, current));
+}
+
+ObjListData ObjList_MoveObjToPrev(ObjList list,
+				  ObjListData current,
+				  ObjListData to)
+{
+  if (list == NULL) return (NULL);
+  return (ObjList_MoveObjToPrevOfOtherList(list, current, list, to));
+}
+
+ObjListData ObjList_MoveObjToNext(ObjList list,
+				  ObjListData current,
+				  ObjListData to)
+{
+  if (list == NULL) return (NULL);
+  return (ObjList_MoveObjToNextOfOtherList(list, current, list, to));
+}
+
+ObjListData ObjList_MoveObjToStart(ObjList list, ObjListData current)
+{
+  if (list == NULL) return (NULL);
+  return (ObjList_MoveObjToStartOfOtherList(list, current, list));
+}
+
+ObjListData ObjList_MoveObjToEnd(ObjList list, ObjListData current)
+{
+  if (list == NULL) return (NULL);
+  return (ObjList_MoveObjToEndOfOtherList(list, current, list));
+}
+
+ObjList ObjList_Create() /* ObjList 型オブジェクトを作成する */
+{
+  ObjList list;
+
+  list = (ObjList)malloc(sizeof(_ObjList));
+  if (list == NULL) return (NULL);
+
+  list->start_edge   = ObjListData_Create(NULL, NULL);
+  list->end_edge     = ObjListData_Create(NULL, NULL);
+  list->length  = 0;    /* 現在存在しているデータの数 */
+
+  list->start_edge->prev = NULL;
+  list->start_edge->next = list->end_edge;
+  list->end_edge->prev   = list->start_edge;
+  list->end_edge->next   = NULL;
+
+  return (list);
+}
+
+ObjList ObjList_Destroy(ObjList list) /*  */
+{
+  if (list == NULL) return (NULL);
+
+  while (!ObjList_IsEmpty(list))
+    ObjList_DeleteObjFromStart(list);
+
+  if (list->start_edge)
+    list->start_edge = ObjListData_Destroy(list->start_edge);
+  if (list->end_edge)
+    list->end_edge = ObjListData_Destroy(list->end_edge);
+
+  free(list);
+
+  return (NULL);
+}
+
+/*===========================================================================*/
+/* 複数のリスト間での操作                                                    */
+/*===========================================================================*/
+
+ObjListData ObjList_MoveObjToPrevOfOtherList(ObjList list, ObjListData current,
+					     ObjList to_list, ObjListData to)
+{
+  if (list == NULL) return (NULL);
+  if (to_list == NULL) return (NULL);
+  if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
+    return (NULL);
+
+  if (ObjList_IsStartEdge(to_list, to)) return (NULL);
+  if ((list == to_list) && (current == to)) return (current);
+
+  current->prev->next = current->next;
+  current->next->prev = current->prev;
+
+  current->prev = to->prev;
+  current->next = to;
+  to->prev->next = current;
+  to->prev = current;
+
+  (list->length)--;
+  (to_list->length)++;
+
+  return (current);
+}
+
+ObjListData ObjList_MoveObjToNextOfOtherList(ObjList list, ObjListData current,
+					     ObjList to_list, ObjListData to)
+{
+  if (list == NULL) return (NULL);
+  if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
+    return (NULL);
+
+  if (ObjList_IsEndEdge(to_list, to)) return (NULL);
+  if ((list == to_list) && (current == to)) return (current);
+
+  current->prev->next = current->next;
+  current->next->prev = current->prev;
+
+  current->next = to->next;
+  current->prev = to;
+  to->next->prev = current;
+  to->next = current;
+
+  (list->length)--;
+  (to_list->length)++;
+
+  return (current);
+}
+
+ObjListData ObjList_MoveObjToStartOfOtherList(ObjList list,
+					      ObjListData current,
+					      ObjList to_list)
+{
+  ObjListData to;
+  if (list == NULL) return (NULL);
+  if (to_list == NULL) return (NULL);
+  to = ObjList_GetStart(to_list);
+  return (ObjList_MoveObjToPrevOfOtherList(list, current, to_list, to));
+}
+
+ObjListData ObjList_MoveObjToEndOfOtherList(ObjList list,
+					    ObjListData current,
+					    ObjList to_list)
+{
+  ObjListData to;
+  if (list == NULL) return (NULL);
+  if (to_list == NULL) return (NULL);
+  to = ObjList_GetEnd(to_list);
+  return (ObjList_MoveObjToNextOfOtherList(list, current, to_list, to));
+}
+
+ObjList ObjList_Concatenate(ObjList list1, ObjList list2)
+{
+  ObjListData tmp;
+
+  if (list1 == NULL) {
+    list1 = list2;
+    return (list1);
+  }
+  if (list2 == NULL) return (list1);
+
+  list1->end_edge->prev->next = list2->start_edge->next;
+  list2->start_edge->next->prev = list1->end_edge->prev;
+
+  tmp = list1->end_edge;
+  list1->end_edge = list2->end_edge;
+  list2->end_edge = tmp;
+
+  list2->start_edge->next = list2->end_edge;
+  list2->end_edge->prev = list2->start_edge;
+
+  list1->length += list2->length;
+  list2->length = 0;
+
+  ObjList_Destroy(list2);
+
+  return (list1);
+}
+
+/* End of File. */

+ 76 - 0
Obj.h

@@ -0,0 +1,76 @@
+/*****************************************************************************/
+/* Obj.h - A library for object list.                                        */
+/*                                                                           */
+/* Obj.h Copyright (c) 2000 Sakai Hiroaki.                                   */
+/* All Rights Reserved.                                                      */
+/*****************************************************************************/
+
+#ifndef _SAKAILIB_OBJ_H_INCLUDED_
+#define _SAKAILIB_OBJ_H_INCLUDED_
+
+typedef void * Obj;
+typedef struct _ObjListData * ObjListData;
+typedef struct _ObjList * ObjList;
+typedef Obj (*ObjDestructor)(Obj);
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/*****************************************************************************/
+/* ObjList 型オブジェクトの操作                                              */
+/*****************************************************************************/
+
+Obj ObjListData_GetObj(ObjListData data);
+Obj ObjListData_GetPrev(ObjListData data);
+Obj ObjListData_GetNext(ObjListData data);
+int ObjList_GetLength(ObjList list);
+ObjListData ObjList_GetStartEdge(ObjList list);
+ObjListData ObjList_GetEndEdge(ObjList list);
+ObjListData ObjList_GetStart(ObjList list);
+ObjListData ObjList_GetEnd(ObjList list);
+int ObjList_IsEmpty(ObjList list);
+int ObjList_IsStartEdge(ObjList list, ObjListData data);
+int ObjList_IsEndEdge(ObjList list, ObjListData data);
+int ObjList_IsStart(ObjList list, ObjListData data);
+int ObjList_IsEnd(ObjList list, ObjListData data);
+ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
+				    Obj obj, Obj (*destructor)());
+ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
+				    Obj obj, Obj (*destructor)());
+ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
+				     Obj (*destructor)());
+ObjListData ObjList_InsertObjToEnd(ObjList list, Obj obj,
+				   Obj (*destructor)());
+ObjListData ObjList_DeleteObjToPrev(ObjList list, ObjListData current);
+ObjListData ObjList_DeleteObjToNext(ObjList list, ObjListData current);
+ObjListData ObjList_DeleteObjFromStart(ObjList list);
+ObjListData ObjList_DeleteObjFromEnd(ObjList list);
+ObjListData ObjList_MoveObjToPrev(ObjList list,
+				  ObjListData current,
+				  ObjListData to);
+ObjListData ObjList_MoveObjToNext(ObjList list,
+				  ObjListData current,
+				  ObjListData to);
+ObjListData ObjList_MoveObjToStart(ObjList list, ObjListData current);
+ObjListData ObjList_MoveObjToEnd(ObjList list, ObjListData current);
+ObjList ObjList_Create(); /* ObjList 型オブジェクトを作成する */
+ObjList ObjList_Destroy(ObjList list); /*  */
+
+/*===========================================================================*/
+/* 複数のリスト間での操作                                                    */
+/*===========================================================================*/
+
+ObjListData ObjList_MoveObjToPrevOfOtherList(ObjList list, ObjListData current,
+					     ObjList to_list, ObjListData to);
+ObjListData ObjList_MoveObjToNextOfOtherList(ObjList list, ObjListData current,
+					     ObjList to_list, ObjListData to);
+ObjListData ObjList_MoveObjToStartOfOtherList(ObjList list,
+					      ObjListData current,
+					      ObjList to_list);
+ObjListData ObjList_MoveObjToEndOfOtherList(ObjList list,
+					    ObjListData current,
+					    ObjList to_list);
+ObjList ObjList_Concatenate(ObjList list1, ObjList list2);
+
+#endif
+

+ 28 - 0
ObjP.h

@@ -0,0 +1,28 @@
+/*****************************************************************************/
+/* ObjP.h - A library for object list.                                       */
+/*                                                                           */
+/* ObjP.h Copyright (c) 2000 Sakai Hiroaki.                                  */
+/* All Rights Reserved.                                                      */
+/*****************************************************************************/
+
+#ifndef _SAKAILIB_OBJP_H_INCLUDED_
+#define _SAKAILIB_OBJP_H_INCLUDED_
+
+#include "Obj.h"
+
+/* データ格納用構造体 */
+typedef struct _ObjListData {
+  struct _ObjListData * prev; /* 前のデータ */
+  struct _ObjListData * next; /* 次のデータ */
+  Obj obj; /* オブジェクト */
+  Obj (*destructor)(Obj); /* 削除時に呼ばれるデストラクタ */
+} _ObjListData;
+
+/* リスト構造の管理用 */
+typedef struct _ObjList {
+  struct _ObjListData * start_edge;
+  struct _ObjListData * end_edge;
+  int length;
+} _ObjList;
+
+#endif

+ 89 - 61
WWCharacter.c

@@ -2,6 +2,8 @@
 /* ここから                                                                  */
 /*****************************************************************************/
 
+#include <string.h>
+
 #include "WWCharacterP.h"
 #include "WonX.h"
 
@@ -11,20 +13,42 @@
 
 int WWCharacter_GetNumber(WWCharacter c)
 {
-  if (c == NULL) WonX_Error("WWCharacter_GetNumber()", "WWCharacter is NULL.");
+  if (c == NULL) WonX_Error("WWCharacter_GetNumber", "WWCharacter is NULL.");
 
   return (c->number);
 }
 
 int WWCharacter_SetNumber(WWCharacter c, int n)
 {
-  if ((n < 0) || (n >= 512))
-    WonX_Error("WWCharacter_SetNumber()", "Invalid range.");
+  if (c == NULL) WonX_Error("WWCharacter_SetNumber", "WWCharacter is NULL.");
+
+  if ((n < 0) || (n > 512 - 1))
+    WonX_Error("WWCharacter_SetNumber", "Invalid range.");
 
   return (c->number = n);
 }
 
-WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
+unsigned char WWCharacter_GetBitmap(WWCharacter c, int n)
+{
+  if (c == NULL) WonX_Error("WWCharacter_GetBitmap", "WWCharacter is NULL.");
+
+  if ((n < 0) || (n > 32 - 1))
+    WonX_Error("WWCharacter_GetBitmap", "Invalid range.");
+
+  return (c->bitmap[n]);
+}
+
+unsigned char WWCharacter_SetBitmap(WWCharacter c, int n, unsigned char bitmap)
+{
+  if (c == NULL) WonX_Error("WWCharacter_SetBitmap", "WWCharacter is NULL.");
+
+  if ((n < 0) || (n > 32 - 1))
+    WonX_Error("WWCharacter_SetBitmap", "Invalid range.");
+
+  return (c->bitmap[n] = bitmap);
+}
+
+WWCharacter WWCharacter_Create(int number)
 {
   WWCharacter character;
 
@@ -33,7 +57,7 @@ WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
     WonX_Error("WWCharacter_Create", "Cannot allocate memory.");
 
   WWCharacter_SetNumber(character, number);
-  WWCharacter_SetBitmap(character, bitmap);
+  WWCharacter_ClearAllPixels(character);
 
   return (character);
 }
@@ -41,82 +65,77 @@ WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
 WWCharacter WWCharacter_Destroy(WWCharacter character)
 {
   if (character == NULL)
-    WonX_Error("WWCharacter_Destroy()", "WWCharacter is NULL.");
+    WonX_Error("WWCharacter_Destroy", "WWCharacter is NULL.");
   free(character);
   return (NULL);
 }
 
-unsigned char * WWCharacter_GetBitmap(WWCharacter character)
+int WWCharacter_GetPixel(WWCharacter character, int x, int y,
+			 WWDisplay display)
 {
-  return (character->bitmap);
-}
-
-int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap)
-{
-  int i;
+  unsigned short int pixel;
 
   if (character == NULL)
-    WonX_Error("WWCharacter_SetBitmap()", "WWCharacter is NULL.");
+    WonX_Error("WWCharacter_GetPixel", "WWCharacter is NULL.");
 
-  for (i = 0; i < 16; i++) {
-    if (bitmap == NULL) {
-      character->bitmap[i] = 0x00;
-    } else {
-      character->bitmap[i] = bitmap[i];
-    }
+  if ((x < 0) || (x > 7))
+    WonX_Error("WWCharacter_GetPixel", "x is out of range.");
+  if ((y < 0) || (y > 7))
+    WonX_Error("WWCharacter_GetPixel", "y is out of range.");
+
+  /* パレット色を返す */
+  pixel = 0;
+  switch (WWDisplay_GetColorMode(display)) {
+  case COLOR_MODE_GRAYSCALE:
+  case COLOR_MODE_4COLOR:
+    pixel  = ((character->bitmap[y * 2 + 0] >> (7-x)) & 1) << 0;
+    pixel |= ((character->bitmap[y * 2 + 1] >> (7-x)) & 1) << 1;
+    break;
+  case COLOR_MODE_16COLOR:
+    pixel  = ((character->bitmap[y * 4 + 0] >> (7-x)) & 1) << 0;
+    pixel |= ((character->bitmap[y * 4 + 1] >> (7-x)) & 1) << 1;
+    pixel |= ((character->bitmap[y * 4 + 2] >> (7-x)) & 1) << 2;
+    pixel |= ((character->bitmap[y * 4 + 3] >> (7-x)) & 1) << 3;
+    break;
+  case COLOR_MODE_16PACKED:
+    pixel = character->bitmap[y * 4 + (7-x) / 2] >> (((7-x) % 2) * 4);
+    pixel &= 0x0f;
+    break;
+  default:
+    WonX_Error("WWCharacter_GetPixel", "Unknown color mode.");
   }
 
-  return (0);
+  return (pixel);
 }
 
-int WWCharacter_GetPixel(WWCharacter character, int x, int y)
+int WWCharacter_ClearAllPixels(WWCharacter character)
 {
   if (character == NULL)
-    WonX_Error("WWCharacter_GetPixel()", "WWCharacter is NULL.");
-
-  if ((x < 0) || (x > 7))
-    WonX_Error("WWCharacter_GetPixel()", "x is invalid value.");
-  if ((y < 0) || (y > 7))
-    WonX_Error("WWCharacter_GetPixel()", "y is invalid value.");
+    WonX_Error("WWCharacter_ClearAllPixels", "WWCharacter is NULL.");
 
-  /* ビットマップは2ビットでぴとつのピクセルに対応する.      */
-  /* 2ビットの値が,palette の色に対応する.                  */
-  /* bitmap は unsigned char bitmap[16]; に定義してある. */
+  memset(character->bitmap, 0, 32);
 
-  /* パレット色(0~3)を返す */
-  return ( (character->bitmap[y * 2 + x / 4] >> ((x % 4) * 2)) & 0x03 );
+  return (0);
 }
 
-int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel)
+int WWCharacter_CopyAllPixels(WWCharacter dst, WWCharacter src)
 {
-  unsigned char p;
-  if (character == NULL)
-    WonX_Error("WWCharacter_SetPixel()", "WWCharacter is NULL.");
+  if (dst == NULL)
+    WonX_Error("WWCharacter_CopyAllPixel", "dst is NULL.");
+  if (src == NULL)
+    WonX_Error("WWCharacter_CopyAllPixel", "src is NULL.");
 
-  if ((x < 0) || (x > 7))
-    WonX_Error("WWCharacter_SetPixel()", "x is invalid value.");
-  if ((y < 0) || (y > 7))
-    WonX_Error("WWCharacter_SetPixel()", "y is invalid value.");
-  if ((pixel < 0) || (pixel > 3))
-    WonX_Error("WWCharacter_SetPixel()", "Invalid pixel.");
+  memcpy(dst->bitmap, src->bitmap, 32);
 
-  p = ((unsigned char)pixel) & 0x03;
-  p = p << ((x % 4) * 2);
-
-  character->bitmap[y * 2 + x / 4] &= ~(0x03 << ((x % 4) * 2));
-  character->bitmap[y * 2 + x / 4] |= p;
-
-  return (pixel);
+  return (0);
 }
 
-int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src)
+int WWCharacter_PrintData(WWCharacter character, WWDisplay display, FILE * f)
 {
-  return (WWCharacter_SetBitmap(dst, src->bitmap));
-}
+  int i, x, y, n;
 
-int WWCharacter_PrintData(WWCharacter character, FILE * f)
-{
-  int x, y, i, n;
+  if (character == NULL)
+    WonX_Error("WWCharacter_PrintData", "WWCharacter is NULL.");
 
   n = WWCharacter_GetNumber(character);
 
@@ -125,15 +144,24 @@ int WWCharacter_PrintData(WWCharacter character, FILE * f)
   fprintf(f, "character[%d] :\tnumber = %d\n",
 	  n, WWCharacter_GetNumber(character));
 
-  for (i = 0; i < 16; i++) {
-    fprintf(f, "character[%d] :\tbitmap[%d] = 0x%02x\n",
-	    n, i, (int)(WWCharacter_GetBitmap(character)[i]));
+  for (i = 0; i < 32; i += 8) {
+    fprintf(f, "character[%d] :\tbitmap[%d] =", n, i);
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i  ));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+1));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+2));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+3));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+4));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+5));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+6));
+    fprintf(f, " %02x", (int)WWCharacter_GetBitmap(character, i+7));
+    fprintf(f, "\n");
   }
 
+  fprintf(f, "character[%d] :\tpixels :   01234567\n", n);
   for (y = 0; y < 8; y++) {
-    fprintf(f, "character[%d] :\tbitmap : ", n);
+    fprintf(f, "character[%d] :\tpixels : %d ", n, y);
     for (x = 0; x < 8; x++) {
-      fprintf(f, "%d", WWCharacter_GetPixel(character, x, y));
+      fprintf(f, "%d", WWCharacter_GetPixel(character, x, y, display));
     }
     fprintf(f, "\n");
   }

+ 14 - 7
WWCharacter.h

@@ -18,20 +18,27 @@ typedef struct _WWCharacter * WWCharacter;
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "WWDisplay.h"
+#include "wonx_include/libwwc.h"
+
 /*****************************************************************************/
 /* メンバ関数の宣言                                                          */
 /*****************************************************************************/
 
 int WWCharacter_GetNumber(WWCharacter c);
 int WWCharacter_SetNumber(WWCharacter c, int n);
-WWCharacter WWCharacter_Create(int number, unsigned char * bitmap);
+unsigned char WWCharacter_GetBitmap(WWCharacter c, int n);
+unsigned char WWCharacter_SetBitmap(WWCharacter c, int n, unsigned char bitmap);
+
+WWCharacter WWCharacter_Create(int number);
 WWCharacter WWCharacter_Destroy(WWCharacter character);
-unsigned char * WWCharacter_GetBitmap(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);
+
+int WWCharacter_GetPixel(WWCharacter character, int x, int y,
+			 WWDisplay display);
+
+int WWCharacter_ClearAllPixels(WWCharacter character);
+int WWCharacter_CopyAllPixels(WWCharacter dst, WWCharacter src);
+int WWCharacter_PrintData(WWCharacter character, WWDisplay display, FILE * f);
 
 /*****************************************************************************/
 /* ここまで                                                                  */

+ 2 - 3
WWCharacterP.h

@@ -14,9 +14,8 @@
 typedef struct _WWCharacter {
   int number;
 
-  /* ビットマップは2ビットでぴとつのピクセルに対応する. */
-  /* 2ビットの値が,palette の色に対応する.             */
-  unsigned char bitmap[16];
+  /* キャラクタのビットマップ */
+  unsigned char bitmap[32];
 } _WWCharacter;
 
 /*****************************************************************************/

+ 121 - 14
WWDisplay.c

@@ -4,6 +4,7 @@
 
 #include "wonx_include/disp.h"
 #include "wonx_include/text.h"
+#include "wonx_include/libwwc.h"
 
 #include "WWDisplayP.h"
 #include "WonX.h"
@@ -26,6 +27,8 @@ WWLCDPanel WWDisplay_GetLCDPanel(WWDisplay d) { return (d->lcd_panel); }
 WWText WWDisplay_GetText(WWDisplay d) { return (d->text); }
 WWCursor WWDisplay_GetCursor(WWDisplay d) { return (d->cursor); }
 
+unsigned int WWDisplay_GetColorMode(WWDisplay d) { return (d->color_mode); }
+
 int WWDisplay_GetSpriteEnable(WWDisplay d) { return (d->sprite_enable); }
 int WWDisplay_GetSpriteWindowEnable(WWDisplay d)
 { return (d->sprite_window_enable); }
@@ -39,7 +42,10 @@ int WWDisplay_GetSpriteWindowWidth(WWDisplay d)
 int WWDisplay_GetSpriteWindowHeight(WWDisplay d)
 { return (d->sprite_window_height); }
 
-int WWDisplay_GetBorder(WWDisplay d) { return (d->border); }
+WWPalette WWDisplay_GetBorderPalette(WWDisplay d)
+{ return (d->border_palette); }
+int WWDisplay_GetBorderColor(WWDisplay d)
+{ return (d->border_color); }
 
 int WWDisplay_GetForegroundColor(WWDisplay d) { return (d->foreground_color); }
 int WWDisplay_GetBackgroundColor(WWDisplay d) { return (d->background_color); }
@@ -68,6 +74,9 @@ WWText WWDisplay_SetText(WWDisplay d, WWText p)
 WWCursor WWDisplay_SetCursor(WWDisplay d, WWCursor p)
 { return (d->cursor = p); }
 
+unsigned int WWDisplay_SetColorMode(WWDisplay d, unsigned int mode)
+{ return (d->color_mode = mode); }
+
 int WWDisplay_SetSpriteEnable(WWDisplay d, int f)
 { return (d->sprite_enable = f); }
 int WWDisplay_SetSpriteWindowEnable(WWDisplay d, int f)
@@ -82,7 +91,10 @@ int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n)
 int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n)
 { return (d->sprite_window_height = n); }
 
-int WWDisplay_SetBorder(WWDisplay d, int b) { return (d->border = b); }
+WWPalette WWDisplay_SetBorderPalette(WWDisplay d, WWPalette p)
+{ return (d->border_palette = p); }
+int WWDisplay_SetBorderColor(WWDisplay d, int b)
+{ return (d->border_color = b); }
 
 int WWDisplay_SetForegroundColor(WWDisplay d, int c)
 { return (d->foreground_color = c); }
@@ -122,14 +134,23 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
   WWDisplay_SetColorMap(display, WWColorMap_Create(default_lcd_colors));
 
   for (i = 0; i < 16; i++) {
+    /*
+     * WonX-2.0 以降では,透明色は WWPalette クラスでは管理しないように
+     * 変更したので,透明色の設定は必要無くなった.
+     */
+#if 1
+    WWDisplay_SetPalette(display, i,
+			 WWPalette_Create(i,default_palette_colors[i].colors));
+#else /* WonX-2.0 以前では,透明色の設定が必要だった.一応コードを残しておく */
     WWDisplay_SetPalette(display, i,
 			 WWPalette_Create(i,
 					  default_palette_colors[i].colors,
 					  ((i / 4) % 2) ? 1 : 0));
+#endif
   }
 
   for (i = 0; i < 512; i++) {
-    WWDisplay_SetCharacter(display, i, WWCharacter_Create(i, NULL));
+    WWDisplay_SetCharacter(display, i, WWCharacter_Create(i));
   }
 
   for (i = 0; i < 128; i++) {
@@ -151,8 +172,6 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
   WWDisplay_SetLCDPanel(display, WWLCDPanel_Create(lcd_panel_width,
 						   lcd_panel_height));
 
-
-
   /* デフォルトのテキスト表示用パレットは0 */
   WWDisplay_SetText(display,
 		    WWText_Create(WWDisplay_GetScreen(display, SCREEN2),
@@ -168,6 +187,9 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
   WWDisplay_SetCursor(display,
 		      WWCursor_Create(WWDisplay_GetPalette(display, 1)));
 
+  /* デフォルトのカラーモードは白黒モード */
+  WWDisplay_SetColorMode(display, COLOR_MODE_GRAYSCALE);
+
   WWDisplay_SetSpriteEnable(display, 0);
   WWDisplay_SetSpriteWindowEnable(display, 0);
 
@@ -176,7 +198,8 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
   WWDisplay_SetSpriteWindowWidth( display, lcd_panel_width);
   WWDisplay_SetSpriteWindowHeight(display, lcd_panel_height);
 
-  WWDisplay_SetBorder(display, 0);
+  WWDisplay_SetBorderPalette(display, WWDisplay_GetPalette(display, 0));
+  WWDisplay_SetBorderColor(display, 0);
 
   WWDisplay_SetForegroundColor(display, 3);
   WWDisplay_SetBackgroundColor(display, 0);
@@ -316,12 +339,24 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
       px = x + WWScreen_GetRollX(screen);
 
       /* 透明色の場合には,-1が返ってくる */
-      pixel = WWScreen_GetPixel(screen, px, py, cursor);
+      pixel = WWScreen_GetPixel(screen, px, py, display, cursor);
 
       /* 透明色の場合 */
       if (pixel == -1) continue;
 
-      pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
+      /* カラー対応 */
+      switch (WWDisplay_GetColorMode(display)) {
+      case COLOR_MODE_GRAYSCALE:
+	pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
+	break;
+      case COLOR_MODE_4COLOR:
+      case COLOR_MODE_16COLOR:
+      case COLOR_MODE_16PACKED:
+	break;
+      default:
+	WonX_Error("WWDisplay_DrawSprite", "Unknown color mode.");
+      }
+
       WWLCDPanel_SetPixel(lcd_panel, x, y, pixel);
     }
   }
@@ -349,7 +384,9 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
 
   for (y = 0; y < 8; y++) {
     for (x = 0; x < 8; x++) {
-      pixel = WWSprite_GetPixel(sprite, x, y); /* 透明色は-1が返ってくる */
+
+      /* 透明色は-1が返ってくる */
+      pixel = WWSprite_GetPixel(sprite, x, y, display);
 
       /* 透明色の場合 */
       if (pixel == -1) continue;
@@ -370,7 +407,19 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
 	}
       }
 
-      pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
+      /* カラー対応 */
+      switch (WWDisplay_GetColorMode(display)) {
+      case COLOR_MODE_GRAYSCALE:
+	pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
+	break;
+      case COLOR_MODE_4COLOR:
+      case COLOR_MODE_16COLOR:
+      case COLOR_MODE_16PACKED:
+	break;
+      default:
+	WonX_Error("WWDisplay_DrawSprite", "Unknown color mode.");
+      }
+
       WWLCDPanel_SetPixel(WWDisplay_GetLCDPanel(display), lcd_x, lcd_y, pixel);
     }
   }
@@ -385,7 +434,8 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
   int lcd_panel_width;
   int lcd_panel_height;
   WWColorMap color_map;
-  int border;
+  WWPalette border_palette;
+  int border_color;
   WWScreen screen;
   WWSprite sprite;
   WWCursor cursor;
@@ -394,13 +444,38 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
   lcd_panel_width  = WWLCDPanel_GetWidth( lcd_panel);
   lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel);
   color_map = WWDisplay_GetColorMap(display);
-  border = WWDisplay_GetBorder(display);
+  border_palette = WWDisplay_GetBorderPalette(display);
+  border_color = WWDisplay_GetBorderColor(display);
+
+  /* カラー対応 */
+  switch (WWDisplay_GetColorMode(display)) {
+  case COLOR_MODE_GRAYSCALE:
+    border_color &= (DCM_BORDER_COLOR >> 8);
+    border_color = WWColorMap_GetLCDColor(color_map, border_color);
+    break;
+  case COLOR_MODE_4COLOR:
+    border_color &= 0x03;
+    border_color =
+      ((unsigned short int)WWPalette_GetRed(  border_palette,border_color)<<8)|
+      ((unsigned short int)WWPalette_GetGreen(border_palette,border_color)<<4)|
+      ((unsigned short int)WWPalette_GetBlue( border_palette,border_color)<<0);
+    break;
+  case COLOR_MODE_16COLOR:
+  case COLOR_MODE_16PACKED:
+    border_color &= 0x0f;
+    border_color =
+      ((unsigned short int)WWPalette_GetRed(  border_palette,border_color)<<8)|
+      ((unsigned short int)WWPalette_GetGreen(border_palette,border_color)<<4)|
+      ((unsigned short int)WWPalette_GetBlue( border_palette,border_color)<<0);
+    break;
+  default:
+    WonX_Error("WWDisplay_DrawLCDPanel", "Unknown color mode.");
+  }
 
   /* ボーダーカラーで埋める */
   for (x = 0; x < lcd_panel_width; x++) {
     for (y = 0; y < lcd_panel_height; y++) {
-      WWLCDPanel_SetPixel(lcd_panel, x, y,
-			  WWColorMap_GetLCDColor(color_map, border));
+      WWLCDPanel_SetPixel(lcd_panel, x, y, border_color);
     }
   }
 
@@ -447,6 +522,38 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
   return (0);
 }
 
+/*===========================================================================*/
+/* 透明色かどうか調べる                                                      */
+/*===========================================================================*/
+
+int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color)
+{
+  int mode;
+  int palette_num;
+  int ret;
+
+  if (color != 0) return (0);
+
+  mode = WWDisplay_GetColorMode(display);
+  palette_num = WWPalette_GetNumber(palette);
+
+  ret = 0;
+  switch (mode) {
+  case COLOR_MODE_GRAYSCALE :
+  case COLOR_MODE_4COLOR :
+    ret = ((palette_num / 4) % 2) ? 1 : 0;
+    break;
+  case COLOR_MODE_16COLOR :
+  case COLOR_MODE_16PACKED :
+    ret = 1;
+    break;
+  default :
+    WonX_Error("WWDisplay_IsTransparent", "Unknown color mode.");
+  }
+
+  return (ret);
+}
+
 /*****************************************************************************/
 /* ここまで                                                                  */
 /*****************************************************************************/

+ 14 - 2
WWDisplay.h

@@ -41,6 +41,8 @@ WWLCDPanel WWDisplay_GetLCDPanel(WWDisplay d);
 WWText WWDisplay_GetText(WWDisplay d);
 WWCursor WWDisplay_GetCursor(WWDisplay d);
 
+unsigned int WWDisplay_GetColorMode(WWDisplay d);
+
 int WWDisplay_GetSpriteEnable(WWDisplay d);
 int WWDisplay_GetSpriteWindowEnable(WWDisplay d);
 
@@ -49,7 +51,8 @@ int WWDisplay_GetSpriteWindowY(WWDisplay d);
 int WWDisplay_GetSpriteWindowWidth(WWDisplay d);
 int WWDisplay_GetSpriteWindowHeight(WWDisplay d);
 
-int WWDisplay_GetBorder(WWDisplay d);
+WWPalette WWDisplay_GetBorderPalette(WWDisplay d);
+int WWDisplay_GetBorderColor(WWDisplay d);
 
 int WWDisplay_GetForegroundColor(WWDisplay d);
 int WWDisplay_GetBackgroundColor(WWDisplay d);
@@ -70,6 +73,8 @@ WWLCDPanel WWDisplay_SetLCDPanel(WWDisplay d, WWLCDPanel p);
 WWText WWDisplay_SetText(WWDisplay d, WWText p);
 WWCursor WWDisplay_SetCursor(WWDisplay d, WWCursor p);
 
+unsigned int WWDisplay_SetColorMode(WWDisplay d, unsigned int mode);
+
 int WWDisplay_SetSpriteEnable(WWDisplay d, int f);
 int WWDisplay_SetSpriteWindowEnable(WWDisplay d, int f);
 
@@ -78,7 +83,8 @@ int WWDisplay_SetSpriteWindowY(WWDisplay d, int n);
 int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n);
 int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n);
 
-int WWDisplay_SetBorder(WWDisplay d, int b);
+WWPalette WWDisplay_SetBorderPalette(WWDisplay d, WWPalette p);
+int WWDisplay_SetBorderColor(WWDisplay d, int b);
 
 int WWDisplay_SetForegroundColor(WWDisplay d, int c);
 int WWDisplay_SetBackgroundColor(WWDisplay d, int c);
@@ -100,6 +106,12 @@ WWDisplay WWDisplay_Destroy(WWDisplay display);
 
 int WWDisplay_DrawLCDPanel(WWDisplay display);
 
+/*===========================================================================*/
+/* 透明色かどうか調べる                                                      */
+/*===========================================================================*/
+
+int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color);
+
 /*****************************************************************************/
 /* ここまで                                                                  */
 /*****************************************************************************/

+ 6 - 2
WWDisplayP.h

@@ -23,6 +23,8 @@ typedef struct _WWDisplay {
   WWCursor cursor;
 
   /* ディスプレイの属性情報 */
+  unsigned int color_mode; /* カラーモード */
+
   int sprite_enable; /* スプライト表示イネーブルフラグ */
   int sprite_window_enable; /* スプライトウインドウ機能イネーブルフラグ */
   int sprite_window_x;      /* スプライトウインドウ用 */
@@ -30,14 +32,16 @@ typedef struct _WWDisplay {
   int sprite_window_width;  /* スプライトウインドウ用 */
   int sprite_window_height; /* スプライトウインドウ用 */
 
-  int border; /* ボーダーカラー.0~7のカラーマップ番号 */
+  /* ボーダーカラーのパレット.カラーで必要 */
+  WWPalette border_palette;
+  /* ボーダーカラー.白黒の場合には,0~7のカラーマップ番号 */
+  int border_color;
 
   int foreground_color; /* モノクロフォント展開時の色 */
   int background_color; /* モノクロフォント展開時の色 */
 
   int sprite_start; /* スプライトの描画の指定 */
   int sprite_count; /* スプライトの描画の指定 */
-
 } _WWDisplay;
 
 /*****************************************************************************/

+ 25 - 20
WWLCDPanel.c

@@ -28,56 +28,59 @@ int WWLCDPanel_ResetAllDraw(WWLCDPanel p) { return (p->all_draw = 0); }
 int WWLCDPanel_SetAllDraw(WWLCDPanel p)   { return (p->all_draw = 1); }
 int WWLCDPanel_IsAllDraw(WWLCDPanel p)   { return (p->all_draw); }
 
-unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p)
+unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p)
 {
   return (p->pixel[p->current]);
 }
 
-/* LCDは1ピクセル16色(4ビット必要) */
-static int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel, int current,
-					int x, int y)
+/* LCDは1ピクセル4096色(12ビット必要) */
+static unsigned short int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel,
+						       int current,
+						       int x, int y)
 {
-  unsigned char pixel;
+  unsigned short int pixel;
 
   if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
        (y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
     return (-1);
 
   pixel = lcd_panel->pixel[current][y * WWLCDPanel_GetWidth(lcd_panel) + x];
-  pixel &= 0x0f;
   return ((int)pixel);
 }
 
-static int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel, int x, int y)
+static unsigned short int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel,
+						 int x, int y)
 {
-  return (WWLCDPanel_GetPixelByCurrent(lcd_panel, 1 - lcd_panel->current, x, y));
+  return (WWLCDPanel_GetPixelByCurrent(lcd_panel,
+				       1 - lcd_panel->current, x, y));
 }
 
-int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
+unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
 {
   return (WWLCDPanel_GetPixelByCurrent(lcd_panel, lcd_panel->current, x, y));
 }
 
-int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel)
+unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
+				       unsigned short int pixel)
 {
-  unsigned char p;
+  unsigned short int p;
   int n;
 
   if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
        (y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
     return (-1);
 
-  p = ((unsigned char)pixel) & 0x0f;
+  p = pixel & 0x0fff;
   n = y * WWLCDPanel_GetWidth(lcd_panel) + x;
   lcd_panel->pixel[lcd_panel->current][n] = p;
 
-  return (pixel);
+  return (p);
 }
 
 int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y)
 {
-  int old_pixel;
-  int current_pixel;
+  unsigned short int old_pixel;
+  unsigned short int current_pixel;
 
   if (WWLCDPanel_IsAllDraw(lcd_panel)) return (1);
   old_pixel = WWLCDPanel_GetOldPixel(lcd_panel, x, y);
@@ -90,6 +93,7 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
 {
   WWLCDPanel lcd_panel;
   int x, y, i;
+  unsigned short int * p;
 
   lcd_panel = (WWLCDPanel)malloc(sizeof(_WWLCDPanel));
   if (lcd_panel == NULL)
@@ -99,15 +103,16 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
   WWLCDPanel_SetHeight(lcd_panel, height);
 
   for (i = 0; i < 2; i++) {
-    lcd_panel->pixel[i] =
-      (unsigned char *)malloc(sizeof(unsigned char) *
-			      WWLCDPanel_GetWidth(lcd_panel) *
-			      WWLCDPanel_GetHeight(lcd_panel));
+    p = (unsigned short int *)malloc(sizeof(unsigned short int) *
+				     WWLCDPanel_GetWidth(lcd_panel) *
+				     WWLCDPanel_GetHeight(lcd_panel));
+    if (p == NULL) WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
+    lcd_panel->pixel[i] = p;
   }
 
   for (y = 0; y < lcd_panel->height; y++) {
     for (x = 0; x < lcd_panel->width / 2; x++) {
-      WWLCDPanel_SetPixel(lcd_panel, x, y, 0x00);
+      WWLCDPanel_SetPixel(lcd_panel, x, y, 0);
     }
   }
 

+ 4 - 3
WWLCDPanel.h

@@ -32,9 +32,10 @@ int WWLCDPanel_ResetAllDraw(WWLCDPanel p);
 int WWLCDPanel_SetAllDraw(WWLCDPanel p);
 int WWLCDPanel_IsAllDraw(WWLCDPanel p);
 
-unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p);
-int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y);
-int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel);
+unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p);
+unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y);
+unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
+				       unsigned short int pixel);
 int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y);
 WWLCDPanel WWLCDPanel_Create(int width, int height);
 WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel);

+ 10 - 8
WWLCDPanelP.h

@@ -15,18 +15,20 @@ typedef struct _WWLCDPanel {
   int width;
   int height;
 
-  /* Xサーバの負荷を減らすため,ビットマップを2枚持ち, */
-  /* 前回と同じ部分は書き換えないようにする.            */
-  /* pixel[current] が現在描画中のビットマップになる.   */
-  /* pixel[1 - current] が前回のビットマップになる.     */
+  /* Xサーバの負荷を減らすため,ビットマップを2枚持ち,    */
+  /* 前回と同じ部分は書き換えないようにする.               */
+  /* pixel[current] が現在描画中のビットマップになる.      */
+  /* pixel[1 - current] が前回のビットマップになる.        */
   int current;
 
-  /* all_draw == 1 のときは,前回分が無いので,          */
-  /* 全部描画することを示す.                            */
+  /* all_draw == 1 のときは,前回分が無いので,             */
+  /* 全部描画することを示す.                               */
   int all_draw;
 
-  /* 16色のカラー情報.1バイトで1ピクセル分の情報を持つ */
-  unsigned char * pixel[2];
+  /* 4096色のカラー情報.1バイトで1ピクセル分の情報を持つ */
+  /* Xサーバの負荷を減らすため,ビットマップを2枚持ち,    */
+  /* 前回と同じ部分は書き換えないようにする.               */
+  unsigned short int * pixel[2];
 } _WWLCDPanel;
 
 /*****************************************************************************/

+ 67 - 4
WWPalette.c

@@ -13,20 +13,57 @@
 int WWPalette_GetNumber(WWPalette p) { return (p->number); }
 int WWPalette_SetNumber(WWPalette p, int n) { return (p->number = n); }
 
+/*
+ * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+ * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+ */
+#if 0
 int WWPalette_GetTransparent(WWPalette p) { return (p->transparent); }
 int WWPalette_SetTransparent(WWPalette p, int f)
 { return (p->transparent = f); }
-
-WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
+#endif
+
+int WWPalette_GetRed(  WWPalette p, int n) { return (p->red[  n]); }
+int WWPalette_GetGreen(WWPalette p, int n) { return (p->green[n]); }
+int WWPalette_GetBlue( WWPalette p, int n) { return (p->blue[ n]); }
+int WWPalette_SetRed(  WWPalette p, int n, int value)
+{ return (p->red[  n] = value); }
+int WWPalette_SetGreen(WWPalette p, int n, int value)
+{ return (p->green[n] = value); }
+int WWPalette_SetBlue( WWPalette p, int n, int value)
+{ return (p->blue[ n] = value); }
+
+/*
+ * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+ * WWPalette で透明色を管理する必要は無くなった.
+ * もともとは,
+ * WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
+ * のように,引数 transparent があった.
+ */
+WWPalette WWPalette_Create(int number, int * mapped_colors)
 {
   WWPalette palette;
+  int i;
 
   palette = (WWPalette)malloc(sizeof(_WWPalette));
   if (palette == NULL)
     WonX_Error("WWPalette_Create", "Cannot allocate memory");
 
   WWPalette_SetNumber(palette, number);
+
+  /*
+   * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+   * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+   */
+#if 0
   WWPalette_SetTransparent(palette, transparent);
+#endif
+
+  for (i = 0; i < 16; i++) {
+    WWPalette_SetRed(  palette, i, 0);
+    WWPalette_SetGreen(palette, i, 0);
+    WWPalette_SetBlue( palette, i, 0);
+  }
   WWPalette_SetMappedColors(palette, mapped_colors);
 
   return (palette);
@@ -70,29 +107,55 @@ int WWPalette_GetMappedColor(WWPalette palette, int color)
   int pixel;
 
   pixel = palette->mapped_color[color];
+
+  /*
+   * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+   * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+   */
+#if 0
   if (WWPalette_GetTransparent(palette) && (pixel == 0)) {
     pixel = -1;
   }
+#endif
+
   return (pixel);
 }
 
 int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color)
 {
+  /*
+   * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+   * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+   */
+#if 0
   if (mapped_color == -1) mapped_color = 0;
+#endif
   return (palette->mapped_color[color] = mapped_color);
 }
 
-int WWPalette_PrintData(WWPalette p, FILE * f)
+int WWPalette_PrintData(WWPalette p, WWDisplay display, FILE * f)
 {
   int i, n;
+  int transparent;
 
   n = WWPalette_GetNumber(p);
 
   fprintf(f, "\n");
 
   fprintf(f, "palette[%d] :\tnumber = %d\n", n, WWPalette_GetNumber(p));
+
+  /*
+   * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+   * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+   */
+#if 1
+  transparent = WWDisplay_IsTransparent(display, p, 0);
+  fprintf(f, "palette[%d] :\ttransparent = %s\n",
+	  n, wonx_true_false(transparent));
+#else
   fprintf(f, "palette[%d] :\ttransparent = %s\n",
-	  n, wonx_true_false(WWPalette_GetTransparent(p)));
+          n, wonx_true_false(WWPalette_GetTransparent(p)));
+#endif
 
   for (i = 0; i < 4; i++) {
     fprintf(f, "palette[%d] :\tcolor[%d] = %d\n",

+ 26 - 1
WWPalette.h

@@ -18,21 +18,46 @@ typedef struct _WWPalette * WWPalette;
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "WWDisplay.h"
+
 /*****************************************************************************/
 /* メンバ関数の宣言                                                          */
 /*****************************************************************************/
 
 int WWPalette_GetNumber(WWPalette p);
 int WWPalette_SetNumber(WWPalette p, int n);
+
+/*
+ * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+ * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+ */
+#if 0
 int WWPalette_GetTransparent(WWPalette palette);
 int WWPalette_SetTransparent(WWPalette palette, int f);
+#endif
+
+int WWPalette_GetRed(  WWPalette p, int n);
+int WWPalette_GetGreen(WWPalette p, int n);
+int WWPalette_GetBlue( WWPalette p, int n);
+int WWPalette_SetRed(  WWPalette p, int n, int value);
+int WWPalette_SetGreen(WWPalette p, int n, int value);
+int WWPalette_SetBlue( WWPalette p, int n, int value);
+
+/*
+ * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+ * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+ */
+#if 1
+WWPalette WWPalette_Create(int number, int * mapped_colors);
+#else
 WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent);
+#endif
 WWPalette WWPalette_Destroy(WWPalette palette);
 int * WWPalette_GetMappedColors(WWPalette palette, int * mapped_colors);
 int WWPalette_SetMappedColors(WWPalette palette, int * mapped_colors);
 int WWPalette_GetMappedColor(WWPalette palette, int color);
 int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color);
-int WWPalette_PrintData(WWPalette p, FILE * f);
+int WWPalette_PrintData(WWPalette p, WWDisplay display, FILE * f);
 
 /*****************************************************************************/
 /* ここまで                                                                  */

+ 18 - 2
WWPaletteP.h

@@ -12,12 +12,28 @@
 /*****************************************************************************/
 
 typedef struct _WWPalette {
+
   int number;
 
+  /*
+   * WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
+   * WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
+   */
+#if 0
   int transparent; /* 0 は透明色になるかどうかのフラグ */
+#endif
 
-  /* カラーマップの8色中から4色を選択 */
-  int mapped_color[4]; /* カラーマップの番号(0~7)を持つ */
+  /* 白黒モードの場合には,カラーマップの8色中から4色を選択 */
+  int mapped_color[4]; /* 白黒モードでは,カラーマップの番号(0~7)を持つ */
+
+  /*
+   * 4色カラー,16色カラーモードの場合には,rgb の色を使用する.
+   * 4色カラーモードの場合には,0~3までを使用する.
+   * 16色カラーモードの場合には,0~15までを全部使用する.
+   */
+  int red[16];
+  int green[16];
+  int blue[16];
 
 } _WWPalette;
 

+ 28 - 3
WWScreen.c

@@ -159,7 +159,8 @@ int WWScreen_SetDrawWidth( WWScreen s, int n) { return (s->draw_width  = n); }
 int WWScreen_SetDrawHeight(WWScreen s, int n) { return (s->draw_height = n); }
 
 /* カラーマップの色(0~7)を返す(透明色は-1を返す) */
-int WWScreen_GetPixel(WWScreen screen, int x, int y, WWCursor cursor)
+int WWScreen_GetPixel(WWScreen screen, int x, int y,
+		      WWDisplay display, WWCursor cursor)
 {
   int cx, cy, px, py;
   int pixel;
@@ -193,8 +194,32 @@ int WWScreen_GetPixel(WWScreen screen, int x, int y, WWCursor cursor)
     }
   }
 
-  pixel = WWCharacter_GetPixel(character, px, py);
-  pixel = WWPalette_GetMappedColor(palette, pixel); /*透明色は-1が返ってくる*/
+  pixel = WWCharacter_GetPixel(character, px, py, display);
+
+  /* カラー対応 */
+  switch (WWDisplay_GetColorMode(display)) {
+  case COLOR_MODE_GRAYSCALE:
+    /*
+     * WonX-2.0 以降では,透明色の処理は WWDisplay クラスで行うように
+     * 変更したので,WWPalette_GetMappedColor() が -1 を返すことは無い.
+     */
+    pixel = WWPalette_GetMappedColor(palette, pixel);
+    break;
+  case COLOR_MODE_4COLOR:
+  case COLOR_MODE_16COLOR:
+  case COLOR_MODE_16PACKED:
+    pixel =
+      ((unsigned short int)WWPalette_GetRed(  palette, pixel) << 8) |
+      ((unsigned short int)WWPalette_GetGreen(palette, pixel) << 4) |
+      ((unsigned short int)WWPalette_GetBlue( palette, pixel) << 0);
+    break;
+  default:
+    WonX_Error("WWScreen_GetPixel", "Unknown color mode.");
+  }
+
+  /* 透明色の場合には -1 を返す */
+  if (WWDisplay_IsTransparent(display, palette, pixel))
+    pixel = -1;
 
   return (pixel);
 }

+ 3 - 1
WWScreen.h

@@ -20,6 +20,7 @@ typedef struct _WWScreen * WWScreen;
 #include "WWPalette.h"
 #include "WWCharacter.h"
 #include "WWCursor.h"
+#include "WWDisplay.h"
 
 /*****************************************************************************/
 /* Äê¿ô¤ÎÄêµÁ                                                                */
@@ -71,7 +72,8 @@ int WWScreen_SetDrawY(     WWScreen s, int n);
 int WWScreen_SetDrawWidth( WWScreen s, int n);
 int WWScreen_SetDrawHeight(WWScreen s, int n);
 
-int WWScreen_GetPixel(WWScreen screen, int x, int y, WWCursor cursor);
+int WWScreen_GetPixel(WWScreen screen, int x, int y,
+		      WWDisplay display, WWCursor cursor);
 
 WWScreen WWScreen_Create(int number,
 			 int width, int height,

+ 31 - 7
WWSprite.c

@@ -39,20 +39,44 @@ int WWSprite_SetPosition(WWSprite sprite, int x, int y)
 }
 
 /* スプライトのピクセル値を返す.(透明色は-1を返す) */
-int WWSprite_GetPixel(WWSprite sprite, int x, int y)
+int WWSprite_GetPixel(WWSprite sprite, int x, int y, WWDisplay display)
 {
-  WWPalette p;
-  WWCharacter c;
+  WWPalette palette;
+  WWCharacter character;
   int pixel;
 
-  p = WWSprite_GetPalette(sprite);
-  c = WWSprite_GetCharacter(sprite);
+  palette = WWSprite_GetPalette(sprite);
+  character = WWSprite_GetCharacter(sprite);
 
   if (WWSprite_GetHorizontal(sprite)) x = 7 - x;
   if (WWSprite_GetVertical(  sprite)) y = 7 - y;
 
-  pixel = WWCharacter_GetPixel(c, x, y);
-  pixel = WWPalette_GetMappedColor(p, pixel); /* 透明色は -1 を返す */
+  pixel = WWCharacter_GetPixel(character, x, y, display);
+
+  /* カラー対応 */
+  switch (WWDisplay_GetColorMode(display)) {
+  case COLOR_MODE_GRAYSCALE:
+    /*
+     * WonX-2.0 以降では,透明色の処理は WWDisplay クラスで行うように
+     * 変更したので,WWPalette_GetMappedColor() が -1 を返すことは無い.
+     */
+    pixel = WWPalette_GetMappedColor(palette, pixel);
+    break;
+  case COLOR_MODE_4COLOR:
+  case COLOR_MODE_16COLOR:
+  case COLOR_MODE_16PACKED:
+    pixel =
+      ((unsigned short int)WWPalette_GetRed(  palette, pixel) << 8) |
+      ((unsigned short int)WWPalette_GetGreen(palette, pixel) << 4) |
+      ((unsigned short int)WWPalette_GetBlue( palette, pixel) << 0);
+    break;
+  default:
+    WonX_Error("WWSprite_GetPixel", "Unknown color mode.");
+  }
+
+  /* 透明色の場合には -1 を返す */
+  if (WWDisplay_IsTransparent(display, palette, pixel))
+    pixel = -1;
 
   return (pixel);
 }

+ 2 - 1
WWSprite.h

@@ -19,6 +19,7 @@ typedef struct _WWSprite * WWSprite;
 
 #include "WWPalette.h"
 #include "WWCharacter.h"
+#include "WWDisplay.h"
 
 /*****************************************************************************/
 /* ¥á¥ó¥Ð´Ø¿ô¤ÎÀë¸À                                                          */
@@ -43,7 +44,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);
+int WWSprite_GetPixel(WWSprite sprite, int x, int y, WWDisplay display);
 
 WWSprite WWSprite_Create(int number, int x, int y,
 			 int horizontal, int vertical,

+ 65 - 8
WWText.c

@@ -57,7 +57,7 @@ int WWText_SetTextWindow(WWText ww_text, int x, int y,
     for (tx = 0; tx < WWText_GetWidth(ww_text); tx++) {
       if (c >= 512) WonX_Error("WWText_SetTextWindow", "Over character.");
       ww_character = WWDisplay_GetCharacter(ww_display, c);
-      WWCharacter_SetBitmap(ww_character, NULL);
+      WWCharacter_ClearAllPixels(ww_character);
       WWScreen_SetCharacter(WWText_GetScreen(ww_text),
 			    WWText_GetX(ww_text) + tx,
 			    WWText_GetY(ww_text) + ty,
@@ -72,10 +72,13 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
 			WWDisplay ww_display)
 {
   WWCharacter ww_character;
+  int j, k, n;
+  unsigned char pixel;
+  int f, b;
+  unsigned char bitmap[2];
 
   if ((character < 0) || (character > 127)) {
     WonX_Warning("WWText_PutCharacter", "Character number is out of range.");
-    fflush(stdout);
     return (-1);
   }
 
@@ -87,7 +90,6 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
   if ( (x < 0) || (x > WWText_GetWidth( ww_text) - 1) ||
        (y < 0) || (y > WWText_GetHeight(ww_text) - 1) ) {
     WonX_Warning("WWText_PutCharacter", "Position is out of range.");
-    fflush(stdout);
     return (-1);
   }
 
@@ -102,7 +104,36 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
 				       WWText_GetY(ww_text) + y);
 #endif
 
-  WWCharacter_CopyBitmap(ww_character, WWText_GetFont(ww_text, character));
+  /*
+   * テキストフォントは
+   * f = WWDisplay_GetForegroundColor(ww_display);
+   * b = WWDisplay_GetBackgroundColor(ww_display);
+   * で描画する必要があるため,描画のたびにビットマップをコピーする必要がある.
+   * で,カラー化の際に,そのように修正した.
+   * よって,テキストの初期化時に WWCharacter の配列を作成する必要は
+   * 無くなったので,WWCharacter の配列はいずれ削除すること.
+   */
+
+#if 0
+  WWCharacter_CopyAllPixels(ww_character, WWText_GetFont(ww_text, character));
+#else
+  f = WWDisplay_GetForegroundColor(ww_display);
+  b = WWDisplay_GetBackgroundColor(ww_display);
+
+  n = character * 8;
+  for (j = 0; j < 8; j++) {
+    bitmap[0] = 0;
+    bitmap[1] = 0;
+    for (k = 0; k < 8; k++) {
+      pixel = (fonts[n] & (1 << k)) ? f : b;
+      bitmap[0] |= ( pixel       & 1) << k;
+      bitmap[1] |= ((pixel >> 1) & 1) << k;
+    }
+    WWCharacter_SetBitmap(ww_character, j*2  , bitmap[0]);
+    WWCharacter_SetBitmap(ww_character, j*2+1, bitmap[1]);
+    n++;
+  }
+#endif
 
   /* 表示時にパレットを設定するのでいいのか? 不明 */
   WWScreen_SetPalette(WWText_GetScreen(ww_text),
@@ -122,20 +153,46 @@ WWText WWText_Create(WWScreen screen,
 		     WWPalette palette)
 {
   WWText ww_text;
-  int i;
+  WWCharacter ww_character;
+  int i, j, k, n;
+  unsigned char pixel;
+  int f, b;
+  unsigned char bitmap[2];
 
   ww_text = (WWText)malloc(sizeof(_WWText));
   if (ww_text == NULL) WonX_Error("WWText_Create", "Cannot allocate memory.");
 
   WWText_SetScreen(ww_text, screen);
-  WWText_SetX(ww_text, 0);
-  WWText_SetY(ww_text, 0);
+  WWText_SetX(ww_text, x);
+  WWText_SetY(ww_text, y);
   WWText_SetWidth( ww_text, width );
   WWText_SetHeight(ww_text, height);
   WWText_SetPalette(ww_text, palette);
 
+  /* 以下は,
+     f = WWDisplay_GetForegroundColor(ww_display);
+     b = WWDisplay_GetBackgroundColor(ww_display);
+     で取得すべきかもしれない
+     */
+  f = 3;
+  b = 0;
+
+  n = 0;
   for (i = 0; i < 128; i++) {
-    WWText_SetFont(ww_text, i, WWCharacter_Create(i, &(fonts[i * 16])));
+    ww_character = WWCharacter_Create(i);
+    for (j = 0; j < 8; j++) {
+      bitmap[0] = 0;
+      bitmap[1] = 0;
+      for (k = 0; k < 8; k++) {
+	pixel = (fonts[n] & (1 << k)) ? f : b;
+	bitmap[0] |= ( pixel       & 1) << k;
+	bitmap[1] |= ((pixel >> 1) & 1) << k;
+      }
+      WWCharacter_SetBitmap(ww_character, j*2  , bitmap[0]);
+      WWCharacter_SetBitmap(ww_character, j*2+1, bitmap[1]);
+      n++;
+    }
+    WWText_SetFont(ww_text, i, ww_character);
   }
 
   return (ww_text);

+ 0 - 15
WWText.h

@@ -57,21 +57,6 @@ WWText WWText_Create(WWScreen screen, int x, int y, int width, int height,
 		     WWPalette palette);
 WWText WWText_Destroy(WWText text);
 
-/*****************************************************************************/
-/* ¤³¤³¤Þ¤Ç                                                                  */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* End of File.                                                              */
-/*****************************************************************************/
-
-
-
-
-
-
-
-
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */
 /*****************************************************************************/

+ 128 - 128
WWTextFonts.c

@@ -1,130 +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 △ */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 空白文字 */
+  0x00, 0x00, 0x14, 0x00, 0x22, 0x1c, 0x00, 0x00, /* 1 笑顔 */
+  0x00, 0x3e, 0x6b, 0x7f, 0x5d, 0x63, 0x3e, 0x00, /* 2 笑顔 */
+  0x22, 0x77, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00, /* 3 ハート */
+  0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00, /* 4 ダイヤ */
+  0x08, 0x1c, 0x1c, 0x77, 0x77, 0x08, 0x1c, 0x00, /* 5 クローバー */
+  0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x08, 0x1c, 0x00, /* 6 スペード */
+  0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, /* 7 点 */
+  0x00, 0x00, 0x3c, 0x24, 0x24, 0x3c, 0x00, 0x00, /* 8 小さい□ */
+  0x00, 0x00, 0x18, 0x24, 0x24, 0x18, 0x00, 0x00, /* 9 小さい○ */
+  0x00, 0x7e, 0x42, 0x5a, 0x5a, 0x42, 0x7e, 0x00, /* 10 2重四角 */
+  0x0f, 0x03, 0x05, 0x39, 0x48, 0x48, 0x30, 0x00, /* 11 ♂ */
+  0x1c, 0x22, 0x22, 0x1c, 0x08, 0x3e, 0x08, 0x00, /* 12 ♀ */
+  0x18, 0x1c, 0x16, 0x12, 0x12, 0x70, 0x60, 0x00, /* 13 ♪ */
+  0x18, 0x1e, 0x16, 0x12, 0x62, 0x6e, 0x0c, 0x00, /* 14 音符 */
+  0x08, 0x2a, 0x1c, 0x77, 0x1c, 0x2a, 0x08, 0x00, /* 15 爆発? */
+  0x10, 0x18, 0x1c, 0x1e, 0x1c, 0x18, 0x10, 0x00, /* 16 右向き▲ */
+  0x04, 0x0c, 0x1c, 0x3c, 0x1c, 0x0c, 0x04, 0x00, /* 17 左向き▲ */
+  0x08, 0x1c, 0x3e, 0x08, 0x3e, 0x1c, 0x08, 0x00, /* 18 上下矢印 */
+  0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x36, 0x00, /* 19 !! */
+  0x00, 0x00, 0x02, 0x06, 0x2c, 0x38, 0x10, 0x00, /* 20 チェック */
+  0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, /* 21 小さい● */
+  0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, /* 22 ・・ */
+  0x08, 0x1c, 0x3e, 0x08, 0x3e, 0x1c, 0x3e, 0x00, /* 23 矢印? */
+  0x08, 0x1c, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x00, /* 24 ↑ */
+  0x08, 0x08, 0x08, 0x08, 0x3e, 0x1c, 0x08, 0x00, /* 25 ↓ */
+  0x00, 0x04, 0x06, 0x7f, 0x06, 0x04, 0x00, 0x00, /* 26 → */
+  0x00, 0x10, 0x30, 0x7f, 0x30, 0x10, 0x00, 0x00, /* 27 ← */
+  0x3c, 0x42, 0x9d, 0xa1, 0xa1, 0x9d, 0x42, 0x3c, /* 28 (C) */
+  0x00, 0x14, 0x36, 0x7f, 0x36, 0x14, 0x00, 0x00, /* 29 ←→ */
+  0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x00, 0x00, 0x00, /* 30 上向き▲ */
+  0x00, 0x00, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00, /* 31 下向き▲ */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 32 空白 */
+  0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, /* 33 ! */
+  0x36, 0x36, 0x12, 0x24, 0x00, 0x00, 0x00, 0x00, /* 34 " */
+  0x14, 0x14, 0x7f, 0x14, 0x7f, 0x14, 0x14, 0x00, /* 35 # */
+  0x08, 0x3e, 0x68, 0x3e, 0x0b, 0x3e, 0x08, 0x00, /* 36 $ */
+  0x21, 0x52, 0x24, 0x08, 0x12, 0x25, 0x42, 0x00, /* 37 % */
+  0x18, 0x24, 0x24, 0x39, 0x4e, 0x44, 0x3b, 0x00, /* 38 & */
+  0x0c, 0x0c, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, /* 39 ' */
+  0x04, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, /* 40 ( */
+  0x10, 0x08, 0x04, 0x04, 0x04, 0x08, 0x10, 0x00, /* 41 ) */
+  0x00, 0x08, 0x2a, 0x1c, 0x2a, 0x08, 0x00, 0x00, /* 42 * */
+  0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00, /* 43 + */
+  0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x20, 0x40, /* 44 , */
+  0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, /* 45 - */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, /* 46 . */
+  0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, /* 47 / */
+  0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, /* 48 0 */
+  0x0c, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, /* 49 1 */
+  0x3c, 0x66, 0x06, 0x0c, 0x18, 0x30, 0x7e, 0x00, /* 50 2 */
+  0x3c, 0x66, 0x06, 0x3c, 0x06, 0x66, 0x3c, 0x00, /* 51 3 */
+  0x0e, 0x1e, 0x36, 0x66, 0x66, 0x7f, 0x06, 0x00, /* 52 4 */
+  0x7e, 0x60, 0x60, 0x7c, 0x06, 0x66, 0x3c, 0x00, /* 53 5 */
+  0x3c, 0x66, 0x60, 0x7c, 0x66, 0x66, 0x3c, 0x00, /* 54 6 */
+  0x7e, 0x66, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x00, /* 55 7 */
+  0x3c, 0x66, 0x66, 0x3c, 0x66, 0x66, 0x3c, 0x00, /* 56 8 */
+  0x3c, 0x66, 0x66, 0x3e, 0x06, 0x66, 0x3c, 0x00, /* 57 9 */
+  0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, /* 58 : */
+  0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, /* 59 ; */
+  0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, /* 60 < */
+  0x00, 0x00, 0x7f, 0x00, 0x7f, 0x00, 0x00, 0x00, /* 61 = */
+  0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, /* 62 > */
+  0x3c, 0x66, 0x66, 0x0c, 0x18, 0x00, 0x18, 0x00, /* 63 ? */
+  0x3e, 0x45, 0x5d, 0x55, 0x5f, 0x40, 0x3e, 0x00, /* 64 @ */
+  0x1c, 0x36, 0x63, 0x63, 0x7f, 0x63, 0x63, 0x00, /* 65 A */
+  0x7e, 0x63, 0x63, 0x7e, 0x63, 0x63, 0x7e, 0x00, /* 66 B */
+  0x3e, 0x63, 0x60, 0x60, 0x60, 0x63, 0x3e, 0x00, /* 67 C */
+  0x7c, 0x66, 0x63, 0x63, 0x63, 0x66, 0x7c, 0x00, /* 68 D */
+  0x7e, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x7e, 0x00, /* 69 E */
+  0x7e, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x00, /* 70 F */
+  0x3e, 0x63, 0x60, 0x67, 0x63, 0x63, 0x3e, 0x00, /* 71 G */
+  0x63, 0x63, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x00, /* 72 H */
+  0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, /* 73 I */
+  0x0f, 0x03, 0x03, 0x63, 0x63, 0x63, 0x3e, 0x00, /* 74 J */
+  0x63, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0x63, 0x00, /* 75 K */
+  0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7f, 0x00, /* 76 L */
+  0x63, 0x77, 0x7f, 0x6b, 0x63, 0x63, 0x63, 0x00, /* 77 M */
+  0x63, 0x73, 0x7b, 0x6f, 0x67, 0x63, 0x63, 0x00, /* 78 N */
+  0x3e, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x00, /* 79 O */
+  0x7e, 0x63, 0x63, 0x7e, 0x60, 0x60, 0x60, 0x00, /* 80 P */
+  0x3e, 0x63, 0x63, 0x6b, 0x6f, 0x67, 0x3e, 0x00, /* 81 Q */
+  0x7e, 0x63, 0x63, 0x7e, 0x6c, 0x66, 0x63, 0x00, /* 82 R */
+  0x3e, 0x63, 0x60, 0x3e, 0x03, 0x63, 0x3e, 0x00, /* 83 S */
+  0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, /* 84 T */
+  0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x00, /* 85 U */
+  0x63, 0x63, 0x63, 0x36, 0x36, 0x1c, 0x08, 0x00, /* 86 V */
+  0x63, 0x6b, 0x6b, 0x6b, 0x7f, 0x36, 0x22, 0x00, /* 87 W */
+  0x63, 0x63, 0x36, 0x1c, 0x36, 0x63, 0x63, 0x00, /* 88 X */
+  0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x00, /* 89 Y */
+  0x7f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x7f, 0x00, /* 90 Z */
+  0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x00, /* 91 [ */
+  0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, /* 92 \ */
+  0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00, /* 93 ] */
+  0x08, 0x1c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, /* 94 ^ */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 95 _ */
+  0x18, 0x18, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, /* 96 ` */
+  0x00, 0x00, 0x3e, 0x66, 0x66, 0x66, 0x3f, 0x00, /* 97 a */
+  0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x7c, 0x00, /* 98 b */
+  0x00, 0x00, 0x3c, 0x66, 0x60, 0x66, 0x3c, 0x00, /* 99 c */
+  0x06, 0x06, 0x3e, 0x66, 0x66, 0x66, 0x3e, 0x00, /* 100 d */
+  0x00, 0x00, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00, /* 101 e */
+  0x1c, 0x32, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x00, /* 102 f */
+  0x00, 0x00, 0x3e, 0x66, 0x66, 0x1e, 0x66, 0x3c, /* 103 g */
+  0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00, /* 104 h */
+  0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, /* 105 i */
+  0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3c, /* 106 j */
+  0x60, 0x60, 0x66, 0x6c, 0x70, 0x6c, 0x66, 0x00, /* 107 k */
+  0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, /* 108 l */
+  0x00, 0x00, 0x76, 0x6b, 0x6b, 0x6b, 0x6b, 0x00, /* 109 m */
+  0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00, /* 110 n */
+  0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00, /* 111 o */
+  0x00, 0x00, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60, /* 112 p */
+  0x00, 0x00, 0x3e, 0x66, 0x66, 0x1e, 0x06, 0x06, /* 113 q */
+  0x00, 0x00, 0x6e, 0x70, 0x60, 0x60, 0x60, 0x00, /* 114 r */
+  0x00, 0x00, 0x3e, 0x70, 0x3c, 0x0e, 0x7c, 0x00, /* 115 s */
+  0x18, 0x18, 0x3e, 0x18, 0x18, 0x18, 0x0e, 0x00, /* 116 t */
+  0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3f, 0x00, /* 117 u */
+  0x00, 0x00, 0x66, 0x66, 0x24, 0x3c, 0x18, 0x00, /* 118 v */
+  0x00, 0x00, 0x63, 0x6b, 0x2a, 0x3e, 0x14, 0x00, /* 119 w */
+  0x00, 0x00, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0x00, /* 120 x */
+  0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x30, 0x60, /* 121 y */
+  0x00, 0x00, 0x7e, 0x0c, 0x18, 0x30, 0x7e, 0x00, /* 122 z */
+  0x0c, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0c, 0x00, /* 123 { */
+  0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, /* 124 | */
+  0x18, 0x0c, 0x0c, 0x06, 0x0c, 0x0c, 0x18, 0x00, /* 125 } */
+  0x32, 0x3c, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 126 ~ */
+  0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x3e, 0x00  /* 127 △ */
 };

+ 11 - 0
WWTextP.h

@@ -21,6 +21,17 @@ typedef struct _WWText {
   int base; /* 使用するキャラクタのベース */
 
   WWPalette palette;
+
+  /*
+   * テキストフォントは
+   * f = WWDisplay_GetForegroundColor(ww_display);
+   * b = WWDisplay_GetBackgroundColor(ww_display);
+   * で描画する必要があるため,描画のたびにビットマップをコピーする必要がある.
+   * で,カラー化の際に,そのように修正した.
+   * よって,テキストの初期化時に WWCharacter の配列を作成する必要は
+   * 無くなったので,WWCharacter の配列はいずれ削除すること.
+   * (WWText_PutCharacter() 参照)
+   */
   WWCharacter font[128]; /* フォント */
 
 } _WWText;

+ 21 - 4
WonXDisplay.c

@@ -45,7 +45,7 @@ WonXDisplay WonXDisplay_Create(int x_width, int x_height,
   return (wonx_display);
 }
 
-int WonXDisplay_Sync(WonXDisplay wonx_display)
+int WonXDisplay_PrintData(WonXDisplay wonx_display)
 {
   int i;
   XDisplay x_display;
@@ -56,19 +56,24 @@ int WonXDisplay_Sync(WonXDisplay wonx_display)
 
   if (XDisplay_GetColorMapPrint(x_display)) {
     WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
+    fflush(stdout);
     XDisplay_SetColorMapPrint(x_display, 0);
   }
 
   if (XDisplay_GetPalettePrint(x_display)) {
     for (i = 0; i < 16; i++) {
-      WWPalette_PrintData(WWDisplay_GetPalette(ww_display, i), stdout);
+      WWPalette_PrintData(WWDisplay_GetPalette(ww_display, i),
+			  ww_display, stdout);
+      fflush(stdout);
     }
     XDisplay_SetPalettePrint(x_display, 0);
   }
 
   if (XDisplay_GetCharacterPrint(x_display)) {
     for (i = 0; i < 512; i++) {
-      WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i), stdout);
+      WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i),
+			    ww_display, stdout);
+      fflush(stdout);
     }
     XDisplay_SetCharacterPrint(x_display, 0);
   }
@@ -76,10 +81,22 @@ int WonXDisplay_Sync(WonXDisplay wonx_display)
   if (XDisplay_GetSpritePrint(x_display)) {
     for (i = 0; i < 128; i++) {
       WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout);
+      fflush(stdout);
     }
     XDisplay_SetSpritePrint(x_display, 0);
   }
 
+  return (0);
+}
+
+int WonXDisplay_Sync(WonXDisplay wonx_display)
+{
+  XDisplay x_display;
+
+  WonXDisplay_PrintData(wonx_display);
+
+  x_display = WonXDisplay_GetXDisplay(wonx_display);
+
   XDisplay_Sync(x_display);
 
   return (0);
@@ -97,7 +114,7 @@ int WonXDisplay_Flush(WonXDisplay wonx_display)
   if (XDisplay_GetLCDDraw(x_display)) {
     WWDisplay_DrawLCDPanel(ww_display);
     ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
-    XDisplay_DrawLCDWindow(x_display, ww_lcd_panel);
+    XDisplay_DrawLCDWindow(x_display, ww_display, ww_lcd_panel);
   }
 
   WonXDisplay_Sync(wonx_display);

+ 1 - 0
WonXDisplay.h

@@ -27,6 +27,7 @@ WWDisplay WonXDisplay_GetWWDisplay(WonXDisplay wonx_display);
 WonXDisplay WonXDisplay_Create(int x_width, int x_height,
 			       int ww_lcd_panel_width, int ww_lcd_panel_height,
 			       int ww_screen_width, int ww_screen_height);
+int WonXDisplay_PrintData(WonXDisplay wonx_display);
 int WonXDisplay_Sync(WonXDisplay wonx_display);
 int WonXDisplay_Flush(WonXDisplay wonx_display);
 

+ 2 - 0
WonXSystem.c

@@ -116,6 +116,8 @@ static int WonXTimer_Callback(WonXSystem wonx_system)
       WWInterrupt_ExecuteReceiveReadyCallback(ww_interrupt);
   }
 
+  WonXDisplay_PrintData(wonx_display);
+
   return (0);
 }
 

+ 743 - 0
XColorGC.c

@@ -0,0 +1,743 @@
+/*****************************************************************************/
+/* XColorGC GCと色の管理・問い合わせ用のライブラリ                           */
+/*****************************************************************************/
+
+#include "XColorGCP.h"
+
+#include "WonX.h"
+
+#include <string.h>
+
+/*===========================================================================*/
+/* XColorGCInstance 関連                                                     */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの作成                                                        */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCInstance XColorGCInstance_Create(XDisplay x_display,
+						XColor color)
+{
+  XColorGCInstance instance;
+
+  instance = (XColorGCInstance)malloc(sizeof(_XColorGCInstance));
+  if (instance == NULL)
+    WonX_Error("XColorGCInstance_Create", "Cannot allocate memory");
+
+  instance->x_display = x_display;
+  instance->color = color;
+
+  XAllocColor(XDisplay_GetDisplay(instance->x_display),
+	      XDisplay_GetColormap(instance->x_display),
+	      &(instance->color));
+
+  /* XAllocColor で instance->color.red などの内容が変わってしまうので,   */
+  /* もとに戻す.でないと,あとで同じ色をRGB値で検索しても,違った色として */
+  /* 解釈されてしまい,検索できないので,色情報を保存する意味が無くなって  */
+  /* しまう.                                                              */
+  instance->color.red   = color.red;
+  instance->color.green = color.green;
+  instance->color.blue  = color.blue;
+
+  instance->gc = XDisplay_CreateGC(instance->x_display);
+
+  XSetForeground(XDisplay_GetDisplay(instance->x_display), instance->gc,
+		 instance->color.pixel);
+  XSetBackground(XDisplay_GetDisplay(instance->x_display), instance->gc,
+		 instance->color.pixel);
+
+  return (instance);
+}
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの削除                                                        */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCInstance XColorGCInstance_Destroy(XColorGCInstance instance)
+{
+  unsigned long pixel;
+
+  if (instance == NULL) return (NULL);
+  if (instance->gc) XDisplay_DestroyGC(instance->x_display, instance->gc);
+  pixel = instance->color.pixel;
+  XFreeColors(XDisplay_GetDisplay(instance->x_display),
+	      XDisplay_GetColormap(instance->x_display),
+	      &pixel, 1, 0);
+  free(instance);
+  return (NULL);
+}
+
+/*===========================================================================*/
+/* XColorGCList 関連                                                         */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの作成                                                        */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCList XColorGCList_Create(XDisplay x_display, int studying_flag)
+{
+  XColorGCList list;
+
+  list = (XColorGCList)malloc(sizeof(_XColorGCList));
+  if (list == NULL) WonX_Error("XColorGCList_Create", "Cannot allocate memory");
+
+  list->x_display = x_display;
+  list->studying_flag = studying_flag;
+  list->list = ObjList_Create();
+
+  return (list);
+}
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの削除                                                        */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCList XColorGCList_Destroy(XColorGCList list)
+{
+  if (list == NULL) return (NULL);
+
+  if (list->list) ObjList_Destroy(list->list);
+
+  free(list);
+
+  return (NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+/* XColorGCList 中での XColorGCInstance のソート用の比較関数                 */
+/*---------------------------------------------------------------------------*/
+
+static int XColorGCInstance_CmpToColor(XColorGCInstance gci, XColor color)
+{
+  if (gci->color.red   > color.red  ) return ( 1);
+  if (gci->color.red   < color.red  ) return (-1);
+  if (gci->color.green > color.green) return ( 1);
+  if (gci->color.green < color.green) return (-1);
+  if (gci->color.blue  > color.blue ) return ( 1);
+  if (gci->color.blue  < color.blue ) return (-1);
+  return (0);
+}
+
+/*---------------------------------------------------------------------------*/
+/* リストから XColorGCInstance を得る.                                      */
+/* GC の取得要求に対して,GC のリストを検索して返す.                        */
+/* 存在しない場合には,作成してリストに追加する.                            */
+/* (常に RGB 値でソートされた状態で追加する)                                 */
+/* 線形探索なので,O(n^2)で遅くなる.                                        */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCInstance XColorGCList_GetXColorGCInstance(XColorGCList list,
+							 XColor color)
+{
+  XColorGCInstance instance;
+  ObjListData current;
+  int cmp;
+
+  for (current = ObjList_GetStart(list->list);
+       !ObjList_IsEndEdge(list->list, current);
+       current = ObjListData_GetNext(current)) {
+
+    instance = (XColorGCInstance)ObjListData_GetObj(current);
+    cmp = XColorGCInstance_CmpToColor(instance, color);
+
+    if (cmp == 0) { /* 見つかれば,それを返す */
+#ifdef HIT_LIST
+      fprintf(stderr, "S");
+#endif
+      if (list->studying_flag) ObjList_MoveObjToStart(list->list, current);
+      return (instance);
+    } else if (cmp > 0) {
+      if (!list->studying_flag) break;
+    }
+  }
+
+  /* 見つからなかった場合は,作成してリストに追加する */
+  instance = XColorGCInstance_Create(list->x_display, color);
+
+  if (list->studying_flag)
+    ObjList_InsertObjToStart(list->list, instance,
+			     (ObjDestructor)XColorGCInstance_Destroy);
+  else
+    ObjList_InsertObjToPrev(list->list, current, instance,
+			    (ObjDestructor)XColorGCInstance_Destroy);
+
+#ifdef HIT_LIST
+  fprintf(stderr, "A");
+#endif
+
+  return (instance);
+}
+
+/*===========================================================================*/
+/* XColorGCCache 関連                                                        */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* キャッシュ用バッファ                                                      */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCCacheBuffer XColorGCCacheBuffer_Create(XColorGCInstance instance)
+{
+  XColorGCCacheBuffer buffer;
+  buffer = (XColorGCCacheBuffer)malloc(sizeof(_XColorGCCacheBuffer));
+  if (buffer == NULL) WonX_Error("XColorGCCacheBuffer_Create",
+				 "Cannot allocate memory.");
+  buffer->instance = instance;
+  return (buffer);
+}
+
+static XColorGCCacheBuffer XColorGCCacheBuffer_Destroy(XColorGCCacheBuffer buffer)
+{
+  if (buffer == NULL) return (NULL);
+  free(buffer);
+  return (NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+/* キャッシュ                                                                */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCCache XColorGCCache_Create(XColorGCList color_gc_list, int size)
+{
+  XColorGCCache cache;
+
+  cache = (XColorGCCache)malloc(sizeof(_XColorGCCache));
+  if (cache == NULL) WonX_Error("XColorGCCache_Create",
+				"Cannot allocate memory.");
+
+  cache->size = size;
+  cache->color_gc_list = color_gc_list;
+  cache->buffer_list = ObjList_Create();
+
+  return (cache);
+}
+
+static XColorGCCache XColorGCCache_Destroy(XColorGCCache cache)
+{
+  if (cache == NULL) return (NULL);
+
+  if (cache->buffer_list) ObjList_Destroy(cache->buffer_list);
+  free(cache);
+
+  return (NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+/* キャッシュから XColorGCInstance を得る.                                  */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCInstance XColorGCCache_GetXColorGCInstance(XColorGCCache cache,
+							  XColor color)
+{
+  ObjListData current;
+  XColorGCCacheBuffer buffer;
+  XColorGCInstance instance;
+  int cmp;
+
+  /* キャッシュの中を検索 */
+  for (current = ObjList_GetStart(cache->buffer_list);
+       !ObjList_IsEndEdge(cache->buffer_list, current);
+       current = ObjListData_GetNext(current)) {
+
+    buffer = (XColorGCCacheBuffer)ObjListData_GetObj(current);
+    cmp = XColorGCInstance_CmpToColor(buffer->instance, color);
+
+    if (cmp == 0) { /* キャッシュ中に見つけた場合 */
+#ifdef HIT_CACHE
+      fprintf(stderr, "H"); /* Hit! */
+#endif
+      ObjList_MoveObjToStart(cache->buffer_list, current);
+      return (buffer->instance);
+    }
+  }
+
+  /* キャッシュ中に見つけられなかった場合 */
+
+  /* リストから検索する */
+  instance = XColorGCList_GetXColorGCInstance(cache->color_gc_list, color);
+
+  /* キャッシュに追加する */
+  if (ObjList_GetLength(cache->buffer_list) < cache->size) {
+    buffer = XColorGCCacheBuffer_Create(instance);
+    ObjList_InsertObjToStart(cache->buffer_list, buffer,
+			     (ObjDestructor)XColorGCCacheBuffer_Destroy);
+  } else {
+    current = ObjList_GetEnd(cache->buffer_list);
+    buffer = (XColorGCCacheBuffer)ObjListData_GetObj(current);
+    buffer->instance = instance;
+    ObjList_MoveObjToStart(cache->buffer_list, current);
+  }
+
+#ifdef HIT_CACHE
+  fprintf(stderr, "F"); /* False! */
+#endif
+
+  return (instance);
+}
+
+/*===========================================================================*/
+/* XColorGCHash 関連                                                         */
+/*===========================================================================*/
+
+static XColorGCHash XColorGCHash_Create(XDisplay x_display,
+					int studying_flag,
+					int cache_flag,
+					int cache_size,
+					int hash_number)
+{
+  XColorGCHash hash;
+  int i;
+
+  hash = (XColorGCHash)malloc(sizeof(_XColorGCHash));
+  if (hash == NULL)
+    WonX_Error("XColorGCHash_Create", "Cannot allocate memory.");
+
+  hash->number = hash_number;
+  hash->cache_flag = cache_flag;
+
+  if (cache_flag) {
+    hash->color_gc_cache =
+      (XColorGCCache *)malloc(sizeof(XColorGCCache) * hash->number);
+    if (hash->color_gc_cache == NULL)
+      WonX_Error("XColorGCHash_Create", "Cannot allocate memory.");
+  } else {
+    hash->color_gc_cache = NULL;
+  }
+
+  hash->color_gc_list =
+    (XColorGCList *)malloc(sizeof(XColorGCList) * hash->number);
+  if (hash->color_gc_list == NULL)
+    WonX_Error("XColorGCHash_Create", "Cannot allocate memory.");
+
+  for (i = 0; i < hash->number; i++) {
+    hash->color_gc_list[i] = XColorGCList_Create(x_display, studying_flag);
+    if (cache_flag) {
+      hash->color_gc_cache[i] = XColorGCCache_Create(hash->color_gc_list[i],
+						     cache_size);
+    }
+  }
+
+  return (hash);
+}
+
+static XColorGCHash XColorGCHash_Destroy(XColorGCHash hash)
+{
+  int i;
+
+  if (hash == NULL) return (NULL);
+
+  if (hash->color_gc_cache) {
+    for (i = 0; i < hash->number; i++) {
+      if (hash->color_gc_cache[i])
+	XColorGCCache_Destroy(hash->color_gc_cache[i]);
+    }
+    free(hash->color_gc_cache);
+  }
+
+  if (hash->color_gc_list) {
+    for (i = 0; i < hash->number; i++) {
+      if (hash->color_gc_list[i])
+	XColorGCList_Destroy(hash->color_gc_list[i]);
+    }
+    free(hash->color_gc_list);
+  }
+
+  free(hash);
+
+  return (NULL);
+}
+
+static void XColorGCHash_OutputHashStatus(XColorGCHash hash)
+{
+  int i;
+  printf ("\nHash :");
+  for (i = 0; i < hash->number; i++) {
+    printf("%d ", ObjList_GetLength(hash->color_gc_list[i]->list));
+  }
+  printf ("\n");
+}
+
+/*---------------------------------------------------------------------------*/
+/* ハッシュ関数                                                              */
+/* 色を減色している場合,特定の位置だけ頻繁に使用されたりしないように注意.  */
+/* (たとえば,                                                               */
+/*  ((int)color.red*3 + (int)color.green*2 + (int)color.blue) % hash->number */
+/*  のようなハッシュ関数だと,16階調に減色したときに,4096 の倍数の位置だけ  */
+/*  頻繁に使用されてしまう.                                                 */
+/*---------------------------------------------------------------------------*/
+
+static int HashFunction(XColorGCHash hash, XColor color)
+{
+  return ((
+	   (((int)color.red)   / 3000) * 11 +
+	   (((int)color.green) % 3000) / 7 +
+	   (((int)color.blue)  % 1000) / 3
+	   ) % hash->number);
+}
+
+/*---------------------------------------------------------------------------*/
+/* ハッシュから XColorGCInstance を得る.                                    */
+/*---------------------------------------------------------------------------*/
+
+static XColorGCInstance XColorGCHash_GetXColorGCInstance(XColorGCHash hash,
+							 XColor color)
+{
+  int n;
+
+  n = HashFunction(hash, color);
+
+  if (hash->cache_flag)
+    return (XColorGCCache_GetXColorGCInstance(hash->color_gc_cache[n], color));
+  else
+    return (XColorGCList_GetXColorGCInstance(hash->color_gc_list[n], color));
+}
+
+/*===========================================================================*/
+/* ColorName 関連                                                            */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの生成                                                        */
+/*---------------------------------------------------------------------------*/
+
+static ColorName ColorName_Create(XDisplay x_display, char * name)
+{
+  ColorName color_name;
+
+  color_name = (ColorName)malloc(sizeof(_ColorName));
+  if (color_name == NULL)
+    WonX_Error("ColorName_Create", "Cannot allocate memory");
+
+  color_name->name = malloc(sizeof(char) * (strlen(name) + 1));
+  if (color_name->name == NULL)
+    WonX_Error("ColorName_Create", "Cannot allocate memory");
+
+  strcpy(color_name->name, name);
+
+  XParseColor(XDisplay_GetDisplay(x_display),
+	      XDisplay_GetColormap(x_display),
+	      color_name->name, &(color_name->color));
+
+  return (color_name);
+}
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの削除                                                        */
+/*---------------------------------------------------------------------------*/
+
+static ColorName ColorName_Destroy(ColorName color_name)
+{
+  if (color_name == NULL) return (NULL);
+  if (color_name->name) free(color_name->name);
+  free(color_name);
+  return (NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの生成                                                        */
+/*---------------------------------------------------------------------------*/
+
+static ColorNameList ColorNameList_Create(XDisplay x_display)
+{
+  ColorNameList list;
+
+  list = (ColorNameList)malloc(sizeof(_ColorNameList));
+  if (list == NULL)
+    WonX_Error("ColorNameList_Create", "Cannot allocate memory");
+
+  list->x_display = x_display;
+  list->list = ObjList_Create();
+
+  return (list);
+}
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの削除                                                        */
+/*---------------------------------------------------------------------------*/
+
+static ColorNameList ColorNameList_Destroy(ColorNameList list)
+{
+  if (list == NULL) return (NULL);
+  if (list->list) ObjList_Destroy(list->list);
+  free(list);
+  return (NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+/* 文字列で与えられた色名から,RGB値を検索する.                             */
+/*---------------------------------------------------------------------------*/
+
+static XColor ColorNameList_GetColor(ColorNameList list, char * name)
+{
+  ObjListData current;
+  ColorName color_name;
+
+  for (current = ObjList_GetStart(list->list);
+       !ObjList_IsEndEdge(list->list, current);
+       current = ObjListData_GetNext(current)) {
+    color_name = (ColorName)ObjListData_GetObj(current);
+    if (!strcmp(color_name->name, name)) {
+      ObjList_MoveObjToStart(list->list, current);
+      return (color_name->color);
+    }
+  }
+
+  color_name = ColorName_Create(list->x_display, name);
+  if (color_name == NULL)
+    WonX_Error("ColorNameList_GetColor", "Cannot create ColorName");
+
+  ObjList_InsertObjToStart(list->list, color_name,
+			   (ObjDestructor)ColorName_Destroy);
+
+  return (color_name->color);
+}
+
+/*===========================================================================*/
+/* XColorGC 関連                                                             */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの生成                                                        */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_Create(XColorGCDatabase database, XColor color)
+{
+  XColorGC color_gc;
+
+  color_gc = (XColorGC)malloc(sizeof(_XColorGC));
+
+  /* ハッシュから色とGCを検索 */
+  color_gc->instance = XColorGCHash_GetXColorGCInstance(database->hash, color);
+
+  return (color_gc);
+}
+
+XColorGC XColorGC_CreateFromXColorGC(XColorGCDatabase database, XColorGC c)
+{
+  XColorGC color_gc;
+
+  color_gc = (XColorGC)malloc(sizeof(_XColorGC));
+
+  color_gc->instance = c->instance;
+
+  return (color_gc);
+}
+
+/*---------------------------------------------------------------------------*/
+/* RGB 値から生成する.                                                      */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_CreateFromRGB(XColorGCDatabase database,
+				int red, int green, int blue)
+{
+  XColor color;
+
+  color.red   = red;
+  color.green = green;
+  color.blue  = blue;
+  color.flags = DoRed | DoGreen | DoBlue;
+
+  return (XColorGC_Create(database, color));
+}
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの削除                                                        */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_Destroy(XColorGC color_gc)
+{
+  if (!color_gc) return (NULL);
+
+  free(color_gc);
+
+  return (NULL);
+}
+
+/*===========================================================================*/
+/* 文字列読み込み用関数                                                      */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* 色の節約のための,減色用の関数.                                          */
+/* 減色すると,色の共有化が進み,キャッシングの効果が大きくなる.            */
+/* あるていど減色しないと,色が共有できないので,無駄が多くなる.            */
+/*---------------------------------------------------------------------------*/
+
+static XColor DecreaseColor(XColor color, int gradation)
+{
+  int div = RGB_MAX_VALUE / gradation + 1;
+
+  color.red   /= div;
+  if (color.red   >= gradation - 1) color.red   = RGB_MAX_VALUE;
+  else color.red   *= div;
+
+  color.green /= div;
+  if (color.green >= gradation - 1) color.green = RGB_MAX_VALUE;
+  else color.green *= div;
+
+  color.blue  /= div;
+  if (color.blue  >= gradation - 1) color.blue  = RGB_MAX_VALUE;
+  else color.blue  *= div;
+
+  return (color);
+}
+
+/*---------------------------------------------------------------------------*/
+/* 色とGCのデータベースから name で与えられた名前の色を検索する.            */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_CreateFromCharacters(XColorGCDatabase database, char * name)
+{
+  XColor color;
+
+  if (!strcmp(name, "none") ||
+      !strcmp(name, "None") ||
+      !strcmp(name, "NONE") ||
+      !strcmp(name, "back") ||
+      !strcmp(name, "Back") ||
+      !strcmp(name, "BACK") ||
+      !strcmp(name, "background") ||
+      !strcmp(name, "Background") ||
+      !strcmp(name, "BACKGROUND")) {
+    if (database->background_color_gc)
+      return (XColorGC_CreateFromXColorGC(database,
+					  database->background_color_gc));
+    else
+#if 1
+      name = "none";
+#else
+    name = "black";
+#endif
+  }
+
+  color = ColorNameList_GetColor(database->color_name_list, name);
+
+  /* 色の節約のため,減色する */
+  color = DecreaseColor(color, database->gradation);
+
+  return (XColorGC_Create(database, color));
+}
+
+/*---------------------------------------------------------------------------*/
+/* XColor 構造体の取得                                                       */
+/*---------------------------------------------------------------------------*/
+
+XColor XColorGC_GetColor(XColorGC color_gc)
+{
+  return (color_gc->instance->color);
+}
+
+/*---------------------------------------------------------------------------*/
+/* ピクセル値の取得                                                          */
+/*---------------------------------------------------------------------------*/
+
+unsigned long XColorGC_GetPixel(XColorGC color_gc)
+{
+  return (color_gc->instance->color.pixel);
+}
+
+/*---------------------------------------------------------------------------*/
+/* GC の取得                                                                 */
+/*---------------------------------------------------------------------------*/
+
+GC XColorGC_GetGC(XColorGC color_gc)
+{
+  return (color_gc->instance->gc);
+}
+
+/*---------------------------------------------------------------------------*/
+/* 色の明るさの取得                                                          */
+/*---------------------------------------------------------------------------*/
+
+int GetBrightness(XColor color)
+{
+  long int br;
+
+#if 0
+  br = color.red > color.green ? color.red : color.green;
+  br = br > color.blue ? br : color.blue;
+  br = br * 100 / RGB_MAX_VALUE;
+#else
+  br = color.red + color.green + color.blue;
+  br = br * 100 / RGB_MAX_VALUE;
+#endif
+
+  if (br > 100) br = 100;
+
+  return ((int)br);
+}
+
+/*===========================================================================*/
+/* GC のデータベース                                                         */
+/*===========================================================================*/
+
+XColorGCDatabase XColorGCDatabase_Create(XDisplay x_display,
+					 int studying_flag,
+					 int cache_flag,
+					 int cache_size,
+					 int hash_number,
+					 char * background,
+					 int gradation)
+{
+  XColorGCDatabase database;
+
+  database = (XColorGCDatabase)malloc(sizeof(_XColorGCDatabase));
+  if (database == NULL)
+    WonX_Error("XColorGCDatabase_Create", "Cannot allocate memory.");
+
+  database->x_display = x_display;
+  database->gradation = gradation;
+
+  database->hash = XColorGCHash_Create(database->x_display,
+				       studying_flag,
+				       cache_flag,
+				       cache_size,
+				       hash_number);
+  database->color_name_list = ColorNameList_Create(database->x_display);
+
+  /* background が "none" の場合にも正常動作するように,               */
+  /* XColorGC_CreateFromCharacters()を呼び出す前に,NULL で初期化する. */
+  database->background_color_gc = NULL;
+
+  /* 引数に database を入れて呼び出すので,必ず最後に置くこと */
+  database->background_color_gc =
+    XColorGC_CreateFromCharacters(database, background);
+  /* この直後に return() が来るようにすること */
+
+  return (database);
+}
+
+XColorGCDatabase XColorGCDatabase_Destroy(XColorGCDatabase database)
+{
+  if (database == NULL) return (NULL);
+
+  if (database->background_color_gc)
+    XColorGC_Destroy(database->background_color_gc);
+
+  if (database->color_name_list)
+    ColorNameList_Destroy(database->color_name_list);
+  if (database->hash) XColorGCHash_Destroy(database->hash);
+  free(database);
+
+  return (NULL);
+}
+
+XColorGC XColorGCDatabase_GetBackgroundXColorGC(XColorGCDatabase database)
+{
+  return (database->background_color_gc);
+}
+
+/*---------------------------------------------------------------------------*/
+/* チューニング用                                                            */
+/*---------------------------------------------------------------------------*/
+
+void XColorGCDatabase_OutputHashStatus(XColorGCDatabase database)
+{
+  XColorGCHash_OutputHashStatus(database->hash);
+}
+
+/*****************************************************************************/
+/* End of File                                                               */
+/*****************************************************************************/

+ 98 - 0
XColorGC.h

@@ -0,0 +1,98 @@
+/*****************************************************************************/
+/* XColorGC GCと色の管理・問い合わせ用のライブラリ                           */
+/*****************************************************************************/
+
+#ifndef _XColorGC_h_INCLUDED_
+#define _XColorGC_h_INCLUDED_
+
+typedef struct _XColorGCDatabase * XColorGCDatabase;
+typedef struct _XColorGC * XColorGC;
+
+#include <X11/Xlib.h>
+
+#include "XDisplay.h"
+#include "Obj.h"
+
+/*===========================================================================*/
+/* XColorGC 関連                                                             */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの生成                                                        */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_Create(XColorGCDatabase database, XColor color);
+XColorGC XColorGC_CreateFromXColorGC(XColorGCDatabase database, XColorGC c);
+
+/*---------------------------------------------------------------------------*/
+/* RGB 値から生成する.                                                      */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_CreateFromRGB(XColorGCDatabase database,
+			      int red, int green, int blue);
+
+/*---------------------------------------------------------------------------*/
+/* オブジェクトの削除                                                        */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_Destroy(XColorGC color_gc);
+
+/*===========================================================================*/
+/* 文字列読み込み用関数                                                      */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* 色とGCのデータベースから name で与えられた名前の色を検索する.            */
+/*---------------------------------------------------------------------------*/
+
+XColorGC XColorGC_CreateFromCharacters(XColorGCDatabase database, char * name);
+
+/*---------------------------------------------------------------------------*/
+/* XColor 構造体の取得                                                       */
+/*---------------------------------------------------------------------------*/
+
+XColor XColorGC_GetColor(XColorGC color_gc);
+
+/*---------------------------------------------------------------------------*/
+/* ピクセル値の取得                                                          */
+/*---------------------------------------------------------------------------*/
+
+unsigned long XColorGC_GetPixel(XColorGC color_gc);
+
+/*---------------------------------------------------------------------------*/
+/* GC の取得                                                                 */
+/*---------------------------------------------------------------------------*/
+
+GC XColorGC_GetGC(XColorGC color_gc);
+
+/*---------------------------------------------------------------------------*/
+/* 色の明るさの取得                                                          */
+/*---------------------------------------------------------------------------*/
+
+int GetBrightness(XColor color);
+
+/*===========================================================================*/
+/* GC のデータベース                                                         */
+/*===========================================================================*/
+
+XColorGCDatabase XColorGCDatabase_Create(XDisplay x_display,
+					 int studying_flag,
+					 int cache_flag,
+					 int cache_size,
+					 int hash_number,
+					 char * background,
+					 int gradation);
+XColorGCDatabase XColorGCDatabase_Destroy(XColorGCDatabase database);
+XColorGC XColorGCDatabase_GetBackgroundXColorGC(XColorGCDatabase database);
+
+/*---------------------------------------------------------------------------*/
+/* チューニング用                                                            */
+/*---------------------------------------------------------------------------*/
+
+void XColorGCDatabase_OutputHashStatus(XColorGCDatabase database);
+
+#endif
+
+/*****************************************************************************/
+/* End of File                                                               */
+/*****************************************************************************/

+ 148 - 0
XColorGCP.h

@@ -0,0 +1,148 @@
+/*****************************************************************************/
+/* XColorGC GCと色の管理・問い合わせ用のライブラリ                           */
+/*****************************************************************************/
+
+#ifndef _XColorGCP_h_INCLUDED_
+#define _XColorGCP_h_INCLUDED_
+
+#include "XColorGC.h"
+
+#define RGB_MAX_VALUE 65535
+
+/*===========================================================================*/
+/* XFireworks は,描画の高速化のために,描画に必要な色と GC は,起動時に     */
+/* すべて確保するのですが,無駄な X サーバへのリクエストとメモリの浪費を     */
+/* 減らすために,いったん確保した色と GC はデータベースに記憶しておき,      */
+/* 同じ色が必要になったときには,共有するようにします.                      */
+/* (XColorGCDatabase はそのためのクラスです)                                 */
+/* これにより,XAllocColor() による色の問い合わせ待ちが減るため,            */
+/* 起動が格段に高速になります.                                              */
+/* データベースの検索には,ハッシュ,キャッシュ,学習機能を使用することが    */
+/* できます.                                                                */
+/*===========================================================================*/
+
+/*---------------------------------------------------------------------------*/
+/* 以下を有効にすると,同じ色のGCがどれくらい共有されているか調べることが    */
+/* できます.                                                                */
+/*---------------------------------------------------------------------------*/
+
+/* #define HIT_LIST */
+
+/*---------------------------------------------------------------------------*/
+/* 以下を有効にすると,キャッシュのヒット率を調べることができます.          */
+/*---------------------------------------------------------------------------*/
+
+/* #define HIT_CACHE */
+
+/*===========================================================================*/
+/* GC の実体を管理するクラス                                                 */
+/*===========================================================================*/
+
+typedef struct _XColorGCInstance * XColorGCInstance;
+
+typedef struct _XColorGCInstance {
+  XDisplay x_display;
+  GC gc;
+  XColor color;
+} _XColorGCInstance;
+
+/*===========================================================================*/
+/* GC の実体のリストを管理するクラス                                         */
+/* 同一の色のGCは共有したいため,GCの実体をリストで管理し,GCの取得要求に    */
+/* 対して,適切な XColorGCInstance を返す.                                  */
+/* (すでに存在するのならそれを返し,無ければ Create する)                    */
+/*===========================================================================*/
+
+typedef struct _XColorGCList * XColorGCList;
+
+typedef struct _XColorGCList { /* GC の管理用 */
+  XDisplay x_display;
+  int studying_flag; /* 学習機能のON/OFFのフラグ */
+  ObjList list; /* XColorGCInstance のリスト */
+} _XColorGCList;
+
+/*===========================================================================*/
+/* キャッシュ                                                                */
+/*===========================================================================*/
+
+typedef struct _XColorGCCacheBuffer * XColorGCCacheBuffer;
+typedef struct _XColorGCCache * XColorGCCache;
+
+/* キャッシュ用バッファ */
+typedef struct _XColorGCCacheBuffer {
+  XColorGCInstance instance;
+} _XColorGCCacheBuffer;
+
+/* キャッシュ */
+typedef struct _XColorGCCache {
+  int size; /* キャッシュサイズ */
+
+  XColorGCList color_gc_list;
+  ObjList buffer_list;
+} _XColorGCCache;
+
+/*===========================================================================*/
+/* ハッシュ                                                                  */
+/*===========================================================================*/
+
+typedef struct _XColorGCHash * XColorGCHash;
+
+typedef struct _XColorGCHash {
+  int number; /* ハッシュの個数 */
+  int cache_flag; /* キャッシュの使用・未使用のフラグ */
+  XColorGCCache * color_gc_cache;
+  XColorGCList * color_gc_list;
+} _XColorGCHash;
+
+/*===========================================================================*/
+/* 色の名前とRGB値の対応を管理するためのクラス                               */
+/*===========================================================================*/
+
+typedef struct _ColorName * ColorName;
+typedef struct _ColorNameList * ColorNameList;
+
+typedef struct _ColorName {
+  char * name;
+  XColor color;
+} _ColorName;
+
+typedef struct _ColorNameList {
+  XDisplay x_display;
+  ObjList list; /* ColorName のリスト */
+} _ColorNameList;
+
+/*===========================================================================*/
+/* 色と GC のデータベース                                                    */
+/* GC の検索には,ハッシュを用いる.                                         */
+/*===========================================================================*/
+
+typedef struct _XColorGCDatabase { /* GC の管理用 */
+  XDisplay x_display;
+  XColorGCHash hash; /* ハッシュ */
+
+  ColorNameList color_name_list; /* 色名 → RGB値の変換用 */
+
+  /* 背景色.色名で"none"を指定すると,この色が使用される. */
+  XColorGC background_color_gc;
+
+  /* 減色数.16階調にするときには16を指定 */
+  /* 10階調や20階調も指定可能             */
+  int gradation;
+
+} _XColorGCDatabase;
+
+/*===========================================================================*/
+/* GC を管理するクラス                                                       */
+/* 同じ色の GC が重複しない用に,XColorGCList で GC を管理して,             */
+/* 色の要求時には,XColorGCList から GC をもらうようにする.                 */
+/*===========================================================================*/
+
+typedef struct _XColorGC {
+  XColorGCInstance instance;
+} _XColorGC;
+
+#endif
+
+/*****************************************************************************/
+/* End of File                                                               */
+/*****************************************************************************/

+ 161 - 53
XDisplay.c

@@ -15,6 +15,12 @@
 /* メンバ関数の定義                                                          */
 /*****************************************************************************/
 
+Display * XDisplay_GetDisplay(XDisplay d) { return (d->display); }
+Colormap XDisplay_GetColormap(XDisplay d) { return (d->colormap); }
+
+XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display)
+{ return (x_display->color_gc_database); }
+
 unsigned int XDisplay_GetKeyPress(XDisplay d) { return (d->key_press); }
 int XDisplay_GetLCDDraw(XDisplay d) { return (d->lcd_draw); }
 
@@ -280,6 +286,16 @@ XDisplay XDisplay_Create(int width, int height)
     XSetFunction(x_display->display, x_display->color_gc[i], GXcopy);
   }
 
+  /* GCのデータベース初期化 */
+  x_display->color_gc_database =
+    XColorGCDatabase_Create(x_display,
+			    0,       /* studying_flag */
+			    1,       /* cache_flag */
+			    3,       /* cache_size */
+			    256,     /* hash_number */
+			    "black", /* background_color */
+			    16       /* gradation */);
+
   /* フォントの確保 */
   x_display->font = XLoadFont(x_display->display, "8x16");
   x_display->font_gc = XCreateGC(x_display->display,
@@ -382,89 +398,181 @@ int XDisplay_Sync(XDisplay x_display)
 /* 描画                                                                      */
 /*---------------------------------------------------------------------------*/
 
-int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel)
+int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
+			   WWLCDPanel ww_lcd_panel)
 {
   int x, y;
   int px, py, ph;
   int num;
   int n[16];
+  XRectangle rectangle;
   XRectangle * rectangles[16];
   int pixel;
   int ww_lcd_width, ww_lcd_height;
-
-  /* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
-  /* 最悪の場合(縞々模様のとき)で,width * height / 2 になる.        */
-  num =
-    WWLCDPanel_GetHeight(ww_lcd_panel) * WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
-
-  /*
-   * この malloc() は,実際にはメモリはほとんど使用されていないので,
-   * そのうちなんとかする必要がある
-   */
-  for (pixel = 0; pixel < 16; pixel++) {
-    n[pixel] = 0;
-    rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
-  }
-  if (rectangles == NULL)
-    WonX_Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
+  int red, green, blue;
+  XColorGCDatabase database;
+  XColorGC x_color_gc;
+  GC gc;
 
   ww_lcd_width  = WWLCDPanel_GetWidth( ww_lcd_panel);
   ww_lcd_height = WWLCDPanel_GetHeight(ww_lcd_panel);
 
-  /* ここの処理はホットスポットになるので,のちのちにチューニングすること */
+  switch (WWDisplay_GetColorMode(ww_display)) {
 
-  for (y = 0; y < ww_lcd_height; y++) {
-    py = (y * x_display->height) / ww_lcd_height;
-    ph = (y+1) * x_display->height / ww_lcd_height- py;
-    for (x = 0; x < ww_lcd_width; x++) {
-      if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
-	continue;
-      }
-      pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
-      px = (x * x_display->width ) / ww_lcd_width;
-      rectangles[pixel][n[pixel]].x = px;
-      rectangles[pixel][n[pixel]].y = py;
-      rectangles[pixel][n[pixel]].width  =
-	(x+1) * x_display->width  / ww_lcd_width - px;
-      rectangles[pixel][n[pixel]].height = ph;
-
-      /* 隣接してる同色のピクセルは,極力いっしょに描画する */
-      x++;
-      while ( (x < ww_lcd_width) &&
-	      (pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
-	      (WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
-	rectangles[pixel][n[pixel]].width =
-	  (x+1) * x_display->width / ww_lcd_width - px;
+  case COLOR_MODE_GRAYSCALE:
+
+    /* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
+    /* 最悪の場合(縞々模様のとき)で,width * height / 2 になる.        */
+    num =
+      WWLCDPanel_GetHeight(ww_lcd_panel) *
+      WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
+
+    /*
+     * この malloc() は,実際にはメモリはほとんど使用されていないので,
+     * そのうちなんとかする必要がある
+     */
+    for (pixel = 0; pixel < 16; pixel++) {
+      n[pixel] = 0;
+      rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
+    }
+    if (rectangles == NULL)
+      WonX_Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
+
+    /* ここの処理はホットスポットになるので,のちのちにチューニングすること */
+
+    for (y = 0; y < ww_lcd_height; y++) {
+      py = (y * x_display->height) / ww_lcd_height;
+      ph = (y+1) * x_display->height / ww_lcd_height- py;
+      for (x = 0; x < ww_lcd_width; x++) {
+	if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
+	  continue;
+	}
+	pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
+	px = (x * x_display->width ) / ww_lcd_width;
+	rectangles[pixel][n[pixel]].x = px;
+	rectangles[pixel][n[pixel]].y = py;
+	rectangles[pixel][n[pixel]].width  =
+	  (x+1) * x_display->width  / ww_lcd_width - px;
+	rectangles[pixel][n[pixel]].height = ph;
+
+	/* 隣接してる同色のピクセルは,極力いっしょに描画する */
 	x++;
+	while ( (x < ww_lcd_width) &&
+		(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
+		(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
+	  rectangles[pixel][n[pixel]].width =
+	    (x+1) * x_display->width / ww_lcd_width - px;
+	  x++;
+	}
+	x--;
+
+	n[pixel]++;
       }
-      x--;
+    }
 
-      n[pixel]++;
+    for (pixel = 0; pixel < 16; pixel++) {
+      if (n[pixel] > 0) {
+	XFillRectangles(x_display->display,
+			x_display->lcd_pixmap,
+			x_display->color_gc[pixel],
+			rectangles[pixel], n[pixel]);
+      }
     }
-  }
 
-  for (pixel = 0; pixel < 16; pixel++) {
-    if (n[pixel] > 0) {
-      XFillRectangles(x_display->display,
-		      x_display->lcd_pixmap,
-		      x_display->color_gc[pixel],
-		      rectangles[pixel], n[pixel]);
+    for (pixel = 0; pixel < 16; pixel++) {
+      free(rectangles[pixel]);
+    }
+
+    break;
+
+  case COLOR_MODE_4COLOR:
+  case COLOR_MODE_16COLOR:
+  case COLOR_MODE_16PACKED:
+
+    database = XDisplay_GetColorGCDatabase(x_display);
+
+    for (y = 0; y < ww_lcd_height; y++) {
+      py = (y * x_display->height) / ww_lcd_height;
+      ph = (y+1) * x_display->height / ww_lcd_height- py;
+      for (x = 0; x < ww_lcd_width; x++) {
+	if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
+	  continue;
+	}
+	pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
+	px = (x * x_display->width ) / ww_lcd_width;
+	rectangle.x = px;
+	rectangle.y = py;
+	rectangle.width  = (x+1) * x_display->width  / ww_lcd_width - px;
+	rectangle.height = ph;
+
+	/* 隣接してる同色のピクセルは,極力いっしょに描画する */
+	x++;
+	while ( (x < ww_lcd_width) &&
+		(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
+		(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
+	  rectangle.width =
+	    (x+1) * x_display->width / ww_lcd_width - px;
+	  x++;
+	}
+	x--;
+
+	red   = (pixel >> 8) & 0xf;
+	green = (pixel >> 4) & 0xf;
+	blue  = (pixel >> 0) & 0xf;
+
+	red   = (red   == 15) ? 65535 : red   * 4096;
+	green = (green == 15) ? 65535 : green * 4096;
+	blue  = (blue  == 15) ? 65535 : blue  * 4096;
+
+	x_color_gc = XColorGC_CreateFromRGB(database, red, green, blue);
+	gc = XColorGC_GetGC(x_color_gc);
+
+	XFillRectangle(x_display->display,
+		       x_display->lcd_pixmap,
+		       gc,
+		       rectangle.x,
+		       rectangle.y,
+		       rectangle.width,
+		       rectangle.height);
+      }
     }
+
+    break;
+
+  default:
+    WonX_Error("XDisplay_DrawLCDWindow", "Unknown color mode.");
   }
 
   XCopyArea(x_display->display, x_display->lcd_pixmap,
 	    x_display->lcd_window, x_display->copy_gc,
-            0, 0, x_display->width, x_display->height, 0, 0);
+	    0, 0, x_display->width, x_display->height, 0, 0);
 
   WWLCDPanel_ResetAllDraw(ww_lcd_panel);
   WWLCDPanel_ReverseCurrent(ww_lcd_panel);
 
   XDisplay_Sync(x_display);
 
-  for (pixel = 0; pixel < 16; pixel++) {
-    free(rectangles[pixel]);
-  }
+  return (0);
+}
+
+/*---------------------------------------------------------------------------*/
+/* GC の作成                                                                 */
+/*---------------------------------------------------------------------------*/
+
+GC XDisplay_CreateGC(XDisplay x_display)
+{
+  GC gc;
+  gc = XCreateGC(x_display->display, x_display->root_window, 0, 0);
+  return (gc);
+}
 
+/*---------------------------------------------------------------------------*/
+/* GC の解放                                                                 */
+/*---------------------------------------------------------------------------*/
+
+int XDisplay_DestroyGC(XDisplay x_display, GC gc)
+{
+  XFreeGC(x_display->display, gc);
   return (0);
 }
 

+ 23 - 1
XDisplay.h

@@ -15,14 +15,23 @@ typedef struct _XDisplay * XDisplay;
 /* ヘッダファイルのインクルード                                              */
 /*****************************************************************************/
 
+#include <X11/Xlib.h>
+
 #include "wonx_include/key.h"
 
+#include "WWDisplay.h"
 #include "WWLCDPanel.h"
+#include "XColorGC.h"
 
 /*****************************************************************************/
 /* メンバ関数の宣言                                                          */
 /*****************************************************************************/
 
+Display * XDisplay_GetDisplay(XDisplay x_display);
+Colormap XDisplay_GetColormap(XDisplay x_display);
+
+XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display);
+
 unsigned int XDisplay_GetKeyPress(XDisplay x_display);
 int XDisplay_GetLCDDraw(XDisplay x_display);
 
@@ -62,7 +71,20 @@ int XDisplay_Sync(XDisplay x_display);
 /* 描画                                                                      */
 /*---------------------------------------------------------------------------*/
 
-int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel);
+int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
+			   WWLCDPanel ww_lcd_panel);
+
+/*---------------------------------------------------------------------------*/
+/* GC の作成                                                                 */
+/*---------------------------------------------------------------------------*/
+
+GC XDisplay_CreateGC(XDisplay x_display);
+
+/*---------------------------------------------------------------------------*/
+/* GC の解放                                                                 */
+/*---------------------------------------------------------------------------*/
+
+int XDisplay_DestroyGC(XDisplay x_display, GC gc);
 
 /*****************************************************************************/
 /* ここまで                                                                  */

+ 4 - 2
XDisplayP.h

@@ -9,7 +9,6 @@
 
 #include <signal.h>
 
-#include <X11/Xlib.h>
 #include <X11/Intrinsic.h>
 #include <X11/StringDefs.h>
 #include <X11/Shell.h>
@@ -37,7 +36,10 @@ typedef struct _XDisplay {
   Pixmap lcd_pixmap;
 
   GC copy_gc;
-  GC color_gc[16];
+  GC color_gc[16]; /* 白黒表示用のGC */
+
+  /* 4096色表示用のGCのデータベース(XFireworks から流用) */
+  XColorGCDatabase color_gc_database;
 
   /* テキストスクリーンへの文字表示用のフォント */
   Font font;

+ 51 - 45
disp.c

@@ -65,7 +65,14 @@ void display_control(unsigned int flags)
     WWScreen_SetMode(WWDisplay_GetScreen(ww_display, SCREEN2),
 		     WW_SCREEN_OUTSIDE_ONLY);
 
-  WWDisplay_SetBorder(ww_display, (flags & DCM_BORDER_COLOR) >> 7);
+  WWDisplay_SetBorderPalette(ww_display,
+			     WWDisplay_GetPalette(ww_display,
+						  (flags & 0xf000) >> 12));
+#if 0
+  WWDisplay_SetBorderColor(ww_display, (flags & DCM_BORDER_COLOR) >> 8);
+#else /* カラー対応で,ボーダーカラーは4ビットに変更された */
+  WWDisplay_SetBorderColor(ww_display, (flags & 0x0f00) >> 8);
+#endif
 
   WonXDisplay_Flush(WonX_GetWonXDisplay());
 
@@ -115,7 +122,8 @@ unsigned int display_status(void)
     default:
   }
 
-  ret |= WWDisplay_GetBorder(ww_display) << 7;
+  ret |= (unsigned short int)WWPalette_GetNumber(WWDisplay_GetBorderPalette(ww_display)) << 12;
+  ret |= (unsigned short int)WWDisplay_GetBorderColor(ww_display) << 8;
 
   WonXDisplay_Sync(WonX_GetWonXDisplay());
 
@@ -135,10 +143,12 @@ unsigned int display_status(void)
 void font_set_monodata(unsigned int number, unsigned int count,
 		       unsigned char * data)
 {
-  WWCharacter c;
-  int i, x, y, n, p;
-  int f, b;
+  WWCharacter ww_character;
   WWDisplay ww_display;
+  int i, j, k, n;
+  unsigned char pixel;
+  int f, b;
+  unsigned char bitmap[2];
 
   if (!WonX_IsCreated()) WonX_Create();
 
@@ -146,7 +156,8 @@ void font_set_monodata(unsigned int number, unsigned int count,
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
   printf("call : font_set_monodata() : number = %u, count = %u, data = %p\n",
-	 (int)number, (int)count, (void *)data); fflush(stdout);
+	 (int)number, (int)count, (void *)data);
+  fflush(stdout);
 
   ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
 
@@ -155,12 +166,17 @@ void font_set_monodata(unsigned int number, unsigned int count,
 
   n = 0;
   for (i = 0; i < count; i++) {
-    c = WWDisplay_GetCharacter(ww_display, number + i);
-    for (y = 0; y < 8; y++) {
-      for (x = 0; x < 8; x++) {
-	p = (data[n] & (1 << (7 - x))) ? f : b; /*これでよいのか?*/
-	WWCharacter_SetPixel(c, x, y, p);
+    ww_character = WWDisplay_GetCharacter(ww_display, number + i);
+    for (j = 0; j < 8; j++) {
+      bitmap[0] = 0;
+      bitmap[1] = 0;
+      for (k = 0; k < 8; k++) {
+	pixel = (data[n] & (1 << k)) ? f : b;
+	bitmap[0] |= ( pixel       & 1) << k;
+	bitmap[1] |= ((pixel >> 1) & 1) << k;
       }
+      WWCharacter_SetBitmap(ww_character, j*2  , bitmap[0]);
+      WWCharacter_SetBitmap(ww_character, j*2+1, bitmap[1]);
       n++;
     }
   }
@@ -183,8 +199,9 @@ void font_set_monodata(unsigned int number, unsigned int count,
 void font_set_colordata(unsigned int number, unsigned int count,
 			unsigned char * data)
 {
-  WWCharacter c;
-  int i, x, y, n, p;
+  WWCharacter ww_character;
+  WWDisplay ww_display;
+  int i, j, n;
 
   if (!WonX_IsCreated()) WonX_Create();
 
@@ -192,23 +209,16 @@ void font_set_colordata(unsigned int number, unsigned int count,
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
   printf("call : font_set_colordata() : number = %u, count = %u, data = %p\n",
-	 (int)number, (int)count, (void *)data); fflush(stdout);
+	 (int)number, (int)count, (void *)data);
+  fflush(stdout);
 
-  n = 0;
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
 
+  n = 0;
   for (i = 0; i < count; i++) {
-    c = WWDisplay_GetCharacter(WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay()),
-			       number + i);
-    for (y = 0; y < 8; y++) {
-      for (x = 0; x < 8; x++) {
-
-	/*これでよいのか?*/
-	p = ((data[n] & (1 << (7-x))) ? 2 : 0)
-	  + ((data[n + 1] & (1 << (7-x))) ? 1 : 0);
-
-	WWCharacter_SetPixel(c, x, y, p);
-      }
-      n++;
+    ww_character = WWDisplay_GetCharacter(ww_display, number + i);
+    for (j = 0; j < 16; j++) {
+      WWCharacter_SetBitmap(ww_character, j, data[n]);
       n++;
     }
   }
@@ -232,8 +242,9 @@ void font_get_data(unsigned int number, unsigned int count,
 		   unsigned char * data)
 {
   /* 関数の仕様がわからんので適当に書くぞ */
-  WWCharacter c;
-  int i, x, y, n, p;
+  WWCharacter ww_character;
+  WWDisplay ww_display;
+  int i, j, n;
 
   if (!WonX_IsCreated()) WonX_Create();
 
@@ -241,23 +252,16 @@ void font_get_data(unsigned int number, unsigned int count,
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
   printf("call : font_get_data() : number = %u, count = %u, data = %p\n",
-	 (int)number, (int)count, (void *)data); fflush(stdout);
+	 (int)number, (int)count, (void *)data);
+  fflush(stdout);
 
-  n = 0;
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
 
+  n = 0;
   for (i = 0; i < count; i++) {
-    c = WWDisplay_GetCharacter(WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay()),
-			       number + i);
-    for (y = 0; y < 8; y++) {
-      data[n  ] = 0;
-      data[n+1] = 0;
-      for (x = 0; x < 8; x++) {
-	p = WWCharacter_GetPixel(c, x, y);
-	/* これでよいのか? */
-	data[n  ] |= (((unsigned char)p & 0x02) ? 1 : 0) << (7-x);
-	data[n+1] |= (((unsigned char)p & 0x01) ? 1 : 0) << (7-x);
-      }
-      n++;
+    ww_character = WWDisplay_GetCharacter(ww_display, number + i);
+    for (j = 0; j < 16; j++) {
+      data[n] = WWCharacter_GetBitmap(ww_character, j);
       n++;
     }
   }
@@ -1082,7 +1086,6 @@ unsigned int palette_get_color(unsigned int palette_num)
   int mapped_colors[4];
   WWPalette palette;
   unsigned short int ret;
-  int i;
 
   if (!WonX_IsCreated()) WonX_Create();
 
@@ -1095,12 +1098,15 @@ unsigned int palette_get_color(unsigned int palette_num)
   palette =
     WWDisplay_GetPalette(WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay()),
 			 palette_num);
-  /* 透明色は -1 で返されるので注意すること */
+
+  /* WonX-2.0 以前では,透明色は -1 で返されていたので注意が必要だった  */
   WWPalette_GetMappedColors(palette, mapped_colors);
 
+#if 0 /* WonX-2.0 以前では,透明色の処理が必要だった.一応コードを残しておく */
   /* 透明色は -1 で表されるので,0にする */
   for (i = 0; i < 4; i++)
     if (mapped_colors[i] == -1) mapped_colors[i] = 0;
+#endif
 
   ret = 0;
   ret |=  mapped_colors[0] & 0x07;

+ 6 - 6
key.c

@@ -39,7 +39,7 @@ int key_press_check(void)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : key_press_check() : "); fflush(stdout);
+  printf("call : key_press_check() : \n"); fflush(stdout);
 
   x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
   XDisplay_Sync(x_display);
@@ -67,7 +67,7 @@ int key_hit_check(void)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : key_hit_check() : "); fflush(stdout);
+  printf("call : key_hit_check() : \n"); fflush(stdout);
 
   x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
   XDisplay_Sync(x_display);
@@ -95,7 +95,7 @@ int key_wait(void)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : key_wait() : "); fflush(stdout);
+  printf("call : key_wait() : \n"); fflush(stdout);
 
   x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
 
@@ -127,7 +127,7 @@ void key_set_repeat(int rate, int delay)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : key_set_repeat() : rate = %d, delay = %d, ", rate, delay);
+  printf("call : key_set_repeat() : rate = %d, delay = %d\n", rate, delay);
   fflush(stdout);
 
   WonXDisplay_Sync(WonX_GetWonXDisplay());
@@ -149,7 +149,7 @@ int key_get_repeat(void)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : key_get_repeat() : "); fflush(stdout);
+  printf("call : key_get_repeat() : \n"); fflush(stdout);
 
   ret = 0;
 
@@ -174,7 +174,7 @@ int key_hit_check_with_repeat(void)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : key_hit_check_with_repeat() : "); fflush(stdout);
+  printf("call : key_hit_check_with_repeat() : \n"); fflush(stdout);
 
   x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
   XDisplay_Sync(x_display);

+ 317 - 0
libwwc.c

@@ -0,0 +1,317 @@
+/*****************************************************************************/
+/* ここから                                                                  */
+/*****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "wonx_configure.h"
+
+#include "wonx_include/libwwc.h"
+
+#include "WonX.h"
+
+/*****************************************************************************/
+/* 互換関数の定義                                                            */
+/*****************************************************************************/
+
+/*
+ * void * でデータを渡す関数は,型を間違えるバグが入る可能性があるので,
+ * void * を適切な型に置き換えてある.
+ */
+
+/*
+ * Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので,
+ * 互換関数の内部は UNIXTimer_Pause(), UNIXTimer_Unpause() でくくり,
+ * タイマ割り込みを一時停止して処理を行う.また,unpause するまえに,
+ * かならず sync するようにする.
+ */
+
+/*
+ * タイマの一時停止の2重解除の問題が出てくるので,
+ * 互換関数から互換関数を呼んではいけない.
+ * (一時停止はネストされるが,いちおう)
+ * 似たような処理をする関数の場合は,必ず static な別関数に処理をまとめ,
+ * そっちを呼び出すようにすること.
+ * 引数の表示の問題もあるしね.
+ */
+
+unsigned int wwc_set_color_mode(unsigned int mode)
+{
+  WWDisplay ww_display;
+  unsigned int ret;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_set_color_mode() : mode = 0x%04x\n", (int)mode);
+  fflush(stdout);
+
+  switch (mode) {
+  case COLOR_MODE_GRAYSCALE :
+  case COLOR_MODE_4COLOR :
+  case COLOR_MODE_16COLOR :
+  case COLOR_MODE_16PACKED :
+    break;
+  default :
+    WonX_Error("wwc_set_color_mode", "unknown color mode.");
+  }
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+
+  ret = WWDisplay_SetColorMode(ww_display, mode);
+
+  /* 次回の描画時には,全描画する */
+  WWLCDPanel_SetAllDraw(WWDisplay_GetLCDPanel(ww_display));
+
+  WonXDisplay_Flush(WonX_GetWonXDisplay());
+
+  printf("call : wwc_set_color_mode() : return value = 0x%04x\n", (int)ret);
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return (ret);
+}
+
+unsigned int wwc_get_color_mode(void)
+{
+  WWDisplay ww_display;
+  unsigned int ret;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_get_color_mode() : \n"); fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+
+  ret = WWDisplay_GetColorMode(ww_display);
+
+  WonXDisplay_Sync(WonX_GetWonXDisplay());
+
+  printf("call : wwc_get_color_mode() : return value = 0x%04x\n", (int)ret);
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return (ret);
+}
+
+void wwc_palette_set_color(unsigned int palette_num, unsigned int color_num, unsigned int rgb)
+{
+  WWDisplay ww_display;
+  WWPalette ww_palette;
+  unsigned short int red, green, blue;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_palette_set_color() : palette_num = %u, color_num = %u, rgb = 0x%04x\n",
+	 (int)palette_num, (int)color_num, (int)rgb);
+  fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+  ww_palette = WWDisplay_GetPalette(ww_display, palette_num);
+  red   = (rgb >> 8) & 0x0f;
+  green = (rgb >> 4) & 0x0f;
+  blue  = (rgb >> 0) & 0x0f;
+  WWPalette_SetRed(  ww_palette, color_num, red  );
+  WWPalette_SetGreen(ww_palette, color_num, green);
+  WWPalette_SetBlue( ww_palette, color_num, blue );
+
+  WonXDisplay_Flush(WonX_GetWonXDisplay());
+
+  printf("call : wwc_palette_set_color() : return value = none\n");
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return;
+}
+
+unsigned int wwc_palette_get_color(unsigned int palette_num, unsigned int color_num)
+{
+  WWDisplay ww_display;
+  WWPalette ww_palette;
+  unsigned short int red, green, blue;
+  unsigned short int ret;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_palette_get_color() : palette_num = %u, color_num = %u\n",
+	 (int)palette_num, (int)color_num);
+  fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+  ww_palette = WWDisplay_GetPalette(ww_display, palette_num);
+
+  red   = WWPalette_GetRed(  ww_palette, color_num);
+  green = WWPalette_GetGreen(ww_palette, color_num);
+  blue  = WWPalette_GetBlue( ww_palette, color_num);
+
+  ret = (red << 8) | (green << 4) | (blue << 0);
+
+  WonXDisplay_Sync(WonX_GetWonXDisplay());
+
+  printf("call : wwc_palette_get_color() : return value = 0x%04x\n", (int)ret);
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return (ret);
+}
+
+void wwc_font_set_colordata(unsigned int number, unsigned int count, unsigned char * data)
+{
+  WWCharacter ww_character;
+  WWDisplay ww_display;
+  int i, j, n;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_font_set_colordata() : number = %u, count = %u, data = %p\n",
+	 (int)number, (int)count, (void *)data);
+  fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+
+  n = 0;
+  for (i = 0; i < count; i++) {
+    ww_character = WWDisplay_GetCharacter(ww_display, number + i);
+    for (j = 0; j < 32; j++) {
+      WWCharacter_SetBitmap(ww_character, j, data[n]);
+      n++;
+    }
+  }
+
+  WonXDisplay_Flush(WonX_GetWonXDisplay());
+
+  printf("call : wwc_font_set_colordata() : return value = none\n");
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return;
+}
+
+void wwc_font_get_colordata(unsigned int number, unsigned int count, unsigned char * data)
+{
+  WWCharacter ww_character;
+  WWDisplay ww_display;
+  int i, j, n;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_font_get_colordata() : number = %u, count = %u, data = %p\n",
+	 (int)number, (int)count, (void *)data);
+  fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+
+  n = 0;
+  for (i = 0; i < count; i++) {
+    ww_character = WWDisplay_GetCharacter(ww_display, number + i);
+    for (j = 0; j < 32; j++) {
+      data[n] = WWCharacter_GetBitmap(ww_character, j);
+      n++;
+    }
+  }
+
+  WonXDisplay_Sync(WonX_GetWonXDisplay());
+
+  printf("call : wwc_font_get_colordata() : return value = none\n");
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return;
+}
+
+unsigned int wwc_get_hardarch(void)
+{
+  WWDisplay ww_display;
+  unsigned int ret;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_get_hardarch() : \n"); fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+
+  ret = WONX_DEFAULT_ARCH;
+
+  WonXDisplay_Sync(WonX_GetWonXDisplay());
+
+  printf("call : wwc_get_hardarch() : return value = %u\n", (int)ret);
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return (ret);
+}
+
+void wwc_clear_font(void)
+{
+  WWDisplay ww_display;
+  WWCharacter ww_character;
+  int i;
+
+  if (!WonX_IsCreated()) WonX_Create();
+
+  /* タイマを一時停止する */
+  UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  printf("call : wwc_clear_font() : \n");
+  fflush(stdout);
+
+  ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
+
+  for (i = 0; i < 512; i++) {
+    ww_character = WWDisplay_GetCharacter(ww_display, i);
+    WWCharacter_ClearAllPixels(ww_character);
+  }
+
+  WonXDisplay_Flush(WonX_GetWonXDisplay());
+
+  printf("call : wwc_clear_font() : return value = none\n");
+  fflush(stdout);
+
+  /* タイマをもとに戻す */
+  UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
+
+  return;
+}
+
+/*****************************************************************************/
+/* ここまで                                                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* End of File.                                                              */
+/*****************************************************************************/

+ 1 - 1
sample1.c

@@ -12,7 +12,7 @@ main()
   text_put_string(0,  8, "   linked to program for    ");
   text_put_string(0,  9, "  WonderWitch and behave as ");
   text_put_string(0, 10, "        WonderWitch.        ");
-  text_put_string(0, 12, "  WonX Copyright (c) 2000   ");
+  text_put_string(0, 12, "WonX Copyright (c) 2000-2001");
   text_put_string(0, 13, "       Sakai Hiroaki.       ");
   text_put_string(0, 14, "    All Rights Reserved.    ");
   text_put_string(0, 16, "   Hit space key to exit.   ");

+ 2 - 2
text.c

@@ -505,7 +505,7 @@ void cursor_set_location(int x, int y, int w, int h)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : cursor_set_location() : x = %d, y = %d, w = %d, h = %d",
+  printf("call : cursor_set_location() : x = %d, y = %d, w = %d, h = %d\n",
 	 x, y, w, h);
   fflush(stdout);
 
@@ -585,7 +585,7 @@ void cursor_set_type(int palette_num, int interval)
   /* タイマを一時停止する */
   UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
 
-  printf("call : cursor_set_type() : palette = %d, interval = %d",
+  printf("call : cursor_set_type() : palette = %d, interval = %d\n",
 	 palette_num, interval);
   fflush(stdout);
 

+ 6 - 1
wonx_configure.h

@@ -1,8 +1,13 @@
 /* configure.h for configuration of wonx */
 
-#ifndef _WONX_winx_configure_h_INCLUDED_
+#ifndef _WONX_wonx_configure_h_INCLUDED_
 #define _WONX_wonx_configure_h_INCLUDED_
 
+#include "wonx_include/libwwc.h"
+
+/* デフォルトのアーキテクチャ */
+#define WONX_DEFAULT_ARCH HARDARCH_WSC
+
 /* WonX でのタイマ割り込みの周期(単位はミリ秒) */
 #define WONX_TIMER_INTERVAL 100 /* 0.1 秒 */
 

+ 16 - 0
wonx_include/fcntl_attention.h

@@ -0,0 +1,16 @@
+#ifndef _WONX_SYS_FCNTL_H_
+#define _WONX_SYS_FCNTL_H_
+
+/*
+ * fcntl.h は /usr/include/fcntl.h を読み込めばよいので,
+ * wonx_include/fcntl.h を作らないほうがよい.(wonx_include/fcntl.h を作ると,
+ * 書き方によってはそっちが読み込まれてしまうかもしれないので)
+ * もしも作るとすれば,このファイルのようなのを作るか?
+ */
+
+#include "filesys.h"
+
+/* 自分自身を読み込まないように,/usr/include を明示する */
+#include </usr/include/fcntl.h>
+
+#endif

+ 8 - 0
wonx_include/filesys.h

@@ -0,0 +1,8 @@
+#ifndef _WONX_SYS_FILESYS_H_
+#define _WONX_SYS_FILESYS_H_
+
+#include "types.h"
+
+#include <stdio.h>
+
+#endif

+ 9 - 0
wonx_include/indirect.h

@@ -0,0 +1,9 @@
+#ifndef _WONX_SYS_INDIRECT_H_
+#define _WONX_SYS_INDIRECT_H_
+
+#include "service.h"
+#include "filesys.h"
+
+#warning indirect function is not supported.
+
+#endif

+ 31 - 0
wonx_include/libwwc.h

@@ -0,0 +1,31 @@
+#ifndef _WONX_SYS_LIBWWC_H_
+#define _WONX_SYS_LIBWWC_H_
+
+#include "service.h"
+
+/*****************************************************************************/
+/* 年眶の年盗                                                                */
+/*****************************************************************************/
+
+#define COLOR_MODE_GRAYSCALE 0x00
+#define COLOR_MODE_4COLOR    0x80
+#define COLOR_MODE_16COLOR   0xC0
+#define COLOR_MODE_16PACKED  0xE0
+
+#define HARDARCH_WS  0
+#define HARDARCH_WSC 1
+
+/*****************************************************************************/
+/* 高垂簇眶の离咐                                                            */
+/*****************************************************************************/
+
+unsigned int wwc_set_color_mode(unsigned int mode);
+unsigned int wwc_get_color_mode(void);
+void wwc_palette_set_color(unsigned int palette_num, unsigned int color_num, unsigned int rgb);
+unsigned int wwc_palette_get_color(unsigned int palette_num, unsigned int color_num);
+void wwc_font_set_colordata(unsigned int number, unsigned int count, unsigned char * data);
+void wwc_font_get_colordata(unsigned int number, unsigned int count, unsigned char * data);
+unsigned int wwc_get_hardarch(void);
+void wwc_clear_font(void);
+
+#endif

+ 9 - 0
wonx_include/oswork.h

@@ -0,0 +1,9 @@
+#ifndef _WONX_SYS_OSWORK_H_
+#define _WONX_SYS_OSWORK_H_
+
+#include "process.h"
+#include "fcntl.h"
+
+#warning oswork function is not supported.
+
+#endif

+ 10 - 0
wonx_include/process.h

@@ -0,0 +1,10 @@
+#ifndef _WONX_SYS_PROCESS_H_
+#define _WONX_SYS_PROCESS_H_
+
+#include "bank.h"
+#include "filesys.h"
+#include "indirect.h"
+
+#warning process function is not supported.
+
+#endif