We implemented mmap (). Specifically, see README.

Added service function.  (A service function dumping information for debugging,
Added service function for screen drawing ON / OFF control) Specifically, see README.

Make the object's destructor called from bios_exit ()
Add appropriate Destroy function to each object.  Delete objects properly
We have checked the termination process as a whole, as done.

Fix to accept interrupts even during key_wait ().
(Previously, only key input was accepted)

Some timer interrupts are improved.  (UNIXTimer.c)

Change the wonx_include directory to wonx.

Changed to search the full path to perl automatically and insert it at the beginning of perl script.

Makefile review, improvement.

Changed ON / OFF of screen drawing to switch according to display level.
(See README for details.)
Also change to display level lowered by F9 and display level raised by F10.
In accordance with that, we have reviewed a part of ON / OFF part of drawing and key input event processing.

Fixed to display message when pressing key.

Obj ObjListData_GetPrev (ObjListData data)
Obj ObjListData_GetNext (ObjListData data)
To
ObjListData ObjListData_GetPrev (ObjListData data)
ObjListData ObjListData_GetNext (ObjListData data)
Fixed to.

Added install, uninstall target to Makefile.  Fixed challsrc.sh.

Version 2.2 - from wonx-2.2.tar.gz
This commit is contained in:
Hiroaki Sakai 2001-02-04 12:00:00 +09:00 committed by Godzil
parent d1cde9116a
commit 103ffe29f1
74 changed files with 2408 additions and 264 deletions

View File

@ -1,7 +1,7 @@
/*****************************************************************************/ /*****************************************************************************/
/* WonX - WonderWitch on X. */ /* WonX - WonderWitch on X. */
/* */ /* */
/* WonX Copyright (c) 2000-2001 Sakai Hiroaki. */ /* WonX Copyright (c) 2000-2002 Sakai Hiroaki. */
/* All Rights Reserved. */ /* All Rights Reserved. */
/*===========================================================================*/ /*===========================================================================*/
/* This program is free software; you can redistribute it and/or modify */ /* This program is free software; you can redistribute it and/or modify */
@ -37,10 +37,14 @@
/* あるものとします. */ /* あるものとします. */
/*===========================================================================*/ /*===========================================================================*/
/* 坂井弘亮の連絡先のメールアドレスは, */ /* 坂井弘亮の連絡先のメールアドレスは, */
/* sakai@seki.ee.kagu.sut.ac.jp */ /* hsakai@m8.people.or.jp */
/* hsakai@pfu.co.jp */
/* です.また,本ソフトウエアの最新版を, */ /* です.また,本ソフトウエアの最新版を, */
/* http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html */ /* http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html */
/* で配布しています. */ /* で配布しています. */
/* 以下はミラーサイトです. */
/* http://hp.vector.co.jp/authors/VA014157/index.html */
/* http://www.people.or.jp/~hsakai/index.html */
/* ミラーサイトは,坂井が気が向いたときにアップデートするので,常に最新, */
/* というわけではありません.あくまでバックアップ用です. */
/* ご意見,ご感想がありましたら,ぜひ連絡ください. */ /* ご意見,ご感想がありましたら,ぜひ連絡ください. */
/*****************************************************************************/ /*****************************************************************************/

43
HISTORY
View File

@ -1,3 +1,46 @@
2002/2/4(月)
wonx-2.2 公開
mmap() を実装した.具体的には README 参照.
サービス関数を追加.(デバッグ用の情報をダンプするサービス関数と,
画面描画ON/OFF制御用のサービス関数を追加) 具体的には README 参照.
bios_exit() からオブジェクトのデストラクタが呼ばれるようにして,
各オブジェクトに適切な Destroy 関数を追加.オブジェクトの削除が適切に
行われるように,終了処理を全般的にチェックした.
key_wait() 中にも割り込みを受け付けるように修正.
(以前はキー入力しか受け付けていなかった)
タイマ割り込みを一部改良.(UNIXTimer.c)
wonx_include ディレクトリを wonx に名前を変更.
perl へのフルパスを自動で検索して perl スクリプトの先頭に挿入するように変更.
Makefile 見直し,改良.
画面描画の ON/OFF を,表示レベルによって切替えるように変更.
(詳しくは README 参照)
またF9 で表示レベルを下げF10 で表示レベルを上げるように変更.
それにあわせて描画のON/OFF部分とキー入力イベント処理の一部見直しをした
キーの押下時にメッセージを表示するように修正.
Obj ObjListData_GetPrev(ObjListData data)
Obj ObjListData_GetNext(ObjListData data)
ObjListData ObjListData_GetPrev(ObjListData data)
ObjListData ObjListData_GetNext(ObjListData data)
に修正.
Makefile に install, uninstall ターゲットを追加challsrc.sh 修正.
2001/1/13(ナレ) 2001/1/13(ナレ)
wonx-2.1 ク<> wonx-2.1 ク<>

View File

@ -2,29 +2,40 @@ XINCLUDEDIR = /usr/X11R6/include
INCLUDEDIR = . INCLUDEDIR = .
XLIBDIR = /usr/X11R6/lib XLIBDIR = /usr/X11R6/lib
VERSION = WonX-2.1 VERSION = WonX-2.2
PKGNAME = wonx-2.1 PKGNAME = wonx-2.2
SMAC = smac-b02 SMAC = smac-b02
WWTERM = wwterm-b05 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 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 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 fcntl.o etc.o wonx.o
CC = gcc PERLS = filters.pl int2sint.pl sout2str.pl sys2wonx.pl
#PERL = /usr/bin/perl
CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
CFLAGS += -O
#CFLAGS += -g
CFLAGS += -Wall
PREFIX ?= /usr/local
.SUFFIXES: .c .o .SUFFIXES: .c .o
.SUFFIXES: .perl .pl
all : libwonx.a all : libwonx.a $(PERLS)
libwonx.a : $(OBJS) libwonx.a : $(OBJS)
ar ruc libwonx.a $(OBJS) $(AR) ruc libwonx.a $(OBJS)
# ranlib libwonx.a # $(RANLIB) libwonx.a
.c.o : $*.c .c.o : $*.c
$(CC) -c $*.c -O -Wall -I$(INCLUDEDIR) -I$(XINCLUDEDIR) $(CC) -c $*.c $(CFLAGS) -I$(INCLUDEDIR) -I$(XINCLUDEDIR)
clean : clean :
rm -f libwonx.a sample1 sample2 *.o rm -f libwonx.a sample1 sample2 sample3 *.o *.pl
rm -fR $(SMAC) $(WWTERM) rm -fR $(SMAC) $(WWTERM)
sample1 : libwonx.a sample1.o sample1 : libwonx.a sample1.o
@ -35,38 +46,63 @@ sample2 : libwonx.a sample2.o
$(CC) sample2.o -o sample2 \ $(CC) sample2.o -o sample2 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt -L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
smac : libwonx.a sample3 : libwonx.a sample3.o
$(CC) sample3.o -o sample3 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
smac : libwonx.a $(SMAC)
cd $(SMAC) ; $(MAKE)
$(SMAC) : $(SMAC).zip $(PERLS)
unzip $(SMAC).zip unzip $(SMAC).zip
cp -R wonx_include $(SMAC) mkdir -p $(SMAC)/wonx
cp wonx/*.h $(SMAC)/wonx
cp libwonx.a $(SMAC) cp libwonx.a $(SMAC)
mv $(SMAC)/makefile $(SMAC)/makefile.orig mv $(SMAC)/makefile $(SMAC)/makefile.orig
cp makefile_for_smac $(SMAC)/makefile cp makefile_for_smac $(SMAC)/makefile
cp challsrc.sh filters.pl sys2wonx.pl int2sint.pl $(SMAC) cp challsrc.sh $(PERLS) $(SMAC)
# ここで止まったときはfilters.pl, sys2wonx.pl, int2sint.pl の
# 行目に適切なperlを指定してください"
cd $(SMAC) ; ./challsrc.sh *.[ch] makefile cd $(SMAC) ; ./challsrc.sh *.[ch] makefile
cd $(SMAC) ; $(MAKE)
wwterm : libwonx.a wwterm : libwonx.a $(WWTERM)
cd $(WWTERM) ; $(MAKE)
$(WWTERM) : $(WWTERM).zip $(PERLS)
unzip $(WWTERM).zip unzip $(WWTERM).zip
cp -R wonx_include $(WWTERM) mkdir -p $(WWTERM)/wonx
cp wonx/*.h $(WWTERM)/wonx
cp libwonx.a $(WWTERM) cp libwonx.a $(WWTERM)
mv $(WWTERM)/makefile $(WWTERM)/makefile.orig mv $(WWTERM)/makefile $(WWTERM)/makefile.orig
cp makefile_for_wwterm $(WWTERM)/makefile cp makefile_for_wwterm $(WWTERM)/makefile
cp challsrc.sh filters.pl sys2wonx.pl int2sint.pl $(WWTERM) cp challsrc.sh $(PERLS) $(WWTERM)
# ここで止まったときはfilters.pl, sys2wonx.pl, int2sint.pl の
# 行目に適切なperlを指定してください"
cd $(WWTERM) ; ./challsrc.sh *.[ch] makefile cd $(WWTERM) ; ./challsrc.sh *.[ch] makefile
cd $(WWTERM) ; $(MAKE)
.perl.pl : $*.perl
./findperl.sh $(PERL) | cat - $*.perl > $*.pl
chmod +x $*.pl
install : libwonx.a $(PERLS)
mkdir -p $(PREFIX)/include/wonx
cp wonx/*.h $(PREFIX)/include/wonx
cp libwonx.a $(PREFIX)/lib
cp challsrc.sh $(PERLS) $(PREFIX)/bin
uninstall :
rm -fR $(PREFIX)/include/wonx
rm -f $(PREFIX)/lib/libwonx.a
rm -f $(PREFIX)/bin/challsrc.sh
rm -f $(PREFIX)/bin/filters.pl
rm -f $(PREFIX)/bin/int2sint.pl
rm -f $(PREFIX)/bin/sout2str.pl
rm -f $(PREFIX)/bin/sys2wonx.pl
package : package :
mkdir -p $(PKGNAME) mkdir -p $(PKGNAME)
rm -fR $(PKGNAME)/* rm -fR $(PKGNAME)/*
mkdir -p $(PKGNAME)/wonx_include mkdir -p $(PKGNAME)/wonx
cp COPYING COPYRIGHT HISTORY README MANUAL OMAKE.jpn Makefile \ cp COPYING COPYRIGHT HISTORY README MANUAL OMAKE.jpn Makefile \
makefile_for_smac makefile_for_wwterm *.sh *.pl \ makefile_for_smac makefile_for_wwterm *.sh *.perl \
*.h *.c $(SMAC).zip $(WWTERM).zip $(PKGNAME) *.h *.c $(SMAC).zip $(WWTERM).zip $(PKGNAME)
cp wonx_include/*.h $(PKGNAME)/wonx_include cp wonx/*.h $(PKGNAME)/wonx
tar cvzf $(PKGNAME).tar.gz $(PKGNAME) tar cvzf $(PKGNAME).tar.gz $(PKGNAME)
# End of Makefile. # End of Makefile.

982
OMAKE.jpn

File diff suppressed because it is too large Load Diff

4
Obj.c
View File

@ -46,13 +46,13 @@ Obj ObjListData_GetObj(ObjListData data)
return (data->obj); return (data->obj);
} }
Obj ObjListData_GetPrev(ObjListData data) ObjListData ObjListData_GetPrev(ObjListData data)
{ {
if (data == NULL) return (NULL); if (data == NULL) return (NULL);
return (data->prev); return (data->prev);
} }
Obj ObjListData_GetNext(ObjListData data) ObjListData ObjListData_GetNext(ObjListData data)
{ {
if (data == NULL) return (NULL); if (data == NULL) return (NULL);
return (data->next); return (data->next);

4
Obj.h
View File

@ -21,8 +21,8 @@ typedef Obj (*ObjDestructor)(Obj);
/*****************************************************************************/ /*****************************************************************************/
Obj ObjListData_GetObj(ObjListData data); Obj ObjListData_GetObj(ObjListData data);
Obj ObjListData_GetPrev(ObjListData data); ObjListData ObjListData_GetPrev(ObjListData data);
Obj ObjListData_GetNext(ObjListData data); ObjListData ObjListData_GetNext(ObjListData data);
int ObjList_GetLength(ObjList list); int ObjList_GetLength(ObjList list);
ObjListData ObjList_GetStartEdge(ObjList list); ObjListData ObjList_GetStartEdge(ObjList list);
ObjListData ObjList_GetEndEdge(ObjList list); ObjListData ObjList_GetEndEdge(ObjList list);

