Browse Source

Fixed the display range of screen2_set_window ().
In the explanation of screen 2 _ set _ window () of the manual, "width and height of the display area"
Although it is written, in fact it operates with "horizontal width of display area + 1 and vertical width + 1"
want to see? (Unconfirmed), do not you have to do -1?
Or, in actual operation in WonderWitch,
ex = sx + WWScreen_GetDrawWidth (screen);
Not
ex = WWScreen_GetDrawWidth (screen);
It may be.

Implemented sprite enable / disable.

LCD color map, palette, character, sprite data dump function implemented.

Improve display message when calling function.

Version 0.0.3 alpha - from wonx-a03.tar.gz

Hiroaki Sakai 23 years ago
parent
commit
9c414a9117
20 changed files with 348 additions and 93 deletions
  1. 21 0
      HISTORY
  2. 2 2
      Makefile
  3. 41 2
      README
  4. 24 2
      WWCharacter.c
  5. 2 0
      WWCharacter.h
  6. 16 0
      WWColorMap.c
  7. 2 0
      WWColorMap.h
  8. 21 10
      WWDisplay.c
  9. 22 0
      WWPalette.c
  10. 2 0
      WWPalette.h
  11. 29 0
      WWSprite.c
  12. 1 0
      WWSprite.h
  13. 27 0
      WonxDisplay.c
  14. 30 12
      XDisplay.c
  15. 10 0
      XDisplay.h
  16. 6 0
      XDisplayP.h
  17. 63 54
      disp.c
  18. 12 0
      etc.c
  19. 6 0
      etc.h
  20. 11 11
      key.c

+ 21 - 0
HISTORY

@@ -1,3 +1,24 @@
+2000/9/28(木)
+
+screen2_set_window()の表示範囲を修正.
+マニュアルの screen2_set_window() の説明には「表示領域の横幅と縦幅」と
+書いてあるが,実際には「表示領域の横幅+1と縦幅+1」で動作する
+みたい?(未確認)なので,-1 しなくてよい?
+もしくは,WonderWitch での実際の動作は,
+ex = sx + WWScreen_GetDrawWidth( screen);
+でなく
+ex = WWScreen_GetDrawWidth( screen);
+なのかもしれない.
+
+スプライトの有効/無効を実装した.
+
+LCDカラーマップ,パレット,キャラクター,スプライトのデータダンプ機能を実装.
+
+関数呼び出し時の表示メッセージを改良.
+
+
+
+
 2000/9/27(水)
 
 Wonx-a02 公開

+ 2 - 2
Makefile

@@ -2,8 +2,8 @@ XINCLUDEDIR = /usr/X11R6/include
 INCLUDEDIR = .
 XLIBDIR = /usr/X11R6/lib
 
-VERSION = Wonx-a02
-PKGNAME = wonx-a02
+VERSION = Wonx-a03
+PKGNAME = wonx-a03
 
 OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WonxDisplay.o XDisplay.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o etc.o wonx.o
 

+ 41 - 2
README

@@ -34,7 +34,7 @@ Wonx 
 ・C言語レベルで互換機能を持っているので,WonderWitch 用のプログラムを
   UNIX上でそのままコンパイルできる.(-lwonx でコンパイルする)
 ・UNIX上でデバッガを使用してデバッグできるようになる.(強力!)
