In serial communication, input \n from standard input is converted to \r and passed
Fix comm_input() in comm.c. (See the e-mail of [WitchFan 00462]) Instead of error termination when displaying text characters outside the screen, Fix WWText_PutCharacter() to proceed with issuing a warning. (Correspondence to one person) Add #define _WONX_ to wonx_include/types.h. (The part you want to depend on WONX For when you want to enclose in source) Version 0.5 beta - from wonx-b05.tar.gz
This commit is contained in:
parent
96b108c909
commit
7630141b26
17
HISTORY
17
HISTORY
@ -1,3 +1,20 @@
|
||||
2000/11/23(木)
|
||||
|
||||
wonx-b05 公開
|
||||
|
||||
シリアル通信で,標準入力からの入力の \n は \r に変換して渡すように
|
||||
comm.c の comm_input() を修正.([WitchFan 00462] のメール参照)
|
||||
|
||||
画面外へのテキスト文字の表示時に,エラー終了するのでなく,
|
||||
ワーニングを出して続行するように WWText_PutCharacter() を修正.
|
||||
(ワンべぇへの対応)
|
||||
|
||||
wonx_include/types.h に #define _WONX_ を追加.(WONX依存にしたい部分を
|
||||
ソース中でくくりたいときのため)
|
||||
|
||||
|
||||
|
||||
|
||||
2000/11/18(ナレ)
|
||||
|
||||
wonx-b04 ク<>ォ
|
||||
|
||||
4
Makefile
4
Makefile
@ -2,8 +2,8 @@ XINCLUDEDIR = /usr/X11R6/include
|
||||
INCLUDEDIR = .
|
||||
XLIBDIR = /usr/X11R6/lib
|
||||
|
||||
VERSION = Wonx-b04
|
||||
PKGNAME = wonx-b04
|
||||
VERSION = Wonx-b05
|
||||
PKGNAME = wonx-b05
|
||||
|
||||
SMAC = smac-b02
|
||||
|
||||
|
||||
114
README
114
README
@ -329,6 +329,7 @@ wonx
|
||||
関数を呼び出しても,何も起こりません.(空の関数になっている)
|
||||
|
||||
・サウンド
|
||||
・カーソル表示
|
||||
・その他いっぱい
|
||||
|
||||
■ 注意しなければならないこと
|
||||
@ -340,8 +341,8 @@ UNIX
|
||||
ならないことがいくつかあります.これらは Wonx の性質上,仕方の無いことです.
|
||||
|
||||
以下のことは,意識することと,きれいなプログラムを書くことで,
|
||||
かなり回避できると思います.(short int にすべきところでは,省略せずに
|
||||
ちゃんと short int と明示するとか)
|
||||
かなり回避できると思います.(ビットマップ操作などで,short int にすべき
|
||||
ところでは,省略せずにちゃんと short int と明示するとか)
|
||||
|
||||
まあ,Wonx の目的は論理的なバグを早い段階で無くすことにあるので,このへんは
|
||||
そういうものだと割り切って使ってください.
|
||||
@ -406,6 +407,115 @@ WonderWitch
|
||||
反応しないからといってなんども押すのでなく,1回を長く確実に押すように
|
||||
してください.
|
||||
|
||||
[MS-DOS 形式ファイルの扱い]
|
||||
|
||||
MS-DOS 形式ファイルは,行末の改行コードが UNIX のテキストファイルと
|
||||
異なるので,注意してください.*.[ch] ファイルの場合は問題無いのですが,
|
||||
makefile は注意してください.
|
||||
(UNIX のテキストファイルでは,改行は \n ですが,MS-DOS では \r\n です)
|
||||
例えば,makefile 中に,
|
||||
|
||||
gcc -g -o smac $(OBJS) -L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
|
||||
|
||||
のような行があったとして,これが MS-DOS のテキスト形式のファイルだと,
|
||||
-lXt のあとに余分な改行コード(\r)が付加されてしまうため,UNIX 上で make
|
||||
しても,「-lXt に相当するライブラリが無い」と怒られてしまいます.
|
||||
(しかも,ファイルを emacs や less などで参照しても,改行コードは表示されない
|
||||
ため,原因がわかりにくい)
|
||||
また,
|
||||
|
||||
gcc -g -o smac $(OBJS) -lwonx -lX11 -lXt -L. -L/usr/X11R6/lib
|
||||
|
||||
のようにしていると,/usr/X11R6/lib を指定したつもりなのに,実際には
|
||||
/usr/X11R6/lib\r というディレクトリが指定されたことになってしまい,
|
||||
-lX11, -lXt の検索に失敗します.
|
||||
|
||||
漢字コードに関しても,同じことがいえます.UNIX での漢字コードは EUC なので,
|
||||
ソースコード中に SJIS の漢字が入っていると,うまくコンパイルできなかったり,
|
||||
make がうまく動作しなかったり,コンパイルできてもプログラム自体が
|
||||
誤動作してしまい,しかも原因に気づきにくくなってしまう可能性があります.
|
||||
makefile やソースコードは必ず,
|
||||
> cat makefile | qkc -I -O -e -u > makefile.tmp
|
||||
> mv makefile.tmp makefile
|
||||
などを通して,UNIXのテキストファイルに変換しましょう.
|
||||
|
||||
[ファイル名の問題]
|
||||
|
||||
MS-DOS ではファイル名はすべて大文字ですが,gcc では *.C のような
|
||||
ファイル名のファイルは C++ で書かれていると判断されるため,
|
||||
SAMPLE.C のような名前のファイルをコンパイルすると,うまくリンクできない
|
||||
ことがあります.
|
||||
このような場合は,sample.c にリネームしてコンパイルしてください.
|
||||
|
||||
[シリアル通信について]
|
||||
|
||||
シリアル通信の受信用関数(comm_receive_char()等)は,fgetc(stdin) から
|
||||
入力文字を取得して,\n は \r に変換して返します.これは,一般的な通信回線上の
|
||||
端末をエミュレートするためです.
|
||||
|
||||
また,comm_send_char() に渡した文字は,標準出力に出力されますが,
|
||||
タブや改行コードは,"\t" "\n" のような文字列に変換されて出力されます.
|
||||
添付の sout2str.pl を通すことにより,シリアル通信への出力のみ抽出して,
|
||||
端末への出力のイメージで表示させることができます.
|
||||
|
||||
[ソース中の WONX 依存部分のくくりかた]
|
||||
|
||||
WonderWitch 用のプログラムを開発していく際に,WONX の場合のみ組み込みたくて,
|
||||
WonderSwan 上で実行するときには取り除きたいコードがあったとします.
|
||||
(例えば,デバッグ情報の出力のために printf() を入れる場合など)
|
||||
このようなときのために,wonx_include/types.h で
|
||||
#define _WONX_
|
||||
してあるので,そのような場所は #ifdef _WONX_ でくくってください.
|
||||
|
||||
[ダンプデータの取りかた]
|
||||
|
||||
ソース中に,
|
||||
|
||||
#include "Wonx.h"
|
||||
#include "WonxDisplay.h"
|
||||
#include "WWDisplay.h"
|
||||
#include "WWColorMap.h"
|
||||
#include "WWPalette.h"
|
||||
#include "WWCharacter.h"
|
||||
#include "WWSprite.h"
|
||||
|
||||
int i;
|
||||
WWDisplay ww_display;
|
||||
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
WWPalette_PrintData(WWDisplay_GetPalette(ww_display, i), stdout);
|
||||
|
||||
for (i = 0; i < 512; i++)
|
||||
WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i), stdout);
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout);
|
||||
|
||||
のようなコードを挿入することにより,任意の場所でキャラクタやパレットの
|
||||
ダンプデータを出力させることができます.
|
||||
|
||||
プログラム中に,不安な場所があったら,
|
||||
|
||||
#ifdef _WONX_
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
printf("Before setting:\n");
|
||||
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, 0), stdout);
|
||||
#endif
|
||||
|
||||
/* ここにスプライトの設定についての不安なコードがある */
|
||||
|
||||
#ifdef _WONX_
|
||||
printf("After setting:\n");
|
||||
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, 0), stdout);
|
||||
#endif
|
||||
|
||||
のようにして不安なコードの前後でダンプデータを取ると,デバッグに
|
||||
役立つでしょう.
|
||||
|
||||
■ 作者
|
||||
|
||||
Wonx は,坂井弘亮がその大部分を往復3時間の通勤電車の中で Libretto で書いた,
|
||||
|
||||
14
WWText.c
14
WWText.c
@ -73,8 +73,11 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
|
||||
{
|
||||
WWCharacter ww_character;
|
||||
|
||||
if ((character < 0) || (character > 127))
|
||||
Wonx_Error("WWText_PutCharacter", "Character number is out of range.");
|
||||
if ((character < 0) || (character > 127)) {
|
||||
printf("warning : WWText_PutCharacter() : Character number is out of range.\n");
|
||||
fflush(stdout);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* テキスト表示は,text_window_init() で指定したテキストウインドウの
|
||||
@ -82,8 +85,11 @@ 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_Error("WWText_PutCharacter", "Position is out of range.");
|
||||
(y < 0) || (y > WWText_GetHeight(ww_text) - 1) ) {
|
||||
printf("warning : WWText_PutCharacter() : Position is out of range.\n");
|
||||
fflush(stdout);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
n = WWText_GetBase(ww_text) +
|
||||
|
||||
1
comm.c
1
comm.c
@ -144,6 +144,7 @@ static int comm_input(int timeout)
|
||||
select(fileno(stdin) + 1, &bitmap, NULL, NULL, t_p);
|
||||
|
||||
c = FD_ISSET(fileno(stdin), &bitmap) ? fgetc(stdin) : -1;
|
||||
c = (c == '\n') ? '\r' : c;
|
||||
|
||||
return (c);
|
||||
}
|
||||
|
||||
@ -5,6 +5,10 @@
|
||||
|
||||
#include <stdlib.h> /* for NULL definition */
|
||||
|
||||
#ifndef _WONX_
|
||||
#define _WONX_
|
||||
#endif
|
||||
|
||||
#ifdef TYPEDEF_USHORT
|
||||
typedef unsigned short int ushort;
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user