393
README
View File

@ -5,14 +5,18 @@ WonX - WonderWitch on X.
ご意見,ご要望など歓迎します.どしどしお寄せください. ご意見,ご要望など歓迎します.どしどしお寄せください.
バグ情報やアドバイスがあれば,作者の坂井弘亮まで,どんどんメールください. バグ情報やアドバイスがあれば,作者の坂井弘亮まで,どんどんメールください.
アドレスは, アドレスは,
sakai@seki.ee.kagu.sut.ac.jp hsakai@m8.people.or.jp
hsakai@pfu.co.jp
です. です.
(ただし,返事を書くとは限らないし,要望を反映するとも限りませんので (ただし,返事を書くとは限らないし,要望を反映するとも限りませんので
その点はご容赦ください) その点はご容赦ください)
また,坂井の気が向く限り,アップデートは随時行っていきます. また,坂井の気が向く限り,アップデートは随時行っていきます.
http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html
で,随時公開していきます. で,随時公開していきます.
以下はミラーサイトです.
http://hp.vector.co.jp/authors/VA014157/WonderWitch/index.html
http://www.people.or.jp/~hsakai/WonderWitch/index.html
ミラーサイトは,坂井が気が向いたときにアップデートするので,常に最新,
というわけではありません.あくまでバックアップ用です.
■ はじめに ■ はじめに
@ -48,8 +52,9 @@ WonX
(WonderWitch用ソースコード → WonX用ソースコードの変換用 perl スクリプトを (WonderWitch用ソースコード → WonX用ソースコードの変換用 perl スクリプトを
添付しているのでWonderWitch用ソースコードの中に漢字が入っているのならば 添付しているのでWonderWitch用ソースコードの中に漢字が入っているのならば
日本語 perl が望ましい) 日本語 perl が望ましい)
添付の perl スクリプトは,すべて #!/usr/local/bin/perl になっているので, 添付の perl スクリプトはmake 時に自動で先頭に perl へのフルパス
日本語 perl が別のところにあるばあいには,修正してから使用してください. (#!/usr/bin/perl など)が付加されるので,日本語 perl が別のところにある
ばあいには,修正してから使用してください.
日本語 perl が無ければ,まあ,ふつうの perl でもたぶん大丈夫でしょう. 日本語 perl が無ければ,まあ,ふつうの perl でもたぶん大丈夫でしょう.
・qkc ・qkc
漢字コード変換,改行コード変換に必要. 漢字コード変換,改行コード変換に必要.
@ -104,16 +109,17 @@ WonX
~/wonx/smac>% ./smac ~/wonx/smac>% ./smac
ウインドウが開いて,標準出力にメッセージが出力されます. ウインドウが開いて,標準出力にメッセージが出力されます.
いったん F10 を押して画面描画を OFF にします.しばらくしたら いったん F9 を押して画面描画を OFF にします.(何度も押すと表示レベルが
(メッセージの内容が変わったら) F10 を押して再び画面表示を ON にすると, 下がってしまうので,1回だけ長めに押してください)
smac のタイトル画面が表示されます. しばらくしたら(メッセージの内容が変わったら) F10 を(長めに1回だけ)押して
ここでスペースを押して,さらにまた F10 で画面表示を OFF にして, 再び画面表示を ON にするとsmac のタイトル画面が表示されます.
ここでスペースを押して,さらにまた F9 で画面表示を OFF にして,
しばらくしたら(メッセージの内容が変わったら) F10 で画面表示を ON にします. しばらくしたら(メッセージの内容が変わったら) F10 で画面表示を ON にします.
どうですか? SpeedMac のゲーム画面が表示されているでしょうか? どうですか? SpeedMac のゲーム画面が表示されているでしょうか?
カーソルキーで移動,スペースキーで射撃です. カーソルキーで移動,スペースキーで射撃です.
ただし,キー入力はキー入力用関数が呼ばれたときしか有効ではないので, ただし,キー入力はキー入力用関数が呼ばれたときしか有効ではないので,
キーは反応するまで長めに押してください. キーは反応するまで長めに押してください.
F10 を押して頻繁に描画の ON, OFF を切替えるのは,描画が非常に遅いため, F9, F10 を押して頻繁に描画の ON, OFF を切替えるのは,描画が非常に遅いため,
ONのままだと画面クリアとかに異常に時間がかかるからです ONのままだと画面クリアとかに異常に時間がかかるからです
最後にWonderWitch 用の端末エミュレータ "WWTerm" をコンパイル・実行 最後にWonderWitch 用の端末エミュレータ "WWTerm" をコンパイル・実行
@ -130,7 +136,8 @@ ON
コンパイル・リンクしてX Window System 上で動作するような実行形式を コンパイル・リンクしてX Window System 上で動作するような実行形式を
作ってみましょう. 作ってみましょう.
まずWonX を展開してmake してくださいlibwonx.a ができあがります. まずWonX を展開してmake してくださいlibwonx.a と各種 perl スクリプトが
できあがります.
~>% tar xvzf wonx-x.x.tar.gz ~>% tar xvzf wonx-x.x.tar.gz
(中略) (中略)
@ -141,11 +148,11 @@ ON
libwonx.a libwonx.a
~/wonx>% ~/wonx>%
次にlibwonx.a とwonx_include ディレクトリと, 次にlibwonx.a とwonx ディレクトリと,
challsrc.sh, filters.pl, sys2wonx.pl, int2sint.pl をあなたの作ったプログラムの challsrc.sh, filters.pl, sys2wonx.pl, int2sint.pl をあなたの作ったプログラムの
ディレクトリ(ここでは例としてyoursample とします)にコピーします. ディレクトリ(ここでは例としてyoursample とします)にコピーします.
~/wonx>% cp -R libwonx.a wonx_include ../yoursample ~/wonx>% cp -R libwonx.a wonx ../yoursample
~/wonx>% cp challsrc.sh filters.pl sys2wonx.pl int2sint.pl ../yoursample ~/wonx>% cp challsrc.sh filters.pl sys2wonx.pl int2sint.pl ../yoursample
~/wonx>% cd ../yoursample ~/wonx>% cd ../yoursample
~/yoursample>% ~/yoursample>%
@ -160,8 +167,9 @@ challsrc.sh, filters.pl, sys2wonx.pl, int2sint.pl
(つまり,改行コードを \r\n から \n に変換して,漢字コードを SJIS から (つまり,改行コードを \r\n から \n に変換して,漢字コードを SJIS から
EUC に変換します) EUC に変換します)
・プログラム中の #include <sys/disp.h> のようなのを, ・プログラム中の #include <sys/disp.h> のようなのを,
#include "wonx_include/disp.h" に変更する.(sys2wonx.pl を通す) #include "wonx/disp.h" に変更する.(sys2wonx.pl を通すことで変換してくれる)
・デフォルトの int をshort int に変換する.(int2sint.pl を通す) ・デフォルトの int をshort int に変換する.
(int2sint.pl を通すことで変換してくれる)
これらのフィルタをまとめて通してくれる filters.pl というスクリプトを これらのフィルタをまとめて通してくれる filters.pl というスクリプトを
添付してあるので,以下のようにして,すべてのソースファイルに対して, 添付してあるので,以下のようにして,すべてのソースファイルに対して,
必要なフィルタを通してください. 必要なフィルタを通してください.
@ -172,7 +180,7 @@ challsrc.sh, filters.pl, sys2wonx.pl, int2sint.pl
~/yoursample>% ./challsrc.sh *.[ch] [Mm]akefile* MAKEFILE* ~/yoursample>% ./challsrc.sh *.[ch] [Mm]akefile* MAKEFILE*
(注意! filters.pl や challsrc.sh は,ファイルの本体を書き換えてしまうので, (注意! filters.pl や challsrc.sh は,*ファイルの本体を書き換えてしまう*ので,
変更されると困るようなファイルは必ずバックアップしてください) 変更されると困るようなファイルは必ずバックアップしてください)
makefile を以下のように修正する. makefile を以下のように修正する.
@ -198,8 +206,8 @@ makefile
■ WonX 概要 ■ WonX 概要
WonX はWonderWitch の display_control() とか display_status() といった WonX はWonderWitch の display_control() とか display_status() といった関数
関数(BIOS に対するシステムコール)と代替の関数を持っています. (BIOS に対するシステムコール)と代替の関数を持っています.
これらの関数はX上にウインドウを開いてそこで WonderWitch と互換の動作を これらの関数はX上にウインドウを開いてそこで WonderWitch と互換の動作を
するように書いてあります. するように書いてあります.
@ -211,39 +219,41 @@ WonderWitch
■ ヘッダファイルについて ■ ヘッダファイルについて
WonX はUNIXシステム上にある libc を使用します.つまり,/usr/include の WonX はUNIXシステム上にある libc を使用します.つまり,/usr/include の
下を include します. 下を include します.(このため strlen(), fopen() などの標準ライブラリは
UNIX 付属のものが使用可能)
またWonderWitch にはsys/types.h などといったヘッダファイルがあります. またWonderWitch にはsys/types.h などといったヘッダファイルがあります.
よってWonderWitch のヘッダファイル構成をそのまま WonX に引き継ぐと, よってWonderWitch のヘッダファイル構成をそのまま WonX に引き継ぐと,
WonX のヘッダファイルと UNIX のヘッダファイルがコンフリクトする WonX のヘッダファイルと UNIX のヘッダファイルがコンフリクトする
可能性が出てきます. 可能性が出てきます.
(たとえばWonderWitch の sys/types.h と /usr/include/sys/types が (たとえばWonderWitch の sys/types.h と UNIX の /usr/include/sys/types.h
コンフリクトする,などです) コンフリクトする,などです)
これはWonderWitch用のアプリケーションをコンパイルするときに要注意です これはWonderWitch用のアプリケーションをコンパイルするときに要注意です
コンパイルがうまくとおらないという障害の原因は,ほとんどがこのような, コンパイルがうまくとおらないという障害の原因は,ほとんどがこのような,
「ヘッダファイルのコンフリクトもしくは誤認」に起因しています. 「ヘッダファイルのコンフリクトもしくは誤認」に起因しています.
対策としてWonX では wonx_include というディレクトリの下にヘッダファイルを 対策としてWonX では wonx というディレクトリの下にヘッダファイルを
格納してあります.(本当は sys というディレクトリにしたかったが, 格納してあります.(本当は sys というディレクトリにしたかったが,
上記の対策のため,このようにした) 上記の対策のため,このようにした)
WonderWitch 用プログラム中の, WonderWitch 用プログラム中の,
#include <sys/types.h> #include <sys/types.h>
のような部分は,すべて, のような部分は,すべて,
#include <wonx_include/types.h> #include "wonx/types.h"
のように修正する必要があります. のように修正する必要があります.
(stdio.h や stdlib.h はUNIX システム付属のものを使用するので, (stdio.h や stdlib.h はUNIX システム付属のものを使用するので,
そのままでかまいません) そのままでかまいません)
(ただし,コンフリクトしないという絶対の自信があるなら,この限りではありません) (ただし,コンフリクトしないという絶対の自信があるなら,この限りではありません)
WonderWitch のプログラムの,#include <sys/*.h> は,すべて WonderWitch のプログラムの,#include <sys/*.h> は,すべて
#include <wonx_include/*.h> に修正する必要がある,ということです. #include "wonx/*.h" に修正する必要がある,ということです.
(これをまとめて行うための sys2wonx.pl という perl スクリプトを添付して (これをまとめて行うための sys2wonx.pl という perl スクリプトを添付して
あります../filters.pl ./sys2wonx.pl -f *.[ch] を実行すると,ごっそりと あります../filters.pl ./sys2wonx.pl -f *.[ch] を実行すると,ごっそりと
書き換えてくれます) 書き換えてくれます)
またUNIXシステムによっては/usr/include/sys/types.h で ushort, ulong を またUNIXシステムによっては/usr/include/sys/types.h で ushort, ulong を
定義しているものといないものがあります.よって,コンパイル中に 定義しているものといないものがあります.よって,コンパイル中に
ulong が2重定義されているとおこられる場合があります. ulong が2重定義されているとおこられる場合があります.(Linux ではそのように
このあたりの微調整にはwonx_include 以下のファイルを直接修正して なるようである)
調整してくださいwonx_include/system_configure.h を修正することにより, このあたりの微調整にはwonx ディレクトリ以下のファイルを直接修正して
調整してくださいwonx/system_configure.h を修正することにより,
調整できるようになってます. 調整できるようになってます.
■ WonX のコンパイル ■ WonX のコンパイル
@ -269,6 +279,15 @@ ar ruc libwonx.a WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o
libwonx.a libwonx.a
~/wonx>% ~/wonx>%
このとき,各種 perl スクリプトも同時に作成されます.
必要があれば make install すると,各種ヘッダファイル,ライブラリ,
perl スクリプトがインストールされます.(インストールしなくても構いません.
以降はインストールしなかったものとして説明します)
~/wonx>% su
Password:
# make install
ここまでで,ライブラリの作成は終りです. ここまでで,ライブラリの作成は終りです.
■ WonderWitch 用アプリケーションのコンパイル ■ WonderWitch 用アプリケーションのコンパイル
@ -290,7 +309,7 @@ SpeedMac
2. ヘッダファイルと libwonx.a をコピーする. 2. ヘッダファイルと libwonx.a をコピーする.
~/wonx/smac-b02>% cp -R ../wonx_include . ~/wonx/smac-b02>% cp -R ../wonx .
~/wonx/smac-b02>% cp ../libwonx.a . ~/wonx/smac-b02>% cp ../libwonx.a .
~/wonx/smac-b02>% ~/wonx/smac-b02>%
@ -313,8 +332,8 @@ qkc
#include <sys/disp.h> #include <sys/disp.h>
#include <sys/key.h> #include <sys/key.h>
のような部分を, のような部分を,
#include "wonx_include/disp.h" #include "wonx/disp.h"
#include "wonx_include/key.h" #include "wonx/key.h"
のように修正します. のように修正します.
これをまとめてやるための perl スクリプト (sys2wonx.pl) を添付してあるので, これをまとめてやるための perl スクリプト (sys2wonx.pl) を添付してあるので,
@ -401,8 +420,10 @@ smac
・F2 を押すと,パレットのデータをダンプ出力する. ・F2 を押すと,パレットのデータをダンプ出力する.
・F3 を押すと,キャラクターのデータをダンプ出力する. ・F3 を押すと,キャラクターのデータをダンプ出力する.
・F4 を押すと,スプライトのデータをダンプ出力する. ・F4 を押すと,スプライトのデータをダンプ出力する.
・F10 を押すと,表示/非表示モードを切替える. ・F9 を押すと,画面の表示レベルを下げる.
(非表示だと画面への描画を行わないが高速) ・F10 を押すと,画面の表示レベルを上げる.
表示レベルはデフォルトで 1 になっており,現在のレベルが 1 以上の場合のみ
画面の描画を行う0 以下の場合には,画面への描画を行わないがそのぶん高速.
・F11 で10秒間停止(画面写真をとるときなどに利用できる) ・F11 で10秒間停止(画面写真をとるときなどに利用できる)
(F11は短めに押してください長めに押すと復帰しなくなるようです) (F11は短めに押してください長めに押すと復帰しなくなるようです)
・q もしくは Ctrl-c もしくは F12 で強制終了. ・q もしくは Ctrl-c もしくは F12 で強制終了.
@ -419,8 +440,9 @@ for (y = 0; y < 32; y++)
} }
} }
このような場合はF10 を押して非表示モードにして,ループ処理が終ったら このような場合はF9 を押して表示レベルを下げて,ループ処理が終ったら
再び F10 を押して表示モードに戻してください. 再び F10 を押して表示レベルを上げてください.(何度も押すと表示レベルが
どんどん下がって(もしくは上がって)しまうので,長めに1回だけ押してください)
F1 や F2 を押すと,データをダンプ出力するのですが,標準ではその他にも F1 や F2 を押すと,データをダンプ出力するのですが,標準ではその他にも
メッセージが大量に出力されているので,ふつうに F1 を押しただけでは, メッセージが大量に出力されているので,ふつうに F1 を押しただけでは,
@ -450,7 +472,7 @@ WonX
> smac > /dev/null > smac > /dev/null
だと,文字列を kterm などに表示しないぶん,高速になります. だと,文字列を kterm などに表示しないぶん,(かなり)高速になります.
■ 足りないもの ■ 足りないもの
@ -486,7 +508,7 @@ WonX
ヘッダファイルのコンフリクトですとくにWonderWitch で sys 以下の ヘッダファイルのコンフリクトですとくにWonderWitch で sys 以下の
ファイルをインクルードしている場合は注意してください. ファイルをインクルードしている場合は注意してください.
ushort, ulong などはsys/types.h で定義されているシステムもあるし, ushort, ulong などはsys/types.h で定義されているシステムもあるし,
そうでないシステムもありますこのへんはwonx_include/system_configure.h で そうでないシステムもありますこのへんはwonx/system_configure.h で
調整してください. 調整してください.
(FreeBSD では ushort のみ定義されているがRedHat Linux では, (FreeBSD では ushort のみ定義されているがRedHat Linux では,
uchort, ulong ともに定義されているので,そのままだとコンパイル中に uchort, ulong ともに定義されているので,そのままだとコンパイル中に
@ -530,7 +552,7 @@ WonderWitch
バグなど)を発見できることがあるので,なるべくなら int2sint.pl で int を バグなど)を発見できることがあるので,なるべくなら int2sint.pl で int を
ごっそり short int にしてしまうことをおすすめします. ごっそり short int にしてしまうことをおすすめします.
[エンディアンの問題] [バイトエンディアンの問題]
WonderWitch の CPU は x86系ですSPARC などで使用する場合には, WonderWitch の CPU は x86系ですSPARC などで使用する場合には,
エンディアンに注意する必要があります. エンディアンに注意する必要があります.
@ -543,7 +565,9 @@ WonX-2.1
修正しましたi386 と SPARC でエンディアンに依存しないことを動作確認 修正しましたi386 と SPARC でエンディアンに依存しないことを動作確認
しています.しかしそれでも,キャラクタデータを unsigned char * で定義して, しています.しかしそれでも,キャラクタデータを unsigned char * で定義して,
ビットマップ読み込み用の関数にキャラクタデータを渡すときに short int * に ビットマップ読み込み用の関数にキャラクタデータを渡すときに short int * に
キャストして渡すような書き方をしていると,依存してしまいます. キャストして渡すような書き方をしていると,依存してしまいます.つまり,
WonX 自体はエンディアンに依存していないがWonX を利用するプログラムが
エンディアン依存に書いてあっては,どうしようもないということです.
キャラクタデータのビットマップ読み込み用の関数には,適切な型のデータを キャラクタデータのビットマップ読み込み用の関数には,適切な型のデータを
渡すようにしてくださいshort int * を渡すべきところにunsigned char * を 渡すようにしてくださいshort int * を渡すべきところにunsigned char * を
@ -631,14 +655,14 @@ gcc -g -o smac $(OBJS) -L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
(実際にはコンパイラは,-lXt\r だと思ってしまってlibXt\r.a というライブラリを (実際にはコンパイラは,-lXt\r だと思ってしまってlibXt\r.a というライブラリを
探してしまうのです) 探してしまうのです)
(しかも,ファイルを emacs や less などで参照しても,改行コードは表示されない (しかも,ファイルを emacs や less などで参照しても,改行コードは表示されない
ため,原因がわかりにくい) ため,原因がとってもわかりにくい)
また, また,
gcc -g -o smac $(OBJS) -lwonx -lX11 -lXt -L. -L/usr/X11R6/lib gcc -g -o smac $(OBJS) -lwonx -lX11 -lXt -L. -L/usr/X11R6/lib
のようにしていると,/usr/X11R6/lib を指定したつもりなのに,実際には のようにしていると,/usr/X11R6/lib を指定したつもりなのに,実際には
/usr/X11R6/lib\r というディレクトリが指定されたことになってしまい, /usr/X11R6/lib\r というディレクトリが指定されたことになってしまい,
-lX11, -lXt の検索に失敗します. -lX11, -lXt の検索に失敗し,やはり make に失敗します.
漢字コードに関しても同じことがいえますUNIX での漢字コードは EUC なので, 漢字コードに関しても同じことがいえますUNIX での漢字コードは EUC なので,
ソースコード中に SJIS の漢字が入っていると,うまくコンパイルできなかったり, ソースコード中に SJIS の漢字が入っていると,うまくコンパイルできなかったり,
@ -667,6 +691,11 @@ SAMPLE.C
タブや改行コードは,"\t" "\n" のような文字列に変換されて出力されます. タブや改行コードは,"\t" "\n" のような文字列に変換されて出力されます.
添付の sout2str.pl を通すことにより,シリアル通信への出力のみ抽出して, 添付の sout2str.pl を通すことにより,シリアル通信への出力のみ抽出して,
端末への出力のイメージで表示させることができます. 端末への出力のイメージで表示させることができます.
sout2str.pl は以下のようにして利用します.
(terminal という WonderWitch 用プログラムをWonX を利用して UNIX 上で
コンパイルしてsout2str.pl を通してシリアルへの出力のイメージを見たい場合)
> ./terminal | ./sout2str.pl
■ 割り込みについて ■ 割り込みについて
@ -732,66 +761,285 @@ _asm_inline()
WonderWitch 用のプログラムを開発していく際にWonX の場合のみ組み込みたくて, WonderWitch 用のプログラムを開発していく際にWonX の場合のみ組み込みたくて,
WonderSwan 上で実行するときには取り除きたいコードがあったとします. WonderSwan 上で実行するときには取り除きたいコードがあったとします.
(例えば,デバッグ情報の出力のために printf() を入れる場合など) (例えば,デバッグ情報の出力のために printf() を入れる場合など)
このようなときのためにwonx_include/types.h で このようなときのためにwonx/types.h で
#define _WONX_ #define _WONX_
してあるので,そのような場所は #ifdef _WONX_ でくくってください. してあるので,そのような場所は #ifdef _WONX_ でくくってください.
ダンプデータの取りかた WonX が提供するサービス関数
ソース中に, WonX は以下の関数をデバッグ用のサービス関数として提供しています.
以下の関数を実行することにより,デバッグ情報を stdout に出力します.
#include "WonX.h" #include "wonx/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; void wonx_print_colormap_data(void);
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay()); /* パレット情報の出力 */
void wonx_print_palette_data(int n);
WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout); /* すべてのパレット情報を出力 */
void wonx_print_all_palette_data(void);
for (i = 0; i < 16; i++) /* キャラクタ情報の出力 */
WWPalette_PrintData(WWDisplay_GetPalette(ww_display, i), stdout); void wonx_print_character_data(int n);
for (i = 0; i < 512; i++) /* すべてのキャラクタ情報を出力 */
WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i), stdout); void wonx_print_all_character_data(void);
for (i = 0; i < 128; i++) /* スプライト情報の出力 */
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout); void wonx_print_sprite_data(int n);
のようなコードを挿入することにより,任意の場所でキャラクタやパレットの /* すべてのスプライト情報を出力 */
ダンプデータを出力させることができます. void wonx_print_all_sprite_data(void);
プログラム中に,不安な場所があったら, たとえばソース中に不安な場所があったら,
#ifdef _WONX_ #ifdef _WONX_
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay()); #include "wonx/wonx.h"
printf("Before setting:\n"); #endif
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, 0), stdout);
#endif /* _WONX_ */ void func(void)
{
...(中略)...
#ifdef _WONX_
wonx_print_sprite_data(0);
#endif
/* ここにスプライトの設定についての不安なコードがある */ /* ここにスプライトの設定についての不安なコードがある */
#ifdef _WONX_ #ifdef _WONX_
printf("After setting:\n"); wonx_print_sprite_data(0);
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, 0), stdout); #endif
#endif /* _WONX_ */
のようにして不安なコードの前後でダンプデータを取ると,デバッグに ...(以下略)...
役立つでしょう.
のようにして不安なコードの前後でダンプデータを取ると,デバッグに役立つ
でしょう.#ifdef _WONX_ でくくっておけば,デバッグコードをソース中に残した
ままで WonderWitch でもコンパイルが可能なので便利です.
またWonX では画面の描画に時間がかかるのに加えて,画面の描画は画面関連の
システムコール(パレットの変更なども含む)が呼ばれるたびに行われるため,
for (y = 0; y < TEXT_SCREEN_HEIGHT; y++) {
for (x = 0; x < TEXT_SCREEN_WIDTH; x++) {
text_put_char(x, y, ' ');
}
}
のようなコードがあるとtext_put_char() の呼び出しのたびに画面描画が行われる
ため,動作が非常に遅くなります.
これの対策としてF9, F10 を押して画面の表示レベルを変化させることで
画面の表示/非表示を切替えられるようにしてあるのですが,以下のサービス関数を
利用することで,プログラム中から画面の表示レベルを制御できます.
表示レベルはデフォルトでは 1 になっており,表示レベルが 1 以上のときのみ
描画が行われます.
とくに gdb などを使ってデバッグする場合にはF9, F10 の反応が鈍くなったり
するおそれがあるため,重宝するでしょう.
#include "wonx/wonx.h"
/* 現在の表示/非表示のレベルの取得.(1以上で表示0以下で非表示) */
int wonx_get_lcddraw_level(void);
/* 現在の表示/非表示のレベルの設定 */
int wonx_set_lcddraw_level(int level);
/* 表示レベルを下げる */
int wonx_lcddraw_level_down(void);
/* 表示レベルを上げる */
int wonx_lcddraw_level_up(void);
実際のプログラム中では,以下のようにして利用します.
#ifdef _WONX_
#include "wonx/wonx.h"
#endif
void func(void)
{
...(中略)...
#ifdef _WONX_
wonx_lcddraw_level_down();
#endif
for (y = 0; y < TEXT_SCREEN_HEIGHT; y++) {
for (x = 0; x < TEXT_SCREEN_WIDTH; x++) {
text_put_char(x, y, ' ');
}
}
#ifdef _WONX_
wonx_lcddraw_level_up();
#endif
...(以下略)...
このように書くことによりWonX でのコンパイル時には text_put_char() 実行時の
画面描画を抑止して,高速化することができます.
(#ifdef _WONX_ でくくるのを忘れないようにしましょう)
■ 画面の表示レベルについて
WonX-2.2 から,画面の表示レベルというものを導入しました.
(WonX-2.1 まではF10 による画面描画の ON/OFF の切替えのみだった)
これの理由は,プログラム中から
(wonx_lcddraw_level_up(), wonx_lcddraw_level_down() などによって)画面の描画を
制御する際にON/OFF しかできないと,関数の中から関数を呼ぶような場合に
期待通りに動作しないからです.たとえば以下のような場合です.
void sample1(void)
{
wonx_lcddraw_draw_off();
/* 処理2 */
wonx_lcddraw_draw_on();
}
void sample2(void)
{
wonx_lcddraw_draw_off();
/* 処理1 */
sample1();
/* 処理3 */
wonx_lcddraw_draw_on();
}
処理処理の位置では画面描画はOFFになっているのですが処理の部分では
期待に反して画面の描画は ON になってしまいます.これではどこの関数で
ON/OFF しているのかを常に注意しなければならなくなりOFF にしているつもりでも
どこかで ON になってしまっていたりと,何のデバッグをしているのがわからなく
なってしまいます.
この対策として,表示レベルを定めて,以下のように書けるようにしました.
void sample1(void)
{
wonx_lcddraw_level_down();
/* 処理2 */
wonx_lcddraw_level_up();
}
void sample2(void)
{
wonx_lcddraw_level_down();
/* 処理1 */
sample1();
/* 処理3 */
wonx_lcddraw_level_up();
}
これだと処理2のところでは表示レベルは -1処理処理のところでは
表示レベルは 0 となるため,期待通りに動作してくれます.
■ mmap() について
WonX の設計思想では「UNIX側にも存在するサービス関数はUNIXにまかせる」
と考えているためfopen() などは WonX では用意していません.
しかし mmap() に関してはUNIX と WonderWitch で動作がかなり違うのと,
WonderWitch のプログラム中で実際に mmap() を使用しているものが多いという
実情があったのでWonX-2.2 で mmap() システムコールの実装を行いました.
ただし実装上の問題があってUNIX 側では mmap() は,/usr/include/stdio.h で,
void * mmap(void * addr, size_t len, int prot, int flags, int fd, off_t offset);
のように定義されています.(FreeBSD の例)
これに対して WonderWitch ではinclude/sys/fcntl.h で,
void * mmap(char * filename);
のような形でに定義されています.(実際にはポインタは far ポインタになっているが)
UNIX の mmap() と WonderWitch の mmap() では,引数の数も種類も違います.
このため WonderWitch に合わせて mmap() を実装するとWonX のコンパイル時や
WonX をリンクするプログラムのコンパイル時に,関数の引数がコンフリクトして
エラーとなってしまいますWonX をリンクするプログラム中ではstdio.h が
インクルードされる可能性が常に存在するので,移植性の高い方法でこの問題を
根本的に解決することはできません.
これの苦肉の対策としてWonX では mmap() は wonx_mmap() という名前で定義して,
fcntl.h では,
#define mmap wonx_mmap
することで対処していますつまりmmap() の実体は wonx_mmap() となります.
具体的には fcntl.[ch] を参照してください.
このためfcntl.h をインクルードするのを忘れて mmap() を使用すると,
UNIX の mmap() (stdio.h の mmap()) が有効になってしまうため,
「関数の引数が食い違っている」という内容のエラーが出ると思われるので,
注意してください.
また,この方法だと fcntl.h の後に stdio.h がインクルードされるような場合に,
stdio.h の中で宣言されている mmap() も wonx_mmap() に書き変わってしまい,
やはり関数の引数がコンフリクトしてしまいます対策としてfcntl.h の先頭付近で
stdio.h のインクルードを行いfcntl.h の後で stdio.h がインクルードされても,
度目のインクルードになってstdio.h の先頭で,
#ifndef _STDIO_H_
#define _STDIO_H_
などで切られるようになっています.
今後同様な関数を実装するときにも,同じような対処になるでしょう.
うーん,ほんとに苦肉の策だなあ... #define をつかうか,もしくは
void * wonx_mmap(char * filename);
void * mmap;
mmap = wonx_mmap;
のようにして代入しなおす,などの方法も検討したのですが,結局これがいちばん
確実でわかりやすい方法かなあ... と思ってます.もっといいアイディアがあったら
教えてください.
■ 実行の高速化について
WonX はデバッグ目的のライブラリであるため,あまり高速動作のことを
考えていません.そのため,遅いです.ですが,以下のことに注意することで,
かなり速く動作させることもできます.
プログラム中のホットスポットになる部分を,
wonx_lcddraw_level_down(), wonx_lcddraw_level_up()
でくくるこれによりF10 を押して画面描画を OFF にしたのと同じ効果が
得られます.
実行時には,
> ./smac > /dev/null
のようにして,出力メッセージを /dev/null に捨てる.
WonX は大量のメッセージを出力しますがkterm 上などで動作させている場合には,
このメッセージの処理が大きな負荷になります.このため,メッセージを
/dev/null に捨ててしまうことで,高速に動作させることができるようになります.
これらのことに気をつければ,かなり高速に動かすことが可能になります.
■ 添付のツールについて ■ 添付のツールについて
perl スクリプト(*.pl)は make することにより,*.perl から自動生成されます.
このときperl のある場所を自動検索して,スクリプトの先頭行に
#!/usr/bin/perl のような行を追加してくれます.
[sys2wonx.pl] [sys2wonx.pl]
#include <sys/disp.h> #include <sys/disp.h>
を, を,
#include "wonx_include/disp.h" #include "wonx/disp.h"
のように変換するフィルタです. のように変換するフィルタです.
[int2sint.pl] [int2sint.pl]
@ -861,8 +1109,7 @@ WonX
作者については,添付の OMAKE.jpn を参照してください. 作者については,添付の OMAKE.jpn を参照してください.
坂井弘亮の連絡先のメールアドレスは, 坂井弘亮の連絡先のメールアドレスは,
sakai@seki.ee.kagu.sut.ac.jp hsakai@m8.people.or.jp
hsakai@pfu.co.jp
です.また,本ソフトウエアの最新版を, です.また,本ソフトウエアの最新版を,
http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html
で配布しています. で配布しています.

View File

@ -163,8 +163,10 @@ UNIXSerialPort UNIXSerialPort_Destroy(UNIXSerialPort unix_serial_port)
if (unix_serial_port == NULL) if (unix_serial_port == NULL)
WonX_Error("UNIXSerialPort_Destroy", "Object is not created."); WonX_Error("UNIXSerialPort_Destroy", "Object is not created.");
if (UNIXSerialPort_IsOpened(unix_serial_port)) if (UNIXSerialPort_IsOpened(unix_serial_port)) {
UNIXSerialPort_Close(unix_serial_port); UNIXSerialPort_Close(unix_serial_port);
unix_serial_port->opened = 0;
}
free(unix_serial_port); free(unix_serial_port);

View File

@ -23,6 +23,7 @@ volatile static UNIXTimer pointed_unix_timer = NULL;
static void UNIXTimer_CallBackFunction(int argument) static void UNIXTimer_CallBackFunction(int argument)
{ {
int ret; int ret;
int old;
/* /*
* static * static
@ -34,6 +35,9 @@ static void UNIXTimer_CallBackFunction(int argument)
if (pointed_unix_timer->pause) { if (pointed_unix_timer->pause) {
pointed_unix_timer->interrupt_in_pause++; pointed_unix_timer->interrupt_in_pause++;
if (pointed_unix_timer->interrupt_in_pause > 1000) {
WonX_Error("UNIXTimer_CallBackFunction", "interrupt count is too much.");
}
} else { } else {
if (pointed_unix_timer->interrupt_in_pause == 0) if (pointed_unix_timer->interrupt_in_pause == 0)
pointed_unix_timer->interrupt_in_pause = 1; pointed_unix_timer->interrupt_in_pause = 1;
@ -44,13 +48,15 @@ static void UNIXTimer_CallBackFunction(int argument)
/* /*
* UNIXTimer_Unpause() * UNIXTimer_Unpause()
* *
* * interrupt_in_pause
* (?)
* interrupt_in_pause
*/ */
pointed_unix_timer->pause++; pointed_unix_timer->pause++;
old = pointed_unix_timer->interrupt_in_pause;
ret = (*pointed_unix_timer->callback)(pointed_unix_timer->parameter); ret = (*pointed_unix_timer->callback)(pointed_unix_timer->parameter);
pointed_unix_timer->pause--; pointed_unix_timer->pause--;
pointed_unix_timer->interrupt_in_pause = old;
/* /*
* UNIXTimer_* * UNIXTimer_*

View File

@ -139,7 +139,7 @@ WWCharacter WWCharacter_Create(int number)
WWCharacter WWCharacter_Destroy(WWCharacter character) WWCharacter WWCharacter_Destroy(WWCharacter character)
{ {
if (character == NULL) if (character == NULL)
WonX_Error("WWCharacter_Destroy", "WWCharacter is NULL."); WonX_Error("WWCharacter_Destroy", "Object is not created.");
free(character); free(character);
return (NULL); return (NULL);
} }

View File

@ -19,7 +19,7 @@ typedef struct _WWCharacter * WWCharacter;
#include <stdlib.h> #include <stdlib.h>
#include "WWDisplay.h" #include "WWDisplay.h"
#include "wonx_include/libwwc.h" #include "wonx/libwwc.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の宣言 */ /* メンバ関数の宣言 */

View File

@ -24,7 +24,8 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
WWColorMap WWColorMap_Destroy(WWColorMap color_map) WWColorMap WWColorMap_Destroy(WWColorMap color_map)
{ {
if (color_map == NULL) return (NULL); if (color_map == NULL)
WonX_Error("WWColorMap_Destroy", "Object is not created.");
free(color_map); free(color_map);
return (NULL); return (NULL);
} }

View File

@ -53,7 +53,8 @@ WWCursor WWCursor_Create(WWPalette palette)
WWCursor WWCursor_Destroy(WWCursor cursor) WWCursor WWCursor_Destroy(WWCursor cursor)
{ {
if (cursor == NULL) return (NULL); if (cursor == NULL)
WonX_Error("WWCursor_Destroy", "Object is not created.");
free(cursor); free(cursor);
return (NULL); return (NULL);
} }

View File

@ -2,9 +2,9 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "wonx_include/disp.h" #include "wonx/disp.h"
#include "wonx_include/text.h" #include "wonx/text.h"
#include "wonx_include/libwwc.h" #include "wonx/libwwc.h"
#include "WWDisplayP.h" #include "WWDisplayP.h"
#include "WonX.h" #include "WonX.h"
@ -214,7 +214,8 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
{ {
int i; int i;
if (display == NULL) return (NULL); if (display == NULL)
WonX_Error("WWDisplay_Destroy", "Object is not created.");
if (WWDisplay_GetColorMap(display) != NULL) if (WWDisplay_GetColorMap(display) != NULL)
WWDisplay_SetColorMap(display, WWDisplay_SetColorMap(display,

View File

@ -19,7 +19,7 @@ typedef void (*WWInterruptCallback)();
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/system.h" #include "wonx/system.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の宣言 */ /* メンバ関数の宣言 */

View File

@ -125,11 +125,16 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel) WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel)
{ {
int i; int i;
if (lcd_panel == NULL) return (NULL);
if (lcd_panel == NULL)
WonX_Error("WWLCDPanel_Destroy", "Object is not created.");
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]); if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]);
} }
free(lcd_panel); free(lcd_panel);
return (NULL); return (NULL);
} }