-・キャラクタデータやパレットデータのダンプ機能をつける予定
+・キャラクタデータやパレットデータのダンプ機能がある
 ・不正な引数の値や,パレットやキャラクタを初期化しないで使用するなどを
   厳しくチェックし,エラーを出力する(ようにする).厳しくエラーチェックする.
 ・使用できない機能(関数は用意してあるが,まだ実装してなかったり,
@@ -206,9 +206,48 @@ smac 
 ・sキーが,STARTボタンに対応している.
 ・p を押すと,表示/非表示モードを切替える.
   (非表示だと画面への描画を行わないが高速)
+・F1 を押すと,LCDカラーマップのデータをダンプ出力する.
+・F2 を押すと,パレットのデータをダンプ出力する.
+・F3 を押すと,キャラクターのデータをダンプ出力する.
+・F4 を押すと,スプライトのデータをダンプ出力する.
 
 標準ではなにか関数が呼ばれるたびに画面の再描画を行うため,非常に低速です.
-このような場合は,非表示モードにしてください.
+たとえば,以下のようなことをやっていると,非常に低速になります.
+
+for (y = 0; y < 32; y++)
+  for (x = 0; x < 32; x++) {
+    screen_fill_char(0, x, y, 1, 1, 0x0000); /* ここで毎回再描画される */
+  }
+}
+
+このような場合は,p を押して非表示モードにして,ループ処理が終ったら
+再び p を押して表示モードに戻してください.
+
+F1 や F2 を押すと,データをダンプ出力するのですが,標準ではその他にも
+メッセージが大量に出力されているので,ふつうに F1 を押しただけでは,
+あっというまに大量のメッセージに流されてしまうことがあります.
+このようなときは,以下のようにして起動します.たとえばコンパイルして
+smac という実行形式ができているのなら,
+
+> smac | grep -v call
+
+もしもキャラクタ番号10番のキャラクタのデータだけが見たい場合には,
+以下のように実行してから,F3 キーを押せば良いでしょう.
+
+> smac | grep "character\[10\]"
+
+wonx は,メッセージを出力する再に,grep でフィルタリングできるように,
+かならず行の先頭に統一性のある文字列を追加しています.
+たとえば,関数呼び出し時に表示されるメッセージには,先頭に必ず
+"call" という文字列が追加されてます.よって,grep -v call を通せば,
+関数呼び出しのメッセージがごっそり出なくなる,というようになってます.
+
+標準では大量のメッセージが出てくるので,grep をうまく使うようにしてください.
+もしくは,
+
+> smac | grep call > function_call.log
+
+のようにして,ログをとるのも有効でしょう.
 
 ■ 作者
 

+ 24 - 2
WWCharacter.c

@@ -63,8 +63,6 @@ int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap)
   return (0);
 }
 
-#include <stdio.h>
-
 int WWCharacter_GetPixel(WWCharacter character, int x, int y)
 {
   if (character == NULL)
@@ -105,6 +103,30 @@ int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel)
   return (pixel);
 }
 
+int WWCharacter_PrintData(WWCharacter character, FILE * f)
+{
+  int x, y, n;
+
+  n = WWCharacter_GetNumber(character);
+
+  fprintf(f, "\n");
+
+  fprintf(f, "character[%d] :\tnumber = %d\n",
+	  n, WWCharacter_GetNumber(character));
+
+  for (y = 0; y < 8; y++) {
+    fprintf(f, "character[%d] :\tbitmap : ", n);
+    for (x = 0; x < 8; x++) {
+      fprintf(f, "%d", WWCharacter_GetPixel(character, x, y));
+    }
+    fprintf(f, "\n");
+  }
+
+  fflush(f);
+
+  return (0);
+}
+
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */
 /*****************************************************************************/

+ 2 - 0
WWCharacter.h

@@ -5,6 +5,7 @@
 /* ¤³¤³¤«¤é                                                                  */
 /*****************************************************************************/
 
+#include <stdio.h>
 #include <stdlib.h>
 
 /*****************************************************************************/
@@ -24,6 +25,7 @@ WWCharacter WWCharacter_Destroy(WWCharacter character);
 int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap);
 int WWCharacter_GetPixel(WWCharacter character, int x, int y);
 int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel);
+int WWCharacter_PrintData(WWCharacter character, FILE * f);
 
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */

+ 16 - 0
WWColorMap.c

@@ -63,6 +63,22 @@ int WWColorMap_SetLCDColor(WWColorMap color_map, int color, int lcd_color)
   return (color_map->lcd_color[color] = lcd_color);
 }
 
+int WWColorMap_PrintData(WWColorMap c, FILE * f)
+{
+  int i, n;
+
+  fprintf(f, "\n");
+
+  for (i = 0; i < 8; i++) {
+    fprintf(f, "colormap :\tcolor[%d] = %d\n",
+	    i, WWColorMap_GetLCDColor(c, i));
+  }
+
+  fflush(f);
+
+  return (0);
+}
+
 /*****************************************************************************/
 /* ¤ł¤ł¤Ţ¤Ç                                                                  */
 /*****************************************************************************/

+ 2 - 0
WWColorMap.h

@@ -5,6 +5,7 @@
 /* ¤³¤³¤«¤é                                                                  */
 /*****************************************************************************/
 
+#include <stdio.h>
 #include <stdlib.h>
 
 /*****************************************************************************/