View File

@ -71,7 +71,8 @@ WWPalette WWPalette_Create(int number, int * mapped_colors)
WWPalette WWPalette_Destroy(WWPalette palette) WWPalette WWPalette_Destroy(WWPalette palette)
{ {
if (palette == NULL) return (NULL); if (palette == NULL)
WonX_Error("WWPalette_Destroy", "Object is not created.");
free(palette); free(palette);
return (NULL); return (NULL);
} }

View File

@ -54,7 +54,8 @@ static WWScreenCharacter WWScreenCharacter_Create(int horizontal, int vertical,
static WWScreenCharacter WWScreenCharacter_Destroy(WWScreenCharacter static WWScreenCharacter WWScreenCharacter_Destroy(WWScreenCharacter
screen_character) screen_character)
{ {
if (screen_character == NULL) return (NULL); if (screen_character == NULL)
WonX_Error("WWScreenCharacter_Destroy", "Object is not created.");
free(screen_character); free(screen_character);
return (NULL); return (NULL);
} }
@ -272,7 +273,8 @@ WWScreen WWScreen_Destroy(WWScreen screen)
int x, y; int x, y;
WWScreenCharacter sc; WWScreenCharacter sc;
if (screen == NULL) return (NULL); if (screen == NULL)
WonX_Error("WWScreen_Destroy", "Object is not created.");
for (y = 0; y < screen->height; y++) { for (y = 0; y < screen->height; y++) {
for (x = 0; x < screen->width; x++) { for (x = 0; x < screen->width; x++) {

View File

@ -70,6 +70,8 @@ WWSerialPort WWSerialPort_Destroy(WWSerialPort ww_serial_port)
if (ww_serial_port == NULL) if (ww_serial_port == NULL)
WonX_Error("WWSerialPort_Destroy", "Object is not created."); WonX_Error("WWSerialPort_Destroy", "Object is not created.");
WWSerialPort_Close(ww_serial_port);
free(ww_serial_port); free(ww_serial_port);
return (NULL); return (NULL);

View File

@ -18,7 +18,7 @@ typedef struct _WWSerialPort * WWSerialPort;
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/comm.h" #include "wonx/comm.h"
/*****************************************************************************/ /*****************************************************************************/
/* 年眶の年盗 */ /* 年眶の年盗 */

View File

@ -107,7 +107,8 @@ WWSprite WWSprite_Create(int number, int x, int y,
WWSprite WWSprite_Destroy(WWSprite sprite) WWSprite WWSprite_Destroy(WWSprite sprite)
{ {
if (sprite == NULL) return (NULL); if (sprite == NULL)
WonX_Error("WWSprite_Destroy", "Object is not created.");
free(sprite); free(sprite);
return (NULL); return (NULL);
} }

View File

@ -198,7 +198,8 @@ WWText WWText_Destroy(WWText ww_text)
{ {
int i; int i;
if (ww_text == NULL) WonX_Error("WWText_Destroy", "Object is not created."); if (ww_text == NULL)
WonX_Error("WWText_Destroy", "Object is not created.");
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
if (WWText_GetFont(ww_text, i)) if (WWText_GetFont(ww_text, i))

View File

@ -100,6 +100,8 @@ WWTimer WWTimer_Destroy(WWTimer ww_timer)
if (ww_timer == NULL) if (ww_timer == NULL)
WonX_Error("WWTimer_Destroy", "Object is not created."); WonX_Error("WWTimer_Destroy", "Object is not created.");
WWTimer_OFF(ww_timer);
free(ww_timer); free(ww_timer);
return (NULL); return (NULL);

View File

@ -18,7 +18,7 @@ typedef struct _WWTimer * WWTimer;
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/timer.h" #include "wonx/timer.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の宣言 */ /* メンバ関数の宣言 */

69
WonX.c
View File

@ -1,9 +1,9 @@
#include "WonXP.h" #include "WonXP.h"
#include "etc.h" #include "etc.h"
#include "wonx_include/disp.h" #include "wonx/disp.h"
#include "wonx_include/system.h" #include "wonx/system.h"
#include "wonx_include/comm.h" #include "wonx/comm.h"
static WonX wonx = NULL; static WonX wonx = NULL;
@ -14,17 +14,78 @@ int WonX_IsCreated(void)
void WonX_Create(void) void WonX_Create(void)
{ {
if (WonX_IsCreated())
WonX_Error("WonX_Create", "WonX has been already created.");
wonx = (WonX)malloc(sizeof(_WonX)); wonx = (WonX)malloc(sizeof(_WonX));
if (wonx == NULL) WonX_Error("WonX_Create", "Cannot allocate memory."); if (wonx == NULL) WonX_Error("WonX_Create", "Cannot allocate memory.");
/*
* WonX
* WonXSystem_Create() WonXDisplay_Create()
* WonXDisplay
* WonXDisplay_Create() WonXSystem_Create()
*/
wonx->wonx_display = wonx->wonx_display =
WonXDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2, WonXDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2,
LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT,
SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT); SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT);
/*
* WonXDisplay WonXSerialPort
* WonXSerialPort_Create()
* WonXSystem_Create()
*/
wonx->wonx_serial_port = WonXSerialPort_Create();
/*
* WonXSystem_Create()
*
* WonXSystem_Create()
* (
* )
*/
wonx->wonx_system = WonXSystem_Create(); wonx->wonx_system = WonXSystem_Create();
wonx->wonx_serial_port = WonXSerialPort_Create(); return;
}
void WonX_Destroy(void)
{
if (!WonX_IsCreated())
WonX_Error("WonX_Destroy", "WonX has not been created yet.");
/*
* WonXSystem
*
* WonXSystem_Destroy()
* (
* )
*/
if (wonx->wonx_system)
wonx->wonx_system = WonXSystem_Destroy(wonx->wonx_system);
/*
* WonXDisplay WonXSerialPort
* WonXSerialPort_Destroy()
* WonXSystem_Destroy()
*/
if (wonx->wonx_serial_port)
wonx->wonx_serial_port = WonXSerialPort_Destroy(wonx->wonx_serial_port);
/*
* WonX
* WonXDisplay WonXSystem
* ( WonXDisplay_Destroy()
* )
* WonXDisplay_Destroy() WonXSystem_Destroy()
*
*/
if (wonx->wonx_display)
wonx->wonx_display = WonXDisplay_Destroy(wonx->wonx_display);
free(wonx);
wonx = NULL;
return; return;
} }

1
WonX.h
View File

@ -7,6 +7,7 @@
int WonX_IsCreated(void); int WonX_IsCreated(void);
void WonX_Create(void); void WonX_Create(void);
void WonX_Destroy(void);
WonXDisplay WonX_GetWonXDisplay(void); WonXDisplay WonX_GetWonXDisplay(void);
WonXSystem WonX_GetWonXSystem(void); WonXSystem WonX_GetWonXSystem(void);
WonXSerialPort WonX_GetWonXSerialPort(void); WonXSerialPort WonX_GetWonXSerialPort(void);

View File

@ -45,6 +45,27 @@ WonXDisplay WonXDisplay_Create(int x_width, int x_height,
return (wonx_display); return (wonx_display);
} }
WonXDisplay WonXDisplay_Destroy(WonXDisplay wonx_display)
{
XDisplay x_display;
WWDisplay ww_display;
if (wonx_display == NULL)
WonX_Error("WonXDisplay_Destroy", "Object is not created.");
x_display = WonXDisplay_GetXDisplay(wonx_display);
if (x_display)
WonXDisplay_SetXDisplay(wonx_display, XDisplay_Destroy(x_display));
ww_display = WonXDisplay_GetWWDisplay(wonx_display);
if (ww_display)
WonXDisplay_SetWWDisplay(wonx_display, WWDisplay_Destroy(ww_display));
free(wonx_display);
return (NULL);
}
int WonXDisplay_PrintData(WonXDisplay wonx_display) int WonXDisplay_PrintData(WonXDisplay wonx_display)
{ {
int i; int i;
@ -89,20 +110,7 @@ int WonXDisplay_PrintData(WonXDisplay wonx_display)
return (0); return (0);
} }
int WonXDisplay_Sync(WonXDisplay wonx_display) int WonXDisplay_DrawLCDWindow(WonXDisplay wonx_display)
{
XDisplay x_display;
WonXDisplay_PrintData(wonx_display);
x_display = WonXDisplay_GetXDisplay(wonx_display);
XDisplay_Sync(x_display);
return (0);
}
int WonXDisplay_Flush(WonXDisplay wonx_display)
{ {
XDisplay x_display; XDisplay x_display;
WWDisplay ww_display; WWDisplay ww_display;
@ -111,12 +119,30 @@ int WonXDisplay_Flush(WonXDisplay wonx_display)
x_display = WonXDisplay_GetXDisplay(wonx_display); x_display = WonXDisplay_GetXDisplay(wonx_display);
ww_display = WonXDisplay_GetWWDisplay(wonx_display); ww_display = WonXDisplay_GetWWDisplay(wonx_display);
if (XDisplay_GetLCDDraw(x_display)) { /* 表示レベルが1以上のときだけ描画する */
if (XDisplay_GetLCDDrawLevel(x_display) > 0) {
WWDisplay_DrawLCDPanel(ww_display); WWDisplay_DrawLCDPanel(ww_display);
ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display); ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
XDisplay_DrawLCDWindow(x_display, ww_display, ww_lcd_panel); XDisplay_DrawLCDWindow(x_display, ww_display, ww_lcd_panel);
} }
return (0);
}
int WonXDisplay_Sync(WonXDisplay wonx_display)
{
XDisplay x_display;
WonXDisplay_PrintData(wonx_display);
x_display = WonXDisplay_GetXDisplay(wonx_display);
XDisplay_Flush(x_display);
return (0);
}
int WonXDisplay_Flush(WonXDisplay wonx_display)
{
WonXDisplay_DrawLCDWindow(wonx_display);
WonXDisplay_Sync(wonx_display); WonXDisplay_Sync(wonx_display);
return (0); return (0);

View File

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

View File

@ -85,15 +85,15 @@ static int WonXTimer_Callback(WonXSystem wonx_system)
/* キー入力割り込み */ /* キー入力割り込み */
/* /*
* XDisplay_Sync() * XDisplay_Flush()
* XDisplay * XDisplay
* *
* ( XDisplay_Sync() * ( XDisplay_Flush()
* ) * )
* *
*/ */
old_key = XDisplay_GetKeyPress(x_display); old_key = XDisplay_GetKeyPress(x_display);
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
new_key = XDisplay_GetKeyPress(x_display); new_key = XDisplay_GetKeyPress(x_display);
/* 新しいキーが押された場合 */ /* 新しいキーが押された場合 */
/* /*

View File

@ -9,6 +9,7 @@
#include "XDisplayP.h" #include "XDisplayP.h"
#include "WonX.h" #include "WonX.h"
#include "WonXDisplay.h"
#include "etc.h" #include "etc.h"
/*****************************************************************************/ /*****************************************************************************/
@ -22,7 +23,18 @@ XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display)
{ return (x_display->color_gc_database); } { return (x_display->color_gc_database); }
unsigned int XDisplay_GetKeyPress(XDisplay d) { return (d->key_press); } unsigned int XDisplay_GetKeyPress(XDisplay d) { return (d->key_press); }
int XDisplay_GetLCDDraw(XDisplay d) { return (d->lcd_draw); }
int XDisplay_GetLCDDrawLevel(XDisplay d) { return (d->lcd_draw_level); }
int XDisplay_SetLCDDrawLevel(XDisplay d, int level)
{
d->lcd_draw_level = level;
WonXDisplay_Flush(WonX_GetWonXDisplay());
return (d->lcd_draw_level);
}
int XDisplay_LCDDrawLevelDown(XDisplay d)
{ return (XDisplay_SetLCDDrawLevel(d, d->lcd_draw_level - 1)); }
int XDisplay_LCDDrawLevelUp( XDisplay d)
{ return (XDisplay_SetLCDDrawLevel(d, d->lcd_draw_level + 1)); }
int XDisplay_GetColorMapPrint(XDisplay d) {return (d->color_map_print); } int XDisplay_GetColorMapPrint(XDisplay d) {return (d->color_map_print); }
int XDisplay_GetPalettePrint(XDisplay d) {return (d->palette_print); } int XDisplay_GetPalettePrint(XDisplay d) {return (d->palette_print); }
@ -111,6 +123,7 @@ static char * translations =
/* 色名からピクセル値を取得する */ /* 色名からピクセル値を取得する */
/*===========================================================================*/ /*===========================================================================*/
#ifdef USE_X_FONT
static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display, static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display,
char * color_name) char * color_name)
{ {
@ -119,6 +132,7 @@ static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display,
&c0, &c1); &c0, &c1);
return (c0.pixel); return (c0.pixel);
} }
#endif
/*===========================================================================*/ /*===========================================================================*/
/* イベントハンドラ */ /* イベントハンドラ */
@ -157,31 +171,72 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event,
switch (key_sym) { switch (key_sym) {
/* WonderSwan用 */ /* WonderSwan用 */
case XK_Up : press = KEY_UP1; break; case XK_Up : press = KEY_UP1; printf("key : Up1 " ); break;
case XK_Right : press = KEY_RIGHT1; break; case XK_Right : press = KEY_RIGHT1; printf("key : Right1 "); break;
case XK_Down : press = KEY_DOWN1; break; case XK_Down : press = KEY_DOWN1; printf("key : Down1 " ); break;
case XK_Left : press = KEY_LEFT1; break; case XK_Left : press = KEY_LEFT1; printf("key : Left1 " ); break;
case XK_i : press = KEY_UP2; break; case XK_i : press = KEY_UP2; printf("key : Up2 " ); break;
case XK_l : press = KEY_RIGHT2; break; case XK_l : press = KEY_RIGHT2; printf("key : Right2 "); break;
case XK_k : press = KEY_DOWN2; break; case XK_k : press = KEY_DOWN2; printf("key : Down2 " ); break;
case XK_j : press = KEY_LEFT2; break; case XK_j : press = KEY_LEFT2; printf("key : Left2 " ); break;
case XK_s : press = KEY_START; break; case XK_s : press = KEY_START; printf("key : Start " ); break;
case XK_space : press = KEY_A; break; case XK_space : press = KEY_A; printf("key : A " ); break;
case XK_Shift_L : press = KEY_B; break; case XK_Shift_L : press = KEY_B; printf("key : B " ); break;
default : press = 0; break; default : press = 0; break;
} }
if (press) {
if (event->type == KeyPress) {
x_display->key_press |= press;
printf("Pressed\n");
} else {
x_display->key_press &= ~press;
printf("Released\n");
}
}
/* WonX 操作用 */ /* WonX 操作用 */
if (event->type == KeyPress) { if (event->type == KeyPress) {
switch (key_sym) { switch (key_sym) {
/* 表示モード変更 */ /* 表示モード変更 */
case XK_F9 :
case XK_F10 : case XK_F10 :
x_display->lcd_draw = !(x_display->lcd_draw);
if (x_display->lcd_draw) { if (key_sym == XK_F9) {
printf("key : F9 Pressed\n");
printf("lcd_draw_level : down (%d", x_display->lcd_draw_level);
(x_display->lcd_draw_level)--;
printf(" -> %d)\n", x_display->lcd_draw_level);
} else {
printf("key : F10 Pressed\n");
printf("lcd_draw_level : up (%d", x_display->lcd_draw_level);
(x_display->lcd_draw_level)++;
printf(" -> %d)\n", x_display->lcd_draw_level);
}
if (x_display->lcd_draw_level > 0) {
#if 1 #if 1
/*
* WonXDisplay_Flush() XDisplay_Flush()
*
*
* X XtDispatchEvent()
*
*
*
* XtDispatchEvent()
* XtDispatchEvent()
*
*
* ( XFree86 )
* WonXDisplay_Flush()
* WonXDisplay_DrawLCDWindow()
* WonX-2.2
*/
WonXDisplay_DrawLCDWindow(WonX_GetWonXDisplay());
#elif 1
WonXDisplay_Flush(WonX_GetWonXDisplay()); WonXDisplay_Flush(WonX_GetWonXDisplay());
#else #else
ExposeHandler(w, p, event, dispatch); ExposeHandler(w, p, event, dispatch);
@ -190,17 +245,28 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event,
break; break;
/* データのダンプ操作 */ /* データのダンプ操作 */
case XK_F1 : x_display->color_map_print = 1; break; case XK_F1 :
case XK_F2 : x_display->palette_print = 1; break; printf("key : F1 Pressed\n");
case XK_F3 : x_display->character_print = 1; break; x_display->color_map_print = 1;
case XK_F4 : x_display->sprite_print = 1; break; printf("dump : color_map\n");
break;
case XK_F2 :
printf("key : F2 Pressed\n");
x_display->palette_print = 1;
printf("dump : palette\n");
break;
case XK_F3 :
printf("key : F3 Pressed\n");
x_display->character_print = 1;
printf("dump : character\n");
break;
case XK_F4 :
printf("key : F4 Pressed\n");
x_display->sprite_print = 1;
printf("dump : sprite\n");
break;
} }
} }
if (press) {
if (event->type == KeyPress) x_display->key_press |= press;
else x_display->key_press &= ~press;
}
} }
return; return;
@ -259,7 +325,7 @@ XDisplay XDisplay_Create(int width, int height)
XtVaSetValues(x_display->toplevel, XtNmaxHeight, x_display->height, NULL); XtVaSetValues(x_display->toplevel, XtNmaxHeight, x_display->height, NULL);
x_display->key_press = 0; x_display->key_press = 0;
x_display->lcd_draw = 1; x_display->lcd_draw_level = 1;
XtRealizeWidget(x_display->toplevel); XtRealizeWidget(x_display->toplevel);
while (!XtIsRealized(x_display->toplevel)) { /* None */ } while (!XtIsRealized(x_display->toplevel)) { /* None */ }
@ -293,16 +359,7 @@ XDisplay XDisplay_Create(int width, int height)
XSetFunction(x_display->display, x_display->color_gc[i], GXcopy); XSetFunction(x_display->display, x_display->color_gc[i], GXcopy);
} }
/* GCのデータベース初期化 */ #ifdef USE_X_FONT
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 = XLoadFont(x_display->display, "8x16");
x_display->font_gc = XCreateGC(x_display->display, x_display->font_gc = XCreateGC(x_display->display,
@ -313,6 +370,24 @@ XDisplay XDisplay_Create(int width, int height)
XDisplay_GetPixelFromColorName(x_display, "white")); XDisplay_GetPixelFromColorName(x_display, "white"));
XSetBackground(x_display->display, x_display->font_gc, XSetBackground(x_display->display, x_display->font_gc,
XDisplay_GetPixelFromColorName(x_display, "black")); XDisplay_GetPixelFromColorName(x_display, "black"));
#endif
/* GCのデータベース初期化 */
/*
* XColorGCDatabase_Create() XCreateGC() GC
* XFreeGC() Segmentation Fault
* (FreeBSD OS (Xライブラリ)
* )XColorGCDatabase_Create() 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 */);
XFillRectangle(x_display->display, x_display->lcd_window, XFillRectangle(x_display->display, x_display->lcd_window,
x_display->color_gc[0], x_display->color_gc[0],
@ -362,17 +437,87 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
{ {
int i; int i;
if (x_display == NULL) return (NULL); if (x_display == NULL)
WonX_Error("XDisplay_Destroy", "Object is not created.");
/* Xサーバと同期をとる */
/* True だと,イベントキュー内のイベントを廃棄する */
XSync(x_display->display, True);
/* トランスレーションのアンインストール */
XtUninstallTranslations(x_display->toplevel);
/* アクションの削除 */
#if 0
/*
*
* ()
*/
#endif
/* アイコンの削除 */
#if 0
/* アイコンの削除処理が必要な場合にはここに書く.現状では必要無し */
#endif
/* イベントハンドラの削除 */
XtRemoveEventHandler(x_display->toplevel, KeyPressMask | KeyReleaseMask,
False, KeyHandler, x_display);
XtRemoveEventHandler(x_display->toplevel, ExposureMask,
False, ExposeHandler, x_display);
XtRemoveEventHandler(x_display->toplevel, LeaveWindowMask | FocusChangeMask,
False, LeaveWindowHandler, x_display);
/* GCのデータベース終了処理 */
if (x_display->color_gc_database) {
x_display->color_gc_database =
XColorGCDatabase_Destroy(x_display->color_gc_database);
}
#ifdef USE_X_FONT
/* フォントの解放 */
if (x_display->font_gc) {
XFreeGC(x_display->display, x_display->font_gc);
x_display->font_gc = 0;
}
if (x_display->font) {
XUnloadFont(x_display->display, x_display->font);
x_display->font = 0;
}
#endif
/* あとでリソースの解放を追加すること */
if (x_display->color_gc != NULL) {
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (x_display->color_gc[i]) if (x_display->color_gc[i]) {
XFreeGC(x_display->display, x_display->color_gc[i]); XFreeGC(x_display->display, x_display->color_gc[i]);
x_display->color_gc[i] = 0; x_display->color_gc[i] = 0;
} }
} }
if (x_display->copy_gc) {
XFreeGC(x_display->display, x_display->copy_gc);
x_display->copy_gc = 0;
}
if (x_display->lcd_pixmap) {
XFreePixmap(x_display->display, x_display->lcd_pixmap);
x_display->lcd_pixmap = 0;
}
x_display->key_press = 0;
x_display->lcd_draw_level = 0;
#if 0
if (x_display->app_context) {
XtDestroyApplicationContext(x_display->app_context);
x_display->app_context = 0;
}
#endif
if (x_display->toplevel) {
XtDestroyWidget(x_display->toplevel);
x_display->toplevel = 0;
}
free(x_display); free(x_display);
return (NULL); return (NULL);
@ -384,14 +529,21 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
int XDisplay_Sync(XDisplay x_display) int XDisplay_Sync(XDisplay x_display)
{ {
XEvent event;
XFlush(x_display->display); XFlush(x_display->display);
/* Xサーバと同期をとる */ /* Xサーバと同期をとる */
/* False だと,イベントキュー内のイベントを廃棄しない */ /* False だと,イベントキュー内のイベントを廃棄しない */
XSync(x_display->display, False); XSync(x_display->display, False);
return (0);
}
int XDisplay_Flush(XDisplay x_display)
{
XEvent event;
XDisplay_Sync(x_display);
/* イベントの処理 */ /* イベントの処理 */
while (XtAppPending(x_display->app_context)) { while (XtAppPending(x_display->app_context)) {
XtAppNextEvent(x_display->app_context, &event); XtAppNextEvent(x_display->app_context, &event);
@ -570,7 +722,7 @@ int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
GC XDisplay_CreateGC(XDisplay x_display) GC XDisplay_CreateGC(XDisplay x_display)
{ {
GC gc; GC gc;
gc = XCreateGC(x_display->display, x_display->root_window, 0, 0); gc = XCreateGC(x_display->display, x_display->lcd_window, 0, 0);
return (gc); return (gc);
} }

View File

@ -17,7 +17,7 @@ typedef struct _XDisplay * XDisplay;
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "wonx_include/key.h" #include "wonx/key.h"
#include "WWDisplay.h" #include "WWDisplay.h"
#include "WWLCDPanel.h" #include "WWLCDPanel.h"
@ -33,7 +33,11 @@ Colormap XDisplay_GetColormap(XDisplay x_display);
XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display); XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display);
unsigned int XDisplay_GetKeyPress(XDisplay x_display); unsigned int XDisplay_GetKeyPress(XDisplay x_display);
int XDisplay_GetLCDDraw(XDisplay x_display);
int XDisplay_GetLCDDrawLevel(XDisplay d);
int XDisplay_SetLCDDrawLevel(XDisplay d, int level);
int XDisplay_LCDDrawLevelDown(XDisplay d);
int XDisplay_LCDDrawLevelUp( XDisplay d);
int XDisplay_GetColorMapPrint(XDisplay d); int XDisplay_GetColorMapPrint(XDisplay d);
int XDisplay_GetPalettePrint(XDisplay d); int XDisplay_GetPalettePrint(XDisplay d);
@ -66,6 +70,7 @@ XDisplay XDisplay_Destroy(XDisplay x_display);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int XDisplay_Sync(XDisplay x_display); int XDisplay_Sync(XDisplay x_display);
int XDisplay_Flush(XDisplay x_display);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* ÉÁ²è */ /* ÉÁ²è */

View File

@ -15,6 +15,11 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
/*
* X
*/
#define USE_X_FONT
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
@ -41,15 +46,17 @@ typedef struct _XDisplay {
/* 4096色表示用のGCのデータベース(XFireworks から流用) */ /* 4096色表示用のGCのデータベース(XFireworks から流用) */
XColorGCDatabase color_gc_database; XColorGCDatabase color_gc_database;
#ifdef USE_X_FONT
/* テキストスクリーンへの文字表示用のフォント */ /* テキストスクリーンへの文字表示用のフォント */
Font font; Font font;
GC font_gc; GC font_gc;
#endif
/* キーの状態 */ /* キーの状態 */
unsigned int key_press; unsigned int key_press;
/* LCD描画のフラグ */ /* LCD描画のレベル */
int lcd_draw; int lcd_draw_level;
/* ダンプ出力のフラグ */ /* ダンプ出力のフラグ */
int color_map_print; int color_map_print;

2
bank.c
View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/bank.h" #include "wonx/bank.h"
#include "WonX.h" #include "WonX.h"

View File

@ -1,4 +1,7 @@
#!/bin/sh #!/bin/sh
if [ -x ./filters.pl ] ; then
./filters.pl "qkc -e -u" ./sys2wonx.pl ./int2sint.pl -f $* ./filters.pl "qkc -e -u" ./sys2wonx.pl ./int2sint.pl -f $*
else
filters.pl "qkc -e -u" sys2wonx.pl int2sint.pl -f $*
fi

2
comm.c
View File

@ -10,7 +10,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include "wonx_include/comm.h" #include "wonx/comm.h"
#include "wonx_configure.h" #include "wonx_configure.h"
#include "WonX.h" #include "WonX.h"

2
disp.c
View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/disp.h" #include "wonx/disp.h"
#include "WonX.h" #include "WonX.h"

105
fcntl.c Normal file
View File

@ -0,0 +1,105 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx_configure.h"
#include "wonx/fcntl.h"
#include "WonX.h"
/*****************************************************************************/
/* 互換関数の定義 */
/*****************************************************************************/
/*
* void *
* void *
*/
/*
* Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので
* UNIXTimer_Pause(), UNIXTimer_Unpause()
* unpause
* sync
*/
/*
*
*
* ()
* static
*
*
*/
/*
* mmap() UNIX WonderWitch
* README
*/
#if 0
void * wonx_mmap(char * filename);
void * mmap = wonx_mmap;
#endif
#if 0
#ifdef wonx_mmap
#undef wonx_mmap
#endif
#endif
void * wonx_mmap(char * filename)
{
int size = 10;
FILE * fp;
int i, c;
char * p;
void * ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : mmap() : filename = %s\n", filename);
fflush(stdout);
p = (char *)malloc(size);
if (p == NULL) WonX_Error("mmap", "cannot allocate memory.");
fp = fopen(filename, "rb");
if (fp == NULL) WonX_Error("mmap", "cannot open file.");
i = 0;
while ((c = fgetc(fp)) != EOF) {
if (i > size - 1) {
p = (char *)realloc(p, size);
if (p == NULL) WonX_Error("mmap", "cannot reallocate memory.");
}
p[i] = c;
i++;
}
fclose(fp);
ret = p;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : mmap() : return value = 0x%p\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/perl #!PATH_TO_PERL
while ($_ = shift(@ARGV)) { while ($_ = shift(@ARGV)) {
if ($_ eq "-f" ) { last; } if ($_ eq "-f" ) { last; }
@ -8,9 +8,13 @@ while ($_ = shift(@ARGV)) {
while ($filename = shift(@ARGV)) { while ($filename = shift(@ARGV)) {
$command = "cat $filename$filters > $filename.tmp"; $command = "cat $filename$filters > $filename.tmp";
print "$command\n"; print STDERR "$command\n";
system($command); $ret = system($command);
if ($ret != 0) { die "Command not found. Install perl scripts.\n"; }
$command = "mv $filename.tmp $filename"; $command = "mv $filename.tmp $filename";
print "$command\n"; print STDERR "$command\n";
system($command); $ret = system($command);
if ($ret != 0) { die "Command not found.\n"; }
} }
exit (0);

26
findperl.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
arg=${1}
if [ -n "${arg}" -a -x "${arg}" ]; then
whereperl="${1}"
elif [ -x /usr/local/bin/perl ]; then
whereperl="/usr/local/bin/perl"
elif [ -x /usr/pkg/bin/perl ]; then
whereperl="/usr/pkg/bin/perl"
elif [ -x /usr/bin/perl ]; then
whereperl="/usr/bin/perl"
elif which -s perl; then
whereperl=`which perl`
else
echo "Cannot find perl." 1>&2
echo -n "Input path to perl as full path (Ex. /usr/bin/perl): " 1>&2
read whereperl
if [ ! -x $whereperl ]; then
echo "Error: cannot find perl." 1>&2
exit 1
fi
fi
echo "#!$whereperl"
exit 0

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/perl #!PATH_TO_PERL
while (<STDIN>) { while (<STDIN>) {
s/([\s;\}\/])uint(\s)/$1unsigned int$2/g; s/([\s;\}\/])uint(\s)/$1unsigned int$2/g;
@ -17,3 +17,5 @@ while (<STDIN>) {
s/_WONX_INT_/int/g; s/_WONX_INT_/int/g;
print $_; print $_;
} }
exit (0);

26
key.c
View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/key.h" #include "wonx/key.h"
#include "WonX.h" #include "WonX.h"
@ -42,7 +42,7 @@ int key_press_check(void)
printf("call : key_press_check() : \n"); fflush(stdout); printf("call : key_press_check() : \n"); fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay()); x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
@ -70,7 +70,7 @@ int key_hit_check(void)
printf("call : key_hit_check() : \n"); fflush(stdout); printf("call : key_hit_check() : \n"); fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay()); x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
@ -88,7 +88,7 @@ int key_hit_check(void)
int key_wait(void) int key_wait(void)
{ {
XDisplay x_display; XDisplay x_display;
int ret; volatile int ret;
if (!WonX_IsCreated()) WonX_Create(); if (!WonX_IsCreated()) WonX_Create();
@ -101,13 +101,25 @@ int key_wait(void)
/* /*
* ! * !
* key_wait() Unpause
*
* dowhile XDisplay_Flush()
*/
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
/*
* Unpause
* Pause XDisplay
*
* (XDisplay_GetKeyPress() )
*/ */
ret = 0; ret = 0;
do { do {
XDisplay_Sync(x_display); #if 0 /* タイマを Unpause しない場合には必要 */
XDisplay_Flush(x_display);
#endif
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
} while (ret == 0); } while (ret == 0);
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
WonXDisplay_Sync(WonX_GetWonXDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
@ -177,7 +189,7 @@ int key_hit_check_with_repeat(void)
printf("call : key_hit_check_with_repeat() : \n"); fflush(stdout); printf("call : key_hit_check_with_repeat() : \n"); fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay()); x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);

View File

@ -7,7 +7,7 @@
#include "wonx_configure.h" #include "wonx_configure.h"
#include "wonx_include/libwwc.h" #include "wonx/libwwc.h"
#include "WonX.h" #include "WonX.h"

View File

@ -1,5 +1,5 @@
#include "wonx_include/text.h" #include "wonx/text.h"
#include "wonx_include/key.h" #include "wonx/key.h"
main() main()
{ {
@ -12,7 +12,7 @@ main()
text_put_string(0, 8, " linked to program for "); text_put_string(0, 8, " linked to program for ");
text_put_string(0, 9, " WonderWitch and behave as "); text_put_string(0, 9, " WonderWitch and behave as ");
text_put_string(0, 10, " WonderWitch. "); text_put_string(0, 10, " WonderWitch. ");
text_put_string(0, 12, "WonX Copyright (c) 2000-2001"); text_put_string(0, 12, "WonX Copyright (c) 2000-2002");
text_put_string(0, 13, " Sakai Hiroaki. "); text_put_string(0, 13, " Sakai Hiroaki. ");
text_put_string(0, 14, " All Rights Reserved. "); text_put_string(0, 14, " All Rights Reserved. ");
text_put_string(0, 16, " Hit space key to exit. "); text_put_string(0, 16, " Hit space key to exit. ");

View File

@ -1,5 +1,5 @@
#include "wonx_include/disp.h" #include "wonx/disp.h"
#include "wonx_include/key.h" #include "wonx/key.h"
static unsigned char clear[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static unsigned char clear[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char block[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static unsigned char block[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

35
sample3.c Normal file
View File

@ -0,0 +1,35 @@
#include "wonx/text.h"
#include "wonx/fcntl.h"
#include "wonx/key.h"
#ifdef _WONX_
#include "wonx/wonx.h"
#endif
main()
{
char * p;
int x, y, i;
text_screen_init();
p = mmap("COPYING");
#ifdef _WONX_
wonx_lcddraw_level_down();
#endif
i = 0;
for (y = 0; y < TEXT_SCREEN_HEIGHT; y++) {
for (x = 0; x < TEXT_SCREEN_WIDTH; x++) {
text_put_char(x, y, p[i++]);
}
}
#ifdef _WONX_
wonx_lcddraw_level_up();
#endif
key_wait();
bios_exit();
}

View File

@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include "wonx_include/service.h" #include "wonx/service.h"
#include "WonX.h" #include "WonX.h"
@ -40,6 +40,7 @@ void bios_exit()
{ {
printf("call : bios_exit() : \n"); printf("call : bios_exit() : \n");
fflush(stdout); fflush(stdout);
if (WonX_IsCreated()) WonX_Destroy();
exit (0); exit (0);
} }

View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/sound.h" #include "wonx/sound.h"
#include "WonX.h" #include "WonX.h"

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/perl #!PATH_TO_PERL
use FileHandle; use FileHandle;
@ -17,4 +17,4 @@ while (<STDIN>) {
} }
} }
# End of program exit (0);

8
sys2wonx.perl Normal file
View File

@ -0,0 +1,8 @@
#!PATH_TO_PERL
while (<STDIN>) {
s/^(\s*\#\s*include\s*)[\<\"]sys\/(.+\.h)[\>\"]/$1\"wonx\/$2\"/i;
print $_;
}
exit (0);

View File

@ -1,6 +0,0 @@
#!/usr/local/bin/perl
while (<STDIN>) {
s/^(\s*\#\s*include\s*)[\<\"]sys\/(.+\.h)[\>\"]/$1\"wonx_include\/$2\"/i;
print $_;
}

View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "wonx_include/system.h" #include "wonx/system.h"
#include "WonX.h" #include "WonX.h"

2
text.c
View File

@ -6,7 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "wonx_include/text.h" #include "wonx/text.h"
#include "WonX.h" #include "WonX.h"
#include "WWText.h" #include "WWText.h"

View File

@ -6,7 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "wonx_include/timer.h" #include "wonx/timer.h"
#include "wonx_configure.h" #include "wonx_configure.h"
#include "WonX.h" #include "WonX.h"

366
wonx.c Normal file
View File

@ -0,0 +1,366 @@
#include <stdio.h>
#include <stdlib.h>
#include "wonx/wonx.h"
#include "WonX.h"
#include "WonXDisplay.h"
#include "WWDisplay.h"
#include "XDisplay.h"
#include "WWColorMap.h"
#include "WWPalette.h"
#include "WWCharacter.h"
#include "WWSprite.h"
/*****************************************************************************/
/* 外部に公開する WonX のサービス関数 */
/*****************************************************************************/
/*
* Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので
* UNIXTimer_Pause(), UNIXTimer_Unpause()
* unpause
* sync
*/
/*
*
*
* ()
* static
*
*
*/
/* カラーマップ情報の出力 */
void wonx_print_colormap_data(void)
{
WWDisplay ww_display;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_colormap_data() : \n");
fflush(stdout);
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_colormap_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* パレット情報の出力用内部関数 */
static void _print_palette_data(int n)
{
WWDisplay ww_display;
WWPalette ww_palette;
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_palette = WWDisplay_GetPalette(ww_display, n);
WWPalette_PrintData(ww_palette, ww_display, stdout);
return;
}
/* パレット情報の出力 */
void wonx_print_palette_data(int n)
{
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_palette_data() : number = %d\n", n);
fflush(stdout);
if ((n < 0) || (n > 16 - 1))
WonX_Error("wonx_print_palette_data", "number is out of range.");
_print_palette_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_palette_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* すべてのパレット情報を出力 */
void wonx_print_all_palette_data(void)
{
int n;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_all_palette_data() : \n");
fflush(stdout);
for (n = 0; n < 16; n++) _print_palette_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_all_palette_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* キャラクタ情報の出力用内部関数 */
static void _print_character_data(int n)
{
WWDisplay ww_display;
WWCharacter ww_character;
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_character = WWDisplay_GetCharacter(ww_display, n);
WWCharacter_PrintData(ww_character, ww_display, stdout);
return;
}
/* キャラクタ情報の出力 */
void wonx_print_character_data(int n)
{
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_character_data() : number = %d\n", n);
fflush(stdout);
if ((n < 0) || (n > 512 - 1))
WonX_Error("wonx_print_character_data", "number is out of range.");
_print_character_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_character_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* すべてのキャラクタ情報を出力 */
void wonx_print_all_character_data(void)
{
int n;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_all_character_data() : \n");
fflush(stdout);
for (n = 0; n < 512; n++) _print_character_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_all_character_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* スプライト情報の出力用内部関数 */
static void _print_sprite_data(int n)
{
WWDisplay ww_display;
WWSprite ww_sprite;
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_sprite = WWDisplay_GetSprite(ww_display, n);
WWSprite_PrintData(ww_sprite, stdout);
return;
}
/* スプライト情報の出力 */
void wonx_print_sprite_data(int n)
{
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_sprite_data() : number = %d\n", n);
fflush(stdout);
if ((n < 0) || (n > 128 - 1))
WonX_Error("wonx_print_sprite_data", "number is out of range.");
_print_sprite_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_sprite_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* すべてのスプライト情報を出力 */
void wonx_print_all_sprite_data(void)
{
int n;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_all_sprite_data() : \n");
fflush(stdout);
for (n = 0; n < 128; n++) _print_sprite_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_all_sprite_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* 現在の表示/非表示のレベルの取得.(1以上で表示0以下で非表示) */
int wonx_get_lcddraw_level(void)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_get_lcddraw_level() : \n");
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_GetLCDDrawLevel(x_display);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_get_lcddraw_level() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/* 現在の表示/非表示のレベルの設定 */
int wonx_set_lcddraw_level(int level)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_set_lcddraw_level() : level = %d\n", level);
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_SetLCDDrawLevel(x_display, level);
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : wonx_set_lcddraw_level() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/* 表示レベルを下げる */
int wonx_lcddraw_level_down(void)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_lcddraw_level_down() : \n");
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_LCDDrawLevelDown(x_display);
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : wonx_lcddraw_level_down() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/* 表示レベルを上げる */
int wonx_lcddraw_level_up(void)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_lcddraw_level_up() : \n");
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_LCDDrawLevelUp(x_display);
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : wonx_lcddraw_level_up() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

View File

@ -7,7 +7,7 @@
* fcntl.h /usr/include/fcntl.h * fcntl.h /usr/include/fcntl.h
* *
* #include <fcntl.h> * #include <fcntl.h>
* -Iwonx_include * -Iwonx
* *
* #include </usr/include/fcntl.h> * #include </usr/include/fcntl.h>
* /usr/include * /usr/include
@ -29,4 +29,14 @@
#include </usr/include/fcntl.h> #include </usr/include/fcntl.h>
#include </usr/include/sys/fcntl.h> #include </usr/include/sys/fcntl.h>
/*
* mmap() UNIX WonderWitch
* README
*/
#include </usr/include/stdio.h>
/* void * mmap(char * filename); */
void * wonx_mmap(char * filename);
/* #define wonx_mmap mmap */
#define mmap wonx_mmap
#endif #endif

43
wonx/wonx.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef _WONX_SYS_WONX_H_
#define _WONX_SYS_WONX_H_
#include "service.h"
/*****************************************************************************/
/* 外部に公開する WonX のサービス関数 */
/*****************************************************************************/
/* カラーマップ情報の出力 */
void wonx_print_colormap_data(void);
/* パレット情報の出力 */
void wonx_print_palette_data(int n);
/* すべてのパレット情報を出力 */
void wonx_print_all_palette_data(void);
/* キャラクタ情報の出力 */
void wonx_print_character_data(int n);
/* すべてのキャラクタ情報を出力 */
void wonx_print_all_character_data(void);
/* スプライト情報の出力 */
void wonx_print_sprite_data(int n);
/* すべてのスプライト情報を出力 */
void wonx_print_all_sprite_data(void);
/* 現在の表示/非表示のレベルの取得.(1以上で表示0以下で非表示) */
int wonx_get_lcddraw_level(void);
/* 現在の表示/非表示のレベルの設定 */
int wonx_set_lcddraw_level(int level);
/* 表示レベルを下げる */
int wonx_lcddraw_level_down(void);
/* 表示レベルを上げる */
int wonx_lcddraw_level_up(void);
#endif

View File

@ -3,13 +3,17 @@
#ifndef _WONX_wonx_configure_h_INCLUDED_ #ifndef _WONX_wonx_configure_h_INCLUDED_
#define _WONX_wonx_configure_h_INCLUDED_ #define _WONX_wonx_configure_h_INCLUDED_
#include "wonx_include/libwwc.h" #include "wonx/libwwc.h"
/* デフォルトのアーキテクチャ */ /* デフォルトのアーキテクチャ */
#define WONX_DEFAULT_ARCH HARDARCH_WSC #define WONX_DEFAULT_ARCH HARDARCH_WSC
/* WonX でのタイマ割り込みの周期(単位はミリ秒) */ /* WonX でのタイマ割り込みの周期(単位はミリ秒) */
#if 1
#define WONX_TIMER_INTERVAL 100 /* 0.1 秒 */ #define WONX_TIMER_INTERVAL 100 /* 0.1 秒 */
#else
#define WONX_TIMER_INTERVAL 1 /* デバッグ用(0.001 秒) */
#endif
/* HBLANK, VBLANK 割り込みのデフォルトのインターバル(0.1秒単位) */ /* HBLANK, VBLANK 割り込みのデフォルトのインターバル(0.1秒単位) */
#define WONX_HBLANK_INTERVAL ( 3 * 10) /* 3 秒毎 */ #define WONX_HBLANK_INTERVAL ( 3 * 10) /* 3 秒毎 */