@@ -23,6 +24,7 @@ int * WWColorMap_GetLCDColors(WWColorMap color_map, int * lcd_colors);
 int WWColorMap_SetLCDColors(WWColorMap color_map, int * lcd_colors);
 int WWColorMap_GetLCDColor(WWColorMap color_map, int color);
 int WWColorMap_SetLCDColor(WWColorMap color_map, int color, int lcd_color);
+int WWColorMap_PrintData(WWColorMap c, FILE * f);
 
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */

+ 21 - 10
WWDisplay.c

@@ -193,8 +193,25 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
        (WWScreen_GetMode(screen) == WWSCREEN_OUTSIDE_ONLY) ) {
     sx = WWScreen_GetDrawX(screen);
     sy = WWScreen_GetDrawX(screen);
+
+    /*
+     * マニュアルの screen2_set_window() の説明には「表示領域の横幅と縦幅」と
+     * 書いてあるが,実際には「表示領域の横幅+1と縦幅+1」で動作する
+     * みたい?(未確認)なので,-1 しなくてよい?
+     * もしくは,WonderWitch での実際の動作は,
+     * ex = sx + WWScreen_GetDrawWidth( screen);
+     * でなく
+     * ex = WWScreen_GetDrawWidth( screen);
+     * なのかもしれない.
+     */
+
+#if 0
     ex = sx + WWScreen_GetDrawWidth( screen) - 1;
     ey = sy + WWScreen_GetDrawHeight(screen) - 1;
+#else
+    ex = sx + WWScreen_GetDrawWidth( screen);
+    ey = sy + WWScreen_GetDrawHeight(screen);
+#endif
   }
 
   mode = WWScreen_GetMode(screen);
@@ -283,7 +300,8 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
   }
 
   /* スクリーン1描画 */
-  WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 0));
+  if (WWDisplay_GetSpriteEnable(display))
+    WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 0));
 
   /* スプライト描画(スクリーン2より優先でないもの) */
   for (i = 0; i < WWDisplay_GetSpriteCount(display); i++) {
@@ -295,7 +313,8 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
   }
 
   /* スクリーン2描画 */
-  WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 1));
+  if (WWDisplay_GetSpriteEnable(display))
+    WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 1));
 
   /* スプライト描画(スクリーン2より優先なもの) */
   for (i = 0; i < WWDisplay_GetSpriteCount(display); i++) {
@@ -306,14 +325,6 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
     }
   }
 
-  /*
-  for (x = 0; x < lcd_panel_width; x++) {
-    for (y = 0; y < lcd_panel_height; y++) {
-      printf("%d", WWLCDPanel_GetPixel(lcd_panel, x, y));
-    }
-  }
-*/
-
   return (0);
 }
 

+ 22 - 0
WWPalette.c

@@ -79,6 +79,28 @@ int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color)
   return (palette->mapped_color[color] = mapped_color);
 }
 
+int WWPalette_PrintData(WWPalette p, FILE * f)
+{
+  int i, n;
+
+  n = WWPalette_GetNumber(p);
+
+  fprintf(f, "\n");
+
+  fprintf(f, "palette[%d] :\tnumber = %d\n", n, WWPalette_GetNumber(p));
+  fprintf(f, "palette[%d] :\ttransparent = %s\n",
+	  n, true_false(WWPalette_GetTransparent(p)));
+
+  for (i = 0; i < 4; i++) {
+    fprintf(f, "palette[%d] :\tcolor[%d] = %d\n",
+	    n, i, WWPalette_GetMappedColor(p, i));
+  }
+
+  fflush(f);
+
+  return (0);
+}
+
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */
 /*****************************************************************************/

+ 2 - 0
WWPalette.h

@@ -5,6 +5,7 @@
 /* ¤³¤³¤«¤é                                                                  */
 /*****************************************************************************/
 
+#include <stdio.h>
 #include <stdlib.h>
 
 /*****************************************************************************/
@@ -27,6 +28,7 @@ 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);
 
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */

+ 29 - 0
WWSprite.c

@@ -84,6 +84,35 @@ WWSprite WWSprite_Destroy(WWSprite sprite)
   return (NULL);
 }
 
+int WWSprite_PrintData(WWSprite s, FILE * f)
+{
+  int n;
+
+  n = WWSprite_GetNumber(s);
+
+  fprintf(f, "\n");
+
+  fprintf(f, "sprite[%d] :\tnumber     = %d\n", n, WWSprite_GetNumber(s));
+  fprintf(f, "sprite[%d] :\thorizontal = %s\n",
+	  n, true_false(WWSprite_GetHorizontal(s)));
+  fprintf(f, "sprite[%d] :\tvertical   = %s\n",
+	  n, true_false(WWSprite_GetVertical(  s)));
+  fprintf(f, "sprite[%d] :\tpriority   = %s\n",
+	  n, true_false(WWSprite_GetPriority(   s)));
+  fprintf(f, "sprite[%d] :\tclipping   = %s\n",
+	  n, true_false(WWSprite_GetClipping(  s)));
+  fprintf(f, "sprite[%d] :\tpalette number   = %d\n",
+	  n, WWPalette_GetNumber(WWSprite_GetPalette(s)));
+  fprintf(f, "sprite[%d] :\tcharacter number = %d\n",
+	  n, WWCharacter_GetNumber(WWSprite_GetCharacter(s)));
+  fprintf(f, "sprite[%d] :\tx = %d\n", n, WWSprite_GetX(s));
+  fprintf(f, "sprite[%d] :\ty = %d\n", n, WWSprite_GetY(s));
+
+  fflush(f);
+
+  return (0);
+}
+
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */
 /*****************************************************************************/

+ 1 - 0
WWSprite.h

@@ -45,6 +45,7 @@ WWSprite WWSprite_Create(int number, int x, int y,
 			 int priority, int clipping,
 			 WWPalette palette, WWCharacter character);
 WWSprite WWSprite_Destroy(WWSprite sprite);
+int WWSprite_PrintData(WWSprite s, FILE * f);
 
 /*****************************************************************************/
 /* ¤³¤³¤Þ¤Ç                                                                  */

+ 27 - 0
WonxDisplay.c

@@ -46,6 +46,7 @@ WonxDisplay WonxDisplay_Create(int x_width, int x_height,
 
 int WonxDisplay_Flush(WonxDisplay wonx_display)
 {
+  int i;
   XDisplay x_display;
   WWDisplay ww_display;
   WWLCDPanel ww_lcd_panel;
@@ -59,6 +60,32 @@ int WonxDisplay_Flush(WonxDisplay wonx_display)
     XDisplay_DrawLCDWindow(x_display, ww_lcd_panel);
   }
 
+  if (XDisplay_GetColorMapPrint(x_display)) {
+    WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), 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);
+    }
+    XDisplay_SetPalettePrint(x_display, 0);
+  }
+
+  if (XDisplay_GetCharacterPrint(x_display)) {
+    for (i = 0; i < 512; i++) {
+      WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i), stdout);
+    }
+    XDisplay_SetCharacterPrint(x_display, 0);
+  }
+
+  if (XDisplay_GetSpritePrint(x_display)) {
+    for (i = 0; i < 128; i++) {
+      WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout);
+    }
+    XDisplay_SetSpritePrint(x_display, 0);
+  }
+
   return (0);
 }
 

+ 30 - 12
XDisplay.c

@@ -10,10 +10,22 @@
 /* メンバ関数の定義                                                          */
 /*****************************************************************************/
 
-unsigned int XDisplay_GetKeyPress(XDisplay x_display)
-{ return (x_display->key_press); }
-int XDisplay_GetLCDDraw(XDisplay x_display)
-{ return (x_display->lcd_draw); }
+unsigned int XDisplay_GetKeyPress(XDisplay d) { return (d->key_press); }
+int XDisplay_GetLCDDraw(XDisplay d) { return (d->lcd_draw); }
+
+int XDisplay_GetColorMapPrint(XDisplay d) {return (d->color_map_print); }
+int XDisplay_GetPalettePrint(XDisplay d) {return (d->palette_print); }
+int XDisplay_GetCharacterPrint(XDisplay d) {return (d->character_print); }
+int XDisplay_GetSpritePrint(XDisplay d) {return (d->sprite_print); }
+
+int XDisplay_SetColorMapPrint(XDisplay d, int f)
+{ return (d->color_map_print = f); }
+int XDisplay_SetPalettePrint(XDisplay d, int f)
+{ return (d->palette_print = f); }
+int XDisplay_SetCharacterPrint(XDisplay d, int f)
+{ return(d->character_print = f); }
+int XDisplay_SetSpritePrint(XDisplay d, int f)
+{ return (d->sprite_print = f); }
 
 /*****************************************************************************/
 /* 内部で使用する関数などの定義                                              */
@@ -113,17 +125,23 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event,
     case XK_s       : press = KEY_START;  break;
     case XK_space   : press = KEY_A;      break;
     case XK_Shift_L : press = KEY_B;      break;
+    default         : press = 0;          break;
+    }
+
+    /* Wonx 操作用 */
+    if (event->type == KeyPress) {
 
-      /* Wonx 操作用 */
+      switch (key_sym) {
 
-      /* 表示モード変更 */
-    case XK_p       :
-      press = 0;
-      if (event->type == KeyPress)
-	x_display->lcd_draw = !(x_display->lcd_draw);
-      break;
+	/* 表示モード変更 */
+      case XK_p       : x_display->lcd_draw = !(x_display->lcd_draw); break;
 
-    default :         press = 0;          break;
+	/* データのダンプ操作 */
+      case XK_F1       : x_display->color_map_print = 1; break;
+      case XK_F2       : x_display->palette_print = 1; break;
+      case XK_F3       : x_display->character_print = 1; break;
+      case XK_F4       : x_display->sprite_print = 1; break;
+      }
     }
 
     if (press) {

+ 10 - 0
XDisplay.h

@@ -22,6 +22,16 @@ typedef struct _XDisplay * XDisplay;
 unsigned int XDisplay_GetKeyPress(XDisplay x_display);
 int XDisplay_GetLCDDraw(XDisplay x_display);
 
+int XDisplay_GetColorMapPrint(XDisplay d);
+int XDisplay_GetPalettePrint(XDisplay d);
+int XDisplay_GetCharacterPrint(XDisplay d);
+int XDisplay_GetSpritePrint(XDisplay d);
+
+int XDisplay_SetColorMapPrint(XDisplay d, int f);
+int XDisplay_SetPalettePrint(XDisplay d, int f);
+int XDisplay_SetCharacterPrint(XDisplay d, int f);
+int XDisplay_SetSpritePrint(XDisplay d, int f);
+
 /*===========================================================================*/
 /* オブジェクトの生成と消去                                                  */
 /*===========================================================================*/

+ 6 - 0
XDisplayP.h

@@ -49,6 +49,12 @@ typedef struct _XDisplay {
   /* LCD描画のフラグ */
   int lcd_draw;
 
+  /* ダンプ出力のフラグ */
+  int color_map_print;
+  int palette_print;
+  int character_print;
+  int sprite_print;
+
 } _XDisplay;
 
 /*****************************************************************************/

+ 63 - 54
disp.c

@@ -19,7 +19,8 @@ void display_control(unsigned int flags)
 {
   WWDisplay ww_display;
 
-  printf("display_control(): flags = %ud, ", flags); fflush(stdout);
+  printf("call : display_control() : flags = 0x%04x, ", (int)flags);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -56,7 +57,7 @@ unsigned int display_status()
   WWDisplay ww_display;
   unsigned short int ret;
 
-  printf("display_status(): "); fflush(stdout);
+  printf("call : display_status() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -90,7 +91,7 @@ unsigned int display_status()
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ul\n", (unsigned int)ret); fflush(stdout);
+  printf("return value = %u\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -102,8 +103,8 @@ void font_set_monodata(unsigned int number, unsigned int count, void * data)
   int f, b;
   unsigned char * d;
 
-  printf("font_set_monodata(): number = %ud, count = %ud, data = %p, ",
-	 number, count, data); fflush(stdout);
+  printf("call : font_set_monodata() : number = %u, count = %u, data = %p, ",
+	 (int)number, (int)count, data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -139,8 +140,8 @@ void font_set_colordata(unsigned int number,
   int f, b;
   unsigned char * d;
 
-  printf("font_set_colordata(): number = %ud, count = %ud, data = %p, ",
-	 number, count, data); fflush(stdout);
+  printf("call : font_set_colordata() : number = %u, count = %u, data = %p, ",
+	 (int)number, (int)count, data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -179,8 +180,8 @@ void font_get_data(unsigned int number,
   int f, b;
   unsigned char * d;
 
-  printf("font_get_data(): number = %ud, count = %ud, data = %p, ",
-	 number, count, data); fflush(stdout);
+  printf("call : font_get_data() : number = %u, count = %u, data = %p, ",
+	 (int)number, (int)count, data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -215,7 +216,8 @@ void font_set_color(unsigned int colors)
 {
   WWDisplay dis;
 
-  printf("font_set_color(): colors = %ud, ", colors); fflush(stdout);
+  printf("call : font_set_color() : colors = 0x%04x, ", (int)colors);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -235,7 +237,7 @@ unsigned int font_get_color(void)
   unsigned short int ret;
   WWDisplay dis;
 
-  printf("font_get_color(): "); fflush(stdout);
+  printf("call : font_get_color() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -246,7 +248,7 @@ unsigned int font_get_color(void)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ud\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -263,7 +265,7 @@ void screen_set_char(int screen, int x, int y, int w, int h, void * data)
   WWPalette p;
   WWCharacter c;
 
-  printf("font_set_char(): screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p",
+  printf("call : screen_set_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p",
 	 screen, x, y, w, h, data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
@@ -309,7 +311,7 @@ void screen_get_char(int screen, int x, int y, int w, int h, void * data)
   WWPalette p;
   WWCharacter c;
 
-  printf("font_get_char(): screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p",
+  printf("call : screen_get_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = %p",
 	 screen, x, y, w, h, data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
@@ -346,8 +348,9 @@ unsigned int screen_get_char1(int screen, int x, int y)
 {
   unsigned short int ret;
 
-  printf("screen_get_char1(): screen = %d, x = %d, y = %d, ",
-	 screen, x, y); fflush(stdout);
+  printf("call : screen_get_char1() : screen = %d, x = %d, y = %d, ",
+	 screen, x, y);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -355,7 +358,7 @@ unsigned int screen_get_char1(int screen, int x, int y)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ud\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -372,8 +375,8 @@ void screen_fill_char(int screen, int x, int y, int w, int h,
   WWPalette p;
   WWCharacter c;
 
-  printf("screen_fill_char(): screen = %d, x = %d, y = %d, w = %d, h = %d, data = %ud",
-	 screen, x, y, w, h, data); fflush(stdout);
+  printf("call : screen_fill_char() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x, ",
+	 screen, x, y, w, h, (int)data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -411,8 +414,8 @@ void screen_fill_attr(int screen, int x, int y, int w, int h,
   int i, j;
   unsigned short int c;
 
-  printf("screen_fill_attr(): screen = %d, x = %d, y = %d, w = %d, h = %d, data = %ud, mask = %ud, ",
-	 screen, x, y, w, h, data, mask); fflush(stdout);
+  printf("call : screen_fill_attr() : screen = %d, x = %d, y = %d, w = %d, h = %d, data = 0x%04x, mask = 0x%04x, ",
+	 screen, x, y, w, h, (int)data, (int)mask); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -434,8 +437,8 @@ void screen_fill_attr(int screen, int x, int y, int w, int h,
 
 void sprite_set_range(unsigned int sprite_start, unsigned int sprite_count)
 {
-  printf("sprite_set_range(): start = %ud, count = %ud, ",
-	 sprite_start, sprite_count); fflush(stdout);
+  printf("call : sprite_set_range() : start = %u, count = %u, ",
+	 (int)sprite_start, (int)sprite_count); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -458,8 +461,8 @@ void sprite_set_char(unsigned int sprite_num,
   WWPalette p;
   WWCharacter c;
 
-  printf("sprite_set_char(): number = %ud, data = %ud, ",
-	 sprite_num, data); fflush(stdout);
+  printf("call : sprite_set_char() : number = %u, data = 0x%04x, ",
+	 (int)sprite_num, (int)data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -472,7 +475,8 @@ void sprite_set_char(unsigned int sprite_num,
 
   p = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
 			   (data >> 9) & 0x07);
-  c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display), data & 0x1ff);
+  c = WWDisplay_GetCharacter(WonxDisplay_GetWWDisplay(wonx_display),
+			     data & 0x1ff);
 
   WWSprite_SetPalette(s, p);
   WWSprite_SetCharacter(s, c);
@@ -491,7 +495,8 @@ unsigned int sprite_get_char(unsigned int sprite_num)
   WWCharacter c;
   unsigned short int ret;
 
-  printf("sprite_get_char(): number = %ud, ", sprite_num); fflush(stdout);
+  printf("call : sprite_get_char() : number = %u, ", (int)sprite_num);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -513,7 +518,7 @@ unsigned int sprite_get_char(unsigned int sprite_num)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ud\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -522,8 +527,8 @@ void sprite_set_location(unsigned int sprite_num, int x, int y)
 {
   WWSprite s;
 
-  printf("sprite_set_location(): number = %ud, x = %d, y = %d, ",
-	 sprite_num, x, y); fflush(stdout);
+  printf("call : sprite_set_location() : number = %u, x = %d, y = %d, ",
+	 (int)sprite_num, x, y); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -542,7 +547,8 @@ unsigned int sprite_get_location(unsigned int sprite_num)
   WWSprite s;
   unsigned short int ret;
 
-  printf("sprite_get_location(): number = %ud, ", sprite_num); fflush(stdout);
+  printf("call : sprite_get_location() : number = %u, ", (int)sprite_num);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -555,7 +561,7 @@ unsigned int sprite_get_location(unsigned int sprite_num)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ud\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -565,8 +571,8 @@ void sprite_set_char_location(unsigned int sprite_num,
 {
   if (wonx_display == NULL) Wonx_Create();
 
-  printf("sprite_set_char_location(): number = %ud, data = %ud, x = %d, y = %d, ",
-	 sprite_num, data, x, y); fflush(stdout);
+  printf("call : sprite_set_char_location() : number = %u, data = 0x%04x, x = %d, y = %d, ",
+	 (int)sprite_num, (int)data, x, y); fflush(stdout);
 
   sprite_set_char(sprite_num, data);
   sprite_set_location(sprite_num, x, y);
@@ -582,8 +588,8 @@ unsigned long int sprite_get_char_location(unsigned int sprite_num)
 {
   unsigned long int ret;
 
-  printf("sprite_get_char_location(): number = %ud, ",
-	 sprite_num); fflush(stdout);
+  printf("call : sprite_get_char_location() : number = %u, ", (int)sprite_num);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -594,19 +600,19 @@ unsigned long int sprite_get_char_location(unsigned int sprite_num)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ul\n", ret); fflush(stdout);
+  printf("return value = 0x%08x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
 
-void sprite_set_data(unsigned sprite_num, unsigned int count, void * data)
+void sprite_set_data(unsigned int sprite_num, unsigned int count, void * data)
 {
   int i;
   char * d;
   unsigned long int * n;
 
-  printf("sprite_set_data(): number = %ud, count = %ud, data = %p",
-	 sprite_num, count, data); fflush(stdout);
+  printf("call : sprite_set_data() : number = %u, count = %u, data = %p",
+	 (int)sprite_num, (int)count, data); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -629,7 +635,7 @@ void screen_set_scroll(int screen, int x, int y)
 {
   WWScreen s;
 
-  printf("screen_set_scroll(): scsreen = %d, x = %d, y = %d, ",
+  printf("call : screen_set_scroll() : scsreen = %d, x = %d, y = %d, ",
 	 screen, x, y); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
@@ -650,7 +656,7 @@ unsigned int screen_get_scroll(int screen)
   unsigned short int ret;
   WWScreen s;
 
-  printf("screen_get_scroll(): scsreen = %d, ", screen); fflush(stdout);
+  printf("call : screen_get_scroll() : screen = %d, ", screen); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -662,7 +668,7 @@ unsigned int screen_get_scroll(int screen)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ud\n", ret); fflush(stdout);
+  printf("return value = %u\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -671,7 +677,7 @@ void screen2_set_window(int x, int y, int w, int h)
 {
   WWScreen s;
 
-  printf("screen2_set_window(): x = %d, y = %d, width = %d, height = %d, ",
+  printf("call : screen2_set_window() : x = %d, y = %d, width = %d, height = %d, ",
 	 x, y, w, h); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
@@ -698,7 +704,7 @@ unsigned long int screen2_get_window(void)
 
   if (wonx_display == NULL) Wonx_Create();
 
-  printf("screen2_get_window(): "); fflush(stdout);
+  printf("call : screen2_get_window() : "); fflush(stdout);
 
   s = WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx_display), SCREEN2);
   
@@ -712,7 +718,7 @@ unsigned long int screen2_get_window(void)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ul\n", ret); fflush(stdout);
+  printf("return value = 0x%08x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -739,8 +745,8 @@ void palette_set_color(unsigned int palette_num,
   int mapped_colors[4];
   WWPalette palette;
 
-  printf("palette_set_color(): number = %ud, colors = %ud", palette_num,
-	 colors); fflush(stdout);
+  printf("call : palette_set_color() : number = %u, colors = 0x%04x, ",
+	 (int)palette_num, (int)colors); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -766,11 +772,13 @@ unsigned int palette_get_color(unsigned int palette_num)
   WWPalette palette;
   unsigned short int ret;
 
-  printf("palette_get_color(): number = %ud, ", palette_num); fflush(stdout);
+  printf("call : palette_get_color() : number = %u, ", (int)palette_num);
+  fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
-  palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display), palette_num);
+  palette = WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx_display),
+				 palette_num);
   WWPalette_GetMappedColors(palette, mapped_colors);
 
   ret = 0;
@@ -781,7 +789,7 @@ unsigned int palette_get_color(unsigned int palette_num)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ud\n", ret); fflush(stdout);
+  printf("return value = %u\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -791,7 +799,8 @@ void lcd_set_color(unsigned int colors0, unsigned int colors1)
   WWColorMap color_map;
   int lcd_colors[8];
 
-  printf("lcd_set_color(): colors0 = %ud, colors1 = %ud, ", colors0, colors1); fflush(stdout);
+  printf("call : lcd_set_color() : colors0 = 0x%04x, colors1 = 0x%04x, ",
+	 (int)colors0, (int)colors1); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -820,7 +829,7 @@ unsigned long int lcd_get_color(void)
   int lcd_colors[8];
   unsigned long int ret;
 
-  printf("lcd_get_color(): "); fflush(stdout);
+  printf("call : lcd_get_color() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -839,7 +848,7 @@ unsigned long int lcd_get_color(void)
 
   WonxDisplay_Flush(wonx_display);
 
-  printf("return value = %ul\n", ret); fflush(stdout);
+  printf("return value = 0x%08x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }

+ 12 - 0
etc.c

@@ -12,3 +12,15 @@ int Error(char * funcname, char * message)
   fprintf(stderr, "%s(): %s\n", funcname, message);
   exit (1);
 }
+
+/*===========================================================================*/
+/* "true", "false" ¤Îʸ»úÎó¤òÊÖ¤¹                                            */
+/*===========================================================================*/
+
+char * true_false(int b)
+{
+  char * s[] = {"false", "true"};
+  b = b ? 1 : 0;
+  return (s[b]);
+}
+

+ 6 - 0
etc.h

@@ -7,5 +7,11 @@
 
 int Error(char * funcname, char * message);
 
+/*===========================================================================*/
+/* "true", "false" ¤Îʸ»úÎó¤òÊÖ¤¹                                            */
+/*===========================================================================*/
+
+char * true_false(int b);
+
 #endif
 

+ 11 - 11
key.c

@@ -12,7 +12,7 @@ int key_press_check(void)
   XDisplay x_display;
   int ret;
 
-  printf("key_press_check(): "); fflush(stdout);
+  printf("call : key_press_check() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -21,7 +21,7 @@ int key_press_check(void)
 
   ret = XDisplay_GetKeyPress(x_display);
 
-  printf("return value = %d\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -31,7 +31,7 @@ int key_hit_check(void)
   XDisplay x_display;
   int ret;
 
-  printf("key_hit_check(): "); fflush(stdout);
+  printf("call : key_hit_check() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -40,7 +40,7 @@ int key_hit_check(void)
 
   ret = XDisplay_GetKeyPress(x_display);
 
-  printf("return value = %d\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -50,7 +50,7 @@ int key_wait(void)
   XDisplay x_display;
   int ret;
 
-  printf("key_wait(): "); fflush(stdout);
+  printf("call : key_wait() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -62,14 +62,14 @@ int key_wait(void)
     ret = XDisplay_GetKeyPress(x_display);
   } while (ret == 0);
 
-  printf("return value = %d\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
 
 void key_set_repeat(int rate, int delay)
 {
-  printf("key_set_repeat(): rate = %d, delay = %d, ", rate, delay);
+  printf("call : key_set_repeat() : rate = %d, delay = %d, ", rate, delay);
   fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
@@ -81,13 +81,13 @@ int key_get_repeat(void)
 {
   int ret;
 
-  printf("key_get_repeat(): "); fflush(stdout);
+  printf("call : key_get_repeat() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
   ret = 0;
 
-  printf("return value = %d\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }
@@ -97,7 +97,7 @@ int key_hit_check_with_repeat(void)
   XDisplay x_display;
   int ret;
 
-  printf("key_hit_check_with_repeat(): "); fflush(stdout);
+  printf("call : key_hit_check_with_repeat() : "); fflush(stdout);
 
   if (wonx_display == NULL) Wonx_Create();
 
@@ -106,7 +106,7 @@ int key_hit_check_with_repeat(void)
 
   ret = XDisplay_GetKeyPress(x_display);
 
-  printf("return value = %d\n", ret); fflush(stdout);
+  printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
 
   return (ret);
 }